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

Fixed submission:
import math
N = int(input())

nlist=[""]*N
d={}
for i in range(N):
    t=str(input())
    t=''.join(sorted(t))
    if d.get(t,None)==None:
        d[t]=1
    else:
        d[t]+=1 
ans=0

#print(d.keys(),d.values())
for i in d.values():
    ans += i*(i-1)/2
print(int(ans))

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

nlist=[""]*N

for i in range(N):
    t=str(input())
    t = ''.join(sorted(t))
    nlist[i] = t

sum=0
tsum=1
nlist=sorted(nlist)
tmpStr=nlist[0]
for i in range(1,N):
    if(tmpStr==nlist[i]):
        tsum+=1
    else:
        tmpStr=nlist[i]
        if(tsum!=1):
                sum+=math.factorial(tsum)/2
                tsum=1
if(tsum!=1):
        tmpStr=nlist[i]
        sum+=math.factorial(tsum)/2
        
print(int(sum))

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

nlist=[""]*N

for i in range(N):
    t=str(input())
    t = ''.join(sorted(t))
    nlist[i] = t

cnt=1
sum=0
tsum=1
nlist=sorted(nlist)
tmpStr=nlist[0]
for i in range(1,N):
    if(tmpStr==nlist[i]):
        tsum+=1
    else:
        tmpStr=nlist[i]
        sum+=math.factorial(tsum)/2
        tsum=1
if(tsum!=1):
        tmpStr=nlist[i]
        sum+=math.factorial(tsum)/2
        

print(int(sum))
Problem p02969 (python)

Fixed submission:
N = int(input())
print(3*N*N)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
ansList = []
for i in range(len(A),0,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)
print(len(ansList))

for i in ansList:
    print(i, end=" ")

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
sum=0
ansList = []
for i in range(len(A),0,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)
print(len(ansList))
for i in ansList:
    print(i, end=" ")
Problem p02972 (python)

Fixed submission:
import math as math

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
for i in range(math.floor(N/2)+1,N):
    ANS[i] = A[i]

fnum=math.floor(N/2)
for i in range(fnum,-1,-1):
    j = i + 1
    tsum=A[i]
    for k in range(j,N+1,j):
        tsum+=ANS[k-1]
    ANS[i]=tsum%2

#print(ANS)
anslist=[]
for i in range(N):
    if ANS[i]==1:
        anslist.append(i+1)
 
print(len(anslist))
for s in anslist:
    print(s, end =" ")

Buggy submission (verdict: Runtime Error):
import math as math

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
for i in range(math.ceil(N/2)+1,N):
    ANS[i] = A[i]

fnum=math.ceil(N/2)
for i in range(fnum,-1,-1):
    j = i + 1
    tsum=A[i]
    for k in range(j,N+1,j):
        tsum+=ANS[k-1]
    ANS[i]=tsum%2

#print(ANS)
anslist=[]
for i in range(N):
    if ANS[i]==1:
        anslist.append(i+1)
 
print(len(anslist))
for s in anslist:
    print(s, end =" ")
Problem p02983 (python)

Fixed submission:
import math
L, R = map(int, input().split())
R=min(R,L+2019)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)

Buggy submission (verdict: Runtime Error):
import heapq
L,R = map(int,input().split())
numMap=[10**19]*(R-L+1)
numheap=[]
k=0

AnsA=0
AnsB=0
for i in range(L,R+1):
    num=i%2019
    heapq.heappush(numheap,num)
    if(num==3):AnsA=1
    if(num==673):AnsB=1
    k+=1

if(AnsA!=0 & AnsB!=0):
    print("0")
else:
    print(heapq.heappop(numheap)*heapq.heappop(numheap))

Buggy submission (verdict: Runtime Error):
import heapq
L,R = map(int,input().split())
numMap=[10**19]*(R-L+1)
numheap=[]
k=0

AnsA=0
AnsB=0
for i in range(L,R+1):
    heapq.heappush(numheap,i%2019)
    if(numMap[k]==3):AnsA=i
    if(numMap[k]==673):AnsB=i
    k+=1

if(AnsA!=0 & AnsB!=0):
    print("0")
else:
    print(heapq.heappop(numheap)*heapq.heappop(numheap))
Problem p02995 (python)

Fixed submission:
a,b,c,d = map(int,input().split(" "))
def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = c*d
lcm = prod//gcd(c,d)
a1=b//c - (a-1)//c
a2=b//d - (a-1)//d
a3=b//lcm-(a-1)//lcm
print(b-a+1-a1-a2+a3)

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-=1

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm(C,D))
BCD=int(B/lcm(C,D))
A_=AC+AD-ACD
B_=BC+BD-BCD

print((B-B_)-(A-A_))

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-=1

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm(C,D))
BCD=int(B/lcm(C,D))
A_=AC+AD-ACD
B_=BC+BD-BCD

print((B-B_)-(A-A_))
Problem p03031 (python)

Fixed submission:
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int, input().split()))
q=[0]*11


ans=0
while(True):
    for i in range(n):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int,input().split()))
q=[0]*10


ans=0
for k in range(2*11):
    for i in range(n+1):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int,input().split()))
q=[0]*10


ans=0
while(True):
    for i in range(n+1):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1

    q[0]+=1

print(ans)
Problem p03095 (python)

Fixed submission:
n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input()+"")
#Dic={}
count=0
MOD = 10 ** 9 + 7

def ff(i,L):
    global count
    global MOD
    
    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1
        count %= MOD

ff(0,"")
print(count-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input()+"")
#Dic={}
count=0
MOD = 10 ** 9 + 7

def ff(i,L):
    global count
    global MOD
    
    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1
        count %= MOD

ff(0,"")
print(count-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input()+"")
#Dic={}
count=0

def ff(i,L):
    global count

    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1

ff(0,"")
print(count-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
#Dic={}
count=0

def ff(i,L):
    #global Dic
    global count

    if(len(S)>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        #Dic[L]=1
        count += 1

ff(0,"")
#print(len(Dic)-1)
print(count-1)

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

Dic={}

def ff(i,L):
    if(len(S)>i):
        ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        Dic[L]=1
ff(0,"")
print(len(Dic)-1)
Problem p03231 (python)

Fixed submission:
import fractions
import bisect

N,M = map(int,input().split())
S=input()
T=input()

A=(N//fractions.gcd(N,M))*M

NL=[0]*N
ML=[0]*M

for i in range(N):
    NL[i]=i*(A//N)


for i in range(M):
    ML[i]=i*(A//M)


ANDL = sorted(list(set(NL) & set(ML)))

for i in ANDL:
    St=bisect.bisect_left(NL,i)
    Tt=bisect.bisect_left(ML,i)
    if(S[St]!=T[Tt]):
        print("-1")
        exit()
print(A)

Buggy submission (verdict: Runtime Error):
import math
import bisect

N,M = map(int,input().split())
S=input()
T=input()

A=(N//math.gcd(N,M))*M

NL=[0]*N
ML=[0]*M

for i in range(N):
    NL[i]=i*(A//N)


for i in range(M):
    ML[i]=i*(A//M)


ANDL = sorted(list(set(NL) & set(ML)))

for i in ANDL:
    St=bisect.bisect_left(NL,i)
    Tt=bisect.bisect_left(ML,i)
    if(S[St]!=T[Tt]):
        print("-1")
        exit()
print(A)
Problem p03240 (python)

Fixed submission:
n = int(input())
a = [list(map(int, input().split(' '))) for i in range(n)]
for x in range(101):
    for y in range(101):
        for i in range(n):
            if a[i][2] > 0:
                htop = a[i][2] + abs(x-a[i][0]) + abs(y-a[i][1])
                break
        for i in range(n):
            if a[i][2] == 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) > 0:
                    break
            if a[i][2] > 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) != a[i][2]:
                    break
        else:
            print(x,y,htop)
            exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[0]*N    

for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

"""
if(N==1):
    print(A[0][0],A[0][1],A[0][2])
    exit()
H=0
x=0
y=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j
print(x,y,H)
"""
for cx in range(101):
    for cy in range(101):
        flag=True
        Hcand=-1
        for x,y,h in A:
            if h==0 and H>0:
                if H-abs(x-cx)-abs(y-cy)>0:
                    flag=False
                    break
            else:
                H= h+abs(x-cx)+abs(y-cy)
                if Hcand==-1:
                    Hcand=H
                else:
                    if Hcand!=H:
                        flag=False
                        break
        if flag:
            break
    if flag:
        break
print(cx,cy,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[0]*N

for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

H=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j

print(x,y,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[0]*N

for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

H=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j

print(x,y,H)
Problem p03262 (python)

Fixed submission:
import fractions
N, M = map(int, input().split())
X = list(map(int, input().split()))

Y=[0]*N

for i in range(N):
    Y[i]=abs(X[i]-M)

tmp=Y[0]
for i in range(N-1):
    tmp=fractions.gcd(tmp,Y[i+1])

print(tmp)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
X = list(map(int, input().split()))

Y=[0]*N

for i in range(N):
    Y[i]=abs(X[i]-M)

tmp=Y[0]
for i in range(N-1):
    tmp=math.gcd(tmp,Y[i+1])

print(tmp)
Problem p03319 (python)

Fixed submission:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = math.ceil((N-K) / (K - 1)) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

#print(A)
#print(A.index(min(A)))
m=min(A)
a=A.index(m)

i=a
tmp=0
while(i<N):
    while(A[i]==m):
        if(i>=N):
            break
        i+=1
    if(i>=N):
        break
    #for k in range(K-1):
        #A[i+k]=m
    tmp+=1
    i+=K-1

tmp+=math.ceil(a/(K-1))

print(tmp)
Problem p03363 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)

nCr = {}
def cmb(n, r):
    if n == 1: return 0
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


N=int(input())
a=list(map(int,input().split()))

L=[0]
s=0
for i in range(N):
    s+=a[i]
    L.append(s)

L=sorted(L)

s=0
t=L[0]
c=1
for i in range(1,len(L)):
    if(t==L[i]):
        c+=1
    else:
        s+=cmb(c,2)
        t=L[i]
        c=1
else:
    s+=cmb(c,2)
print(s)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

nCr = {}
def cmb(n, r):
    if n == 1: return 0
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


N=int(input())
a=list(map(int,input().split()))

L=[0]
s=0
for i in range(N):
    s+=a[i]
    L.append(s)

L=sorted(L)

s=0
t=L[0]
c=1
for i in range(1,len(L)):
    if(t==L[i]):
        c+=1
    else:
        s+=cmb(c,2)
        t=L[i]
        c=1
else:
    s+=cmb(c,2)
print(s)

Buggy submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if n == 1: return 0
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


N=int(input())
a=list(map(int,input().split()))

L=[0]
s=0
for i in range(N):
    s+=a[i]
    L.append(s)

L=sorted(L)

s=0
t=L[0]
c=1
for i in range(1,len(L)):
    if(t==L[i]):
        c+=1
    else:
        s+=cmb(c,2)
        t=L[i]
        c=1
else:
    s+=cmb(c,2)
print(s)
Problem p03380 (python)

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

A=sorted(A)
maxA=max(A)
limit=maxA/2
tmp=10**9
for i in range(N):
    if(abs(limit-A[i])<tmp):
        tmp=abs(limit-A[i])
        comb=A[i]
    else:
        break

print(maxA,comb)

Buggy submission (verdict: Runtime Error):
import math

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

A=sorted(A)
maxA=max(A)
limit=math.ceil(maxA/2)
comb=min(A)
for i in range(N):
    if(limit<A[i]):
        if(abs(limit-A[i+1])<abs(limit-A[i])):
            comb=A[i+1]
        break
    comb=A[i]

print(maxA,comb)

Buggy submission (verdict: Runtime Error):
import math

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

A=sorted(A)
maxA=max(A)
limit=math.ceil(maxA/2)
comb=min(A)
for i in range(N):
    if(limit<A[i]):
        if(abs(limit-A[i+1])<abs(limit-A[i])):
            comb=A[i+1]
    comb=A[i]

print(maxA,comb)
Problem p03393 (python)

Fixed submission:
s=input()
alp="".join([chr(i) for i in range(97,97+26)])
if len(s)<26:
    for i in alp:
        if i not in s:
            print(s+i)
            exit()
else:
    if s=="".join([chr(i) for i in range(97,97+26)][::-1]):
        print(-1)
        exit()
    else:
        for i in range(24,-1,-1):
            for j in range(25,i,-1):
                if s[i]<s[j]:
                    print(s[:i]+s[j])
                    exit()

Buggy submission (verdict: Runtime Error):
M=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
O=input()
S=list(O)

if(len(O)!=26):
    for i in range(26):
        if(M[i] not in S):
            print(O,M[i],sep="")
            exit()

for i in range(24,-1,-1):
    for j in range(25,i,-1):
        if S[i]<S[j]:
            print(S[:i]+S[j])
            exit()

print(-1)
Problem p03420 (python)

Fixed submission:
N,K=map(int,input().split())
#N=10
#K=0
s=0

if(K==0):
    print(N**2)
    exit()

for b in range(K,N+1):
    s+=(b-K)*(N//b)
    s+=max(0,N-b*(N//b)-K+1)

print(s)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
#N=352
#K=54
s=0

for b in range(K,N+1):
    s+=(b-K)*(N//b)
    s+=max(0,N-b*(N//b)-K+1)

print(s)
Problem p03475 (python)

Fixed submission:
N=int(input())
C=[0]*N
S=[0]*N
F=[0]*N

for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())

def calc(n):
    t=0
    for i in range(n,N-1):
        if(t<S[i]):
            t=S[i]
        if(t%F[i]!=0):
            t+=(F[i]-t%F[i])
        t+=C[i]
    print(t)


for i in range(N):
    calc(i)

Buggy submission (verdict: Runtime Error):
N=int(input())
C=[0]*N
S=[0]*N
F=[0]*N

for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())

def calc(n):
    t=0
    for i in range(n,N-1):
        if(t<S[i]):
            t=S[i]
        t+=t%F[i]
        t+=C[i]
    print(t)


for i in range(N):
    calc(i)
Problem p03523 (python)

Fixed submission:
S=input()
T="AKIHABARA"
c=0
t=0
while(True):
    if(len(S)==c):
        if(T[t]=="A"):
            t+=1
        else:
            print("NO")
            exit()
    elif(S[c]==T[t]):
        c+=1
        t+=1
    else:
        if(T[t]=="A"):
            t+=1
        else:
            print("NO")
            exit()
    if(len(S)==c and t==9):
        print("YES")
        exit()
    elif(t==9):
        print("NO")
        exit()

Buggy submission (verdict: Runtime Error):
S=input()
T="AKIHABARA"
c=0
t=0
while(True):
    if(len(S)==c):
        if(T[t]=="A"):
            t+=1
        else:
            print("NO")
            exit()
    elif(S[c]==T[t]):
        c+=1
        t+=1
    else:
        if(T[t]=="A"):
            t+=1
        else:
            print("NO")
            exit()
    if(len(S)==c and t==9):
        print("YES")
        exit()
Problem p03565 (python)

Fixed submission:
S = input()
T = input()
lenS=len(S)
lenT=len(T)
ans=["a"]*lenS
for i in range (lenS):
    if(S[i]!="?"):
        ans[i]=S[i]
flag=0
for j in range(lenS-lenT+1):
    flag=1
    for i in range (lenS):
        if(S[i]=="?"):
            ans[i]="a"

    for i in range(1,lenT+1):
        if((S[lenS-i-j]!="?")&(S[lenS-i-j]!=T[lenT-i])):
            flag=0
            break
        else:
            ans[lenS-i-j]=T[lenT-i]
    
    if(flag==1):
        break

if(flag==1):
    print("".join(ans))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
lenS=len(S)
lenT=len(T)
ans=["a"]*lenS
for i in range (lenS):
    if(S[i]!="?"):
        ans[i]=S[i]

for j in range(lenS-lenT):
    flag=1
    for i in range (lenS):
        if(S[i]=="?"):
            ans[i]="a"

    for i in range(1,lenT+1):
        if((S[lenS-i-j]!="?")&(S[lenS-i-j]!=T[lenT-i])):
            flag=0
            break
        else:
            ans[lenS-i-j]=T[lenT-i]
    
    if(flag==1):
        break

if(flag==1):
    print("".join(ans))
else:
    print("UNRESTORABLE")
Problem p03583 (python)

Fixed submission:
#N=3485
#A=[ 32, 1, 87, 25, 36]
N=int(input())


for i in range(1,3501):
    for j in range(1,3501):
        u=-N*i*j
        d=N*i+N*j-4*i*j
        if(d!=0):
            if(u%d==0 and (u*d > 0)):
                k=u//d
                if(N*(i*j+j*k+k*i)==4*i*j*k):
                    print(i,j,k)
                    exit()

Buggy submission (verdict: Runtime Error):
#N=3485
#A=[ 32, 1, 87, 25, 36]
N=int(input())


for i in range(1,3501):
    for j in range(1,3501):
        u=-N*i*j
        d=N*i+N*j-4*i*j
        if(u%d==0 and (u*d > 0)):
            k=u//d
            if(N*(i*j+j*k+k*i)==4*i*j*k):
                print(i,j,k)
                exit()

Buggy submission (verdict: Runtime Error):
#N=3485
#A=[ 32, 1, 87, 25, 36]
N=int(input())


for i in range(1,3501):
    for j in range(1,3501):
        u=-N*i*j
        d=N*i+N*j-4*i*j
        if(u%d==0 and (u*d > 0)):
            k=u//d
            if(N*(i*j+j*k+k*i)==4*i*j*k):
                print(i,j,k)
                exit()
Problem p03607 (python)

Fixed submission:
import collections

N = int(input())

List = {}
for i in range(N):
    A = int(input())
    if List.get(A,None)==None:
        List[A]=1
    else:
        del List[A]

c = collections.Counter(List)

print(len(c))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())

List = {}
for i in range(N):
    A = int(input())
    if List.get(A,None)==None:
        List[A]=1
    else:
        del List[A]

c = collections.Counter(List)
if(c.most_common(1)[0][1]==0):
    print(0)
    exit()

print(len(c))
Problem p03639 (python)

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

odd=0
even=0
even2=0

for num in A:
    if(num%2==1):
        odd+=1
    elif(num%4==0):
        even2+=1
    else:
        even+=1

if(even2>=odd):
    print("Yes")
elif((even==0)&(even2==(odd-1))):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
for i in range(N):
    A += [i + 1] * a[i]
 
L = [[0 for i in range(W)] for j in range(H)]
for i in range(H * W):
    if int((i // W)) % 2 == 0:
        L[int((i // W))][i % W] = A[i]
    else:
        L[int((i // W))][-1 - i % W] = A[i]
 
for i in range(H):
    L[i] = list(map(str, L[i]))
 
 
for i in range(H):
    print(" ".join(L[i]))
Problem p03645 (python)

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

L=[[0]*2 for i in range(M)]

for i in range(M):
    L[i][0] , L[i][1] = map(int, input().split())

A=[0]*M
B=[0]*M

L=sorted(L ,key=lambda x: x[0])

for i in range(M):
    if L[i][0] == 1:
        A[i]=L[i][1]
    else:
        break
A=A[0:i]

L=sorted(L ,key=lambda x: -x[1])

for i in range(M):
    if L[i][1] == N:
        B[i]=L[i][0]
    else:
        break
B=B[0:i]

if((len(A)==0)or(len(B)==0)):
    print("IMPOSSIBLE")
    exit()
if((max(A)<min(B))or(max(B)<min(A))):
    print("IMPOSSIBLE")
    exit()

A.sort()
B.sort()
i=0
j=0
while((i<len(A))and(j<len(B))):
    if A[i] == B[j]:
        print("POSSIBLE")
        exit()
    elif A[i] > B[j]:j+=1
    else:i+=1
print("IMPOSSIBLE")

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

L=[[0]*2 for i in range(M)]

for i in range(M):
    L[i][0] , L[i][1] = map(int, input().split())

A=[0]*M
B=[0]*M

L=sorted(L ,key=lambda x: x[0])

for i in range(M):
    if L[i][0] == 1:
        A[i]=L[i][1]
    else:
        break
A=A[0:i]

L=sorted(L ,key=lambda x: -x[1])

for i in range(M):
    if L[i][1] == N:
        B[i]=L[i][0]
    else:
        break
B=B[0:i]

if((max(A)<min(B))or(max(B)<min(A))):
        print("IMPOSSIBLE")
        exit()

for i in B:
    if i == 10**10 : 
        print("IMPOSSIBLE")
        exit()
    if i in A:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Problem p03695 (python)

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

c = [0] * 9

for rate in a:
    i = rate // 400
    if i < 8:
        c[i] = 1
    else:
        c[8] += 1

c_sum = sum(c[:8])
c_min = max(c_sum, min(c[8],1))
c_max = c_sum + c[8]

print(c_min, c_max)

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

D=[0]*9
for s in S:
    s//=400
    D[s]+=1
c=0
for i in range(8):
    if(D[i]==0):
        c+=1
print(8-c,8-c+min(c,D[8]))