ZhenlongDai/ACPR huggingface dataset:
Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))
a.sort()
print( 'YES' if a == [1,9,7,4] else 'NO' )


Failing test case input:
1 9 7 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
a = list(map(int,input().split()))
a.sort()
print( 'YES' if a == [1,4,7,9] else 'NO' )

Problem: p03149
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
out=["No","Yes"]
print(out[sorted(list(map(int,input().split())))==[1,4,7,9]])

Failing test case input:
1 9 13 4

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
out=["NO","YES"]
print(out[sorted(list(map(int,input().split())))==[1,4,7,9]])

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
get=input()
flg=0
for a in get.split():
  if int(a) in [1,9,7,4]:
    flg=+1
    
if flg==3:
  print("YES")
else:
  print("NO")

Failing test case input:
1 9 7 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
get=input()
get = get.split(" ")
flg=0
get=list(set(get))
for a in get:
  if int(a) in[1,9,7,4]:
    flg+=1
    
if flg==4:
  print("YES")
else:
  print("NO")

Problem: p03149
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=list(map(int,input().split()))
n.sort()
if n==['1','4','7','9']:
  print('YES')
else:
  print('NO')


Failing test case input:
1 7 9 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n=list(map(int,input().split()))
n.sort()
if n==[1,4,7,9]:
  print('YES')
else:
  print('NO')

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
list =input().split() 
var=[]
for a in list:
  a = int(a)
  var.append(a)
flg = False

if 1 in var:
    if 9 in var:
        if 7 in var:
             if 4 in var:
                 flg = True
if flg:
    print("YES")
else:
    print("NO")
    print(list)

Failing test case input:
0 2 -1 0

Expected output:
NO


Actual output:
NO
['0', '2', '-1', '0']


Fixed submission (verdict: Accepted):
list =input().split() 
var=[]
for a in list:
  a = int(a)
  var.append(a)
flg = False

if 1 in var:
    if 9 in var:
        if 7 in var:
             if 4 in var:
                 flg = True
if flg:
    print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = input().split()

if '1' in n and '9' in n and '7' in n and '4' in n:
  print('Yes')
else:
  print('No')


Failing test case input:
1 19 0 0

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):

n = input().split()

if '1' in n and '9' in n and '7' in n and '4' in n:
  print('YES')
else:
  print('NO')

Problem: p03149
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
print("YES" if sorted(input())=='1479' else "NO")

Failing test case input:
1 7 9 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
print("YES" if "".join(sorted(input().split()))=='1479' else "NO")
Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = list(map(int,input().split()))
N.sort()
print("Yes" if N[0]*1000+N[1]*100+N[2]*10+N[3] == 1479 else "No")


Failing test case input:
1 3 13 -1

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
N = list(map(int,input().split()))
N.sort()
print("YES" if N[0]*1000+N[1]*100+N[2]*10+N[3] == 1479 else "NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print("YNEOS"["".join(sorted(list(input())))!="1479"::2])

Failing test case input:
1 9 7 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
print("YNEOS"["".join(sorted(list(input().split())))!="1479"::2])

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(map(int,input().split()))
if "1" in n and "9" in n and "7" in n and "4" in n:
    print("YES")
else:
    print("NO")

Failing test case input:
1 9 7 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = list(map(int,input().split()))
if 1 in n and 9 in n and 7 in n and 4 in n:
    print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input().split()
N = "".join(sorted(N))

if N == "1479":
    print("Yes")
else:
    print("No")

Failing test case input:
1 12 9 4

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
N = input().split()
N = "".join(sorted(N))

if N == "1479":
    print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = set(map(int,input().split()))
print('YNeos'[n!={1,9,7,4}::2])

Failing test case input:
-1 10 1 -2

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
n = set(map(int,input().split()))
print('YNEOS'[n!={1,9,7,4}::2])

Problem: p03149
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

n=list(map(int,input().split()))
if ('1' in n) and ('9' in n) and ('7' in n) and ('4' in n):
    print('YES')
else:
    print('NO')

Failing test case input:
1 7 9 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):

n=list(map(int,input().split()))
if (1 in n) and (9 in n) and (7 in n) and (4 in n):
    print('YES')
else:
    print('NO')

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
get=input()
flg=0
print(get.split(" "))
print(get.split())
for a in get.split(" "):
  if int(a) in[1,9,7,4]:
    flg+=1
    
print(flg)
if flg==4:
  print("YES")
else:
  print("NO")

Failing test case input:
-2 12 2 -2

Expected output:
NO


Actual output:
['-2', '12', '2', '-2']
['-2', '12', '2', '-2']
0
NO


Fixed submission (verdict: Accepted):
get=input()
get = get.split(" ")
flg=0
get=list(set(get))
for a in get:
  if int(a) in[1,9,7,4]:
    flg+=1
    
if flg==4:
  print("YES")
else:
  print("NO")
Problem: p03149
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
if sys.platform =='ios':
	sys.stdin=open('input.txt')
	
l = list(map(int,input().split()))

l.sort()

print(''.join(list(map(str, l))))

if ''.join(list(map(str, l)))=='1479':
	print('YES')
else:
	print('NO')


Failing test case input:
-1 2 13 -1

Expected output:
NO


Actual output:
-1-1213
NO


Fixed submission (verdict: Accepted):
import sys
if sys.platform =='ios':
	sys.stdin=open('input.txt')

l = list(map(int,input().split()))

l.sort()



if ''.join(list(map(str, l)))=='1479':
	print('YES')
else:
	print('NO')

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input().split()
a = [int(m) for m in a]
a = set(a)
b = [1, 9, 7, 4]
b = set(b)
if len(a & b) == 4:
    print("Yes")
else:
    print("No")

Failing test case input:
0 2 1 1

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a = input().split()
a = [int(m) for m in a]
a = set(a)
b = [1, 9, 7, 4]
b = set(b)
if len(a & b) == 4:
    print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = list(map(int, input().split()))
print("Yes" if len(set(N)) == 4 and 1 in N and 9 in N and 7 in N and 4 in N else "No")

Failing test case input:
0 0 -1 23

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
N = list(map(int, input().split()))
print("YES" if len(set(N)) == 4 and 1 in N and 9 in N and 7 in N and 4 in N else "NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = list(map(int,input().split()))
a = A.count('1')
b = A.count('7')
c = A.count('9')
d = A.count('4')
if a == b == c == d == 1:
  print('YES')
else:
  print('NO')

Failing test case input:
1 9 7 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
A = list(map(str,input().split()))
a = A.count('1')
b = A.count('7')
c = A.count('9')
d = A.count('4')
if a == b == c == d == 1:
  print('YES')
else:
  print('NO')

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n1,n2,n3,n4 = map(int,input().split())

if n1==1 or n2==1 or n3==1 or n4==1:
  if n1==7 or n2==7 or n3==7 or n4==7:
    if n1==9 or n2==9 or n3==9 or n4==9:
      if n1==4 or n2==4 or n3==4 or n4==4:
        print("Yes")
      else:
        print("No")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Failing test case input:
0 2 -1 7

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
n1,n2,n3,n4 = map(int,input().split())
 
if n1==1 or n2==1 or n3==1 or n4==1:
  if n1==7 or n2==7 or n3==7 or n4==7:
    if n1==9 or n2==9 or n3==9 or n4==9:
      if n1==4 or n2==4 or n3==4 or n4==4:
        print("YES")
      else:
        print("NO")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")
Problem: p03149
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n1, n2, n3, n4 = input().split()
if {n1, n2, n3, n4} == {1, 9, 7, 4}:
  print("YES")
else:
  print("NO")

Failing test case input:
1 7 9 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n1, n2, n3, n4 = map(int, input().split())
if {n1, n2, n3, n4} == {1, 9, 7, 4}:
  print("YES")
else:
  print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
l = map(int, input().split())
list = [1, 4, 7, 9]
flg = True
for num in list:
  if(num in l):    
    pass
  else:
    flg = False
if(flg):
	print("YES")
else:
    print("NO")

Failing test case input:
1 7 9 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
l = list(map(int, input().split()))
list = [1, 4, 7, 9]
flg = True
for num in list:
  if(num in l):    
    pass
  else:
    flg = False
if(flg):
	print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input().split()
N = "".join(sorted(N))

if N == "1479":
    print("YES")
else:
    print("N0")

Failing test case input:
0 2 -1 -1

Expected output:
NO


Actual output:
N0


Fixed submission (verdict: Accepted):
N = input().split()
N = "".join(sorted(N))

if N == "1479":
    print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input().split()
if "1" and "7" and "9" and "4" in S:
  print("Yes")
else:
  print('No')


Failing test case input:
2 19 0 1

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
S=input().split()
if ("1" in S) and ("9" in S) and ("7" in S) and ("4" in S):
  print("YES")
else:
  print('NO')
Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

num = input()

num1 = num[0]
num2 = num[1]
num3 = num[2]
num4 = num[3]

strTarget = "1974"
isCheck1 = False
isCheck2 = False
isCheck3 = False
isCheck4 = False

isValidation1 = num1 in strTarget
if isValidation1 :
    strTarget = strTarget.replace(num1,"")
    isCheck1 = True

isValidation2 = num2 in strTarget
if isValidation2 :
    strTarget = strTarget.replace(num2,"")
    isCheck2 = True

isValidation3 = num3 in strTarget
if isValidation3 :
    strTarget = strTarget.replace(num3,"")
    isCheck3 = True

isValidation4 = num4 in strTarget
if isValidation4 :
    strTarget = strTarget.replace(num4,"")
    isCheck4 = True

if isCheck1 and isCheck2 and isCheck3 and isCheck4:
    print("YES")
else:
    print("NO")


Failing test case input:
1 9 7 4

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
import sys








num1, num2, num3, num4 = (int(i) for i in input().split())

num1 = str(num1)
num2 = str(num2)
num3 = str(num3)
num4 = str(num4)


strTarget = "1974"
isCheck1 = False
isCheck2 = False
isCheck3 = False
isCheck4 = False

isValidation1 = num1 in strTarget
if isValidation1 :
    strTarget = strTarget.replace(num1,"")
    isCheck1 = True

isValidation2 = num2 in strTarget
if isValidation2 :
    strTarget = strTarget.replace(num2,"")
    isCheck2 = True

isValidation3 = num3 in strTarget
if isValidation3 :
    strTarget = strTarget.replace(num3,"")
    isCheck3 = True

isValidation4 = num4 in strTarget
if isValidation4 :
    strTarget = strTarget.replace(num4,"")
    isCheck4 = True

if isCheck1 and isCheck2 and isCheck3 and isCheck4:
    print("YES")
else:
    print("NO")

Problem: p03149
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n1,n2,n3,n4=map(int,input().split())
t=[n1,n2,n3,n4]
t.sort()
print(t)
if t[0]==1 and t[1]==4 and t[2]==7 and t[3]==9:
  print("YES")
else:
  print("NO")

Failing test case input:
2 1 1 1

Expected output:
NO


Actual output:
[1, 1, 1, 2]
NO


Fixed submission (verdict: Accepted):
n1,n2,n3,n4=map(int,input().split())
t=[n1,n2,n3,n4]
t.sort()
if t[0]==1 and t[1]==4 and t[2]==7 and t[3]==9:
  print("YES")
else:
  print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = set(map(int, input().split()))
if a == set([1,9,7,4]):
  print("Yes")
else:
  print("No")

Failing test case input:
-1 1 -1 23

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a = set(map(int, input().split()))
if a == set([9,1,7,4]):
  print("YES")
else:
  print("NO")

Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(map(int, input().split()))
n.sort()
print('Yes') if n==[1, 4, 7, 9] else print('No')

Failing test case input:
-1 12 2 -2

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
n = list(map(int, input().split()))
n.sort()
print('YES') if n==[1, 4, 7, 9] else print('NO')
Problem: p03149
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=list(map(int,input().split()))
b=[1,7,9,4]
c=[0]*4
d=[True,True,True,True]

for i in range(4):
    c[i]=(b[i] in a)
if c==d:
  print("Yes")
else:
  print("No")
  

Failing test case input:
0 2 -2 0

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a=list(map(int,input().split()))
b=[1,7,9,4]
c=[0]*4
d=[True,True,True,True]

for i in range(4):
    c[i]=(b[i] in a)
if c==d:
  print("YES")
else:
  print("NO")
Problem: p02446
Buggy submission (Python3, verdict: Wrong Answer):


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

print(' '.join(map(str, set(A))))



Failing test case input:
4
-1 0 2 8

Expected output:
-1 0 2 8


Actual output:
0 8 2 -1


Fixed submission (verdict: Accepted):


N = int(input())
A = list(map(int, input().split()))
A = list(set(A))
A.sort()
print(' '.join(map(str, A)))

Problem: p02446
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split(' ')))

a = list(set(a))
print(' '.join(list(map(str, a))))


Failing test case input:
4
-3 0 1 1

Expected output:
-3 0 1


Actual output:
0 1 -3


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

a = sorted(set(a))
print(' '.join(list(map(str, a))))
Problem: p00012
Buggy submission (Python3, verdict: Wrong Answer):
def Cramer(a11, a12, a13, a21, a22, a23):
	den = a11 * a22 - a12 * a21
	return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
		u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
		print('YES' if u >= 0.0 and v >= 0.0 and abs(u + v - 1.0) < 1e10 else 'NO')
	except EOFError:
		break

Failing test case input:
36.31193334159785 26.68885046655779 25.404736254982996 25.948334220523957 34.34911114264862 29.996135988874197 33.66991406586279 30.252233534945287
29.325525259168447 29.32558252598376 27.727604699668394 30.869993684555826 30.33189309116999 40.41549983040785 29.72292961892185 35.213230542063535

Expected output:
NO
YES


Actual output:
YES
YES


Fixed submission (verdict: Accepted):
def Cramer(a11, a12, a13, a21, a22, a23):
	den = a11 * a22 - a12 * a21
	return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
		u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
		print('YES' if u >= 0.0 and v >= 0.0 and u + v <= 1.0 else 'NO')
	except EOFError:
		break

Problem: p00012
Buggy submission (Python3, verdict: Wrong Answer):
def Cramer(a11, a12, a13, a21, a22, a23):
	den = a11 * a22 - a12 * a21
	return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
		u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
		print('YES' if u >= 0.0 and v >= 0.0 and u + v - 1.0 < 1e10 else 'NO')
	except EOFError:
		break

Failing test case input:
36.31193334159785 26.68885046655779 25.404736254982996 25.948334220523957 34.34911114264862 29.996135988874197 33.66991406586279 30.252233534945287
29.325525259168447 29.32558252598376 27.727604699668394 30.869993684555826 30.33189309116999 40.41549983040785 29.72292961892185 35.213230542063535

Expected output:
NO
YES


Actual output:
YES
YES


Fixed submission (verdict: Accepted):
def Cramer(a11, a12, a13, a21, a22, a23):
	den = a11 * a22 - a12 * a21
	return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
		u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
		print('YES' if u >= 0.0 and v >= 0.0 and u + v <= 1.0 else 'NO')
	except EOFError:
		break
Problem: p00012
Buggy submission (Python3, verdict: Wrong Answer):
import math

def tri(x1, y1, x2, y2, x3, y3):
    return math.fabs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2

while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    abc = tri(x1, y1, x2, y2, x3, y3)
    abp = tri(x1, y1, x2, y2, xp, yp)
    acp = tri(x1, y1, x3, y3, xp, yp)
    bcp = tri(x2, y2, x3, y3, xp, yp)
    print("YES" if abc>=abp+acp+bcp else "NO")

Failing test case input:
3.0967642423291464 1.395143496555999 5.834707046140525 3.427004622356066 6.537989778576204 5.069269451882277 4.409212802398131 2.544605964753835
1.8563321983852392 2.2255272168590903 6.060583681050312 7.319953900081695 6.67378142752105 5.524119961039338 2.450630988873168 10.007403341575518

Expected output:
YES
NO


Actual output:
NO
NO


Fixed submission (verdict: Accepted):
import math

def tri(x1, y1, x2, y2, x3, y3):
    return math.fabs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2

while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    abc = tri(x1, y1, x2, y2, x3, y3)
    abp = tri(x1, y1, x2, y2, xp, yp)
    acp = tri(x1, y1, x3, y3, xp, yp)
    bcp = tri(x2, y2, x3, y3, xp, yp)
    x, y = int(abc*pow(10, 5)), int((abp+acp+bcp)*pow(10, 5))
    print("YES" if x >= y else "NO")

Problem: p00012
Buggy submission (Python3, verdict: Wrong Answer):
def f(x):
    x1, y1, x2, y2, x3, y3, xp, yp = x
    ax = x3 - x1
    ay = y3 - y1
    bx = x2 - x1
    by = y2 - y1
    k = (by * xp - bx * yp) / (ax * by - ay * bx)
    l = (ay * xp - ax * yp) / (ay * bx - ax * by)
    if (k > 0 and l > 0 and k + l < 1):
        print('YES')
    else:
        print('NO')
while True:
    try:
        point = list(map(float, input().split()))
        f(point)
    except EOFError:
        break



Failing test case input:
3.0967642423291464 1.395143496555999 5.834707046140525 3.427004622356066 6.537989778576204 5.069269451882277 4.409212802398131 2.544605964753835
1.8563321983852392 2.2255272168590903 6.060583681050312 7.319953900081695 6.67378142752105 5.524119961039338 2.450630988873168 10.007403341575518

Expected output:
YES
NO


Actual output:
NO
NO


Fixed submission (verdict: Accepted):
def f(x):
    x1, y1, x2, y2, x3, y3, xp, yp = x
    ax = x3 - x1
    ay = y3 - y1
    bx = x2 - x1
    by = y2 - y1
    xp -= x1
    yp -= y1
    k = (by * xp - bx * yp) / (ax * by - ay * bx)
    l = (ay * xp - ax * yp) / (ay * bx - ax * by)
    if (k > 0 and l > 0 and k + l < 1):
        print('YES')
    else:
        print('NO')
while True:
    try:
        point = list(map(float, input().split()))
        f(point)
    except EOFError:
        break
Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = 0
for i in range(1,n):
    ans = min(ans,sum(map(int,str(i)))+sum(map(int,str(n-i))))
print(ans)

Failing test case input:
1697

Expected output:
23


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
ans = float("inf")
for i in range(1,n):
    ans = min(ans,sum(map(int,str(i)))+sum(map(int,str(n-i))))
print(ans)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()

if int(n) % 10 == 0:
  print(10)
else:
  res = 0
  for i in n:
  	res += int(n)
  print(n)


Failing test case input:
795

Expected output:
21


Actual output:
795


Fixed submission (verdict: Accepted):
n = input()

if int(n) % 10 == 0:
  print(10)
else:
  res = 0
  for i in n:
  	res += int(i)
  print(res)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=[int(i) for i in input().split()]
s=sum(n)
if s==1 and min(n)==0:
  print(10)
else:
  print(s)

Failing test case input:
234

Expected output:
9


Actual output:
234


Fixed submission (verdict: Accepted):
n=[int(i) for i in list(input())]
s=sum(n)
if s==1 and min(n)==0:
  print(10)
else:
  print(s)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



def read_h(typ=int):
    return map(typ, input().split())


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def digit_sum(i):
    return sum([int(d) for d in str(i)])


def main():
    n, = read_h()
    ans = 10000
    for a in range(1, n):
        b = n - a
        s = digit_sum(a) + digit_sum(b)
        if s < ans:
            print(a, b)
            ans = s

    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
471

Expected output:
12


Actual output:
1 470
12


Fixed submission (verdict: Accepted):



def read_h(typ=int):
    return map(typ, input().split())


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def digit_sum(i):
    return sum([int(d) for d in str(i)])


def main():
    n, = read_h()
    ans = 10000
    for a in range(1, n):
        b = n - a
        s = digit_sum(a) + digit_sum(b)
        if s < ans:
            ans = s

    print(ans)


if __name__ == '__main__':
    main()

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 15
for i in range(1,N):
    A,B = 0,0
    A_str = list(str(i))
    B_str = list(str(N-i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B       
print(ans)

Failing test case input:
1697

Expected output:
23


Actual output:
15


Fixed submission (verdict: Accepted):
N = int(input())
ans = N
for i in range(1,N):
    A,B = 0,0
    A_str = list(str(i))
    B_str = list(str(N-i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B       
print(ans)
Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=input()
if int(N)%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
        print(ans)


Failing test case input:
234

Expected output:
9


Actual output:
2
5
9


Fixed submission (verdict: Accepted):
N=input()
if int(N)%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
    print(ans)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
sum = 0
if n[0] == "1" and n[1:-1]=="0"*(len(n)-1):
  print("10")
else:
  for i in range(len(n)):
    sum +=int(i)
  print(sum)

Failing test case input:
234

Expected output:
9


Actual output:
3


Fixed submission (verdict: Accepted):
n = input()
sum = 0
if n[0] == "1" and n[1:len(n)]=="0"*(len(n)-1):
  print("10")
else:
  for i in range(len(n)):
    sum +=int(n[i])
  print(sum)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
N = int(input())
n = N
amari = 0
for i in range (len(str(N))):
  amari += n % 10
  n = math.floor(n / 10)
if amari < 10:
  print(10+amari)
else:
  print(amari)

Failing test case input:
234

Expected output:
9


Actual output:
19


Fixed submission (verdict: Accepted):
import math
N = int(input())
n = N
amari = 0
for i in range (len(str(N))):
  amari += n % 10
  n = math.floor(n / 10)
if amari == 1:
  print(10)
else:
  print(amari)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math
n=int(input())-1
a=10**int(math.log10(n))
b=n-a+1
print(sum(map(int,str(a)))+sum(map(int,str(b))))
print(a,b)

Failing test case input:
1697

Expected output:
23


Actual output:
23
1000 697


Fixed submission (verdict: Accepted):

import math
n=int(input())-1
a=10**int(math.log10(n))
b=n-a+1
print(sum(map(int,str(a)))+sum(map(int,str(b))))

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
if N == 10 or N ==100 or N==1000 or N==10000 or N == 100000:
    print(10)
else:
    for i in range(5):
        ans += N%10
        N = N
print(ans)

Failing test case input:
234

Expected output:
9


Actual output:
20


Fixed submission (verdict: Accepted):
N = int(input())
if N == 10 or N ==100 or N==1000 or N==10000 or N == 100000:
    print(10)
else:
    print(sum(list(map(int, str(N)))))

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 10

for i in range(1, N):
    b = N -i
    A=sum(list(map(int,list(str(i)))))
    B=sum(list(map(int,list(str(b)))))
    ans = min(ans, A+B)
print(ans)

Failing test case input:
1697

Expected output:
23


Actual output:
10


Fixed submission (verdict: Accepted):
N = int(input())
ans = 10000000

for i in range(1, N):
    b = N -i
    A=sum(list(map(int,list(str(i)))))
    B=sum(list(map(int,list(str(b)))))
    ans = min(ans, A+B)
print(ans)
Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
if N == 10 or N ==100 or N==1000 or N==10000 or N == 100000:
    print(10)
else:
    for i in range(6):
        ans += N%10
        N = N
print(ans)

Failing test case input:
499

Expected output:
22


Actual output:
54


Fixed submission (verdict: Accepted):
N = int(input())
if N == 10 or N ==100 or N==1000 or N==10000 or N == 100000:
    print(10)
else:
    print(sum(list(map(int, str(N)))))

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(input())

m = set(n)

ans = 0
if m != {'1','0'}:
    for i in m:
        ans += int(i)
else:
    ans = 10
print(ans)


Failing test case input:
499

Expected output:
22


Actual output:
13


Fixed submission (verdict: Accepted):
n = list(input())

m = set(n)

ans = 0
if m != {'1','0'}:
    for i in n:
        ans += int(i)
else:
    ans = 10
print(ans)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = list(map(int, list(input())))
s = sum(N)

if s is 1:
    print(10)
else:
    print(sum)

Failing test case input:
234

Expected output:
9


Actual output:
<built-in function sum>


Fixed submission (verdict: Accepted):
N = list(map(int, list(input())))

s = sum(N)

if s is 1:
  print(10)
else:
  print(s)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
ans=10^5
for i in range(1,N):
    j=N-i
    i_s=sum(map(int,list(str(i))))
    j_s=sum(map(int,list(str(j))))
    S=i_s+j_s
    if S<ans:
        ans=S
    else:
        continue
        
print(ans)

Failing test case input:
795

Expected output:
21


Actual output:
15


Fixed submission (verdict: Accepted):
N=int(input())
ans=0
for i in range(1,N):
    j=N-i
    i_s=sum(map(int,list(str(i))))
    j_s=sum(map(int,list(str(j))))
    S=i_s+j_s
    if ans==0:
        ans=S
    else:
        if S<ans:
            ans=S
        else:
            continue

print(ans)

Problem: p03331
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
k = int(input())
 
while k % 10 == 0:
  if k != 10:
    k /= 10
  else:
    break
l = str(k) 
p = list(l)


  
print(p)
al = 0
if k != 10: 
  for i in range(len(p)):
    al += int(p[i])
else:
  al = 10
print(al)

Failing test case input:
234

Expected output:
9


Actual output:
['2', '3', '4']
9


Fixed submission (verdict: Accepted):
k = int(input())
 
while k % 10 == 0:
  if k != 10:
    k /= 10
  else:
    break
l = str(k) 
p = list(l)

al = 0
if k != 10: 
  for i in range(len(p)):
    al += int(p[i])
else:
  al = 10
print(al)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
  n = int(input())
  ans = 100000
  for i in range(1, n+1):
    r = (n-i)
    l = i
    ans = min(ans, r + l)
  print(ans)
  
if __name__ == '__main__':
  main()
  

Failing test case input:
1697

Expected output:
23


Actual output:
1697


Fixed submission (verdict: Accepted):
def main():
  n = int(input())
  ans = 100000
  for i in range(1, (n+2)
    r = (n-i)
    l = i
    ans = min(ans, r + l)
  print(ans)
  
if __name__ == '__main__':
  main()
Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
res=0
flag=s[0]=="1"
for c in s[1:]:
 res+=int(c)
 if c!="0":
  flag=False
if flag:
 print(10)
else:
 print(res)

Failing test case input:
471

Expected output:
12


Actual output:
8


Fixed submission (verdict: Accepted):
s=input()
res=int(s[0])
flag=s[0]=="1"
for c in s[1:]:
 res+=int(c)
 if c!="0":
  flag=False
if flag:
 print(10)
else:
 print(res)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

ansli=[]
for i in range(1, n):
    mn=n-i
    s1=str(i)
    s2=str(mn)
    dli=[]
    for j in s1:
        dli.append(int(j))
    for k in s2:
        dli.append(int(k))
    ans=0
    for l in dli:
        ans+=l
    
    ansli.append(ans)
print("min",min(ansli))


Failing test case input:
234

Expected output:
9


Actual output:
min 9


Fixed submission (verdict: Accepted):
n=int(input())

ansli=[]
for i in range(1, n):
    mn=n-i
    s1=str(i)
    s2=str(mn)
    dli=[]
    for j in s1:
        dli.append(int(j))
    for k in s2:
        dli.append(int(k))
    ans=0
    for l in dli:
        ans+=l
    
    ansli.append(ans)
print(min(ansli))

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = 1234567890
def c(x):
    ers = 0
    for i in str(x):
        ers += ord(i) - ord('0')
    return ers
for a in range(1, n):
    ans = min(ans, c(a) + c(n - a))

Failing test case input:
1697

Expected output:
23


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
ans = 1234567890
def c(x):
    ers = 0
    for i in str(x):
        ers += ord(i) - ord('0')
    return ers
for a in range(1, n):
    ans = min(ans, c(a) + c(n - a))
print(ans)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

ans = [0]

for i in range(2, n):
    a = sum([int(j) for j in str(i)])
    b = sum([int(j) for j in str(n - i)])
    ans.append(a + b)

print(min(ans))

Failing test case input:
1697

Expected output:
23


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())

ans = list()

for i in range(2, n 
    a = sum([int(j) for j in str(i)])
    b = sum([int(j) for j in str(n - i)])
    ans.append(a + b)

if len(ans) > 0:
    print(min(ans))
else:
    print(2)

Problem: p03331
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

ans = float("inf")  
for i in range(n+1):
    a = sum([int(i) for i in list(str(i))])
    b = sum([int(i) for i in list(str(n-i))])
    ans = min(a+b, ans)

Failing test case input:
234

Expected output:
9


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())

ans = float("inf")  
for i in range(1, n):
    a = sum([int(i) for i in list(str(i))])
    b = sum([int(i) for i in list(str(n-i))])
    if ans > a+b:
        ans = a + b
print(ans)
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))

const = pow(10, 9) + 7

c = 0

for i in range(n):
    for j in range(n - i - 1):
        
        if a[i] > a[n - j - 1]:
            c += 1



p = len(set(a))

q = p * (p - 1) / 2



ans = 0 + c * k + q * k * (k - 1) / 2

print(int(ans) % const)


Failing test case input:
10 727991293
0 9 10 7 5 3 0 4 4 1

Expected output:
401205910


Actual output:
556045868


Fixed submission (verdict: Accepted):
import copy

n, k = map(int, input().split())
a = list(map(int, input().split()))

const = 1000000007
c = 0
d = 0

for i in range(n):
    for j in range(n - i - 1):
        if a[i] > a[n - j - 1]:
            c += 1

b = copy.deepcopy(a)

for i in range(n):
    for j in range(n):
        if b[i] > a[j]:
            d += 1





ans = c * k + d * (k * (k - 1) 

print(int(ans) % const)

Problem: p02928
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
M = 10**9+7
import sys
input = sys.stdin.readline
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A_ = sorted(A, reverse = True)
    ans = 0
    ans_ = 0
    for i in range(0,N-1):
        for j in range(i+1,N):
            if A[i] > A[j]:
                ans += 1
            if A_[i] > A_[j]:
                ans_ += 1

    print(int((((K*(K-1)/2)%M)*ans_+ans*K)%M))

if __name__ == '__main__':
    main()

Failing test case input:
10 1652783124
20 9 8 7 5 5 0 4 1 2

Expected output:
611908778


Actual output:
611911682


Fixed submission (verdict: Accepted):
M = 10**9+7
import sys
input = sys.stdin.readline
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A_ = sorted(A, reverse = True)
    ans = 0
    ans_ = 0
    for i in range(0,N-1):
        for j in range(i+1,N):
            if A[i] > A[j]:
                ans += 1
            if A_[i] > A_[j]:
                ans_ += 1

    print(int((((K*(K-1)

if __name__ == '__main__':
    main()

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

X = 0

for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            X += 1
            j += 1

Y =0

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            Y += 1
            j += 1

print((X * K + int((K * (K-1))/2 * Y )) % MOD)

Failing test case input:
10 1051516890
10 15 10 1 5 4 0 8 4 0

Expected output:
142815647


Actual output:
142817293


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

MOD = 10 ** 9 + 7

X = 0

for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            X += 1

Y = 0

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            Y += 1

ans = (X * K + K*(K-1)

print(ans)
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = int(0)
outer = int(0)
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

b = (int(int(inner) * int(k)) + int(int(outer) * int(int(k) * int(k-1)) / 2))
print(int(int(b)%int(1000000007)))

Failing test case input:
10 1184496094
13 1 8 7 5 6 0 4 2 1

Expected output:
574831445


Actual output:
574832913


Fixed submission (verdict: Accepted):
from decimal import *
n, k = map(int,input().split())
a = list(map(int,input().split()))
inner = 0
outer = 0
for i in range(0,n):
    for j in range(0,n):
        if a[i] > a[j]:
            outer += 1
            if i < j:
                inner += 1

print((Decimal(((inner) * (k)) + Decimal((outer) * Decimal((k) * (k-1)) / 2))%(1000000007)))

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
A=list(map(int,input().split()))

cnt=0
a=0

if n==1:print(0)
else:
  for i in range(n-1):
    for j in range(i+1,n):
      if A[i]>A[j]:
        cnt+=1

  for i in range(n):
    for j in range(n):
      if A[i]>A[j]:
        a+=1

      
print(int(cnt*k+a*k*(k-1)/2)%(10**9+7))


Failing test case input:
10 1051516890
10 9 10 7 5 5 0 4 4 0

Expected output:
818429624


Actual output:
818429359


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
A=list(map(int,input().split()))

cnt=0
a=0

if n==1:print(0)
else:
  for i in range(n-1):
    for j in range(i+1,n):
      if A[i]>A[j]:
        cnt+=1

  for i in range(n):
    for j in range(n):
      if A[i]>A[j]:
        a+=1

      
  print(int(cnt*k+a*(k*(k-1)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
 
a=list(map(int,input().split()))
tentou1=0
for i in range(N):
  for j in range(i+1,N):
    if(a[i]>a[j]):
      tentou1+=1
stentou=0
for i in range(N):
  for j in range(N):
    if(a[i]>a[j]):
      stentou+=1
answer=int(tentou1*K + stentou*K*(K-1)/2)
print(answer%1000000007)

Failing test case input:
10 872422839
9 9 8 7 3 5 3 4 4 0

Expected output:
259107781


Actual output:
259106608


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=0
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            x+=1
y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            y+=1
cnt=(x*k)+(k*(k-1)
print(cnt%(10**9+7))
Problem: p02928
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 10**9 + 7

n, k = map(int,input().split())
A = list(map(int,input().split()))

C = [0] * (max(A)+1)
a1 = 0
a2 = 0

for i in range(n):
    C[A[i]] += 1
    a2 += sum(C[A[i]+1:])
for i in range(n):
    a1 += sum(C[A[i]+1:])

a1 %= mod
a2 %= mod

k %= mod

ans = 0
ans += a2*k % mod
ans2 = a1*k % mod
ans2 *= 0.5*(k-1) % mod
ans += ans2 % mod

print(int(ans % mod))

Failing test case input:
10 1652783124
20 9 8 7 5 5 0 4 1 2

Expected output:
611908778


Actual output:
611908762


Fixed submission (verdict: Accepted):
mod = 10**9 + 7

n, k = map(int,input().split())
A = list(map(int,input().split()))

C = [0] * (max(A)+1)
a1 = 0
a2 = 0

for i in range(n):
    C[A[i]] += 1
    a2 += sum(C[A[i]+1:])
for i in range(n):
    a1 += sum(C[A[i]+1:])

a1 %= mod
a2 %= mod

k %= mod

if k % 2 == 0:
    kk = [k
else:
    kk = [k, (k-1)

ans = 0
ans += a2*k % mod
ans2 = a1*kk[0] % mod
ans2 *= kk[1] % mod
ans += ans2 % mod

print(int(ans % mod))

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())

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

mod = 1000000007


B = A * 2
syokiti_A = 0
syokiti_B = 0
for i in range(N):
    for j in range(i, N):
        if A[i] > A[j]:
            syokiti_A += 1

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            syokiti_B += 1

ans = (syokiti_A * K) + (syokiti_B * K * (K-1) / 2)
print(int(ans) % mod)


Failing test case input:
10 998244353
20 9 8 7 5 5 3 4 1 2

Expected output:
25701995


Actual output:
25701953


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())

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

mod = 1000000007


B = A * 2
syokiti_A = 0
syokiti_B = 0
for i in range(N):
    for j in range(i, N):
        if A[i] > A[j]:
            syokiti_A += 1

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            syokiti_B += 1

ans = (syokiti_A * K) % mod + (syokiti_B * K * (K-1) 
print(int(ans) % mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K =map(int,input().split())
a = list(map(int,input().split()))

count = 0
dis = 0
for i in a:
    for k in a:
        if k < i:
            count +=1
        count %= (10 ** 9 + 7)
for i in range(N):
    for k in a[i:]:
        if k<a[i]:
            dis += 1
        dis %= (10**9+7)
a = dis * K % (10**9+7)
b = round(count*K% (10**9+7)*(K-1)% (10**9+7)/2 )
ans = (a+b)% (10**9+7)
print(ans)


Failing test case input:
10 998244353
10 16 8 7 5 5 0 3 6 0

Expected output:
873129374


Actual output:
373129370


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

count = 0
dis = 0
mod = (10**9+7)
for i in a:
    for k in a:
        if k < i:
            count +=1
        count %= mod
for i in range(N):
    for k in a[i:]:
        if k<a[i]:
            dis += 1
        dis %= mod
print(int((K * dis + K * (K - 1) * count
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
INF = 1000000007

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans_i = 0
ans_e = 0

for i in range(len(a)):
    for j in range(len(a)):
        if i == j: continue
        
        if a[i] > a[j]:
            if i < j:
                ans_i += 1
            else:
                ans_e += 1
x = ans_i * k
ans = ans_i + ans_e
p = int((k * (k-1) )/ 2)
y = int(ans * p)
print(int((x + y) % INF))


Failing test case input:
10 1468376359
13 5 8 7 5 6 3 4 3 1

Expected output:
637860655


Actual output:
637861816


Fixed submission (verdict: Accepted):
INF = 1000000007

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans_i = 0
ans_e = 0

for i in range(len(a)):
    for j in range(len(a)):
        if i == j: continue
        
        if a[i] > a[j]:
            if i < j:
                ans_i += 1
            else:
                ans_e += 1
x = ans_i * k
ans = ans_i + ans_e
y = ans * ((k * (k-1) ) 
print(int((x + y) % INF))

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    print(cnt)
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) % mod 
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans % mod)

Failing test case input:
10 998244353
10 9 8 7 5 5 0 3 6 1

Expected output:
32724611


Actual output:
0
9
17
24
30
33
36
36
38
43
132164074


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) * 500000004 % mod
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans % mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
l = list(map(int,input().split()))
mod = 10**9+7
a = 0
l1 = sorted(l)
for i in l:
  t = l1.index(i)
  a += t*(k-1)*k/2
 
  s = l.index(i)
  a += len([1 for e in l[s:] if e<i])*k

print(int(a)%mod)
  

Failing test case input:
10 998244353
10 9 10 7 5 6 0 4 4 1

Expected output:
871373720


Actual output:
869618027


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
l = list(map(int,input().split()))
mod = 10**9+7
a = 0
for i in range(n):
  b = l[i]
  t = (len([1 for m in l if  m<b])%mod)*(int( (k-1)%mod*k
 
  s = (len([1 for m in l[i:] if m<b])%mod)*k%mod

  a += (s+t)%mod
print(a%mod)
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

prime = 10**9+7

def sowa(num):
  return int((1+num)*num/2)

n,k = map(int, input().split())
a = list(map(int, input().split()))


tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = sum(tento1) *(k%prime) %prime + sum(tento2) *(sowa(k-1) %prime)%prime
print(ret%prime)


Failing test case input:
10 1087786498
13 2 8 7 6 6 3 4 4 1

Expected output:
982508952


Actual output:
982508909


Fixed submission (verdict: Accepted):

prime = 10**9+7

def sowa(num):
  return int((1+num)*num

n,k = map(int, input().split())
a = list(map(int, input().split()))

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime))

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
ans1=0
for i in range(n):
  for j in a:
    if a[i]<j:
      ans+=1
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      ans1+=1
print(ans1+(ans+ans1)*(k-1))

Failing test case input:
10 998244353
10 9 10 7 5 6 0 4 4 1

Expected output:
871373720


Actual output:
80857792550


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
ans1=0
for i in range(n):
  for j in a:
    if a[i]<j:
      ans+=1
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      ans1+=1
print((ans1*k+ans*(k*(k-1)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K =map(int,input().split())
a = list(map(int,input().split()))

count = 0
dis = 0
mod = (10**9+7)
for i in a:
    for k in a:
        if k < i:
            count +=1
        count %= mod
for i in range(N):
    for k in a[i:]:
        if k<a[i]:
            dis += 1
        dis %= mod
a = dis * K % mod
b = count*K*(K-1) % mod 
ans = (a+b)% (10**9+7)
print(ans)

Failing test case input:
10 1468376359
10 1 9 7 9 0 1 4 4 2

Expected output:
399688808


Actual output:
684839851


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

count = 0
dis = 0
mod = (10**9+7)
for i in a:
    for k in a:
        if k < i:
            count +=1
        count %= mod
for i in range(N):
    for k in a[i:]:
        if k<a[i]:
            dis += 1
        dis %= mod
print(int((K * dis + K * (K - 1) * count
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) % mod 
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K
print(ans % mod)


Failing test case input:
10 998244353
12 18 7 7 8 7 0 2 1 2

Expected output:
555694540


Actual output:
171081309


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) * 500000004 % mod
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans % mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) % mod 
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans % mod)


Failing test case input:
10 998244353
20 11 8 2 5 2 3 4 1 2

Expected output:
715289784


Actual output:
492027451


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) * 500000004 % mod
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans % mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
mod=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))

a0=0
a1=0

for i in range(N):
    for j in range(i+1,N):
        if A[i]>A[j]:
            a0+=1
for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            a1+=1


print(int(a0*K+a1*(K-1)*K/2)%mod)

Failing test case input:
10 1652783124
20 9 8 7 5 5 0 4 1 2

Expected output:
611908778


Actual output:
611911906


Fixed submission (verdict: Accepted):
mod=10**9+7

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

s=[0]*N
t=[0]*N

for i in range(N):
  for j in range(i+1,N):
    if A[i]>A[j]:
      s[i]+=1


for i in range(N):
  for j in range(N):
    if A[i]>A[j]:
      t[i]+=1


for i in range(N):
  s[i]=(s[i]*K)%mod
  t[i]=(t[i]*(K-1)*K



print((sum(s)+sum(t))%mod)