s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s310143144 | p03773 | u479953984 | 1507339820 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 54 | a, b = map(int, input().split())
printf((a + b) % 24) |
s248704592 | p03773 | u343437894 | 1499481684 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 533 | from math import factorial
n, a, b = map(int, input().split(" "));
v = list(map(int, input().split(" ")))
def product(iterable):
prod = 1
for n in iterable:
prod *= n
return prod
def npr(n, r):
return product(range(n - r + 1, n + 1))
def ncr(n, r):
if r > n // 2:
r = n - r
return npr(n, r) // factorial(r)
v.sort();
revv=list(reversed(v))
print(sum(v[-a:])/a)
revpos=revv.index(v[-a]);
num=v.count(v[-a]);
ans=0;
for i in range(a-revpos, b-revpos+1):
ans+=ncr(num, i);
print(ans);
|
s462999644 | p03773 | u343437894 | 1499477222 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 468 | import math;
n, m = map(int, input().split(" "));
ab = [];
for i in range(0, n):
ab.append(input().split(" "));
cd = [];
for i in range(0, m):
cd.append(input().split(" "));
for i in range(0, n):
dist=9999999999999
nearm=0;
for j in range(0, m):
dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
if dist2 < dist:
dist = dist2;
nearm=j;
print(nearm + 1);
|
s315518269 | p03773 | u343437894 | 1499475972 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 54 | a, b = map(int, input().split(" ");
print( (a+b) % 24) |
s327190238 | p03773 | u583326945 | 1498054577 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 695 | def calcManhattanDistance(student, checkpoint):
return abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1])
if __name__ == "__main__":
# input process
N, M = map(int, input().split())
students = [list(map(int, input().split())) for i in range(N)]
checkpoints = [list(map(int, input().split())) for i in range(M)]
# calculation process
for student in students:
distance_list = []
for checkpoint in checkpoints:
distance_list.append(calcManhattanDistance(student, checkpoint))
# print the first index(+1) of minimum value
minval = min(distance_list)
print(distance_list.index(minval) + 1)
# END |
s020048214 | p03773 | u033407970 | 1497648807 | Python | Python (3.4.3) | py | Runtime Error | 299 | 20504 | 556 | # coding: utf-8
# Here your code !
import numpy as np
n,m = [int(x) for x in input().split(' ')]
chil = []
check = []
minlist = []
for i in range(n):
chil.append([int(x) for x in input().split(' ')])
for i in range(m):
check.append([int(x) for x in input().split(' ')])
for c in chil:
min = 10**12
index = 0
for inde,ch in enumerate(check):
if abs(ch[1]-c[1]) + abs(ch[0]-c[0]) < min:
min = abs(ch[1]-c[1]) + abs(ch[0]-c[0])
index = inde
minlist.append(index + 1)
for i in minlist:
print(i)
|
s381680399 | p03773 | u667084803 | 1494450300 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 217 | import math
N=int( input())
for r in range (int(math.sqrt(N)),0,-1):
if N%r==0:
count=1
l=N/r
for i in range (0,10):
l=l/10
if l<1:
print(count)
break
count+=1
break |
s639369800 | p03773 | u975024434 | 1493259621 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 699 | import sys
sys.setrecursionlimit(10000)
def memoize(f):
cache = {}
def func(*args):
if args not in cache:
cache[args] = f(*args)
return cache[args]
return func
@memoize
def combi(n, r):
if r == 0 or n == r:
return 1
return combi(n-1, r-1) + combi(n-1, r)
n, a, b = map(int, input().split())
items = sorted(map(int, input().split()), reverse=True)
max_ave_list = items[:a]
print(sum(max_ave_list)/len(max_ave_list))
m = max_ave_list.count(max_ave_list[-1])
l = items.count(max_ave_list[-1])
if l == m:
print(1)
elif max_ave_list[0] != max_ave_list[-1]:
print(combi(l, m))
else:
print(sum(combi(l, k) for k in range(m, min(b, l) + 1))) |
s053818268 | p03773 | u124323472 | 1493057886 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 513 | n, m = list(map(int, input().split()))
a = []
b = []
for i in range(n):
tmp1, tmp2 = list(map(int, input().split()))
a.append(tmp1)
b.append(tmp2)
c = []
d = []
for i in range(m):
tmp1, tmp2 = list(map(int, input().split()))
c.append(tmp1)
d.append(tmp2)
for i in range(n):
tmp = abs(a[n] - c[0]) + abs(b[n] - d[0])
s = 1
for j in range(m):
tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
if tmp3 < tmp:
tmp = tmp3
s = j + 1
print(s) |
s605689610 | p03773 | u430478288 | 1492913982 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 456 | n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
stu.append(list(map(int, input().split())))
for i in range(m):
check.append(list(map(int, input().split())))
ans = []
for i in range(n):
dist = []
for j in range(m):
tmp = abs(stu[i][0] - check[j][0]) + abs(stu[i][1] - check[j][1])
dist.append(tmp)
mi = dist.index(min(dist))
ans.append(mi)
for i in range(len(ans)):
print(ans[i] + 1) |
s207769850 | p03773 | u430478288 | 1492913904 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 457 | n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
stu.append(list(map(int, input().split())))
for i in range(m):
check.append(list(map(int, input().split())))
ans = []
for i in range(n):
dist = []
for j in range(m):
tmp = abs(stu[i][0] - check[j][0]) + abs(stu[i][1] - check[j][1])
dist.append(tmp)
mi = dist.index(min(dist))
ans.append(mi)
for i in range(len(ans)):
print(ans[i] + 1)
|
s974614884 | p03773 | u430478288 | 1492912423 | Python | Python (3.4.3) | py | Runtime Error | 19 | 2940 | 48 | a, b = input().split()
c = (a + b) % 24
print(c) |
s373743422 | p03773 | u103099441 | 1492894478 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 434 | n, m = map(int, input().split())
s = []
d = []
for i in range(n):
x, y = map(int, input().split())
s.append([x, y])
for i in range(m):
x, y = map(int, input().split())
d.append([x, y])
for i in s:
a = m
c = abs(i[0] - d[0][0]) + abs(i[1] - d[1][1])
for j in range(1, m):
c_t = abs(i[0] - d[j][0]) + abs(i[1] - d[j][1])
if c_t < c:
c = min(c, c_t)
a = j
print(a)
|
s636740144 | p03773 | u790865353 | 1492476085 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 48 | A,B=map(int,input().split())
print((a + b) % 24) |
s316874031 | p03773 | u450145303 | 1491875133 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38640 | 265 | N,M = list(map(int, input().split()))
s = [list(map(int,input().split())) for i in range(n)]
c = [list(map(int,input().split())) for j in range(n)]
for t1 in s:
l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
print(l.index(min(l)) + 1) |
s277274515 | p03773 | u676264453 | 1491705087 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 182 | def digits(num):
return len(str(num))
N = int(input())
min_d = digits(N)
for i in list(range(2, N, 1)):
if (N % i == 0):
min_d = min(digits(i), min_d)
print(min_d)
|
s526019104 | p03773 | u306773664 | 1491699160 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 459 | #! coding: UTF-8
N,A,B = list(map(int,input().split(" ")))
V = list(map(int,input().split(" ")))
V.sort(reverse=True)
max_avr = sum(V[:A]) / A
a_num = V.count(V[A-1])
a_pos = V[:A].count(V[A-1])
#確率統計nCr
import math
def nCr(n,r):
f = math.factorial
return f(n) // f(r) // f(n-r)
if V[0] == V[A-1]:
cnt = sum(nCr(a_num,i) for i in range(A,min(B,a_num)))
else:
cnt = nCr(a_num,a_pos)
print("{0:.10f}".format(max_avr))
print(int(cnt))
|
s929461025 | p03773 | u306773664 | 1491698831 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3316 | 480 | #! coding: UTF-8
N,A,B = list(map(int,input().split(" ")))
V = list(map(int,input().split(" ")))
V.sort(reverse=True)
max_avr = sum(V[:A]) / A
a_num = V.count(V[A-1])
a_pos = V[:A].count(V[A-1])
#確率統計nCr
import math
def nCr(n,r):
f = math.factorial
return f(n) // f(r) // f(n-r)
cnt = 0
if V[0] == V[A-1]:
while a_pos <= B:
cnt += nCr(a_num,a_pos)
a_pos += 1
else:
cnt = nCr(a_num,a_pos)
print("{0:.10f}".format(max_avr))
print(int(cnt))
|
s646464191 | p03773 | u657875821 | 1491688926 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 150 | #coding:utf-8
AB = raw_input().split()
A = int(AB[0])
B = int(AB[1])
if A+B > 24:
print (A+B)%24
elif A+B = 24:
print 0
else:
print A+B
|
s751034778 | p03773 | u034734062 | 1491667820 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 764 | #!/usr/bin/env python3
# input
n, m = map(int, input().split())
persons = []
checks = []
for i in range(n):
point = tuple(map(int, input().split()))
persons.append(point)
for i in range(m):
point = tuple(map(int, input().split()))
checks.append(point)
# print(persons)
# print(checks)
def get_distance(person, check):
return abs(person[0] - check[0]) + abs(person[1] - check[1])
for i in range(n):
min_distance = 10 ** 10
min_distance_point_num = -1
# calculate min distance from n to each m
for j in range(m):
distance = get_distance(persons[i], checks[j])
if distance < min_distance:
min_distance = distance
min_distance_point_num = j + 1
print(min_distance_point_num)
|
s885979129 | p03773 | u034734062 | 1491667731 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 764 | #!/usr/bin/evn python3
# input
n, m = map(int, input().split())
persons = []
checks = []
for i in range(n):
point = tuple(map(int, input().split()))
persons.append(point)
for i in range(m):
point = tuple(map(int, input().split()))
checks.append(point)
# print(persons)
# print(checks)
def get_distance(person, check):
return abs(person[0] - check[0]) + abs(person[1] - check[1])
for i in range(n):
min_distance = 10 ** 10
min_distance_point_num = -1
# calculate min distance from n to each m
for j in range(m):
distance = get_distance(persons[i], checks[j])
if distance < min_distance:
min_distance = distance
min_distance_point_num = j + 1
print(min_distance_point_num)
|
s044959912 | p03773 | u256823895 | 1491522888 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 42 | a, b = (int(i) for i in input().split()) |
s088206872 | p03773 | u256823895 | 1491522856 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 57 | a, b = (int(i) for i in input().split())
print (a+b)%24 |
s305490849 | p03773 | u009102496 | 1491515416 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 95 | a, b=map(int, input().split())
2.c=a+b
3.if c<24:
4. print (c)
5.elif c>=24:
6. print (c-24)
|
s897069629 | p03773 | u989008537 | 1491497532 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 726 | N, A, B = map(int, input().split())
L = list(map(int, input().split()))
num = [0 for x in range(N)]
total = [0 for x in range(N)]
for i, v in enumerate(L):
for j in reversed(range(1, i + 1)):
new_v = total[j - 1] + v
if(new_v > total[j]):
total[j] = new_v
num[j] = num[j - 1]
elif(new_v == total[j]):
num[j] = num[j] + num[j - 1]
if(v > total[0]):
total[0] = v
num[0] = 1
elif(v == total[0]):
num[0] = num[0] + 1
print(total)
total = [x / (i + 1) for i, x in enumerate(total)]
total = total[(A - 1):B]
num = num[(A - 1):B]
maxV = max(total)
maxNum = sum([j for i, j in zip(total, num) if i == maxV])
print(maxV)
print(maxNum) |
s332347255 | p03773 | u214128237 | 1491256640 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 61 | A = 20
B = 6
X = A + B
if(X>= 24):
X = X - 24
print(X)
|
s546433304 | p03773 | u038319219 | 1491256397 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 393 | import math
def C(n, r):
fact = math.factorial
return fact(n) // fact(r) // fact(n-r)
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v_sort = sorted(v, reverse=True)
print(sum(v_sort[:A])/A)
a, b = v_sort.count(v_sort[A-1]), v_sort[:A].count(v_sort[A-1])
if v_sort[0] == v_sort[A-1]:
print(sum([C(a, r) for r in range(A, min(B, a)+1)]))
else:
print(C(a, b))
|
s592318301 | p03773 | u520481573 | 1491238538 | Python | Python (3.4.3) | py | Runtime Error | 19 | 2940 | 21 | a=9
b=6
print(a+b) |
s396513918 | p03773 | u610051322 | 1491184186 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 620 | #include <stdio.h>
int abs(int j)
{
return (j>0) ? j : -j;
}
int main()
{
int N, M, i, j;
int a[50], b[50], c[50], d[50],;
int p[50] = {0};
scanf("%d %d", &N, &M);
for(i=0; i<N; i++)
{
scanf("%d %d", &a[i], &b[i]);
}
for(j=0; j<M; j++)
{
scanf("%d %d", &c[j], &d[j]);
}
for(i=0; i<N; i++)
{
for(j=0; j<M; j++)
{
if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < abs(a[i] - c[p[i]]) + abs(b[i] - d[p[i]])
{
p[i] = j;
}
}
printf("%d\n", p[i]);
}
} |
s163193535 | p03773 | u610051322 | 1491182321 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 55 | l = map(int, input().split())
print((l[0] + l[1]) % 24) |
s003273602 | p03773 | u610051322 | 1491182172 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 59 | l = map(int, raw_input().split())
print((l[0] + l[1]) % 24) |
s773643436 | p03773 | u432688695 | 1491166157 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 632 | # -*- coding: utf-8 -*-
import sys
import os
N, M = list(map(int, input().split()))
students = []
checkpoints = []
for i in range(N):
a, b = list(map(int, input().split()))
students.append([a, b])
for i in range(M):
a, b = list(map(int, input().split()))
checkpoints.append([a, b])
for student in students:
min_dist = float('inf')
min_i = None
for i, checkpoint in enumerate(checkpoints):
manhattan_dist = abs(checkpoint[0] - student[0]) + abs(checkpoint[1] - student[1])
if manhattan_dist < min_dist:
min_dist = manhattan_dist
min_i = i
print(min_i + 1)
|
s386634879 | p03773 | u231540466 | 1491142631 | Python | PyPy2 (5.6.0) | py | Runtime Error | 36 | 28012 | 518 | import sys
if __name__=="__main__":
ab=[]
cd=[]
[n,m]=map(int,raw_input().split(" "))
for i in range(n):
ab.append( map(int,raw_input().split(" ")) )
for j in range(m):
cd.append( map(int,raw_input().split(" ")) )
for i in range(n):
min=sys.maxint
index=0
for j in range(m):
distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
if min > distance :
min=distance
index=j
print(index+1)
|
s678546107 | p03773 | u231540466 | 1491142530 | Python | PyPy2 (5.6.0) | py | Runtime Error | 35 | 27884 | 518 | import sys
if __name__=="__main__":
ab=[]
cd=[]
[n,m]=map(int,raw_input().split(" "))
for i in range(n):
ab.append( map(int,raw_input().split(" ")) )
for j in range(m):
cd.append( map(int,raw_input().split(" ")) )
for i in range(n):
min=sys.maxint
index=0
for j in range(m):
distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
if min > distance :
min=distance
index=j
print(index+1)
|
s284989906 | p03773 | u794543767 | 1491103725 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 13 | print(A+B/24) |
s743214012 | p03773 | u706884679 | 1491100474 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 87 | l = input().split()
A = l[0]
B = l[1]
T = A + B
if T < 24:
print(T)
else:
print(T-24) |
s956168709 | p03773 | u076936237 | 1490997063 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 784 | import math
def main():
N, M = tuple(map(int, input().split(' ')))
man_list = []
point_list = []
for i in range(N):
man_list.append(tuple(map(int, input().split(' '))))
for i in range(M):
point_list.append(tuple(map(int, input().split(' '))))
result = []
for i, man in enumerate(man_list):
a, b = man
min_ = float('inf')
for j, point in enumerate(point_list):
c, d = point
v = abs(a-c)+ abs(b-d)
if len(result) < i+1:
min_ = v
result.append(j+1)
continue
if v < min_:
result[i] = j+1
min_ = v
for r in result:
print('{}'.format(r))
if __name__ == '__main__':
main()
|
s380193969 | p03773 | u076936237 | 1490995689 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 136 | def main():
A, B = tuple(map(int, raw_input().split(' ')))
print('{}'.format((A+B)%24))
if __name__ == '__main__':
main()
|
s504073794 | p03773 | u076936237 | 1490995652 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 119 | def main():
A, B = raw_input().split(' ')
print('{}'.format((A+B)%24))
if __name__ == '__main__':
main()
|
s414845082 | p03773 | u076936237 | 1490995536 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 109 |
def main():
A, B = raw_input()
print('{}'.format((A+B)%24))
if __name__ == '__main__':
main()
|
s577868901 | p03773 | u481165257 | 1490981544 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 98 | if __name__ == "__main__":
times = [int(time) for time in input().split()]
print((A+B)%24) |
s912632010 | p03773 | u671912011 | 1490977646 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 66 | a = int(a)
b = int(b)
time = a+b
if time>=24:
time = time -24
|
s556268963 | p03773 | u671912011 | 1490977256 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 128 | #input a,b
beginning_time = a+b
if beginning_time>12:
beginning_time = beginning_time - 12
else:
beginning = beginning
|
s462817035 | p03773 | u368749019 | 1490936399 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 230 | import math
N = int(input())
ans = 10
for i in reversed(range(1,int(math.sqrt(N)) + 1)):
if N % i == 0:
A = len(str(i))
B = len(str(N // i))
print (N // i)
ans = min(ans,max(A,B))
print(ans)
|
s549829214 | p03773 | u505893372 | 1490834836 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 37 | A,B = int(input().split())
print(A+B) |
s257535595 | p03773 | u371573282 | 1490829472 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 550 | def distance(p1,p2):
return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])
M,N=[int(x) for x in input().split()]
student=[]
check=[]
for i in range(0,M):
a,b=[int(x) for x in input().split()]
student.append((a,b))
for j in range(0,N):
c,d=[int(x) for x in input().split()]
check.append((c,d))
for i in range(0,M):
dist=distance(student[i],check[N-1])
num=N-1
for j in range(0,N):
k=N-j-1
if dist>=distance(student[i],check[k]):
dist=distance(student[i],check[k])
num=k
print(num+1)
|
s988836139 | p03773 | u054556734 | 1490816692 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 106 | import math
n = int(input())
nn = int(math.sqrt(n))
while n%nn != 0: nn-=1
ans = len(str(n/nn))
print(ans) |
s574055613 | p03773 | u591287669 | 1490799386 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 136 | import math
n = int(input())
nn = int(math.sqrt(n))
for i in range(nn,0,-1):
if n%i==0:
print(len(str(n//i)))
break
|
s525477045 | p03773 | u265689893 | 1490769858 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 682 | # -*- coding: utf-8 -*-
import math
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
maxavg = sum(V[:A])/A
print(maxavg)
min = V[A-1]
ltAnum = 0
minnum = 0
for i in range(N):
if V[i] > min:
ltAnum = ltAnum + 1
elif V[i] == min:
minnum = minnum + 1
else:
break
#print(ltAnum)
#print(minnum)
import math
def nCr(n,r):
f = math.factorial
return f(n)//f(r)//f(n-r)
c_min = 0
import itertools
if ltAnum > 0:
c_min = nCr(minnum, A-ltAnum)
if ltAnum == 0:
for j in range(A, B+1):
if minnum < j:
break
else:
c_min = c_min + nCr(minnum, j)
print(c_min)
|
s879023387 | p03773 | u265689893 | 1490765182 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 642 | # -*- coding: utf-8 -*-
N, M = map(int, input().split())
students = []
checkpoints = []
for i in range(N):
students.append(list(map(int, input().split())))
#print(students)
for i in range(M):
checkpoints.append(list(map(int, input().split())))
#print(checkpoints)
for i in range(N):
mincp = -1
mindist = -1
for j in range(M):
dist = abs(students[i][0]-checkpoints[j][0]) + abs(students[i][1]-checkpoints[j][1])
if mincp == -1:
mincp = j
mindist = dist
else:
if dist < mindist:
mindist = dist
mincp = j
print("%d" % (mincp+1))
|
s682231032 | p03773 | u813098295 | 1490680853 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 184 | N = int(raw_input())
t = 1
for i in xrange(1, N):
if i*i > N:
break
elif i*i == N:
t = i
break
if N % i == 0:
t = i
print len(str(N/t)) |
s112336957 | p03773 | u231540466 | 1490672805 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 43 | print(sum(map(int,raw_input().split()))%24) |
s859910311 | p03773 | u238130426 | 1490658377 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 46 | a, b = map(int, split.input())
print((a+b)%24) |
s524331774 | p03773 | u177756077 | 1490582404 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 269 | #!/usr/bin/env python
import math
n=int(raw_input().strip())
N=int(math.ceil(math.sqrt(float(n))))
a=[]
for i in range(1,N+1):
if n%i==0:
a.append(i)
A=max(a)
B=int(n/A)
A_keta=len(map(int,str(A)))
B_keta=len(map(int,str(B)))
F=max(A_keta,B_keta)
print F
|
s555652455 | p03773 | u476383383 | 1490582293 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 600 | from itertools import combinations
N,A,B = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
v.sort()
if v[-A] != v[-A-1]:
print(sum(v[-A:]) / A)
print(1)
elif v[-1] :
# AAと同じ数のカウント
# Aよりも大きい数のカウント
cnt = 0
bigger = 0
for i in range(N):
if v[A] < v[i]:
bigger += 1
if v[i] == v[A]:
cnt += 1
ans = 0
mini = min(B, cnt+bigger)
for i in range(A,mini):
ans += len(list(combinations(range(cnt), i - bigger)))
print(sum(v[-A:]) / A)
print(ans) |
s292060036 | p03773 | u456950583 | 1490580947 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 431 | #!/usr/bin/env python
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
student = list()
point = list()
for i in range(n):
student.append([int(a) for a in input().split()])
for j in range(m):
point.append([int(b) for b in input().split()])
mat = [[abs(student[i][0]-point[j][0]) + abs(student[i][1]-point[j][1]) for j in range(m)] for i in range(m)]
for i in range(n):
print(mat[i].index(min(mat[i]))+1) |
s693005417 | p03773 | u330205771 | 1490580404 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2692 | 483 | import itertools
N, A, B = map(int, raw_input().split())
v = map(int, raw_input().split())
resultValue = 0
resultCount = 0
for pcs in range(B - A + 1):
perm = list(itertools.combinations(v, B + pcs))
for cand in perm:
average = float(sum(cand)) / len(cand)
if resultValue < average:
resultValue = average
resultCount = 1
elif resultValue == average:
resultCount += 1
print(resultValue)
print(resultCount)
|
s506598087 | p03773 | u391331433 | 1490579677 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2696 | 759 | import sys
import math
def get_read_func(fileobject):
if fileobject == None :
return raw_input
else:
return fileobject.readline
def main():
if len(sys.argv) > 1:
f = open(sys.argv[1])
else:
f = None
read_func = get_read_func(f);
input_raw = read_func()
top_str = input_raw.strip().split()
[N] = [int(top_str[0])]
min_F = sys.maxint
digit = int(math.log10(N) + 1)
for i in range(10 ** int((digit - 1)/2.0 + 0.5) , 0 , -1):
if(N % i == 0):
A = i
B = N/i
F = max(int(math.log10(A) + 1), int(math.log10(B) + 1))
if F < min_F:
min_F = F
#break
print min_F
if __name__ == '__main__':
main() |
s000811545 | p03773 | u391331433 | 1490579607 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2696 | 759 | import sys
import math
def get_read_func(fileobject):
if fileobject == None :
return raw_input
else:
return fileobject.readline
def main():
if len(sys.argv) > 1:
f = open(sys.argv[1])
else:
f = None
read_func = get_read_func(f);
input_raw = read_func()
top_str = input_raw.strip().split()
[N] = [int(top_str[0])]
min_F = sys.maxint
digit = int(math.log10(N) + 1)
for i in range(10 ** int((digit - 1)/2.0 + 0.5) , 0 , -1):
if(N % i == 0):
A = i
B = N/i
F = max(int(math.log10(A) + 1), int(math.log10(B) + 1))
if F < min_F:
min_F = F
#break
print min_F
if __name__ == '__main__':
main() |
s437881160 | p03773 | u039623862 | 1490579527 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38640 | 915 | n = int(input())
def prime_decomposition(n):
# 素因数分解
if n < 2:
return []
prime_factors = []
while n % 2 == 0:
prime_factors.append(2)
n >>= 1
while n % 3 == 0:
prime_factors.append(3)
n //= 3
a = 5
b = 7
while a ** 2 <= n:
if n % a == 0:
prime_factors.append(a)
n //= a
elif n % b == 0:
prime_factors.append(b)
n //= b
else:
a += 6
b += 6
if n > 1:
prime_factors.append(n)
return prime_factors
pfs = prime_decomposition(n)
pfs.reverse()
def ds(n):
ret = 1
while 10**ret <= n:
ret += 1
return ret
ln = len(pfs)
size = 2**ln
min_v = 100
for i in range(size):
p = 1
for j in range(ln):
if 1<<j & i:
p *= pfs[j]
min_v = min(min_v, max(ds(p), ds(n//p)))
print(min_v) |
s234109882 | p03773 | u581309643 | 1490579485 | Python | Python (3.4.3) | py | Runtime Error | 1753 | 21240 | 587 | import numpy as np
N, M = map(int, input().split())
list_coStu = []
list_coChe = []
for i in range(N):
list_coStu.append(list(map(int, input().split())))
for i in range(M):
list_coChe.append(list(map(int, input().split())))
#calc distance
for iS in range(len(list_coStu)):
coStu = np.array(list_coStu[iS])
min_iC = 0
d = 4 * 10**8 + 1
for iC in range(len(list_coChe)):
coChe = np.array(list_coChe[iC])
dif = coChe - coStu
dist = np.sum(np.abs(dif))
if dist < d:
min_iC = iC
d = dist
print(min_iC + 1)
|
s343666916 | p03773 | u968073812 | 1490579065 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2692 | 407 | import math
N, M = map(int, raw_input().split())
a = []
for i in range(N+M):
a.append(map(int, raw_input().split()))
b=[]
def mhtn(a,b,c,d):
return
for i in range(N):
best=4*10e8
num=0
for j in range(M):
x=math.fabs(a[i][0]-a[N+j][0])+math.fabs(a[i][1]-a[N+j][1])
if(best>x):
best=x
num=j+1
b.append(num)
for i in b:
print i |
s309896863 | p03773 | u762603420 | 1490578506 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 442 | N, M = list(map(int, input().split()))
a = []
c = []
for i in range(0, N + M):
s = list(map(int, input().split()))
if i < N:
a.append(s)
else:
c.append(s)
for i in range(0, N):
min_idx = 0
min_dis = 999999999999
for j in range(0, M):
dis = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
if min_dis > dis:
min_dis = dis
min_idx = j + 1
print(str(min_idx)) |
s672360627 | p03773 | u699347638 | 1490578426 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 330 | import math
def digit(X):
d = 0
while X:
X //= 10
d += 1
return d
def F(A, B):
return max(digit(A), digit(B))
N = int(input())
min_F = 20
max_div = round(math.sqrt(N))
for i in range(1, max_div):
if N % i == 0:
f = F(i, N/i)
if f < min_F:
min_F = f
print(min_F)
|
s280080185 | p03773 | u768951609 | 1490578375 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 166 | import math
N=int(raw_input())
n=math.floor(math.sqrt(N))
while(N%n!=0): n-=1
m=N/n
n=int(n)
m=int(m)
if n>=m:
print len(str(n))
else:
print len(str(m))
|
s863586207 | p03773 | u976966750 | 1490577517 | Python | PyPy2 (5.6.0) | py | Runtime Error | 35 | 28396 | 407 | import math
n=int(raw_input())
sq=math.sqrt(n)
ans=None
if str(sq)[-2]=='.':
print len(str(sq))-2
else:
nu=[]
while sq>1:
sq=int(sq)
if n%sq==0:
nu.append(str(sq))
nu.append(str(n/sq))
sq-=1
break
else:
sq-=1
if len(nu)!=0:
nu.sort()
print len((nu[1]))
else:
print len(str(n)) |
s951004342 | p03773 | u945028875 | 1490577056 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 78 | A = int(input())
B = int(input())
C = A + B
if C >= 24:
C -= 24
print(C)
|
s630362116 | p03773 | u247781603 | 1490577029 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 86 | a, b = int(input().split())
c = a + b
if c <= 24:
print(c)
else:
print(c - 24) |
s021147066 | p03773 | u247781603 | 1490576962 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 95 | a, b = int(input().split())
print(a)
c = a + b
if c <= 24:
print(c)
else:
print(c - 24) |
s835137087 | p03773 | u330205771 | 1490576732 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 146 | A, B = map(int, raw_input().split())
result = A + B
while True:
if 24 <= result:
result -= 24
else:
break
print(result) |
s288395939 | p03773 | u481333386 | 1490576710 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 144 | # -*- coding: utf-8 -*-
def main():
a, b = [int(e) for e in input().split()]
answer = (a + b) % 23
return answer
print((main())
|
s678797251 | p03773 | u968073812 | 1490576554 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 56 | l = raw_input().split()
time=(l[0]+l[1])%24
print time |
s968780017 | p03773 | u279196402 | 1490576490 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38640 | 44 | print(sum(map(int, raw_input().split()))%24) |
s262843522 | p03774 | u401487574 | 1600833185 | Python | PyPy3 (7.3.0) | py | Runtime Error | 126 | 74692 | 589 | ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
n,m = ma()
ckp = []
st = []
for i in range(n):
st.append(lma())
for i in range(m):
ckp.append(lma())
for a,b in st:
tmp=10**15
ans=0
for i in range(m):
if tmp<abs(a-c)+abs(b-d):
tmp=abs(a-c)+abs(b-d)
ans=i+1
print(ans)
|
s535832229 | p03774 | u551437236 | 1600805373 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9172 | 521 | n, m = map(int, input().split())
al = []
bl = []
for i in range(n):
a, b = map(int, input().split())
al.append([a, b])
for j in range(m):
c, d = map(int, input().split())
bl.append([c,d])
def check(a,b):
x = a[0] - b[0]
y = a[1] - b[1]
if x < 0:
x = -x
if y < 0:
y = -y
return x + y
for a in al:
min = 100000000
cnt = 1
for b in bl:
tmp = check(a,b)
if tmp < min:
ans = cnt
min = tmp
cnt += 1
print(ans) |
s339516175 | p03774 | u911856499 | 1599932382 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9156 | 352 | N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
mi = 2*10**8+1
for j in range(M):
tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
if mi > tmp:
mi = tmp
ans = j+1
print(ans)
|
s165178470 | p03774 | u911856499 | 1599932157 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9204 | 350 | N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
mi = 2*10**8
for j in range(M):
tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
if mi > tmp:
mi = tmp
ans = j+1
print(ans)
|
s886796195 | p03774 | u999503965 | 1599434852 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9112 | 337 | n,m=map(int,input().split())
a_lis=[list(map(int,input())) for i in range(n)]
c_lis=[list(map(int,input())) for i in range(m)]
for i in range(n):
num=0
ans=10**10
for j in reversed(range(m)):
a=a_lis[i]
c=c_lis[j]
num=abs(a[0]-c[0])+abs(a[1]-c[1])
ans=min(ans,num)
if num==ans:
cnt=j+1
print(cnt)
|
s640405723 | p03774 | u999503965 | 1599433015 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9188 | 353 | n,m=map(int,input().split())
a_lis=[list(map(int,input().split())) for i in range(n)]
c_lis=[list(map(int,input().split())) for i in range(m)]
for i in range(n):
num=0
ans=10**8
for j in reversed(range(m)):
a=a_lis[i]
c=c_lis[j]
num=abs(a[0]-c[0])+abs(a[1]-c[1])
ans=min(ans,num)
if num==ans:
cnt=j+1
print(cnt)
|
s771375173 | p03774 | u999503965 | 1599432969 | Python | Python (3.8.2) | py | Runtime Error | 22 | 9116 | 336 | n,m=map(int,input().split())
a_lis=[list(map(int,input())) for i in range(n)]
c_lis=[list(map(int,input())) for i in range(m)]
for i in range(n):
num=0
ans=10**8
for j in reversed(range(m)):
a=a_lis[i]
c=c_lis[j]
num=abs(a[0]-c[0])+abs(a[1]-c[1])
ans=min(ans,num)
if num==ans:
cnt=j+1
print(cnt)
|
s296298945 | p03774 | u239091426 | 1599320500 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9212 | 307 | n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
st.append(list(map(int, input().split())))
for i in range(n):
pt.append(list(map(int, input().split())))
for j in st:
for k in pt:
d = abs(j[0]-k[0]) + abs(j[1]-k[1])
ch.append(d)
print(ch.index(min(ch))+1)
ch = [] |
s131095897 | p03774 | u493520238 | 1598490350 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 74352 | 429 | n,m = map(int, input().split())
abl = []
cdl = []
for _ in range(n):
a,b = map(int, input().split())
abl.append((a,b))
for _ in range(n):
c,d = map(int, input().split())
cdl.append((c,d))
for a,b in abl:
cmin = 10**10
mini = -1
for i,(c,d) in enumerate(cdl):
v = abs(a-c)+abs(b-d)
if v < cmin:
cmin = v
minc,mind = c,d
mini = i+1
print(mini) |
s829237760 | p03774 | u468972478 | 1598231489 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9072 | 234 | n, m = map(int, input().split())
a = [input().split() for i in range(n)]
c = []
for i in range(n):
for j in range(m):
b = input().split()
c.append(abs(a[i][0] - b[0]) + abs(a[i][1] - b[1]))
print(c.index(min(c)))
|
s323302278 | p03774 | u835575472 | 1597335696 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8948 | 722 | #include <bits/stdc++.h>
using namespace std;
bool PN(int x)
{
if (x <= 1)
return false;
if (x == 2)
return true;
for (int i = 2; i < sqrt(x) + 1; i++)
if (x % i == 0)
return false;
return true;
}
void solve()
{
int n, m; cin >> n >> m;
int a[n], b[n];
int x[m], y[m];
for(int i = 0; i < n; ++i){
cin >> a[i] >> b[i];
}
for(int i = 0; i < m; ++i){
cin >> x[i] >> y[i];
}
for(int i =0 ; i < n; ++i){
int mi = 1000500000;
int ans = -1;
for(int j = 0; j < m; ++j){
if(mi > abs(a[i]-x[j]) + abs(b[i]-y[j])){
ans = j+1;
mi = abs(a[i]-x[j]) + abs(b[i]-y[j]);
}
}
cout << ans << endl;
}
}
int main()
{
solve();
return 0;
} |
s987269046 | p03774 | u309141201 | 1597281699 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9096 | 493 | n, m = map(int, input().split())
stud = []
poit = []
for i in range(n):
a, b = map(int, input().split())
stud.append([a, b])
for i in range(n):
c, d = map(int, input().split())
poit.append([c, d])
for a, b in stud:
# print(a, b)
dist = float('inf')
for i, info in enumerate(poit):
c = info[0]
d = info[1]
mdist = abs(a-c) + abs(b-d)
if dist > mdist:
dist = mdist
ans = i+1
print(ans)
# print(i, info)
|
s100855681 | p03774 | u309141201 | 1597281420 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9120 | 506 | n, m = map(int, input().split())
stud = []
poit = []
for i in range(n):
a, b = map(int, input().split())
stud.append([a, b])
for i in range(n):
c, d = map(int, input().split())
poit.append([c, d])
for a, b in stud:
# print(a, b)
dist = float('inf')
ans = -1
for i, info in enumerate(poit):
c = info[0]
d = info[1]
mdist = abs(a-c) + abs(b-d)
if dist > mdist:
dist = mdist
ans = i+1
print(ans)
# print(i, info)
|
s945342837 | p03774 | u589969467 | 1597229904 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9152 | 477 | def mh(a,b,c,d):
return abs(a-c)+abs(b-d)
n,m = map(int,input().split())
stu = []
for i in range(n):
a,b = map(int,input().split())
stu.append([a,b])
ans = [[99,1000000000] for i in range(m)]
#ans[1][1] = 0
#print(ans)
for j in range(1,m+1):
x,y = map(int,input().split())
for i in range(n):
tmp = mh(stu[i][0],stu[i][1],x,y)
if tmp < ans[i][1]:
ans[i][0] = j
ans[i][1] = tmp
for i in range(n):
print(ans[i][0])
|
s449214456 | p03774 | u257332942 | 1597087174 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8812 | 415 | a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m
for i in range(n):
a[i], b[i] = map(int, input().split())
for i in range(m):
c[i], d[i] = map(int, input().split())
for i in range(n):
min_dist, min_c = abs(a[0]-c[0]) + abs(b[0]-d[0]), 0
for j in range(m):
dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
if dist < min_dist:
min_dist = dist
min_c = j
print(min_c+1) |
s188942997 | p03774 | u765590009 | 1596863945 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9068 | 307 | n, m = map(int, input().split())
ab = []
for i in range(n):
a, b = map(int, input().split())
ab.append([a,b])
cd = []
for i in range(n):
c, d = map(int, input().split())
cd.append([c,d])
for a, b in ab:
distance = [abs(a-c) + abs(b-d) for c,d in cd]
print(distance.index(min(distance))+1) |
s674762635 | p03774 | u765590009 | 1596863820 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9220 | 348 | n, m = map(int, input().split())
ab = []
for i in range(n):
a, b = map(int, input().split())
ab.append([a,b])
cd = []
for i in range(n):
c, d = map(int, input().split())
cd.append([c,d])
distance = []
for a, b in ab:
for c, d in cd:
distance.append(abs(a-c)+abs(b-d))
print(distance.index(min(distance))+1)
distance.clear() |
s406468623 | p03774 | u765590009 | 1596863129 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9160 | 352 | n, m = map(int, input().split())
ab = []
for i in range(n):
a, b = map(int, input().split())
ab.append([a,b])
cd = []
for i in range(n):
c, d = map(int, input().split())
cd.append([c,d])
d = {}
for i in range(len(ab)):
for j in range(len(cd)):
d[j+1] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
print(min(d, key=d.get)) |
s598652484 | p03774 | u875769753 | 1596660941 | Python | PyPy3 (7.3.0) | py | Runtime Error | 77 | 74688 | 476 | N,M = map(int,input().split())
lsab = []
for i in range(N):
a,b = map(int,input().split())
lsab.append([a,b])
lscd = []
for j in range(M):
c,d= map(int,input().split())
lscd.append([c,d])
lsans = []
for i in range(N):
max1 = 2*10**8+1
for j in range(M):
dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
if dis < max1:
ans = j+1
max1 = dis
lsans.append(ans)
for i in range(N):
print(lsans[i]) |
s709760834 | p03774 | u875769753 | 1596660459 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9188 | 478 | N,M = map(int,input().split())
lsab = []
for i in range(N):
a,b = map(int,input().split())
lsab.append([a,b])
lscd = []
for j in range(M):
c,d= map(int,input().split())
lscd.append([c,d])
lsans = []
for i in range(N):
max1 = 2*10**8+100
for j in range(M):
dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
if dis < max1:
ans = j+1
max1 = dis
lsans.append(ans)
for i in range(N):
print(lsans[i]) |
s060777150 | p03774 | u875769753 | 1596660192 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9104 | 476 | N,M = map(int,input().split())
lsab = []
for i in range(N):
a,b = map(int,input().split())
lsab.append([a,b])
lscd = []
for j in range(M):
c,d= map(int,input().split())
lscd.append([c,d])
lsans = []
for i in range(N):
max1 = 2*10**8+1
for j in range(M):
dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
if dis < max1:
ans = j+1
max1 = dis
lsans.append(ans)
for i in range(N):
print(lsans[i]) |
s091261545 | p03774 | u875769753 | 1596660109 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9136 | 472 | N,M = map(int,input().split())
lsab = []
for i in range(N):
a,b = map(int,input().split())
lsab.append([a,b])
lscd = []
for j in range(M):
c,d= map(int,input().split())
lscd.append([c,d])
lsans = []
for i in range(N):
max1 = 10**8
for j in range(M):
dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
if dis < max1:
ans = j+1
max1 = dis
lsans.append(ans)
for i in range(N):
print(lsans[i]) |
s501247943 | p03774 | u054473438 | 1596129355 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9168 | 457 | N, M = list(map(int, input().split()))
P, CP = [], []
for i in range(N):
P.append(list(map(int, input().split())))
for i in range(M):
CP.append(list(map(int, input().split())))
for i in range(N):
a, b = P[i][0], P[i][1]
now = 10**8*2+1
for j in reversed(range(M)):
c, d = CP[j][0], CP[j][1]
distance = abs(a-c)+abs(b-d)
if distance <= now:
result = j+1
now = distance
print(result) |
s374155872 | p03774 | u054473438 | 1596129139 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9232 | 455 | N, M = list(map(int, input().split()))
P, CP = [], []
for i in range(N):
P.append(list(map(int, input().split())))
for i in range(M):
CP.append(list(map(int, input().split())))
for i in range(N):
a, b = P[i][0], P[i][1]
now = 10**8*2+1
for j in reversed(range(M)):
c, d = CP[j][0], CP[j][1]
distance = abs(a-c)+abs(b-d)
if distance <= now:
result = j+1
now = distance
print(result) |
s703286922 | p03774 | u811176339 | 1595449595 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9096 | 391 | import sys
input = sys.stdin.readline
n, m = [int(w) for w in input().split()]
ls = [[int(w) for w in input().split()] for _ in range(n)]
lp = [[int(w) for w in input().split()] for _ in range(n)]
for a, b in ls:
ans = -1
dist = 10e10
for i, (c, d) in enumerate(lp):
d = abs(a-c) + abs(b-d)
if d < dist:
ans = i
dist = d
print(ans+1)
|
s964188701 | p03774 | u241159583 | 1594986067 | Python | Python (3.8.2) | py | Runtime Error | 23 | 9124 | 257 | import bisect
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
AB = sorted(ab)
for x,y in cd:
a = bisect.bisect_left(AB, [x,y])
print(ab.index(AB[a])+1) |
s295693864 | p03774 | u678167152 | 1594986003 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9424 | 473 | def solve():
N, M = map(int, input().split())
ans = [0]*N
A = [0]*N
B = [0]*N
for i in range(N):
A[i],B[i] = map(int, input().split())
X = [0]*M
Y = [0]*M
for i in range(M):
X[i],Y[i] = map(int, input().split())
for i in range(N):
ind = -1
d_min = float('inf')
for j in range(N):
d = ((A[i]-X[j])**2+(B[i]-Y[j])**2)**0.5
if d<d_min:
d_min = d
ind = j+1
ans[i] = ind
return ans
print(*solve(),sep='\n') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.