ZhenlongDai/ACPR huggingface dataset:
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
XY = [[1,2],[1,1],[2,2],[2,1]]
N = len(XY)


vecs = [  (x[0]-y[0], x[1]-y[1]) for y in XY   for x in XY]
pattern = list(set(vecs))
pattern.remove((0,0))
pattern2 = tuple(pattern)
qty = map(lambda x: vecs.count(x), pattern2)
data = zip(qty, pattern)
data2 = list(data)
data2.sort()
d = int(data2[-1][0])
print(N-d)

Failing test case input:
3
1 4
4 6
7 8

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
N=int(input())
XY =  [list(map(int, input().split())) for _ in range(N)]
if N==1:
    print(1)
    exit()
vecs = [  (x[0]-y[0], x[1]-y[1]) for y in XY   for x in XY]
pattern = list(set(vecs))
pattern.remove((0,0))
pattern2 = tuple(pattern)
qty = map(lambda x: vecs.count(x), pattern2)
data = zip(qty, pattern)
data2 = list(data)
data2.sort()
d = int(data2[-1][0])
print(N-d)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(n):
		xi, yi = xy[i]
		xj, yj = xy[j]
		if xi==xj or yi==yj:
			continue
		pq.append((xi - xj, yi - yj))
ans = 1e9
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)


Failing test case input:
2
2 1
2 2

Expected output:
1


Actual output:
1000000000.0


Fixed submission (verdict: Accepted):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(n):
		if i==j:
			continue
		xi, yi = xy[i]
		xj, yj = xy[j]
		pq.append((xi - xj, yi - yj))
ans = 1e9 if n>1 else 1
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    N = int(input())
    pos = [list(map(int,input().split())) for _ in range(N)]
    if N == 1:
        print(1)
    else:
        d = defaultdict(int)
        for i in range(N):
            for j in range(i+1,N):
                slope = (pos[i][0]-pos[j][0],pos[i][1]-pos[j][1])
                if slope[0]*slope[1] != 0:
                    d[slope] += 1
        if len(d) == 0:
            print(N)
        else:
            print(N-max(d.values()))

if __name__ == "__main__":
    main()

Failing test case input:
2
2 1
2 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    N = int(input())
    pos = [list(map(int,input().split())) for _ in range(N)]
    if N == 1:
        print(1)
    else:
        d = defaultdict(int)
        for i in range(N):
            for j in range(N):
                slope = (pos[i][0]-pos[j][0],pos[i][1]-pos[j][1])
                if slope[0] != 0 or slope[1] != 0:
                    d[slope] += 1
        if len(d) == 0:
            print(N)
        else:
            print(N-max(d.values()))

if __name__ == "__main__":
    main()
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
if N==1:
  print(1)
else:
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = []
  for j in range(N):
    for k in range(1,N-j):
      diff_arr.append(str(arr[j+k][0]-arr[j][0])+'_'+str(arr[j+k][1]-arr[j][1]))
  print(diff_arr)
  c = collections.Counter(diff_arr)
  print(N-max(c.values()))
  

Failing test case input:
3
-1 3
5 32
10 0

Expected output:
2


Actual output:
['6_29', '11_-3', '5_-32']
2


Fixed submission (verdict: Accepted):
import collections

N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
if N==1:
  print(1)
else:
  arr = sorted(arr,key=lambda x:(x[0],x[1]))
  diff_arr = []
  for j in range(N):
    for k in range(1,N-j):
      diff_arr.append(str(arr[j+k][0]-arr[j][0])+'_'+str(arr[j+k][1]-arr[j][1]))
  c = collections.Counter(diff_arr)
  print(N-max(c.values()))

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
XY =  [list(map(int, input().split())) for _ in range(N)]
XY = [[1,2],[1,1],[2,2],[2,1],[3,1],[3,2]]
N = len(XY)
vecs = [  (x[0]-y[0], x[1]-y[1]) for y in XY   for x in XY]
pattern = list(set(vecs))
pattern.remove((0,0))
pattern2 = tuple(pattern)
qty = map(lambda x: vecs.count(x), pattern2)
data = zip(qty, pattern)
data2 = list(data)
data2.sort()
d = data2[-1][0]
print(N-d)

Failing test case input:
2
1 2
2 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N=int(input())
XY =  [list(map(int, input().split())) for _ in range(N)]
if N==1:
    print(1)
    exit()
vecs = [  (x[0]-y[0], x[1]-y[1]) for y in XY   for x in XY]
pattern = list(set(vecs))
pattern.remove((0,0))
pattern2 = tuple(pattern)
qty = map(lambda x: vecs.count(x), pattern2)
data = zip(qty, pattern)
data2 = list(data)
data2.sort()
d = int(data2[-1][0])
print(N-d)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
diff = []
if N == 1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1, N):
            diff.append((ball[i][n]-ball[j][n] for n in range(2)))
    k = Counter(diff).most_common()[0][1]
    print(max(1,N-1-k))


Failing test case input:
3
1 4
4 6
8 8

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
ball.sort(key=lambda x: x[1])
ball.sort()
diff = []
if N == 1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1, N):
            diff.append([(ball[j][n]-ball[i][n]) for n in range(2)])
    k = Counter(map(tuple, diff)).most_common()[0][1]

    print(max(1,N-k))
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

n = int(input())
x, y = [0] * n, [0] * n
data = defaultdict(int)
for i in range(n):
    x[i], y[i] = map(int, input().split())

for i in range(n):
    for j in range(n):
        data[x[j] - x[i], y[j] - y[i]] += 1

print(n - max(data.values()))

Failing test case input:
3
-2 4
5 10
11 4

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
from collections import defaultdict

n = int(input())
x, y = [0] * n, [0] * n
data = defaultdict(int)
for i in range(n):
    x[i], y[i] = map(int, input().split())

if n == 1:
    print(1)
    exit()
for i in range(n):
    for j in range(n):
        if i != j:
            data[x[j] - x[i], y[j] - y[i]] += 1

print(n - max(data.values()))

Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
x_y = []
for i in range(N):
    x,y = map(int,input().split())
    x_y.append([x,y])

vectors = []
ans_inv = 0
for i in range(N):
    for j in range(i+1,N):
        vector = [x_y[i][0]-x_y[j][0],x_y[i][1]-x_y[j][1]]

        vector_inv = [x_y[j][0]-x_y[i][0],x_y[j][1]-x_y[i][1]]
        if not vector in vectors and not vector_inv in vectors:
            vectors.append(vector)
path = int(N*(N-1)/2) - len(vectors)
print(path)

Failing test case input:
3
-1 0
6 32
10 4

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
x_y = []
for i in range(N):
    x,y = map(int,input().split())
    x_y.append([x,y])

vectors = []
ans_inv = 0
for i in range(N):
    for j in range(i+1,N):
        vector = [x_y[i][0]-x_y[j][0],x_y[i][1]-x_y[j][1]]

        if vector[0]<0:
            vector = [x_y[j][0]-x_y[i][0],x_y[j][1]-x_y[i][1]]
        elif vector[0] == 0 and vector[1]<0:
            vector = [x_y[j][0]-x_y[i][0],x_y[j][1]-x_y[i][1]]
        vectors.append(vector)
cnt = 0
for i in range(len(vectors)):
    cnt = max(cnt,vectors.count(vectors[i]))

print(N-cnt)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n=int(input())
ball=[]
for i in range(n):
    ball.append([int(i) for i in input().split()])

ball.sort()
    

pq_cand=set()
for v in itertools.combinations(ball,2):
    xdiff=abs(v[0][0]-v[1][0])
    ydiff=abs(v[0][1]-v[1][1])
    pq_cand.add((xdiff,ydiff))
    
connect=0
for pq in pq_cand:
    con=0
    for point in ball:
        if [point[0]-pq[0],point[1]-pq[1]] in ball:
            con+=1
    connect=max(connect,con)
print(n-connect)

Failing test case input:
3
1 1
0 17
2 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import itertools
n=int(input())
ball=[]
for i in range(n):
    ball.append([int(i) for i in input().split()])

ball.sort()


pq_cand=set()
for v in itertools.combinations(ball,2):
    xdiff=v[0][0]-v[1][0]
    ydiff=v[0][1]-v[1][1]
    pq_cand.add((xdiff,ydiff))
    
connect=0
for pq in pq_cand:
    con=0
    for point in ball:
        if [point[0]+pq[0],point[1]+pq[1]] in ball:
            con+=1
    connect=max(connect,con)
print(n-connect)
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

if N==1:
  print(1)
  exit()

pq=[]
for i in range(N):
  for j in range(i+1,N):
    pq.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

print(Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common())
print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Failing test case input:
3
0 1
0 17
2 0

Expected output:
2


Actual output:
[(16, 1), (19999999999, 1), (19999999983, 1)]
2


Fixed submission (verdict: Accepted):
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]
xy.sort()

if N==1:
  print(1)
  exit()

pq=[]
for i in range(N):
  for j in range(i+1,N):
    pq.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
XY=[tuple(map(int,input().split())) for _ in range(n)]
XY.sort()
PQset=set()
for i in range(n):
    for j in range(i+1,n):
        p=abs(XY[j][0]-XY[i][0])
        q=abs(XY[j][1]-XY[i][1])
        if p!=0 or q!=0:
            PQset.add((p,q))
ans=float('inf')
for p,q in PQset:
    cost=1
    for i in range(1,n):
        x,y=XY[i]
        if (x-p,y-q) not in XY:
            cost+=1
    ans=min(cost,ans)
print(ans)

Failing test case input:
3
1 1
0 17
2 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
XY=[tuple(map(int,input().split())) for _ in range(n)]
XY.sort()
PQset=set()
for i in range(n):
    for j in range(i+1,n):
        p=XY[j][0]-XY[i][0]
        q=XY[j][1]-XY[i][1]
        if p!=0 or q!=0:
            PQset.add((p,q))
ans=n
for p,q in PQset:
    cost=1
    for i in range(1,n):
        x,y=XY[i]
        if (x-p,y-q) not in XY:
            cost+=1
    ans=min(cost,ans)
print(ans)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
diff = []
if N == 1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1, N):
            diff.append((abs(ball[i][n]-ball[j][n]) for n in range(2)))
    k = Counter(diff).most_common()[0][1]
    print(max(1,N-1-k))


Failing test case input:
3
1 0
5 16
10 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
ball.sort(key=lambda x: x[1])
ball.sort()
diff = []
if N == 1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1, N):
            diff.append([(ball[j][n]-ball[i][n]) for n in range(2)])
    k = Counter(map(tuple, diff)).most_common()[0][1]

    print(max(1,N-k))
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter
from collections import defaultdict

big = 10**10
N = int(input())
pt = [[int(x) for x in input().split()] for _ in range(N)]
pt.sort(key = itemgetter(1))
pt.sort(key = itemgetter(0))
di = defaultdict(int)
for i,p0 in enumerate(pt):
    for j,p1 in enumerate(pt):
        if(i>=j):continue
        p,q = p0[0]-p1[0],p0[1]-p1[1]
        di[p*big+q] += 1
maxd = 0
for i in di:
    if(i==0):continue
    maxd = max(di[i],maxd)
print(N-maxd)
print(di)


Failing test case input:
3
0 1
1 17
6 0

Expected output:
2


Actual output:
2
defaultdict(<class 'int'>, {-10000000016: 1, -59999999999: 1, -49999999983: 1})


Fixed submission (verdict: Accepted):
from operator import itemgetter
from collections import defaultdict

big = 10**10
N = int(input())
pt = [[int(x) for x in input().split()] for _ in range(N)]
pt.sort(key = itemgetter(1))
pt.sort(key = itemgetter(0))
di = defaultdict(int)
for i,p0 in enumerate(pt):
    for j,p1 in enumerate(pt):
        if(i>=j):continue
        p,q = p0[0]-p1[0],p0[1]-p1[1]
        di[p*big+q] += 1
maxd = 0
for i in di:
    if(i==0):continue
    maxd = max(di[i],maxd)
print(N-maxd)

Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from itertools import combinations as comb

N = int(input())
xy = []
xy_ap = xy.append

for i in range(N):
    xy_ap(list(map(int, input().split())))

ls = [i for i in range(N)]

result = []


for i, j in comb(ls, 2):
    result.append([abs(xy[i][0] - xy[j][0]), abs(xy[i][1] - xy[j][1])])

cnt = 0
for i in range(len(result)):
    if result.count(result[i]) > cnt:
        cnt = result.count(result[i])
        
print(N - (cnt - 1))

Failing test case input:
3
0 1
1 17
6 -1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
from itertools import combinations as comb

N = int(input())
xy = []
xy_ap = xy.append

for i in range(N):
    xy_ap(list(map(int, input().split())))

ls = [i for i in range(N)]

result = []

xy.sort()

for i, j in comb(ls, 2):
    result.append([xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]])

cnt = 0
for i in range(len(result)):
    if result.count(result[i]) >= cnt:
        cnt = result.count(result[i])

print(N - cnt)
Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter
n= int(input())
xy=[[int(x) for x in input().split()] for _ in range(n)]
gr = [[[0,0]for _ in range(n)]for _ in range(n)]
for i in range(n):
  a,b = xy[i]
  for j in range(n):
    gr[i][j] = [xy[j][0]-a,xy[j][1]-b]
gr1 = []
for i in gr:
  for j in i:
    gr1.append(tuple(j))

c = Counter(gr1)
l,f = c.most_common()[0]
if l!=(0,0):
  print(n-f)

Failing test case input:
3
-2 4
5 6
11 4

Expected output:
2


Actual output:

Fixed submission (verdict: Accepted):
from collections import Counter
n= int(input())
if n==1:
  print(1)
  exit()
xy=[[int(x) for x in input().split()] for _ in range(n)]
gr = [[[0,0]for _ in range(n)]for _ in range(n)]
for i in range(n):
  a,b = xy[i]
  for j in range(n):
    gr[i][j] = [xy[j][0]-a,xy[j][1]-b]
gr1 = []
for i in gr:
  for j in i:
    gr1.append(tuple(j))

c = Counter(gr1)
l,f = c.most_common()[0]
if l!=(0,0):
  print(n-f)
else:
  l,f = c.most_common()[1]
  print(n-f)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(i + 1, n):
		xi, yi = xy[i]
		xj, yj = xy[j]
		if xi==xj or yi==yj:
			continue
		pq.append((xi - xj, yi - yj))
ans = 1e9
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)


Failing test case input:
2
2 1
2 2

Expected output:
1


Actual output:
1000000000.0


Fixed submission (verdict: Accepted):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(n):
		if i==j:
			continue
		xi, yi = xy[i]
		xj, yj = xy[j]
		pq.append((xi - xj, yi - yj))
ans = 1e9 if n>1 else 1
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
from collections import Counter


def main():
    n = int(input())
    if n == 1:
        print(1)

    XY = [list(map(int, input().split())) for _ in range(n)]
    d = []
    for A, B in combinations(XY, 2):
        x1, y1 = A[0], A[1]
        x2, y2 = B[0], B[1]
        p, q = x2 - x1, y2 - y1
        d.append((p,q))
    
    

    C = Counter(d)
    ans = 0
    for v in C.values():
        ans = max(ans, v)
    print(ans)

if __name__ == "__main__":
    main()


Failing test case input:
3
-1 4
5 32
10 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from itertools import combinations
from collections import Counter


def main():
    n = int(input())
    if n == 1:
        print(1)
        exit()

    XY = [list(map(int, input().split())) for _ in range(n)]
    d = []
    for A, B in combinations(XY, 2):
        x1, y1 = A[0], A[1]
        x2, y2 = B[0], B[1]
        p, q = x2 - x1, y2 - y1
        d.append((p, q))
        d.append((-p, -q))
    
    

    C = Counter(d)
    ans = 0
    for v in C.values():
        ans = max(ans, v)
    print(n - ans)


if __name__ == "__main__":
    main()

Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
xys=[list(map(int,input().split())) for _ in range(n)]
vec = []
pqs = []
for i in range(n):
    for j in range(i+1,n):
        pqs.append([abs(xys[i][0]-xys[j][0]),abs(xys[i][1]-xys[j][1])])
pqs.sort()
import collections

cnt = 1
cntMax = 0
for i in range(1,len(pqs)+1):
    if i == len(pqs):
        cntMax = max(cntMax,cnt)
    elif pqs[i] == pqs[i-1]:
        cnt += 1
    else:
        cntMax = max(cntMax,cnt)
        cnt = 1
print(n-cntMax)

Failing test case input:
3
-1 4
5 10
11 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
xys=[list(map(int,input().split())) for _ in range(n)]
vec = []
pqs = []
for i in range(n):
    for j in range(i+1,n):
        pqs.append([(xys[i][0]-xys[j][0]),(xys[i][1]-xys[j][1])])
        pqs.append([-(xys[i][0]-xys[j][0]),-(xys[i][1]-xys[j][1])])
pqs.sort()
import collections

cnt = 1
cntMax = 0
for i in range(1,len(pqs)+1):
    if i == len(pqs):
        cntMax = max(cntMax,cnt)
    elif pqs[i] == pqs[i-1]:
        cnt += 1
    else:
        cntMax = max(cntMax,cnt)
        cnt = 1
print(n-cntMax)
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n=int(input())
ball=[]
for i in range(n):
    ball.append([int(i) for i in input().split()])

ball.sort()
    

pq_cand=set()
for v in itertools.combinations(ball,2):
    xdiff=abs(v[0][0]-v[1][0])
    ydiff=abs(v[0][1]-v[1][1])
    pq_cand.add((xdiff,ydiff))
    
connect=0
for pq in pq_cand:
    con=0
    for point in ball:
        if [point[0]+pq[0],point[1]+pq[1]] in ball:
            con+=1
    connect=max(connect,con)
print(n-connect)

Failing test case input:
3
1 1
0 17
2 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import itertools
n=int(input())
ball=[]
for i in range(n):
    ball.append([int(i) for i in input().split()])

ball.sort()


pq_cand=set()
for v in itertools.combinations(ball,2):
    xdiff=v[0][0]-v[1][0]
    ydiff=v[0][1]-v[1][1]
    pq_cand.add((xdiff,ydiff))
    
connect=0
for pq in pq_cand:
    con=0
    for point in ball:
        if [point[0]+pq[0],point[1]+pq[1]] in ball:
            con+=1
    connect=max(connect,con)
print(n-connect)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
point=[]
merge=0
for i in range(0,N):
    x,y=map(int,input().split())
    point.append([x,y])
p=0
q=0
point.sort()
ans=0
if(N>1):
    for i in range(0,N-1):
        for j in range(i+1,N):
            p=point[j][0]-point[i][0]
            q=point[j][1]-point[i][1]
            merge=0
        for k in range(0,N):
            if([point[k][0]+p,point[k][1]+q] in point):
                merge+=1
        ans=max(ans,merge)
        print(N-ans)
else:
    print(N)

Failing test case input:
3
-1 4
4 6
11 3

Expected output:
2


Actual output:
2
2


Fixed submission (verdict: Accepted):
N=int(input())
point=[]
merge=0
for num in range(0,N):
    x,y=map(int,input().split())
    point.append([x,y])
p=0
q=0
point.sort()
ans=0
for i in range(0,N-1):
    for j in range(i+1,N):
        p=point[j][0]-point[i][0]
        q=point[j][1]-point[i][1]
        merge=0
        for k in range(0,N):
            if([point[k][0]+p,point[k][1]+q] in point):
                merge+=1
        ans=max(ans,merge)
print(N-ans)

Problem: p03006
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
l=[]
l_a=[]
if N==1:
   print(1)
   exit()
for i in range(N):
   l.append(list(map(int,input().split())))
for i in range(N):
   for j in range(i+1,N):
      tmp=str(abs(l[j][0]-l[i][0]))+" "+str(abs(l[j][1]-l[i][1]))
      l_a.append(tmp)
import collections
l_a=collections.Counter(l_a).most_common()
print(N-l_a[0][1])

Failing test case input:
3
-1 4
5 6
11 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
l=[]
if N==1:
   print(1)
   exit()
for i in range(N):
   a,b=map(int,input().split())
   l.append((a,b))
l2=[]
for i in range(N):
   for j in range(N):
      if i!=j:
         l2.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter
l2=max(Counter(l2).values())
print(N-l2)
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[]
if n==1:
    print(1)
    exit()
else:
    for i in range(n):
        x,y=map(int,input().split())
        l.append((x,y))
    x={}
    for i in l:
        for j in l:
            if i!=j:
                t=(i[0]-j[0],i[1]-j[1])
                if t in x:
                    x[t]+=1
                else:
                    x[t]=1
    print(max(x.values()))

Failing test case input:
3
-1 4
5 32
10 0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
l=[]
if n==1:
    print(1)
    exit()
else:
    for i in range(n):
        x,y=map(int,input().split())
        l.append((x,y))
    x={}
    for i in l:
        for j in l:
            if i!=j:
                t=(i[0]-j[0],i[1]-j[1])
                if t in x:
                    x[t]+=1
                else:
                    x[t]=1
    print(n-max(x.values()))

Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
XY=[tuple(map(int,input().split())) for _ in range(n)]
XY.sort()
PQset=set()
for i in range(n):
    for j in range(i+1,n):
        p=abs(XY[j][0]-XY[i][0])
        q=abs(XY[j][1]-XY[i][1])
        if p!=0 or q!=0:
            PQset.add((p,q))
ans=n
for p,q in PQset:
    cost=1
    for i in range(1,n):
        x,y=XY[i]
        if (x-p,y-q) not in XY:
            cost+=1
    ans=min(cost,ans)
print(ans)

Failing test case input:
3
1 1
0 17
2 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
XY=[tuple(map(int,input().split())) for _ in range(n)]
XY.sort()
PQset=set()
for i in range(n):
    for j in range(i+1,n):
        p=XY[j][0]-XY[i][0]
        q=XY[j][1]-XY[i][1]
        if p!=0 or q!=0:
            PQset.add((p,q))
ans=n
for p,q in PQset:
    cost=1
    for i in range(1,n):
        x,y=XY[i]
        if (x-p,y-q) not in XY:
            cost+=1
    ans=min(cost,ans)
print(ans)

Problem: p03006
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import defaultdict
n=int(input())
c=[]
for _ in range(n): c.append(list(map(int,input().split())))
dic=defaultdict(int)
for i in range(0,n-1):
    for j in range(i+1,n):
        if c[i][0]>=c[j][0]: temp=(c[i][0]-c[j][0],c[i][1]-c[j][1])
        else: temp=(c[j][0]-c[i][0],c[j][1]-c[i][1])
        dic[temp]+=1
if dict(dic):
    temp=max(dic.values())
    if temp==1: print(n)
    else: print(n-temp)
else: print(1)

Failing test case input:
3
-2 4
5 3
11 3

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
from collections import defaultdict
n=int(input())
c=[]
for _ in range(n): c.append(list(map(int,input().split())))
dic=defaultdict(int)
for i in range(n):
    for j in range(n):
        if i==j: continue
        dic[(c[i][0]-c[j][0],c[i][1]-c[j][1])]+=1
if dict(dic): print(n-max(dic.values()))
else: print(1)
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
xy=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xy.append(a)

if n==1:
    print(1)
    import sys
    sys.exit()
l=[]
ans=0
import itertools
for a,b in itertools.combinations(xy,2):
    p=abs(a[0]-b[0])
    q=abs(a[1]-b[1])
    if p!=0 or q!=0:
        l.append((p,q))

import collections
c=collections.Counter(l)
pp=c.most_common()
print(n-pp[0][1])
    

Failing test case input:
3
-1 4
5 6
11 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
xy=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xy.append(a)

if n==1:
    print(1)
    import sys
    sys.exit()
l=[]
ans=0
import itertools
for a,b in itertools.combinations(xy,2):
    p=(a[0]-b[0])
    q=(a[1]-b[1])
    if p!=0 or q!=0:
        l.append((p,q))
        l.append((-p,-q))

import collections
c=collections.Counter(l)
p=c.most_common()

for i in p:
   ans=max(ans,i[1])
print(n-ans)

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = 10**9

for i in range(n):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        cost = 0
        b = set()
        
        for k in xy:
            seppen = round(k[1] - k[0] * q / p, 10) if p != 0 else k[1]
            
            if (not seppen in b):
                cost += 1
                b.add(seppen)
        
        ans = min(ans, cost)
print(ans)

Failing test case input:
2
2 1
2 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = dict()

if n == 1:
    print(1)
    exit()

for i in range(n):
    for j in range(n):
        if (i == j):
            continue
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        if ans.get((p, q)) == None:
            ans[(p, q)] = 1
        else:
            ans[(p, q)] += 1

print(n-max(ans.values()))

Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
import sys

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

if N == 1:
    print(1)
    sys.exit()

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            pq.append((xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]))
print(pq)
pqc = collections.Counter(pq)
x = pqc.most_common()[0][1]
print(N-x)



Failing test case input:
3
2 4
4 6
11 3

Expected output:
2


Actual output:
[(-2, -2), (-9, 1), (2, 2), (-7, 3), (9, -1), (7, -3)]
2


Fixed submission (verdict: Accepted):
import collections
import sys

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

if N == 1:
    print(1)
    sys.exit()

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            pq.append((xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]))

pqc = collections.Counter(pq)
x = pqc.most_common()[0][1]
print(N-x)
Problem: p03006
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
xy=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xy.append(a)

if n==1:
    print(1)
    import sys
    sys.exit()
l=[]
ans=0
import itertools
for a,b in itertools.combinations(xy,2):
    p=abs(a[0]-b[0])
    q=abs(a[1]-b[1])
    if p!=0 or q!=0:
        l.append((p,q))

import collections
c=collections.Counter(l)
ans=c.most_common()


print(n-ans[0][1])

Failing test case input:
3
-1 4
5 10
11 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
xy=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xy.append(a)

if n==1:
    print(1)
    import sys
    sys.exit()
l=[]
ans=0
import itertools
for a,b in itertools.combinations(xy,2):
    p=(a[0]-b[0])
    q=(a[1]-b[1])
    if p!=0 or q!=0:
        l.append((p,q))
        l.append((-p,-q))

import collections
c=collections.Counter(l)
p=c.most_common()

for i in p:
   ans=max(ans,i[1])
print(n-ans)

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


n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:x[0])

if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    
    for p,q in set(diff):
        intercepts=[]
        for i in range(n):
            qxHIKUpy=q*xy[i][0]-p*xy[i][1]
            intercepts.append(qxHIKUpy)
        
        ans.append(len(set(intercepts)))
    
    print(min(ans))


Failing test case input:
4
1 1
1 4
2 1
2 2

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort(key=lambda x:(x[0],x[1]))

if n<=2:
    print(1)
else:
    diff=[]
    for i in range(n):
        for j in range(i):
            diff.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

    ans=[]
    
    for p,q in set(diff):
        cnt=n
        for i in range(n):
            for j in range(i):
                if xy[i][0]-xy[j][0]==p and xy[i][1]-xy[j][1]==q:
                    cnt-=1
        ans.append(cnt)
    print(min(ans))
Problem: p03006
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from itertools import combinations as comb

N = int(input())
xy = []
xy_ap = xy.append

for i in range(N):
    xy_ap(list(map(int, input().split())))

ls = [i for i in range(N)]

result = []


for i, j in comb(ls, 2):
    result.append([abs(xy[i][0] - xy[j][0]), abs(xy[i][1] - xy[j][1])])

cnt = 0
for i in range(len(result)):
    if result.count(result[i]) > cnt:
        cnt = result.count(result[i])
        dif = result[i]

print(result)

print(N - (cnt - 1))

Failing test case input:
4
1 1
1 2
2 1
2 2

Expected output:
2

Actual output:
[[0, 1], [1, 0], [1, 1], [1, 1], [1, 0], [0, 1]]
3


Fixed submission (verdict: Accepted):
from itertools import combinations as comb

N = int(input())
xy = []
xy_ap = xy.append

for i in range(N):
    xy_ap(list(map(int, input().split())))

ls = [i for i in range(N)]

result = []

xy.sort()

for i, j in comb(ls, 2):
    result.append([xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]])

cnt = 0
for i in range(len(result)):
    if result.count(result[i]) >= cnt:
        cnt = result.count(result[i])

print(N - cnt)
Problem: p03420
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n, k = map(int, input().split())

ans = 0
for b in range(1, n + 1):
    r = n % b
    ans += max(b - k, 0) * n 
    ans += max(0, r - k + 1)

if k == 0:
    ans -= n

print(ans)


Failing test case input:
13 2

Expected output:
97


Actual output:
875


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

ans = 0
for b in range(1, n + 1):
    ans += max(b - k, 0) * (n 
    ans += max(0, n % b - k + 1)

if k == 0:
    ans -= n

print(ans)

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

ans = 0
for b in range(1, N + 1):
  p, r = divmod(N, b)
  ans += p * max(0, b - K) + max(0, r - K + 1)
print(ans)

Failing test case input:
10 0

Expected output:
100

Actual output:
110


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

ans = 0

if K == 0:
  ans = N ** 2
else:
  for b in range(1, N + 1):
    p, r = divmod(N, b)
    ans += p * max(0, b - K) + max(0, r - K + 1)
print(ans)

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

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

cnt = 0
for b in range(1, N+1):
    p,r = divmod(N, b)
    cnt += p * max(0, b - K)
    cnt += max(0, r - K + 1)

print(cnt)

Failing test case input:
130 0

Expected output:
16900


Actual output:
17030


Fixed submission (verdict: Accepted):

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

cnt = 0
for b in range(1, N+1):
    p,r = divmod(N, b)
    cnt += p * max(0, b - K)
    cnt += max(0, r - K + 1)


if K == 0:
    cnt -= N

print(cnt)

Problem: p03420
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n, k = map(int, input().split())

ans = 0
for b in range(1, n + 1):
    ans += max(b - k, 0) * n 
    ans += max(0, n % b - k + 1)

if k == 0:
    ans -= n

print(ans)

Failing test case input:
31415 9265

Expected output:
287927211

Actual output:
7706821964037


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

ans = 0
for b in range(1, n + 1):
    ans += max(b - k, 0) * (n 
    ans += max(0, n % b - k + 1)

if k == 0:
    ans -= n

print(ans)

Problem: p03420
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ans = 0
N,K = list(map(int,input().split()))
for i in range(N):
    b=i+1
    p=int(N/b)

    ans+=max(0,b-K)*p+max(0,N-p*b-K+1)
    

print(ans)

Failing test case input:
24 0

Expected output:
576


Actual output:
600


Fixed submission (verdict: Accepted):

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

for i in range(N):
    b=i+1
    p=int(N/b)
    
    ans+=max(0,b-K)*p+max(0,N-p*b-K+1)
    if K==0:
        ans-=1

print(ans)
Problem: p03420
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    ans += max(0, N-b*cnt-K+1)
print(ans)

Failing test case input:
23 0

Expected output:
529


Actual output:
552


Fixed submission (verdict: Accepted):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    if K!=0:
        ans += max(0, N-b*cnt-K+1)
    else:
        ans += max(0, N-b*cnt-K)
print(ans)
Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
t=input()

x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()

a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)



import bisect


repeat=0
last=0
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>=temp[-1]:
		repeat+=1
		last=temp[0]
	else:
		last=temp[bisect.bisect_right(temp,last)]
	
print(repeat*len(s)+last+1)

Failing test case input:
mlstvdc
msm

Expected output:
8


Actual output:
15


Fixed submission (verdict: Accepted):
s=input()
t=input()
x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()
a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)
import bisect

repeat=0
last=-1
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>=temp[-1]:
		repeat+=1
		last=temp[0]
	else:
		last=temp[bisect.bisect_right(temp,last)]
	
print(repeat*len(s)+last+1)

Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect
s = input()
t = input()

alphabet = 'abcdefghijklmnopqrstuvwxyz'
char = {c: [] for c in alphabet}
for i, c in enumerate(s):
    char[c].append(i)

result = 0
for c in t:
    if len(char[c]) == 0:
        print(-1)
        exit()
    idx = bisect(char[c], result % len(s))
    result = result - result % len(s)
    try:
        result += char[c][idx]
    except IndexError:
        result += len(s) + char[c][0]

print(result+1)


Failing test case input:
mlstvdc
msm

Expected output:
8


Actual output:
15


Fixed submission (verdict: Accepted):
from bisect import bisect
s = input()
t = input()

alphabet = 'abcdefghijklmnopqrstuvwxyz'
char = {c: [] for c in alphabet}
for i, c in enumerate(s):
    char[c].append(i)

if len(char[t[0]]) == 0:
    print(-1)
    exit()

result = char[t[0]][0]

for c in t[1:]:
    if len(char[c]) == 0:
        print(-1)
        exit()
    idx = bisect(char[c], result % len(s))
    result = result - result % len(s)
    try:
        result += char[c][idx]
    except IndexError:
        result += len(s) + char[c][0]

print(result+1)
Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect


def main() -> None:
    S = input()
    T = input()
    SS = S + S
    alphas = [[] for _ in range(26)]
    for i, s in enumerate(SS):
        alphas[ord(s) - ord('a')].append(i)
    rep, now = 0, 0
    for t in T:
        alpha = alphas[ord(t) - ord('a')]
        i = bisect.bisect_left(alpha, now + 1)
        if i == len(alpha):
            print(-1)
            return
        now = alpha[i]
        if now >= len(S):
            now -= len(S)
            rep += 1
    print(rep * len(S) + now + 1)



if __name__ == '__main__':
    main()


Failing test case input:
mlstvdc
msm

Expected output:
8


Actual output:
15


Fixed submission (verdict: Accepted):
import bisect


def main() -> None:
    S = input()
    T = input()
    SS = S + S
    alphas = [[] for _ in range(26)]
    for i, s in enumerate(SS):
        alphas[ord(s) - ord('a')].append(i)
    rep, now = 0, -1
    for t in T:
        alpha = alphas[ord(t) - ord('a')]
        i = bisect.bisect_left(alpha, now + 1)
        if i == len(alpha):
            print(-1)
            return
        now = alpha[i]
        if now >= len(S):
            now -= len(S)
            rep += 1
    print(rep * len(S) + now + 1)



if __name__ == '__main__':
    main()

Problem: p02937
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import defaultdict
from bisect import bisect_right


def main():
    s = input()
    t = input()
    N = len(s)
    idx = defaultdict(list)
    for i in range(N):
        c = s[i]
        idx[c].append(i)
    pos = 0
    ans = 0
    for c in t:
        if c not in idx:
            print(-1)
            return
        n = bisect_right(idx[c], pos)
        if n == len(idx[c]):
            ans += N - pos + idx[c][0]
            pos = idx[c][0]
        else:
            ans += idx[c][n] - pos
            pos = idx[c][n]
    print(ans+1)


if __name__ == "__main__":
    main()


Failing test case input:
mlstvdc
msm

Expected output:
8


Actual output:
15


Fixed submission (verdict: Accepted):
from collections import defaultdict
from bisect import bisect_right


def main():
    s = input()
    t = input()
    N = len(s)
    idx = defaultdict(list)
    for i in range(N):
        c = s[i]
        idx[c].append(i)
    pos = -1
    ans = 0
    for c in t:
        if c not in idx:
            print(-1)
            return
        n = bisect_right(idx[c], pos)
        if n == len(idx[c]):
            ans += N + idx[c][0] - pos
            pos = idx[c][0]
        else:
            ans += idx[c][n] - pos
            pos = idx[c][n]
    print(ans)


if __name__ == "__main__":
    main()
Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = input()

pos = 0
itr = 0

S = set(s)
T = set(t)

if S>=T:
    for i in t:
        pos = s.find(i,pos) 
        if pos < 0:
            itr += 1
            pos = s.find(i)
        else:
            pos += 1
    print(itr*len(s)+pos)

else:
    print(-1)

Failing test case input:
csnoett
son

Expected output:
10


Actual output:
9


Fixed submission (verdict: Accepted):
s = input()
t = input()

pos = 0
itr = 0

S = set(s)
T = set(t)

if S>=T:
    for i in t:
        pos = s.find(i,pos) 
        if pos < 0:
            itr += 1
            pos = s.find(i) + 1
        else:
            pos += 1
    print(itr*len(s)+pos)

else:
    print(-1)

Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict as dd
from bisect import bisect_left as bl
s = input()
t = input()
ind = dd(list)
res = 0
for i in range(len(s)):
  ind[s[i]].append(i)

for i in range(len(t)):
  if len(ind[t[i]]) == 0:
    print(-1)
    exit(0)
  temp = bl(ind[t[i]], res % len(s))
  
  if temp == len(ind[t[i]]):
    res += (len(s) - res % len(s)) + ind[t[i]][0]
  else:
    res += ind[t[i]][temp] - res % len(s)
print(res + 1)

Failing test case input:
vtaletn
tnn

Expected output:
14


Actual output:
7


Fixed submission (verdict: Accepted):
from collections import defaultdict as dd
from bisect import bisect_left as bl
s = input()
t = input()
ind = dd(list)
res = 0
first = 1
for i in range(len(s)):
  ind[s[i]].append(i)

for i in range(len(t)):
  if len(ind[t[i]]) == 0:
    print(-1)
    exit(0)
  temp = bl(ind[t[i]], res % len(s))
  
  if first == 0:
    if res % len(s) == ind[t[i]][min(temp, len(ind[t[i]]) - 1)]:
      temp += 1
  first = 0
  if temp == len(ind[t[i]]):
    res += (len(s) - res % len(s)) + ind[t[i]][0]
  else:
    res += ind[t[i]][temp] - res % len(s)
print(res + 1)

Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
s=str(input())
t=str(input())

for i in range(len(t)):
    if s.find(t[i])==-1:
        print(-1)
        break
else:
    a=0
    count=0
    for k in t:
        if k in s[a:]:
            a=s.find(k)+1
        else:
            count+=1
            a=s.find(k)+1
    print(count*len(s)+a)

Failing test case input:
toncest
sentence

Expected output:
33


Actual output:
26


Fixed submission (verdict: Accepted):
import sys
s=str(input())
t=str(input())

for i in range(len(t)):
    if s.find(t[i])==-1:
        print(-1)
        break
else:
    a=0
    count=0
    for k in t:
        if k in s[a:]:
            a=s.find(k,a)+1
        else:
            count+=1
            a=s.find(k)+1
    print(count*len(s)+a)
Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = input()
ans = 0

if set(t).issubset(set(s)):
    x = s
    for ch in t:
        p = x.find(ch) + 1
        if p == 0:
            ans += len(x)
            x = s
        ans += p
        if p >= len(x) :
            p = 0
        x = x[p:]

    print(ans)
else:
    print('-1')


Failing test case input:
ntelatv
tnn

Expected output:
15


Actual output:
8


Fixed submission (verdict: Accepted):
s = input()
t = input()
ans = 0


for ch in t:
    if ch not in s:
        print('-1')
        exit()

x = s
for ch in t:
    p = x.find(ch) + 1
    if p == 0:
        ans += len(x)
        p = s.find(ch) + 1
        x = s
    ans += p
    
    x = x[p:]

print(ans)

Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = list(input())

index = 0
rep = 0
length = len(s)
ans = 0
for tar in t:
    old_index = index
    kari_index = s[old_index+1:].find(tar)

    if kari_index == -1:
        tmp = s.find(tar)
        if  tmp == -1:
            ans = -1
        else:
            rep += 1
            index = tmp
    else:
        index += kari_index + 1
        if index+1 == length:
            rep += 1
            index = 0
if ans != -1:
    ans = rep * len(s) + index + 1
print(ans)

Failing test case input:
vtaletn
tnn

Expected output:
14


Actual output:
15


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

index = -1
rep = 0
length = len(s)
ans = 0
for tar in t:
    if index+1 == length:
        rep += 1
        index = -1
        
    kari_index = s[index+1:].find(tar)

    if kari_index == -1:
        tmp = s.find(tar)
        if  tmp == -1:
            ans = -1
        else:
            rep += 1
            index = tmp
    else:
        index += kari_index + 1

if ans != -1:
    ans = rep * len(s) + index + 1
print(ans)

Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
T = input()
n = len(S)


res = [[n]*26 for _ in range(n+1)]
for i in reversed(range(n)):
    for j in range(26):
        res[i][j] = res[i+1][j]  
    res[i][ord(S[i])-ord("a")] = i  









cnt = 0
tmp = 0
for i in range(len(T)):
    
    if res[tmp % n][ord(T[i])-ord("a")] == n:  
        if tmp == 0:
            print(-1)
            exit()
        cnt += n
        tmp = 0
    tmp = res[tmp % n][ord(T[i])-ord("a")]  
    tmp += 1
cnt += tmp
print(cnt)


Failing test case input:
ctnntes
spo

Expected output:
-1


Actual output:
22


Fixed submission (verdict: Accepted):
S = input()
T = input()
n = len(S)


res = [[n]*26 for _ in range(n+1)]
for i in reversed(range(n)):
    for j in range(26):
        res[i][j] = res[i+1][j]  
    res[i][ord(S[i])-ord("a")] = i  









set_S = set(list(S))
for i in range(len(T)):
    if T[i] not in set_S:
        print(-1)
        exit()
cnt = 0
tmp = 0
for i in range(len(T)):
    
    if tmp == n:
        cnt += n
        tmp = 0
    elif res[tmp % n][ord(T[i])-ord("a")] == n:  
        if tmp == 0:
            print(-1)
            exit()
        cnt += n
        tmp = 0
    tmp = res[tmp % n][ord(T[i])-ord("a")]  
    tmp += 1
cnt += tmp
print(cnt)
Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = input()

c=0
j=-1
k=1




for i in range(0,len(t)):
  while True:
    j=j+1
    c=c+1


    
    if t[i:i+1]==s[j:j+1]:

      
      k=1
      break
    else:
      
      k=k+1
      if j>=len(s)-1:
        
        j=-1
      
      if k>len(s)+1:
        print("-1")
        exit()
print(c)


Failing test case input:
toncest
sentence

Expected output:
33


Actual output:
34


Fixed submission (verdict: Accepted):
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)

Problem: p02937
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import string
import bisect
S = input()
T = input()
n = len(S)
sa = {_: [] for _ in string.ascii_lowercase}
for i, s in enumerate(S):
    sa[s] += [i]
ans = 0
i = -1
for t in T:
    if sa[t]:
        j = bisect.bisect_left(sa[t], i)
        if j == len(sa[t]):
            ni = sa[t][0] + n
        else:
            ni = sa[t][j]
        ans += ni - i
        i = ni % n
    else:
        print(-1)
        exit()
print(ans)


Failing test case input:
vtaletn
tnn

Expected output:
14


Actual output:
7


Fixed submission (verdict: Accepted):
import string
import bisect
S = input()
T = input()
n = len(S)
sa = {_: [] for _ in string.ascii_lowercase}
for i, s in enumerate(S):
    sa[s] += [i]
ans = 0
i = -1
for t in T:
    if sa[t]:
        j = bisect.bisect_left(sa[t], i + 1)
        if j == len(sa[t]):
            ni = sa[t][0] + n
        else:
            ni = sa[t][j]
        ans += ni - i
        i = ni % n
    else:
        print(-1)
        exit()
print(ans)

Problem: p02937
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input()
t = input()
s_map = [[] for _ in range(26)]
import bisect
for i in range(len(s)):
    s_map[ord(s[i])-97].append(i)
for i in range(len(s)):
    s_map[ord(s[i])-97].append(len(s)+i)
cur = 0
count = 0
f = True
for c in t:
    if s_map[ord(c)-97] == []:
        f = False
        break
    cur = s_map[ord(c)-97][bisect.bisect_left(s_map[ord(c)-97],cur)]
    if cur >= len(s):
        count += 1
        cur -= len(s)
print(count * len(s) + cur+1 if f else -1)

Failing test case input:
vtaletn
tnn

Expected output:
14


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = input()
s_map = [[] for _ in range(26)]
import bisect
for i in range(len(s)):
    s_map[ord(s[i])-97].append(i)
for i in range(len(s)):
    s_map[ord(s[i])-97].append(len(s)+i)
cur = 0
count = 0
f = True
for c in t:
    if s_map[ord(c)-97] == []:
        f = False
        break
    np = bisect.bisect_left(s_map[ord(c)-97],cur)
    cur = s_map[ord(c)-97][np]+1
    
    if cur >= len(s):
        count += 1
        cur -= len(s)
print(count * len(s) + cur if f else -1)