user_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 1
value | submission_id_v0
stringlengths 10
10
| submission_id_v1
stringlengths 10
10
| cpu_time_v0
int64 10
38.3k
| cpu_time_v1
int64 0
24.7k
| memory_v0
int64 2.57k
1.02M
| memory_v1
int64 2.57k
869k
| status_v0
stringclasses 1
value | status_v1
stringclasses 1
value | improvement_frac
float64 7.51
100
| input
stringlengths 20
4.55k
| target
stringlengths 17
3.34k
| code_v0_loc
int64 1
148
| code_v1_loc
int64 1
184
| code_v0_num_chars
int64 13
4.55k
| code_v1_num_chars
int64 14
3.34k
| code_v0_no_empty_lines
stringlengths 21
6.88k
| code_v1_no_empty_lines
stringlengths 20
4.93k
| code_same
bool 1
class | relative_loc_diff_percent
float64 0
79.8
| diff
list | diff_only_import_comment
bool 1
class | measured_runtime_v0
float64 0.01
4.45
| measured_runtime_v1
float64 0.01
4.31
| runtime_lift
float64 0
359
| key
list |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u359358631 | p02718 | python | s603269715 | s435290887 | 87 | 76 | 61,912 | 61,392 | Accepted | Accepted | 12.64 | def main():
n, m = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
total = sum(a_lst)
cnt = 0
for a in a_lst:
if a >= total / (4 * m):
cnt += 1
if cnt >= m:
ans = "Yes"
else:
ans = "No"
print(ans)
if __name__ == "__main__":
main()
| def main():
n, m = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
total = sum(a_lst)
cnt = 0
for a in a_lst:
if a * 4 * m >= total:
cnt += 1
if cnt >= m:
ans = "Yes"
else:
ans = "No"
print(ans)
if __name__ == "__main__":
main()
| 20 | 20 | 345 | 343 | def main():
n, m = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
total = sum(a_lst)
cnt = 0
for a in a_lst:
if a >= total / (4 * m):
cnt += 1
if cnt >= m:
ans = "Yes"
else:
ans = "No"
print(ans)
if __name__ == "__main__":
main()
| def main():
n, m = list(map(int, input().split()))
a_lst = list(map(int, input().split()))
total = sum(a_lst)
cnt = 0
for a in a_lst:
if a * 4 * m >= total:
cnt += 1
if cnt >= m:
ans = "Yes"
else:
ans = "No"
print(ans)
if __name__ == "__main__":
main()
| false | 0 | [
"- if a >= total / (4 * m):",
"+ if a * 4 * m >= total:"
]
| false | 0.034907 | 0.035384 | 0.98653 | [
"s603269715",
"s435290887"
]
|
u145231176 | p03608 | python | s758540155 | s470044655 | 562 | 355 | 78,680 | 84,556 | Accepted | Accepted | 36.83 | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, M, R = getNM()
d = [[float("inf")] * N for i in range(N)]
list_R = [int(i) - 1 for i in input().split()]
for i in range(M):
x, y, z = getNM()
d[x - 1][y - 1] = min(d[x - 1][y - 1], z)
d[y - 1][x - 1] = min(d[x - 1][y - 1], z)
def warshall_floyd(dist):
for k in range(N):
# i:start j:goal k:中間地点でループ回す
for i in range(N):
for j in range(N):
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
#return dist
warshall_floyd(d)
ans = float('inf')
for case in permutations(list_R):
x1 = case[0]
opt = 0
for j in range(1, R):
x2 = case[j]
opt += d[x1][x2]
x1 = x2
ans = min(ans, opt)
print(ans) | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, M, R = getNM()
d = [[float("inf")] * N for i in range(N)]
list_R = [int(i) - 1 for i in input().split()]
for i in range(M):
x, y, z = getNM()
d[x - 1][y - 1] = min(d[x - 1][y - 1], z)
d[y - 1][x - 1] = min(d[x - 1][y - 1], z)
def warshall_floyd(dist):
for k in range(N):
# i:start j:goal k:中間地点でループ回す
for i in range(N):
for j in range(N):
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
#return dist
warshall_floyd(d)
ans = float('inf')
for case in permutations(list_R):
x1 = case[0]
opt = 0
for j in range(1, R):
x2 = case[j]
opt += d[x1][x2]
x1 = x2
ans = min(ans, opt)
print(ans) | 82 | 80 | 2,011 | 2,063 | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
#############
# Main Code #
#############
N, M, R = getNM()
d = [[float("inf")] * N for i in range(N)]
list_R = [int(i) - 1 for i in input().split()]
for i in range(M):
x, y, z = getNM()
d[x - 1][y - 1] = min(d[x - 1][y - 1], z)
d[y - 1][x - 1] = min(d[x - 1][y - 1], z)
def warshall_floyd(dist):
for k in range(N):
# i:start j:goal k:中間地点でループ回す
for i in range(N):
for j in range(N):
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
# return dist
warshall_floyd(d)
ans = float("inf")
for case in permutations(list_R):
x1 = case[0]
opt = 0
for j in range(1, R):
x2 = case[j]
opt += d[x1][x2]
x1 = x2
ans = min(ans, opt)
print(ans)
| def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(eval(input())) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
#############
# Main Code #
#############
N, M, R = getNM()
d = [[float("inf")] * N for i in range(N)]
list_R = [int(i) - 1 for i in input().split()]
for i in range(M):
x, y, z = getNM()
d[x - 1][y - 1] = min(d[x - 1][y - 1], z)
d[y - 1][x - 1] = min(d[x - 1][y - 1], z)
def warshall_floyd(dist):
for k in range(N):
# i:start j:goal k:中間地点でループ回す
for i in range(N):
for j in range(N):
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
# return dist
warshall_floyd(d)
ans = float("inf")
for case in permutations(list_R):
x1 = case[0]
opt = 0
for j in range(1, R):
x2 = case[j]
opt += d[x1][x2]
x1 = x2
ans = min(ans, opt)
print(ans)
| false | 2.439024 | [
"-import heapq",
"+from heapq import heapify, heappop, heappush",
"-from fractions import gcd",
"-import copy",
"-from itertools import permutations",
"-from operator import mul",
"+from copy import deepcopy",
"+from itertools import combinations, permutations, product",
"+from operator import mul, itemgetter"
]
| false | 0.087795 | 0.05182 | 1.694217 | [
"s758540155",
"s470044655"
]
|
u165447384 | p02271 | python | s401874427 | s514870935 | 16,620 | 50 | 5,640 | 5,932 | Accepted | Accepted | 99.7 | n = int(eval(input()))
A = list(map(int,input().split()))
m = int(eval(input()))
B = list(map(int,input().split()))
def solve2(x,y):
if x==n:
S[y] = 1
else:
solve2(x+1,y)
if y+A[x] < 2001:
solve2(x+1,y+A[x])
S = [0 for i in range(2001)]
solve2(0,0)
def solve(x,y):
if y<0:
return False
elif y==0:
return True
elif x==n:
return False
else:
return solve(x+1,y) or solve(x+1,y-A[x])
for i in range(m):
if (i>50 and (S[B[i]] == 1)):
print("yes")
elif (i>50 and (S[B[i]] == 0)):
print("no")
else:
if solve(0,B[i]):
print("yes")
else:
print("no")
| n = int(eval(input()))
A = list(map(int,input().split()))
m = int(eval(input()))
B = list(map(int,input().split()))
T = [[0]*2001 for i in range(n)]
T[0][0] = 1
T[0][A[0]] = 1
for i in range(1,n):
for j in range(2001):
T[i][j] = T[i-1][j]
if (j - A[i] >=0) and (T[i-1][j-A[i]] == 1):
T[i][j] = 1
for i in range(m):
if T[n-1][B[i]] == 1:
print("yes")
else:
print("no")
| 37 | 21 | 746 | 440 | n = int(eval(input()))
A = list(map(int, input().split()))
m = int(eval(input()))
B = list(map(int, input().split()))
def solve2(x, y):
if x == n:
S[y] = 1
else:
solve2(x + 1, y)
if y + A[x] < 2001:
solve2(x + 1, y + A[x])
S = [0 for i in range(2001)]
solve2(0, 0)
def solve(x, y):
if y < 0:
return False
elif y == 0:
return True
elif x == n:
return False
else:
return solve(x + 1, y) or solve(x + 1, y - A[x])
for i in range(m):
if i > 50 and (S[B[i]] == 1):
print("yes")
elif i > 50 and (S[B[i]] == 0):
print("no")
else:
if solve(0, B[i]):
print("yes")
else:
print("no")
| n = int(eval(input()))
A = list(map(int, input().split()))
m = int(eval(input()))
B = list(map(int, input().split()))
T = [[0] * 2001 for i in range(n)]
T[0][0] = 1
T[0][A[0]] = 1
for i in range(1, n):
for j in range(2001):
T[i][j] = T[i - 1][j]
if (j - A[i] >= 0) and (T[i - 1][j - A[i]] == 1):
T[i][j] = 1
for i in range(m):
if T[n - 1][B[i]] == 1:
print("yes")
else:
print("no")
| false | 43.243243 | [
"-",
"-",
"-def solve2(x, y):",
"- if x == n:",
"- S[y] = 1",
"+T = [[0] * 2001 for i in range(n)]",
"+T[0][0] = 1",
"+T[0][A[0]] = 1",
"+for i in range(1, n):",
"+ for j in range(2001):",
"+ T[i][j] = T[i - 1][j]",
"+ if (j - A[i] >= 0) and (T[i - 1][j - A[i]] == 1):",
"+ T[i][j] = 1",
"+for i in range(m):",
"+ if T[n - 1][B[i]] == 1:",
"+ print(\"yes\")",
"- solve2(x + 1, y)",
"- if y + A[x] < 2001:",
"- solve2(x + 1, y + A[x])",
"-",
"-",
"-S = [0 for i in range(2001)]",
"-solve2(0, 0)",
"-",
"-",
"-def solve(x, y):",
"- if y < 0:",
"- return False",
"- elif y == 0:",
"- return True",
"- elif x == n:",
"- return False",
"- else:",
"- return solve(x + 1, y) or solve(x + 1, y - A[x])",
"-",
"-",
"-for i in range(m):",
"- if i > 50 and (S[B[i]] == 1):",
"- print(\"yes\")",
"- elif i > 50 and (S[B[i]] == 0):",
"- else:",
"- if solve(0, B[i]):",
"- print(\"yes\")",
"- else:",
"- print(\"no\")"
]
| false | 0.05208 | 0.058471 | 0.890692 | [
"s401874427",
"s514870935"
]
|
u077898957 | p03352 | python | s653263344 | s590891785 | 21 | 18 | 2,940 | 2,940 | Accepted | Accepted | 14.29 | x = int(eval(input()))
bp = 0
for i in range(x):
for j in range(9):
if((i+1)**(j+2)<=x):
bp = max(bp,(i+1)**(j+2))
print(bp)
| import math
x=int(eval(input()))
a=int(math.sqrt(x)//1)
ans=1
for i in range(1,a+1):
for j in range(2,a+1):
if i**j<=x:
ans=max(ans,i**j)
print(ans)
| 7 | 10 | 149 | 177 | x = int(eval(input()))
bp = 0
for i in range(x):
for j in range(9):
if (i + 1) ** (j + 2) <= x:
bp = max(bp, (i + 1) ** (j + 2))
print(bp)
| import math
x = int(eval(input()))
a = int(math.sqrt(x) // 1)
ans = 1
for i in range(1, a + 1):
for j in range(2, a + 1):
if i**j <= x:
ans = max(ans, i**j)
print(ans)
| false | 30 | [
"+import math",
"+",
"-bp = 0",
"-for i in range(x):",
"- for j in range(9):",
"- if (i + 1) ** (j + 2) <= x:",
"- bp = max(bp, (i + 1) ** (j + 2))",
"-print(bp)",
"+a = int(math.sqrt(x) // 1)",
"+ans = 1",
"+for i in range(1, a + 1):",
"+ for j in range(2, a + 1):",
"+ if i**j <= x:",
"+ ans = max(ans, i**j)",
"+print(ans)"
]
| false | 0.045058 | 0.04855 | 0.928074 | [
"s653263344",
"s590891785"
]
|
u977389981 | p03262 | python | s979618459 | s181283550 | 154 | 123 | 14,224 | 14,252 | Accepted | Accepted | 20.13 | n, x = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort(reverse=True)
D = []
for i in range(len(X)):
dist = abs(x - X[i])
D.append(dist)
def gcd(i, j):
while j != 0:
i, j = j, i % j
return i
for i in range(len(D) - 1):
D[i + 1] = gcd(D[i], D[i + 1])
print((D[-1])) | n, x = list(map(int, input().split()))
city = list(map(int, input().split()))
D = []
for i in range(n):
dis = abs(x - city[i])
D.append(dis)
def gdc(x, y):
if x%y == 0:
return y
x, y = y, x%y
return gdc(x, y)
for i in range(n-1):
D[i + 1] = gdc(D[i], D[i + 1])
print((D[-1])) | 18 | 18 | 331 | 324 | n, x = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort(reverse=True)
D = []
for i in range(len(X)):
dist = abs(x - X[i])
D.append(dist)
def gcd(i, j):
while j != 0:
i, j = j, i % j
return i
for i in range(len(D) - 1):
D[i + 1] = gcd(D[i], D[i + 1])
print((D[-1]))
| n, x = list(map(int, input().split()))
city = list(map(int, input().split()))
D = []
for i in range(n):
dis = abs(x - city[i])
D.append(dis)
def gdc(x, y):
if x % y == 0:
return y
x, y = y, x % y
return gdc(x, y)
for i in range(n - 1):
D[i + 1] = gdc(D[i], D[i + 1])
print((D[-1]))
| false | 0 | [
"-X = list(map(int, input().split()))",
"-X.sort(reverse=True)",
"+city = list(map(int, input().split()))",
"-for i in range(len(X)):",
"- dist = abs(x - X[i])",
"- D.append(dist)",
"+for i in range(n):",
"+ dis = abs(x - city[i])",
"+ D.append(dis)",
"-def gcd(i, j):",
"- while j != 0:",
"- i, j = j, i % j",
"- return i",
"+def gdc(x, y):",
"+ if x % y == 0:",
"+ return y",
"+ x, y = y, x % y",
"+ return gdc(x, y)",
"-for i in range(len(D) - 1):",
"- D[i + 1] = gcd(D[i], D[i + 1])",
"+for i in range(n - 1):",
"+ D[i + 1] = gdc(D[i], D[i + 1])"
]
| false | 0.039245 | 0.04479 | 0.876209 | [
"s979618459",
"s181283550"
]
|
u546285759 | p00341 | python | s820496292 | s641249280 | 30 | 20 | 7,684 | 7,636 | Accepted | Accepted | 33.33 | e= sorted(list(map(int, input().split())))
print(("yes" if len(set(e[:4]))==len(set(e[4:8]))==len(set(e[8:]))==1 else "no")) | e = sorted(map(int, input().split()))
print(("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no")) | 2 | 2 | 123 | 124 | e = sorted(list(map(int, input().split())))
print(("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no"))
| e = sorted(map(int, input().split()))
print(("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no"))
| false | 0 | [
"-e = sorted(list(map(int, input().split())))",
"+e = sorted(map(int, input().split()))"
]
| false | 0.043038 | 0.03769 | 1.141894 | [
"s820496292",
"s641249280"
]
|
u678167152 | p03623 | python | s903483254 | s011581283 | 172 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.12 | x, a, b = list(map(int, input().split()))
ans = 'A'
if abs(x-a)>abs(x-b):
ans='B'
print(ans)
#print(*ans, sep='\n')
| A, B, C = list(map(int, input().split()))
def check():
if abs(B-A)<abs(C-A):
return 'A'
return 'B'
print((check())) | 7 | 6 | 119 | 128 | x, a, b = list(map(int, input().split()))
ans = "A"
if abs(x - a) > abs(x - b):
ans = "B"
print(ans)
# print(*ans, sep='\n')
| A, B, C = list(map(int, input().split()))
def check():
if abs(B - A) < abs(C - A):
return "A"
return "B"
print((check()))
| false | 14.285714 | [
"-x, a, b = list(map(int, input().split()))",
"-ans = \"A\"",
"-if abs(x - a) > abs(x - b):",
"- ans = \"B\"",
"-print(ans)",
"-# print(*ans, sep='\\n')",
"+A, B, C = list(map(int, input().split()))",
"+",
"+",
"+def check():",
"+ if abs(B - A) < abs(C - A):",
"+ return \"A\"",
"+ return \"B\"",
"+",
"+",
"+print((check()))"
]
| false | 0.03852 | 0.038124 | 1.01039 | [
"s903483254",
"s011581283"
]
|
u163907160 | p04045 | python | s129021065 | s849023036 | 400 | 219 | 12,420 | 12,384 | Accepted | Accepted | 45.25 | import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
N,K=list(map(int,input().split()))
D=list(map(int,input().split()))
for i in range(N,100000):
t=set(map(int,list(str(i))))
temp=D+list(t)
temp2=set(temp)
if len(temp)==len(temp2):
#print(temp)
#print(temp2)
print(i)
exit()
| import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
N,K=list(map(int,input().split()))
D=set(eval(input()))
while len(set(str(N))&D)>0:
N+=1
print(N)
| 17 | 11 | 390 | 209 | import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
# N=int(input())
N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
for i in range(N, 100000):
t = set(map(int, list(str(i))))
temp = D + list(t)
temp2 = set(temp)
if len(temp) == len(temp2):
# print(temp)
# print(temp2)
print(i)
exit()
| import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
# N=int(input())
N, K = list(map(int, input().split()))
D = set(eval(input()))
while len(set(str(N)) & D) > 0:
N += 1
print(N)
| false | 35.294118 | [
"-D = list(map(int, input().split()))",
"-for i in range(N, 100000):",
"- t = set(map(int, list(str(i))))",
"- temp = D + list(t)",
"- temp2 = set(temp)",
"- if len(temp) == len(temp2):",
"- # print(temp)",
"- # print(temp2)",
"- print(i)",
"- exit()",
"+D = set(eval(input()))",
"+while len(set(str(N)) & D) > 0:",
"+ N += 1",
"+print(N)"
]
| false | 0.102402 | 0.082398 | 1.242762 | [
"s129021065",
"s849023036"
]
|
u391589398 | p03150 | python | s710588747 | s790771992 | 99 | 64 | 70,720 | 64,224 | Accepted | Accepted | 35.35 | import re
S = eval(input())
k = 'keyence'
for i in range(0, len(k)+1):
rs = '^' + k[:i] + '.*' + k[i:] + '$'
if re.match(rs, S) is not None:
print('YES')
break
else:
print('NO')
| S = eval(input())
ans = False
for i in range(0, len(S)):
for j in range(len(S)-i+1):
ns = S[:j] + S[j+i:]
if ns == 'keyence':
ans = True
break
if ans:
break
print(('YES' if ans else 'NO'))
| 11 | 11 | 211 | 247 | import re
S = eval(input())
k = "keyence"
for i in range(0, len(k) + 1):
rs = "^" + k[:i] + ".*" + k[i:] + "$"
if re.match(rs, S) is not None:
print("YES")
break
else:
print("NO")
| S = eval(input())
ans = False
for i in range(0, len(S)):
for j in range(len(S) - i + 1):
ns = S[:j] + S[j + i :]
if ns == "keyence":
ans = True
break
if ans:
break
print(("YES" if ans else "NO"))
| false | 0 | [
"-import re",
"-",
"-k = \"keyence\"",
"-for i in range(0, len(k) + 1):",
"- rs = \"^\" + k[:i] + \".*\" + k[i:] + \"$\"",
"- if re.match(rs, S) is not None:",
"- print(\"YES\")",
"+ans = False",
"+for i in range(0, len(S)):",
"+ for j in range(len(S) - i + 1):",
"+ ns = S[:j] + S[j + i :]",
"+ if ns == \"keyence\":",
"+ ans = True",
"+ break",
"+ if ans:",
"-else:",
"- print(\"NO\")",
"+print((\"YES\" if ans else \"NO\"))"
]
| false | 0.046089 | 0.132764 | 0.347149 | [
"s710588747",
"s790771992"
]
|
u777923818 | p03504 | python | s491405332 | s342981568 | 1,547 | 524 | 27,956 | 19,540 | Accepted | Accepted | 66.13 | def inpl(): return tuple(map(int, input().split()))
N, C = inpl()
P = sorted([inpl() for _ in range(N)])
R = [[[-1, 0, -1]] for _ in range(30)]
for s, t, c in P:
i = 0
# 連続録画を探す
sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s]
if sr:
R[min(sr)].append([s, t, c])
else:
r = [i for i in range(30) if R[i][-1][1] <= s - 0.5]
R[min(r)].append([s, t, c])
for i in range(30):
if len(R[i]) == 1:
print(i)
break
else:
print((30)) | # -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return tuple(map(int, input().split()))
N, C = inpl()
P = [[] for _ in range(C)]
for _ in range(N):
s, t, c = inpl()
P[c-1].append((2*s, 2*t))
S = [0 for _ in range(2*10**5 + 3)]
for p in P:
if len(p) == 0:
continue
p2 = []
p = sorted(p)
s, t = p[0]
for i in range(1, len(p)):
if t == p[i][0]:
t = p[i][1]
else:
S[s-1] += 1
S[t+1] -= 1
s, t = p[i]
S[s-1] += 1
S[t+1] -= 1
print((max(accumulate(S)))) | 22 | 29 | 531 | 606 | def inpl():
return tuple(map(int, input().split()))
N, C = inpl()
P = sorted([inpl() for _ in range(N)])
R = [[[-1, 0, -1]] for _ in range(30)]
for s, t, c in P:
i = 0
# 連続録画を探す
sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s]
if sr:
R[min(sr)].append([s, t, c])
else:
r = [i for i in range(30) if R[i][-1][1] <= s - 0.5]
R[min(r)].append([s, t, c])
for i in range(30):
if len(R[i]) == 1:
print(i)
break
else:
print((30))
| # -*- coding: utf-8 -*-
from itertools import accumulate
def inpl():
return tuple(map(int, input().split()))
N, C = inpl()
P = [[] for _ in range(C)]
for _ in range(N):
s, t, c = inpl()
P[c - 1].append((2 * s, 2 * t))
S = [0 for _ in range(2 * 10**5 + 3)]
for p in P:
if len(p) == 0:
continue
p2 = []
p = sorted(p)
s, t = p[0]
for i in range(1, len(p)):
if t == p[i][0]:
t = p[i][1]
else:
S[s - 1] += 1
S[t + 1] -= 1
s, t = p[i]
S[s - 1] += 1
S[t + 1] -= 1
print((max(accumulate(S))))
| false | 24.137931 | [
"+# -*- coding: utf-8 -*-",
"+from itertools import accumulate",
"+",
"+",
"-P = sorted([inpl() for _ in range(N)])",
"-R = [[[-1, 0, -1]] for _ in range(30)]",
"-for s, t, c in P:",
"- i = 0",
"- # 連続録画を探す",
"- sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s]",
"- if sr:",
"- R[min(sr)].append([s, t, c])",
"- else:",
"- r = [i for i in range(30) if R[i][-1][1] <= s - 0.5]",
"- R[min(r)].append([s, t, c])",
"-for i in range(30):",
"- if len(R[i]) == 1:",
"- print(i)",
"- break",
"-else:",
"- print((30))",
"+P = [[] for _ in range(C)]",
"+for _ in range(N):",
"+ s, t, c = inpl()",
"+ P[c - 1].append((2 * s, 2 * t))",
"+S = [0 for _ in range(2 * 10**5 + 3)]",
"+for p in P:",
"+ if len(p) == 0:",
"+ continue",
"+ p2 = []",
"+ p = sorted(p)",
"+ s, t = p[0]",
"+ for i in range(1, len(p)):",
"+ if t == p[i][0]:",
"+ t = p[i][1]",
"+ else:",
"+ S[s - 1] += 1",
"+ S[t + 1] -= 1",
"+ s, t = p[i]",
"+ S[s - 1] += 1",
"+ S[t + 1] -= 1",
"+print((max(accumulate(S))))"
]
| false | 0.095082 | 0.136066 | 0.698791 | [
"s491405332",
"s342981568"
]
|
u580697892 | p02819 | python | s485567276 | s820957774 | 168 | 17 | 14,032 | 3,060 | Accepted | Accepted | 89.88 | # coding: utf-8
from bisect import bisect_left
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
X = int(eval(input()))
L = primes(10**6)
idx = bisect_left(L, X)
print((L[idx])) | # coding: utf-8
def elatostenes(x):
for i in range(2, int(x ** 0.5)+1):
if x % i == 0:
return False
return True
X = int(eval(input()))
while True:
if elatostenes(X):
print(X)
exit()
else:
X += 1 | 16 | 14 | 443 | 262 | # coding: utf-8
from bisect import bisect_left
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
X = int(eval(input()))
L = primes(10**6)
idx = bisect_left(L, X)
print((L[idx]))
| # coding: utf-8
def elatostenes(x):
for i in range(2, int(x**0.5) + 1):
if x % i == 0:
return False
return True
X = int(eval(input()))
while True:
if elatostenes(X):
print(X)
exit()
else:
X += 1
| false | 12.5 | [
"-from bisect import bisect_left",
"-",
"-",
"-def primes(n):",
"- is_prime = [True] * (n + 1)",
"- is_prime[0] = False",
"- is_prime[1] = False",
"- for i in range(2, int(n**0.5) + 1):",
"- if not is_prime[i]:",
"- continue",
"- for j in range(i * 2, n + 1, i):",
"- is_prime[j] = False",
"- return [i for i in range(n + 1) if is_prime[i]]",
"+def elatostenes(x):",
"+ for i in range(2, int(x**0.5) + 1):",
"+ if x % i == 0:",
"+ return False",
"+ return True",
"-L = primes(10**6)",
"-idx = bisect_left(L, X)",
"-print((L[idx]))",
"+while True:",
"+ if elatostenes(X):",
"+ print(X)",
"+ exit()",
"+ else:",
"+ X += 1"
]
| false | 0.600942 | 0.041318 | 14.544329 | [
"s485567276",
"s820957774"
]
|
u102461423 | p03160 | python | s776023061 | s037551676 | 168 | 129 | 14,104 | 11,588 | Accepted | Accepted | 23.21 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N = int(eval(input()))
H = [int(x) for x in input().split()]
dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]) for k in [1,2])
answer = dp[-1]
print(answer) | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,*H = list(map(int,read().split()))
dp = [0]*N
for i in range(1,N):
x = dp[i-1] + abs(H[i]-H[i-1])
if i > 1:
y = dp[i-2] + abs(H[i]-H[i-2])
if x>y: x=y
dp[i] = x
answer = dp[-1]
print(answer) | 14 | 17 | 285 | 349 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
H = [int(x) for x in input().split()]
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])
answer = dp[-1]
print(answer)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *H = list(map(int, read().split()))
dp = [0] * N
for i in range(1, N):
x = dp[i - 1] + abs(H[i] - H[i - 1])
if i > 1:
y = dp[i - 2] + abs(H[i] - H[i - 2])
if x > y:
x = y
dp[i] = x
answer = dp[-1]
print(answer)
| false | 17.647059 | [
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**7)",
"-N = int(eval(input()))",
"-H = [int(x) for x in input().split()]",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+N, *H = list(map(int, read().split()))",
"-dp[1] = abs(H[1] - H[0])",
"-for i in range(2, N):",
"- dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2])",
"+for i in range(1, N):",
"+ x = dp[i - 1] + abs(H[i] - H[i - 1])",
"+ if i > 1:",
"+ y = dp[i - 2] + abs(H[i] - H[i - 2])",
"+ if x > y:",
"+ x = y",
"+ dp[i] = x"
]
| false | 0.038046 | 0.036694 | 1.036837 | [
"s776023061",
"s037551676"
]
|
u977389981 | p03379 | python | s251817549 | s844207758 | 354 | 326 | 26,180 | 26,772 | Accepted | Accepted | 7.91 | n = int(eval(input()))
A = list(map(int, input().split()))
sortA = sorted(A)
for i in range(n):
if A[i] <= sortA[(n // 2) - 1]:
print((sortA[n // 2]))
else:
print((sortA[(n // 2) - 1])) | n = int(eval(input()))
A = [int(i) for i in input().split()]
sortA = sorted(A)
mid = sortA[n//2 - 1]
midnext = sortA[n//2]
for i in range(n):
if A[i] <= mid:
print(midnext)
else:
print(mid) | 9 | 12 | 208 | 220 | n = int(eval(input()))
A = list(map(int, input().split()))
sortA = sorted(A)
for i in range(n):
if A[i] <= sortA[(n // 2) - 1]:
print((sortA[n // 2]))
else:
print((sortA[(n // 2) - 1]))
| n = int(eval(input()))
A = [int(i) for i in input().split()]
sortA = sorted(A)
mid = sortA[n // 2 - 1]
midnext = sortA[n // 2]
for i in range(n):
if A[i] <= mid:
print(midnext)
else:
print(mid)
| false | 25 | [
"-A = list(map(int, input().split()))",
"+A = [int(i) for i in input().split()]",
"+mid = sortA[n // 2 - 1]",
"+midnext = sortA[n // 2]",
"- if A[i] <= sortA[(n // 2) - 1]:",
"- print((sortA[n // 2]))",
"+ if A[i] <= mid:",
"+ print(midnext)",
"- print((sortA[(n // 2) - 1]))",
"+ print(mid)"
]
| false | 0.078098 | 0.042802 | 1.824627 | [
"s251817549",
"s844207758"
]
|
u094191970 | p03273 | python | s730169558 | s549861519 | 20 | 18 | 3,064 | 3,188 | Accepted | Accepted | 10 | h,w=list(map(int,input().split()))
a=[list(eval(input())) for i in range(h)]
for i in range(h):
if '#' not in a[i]:
a[i]=['n']*w
for i in range(w):
l=[a[j][i] for j in range(len(a))]
if '#' not in l:
for k in range(len(a)):
a[k][i]='n'
for i in a:
l=[x for x in i if x!='n']
if l:
print((''.join(l))) | h,w=list(map(int,input().split()))
a=[list(eval(input())) for i in range(h)]
l1=[]
for i in a:
if '#' in i:
l1.append(i)
l2=[]
for i in zip(*l1):
if '#' in i:
l2.append(i)
l3=list(zip(*l2))
for i in l3:
print((''.join(i))) | 14 | 14 | 354 | 244 | h, w = list(map(int, input().split()))
a = [list(eval(input())) for i in range(h)]
for i in range(h):
if "#" not in a[i]:
a[i] = ["n"] * w
for i in range(w):
l = [a[j][i] for j in range(len(a))]
if "#" not in l:
for k in range(len(a)):
a[k][i] = "n"
for i in a:
l = [x for x in i if x != "n"]
if l:
print(("".join(l)))
| h, w = list(map(int, input().split()))
a = [list(eval(input())) for i in range(h)]
l1 = []
for i in a:
if "#" in i:
l1.append(i)
l2 = []
for i in zip(*l1):
if "#" in i:
l2.append(i)
l3 = list(zip(*l2))
for i in l3:
print(("".join(i)))
| false | 0 | [
"-for i in range(h):",
"- if \"#\" not in a[i]:",
"- a[i] = [\"n\"] * w",
"-for i in range(w):",
"- l = [a[j][i] for j in range(len(a))]",
"- if \"#\" not in l:",
"- for k in range(len(a)):",
"- a[k][i] = \"n\"",
"+l1 = []",
"- l = [x for x in i if x != \"n\"]",
"- if l:",
"- print((\"\".join(l)))",
"+ if \"#\" in i:",
"+ l1.append(i)",
"+l2 = []",
"+for i in zip(*l1):",
"+ if \"#\" in i:",
"+ l2.append(i)",
"+l3 = list(zip(*l2))",
"+for i in l3:",
"+ print((\"\".join(i)))"
]
| false | 0.007314 | 0.112374 | 0.065084 | [
"s730169558",
"s549861519"
]
|
u427344224 | p03166 | python | s789728072 | s285140323 | 762 | 674 | 125,180 | 125,180 | Accepted | Accepted | 11.55 | import sys
sys.setrecursionlimit(10 ** 8)
N, M = list(map(int, input().split()))
graph = [dict() for _ in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
graph[y - 1][x - 1] = 1
dp = [0 for _ in range(N)]
def dfs(u):
if dp[u] != 0:
return dp[u]
max_dis = 0
for f in list(graph[u].keys()):
if max_dis < dfs(f) + 1:
max_dis = dfs(f) + 1
dp[u] = max_dis
return dp[u]
for i in range(N):
dfs(i)
print((max(dp)))
| import sys
sys.setrecursionlimit(10 ** 8)
N, M = list(map(int, input().split()))
graph = [dict() for _ in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
graph[y - 1][x - 1] = 1
dp = [0 for _ in range(N)]
def dfs(u):
if dp[u] != 0 or len(graph[u]) == 0:
return dp[u]
max_dis = 0
for f in list(graph[u].keys()):
if max_dis < dfs(f) + 1:
max_dis = dfs(f) + 1
dp[u] = max_dis
return dp[u]
for i in range(N):
dfs(i)
print((max(dp)))
| 29 | 29 | 504 | 526 | import sys
sys.setrecursionlimit(10**8)
N, M = list(map(int, input().split()))
graph = [dict() for _ in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
graph[y - 1][x - 1] = 1
dp = [0 for _ in range(N)]
def dfs(u):
if dp[u] != 0:
return dp[u]
max_dis = 0
for f in list(graph[u].keys()):
if max_dis < dfs(f) + 1:
max_dis = dfs(f) + 1
dp[u] = max_dis
return dp[u]
for i in range(N):
dfs(i)
print((max(dp)))
| import sys
sys.setrecursionlimit(10**8)
N, M = list(map(int, input().split()))
graph = [dict() for _ in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
graph[y - 1][x - 1] = 1
dp = [0 for _ in range(N)]
def dfs(u):
if dp[u] != 0 or len(graph[u]) == 0:
return dp[u]
max_dis = 0
for f in list(graph[u].keys()):
if max_dis < dfs(f) + 1:
max_dis = dfs(f) + 1
dp[u] = max_dis
return dp[u]
for i in range(N):
dfs(i)
print((max(dp)))
| false | 0 | [
"- if dp[u] != 0:",
"+ if dp[u] != 0 or len(graph[u]) == 0:"
]
| false | 0.038645 | 0.043243 | 0.893684 | [
"s789728072",
"s285140323"
]
|
u079022693 | p02821 | python | s987898608 | s439661307 | 412 | 311 | 55,356 | 56,248 | Accepted | Accepted | 24.51 | N, M = list(map(int, input().split()))
a = [10**18] + sorted(map(int, input().split()), reverse=True)
def solve(x):
count = 0
j = N
for i in range(1, N+1):
while a[i] + a[j] < x:
j -= 1
count += j
return count
left, right = 0, 10**18
while left < right - 1:
mid = (left + right) // 2
if solve(mid) >= M:
left = mid
else:
right = mid
acc = a[:]
acc[0] = 0
for i in range(N):
acc[i+1] += acc[i]
ans = 0
j = N
for i in range(1, N+1):
while a[i] + a[j] < left+1:
j -= 1
ans += a[i]*j + acc[j]
M -= j
if M:
ans += left * M
print(ans) | N, M = list(map(int, input().split()))
a = [2*10**5+1] + sorted(map(int, input().split()), reverse=True)
def solve(x):
count = 0
j = N
for i in range(1, N+1):
while a[i] + a[j] < x:
j -= 1
count += j
return count
left, right = 0, 2*10**5+1
while left < right - 1:
mid = (left + right) // 2
if solve(mid) >= M:
left = mid
else:
right = mid
acc = a[:]
acc[0] = 0
for i in range(N):
acc[i+1] += acc[i]
ans = 0
j = N
for i in range(1, N+1):
while a[i] + a[j] < left+1:
j -= 1
ans += a[i]*j + acc[j]
M -= j
if M:
ans += left * M
print(ans) | 40 | 39 | 648 | 652 | N, M = list(map(int, input().split()))
a = [10**18] + sorted(map(int, input().split()), reverse=True)
def solve(x):
count = 0
j = N
for i in range(1, N + 1):
while a[i] + a[j] < x:
j -= 1
count += j
return count
left, right = 0, 10**18
while left < right - 1:
mid = (left + right) // 2
if solve(mid) >= M:
left = mid
else:
right = mid
acc = a[:]
acc[0] = 0
for i in range(N):
acc[i + 1] += acc[i]
ans = 0
j = N
for i in range(1, N + 1):
while a[i] + a[j] < left + 1:
j -= 1
ans += a[i] * j + acc[j]
M -= j
if M:
ans += left * M
print(ans)
| N, M = list(map(int, input().split()))
a = [2 * 10**5 + 1] + sorted(map(int, input().split()), reverse=True)
def solve(x):
count = 0
j = N
for i in range(1, N + 1):
while a[i] + a[j] < x:
j -= 1
count += j
return count
left, right = 0, 2 * 10**5 + 1
while left < right - 1:
mid = (left + right) // 2
if solve(mid) >= M:
left = mid
else:
right = mid
acc = a[:]
acc[0] = 0
for i in range(N):
acc[i + 1] += acc[i]
ans = 0
j = N
for i in range(1, N + 1):
while a[i] + a[j] < left + 1:
j -= 1
ans += a[i] * j + acc[j]
M -= j
if M:
ans += left * M
print(ans)
| false | 2.5 | [
"-a = [10**18] + sorted(map(int, input().split()), reverse=True)",
"+a = [2 * 10**5 + 1] + sorted(map(int, input().split()), reverse=True)",
"-left, right = 0, 10**18",
"+left, right = 0, 2 * 10**5 + 1"
]
| false | 0.071099 | 0.037264 | 1.907996 | [
"s987898608",
"s439661307"
]
|
u188827677 | p03993 | python | s429904984 | s046943120 | 92 | 77 | 24,176 | 20,488 | Accepted | Accepted | 16.3 | n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
if a[i] in d and d[a[i]] == i+1: ans += 1
else: d[i+1] = a[i]
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
ans = 0
for num,i in enumerate(a,1):
if i not in d: d[num] = i
else:
if d[i] == num: ans += 1
print(ans) | 9 | 10 | 172 | 182 | n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
ans = 0
for i in range(n):
if a[i] in d and d[a[i]] == i + 1:
ans += 1
else:
d[i + 1] = a[i]
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
ans = 0
for num, i in enumerate(a, 1):
if i not in d:
d[num] = i
else:
if d[i] == num:
ans += 1
print(ans)
| false | 10 | [
"-for i in range(n):",
"- if a[i] in d and d[a[i]] == i + 1:",
"- ans += 1",
"+for num, i in enumerate(a, 1):",
"+ if i not in d:",
"+ d[num] = i",
"- d[i + 1] = a[i]",
"+ if d[i] == num:",
"+ ans += 1"
]
| false | 0.106785 | 0.155319 | 0.687523 | [
"s429904984",
"s046943120"
]
|
u330314953 | p03814 | python | s365398828 | s793440580 | 89 | 61 | 3,512 | 3,516 | Accepted | Accepted | 31.46 | s = str(eval(input()))
a = 199999
z = 0
for i in range(len(s)):
if s[i] == "A":
a = min(a,i)
elif s[i] == "Z":
z = max(z,i)
print((z - a + 1)) | s = str(eval(input()))
z = 0
a = s.find("A")
for i in range(len(s)):
if s[i] == "Z":
z = max(z,i)
print((z - a + 1)) | 13 | 11 | 175 | 129 | s = str(eval(input()))
a = 199999
z = 0
for i in range(len(s)):
if s[i] == "A":
a = min(a, i)
elif s[i] == "Z":
z = max(z, i)
print((z - a + 1))
| s = str(eval(input()))
z = 0
a = s.find("A")
for i in range(len(s)):
if s[i] == "Z":
z = max(z, i)
print((z - a + 1))
| false | 15.384615 | [
"-a = 199999",
"+a = s.find(\"A\")",
"- if s[i] == \"A\":",
"- a = min(a, i)",
"- elif s[i] == \"Z\":",
"+ if s[i] == \"Z\":"
]
| false | 0.036848 | 0.036757 | 1.002482 | [
"s365398828",
"s793440580"
]
|
u647999897 | p02720 | python | s248182072 | s585081602 | 266 | 136 | 53,872 | 80,736 | Accepted | Accepted | 48.87 | def solve():
K = int(eval(input()))
all = []
for i in range(1,10):
dfs(1,i,all)
all.sort()
print((all[K-1]))
def dfs(d, val, all):
all.append(val)
if d == 10:
return
for j in [-1,0,1]:
add = val % 10 + j
if 0 <= add <= 9:
dfs(d+1, val*10+add, all)
if __name__ == '__main__':
solve() | def solve():
K = int(eval(input()))
lunluns = []
for i in range(1,10):
dfs(1,i,lunluns)
lunluns.sort()
print((lunluns[K-1]))
def dfs(d,now,lunluns):
lunluns.append(now)
if d == 10:
return
for i in [-1,0,1]:
add = now % 10 + i
if 0 <= add <= 9:
dfs(d+1,now*10+add, lunluns)
if __name__ == '__main__':
solve()
| 22 | 23 | 392 | 424 | def solve():
K = int(eval(input()))
all = []
for i in range(1, 10):
dfs(1, i, all)
all.sort()
print((all[K - 1]))
def dfs(d, val, all):
all.append(val)
if d == 10:
return
for j in [-1, 0, 1]:
add = val % 10 + j
if 0 <= add <= 9:
dfs(d + 1, val * 10 + add, all)
if __name__ == "__main__":
solve()
| def solve():
K = int(eval(input()))
lunluns = []
for i in range(1, 10):
dfs(1, i, lunluns)
lunluns.sort()
print((lunluns[K - 1]))
def dfs(d, now, lunluns):
lunluns.append(now)
if d == 10:
return
for i in [-1, 0, 1]:
add = now % 10 + i
if 0 <= add <= 9:
dfs(d + 1, now * 10 + add, lunluns)
if __name__ == "__main__":
solve()
| false | 4.347826 | [
"- all = []",
"+ lunluns = []",
"- dfs(1, i, all)",
"- all.sort()",
"- print((all[K - 1]))",
"+ dfs(1, i, lunluns)",
"+ lunluns.sort()",
"+ print((lunluns[K - 1]))",
"-def dfs(d, val, all):",
"- all.append(val)",
"+def dfs(d, now, lunluns):",
"+ lunluns.append(now)",
"- for j in [-1, 0, 1]:",
"- add = val % 10 + j",
"+ for i in [-1, 0, 1]:",
"+ add = now % 10 + i",
"- dfs(d + 1, val * 10 + add, all)",
"+ dfs(d + 1, now * 10 + add, lunluns)"
]
| false | 0.193276 | 0.005874 | 32.904299 | [
"s248182072",
"s585081602"
]
|
u123745130 | p02602 | python | s423601191 | s172976984 | 192 | 153 | 31,684 | 31,720 | Accepted | Accepted | 20.31 | n,k=list(map(int,input().split()))
lst_1=list(map(int,input().split()))
# print(lst_1)
lst_2=[]
for i in range(n-k):
temp=1
temp=lst_1[i+k]/lst_1[i]
lst_2.append(temp)
for i in lst_2:
if i>1:
print("Yes")
else:print("No")
| n,k=list(map(int,input().split()))
lst_1=list(map(int,input().split()))
# print(lst_1)
for i in range(n-k):
if(lst_1[i+k]>lst_1[i]):
print("Yes")
else:print("No") | 12 | 7 | 255 | 178 | n, k = list(map(int, input().split()))
lst_1 = list(map(int, input().split()))
# print(lst_1)
lst_2 = []
for i in range(n - k):
temp = 1
temp = lst_1[i + k] / lst_1[i]
lst_2.append(temp)
for i in lst_2:
if i > 1:
print("Yes")
else:
print("No")
| n, k = list(map(int, input().split()))
lst_1 = list(map(int, input().split()))
# print(lst_1)
for i in range(n - k):
if lst_1[i + k] > lst_1[i]:
print("Yes")
else:
print("No")
| false | 41.666667 | [
"-lst_2 = []",
"- temp = 1",
"- temp = lst_1[i + k] / lst_1[i]",
"- lst_2.append(temp)",
"-for i in lst_2:",
"- if i > 1:",
"+ if lst_1[i + k] > lst_1[i]:"
]
| false | 0.043969 | 0.044734 | 0.982897 | [
"s423601191",
"s172976984"
]
|
u515775940 | p02747 | python | s500823804 | s919950391 | 20 | 17 | 3,188 | 2,940 | Accepted | Accepted | 15 | import re
s = str(eval(input()))
flag = True
s_array = s.split('hi')
for list in s_array:
res = re.match('[a-z0-9]', list)
if res and len(res.group()) > 0 :
flag = False
break
if flag:
print('Yes')
else:
print('No') | s = eval(input())
replaced_str = s.replace('hi','')
if len(replaced_str) > 0:
print('No')
else:
print('Yes') | 18 | 6 | 283 | 111 | import re
s = str(eval(input()))
flag = True
s_array = s.split("hi")
for list in s_array:
res = re.match("[a-z0-9]", list)
if res and len(res.group()) > 0:
flag = False
break
if flag:
print("Yes")
else:
print("No")
| s = eval(input())
replaced_str = s.replace("hi", "")
if len(replaced_str) > 0:
print("No")
else:
print("Yes")
| false | 66.666667 | [
"-import re",
"-",
"-s = str(eval(input()))",
"-flag = True",
"-s_array = s.split(\"hi\")",
"-for list in s_array:",
"- res = re.match(\"[a-z0-9]\", list)",
"- if res and len(res.group()) > 0:",
"- flag = False",
"- break",
"-if flag:",
"+s = eval(input())",
"+replaced_str = s.replace(\"hi\", \"\")",
"+if len(replaced_str) > 0:",
"+ print(\"No\")",
"+else:",
"-else:",
"- print(\"No\")"
]
| false | 0.059394 | 0.054415 | 1.091508 | [
"s500823804",
"s919950391"
]
|
u957167787 | p02996 | python | s530601325 | s577204404 | 1,096 | 988 | 61,536 | 55,260 | Accepted | Accepted | 9.85 | N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート
AB = sorted(AB, key=lambda x: x[1])
t = 0
for i in range(N):
if t <= AB[i][1] - AB[i][0]: # B-A以下のとき
t += AB[i][0]
continue
else:
print('No')
break
else:
if t <= AB[N-1][1]:
print('Yes')
else:
print('No')
| N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
# AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート
AB = sorted(AB, key=lambda x: x[1]) # B-Aが同じ値の時はBが小さい順に並び替え
t = 0
for i in range(N):
if t <= AB[i][1] - AB[i][0]: # B-A以下のとき
t += AB[i][0]
continue
else:
print('No')
break
else:
if t <= AB[N-1][1]:
print('Yes')
else:
print('No')
| 20 | 20 | 421 | 447 | N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[1] - x[0]) # B-Aが小さい順にソート
AB = sorted(AB, key=lambda x: x[1])
t = 0
for i in range(N):
if t <= AB[i][1] - AB[i][0]: # B-A以下のとき
t += AB[i][0]
continue
else:
print("No")
break
else:
if t <= AB[N - 1][1]:
print("Yes")
else:
print("No")
| N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
# AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート
AB = sorted(AB, key=lambda x: x[1]) # B-Aが同じ値の時はBが小さい順に並び替え
t = 0
for i in range(N):
if t <= AB[i][1] - AB[i][0]: # B-A以下のとき
t += AB[i][0]
continue
else:
print("No")
break
else:
if t <= AB[N - 1][1]:
print("Yes")
else:
print("No")
| false | 0 | [
"-AB = sorted(AB, key=lambda x: x[1] - x[0]) # B-Aが小さい順にソート",
"-AB = sorted(AB, key=lambda x: x[1])",
"+# AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート",
"+AB = sorted(AB, key=lambda x: x[1]) # B-Aが同じ値の時はBが小さい順に並び替え"
]
| false | 0.066223 | 0.037545 | 1.763823 | [
"s530601325",
"s577204404"
]
|
u057668615 | p02659 | python | s105793018 | s047755055 | 23 | 20 | 9,096 | 9,120 | Accepted | Accepted | 13.04 | A, B = list(map(float, input().split()))
#print(A*B)
print((int((int(A+0.5)*int(B*100+0.5))//100)))
| A, B = list(map(float, input().split()))
#print(A*B)
print((int((int(A)*int(B*100+0.5))//100)))
| 3 | 3 | 100 | 96 | A, B = list(map(float, input().split()))
# print(A*B)
print((int((int(A + 0.5) * int(B * 100 + 0.5)) // 100)))
| A, B = list(map(float, input().split()))
# print(A*B)
print((int((int(A) * int(B * 100 + 0.5)) // 100)))
| false | 0 | [
"-print((int((int(A + 0.5) * int(B * 100 + 0.5)) // 100)))",
"+print((int((int(A) * int(B * 100 + 0.5)) // 100)))"
]
| false | 0.036399 | 0.036666 | 0.992729 | [
"s105793018",
"s047755055"
]
|
u968166680 | p02685 | python | s057857567 | s658643604 | 660 | 297 | 32,496 | 32,564 | Accepted | Accepted | 55 | from sys import stdin, setrecursionlimit
from math import factorial
setrecursionlimit(10 ** 9)
INF = 1 << 60
def input():
return stdin.readline().strip()
def main():
N, M, K = list(map(int, input().split()))
MOD = 998244353
fac = [0] * (N + 10)
finv = [0] * (N + 10)
inv = [0] * (N + 10)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, N + 2):
fac[i] = fac[i - 1] * i % MOD
inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
def COM(n, k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
ans = 0
for k in range(K + 1):
ans += COM(N - 1, k) * ((M % MOD) * pow(M - 1, (N - k - 1), MOD)) % MOD
print((ans % MOD))
return
if __name__ == '__main__':
main()
| from sys import stdin, setrecursionlimit
from math import factorial
setrecursionlimit(10 ** 9)
INF = 1 << 60
def input():
return stdin.readline().strip()
def main():
N, M, K = list(map(int, input().split()))
MOD = 998244353
COM_MAX = N
fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, COM_MAX + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
def mod_com(n, k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
ans = 0
power = M % MOD
for k in range(N - 1, -1, -1):
if k <= K:
ans += mod_com(N - 1, k) * power % MOD
power = power * (M - 1) % MOD
print((ans % MOD))
return
if __name__ == '__main__':
main()
| 43 | 47 | 947 | 1,042 | from sys import stdin, setrecursionlimit
from math import factorial
setrecursionlimit(10**9)
INF = 1 << 60
def input():
return stdin.readline().strip()
def main():
N, M, K = list(map(int, input().split()))
MOD = 998244353
fac = [0] * (N + 10)
finv = [0] * (N + 10)
inv = [0] * (N + 10)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, N + 2):
fac[i] = fac[i - 1] * i % MOD
inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
def COM(n, k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
ans = 0
for k in range(K + 1):
ans += COM(N - 1, k) * ((M % MOD) * pow(M - 1, (N - k - 1), MOD)) % MOD
print((ans % MOD))
return
if __name__ == "__main__":
main()
| from sys import stdin, setrecursionlimit
from math import factorial
setrecursionlimit(10**9)
INF = 1 << 60
def input():
return stdin.readline().strip()
def main():
N, M, K = list(map(int, input().split()))
MOD = 998244353
COM_MAX = N
fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, COM_MAX + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
def mod_com(n, k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
ans = 0
power = M % MOD
for k in range(N - 1, -1, -1):
if k <= K:
ans += mod_com(N - 1, k) * power % MOD
power = power * (M - 1) % MOD
print((ans % MOD))
return
if __name__ == "__main__":
main()
| false | 8.510638 | [
"- fac = [0] * (N + 10)",
"- finv = [0] * (N + 10)",
"- inv = [0] * (N + 10)",
"+ COM_MAX = N",
"+ fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)",
"- for i in range(2, N + 2):",
"+ for i in range(2, COM_MAX + 1):",
"- def COM(n, k):",
"+ def mod_com(n, k):",
"- for k in range(K + 1):",
"- ans += COM(N - 1, k) * ((M % MOD) * pow(M - 1, (N - k - 1), MOD)) % MOD",
"+ power = M % MOD",
"+ for k in range(N - 1, -1, -1):",
"+ if k <= K:",
"+ ans += mod_com(N - 1, k) * power % MOD",
"+ power = power * (M - 1) % MOD"
]
| false | 0.167649 | 0.157721 | 1.062948 | [
"s057857567",
"s658643604"
]
|
u670180528 | p02889 | python | s156946871 | s783887172 | 1,541 | 436 | 40,860 | 40,888 | Accepted | Accepted | 71.71 | from scipy.sparse import*
f=csgraph.floyd_warshall
I=9e9
n,m,l,*t=list(map(int,open(0).read().split()))
d=eval('[I]*-~n,'*-~n)
for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
d=f(d,0)
d[d>l]=I
d[d<I]=1
d=f(d)
for i in zip(*[iter(t[m*3+1:])]*2):
print(((I>d[i])*int(d[i])-1)) | def main():
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
n, m, l, *L = list(map(int, open(0).read().split()))
abc = L[:3 * m];
st = L[3 * m + 1:]
r = [[float("inf")] * n for _ in range(n)]
for a, b, c in zip(*[iter(abc)] * 3):
if c <= l: r[a - 1][b - 1] = c
fw = floyd_warshall(r, 0)
ans = floyd_warshall(np.where(fw <= l, 1, fw), 0) - 1
for s, t in zip(*[iter(st)] * 2):
x = ans[s - 1, t - 1]
if x == float("inf"):
print((-1))
else:
print((int(x)))
if __name__ == "__main__":
main()
#after contest | 12 | 23 | 277 | 560 | from scipy.sparse import *
f = csgraph.floyd_warshall
I = 9e9
n, m, l, *t = list(map(int, open(0).read().split()))
d = eval("[I]*-~n," * -~n)
for a, b, c in zip(*[iter(t[: m * 3])] * 3):
d[a][b] = c
d = f(d, 0)
d[d > l] = I
d[d < I] = 1
d = f(d)
for i in zip(*[iter(t[m * 3 + 1 :])] * 2):
print(((I > d[i]) * int(d[i]) - 1))
| def main():
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
n, m, l, *L = list(map(int, open(0).read().split()))
abc = L[: 3 * m]
st = L[3 * m + 1 :]
r = [[float("inf")] * n for _ in range(n)]
for a, b, c in zip(*[iter(abc)] * 3):
if c <= l:
r[a - 1][b - 1] = c
fw = floyd_warshall(r, 0)
ans = floyd_warshall(np.where(fw <= l, 1, fw), 0) - 1
for s, t in zip(*[iter(st)] * 2):
x = ans[s - 1, t - 1]
if x == float("inf"):
print((-1))
else:
print((int(x)))
if __name__ == "__main__":
main()
# after contest
| false | 47.826087 | [
"-from scipy.sparse import *",
"+def main():",
"+ from scipy.sparse.csgraph import floyd_warshall",
"+ import numpy as np",
"-f = csgraph.floyd_warshall",
"-I = 9e9",
"-n, m, l, *t = list(map(int, open(0).read().split()))",
"-d = eval(\"[I]*-~n,\" * -~n)",
"-for a, b, c in zip(*[iter(t[: m * 3])] * 3):",
"- d[a][b] = c",
"-d = f(d, 0)",
"-d[d > l] = I",
"-d[d < I] = 1",
"-d = f(d)",
"-for i in zip(*[iter(t[m * 3 + 1 :])] * 2):",
"- print(((I > d[i]) * int(d[i]) - 1))",
"+ n, m, l, *L = list(map(int, open(0).read().split()))",
"+ abc = L[: 3 * m]",
"+ st = L[3 * m + 1 :]",
"+ r = [[float(\"inf\")] * n for _ in range(n)]",
"+ for a, b, c in zip(*[iter(abc)] * 3):",
"+ if c <= l:",
"+ r[a - 1][b - 1] = c",
"+ fw = floyd_warshall(r, 0)",
"+ ans = floyd_warshall(np.where(fw <= l, 1, fw), 0) - 1",
"+ for s, t in zip(*[iter(st)] * 2):",
"+ x = ans[s - 1, t - 1]",
"+ if x == float(\"inf\"):",
"+ print((-1))",
"+ else:",
"+ print((int(x)))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()",
"+# after contest"
]
| false | 0.609441 | 1.002941 | 0.607654 | [
"s156946871",
"s783887172"
]
|
u657913472 | p03473 | python | s343477773 | s298492442 | 17 | 11 | 2,940 | 2,572 | Accepted | Accepted | 35.29 | print((48-int(eval(input())))) | print(48-eval(input())) | 1 | 1 | 22 | 16 | print((48 - int(eval(input()))))
| print(48 - eval(input()))
| false | 0 | [
"-print((48 - int(eval(input()))))",
"+print(48 - eval(input()))"
]
| false | 0.037968 | 0.03989 | 0.951818 | [
"s343477773",
"s298492442"
]
|
u863442865 | p02762 | python | s812197157 | s988658732 | 1,119 | 902 | 122,528 | 95,776 | Accepted | Accepted | 19.39 | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
#from itertools import product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 10**9 + 7
n,m,k = list(map(int, input().split()))
def find(par, x):
if par[x] < 0:
return x
else:
par[x] = find(par, par[x])
return par[x]
def unite(par, x,y):
x = find(par,x)
y = find(par,y)
if x == y:
return False
else:
if par[x] > par[y]:
x,y = y,x
par[x] += par[y]
par[y] = x
return True
def same(par, x,y):
return find(par, x) == find(par, y)
def size(par, x):
return -par[find(par, x)]
def members(par, x, n):
root = find(par, x)
return [i for i in range(n) if find(par, i) == root]
friend = [-1]*n
adj = [[] for _ in range(n)]
for _ in range(m):
a,b = list(map(int, input().split()))
adj[a-1].append(b-1)
adj[b-1].append(a-1)
unite(friend, a-1, b-1)
block = [[] for _ in range(n)] #頂点数, 場合によって変える
for _ in range(k):
a,b = list(map(int, input().split()))
block[a-1].append(b-1)
block[b-1].append(a-1)
res = []
for i in range(n):
p = size(friend, i) - 1 -len(adj[i])
for q in block[i]:
if same(friend, i, q):
p -= 1
res.append(p)
print((*res))
if __name__ == '__main__':
main() | #木作って終わり、問題文難しい
#
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
#from itertools import product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 10**9 + 7
n,m,k = list(map(int, input().split()))
def find(par, x):
if par[x] < 0:
return x
else:
par[x] = find(par, par[x])
return par[x]
def unite(par, x,y):
x = find(par,x)
y = find(par,y)
if x == y:
return False
else:
if par[x] > par[y]:
x,y = y,x
par[x] += par[y]
par[y] = x
return True
def same(par, x,y):
return find(par, x) == find(par, y)
def size(par, x):
return -par[find(par, x)]
friend = [-1]*n
adj = [[] for _ in range(n)]
for _ in range(m):
a,b = list(map(int, input().split()))
adj[a-1].append(b-1)
adj[b-1].append(a-1)
unite(friend, a-1, b-1)
res = []
for i in range(n):
p = size(friend, i) - 1 -len(adj[i])
res.append(p)
for _ in range(k):
a,b = list(map(int, input().split()))
if same(friend, a-1, b-1):
res[a-1] -= 1
res[b-1] -= 1
print((*res))
if __name__ == '__main__':
main() | 72 | 69 | 1,904 | 1,688 | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
# from itertools import product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
# from operator import itemgetter
# inf = 10**17
# mod = 10**9 + 7
n, m, k = list(map(int, input().split()))
def find(par, x):
if par[x] < 0:
return x
else:
par[x] = find(par, par[x])
return par[x]
def unite(par, x, y):
x = find(par, x)
y = find(par, y)
if x == y:
return False
else:
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
return True
def same(par, x, y):
return find(par, x) == find(par, y)
def size(par, x):
return -par[find(par, x)]
def members(par, x, n):
root = find(par, x)
return [i for i in range(n) if find(par, i) == root]
friend = [-1] * n
adj = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
adj[a - 1].append(b - 1)
adj[b - 1].append(a - 1)
unite(friend, a - 1, b - 1)
block = [[] for _ in range(n)] # 頂点数, 場合によって変える
for _ in range(k):
a, b = list(map(int, input().split()))
block[a - 1].append(b - 1)
block[b - 1].append(a - 1)
res = []
for i in range(n):
p = size(friend, i) - 1 - len(adj[i])
for q in block[i]:
if same(friend, i, q):
p -= 1
res.append(p)
print((*res))
if __name__ == "__main__":
main()
| # 木作って終わり、問題文難しい
#
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
# from itertools import product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
# from operator import itemgetter
# inf = 10**17
# mod = 10**9 + 7
n, m, k = list(map(int, input().split()))
def find(par, x):
if par[x] < 0:
return x
else:
par[x] = find(par, par[x])
return par[x]
def unite(par, x, y):
x = find(par, x)
y = find(par, y)
if x == y:
return False
else:
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
return True
def same(par, x, y):
return find(par, x) == find(par, y)
def size(par, x):
return -par[find(par, x)]
friend = [-1] * n
adj = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
adj[a - 1].append(b - 1)
adj[b - 1].append(a - 1)
unite(friend, a - 1, b - 1)
res = []
for i in range(n):
p = size(friend, i) - 1 - len(adj[i])
res.append(p)
for _ in range(k):
a, b = list(map(int, input().split()))
if same(friend, a - 1, b - 1):
res[a - 1] -= 1
res[b - 1] -= 1
print((*res))
if __name__ == "__main__":
main()
| false | 4.166667 | [
"+# 木作って終わり、問題文難しい",
"+#",
"- def members(par, x, n):",
"- root = find(par, x)",
"- return [i for i in range(n) if find(par, i) == root]",
"-",
"- block = [[] for _ in range(n)] # 頂点数, 場合によって変える",
"- for _ in range(k):",
"- a, b = list(map(int, input().split()))",
"- block[a - 1].append(b - 1)",
"- block[b - 1].append(a - 1)",
"- for q in block[i]:",
"- if same(friend, i, q):",
"- p -= 1",
"+ for _ in range(k):",
"+ a, b = list(map(int, input().split()))",
"+ if same(friend, a - 1, b - 1):",
"+ res[a - 1] -= 1",
"+ res[b - 1] -= 1"
]
| false | 0.116047 | 0.069387 | 1.672448 | [
"s812197157",
"s988658732"
]
|
u607563136 | p02861 | python | s172031615 | s625009444 | 327 | 295 | 13,860 | 13,780 | Accepted | Accepted | 9.79 | from itertools import permutations
import math
n = int(eval(input()))
x,y = [],[]
for _ in range(n):
x_, y_ =list(map(int,input().split()))
x.append(x_)
y.append(y_)
c = list(permutations([i for i in range(1,n+1)],n))
g = [[-1]*(n+1) for _ in range(n+1)]
sum = 0
for ci in (c):
tmp = 0
for i in range(len(ci)-1):
if g[ci[i]][ci[i+1]] == -1:
tmp += math.sqrt((x[ci[i]-1]-x[ci[i+1]-1])**2
+ (y[ci[i]-1]-y[ci[i+1]-1])**2)
else:
tmp += g[ci[i]][ci[i+1]]
sum += tmp
print((sum/len(c))) | from itertools import permutations
import math
n = int(eval(input()))
x,y = [],[]
for _ in range(n):
x_, y_ =list(map(int,input().split()))
x.append(x_)
y.append(y_)
c = list(permutations([i for i in range(1,n+1)],n))
sum = 0
for ci in (c):
tmp = 0
for i in range(len(ci)-1):
tmp += math.sqrt((x[ci[i]-1]-x[ci[i+1]-1])**2
+ (y[ci[i]-1]-y[ci[i+1]-1])**2)
sum += tmp
print((sum/len(c))) | 23 | 17 | 584 | 452 | from itertools import permutations
import math
n = int(eval(input()))
x, y = [], []
for _ in range(n):
x_, y_ = list(map(int, input().split()))
x.append(x_)
y.append(y_)
c = list(permutations([i for i in range(1, n + 1)], n))
g = [[-1] * (n + 1) for _ in range(n + 1)]
sum = 0
for ci in c:
tmp = 0
for i in range(len(ci) - 1):
if g[ci[i]][ci[i + 1]] == -1:
tmp += math.sqrt(
(x[ci[i] - 1] - x[ci[i + 1] - 1]) ** 2
+ (y[ci[i] - 1] - y[ci[i + 1] - 1]) ** 2
)
else:
tmp += g[ci[i]][ci[i + 1]]
sum += tmp
print((sum / len(c)))
| from itertools import permutations
import math
n = int(eval(input()))
x, y = [], []
for _ in range(n):
x_, y_ = list(map(int, input().split()))
x.append(x_)
y.append(y_)
c = list(permutations([i for i in range(1, n + 1)], n))
sum = 0
for ci in c:
tmp = 0
for i in range(len(ci) - 1):
tmp += math.sqrt(
(x[ci[i] - 1] - x[ci[i + 1] - 1]) ** 2
+ (y[ci[i] - 1] - y[ci[i + 1] - 1]) ** 2
)
sum += tmp
print((sum / len(c)))
| false | 26.086957 | [
"-g = [[-1] * (n + 1) for _ in range(n + 1)]",
"- if g[ci[i]][ci[i + 1]] == -1:",
"- tmp += math.sqrt(",
"- (x[ci[i] - 1] - x[ci[i + 1] - 1]) ** 2",
"- + (y[ci[i] - 1] - y[ci[i + 1] - 1]) ** 2",
"- )",
"- else:",
"- tmp += g[ci[i]][ci[i + 1]]",
"+ tmp += math.sqrt(",
"+ (x[ci[i] - 1] - x[ci[i + 1] - 1]) ** 2",
"+ + (y[ci[i] - 1] - y[ci[i + 1] - 1]) ** 2",
"+ )"
]
| false | 0.045539 | 0.049374 | 0.922333 | [
"s172031615",
"s625009444"
]
|
u912237403 | p00124 | python | s942741603 | s388894440 | 20 | 10 | 4,240 | 4,236 | Accepted | Accepted | 50 | f=0
while 1:
n=eval(input())
if n==0: break
if f>0: print()
N=[""]*n
C=[0]*n
for i in range(n):
s=input()
p=s.index(" ")
N[i]=s[:p]
a,b,c=list(map(int,s[p+1:].split(" ")))
C[i]=(i,a*3+c)
C=sorted(C,key=lambda x:(-x[1],x[0]))
for e in C: print("".join([N[e[0]],",",str(e[1])]))
f=1 | f=0
while 1:
n=eval(input())
if n==0: break
if f>0: print()
C=[()]*n
for i in range(n):
s=input()
p=s.index(" ")
a,b,c=list(map(int,s[p+1:].split(" ")))
C[i]=(i,a*3+c,s[:p])
C=sorted(C,key=lambda x:(-x[1],x[0]))
for e in C: print(e[2]+","+str(e[1]))
f=1 | 16 | 14 | 322 | 287 | f = 0
while 1:
n = eval(input())
if n == 0:
break
if f > 0:
print()
N = [""] * n
C = [0] * n
for i in range(n):
s = input()
p = s.index(" ")
N[i] = s[:p]
a, b, c = list(map(int, s[p + 1 :].split(" ")))
C[i] = (i, a * 3 + c)
C = sorted(C, key=lambda x: (-x[1], x[0]))
for e in C:
print("".join([N[e[0]], ",", str(e[1])]))
f = 1
| f = 0
while 1:
n = eval(input())
if n == 0:
break
if f > 0:
print()
C = [()] * n
for i in range(n):
s = input()
p = s.index(" ")
a, b, c = list(map(int, s[p + 1 :].split(" ")))
C[i] = (i, a * 3 + c, s[:p])
C = sorted(C, key=lambda x: (-x[1], x[0]))
for e in C:
print(e[2] + "," + str(e[1]))
f = 1
| false | 12.5 | [
"- N = [\"\"] * n",
"- C = [0] * n",
"+ C = [()] * n",
"- N[i] = s[:p]",
"- C[i] = (i, a * 3 + c)",
"+ C[i] = (i, a * 3 + c, s[:p])",
"- print(\"\".join([N[e[0]], \",\", str(e[1])]))",
"+ print(e[2] + \",\" + str(e[1]))"
]
| false | 0.040167 | 0.041558 | 0.966532 | [
"s942741603",
"s388894440"
]
|
u761320129 | p03608 | python | s635835945 | s018403455 | 560 | 309 | 72,152 | 77,892 | Accepted | Accepted | 44.82 | N,M,R = list(map(int,input().split()))
rs = list(map(int,input().split()))
ABC = [tuple(map(int,input().split())) for i in range(M)]
INF = float('inf')
d = [[INF]*N for _ in range(N)]
for a,b,c in ABC:
a,b = a-1,b-1
d[a][b] = d[b][a] = c
for i in range(N):
d[i][i] = 0
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = INF
import itertools
for ptn in itertools.permutations(rs):
tmp = 0
for a,b in zip(ptn,ptn[1:]):
a,b = a-1,b-1
tmp += d[a][b]
ans = min(ans, tmp)
print(ans) | N,M,R = list(map(int,input().split()))
R = list(map(int,input().split()))
ABC = [tuple(map(int,input().split())) for i in range(M)]
INF = float('inf')
d = [[INF]*N for _ in range(N)]
for i in range(N):
d[i][i] = 0
for a,b,c in ABC:
a,b = a-1,b-1
d[a][b] = d[b][a] = c
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = INF
import itertools
for ptn in itertools.permutations(R):
tmp = 0
for a,b in zip(ptn,ptn[1:]):
tmp += d[a-1][b-1]
ans = min(ans, tmp)
print(ans) | 26 | 25 | 616 | 595 | N, M, R = list(map(int, input().split()))
rs = list(map(int, input().split()))
ABC = [tuple(map(int, input().split())) for i in range(M)]
INF = float("inf")
d = [[INF] * N for _ in range(N)]
for a, b, c in ABC:
a, b = a - 1, b - 1
d[a][b] = d[b][a] = c
for i in range(N):
d[i][i] = 0
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = INF
import itertools
for ptn in itertools.permutations(rs):
tmp = 0
for a, b in zip(ptn, ptn[1:]):
a, b = a - 1, b - 1
tmp += d[a][b]
ans = min(ans, tmp)
print(ans)
| N, M, R = list(map(int, input().split()))
R = list(map(int, input().split()))
ABC = [tuple(map(int, input().split())) for i in range(M)]
INF = float("inf")
d = [[INF] * N for _ in range(N)]
for i in range(N):
d[i][i] = 0
for a, b, c in ABC:
a, b = a - 1, b - 1
d[a][b] = d[b][a] = c
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = INF
import itertools
for ptn in itertools.permutations(R):
tmp = 0
for a, b in zip(ptn, ptn[1:]):
tmp += d[a - 1][b - 1]
ans = min(ans, tmp)
print(ans)
| false | 3.846154 | [
"-rs = list(map(int, input().split()))",
"+R = list(map(int, input().split()))",
"+for i in range(N):",
"+ d[i][i] = 0",
"-for i in range(N):",
"- d[i][i] = 0",
"-for ptn in itertools.permutations(rs):",
"+for ptn in itertools.permutations(R):",
"- a, b = a - 1, b - 1",
"- tmp += d[a][b]",
"+ tmp += d[a - 1][b - 1]"
]
| false | 0.046486 | 0.046393 | 1.002021 | [
"s635835945",
"s018403455"
]
|
u699296734 | p03721 | python | s783865689 | s601602577 | 355 | 225 | 27,612 | 11,568 | Accepted | Accepted | 36.62 | n, k = list(map(int, input().split()))
sum_b = 0
ab_list = []
for i in range(n):
ab_list.append(list(map(int, input().split())))
ab_list.sort()
for i in range(n):
a, b = ab_list[i]
sum_b += b
if sum_b >= k:
print(a)
break
| n, k = list(map(int, input().split()))
bucket = [0] * 10 ** 5
for i in range(n):
a, b = list(map(int, input().split()))
bucket[a - 1] += b
sum_b = 0
for i in range(len(bucket)):
sum_b += bucket[i]
if sum_b >= k:
print((i + 1))
break
| 14 | 12 | 263 | 263 | n, k = list(map(int, input().split()))
sum_b = 0
ab_list = []
for i in range(n):
ab_list.append(list(map(int, input().split())))
ab_list.sort()
for i in range(n):
a, b = ab_list[i]
sum_b += b
if sum_b >= k:
print(a)
break
| n, k = list(map(int, input().split()))
bucket = [0] * 10**5
for i in range(n):
a, b = list(map(int, input().split()))
bucket[a - 1] += b
sum_b = 0
for i in range(len(bucket)):
sum_b += bucket[i]
if sum_b >= k:
print((i + 1))
break
| false | 14.285714 | [
"+bucket = [0] * 10**5",
"+for i in range(n):",
"+ a, b = list(map(int, input().split()))",
"+ bucket[a - 1] += b",
"-ab_list = []",
"-for i in range(n):",
"- ab_list.append(list(map(int, input().split())))",
"-ab_list.sort()",
"-for i in range(n):",
"- a, b = ab_list[i]",
"- sum_b += b",
"+for i in range(len(bucket)):",
"+ sum_b += bucket[i]",
"- print(a)",
"+ print((i + 1))"
]
| false | 0.036191 | 0.038402 | 0.94244 | [
"s783865689",
"s601602577"
]
|
u057109575 | p02744 | python | s719775470 | s344309660 | 447 | 166 | 56,920 | 78,192 | Accepted | Accepted | 62.86 |
N = int(eval(input()))
def dfs(x):
if len(x) == N:
s = "".join(chr(v + ord("a")) for v in x)
print(s)
return
val = max(x)
for i in range(val + 2):
x.append(i)
dfs(x)
x.pop()
dfs([0])
|
N = int(eval(input()))
def func(x):
if len(x) == N:
print(("".join(x)))
return
last = ord(max(x)) - ord("a") + 1 if x else 0
for i in range(min(26, last) + 1):
x.append(chr(ord("a") + i))
func(x)
x.pop()
func([])
| 16 | 17 | 256 | 279 | N = int(eval(input()))
def dfs(x):
if len(x) == N:
s = "".join(chr(v + ord("a")) for v in x)
print(s)
return
val = max(x)
for i in range(val + 2):
x.append(i)
dfs(x)
x.pop()
dfs([0])
| N = int(eval(input()))
def func(x):
if len(x) == N:
print(("".join(x)))
return
last = ord(max(x)) - ord("a") + 1 if x else 0
for i in range(min(26, last) + 1):
x.append(chr(ord("a") + i))
func(x)
x.pop()
func([])
| false | 5.882353 | [
"-def dfs(x):",
"+def func(x):",
"- s = \"\".join(chr(v + ord(\"a\")) for v in x)",
"- print(s)",
"+ print((\"\".join(x)))",
"- val = max(x)",
"- for i in range(val + 2):",
"- x.append(i)",
"- dfs(x)",
"+ last = ord(max(x)) - ord(\"a\") + 1 if x else 0",
"+ for i in range(min(26, last) + 1):",
"+ x.append(chr(ord(\"a\") + i))",
"+ func(x)",
"-dfs([0])",
"+func([])"
]
| false | 0.106215 | 0.043598 | 2.436265 | [
"s719775470",
"s344309660"
]
|
u348805958 | p02659 | python | s200295349 | s546973770 | 26 | 24 | 9,920 | 9,172 | Accepted | Accepted | 7.69 | #!python3
iim = lambda: list(map(int, input().rstrip().split()))
from decimal import Decimal
def resolve():
a, b = input().split()
a = int(a); b = int(b.replace(".", ""))
print((a*b//100))
if __name__ == "__main__":
resolve()
| #!python3
iim = lambda: list(map(int, input().rstrip().split()))
def resolve():
a, b = input().split()
a = int(a); b = int(b.replace(".", ""))
print((a*b//100))
if __name__ == "__main__":
resolve()
| 13 | 12 | 250 | 221 | #!python3
iim = lambda: list(map(int, input().rstrip().split()))
from decimal import Decimal
def resolve():
a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
print((a * b // 100))
if __name__ == "__main__":
resolve()
| #!python3
iim = lambda: list(map(int, input().rstrip().split()))
def resolve():
a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
print((a * b // 100))
if __name__ == "__main__":
resolve()
| false | 7.692308 | [
"-from decimal import Decimal"
]
| false | 0.076485 | 0.043262 | 1.767934 | [
"s200295349",
"s546973770"
]
|
u729939940 | p02773 | python | s202670820 | s660323050 | 564 | 338 | 38,092 | 38,468 | Accepted | Accepted | 40.07 | import sys
N = int(eval(input()))
S = (str(x) for x in sys.stdin.read().split())
cnt = {}
for s in S:
if cnt.get(s):
cnt[s] = cnt[s] + 1
else:
cnt[s] = 1
max_cnt = max(cnt.values())
keys = [k for k, v in list(cnt.items()) if v == max_cnt]
for k in sorted(keys):
print(k) | import sys
from collections import Counter
N = int(eval(input()))
S = (str(x) for x in sys.stdin.read().split())
cnt = Counter(s for s in S)
max_cnt = max(cnt.values())
keys = [k for k, v in list(cnt.items()) if v == max_cnt]
print(("\n".join(sorted(keys)))) | 13 | 8 | 284 | 251 | import sys
N = int(eval(input()))
S = (str(x) for x in sys.stdin.read().split())
cnt = {}
for s in S:
if cnt.get(s):
cnt[s] = cnt[s] + 1
else:
cnt[s] = 1
max_cnt = max(cnt.values())
keys = [k for k, v in list(cnt.items()) if v == max_cnt]
for k in sorted(keys):
print(k)
| import sys
from collections import Counter
N = int(eval(input()))
S = (str(x) for x in sys.stdin.read().split())
cnt = Counter(s for s in S)
max_cnt = max(cnt.values())
keys = [k for k, v in list(cnt.items()) if v == max_cnt]
print(("\n".join(sorted(keys))))
| false | 38.461538 | [
"+from collections import Counter",
"-cnt = {}",
"-for s in S:",
"- if cnt.get(s):",
"- cnt[s] = cnt[s] + 1",
"- else:",
"- cnt[s] = 1",
"+cnt = Counter(s for s in S)",
"-for k in sorted(keys):",
"- print(k)",
"+print((\"\\n\".join(sorted(keys))))"
]
| false | 0.037982 | 0.105362 | 0.360492 | [
"s202670820",
"s660323050"
]
|
u871934301 | p02689 | python | s404384463 | s866620392 | 408 | 301 | 29,524 | 20,032 | Accepted | Accepted | 26.23 | N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
l=[[]*i for i in range(N)]
for i in range(M):
A,B=list(map(int,input().split()))
l[A-1].append(B)
l[B-1].append(A)
ans=0
for j in range(N):
if all(H[elem-1]<H[j] for elem in l[j])==True:
ans+=1
print(ans)
| N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0] * N
for i in range(M):
a, b = list(map(int, input().split()))
A[a-1] = max(A[a-1], H[b-1])
A[b-1] = max(A[b-1], H[a-1])
res = sum([H[i] > A[i] for i in range(N)])
print(res) | 35 | 11 | 350 | 268 | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
l = [[] * i for i in range(N)]
for i in range(M):
A, B = list(map(int, input().split()))
l[A - 1].append(B)
l[B - 1].append(A)
ans = 0
for j in range(N):
if all(H[elem - 1] < H[j] for elem in l[j]) == True:
ans += 1
print(ans)
| N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0] * N
for i in range(M):
a, b = list(map(int, input().split()))
A[a - 1] = max(A[a - 1], H[b - 1])
A[b - 1] = max(A[b - 1], H[a - 1])
res = sum([H[i] > A[i] for i in range(N)])
print(res)
| false | 68.571429 | [
"-l = [[] * i for i in range(N)]",
"+A = [0] * N",
"- A, B = list(map(int, input().split()))",
"- l[A - 1].append(B)",
"- l[B - 1].append(A)",
"-ans = 0",
"-for j in range(N):",
"- if all(H[elem - 1] < H[j] for elem in l[j]) == True:",
"- ans += 1",
"-print(ans)",
"+ a, b = list(map(int, input().split()))",
"+ A[a - 1] = max(A[a - 1], H[b - 1])",
"+ A[b - 1] = max(A[b - 1], H[a - 1])",
"+res = sum([H[i] > A[i] for i in range(N)])",
"+print(res)"
]
| false | 0.03771 | 0.101867 | 0.370193 | [
"s404384463",
"s866620392"
]
|
u000623733 | p03048 | python | s529676500 | s238716642 | 1,850 | 546 | 2,940 | 120,156 | Accepted | Accepted | 70.49 | R, G, B, N = list(map(int, input().split()))
count = 0
for i in range(N // R + 1):
n = N - R * i
for j in range(n // G + 1):
if (n - G*j) >= 0 and (n - G*j) % B == 0:
count += 1
print(count)
| R, G ,B, N = list(map(int, input().split()))
tmp = [R, G, B]
tmp.sort()
R, G, B = tmp[2], tmp[1], tmp[0]
num_R = N // R + 1
num_G = N // G
RG = [[N - R*i for i in range(num_R)]]
for j in range(num_G):
RG.append([RG[-1][i] - G for i in range(num_R)])
check = lambda x: 0 if x < 0 else 1 if x == 0 else 1 if x%B == 0 else 0
a = []
count = 0
for i in range(len(RG)):
a = list(map(check, RG[i]))
count += sum(a)
print(count)
| 10 | 23 | 224 | 456 | R, G, B, N = list(map(int, input().split()))
count = 0
for i in range(N // R + 1):
n = N - R * i
for j in range(n // G + 1):
if (n - G * j) >= 0 and (n - G * j) % B == 0:
count += 1
print(count)
| R, G, B, N = list(map(int, input().split()))
tmp = [R, G, B]
tmp.sort()
R, G, B = tmp[2], tmp[1], tmp[0]
num_R = N // R + 1
num_G = N // G
RG = [[N - R * i for i in range(num_R)]]
for j in range(num_G):
RG.append([RG[-1][i] - G for i in range(num_R)])
check = lambda x: 0 if x < 0 else 1 if x == 0 else 1 if x % B == 0 else 0
a = []
count = 0
for i in range(len(RG)):
a = list(map(check, RG[i]))
count += sum(a)
print(count)
| false | 56.521739 | [
"+tmp = [R, G, B]",
"+tmp.sort()",
"+R, G, B = tmp[2], tmp[1], tmp[0]",
"+num_R = N // R + 1",
"+num_G = N // G",
"+RG = [[N - R * i for i in range(num_R)]]",
"+for j in range(num_G):",
"+ RG.append([RG[-1][i] - G for i in range(num_R)])",
"+check = lambda x: 0 if x < 0 else 1 if x == 0 else 1 if x % B == 0 else 0",
"+a = []",
"-for i in range(N // R + 1):",
"- n = N - R * i",
"- for j in range(n // G + 1):",
"- if (n - G * j) >= 0 and (n - G * j) % B == 0:",
"- count += 1",
"+for i in range(len(RG)):",
"+ a = list(map(check, RG[i]))",
"+ count += sum(a)"
]
| false | 0.079615 | 0.064598 | 1.232458 | [
"s529676500",
"s238716642"
]
|
u131984977 | p02420 | python | s056042467 | s188561509 | 30 | 20 | 6,724 | 7,648 | Accepted | Accepted | 33.33 | while True:
text = eval(input())
if text == '-':
break
count = int(eval(input()))
for c in range(count):
index = int(eval(input()))
text = text[index:] + text[:index]
print(text) | while True:
s = eval(input())
if s == '-':
break
m = int(eval(input()))
for mi in range(m):
h = int(eval(input()))
s = s[h:] + s[:h]
print(s) | 11 | 11 | 216 | 179 | while True:
text = eval(input())
if text == "-":
break
count = int(eval(input()))
for c in range(count):
index = int(eval(input()))
text = text[index:] + text[:index]
print(text)
| while True:
s = eval(input())
if s == "-":
break
m = int(eval(input()))
for mi in range(m):
h = int(eval(input()))
s = s[h:] + s[:h]
print(s)
| false | 0 | [
"- text = eval(input())",
"- if text == \"-\":",
"+ s = eval(input())",
"+ if s == \"-\":",
"- count = int(eval(input()))",
"- for c in range(count):",
"- index = int(eval(input()))",
"- text = text[index:] + text[:index]",
"- print(text)",
"+ m = int(eval(input()))",
"+ for mi in range(m):",
"+ h = int(eval(input()))",
"+ s = s[h:] + s[:h]",
"+ print(s)"
]
| false | 0.044192 | 0.04557 | 0.969754 | [
"s056042467",
"s188561509"
]
|
u250583425 | p03127 | python | s288265362 | s268363377 | 805 | 80 | 54,216 | 16,276 | Accepted | Accepted | 90.06 | import sys
from functools import lru_cache
def input(): return sys.stdin.readline().rstrip()
@lru_cache(maxsize=None)
def gcd(m, n):
if n == 0:
return m
else:
return gcd(n, m % n)
def main():
_ = int(eval(input()))
A = tuple(map(int, input().split()))
ans = A[0]
for a in A[1:]:
ans = gcd(ans, a)
print(ans)
if __name__ == '__main__':
main()
| import sys
from fractions import gcd
def input(): return sys.stdin.readline().rstrip()
def main():
_ = int(eval(input()))
A = tuple(map(int, input().split()))
ans = A[0]
for a in A[1:]:
ans = gcd(ans, a)
print(ans)
if __name__ == '__main__':
main()
| 22 | 15 | 421 | 296 | import sys
from functools import lru_cache
def input():
return sys.stdin.readline().rstrip()
@lru_cache(maxsize=None)
def gcd(m, n):
if n == 0:
return m
else:
return gcd(n, m % n)
def main():
_ = int(eval(input()))
A = tuple(map(int, input().split()))
ans = A[0]
for a in A[1:]:
ans = gcd(ans, a)
print(ans)
if __name__ == "__main__":
main()
| import sys
from fractions import gcd
def input():
return sys.stdin.readline().rstrip()
def main():
_ = int(eval(input()))
A = tuple(map(int, input().split()))
ans = A[0]
for a in A[1:]:
ans = gcd(ans, a)
print(ans)
if __name__ == "__main__":
main()
| false | 31.818182 | [
"-from functools import lru_cache",
"+from fractions import gcd",
"-",
"-",
"-@lru_cache(maxsize=None)",
"-def gcd(m, n):",
"- if n == 0:",
"- return m",
"- else:",
"- return gcd(n, m % n)"
]
| false | 0.055545 | 0.0578 | 0.961 | [
"s288265362",
"s268363377"
]
|
u644907318 | p03050 | python | s250278837 | s081391919 | 74 | 68 | 64,480 | 64,084 | Accepted | Accepted | 8.11 | N = int(eval(input()))
A = []
for i in range(1,int(N**0.5)+1):
if N%i==0:
a = i
b = N//i
if a>b:
a,b = b,a
if 0<a<b-1:
A.append(b-1)
print((sum(A))) | N = int(eval(input()))
cnt = 0
if N>2:
for x in range(2,int(N**0.5)+1):
if N%x==0:
y = N//x
if N//(x-1)==N%(x-1):
cnt += x-1
if N//(y-1)==N%(y-1):
cnt += y-1
cnt += N-1
print(cnt) | 11 | 12 | 210 | 268 | N = int(eval(input()))
A = []
for i in range(1, int(N**0.5) + 1):
if N % i == 0:
a = i
b = N // i
if a > b:
a, b = b, a
if 0 < a < b - 1:
A.append(b - 1)
print((sum(A)))
| N = int(eval(input()))
cnt = 0
if N > 2:
for x in range(2, int(N**0.5) + 1):
if N % x == 0:
y = N // x
if N // (x - 1) == N % (x - 1):
cnt += x - 1
if N // (y - 1) == N % (y - 1):
cnt += y - 1
cnt += N - 1
print(cnt)
| false | 8.333333 | [
"-A = []",
"-for i in range(1, int(N**0.5) + 1):",
"- if N % i == 0:",
"- a = i",
"- b = N // i",
"- if a > b:",
"- a, b = b, a",
"- if 0 < a < b - 1:",
"- A.append(b - 1)",
"-print((sum(A)))",
"+cnt = 0",
"+if N > 2:",
"+ for x in range(2, int(N**0.5) + 1):",
"+ if N % x == 0:",
"+ y = N // x",
"+ if N // (x - 1) == N % (x - 1):",
"+ cnt += x - 1",
"+ if N // (y - 1) == N % (y - 1):",
"+ cnt += y - 1",
"+ cnt += N - 1",
"+print(cnt)"
]
| false | 0.206871 | 0.394404 | 0.524515 | [
"s250278837",
"s081391919"
]
|
u775681539 | p02803 | python | s438202819 | s066018411 | 697 | 580 | 3,436 | 3,316 | Accepted | Accepted | 16.79 | #python3
from collections import deque
from collections import namedtuple
Vertex = namedtuple('Vertex', ['i', 'j'])
INF = int(1e10)
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
def main():
h, w = list(map(int, input().split()))
maze = [eval(input()) for i in range(h)]
ans = 0
for si in range(h):
for sj in range(w):
if maze[si][sj] == '#':
continue
dist = [[INF for i in range(w)] for j in range(h)]
q = deque()
def update(i, j, x):
if dist[i][j] != INF:
return None
dist[i][j] = x
q.append(Vertex(i, j))
update(si, sj, 0)
while len(q) != 0:
i, j = q.popleft()
for dir in range(4):
ni = i+di[dir]
nj = j+dj[dir]
if (ni < 0) | (ni >= h) | (nj < 0) | (nj >= w):
continue
if maze[ni][nj] == '#':
continue
update(ni, nj, dist[i][j]+1)
for i in range(h):
for j in range(w):
if dist[i][j] == INF:
continue
ans = max(ans, dist[i][j])
print(ans)
main() | #python3
from collections import deque
INF = int(1e20)
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
def main():
h, w = list(map(int, input().split()))
maze = [eval(input()) for i in range(h)]
ans = 0
for si in range(h):
for sj in range(w):
if maze[si][sj] == '#':
continue
dist = [[INF for i in range(w)] for j in range(h)]
q = deque()
def update(i, j, x):
if dist[i][j] != INF:
return None
dist[i][j] = x
q.append((i,j))
update(si, sj, 0)
while len(q) != 0:
i, j = q.popleft()
for dir in range(4):
ni = i+di[dir]
nj = j+dj[dir]
if (ni<0)|(ni>=h)|(nj<0)|(nj>=w):
continue
if maze[ni][nj] == '#':
continue
update(ni, nj, dist[i][j]+1)
for i in range(h):
for j in range(w):
if dist[i][j] == INF:
continue
ans = max(ans, dist[i][j])
print(ans)
main() | 50 | 46 | 1,344 | 1,257 | # python3
from collections import deque
from collections import namedtuple
Vertex = namedtuple("Vertex", ["i", "j"])
INF = int(1e10)
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
def main():
h, w = list(map(int, input().split()))
maze = [eval(input()) for i in range(h)]
ans = 0
for si in range(h):
for sj in range(w):
if maze[si][sj] == "#":
continue
dist = [[INF for i in range(w)] for j in range(h)]
q = deque()
def update(i, j, x):
if dist[i][j] != INF:
return None
dist[i][j] = x
q.append(Vertex(i, j))
update(si, sj, 0)
while len(q) != 0:
i, j = q.popleft()
for dir in range(4):
ni = i + di[dir]
nj = j + dj[dir]
if (ni < 0) | (ni >= h) | (nj < 0) | (nj >= w):
continue
if maze[ni][nj] == "#":
continue
update(ni, nj, dist[i][j] + 1)
for i in range(h):
for j in range(w):
if dist[i][j] == INF:
continue
ans = max(ans, dist[i][j])
print(ans)
main()
| # python3
from collections import deque
INF = int(1e20)
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
def main():
h, w = list(map(int, input().split()))
maze = [eval(input()) for i in range(h)]
ans = 0
for si in range(h):
for sj in range(w):
if maze[si][sj] == "#":
continue
dist = [[INF for i in range(w)] for j in range(h)]
q = deque()
def update(i, j, x):
if dist[i][j] != INF:
return None
dist[i][j] = x
q.append((i, j))
update(si, sj, 0)
while len(q) != 0:
i, j = q.popleft()
for dir in range(4):
ni = i + di[dir]
nj = j + dj[dir]
if (ni < 0) | (ni >= h) | (nj < 0) | (nj >= w):
continue
if maze[ni][nj] == "#":
continue
update(ni, nj, dist[i][j] + 1)
for i in range(h):
for j in range(w):
if dist[i][j] == INF:
continue
ans = max(ans, dist[i][j])
print(ans)
main()
| false | 8 | [
"-from collections import namedtuple",
"-Vertex = namedtuple(\"Vertex\", [\"i\", \"j\"])",
"-INF = int(1e10)",
"+INF = int(1e20)",
"- q.append(Vertex(i, j))",
"+ q.append((i, j))"
]
| false | 0.036985 | 0.038238 | 0.967232 | [
"s438202819",
"s066018411"
]
|
u914007790 | p00006 | python | s265429640 | s912364006 | 30 | 20 | 7,356 | 7,348 | Accepted | Accepted | 33.33 | a = list(input())
for i in a[::-1]:
print(i, end="")
print()
| a = list(eval(input()))
a.reverse()
print((''.join(a))) | 4 | 3 | 67 | 49 | a = list(input())
for i in a[::-1]:
print(i, end="")
print()
| a = list(eval(input()))
a.reverse()
print(("".join(a)))
| false | 25 | [
"-a = list(input())",
"-for i in a[::-1]:",
"- print(i, end=\"\")",
"-print()",
"+a = list(eval(input()))",
"+a.reverse()",
"+print((\"\".join(a)))"
]
| false | 0.044958 | 0.041455 | 1.08452 | [
"s265429640",
"s912364006"
]
|
u012694084 | p03147 | python | s323384425 | s345163519 | 24 | 18 | 3,064 | 2,940 | Accepted | Accepted | 25 | N = int(eval(input()))
h = list(map(int, input().split()))
current_h = [0] * N
c = 0
l = 0
while True:
escape_loop = False
while current_h[l] == h[l]:
if l + 1 < N:
l += 1
else:
escape_loop = True
break
if escape_loop:
break
r = l
while True:
if r + 1 < N and current_h[r + 1] < h[r + 1]:
r += 1
else:
break
for i in range(l, r + 1):
current_h[i] += 1
c += 1
print(c)
| N = int(eval(input()))
h = list(map(int, input().split()))
s = h[0]
for i in range(1, N):
s += max(0, h[i] - h[i - 1])
print(s)
| 30 | 8 | 532 | 135 | N = int(eval(input()))
h = list(map(int, input().split()))
current_h = [0] * N
c = 0
l = 0
while True:
escape_loop = False
while current_h[l] == h[l]:
if l + 1 < N:
l += 1
else:
escape_loop = True
break
if escape_loop:
break
r = l
while True:
if r + 1 < N and current_h[r + 1] < h[r + 1]:
r += 1
else:
break
for i in range(l, r + 1):
current_h[i] += 1
c += 1
print(c)
| N = int(eval(input()))
h = list(map(int, input().split()))
s = h[0]
for i in range(1, N):
s += max(0, h[i] - h[i - 1])
print(s)
| false | 73.333333 | [
"-current_h = [0] * N",
"-c = 0",
"-l = 0",
"-while True:",
"- escape_loop = False",
"- while current_h[l] == h[l]:",
"- if l + 1 < N:",
"- l += 1",
"- else:",
"- escape_loop = True",
"- break",
"- if escape_loop:",
"- break",
"- r = l",
"- while True:",
"- if r + 1 < N and current_h[r + 1] < h[r + 1]:",
"- r += 1",
"- else:",
"- break",
"- for i in range(l, r + 1):",
"- current_h[i] += 1",
"- c += 1",
"-print(c)",
"+s = h[0]",
"+for i in range(1, N):",
"+ s += max(0, h[i] - h[i - 1])",
"+print(s)"
]
| false | 0.033026 | 0.034248 | 0.964314 | [
"s323384425",
"s345163519"
]
|
u454557108 | p03565 | python | s075022517 | s131748754 | 20 | 17 | 3,064 | 3,064 | Accepted | Accepted | 15 | import sys
s = eval(input())
t = eval(input())
tl = len(t) ; sl = len(s)
c = 1
for i in range(sl,tl-1,-1) :
st = s[i-tl:i]
c = 0
for j in range(tl) :
if st[j] == '?' :
continue
elif st[j] != '?' and st[j] == t[j] :
continue
c = 1
break
if c == 0 :
s = s[:i-tl] + t + s[i:]
break
if c == 1 :
print('UNRESTORABLE')
else :
print((s.replace('?', 'a'))) | import sys
s = eval(input())
t = eval(input())
tl = len(t) ; sl = len(s)
if tl > sl :
print('UNRESTORABLE')
sys.exit()
for i in range(sl,tl-1,-1) :
st = s[i-tl:i]
c = 0
for j in range(tl) :
if st[j] == '?' :
continue
elif st[j] != '?' and st[j] == t[j] :
continue
c = 1
break
if c == 0 :
s = s[:i-tl] + t + s[i:]
break
if c == 1 :
print('UNRESTORABLE')
else :
print((s.replace('?', 'a'))) | 26 | 29 | 412 | 460 | import sys
s = eval(input())
t = eval(input())
tl = len(t)
sl = len(s)
c = 1
for i in range(sl, tl - 1, -1):
st = s[i - tl : i]
c = 0
for j in range(tl):
if st[j] == "?":
continue
elif st[j] != "?" and st[j] == t[j]:
continue
c = 1
break
if c == 0:
s = s[: i - tl] + t + s[i:]
break
if c == 1:
print("UNRESTORABLE")
else:
print((s.replace("?", "a")))
| import sys
s = eval(input())
t = eval(input())
tl = len(t)
sl = len(s)
if tl > sl:
print("UNRESTORABLE")
sys.exit()
for i in range(sl, tl - 1, -1):
st = s[i - tl : i]
c = 0
for j in range(tl):
if st[j] == "?":
continue
elif st[j] != "?" and st[j] == t[j]:
continue
c = 1
break
if c == 0:
s = s[: i - tl] + t + s[i:]
break
if c == 1:
print("UNRESTORABLE")
else:
print((s.replace("?", "a")))
| false | 10.344828 | [
"-c = 1",
"+if tl > sl:",
"+ print(\"UNRESTORABLE\")",
"+ sys.exit()"
]
| false | 0.041085 | 0.041411 | 0.992129 | [
"s075022517",
"s131748754"
]
|
u019685451 | p02584 | python | s368297586 | s123119017 | 31 | 27 | 9,184 | 9,080 | Accepted | Accepted | 12.9 | from math import floor
def solve(X, D, lb, ub):
# min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
ts = [
lb,
ub,
max(min(floor(-X / D), ub), lb),
max(min(floor(-X / D) + 1, ub), lb),
]
return min([abs(X + t * D) for t in ts])
X, K, D = list(map(int, input().split()))
y1 = X - K * D
y2 = X + K * D
if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign
print((min(abs(y1), abs(y2))))
else:
if K % 2 == 0:
ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
ans = min(ans1, ans2)
print(ans)
| from math import floor
def solve(X, D, lb, ub):
# min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
ts = [
lb,
ub,
max(min(floor(-X / D), ub), lb),
max(min(floor(-X / D) + 1, ub), lb),
]
return min([abs(X + t * D) for t in ts])
X, K, D = list(map(int, input().split()))
if K % 2 == 0:
ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
ans = min(ans1, ans2)
print(ans)
| 27 | 22 | 742 | 578 | from math import floor
def solve(X, D, lb, ub):
# min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
ts = [
lb,
ub,
max(min(floor(-X / D), ub), lb),
max(min(floor(-X / D) + 1, ub), lb),
]
return min([abs(X + t * D) for t in ts])
X, K, D = list(map(int, input().split()))
y1 = X - K * D
y2 = X + K * D
if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign
print((min(abs(y1), abs(y2))))
else:
if K % 2 == 0:
ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
ans = min(ans1, ans2)
print(ans)
| from math import floor
def solve(X, D, lb, ub):
# min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
ts = [
lb,
ub,
max(min(floor(-X / D), ub), lb),
max(min(floor(-X / D) + 1, ub), lb),
]
return min([abs(X + t * D) for t in ts])
X, K, D = list(map(int, input().split()))
if K % 2 == 0:
ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
ans = min(ans1, ans2)
print(ans)
| false | 18.518519 | [
"-y1 = X - K * D",
"-y2 = X + K * D",
"-if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign",
"- print((min(abs(y1), abs(y2))))",
"+if K % 2 == 0:",
"+ ans = solve(X, D * 2, -(K // 2), +(K // 2))",
"- if K % 2 == 0:",
"- ans = solve(X, D * 2, -(K // 2), +(K // 2))",
"- else:",
"- ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)",
"- ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)",
"- ans = min(ans1, ans2)",
"- print(ans)",
"+ ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)",
"+ ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)",
"+ ans = min(ans1, ans2)",
"+print(ans)"
]
| false | 0.037632 | 0.040501 | 0.929151 | [
"s368297586",
"s123119017"
]
|
u169200126 | p02659 | python | s066087266 | s654859963 | 25 | 23 | 9,104 | 9,044 | Accepted | Accepted | 8 | a, b = list(map(float, input().split()))
b = float(b)*1000
b = int(b)
c = int(a)*b//1000
print((int(c))) | a, b = list(map(float, input().split()))
b = float(b)*1000
b = int(b)
c = (int(a)*b)//1000
print((int(c))) | 6 | 6 | 103 | 105 | a, b = list(map(float, input().split()))
b = float(b) * 1000
b = int(b)
c = int(a) * b // 1000
print((int(c)))
| a, b = list(map(float, input().split()))
b = float(b) * 1000
b = int(b)
c = (int(a) * b) // 1000
print((int(c)))
| false | 0 | [
"-c = int(a) * b // 1000",
"+c = (int(a) * b) // 1000"
]
| false | 0.056286 | 0.097086 | 0.579749 | [
"s066087266",
"s654859963"
]
|
u983918956 | p03700 | python | s288088731 | s314598955 | 1,252 | 1,142 | 11,036 | 7,076 | Accepted | Accepted | 8.79 | N,A,B = list(map(int,input().split()))
H = [int(eval(input())) for _ in range(N)]
d = A-B
def judge(k):
cnt = 0
remain = [max(h-k*B,0) for h in H]
for r in remain:
cnt += -(-r // d)
if cnt <= k:
return True
else:
return False
def biserch(ok,ng,judge):
while abs(ok-ng) > 1:
mid = (ok+ng) // 2
if judge(mid):
ok = mid
else:
ng = mid
return ok
ans = biserch(10**9,-1,judge)
print(ans) | import sys
input = sys.stdin.readline
N,A,B = list(map(int,input().split()))
H = [int(eval(input())) for _ in range(N)]
def judge(k):
cnt = 0
for h in H:
cnt += -(-(max(h-k*B,0))//(A-B))
if cnt <= k:
return True
return False
def biserch(ok,ng,judge):
while abs(ok-ng) > 1:
mid = (ok+ng) // 2
if judge(mid):
ok = mid
else:
ng = mid
return ok
ans = biserch(max(H),-1,judge)
print(ans) | 26 | 25 | 499 | 486 | N, A, B = list(map(int, input().split()))
H = [int(eval(input())) for _ in range(N)]
d = A - B
def judge(k):
cnt = 0
remain = [max(h - k * B, 0) for h in H]
for r in remain:
cnt += -(-r // d)
if cnt <= k:
return True
else:
return False
def biserch(ok, ng, judge):
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if judge(mid):
ok = mid
else:
ng = mid
return ok
ans = biserch(10**9, -1, judge)
print(ans)
| import sys
input = sys.stdin.readline
N, A, B = list(map(int, input().split()))
H = [int(eval(input())) for _ in range(N)]
def judge(k):
cnt = 0
for h in H:
cnt += -(-(max(h - k * B, 0)) // (A - B))
if cnt <= k:
return True
return False
def biserch(ok, ng, judge):
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if judge(mid):
ok = mid
else:
ng = mid
return ok
ans = biserch(max(H), -1, judge)
print(ans)
| false | 3.846154 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-d = A - B",
"- remain = [max(h - k * B, 0) for h in H]",
"- for r in remain:",
"- cnt += -(-r // d)",
"+ for h in H:",
"+ cnt += -(-(max(h - k * B, 0)) // (A - B))",
"- else:",
"- return False",
"+ return False",
"-ans = biserch(10**9, -1, judge)",
"+ans = biserch(max(H), -1, judge)"
]
| false | 0.047182 | 0.048033 | 0.982271 | [
"s288088731",
"s314598955"
]
|
u079022693 | p02947 | python | s914449165 | s545473545 | 408 | 212 | 18,732 | 19,460 | Accepted | Accepted | 48.04 | N=int(eval(input()))
s=[0]*N
essence={}
count=0
for i in range(N):
s_i="".join(sorted(eval(input())))
s[i]=s_i
if s[i] not in essence:
essence.setdefault(s[i],1)
else:
count+=essence[s[i]]
essence[s[i]]+=1
print(count) | from sys import stdin
def nC2(n):
return n*(n-1)//2
def main():
#入力
readline=stdin.readline
N=int(readline())
s=[""]*N
for i in range(N):
a=list(readline().strip())
a.sort()
s[i]="".join(a)
d=dict()
for i in range(N):
if s[i] not in d:
d[s[i]]=1
else:
d[s[i]]+=1
res=0
for v in list(d.values()):
if v==1:
pass
else:
res+=nC2(v)
print(res)
if __name__=="__main__":
main() | 14 | 32 | 250 | 556 | N = int(eval(input()))
s = [0] * N
essence = {}
count = 0
for i in range(N):
s_i = "".join(sorted(eval(input())))
s[i] = s_i
if s[i] not in essence:
essence.setdefault(s[i], 1)
else:
count += essence[s[i]]
essence[s[i]] += 1
print(count)
| from sys import stdin
def nC2(n):
return n * (n - 1) // 2
def main():
# 入力
readline = stdin.readline
N = int(readline())
s = [""] * N
for i in range(N):
a = list(readline().strip())
a.sort()
s[i] = "".join(a)
d = dict()
for i in range(N):
if s[i] not in d:
d[s[i]] = 1
else:
d[s[i]] += 1
res = 0
for v in list(d.values()):
if v == 1:
pass
else:
res += nC2(v)
print(res)
if __name__ == "__main__":
main()
| false | 56.25 | [
"-N = int(eval(input()))",
"-s = [0] * N",
"-essence = {}",
"-count = 0",
"-for i in range(N):",
"- s_i = \"\".join(sorted(eval(input())))",
"- s[i] = s_i",
"- if s[i] not in essence:",
"- essence.setdefault(s[i], 1)",
"- else:",
"- count += essence[s[i]]",
"- essence[s[i]] += 1",
"-print(count)",
"+from sys import stdin",
"+",
"+",
"+def nC2(n):",
"+ return n * (n - 1) // 2",
"+",
"+",
"+def main():",
"+ # 入力",
"+ readline = stdin.readline",
"+ N = int(readline())",
"+ s = [\"\"] * N",
"+ for i in range(N):",
"+ a = list(readline().strip())",
"+ a.sort()",
"+ s[i] = \"\".join(a)",
"+ d = dict()",
"+ for i in range(N):",
"+ if s[i] not in d:",
"+ d[s[i]] = 1",
"+ else:",
"+ d[s[i]] += 1",
"+ res = 0",
"+ for v in list(d.values()):",
"+ if v == 1:",
"+ pass",
"+ else:",
"+ res += nC2(v)",
"+ print(res)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.039586 | 0.039822 | 0.994062 | [
"s914449165",
"s545473545"
]
|
u071680334 | p02720 | python | s229579859 | s587221625 | 825 | 648 | 3,064 | 22,688 | Accepted | Accepted | 21.45 | def func(n):
s = str(n)
L = len(s)
for i in reversed(list(range(L-1))):
x = int(s[i])
y = int(s[i+1])
if abs(x-y) > 1:
buf = 10**(L-(i+1)-1)
if x > y:
return int(s[:i] + str(x) + str(x-1)) * buf
else:
return (int(s[:i+1]) + 1)*(buf*10)
return -1
def main():
k = int(eval(input()))
target = 1
while k > 0:
buf = func(target)
if buf == -1:
k -= 1
if k == 0:
break
target += 1
else:
target = buf
# print(target)
print(target)
if __name__ == "__main__":
main() | import queue
def main():
k = int(eval(input()))
q = queue.Queue()
for i in range(1, 10):
q.put(str(i))
ans = ""
for i in range(1, k+1):
ans = q.get()
if i < k:
p = int(ans[-1])
if p == 0:
q.put(ans + "0")
q.put(ans + "1")
elif p == 9:
q.put(ans + "8")
q.put(ans + "9")
else:
for v in range(p-1, p+2):
q.put(ans + str(v))
print(ans)
if __name__ == "__main__":
main() | 31 | 25 | 699 | 585 | def func(n):
s = str(n)
L = len(s)
for i in reversed(list(range(L - 1))):
x = int(s[i])
y = int(s[i + 1])
if abs(x - y) > 1:
buf = 10 ** (L - (i + 1) - 1)
if x > y:
return int(s[:i] + str(x) + str(x - 1)) * buf
else:
return (int(s[: i + 1]) + 1) * (buf * 10)
return -1
def main():
k = int(eval(input()))
target = 1
while k > 0:
buf = func(target)
if buf == -1:
k -= 1
if k == 0:
break
target += 1
else:
target = buf
# print(target)
print(target)
if __name__ == "__main__":
main()
| import queue
def main():
k = int(eval(input()))
q = queue.Queue()
for i in range(1, 10):
q.put(str(i))
ans = ""
for i in range(1, k + 1):
ans = q.get()
if i < k:
p = int(ans[-1])
if p == 0:
q.put(ans + "0")
q.put(ans + "1")
elif p == 9:
q.put(ans + "8")
q.put(ans + "9")
else:
for v in range(p - 1, p + 2):
q.put(ans + str(v))
print(ans)
if __name__ == "__main__":
main()
| false | 19.354839 | [
"-def func(n):",
"- s = str(n)",
"- L = len(s)",
"- for i in reversed(list(range(L - 1))):",
"- x = int(s[i])",
"- y = int(s[i + 1])",
"- if abs(x - y) > 1:",
"- buf = 10 ** (L - (i + 1) - 1)",
"- if x > y:",
"- return int(s[:i] + str(x) + str(x - 1)) * buf",
"- else:",
"- return (int(s[: i + 1]) + 1) * (buf * 10)",
"- return -1",
"+import queue",
"- target = 1",
"- while k > 0:",
"- buf = func(target)",
"- if buf == -1:",
"- k -= 1",
"- if k == 0:",
"- break",
"- target += 1",
"- else:",
"- target = buf",
"- # print(target)",
"- print(target)",
"+ q = queue.Queue()",
"+ for i in range(1, 10):",
"+ q.put(str(i))",
"+ ans = \"\"",
"+ for i in range(1, k + 1):",
"+ ans = q.get()",
"+ if i < k:",
"+ p = int(ans[-1])",
"+ if p == 0:",
"+ q.put(ans + \"0\")",
"+ q.put(ans + \"1\")",
"+ elif p == 9:",
"+ q.put(ans + \"8\")",
"+ q.put(ans + \"9\")",
"+ else:",
"+ for v in range(p - 1, p + 2):",
"+ q.put(ans + str(v))",
"+ print(ans)"
]
| false | 0.10283 | 0.182927 | 0.562136 | [
"s229579859",
"s587221625"
]
|
u163320134 | p03201 | python | s400829273 | s356958722 | 570 | 454 | 109,780 | 109,652 | Accepted | Accepted | 20.35 | n=int(eval(input()))
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={}
for val in arr:
if val not in dic:
dic[val]=1
else:
dic[val]+=1
ans=0
for val in arr:
for i in range(40):
if val<2**i:
persuit=2**i
break
if persuit-val==val:
if val in dic:
if dic[val]>=2:
ans+=1
dic[val]-=2
if dic[val]==0:
del dic[val]
else:
continue
else:
continue
else:
if val in dic and persuit-val in dic:
ans+=1
dic[val]-=1
if dic[val]==0:
del dic[val]
dic[persuit-val]-=1
if dic[persuit-val]==0:
del dic[persuit-val]
else:
continue
print(ans) | from bisect import bisect_left
n=int(eval(input()))
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={}
for val in arr:
if val not in dic:
dic[val]=1
else:
dic[val]+=1
arr2=[]
for i in range(40):
arr2.append(2**i)
ans=0
for val in arr:
pos=bisect_left(arr2,val)
if val==arr2[pos]:
persuit=arr2[pos+1]
else:
persuit=arr2[pos]
if persuit-val==val:
if val in dic:
if dic[val]>=2:
ans+=1
dic[val]-=2
if dic[val]==0:
del dic[val]
else:
continue
else:
continue
else:
if val in dic and persuit-val in dic:
ans+=1
dic[val]-=1
if dic[val]==0:
del dic[val]
dic[persuit-val]-=1
if dic[persuit-val]==0:
del dic[persuit-val]
else:
continue
print(ans) | 38 | 44 | 735 | 854 | n = int(eval(input()))
arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
dic = {}
for val in arr:
if val not in dic:
dic[val] = 1
else:
dic[val] += 1
ans = 0
for val in arr:
for i in range(40):
if val < 2**i:
persuit = 2**i
break
if persuit - val == val:
if val in dic:
if dic[val] >= 2:
ans += 1
dic[val] -= 2
if dic[val] == 0:
del dic[val]
else:
continue
else:
continue
else:
if val in dic and persuit - val in dic:
ans += 1
dic[val] -= 1
if dic[val] == 0:
del dic[val]
dic[persuit - val] -= 1
if dic[persuit - val] == 0:
del dic[persuit - val]
else:
continue
print(ans)
| from bisect import bisect_left
n = int(eval(input()))
arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
dic = {}
for val in arr:
if val not in dic:
dic[val] = 1
else:
dic[val] += 1
arr2 = []
for i in range(40):
arr2.append(2**i)
ans = 0
for val in arr:
pos = bisect_left(arr2, val)
if val == arr2[pos]:
persuit = arr2[pos + 1]
else:
persuit = arr2[pos]
if persuit - val == val:
if val in dic:
if dic[val] >= 2:
ans += 1
dic[val] -= 2
if dic[val] == 0:
del dic[val]
else:
continue
else:
continue
else:
if val in dic and persuit - val in dic:
ans += 1
dic[val] -= 1
if dic[val] == 0:
del dic[val]
dic[persuit - val] -= 1
if dic[persuit - val] == 0:
del dic[persuit - val]
else:
continue
print(ans)
| false | 13.636364 | [
"+from bisect import bisect_left",
"+",
"+arr2 = []",
"+for i in range(40):",
"+ arr2.append(2**i)",
"- for i in range(40):",
"- if val < 2**i:",
"- persuit = 2**i",
"- break",
"+ pos = bisect_left(arr2, val)",
"+ if val == arr2[pos]:",
"+ persuit = arr2[pos + 1]",
"+ else:",
"+ persuit = arr2[pos]"
]
| false | 0.112892 | 0.046791 | 2.412698 | [
"s400829273",
"s356958722"
]
|
u952708174 | p03674 | python | s540020607 | s693537432 | 258 | 232 | 27,912 | 31,568 | Accepted | Accepted | 10.08 | def d_11(MOD=10**9 + 7):
from collections import Counter
class Combination(object):
"""参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
__slots__ = ["mod", "factorial", "inverse"]
def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
fac, inv = [1], []
fac_append, inv_append = fac.append, inv.append
for i in range(1, max_n + 1):
fac_append(fac[-1] * i % mod)
inv_append(pow(fac[-1], mod - 2, mod))
for i in range(max_n, 0, -1):
inv_append(inv[-1] * i % mod)
self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
def combination(self, n, r):
if n < 0 or r < 0 or n < r:
return 0
return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
N = int(eval(input()))
A = [int(i) for i in input().split()]
# 重複した数のインデックスを求める
c = Counter(A).most_common(n=1)[0][0] # 重複した整数の値を取得
index = [i for i, x in enumerate(A) if x == c] # 重複した整数のインデックス
left = index[0] + 1
right = index[1] + 1
comb = Combination(N + 1).combination
ans = [(comb(N + 1, k) - comb(N - (right - left), k - 1)) % MOD for k in range(1, N + 2)]
return '\n'.join(map(str, ans))
print((d_11())) | def d_11(MOD=10**9 + 7):
class Combination(object):
"""参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
__slots__ = ["mod", "factorial", "inverse"]
def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
fac, inv = [1], []
fac_append, inv_append = fac.append, inv.append
for i in range(1, max_n + 1):
fac_append(fac[-1] * i % mod)
inv_append(pow(fac[-1], mod - 2, mod))
for i in range(max_n, 0, -1):
inv_append(inv[-1] * i % mod)
self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
def combination(self, n, r):
if n < 0 or r < 0 or n < r:
return 0
return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
N = int(eval(input()))
A = [int(i) for i in input().split()]
# 重複した数のインデックスを求める
appeared = set()
for k, a in enumerate(A):
if a in appeared:
left, right = A.index(a), k
break
appeared.add(a)
c = Combination(N + 1).combination
ans = [(c(N + 1, k) - c(N - (right - left), k - 1)) % MOD for k in range(1, N + 2)]
return '\n'.join(map(str, ans))
print((d_11())) | 39 | 39 | 1,376 | 1,315 | def d_11(MOD=10**9 + 7):
from collections import Counter
class Combination(object):
"""参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
__slots__ = ["mod", "factorial", "inverse"]
def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
fac, inv = [1], []
fac_append, inv_append = fac.append, inv.append
for i in range(1, max_n + 1):
fac_append(fac[-1] * i % mod)
inv_append(pow(fac[-1], mod - 2, mod))
for i in range(max_n, 0, -1):
inv_append(inv[-1] * i % mod)
self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
def combination(self, n, r):
if n < 0 or r < 0 or n < r:
return 0
return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
N = int(eval(input()))
A = [int(i) for i in input().split()]
# 重複した数のインデックスを求める
c = Counter(A).most_common(n=1)[0][0] # 重複した整数の値を取得
index = [i for i, x in enumerate(A) if x == c] # 重複した整数のインデックス
left = index[0] + 1
right = index[1] + 1
comb = Combination(N + 1).combination
ans = [
(comb(N + 1, k) - comb(N - (right - left), k - 1)) % MOD
for k in range(1, N + 2)
]
return "\n".join(map(str, ans))
print((d_11()))
| def d_11(MOD=10**9 + 7):
class Combination(object):
"""参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
__slots__ = ["mod", "factorial", "inverse"]
def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
fac, inv = [1], []
fac_append, inv_append = fac.append, inv.append
for i in range(1, max_n + 1):
fac_append(fac[-1] * i % mod)
inv_append(pow(fac[-1], mod - 2, mod))
for i in range(max_n, 0, -1):
inv_append(inv[-1] * i % mod)
self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
def combination(self, n, r):
if n < 0 or r < 0 or n < r:
return 0
return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
N = int(eval(input()))
A = [int(i) for i in input().split()]
# 重複した数のインデックスを求める
appeared = set()
for k, a in enumerate(A):
if a in appeared:
left, right = A.index(a), k
break
appeared.add(a)
c = Combination(N + 1).combination
ans = [(c(N + 1, k) - c(N - (right - left), k - 1)) % MOD for k in range(1, N + 2)]
return "\n".join(map(str, ans))
print((d_11()))
| false | 0 | [
"- from collections import Counter",
"-",
"- c = Counter(A).most_common(n=1)[0][0] # 重複した整数の値を取得",
"- index = [i for i, x in enumerate(A) if x == c] # 重複した整数のインデックス",
"- left = index[0] + 1",
"- right = index[1] + 1",
"- comb = Combination(N + 1).combination",
"- ans = [",
"- (comb(N + 1, k) - comb(N - (right - left), k - 1)) % MOD",
"- for k in range(1, N + 2)",
"- ]",
"+ appeared = set()",
"+ for k, a in enumerate(A):",
"+ if a in appeared:",
"+ left, right = A.index(a), k",
"+ break",
"+ appeared.add(a)",
"+ c = Combination(N + 1).combination",
"+ ans = [(c(N + 1, k) - c(N - (right - left), k - 1)) % MOD for k in range(1, N + 2)]"
]
| false | 0.04486 | 0.066027 | 0.679418 | [
"s540020607",
"s693537432"
]
|
u077291787 | p03959 | python | s077527684 | s237569503 | 88 | 78 | 19,136 | 19,140 | Accepted | Accepted | 11.36 | # code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists
from bisect import bisect_left as bs
def main():
"""
/----\ <- xi (= yi)
/ \--\
/ \
xi yi
0 ~ xi / xi ~ yi / yi+1 ~ N-1
"""
N = int(eval(input()))
T = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))
x, y, xi, yi = 0, 0, 0, 0 # max of x, y and the indices
for i, t in enumerate(T):
if t > x:
x, xi = t, i
for i, a in enumerate(A):
if a >= y:
y, yi = a, i
if x != y or xi > yi:
print((0))
return
MOD = 10 ** 9 + 7
ans, cur = 1, 0
for i in T[: xi + 1]:
if i > cur: # point of new altitude -> no choice (ans * 1)
cur = i
else:
ans = (ans * cur) % MOD # mulitple choices (1, 2, ..., cur)
for _ in range(xi + 1, yi):
ans = (ans * cur) % MOD
for i in A[yi + 1 :]:
if i < cur:
cur = i
else:
ans = (ans * cur) % MOD
print(ans)
if __name__ == "__main__":
main() | # code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists
from bisect import bisect_left as bs
def main():
"""
/----\ <- xi (= yi)
/ \--\
/ \
xi yi
0 ~ xi / xi ~ yi / yi+1 ~ N-1
"""
N = int(eval(input()))
T = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))
x, y = T[-1], A[0] # max of x, y
xi, yi = T.index(x), N - A[::-1].index(y) - 1 # indices of x, y
if x != y or xi > yi:
print((0))
return
MOD = 10 ** 9 + 7
ans, cur = 1, 0
for i in T[: xi + 1]:
if i > cur: # point of new altitude -> no choice (ans * 1)
cur = i
else:
ans = (ans * cur) % MOD # mulitple choices (1, 2, ..., cur)
for _ in range(xi + 1, yi):
ans = (ans * cur) % MOD
for i in A[yi + 1 :]:
if i < cur:
cur = i
else:
ans = (ans * cur) % MOD
print(ans)
if __name__ == "__main__":
main() | 44 | 39 | 1,124 | 1,018 | # code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists
from bisect import bisect_left as bs
def main():
"""
/----\ <- xi (= yi)
/ \--\
/ \
xi yi
0 ~ xi / xi ~ yi / yi+1 ~ N-1
"""
N = int(eval(input()))
T = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))
x, y, xi, yi = 0, 0, 0, 0 # max of x, y and the indices
for i, t in enumerate(T):
if t > x:
x, xi = t, i
for i, a in enumerate(A):
if a >= y:
y, yi = a, i
if x != y or xi > yi:
print((0))
return
MOD = 10**9 + 7
ans, cur = 1, 0
for i in T[: xi + 1]:
if i > cur: # point of new altitude -> no choice (ans * 1)
cur = i
else:
ans = (ans * cur) % MOD # mulitple choices (1, 2, ..., cur)
for _ in range(xi + 1, yi):
ans = (ans * cur) % MOD
for i in A[yi + 1 :]:
if i < cur:
cur = i
else:
ans = (ans * cur) % MOD
print(ans)
if __name__ == "__main__":
main()
| # code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists
from bisect import bisect_left as bs
def main():
"""
/----\ <- xi (= yi)
/ \--\
/ \
xi yi
0 ~ xi / xi ~ yi / yi+1 ~ N-1
"""
N = int(eval(input()))
T = tuple(map(int, input().split()))
A = tuple(map(int, input().split()))
x, y = T[-1], A[0] # max of x, y
xi, yi = T.index(x), N - A[::-1].index(y) - 1 # indices of x, y
if x != y or xi > yi:
print((0))
return
MOD = 10**9 + 7
ans, cur = 1, 0
for i in T[: xi + 1]:
if i > cur: # point of new altitude -> no choice (ans * 1)
cur = i
else:
ans = (ans * cur) % MOD # mulitple choices (1, 2, ..., cur)
for _ in range(xi + 1, yi):
ans = (ans * cur) % MOD
for i in A[yi + 1 :]:
if i < cur:
cur = i
else:
ans = (ans * cur) % MOD
print(ans)
if __name__ == "__main__":
main()
| false | 11.363636 | [
"- x, y, xi, yi = 0, 0, 0, 0 # max of x, y and the indices",
"- for i, t in enumerate(T):",
"- if t > x:",
"- x, xi = t, i",
"- for i, a in enumerate(A):",
"- if a >= y:",
"- y, yi = a, i",
"+ x, y = T[-1], A[0] # max of x, y",
"+ xi, yi = T.index(x), N - A[::-1].index(y) - 1 # indices of x, y"
]
| false | 0.049886 | 0.050221 | 0.993341 | [
"s077527684",
"s237569503"
]
|
u730769327 | p03436 | python | s155660033 | s760159194 | 235 | 81 | 43,240 | 74,444 | Accepted | Accepted | 65.53 | import queue
INF=10**8
r,c=list(map(int,input().split()))
#sy,sx=map(int,input().split())
#gy,gx=map(int,input().split())
maze=[eval(input()) for _ in range(r)]
d=[[INF for i in range(r)] for _ in range(c)]
sx,sy=1,1
gx,gy=r,c
cnt=0
for i in range(r):
for j in range(c):
if maze[i][j]=='.':
cnt+=1
sx-=1
sy-=1
gx-=1
gy-=1
q=queue.Queue()
dx=[-1,0,1,0]
dy=[0,-1,0,1]
q.put((sx,sy))
d[sy][sx]=0
while not q.empty():
x,y=q.get()
if (x,y)==(gx,gy):break
for i in range(4):
nx=x+dx[i]
ny=y+dy[i]
if 0<=nx<c and 0<=ny<r:
if maze[ny][nx]=='.' and d[nx][ny]==INF:
q.put((nx,ny))
d[nx][ny]=d[x][y]+1
if d[gy][gx]==INF:
print((-1))
else:print((cnt-d[gy][gx]-1)) | from collections import deque
INF=10**18
h,w=list(map(int,input().split()))
a=[eval(input()) for _ in range(h)]
d=[[INF for _ in range(w)]for _ in range(h)]
dx=[0,1,0,-1]
dy=[1,0,-1,0]
sx,sy=0,0
gx,gy=h-1,w-1
d[sx][sy]=1
q=deque([(sx,sy)])
while q:
x,y=q.popleft()
if (x,y)==(gx,gy):break
for i in range(4):
nx,ny=x+dx[i],y+dy[i]
if 0<=nx<h and 0<=ny<w:
if a[nx][ny]=='.' and d[nx][ny]==INF:
d[nx][ny]=d[x][y]+1
q.append((nx,ny))
if d[gx][gy]==INF:print((-1))
else:
cnt=0
for i in a:
cnt+=i.count('.')
print((cnt-d[gx][gy])) | 38 | 26 | 728 | 579 | import queue
INF = 10**8
r, c = list(map(int, input().split()))
# sy,sx=map(int,input().split())
# gy,gx=map(int,input().split())
maze = [eval(input()) for _ in range(r)]
d = [[INF for i in range(r)] for _ in range(c)]
sx, sy = 1, 1
gx, gy = r, c
cnt = 0
for i in range(r):
for j in range(c):
if maze[i][j] == ".":
cnt += 1
sx -= 1
sy -= 1
gx -= 1
gy -= 1
q = queue.Queue()
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
q.put((sx, sy))
d[sy][sx] = 0
while not q.empty():
x, y = q.get()
if (x, y) == (gx, gy):
break
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < c and 0 <= ny < r:
if maze[ny][nx] == "." and d[nx][ny] == INF:
q.put((nx, ny))
d[nx][ny] = d[x][y] + 1
if d[gy][gx] == INF:
print((-1))
else:
print((cnt - d[gy][gx] - 1))
| from collections import deque
INF = 10**18
h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
d = [[INF for _ in range(w)] for _ in range(h)]
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
sx, sy = 0, 0
gx, gy = h - 1, w - 1
d[sx][sy] = 1
q = deque([(sx, sy)])
while q:
x, y = q.popleft()
if (x, y) == (gx, gy):
break
for i in range(4):
nx, ny = x + dx[i], y + dy[i]
if 0 <= nx < h and 0 <= ny < w:
if a[nx][ny] == "." and d[nx][ny] == INF:
d[nx][ny] = d[x][y] + 1
q.append((nx, ny))
if d[gx][gy] == INF:
print((-1))
else:
cnt = 0
for i in a:
cnt += i.count(".")
print((cnt - d[gx][gy]))
| false | 31.578947 | [
"-import queue",
"+from collections import deque",
"-INF = 10**8",
"-r, c = list(map(int, input().split()))",
"-# sy,sx=map(int,input().split())",
"-# gy,gx=map(int,input().split())",
"-maze = [eval(input()) for _ in range(r)]",
"-d = [[INF for i in range(r)] for _ in range(c)]",
"-sx, sy = 1, 1",
"-gx, gy = r, c",
"-cnt = 0",
"-for i in range(r):",
"- for j in range(c):",
"- if maze[i][j] == \".\":",
"- cnt += 1",
"-sx -= 1",
"-sy -= 1",
"-gx -= 1",
"-gy -= 1",
"-q = queue.Queue()",
"-dx = [-1, 0, 1, 0]",
"-dy = [0, -1, 0, 1]",
"-q.put((sx, sy))",
"-d[sy][sx] = 0",
"-while not q.empty():",
"- x, y = q.get()",
"+INF = 10**18",
"+h, w = list(map(int, input().split()))",
"+a = [eval(input()) for _ in range(h)]",
"+d = [[INF for _ in range(w)] for _ in range(h)]",
"+dx = [0, 1, 0, -1]",
"+dy = [1, 0, -1, 0]",
"+sx, sy = 0, 0",
"+gx, gy = h - 1, w - 1",
"+d[sx][sy] = 1",
"+q = deque([(sx, sy)])",
"+while q:",
"+ x, y = q.popleft()",
"- nx = x + dx[i]",
"- ny = y + dy[i]",
"- if 0 <= nx < c and 0 <= ny < r:",
"- if maze[ny][nx] == \".\" and d[nx][ny] == INF:",
"- q.put((nx, ny))",
"+ nx, ny = x + dx[i], y + dy[i]",
"+ if 0 <= nx < h and 0 <= ny < w:",
"+ if a[nx][ny] == \".\" and d[nx][ny] == INF:",
"-if d[gy][gx] == INF:",
"+ q.append((nx, ny))",
"+if d[gx][gy] == INF:",
"- print((cnt - d[gy][gx] - 1))",
"+ cnt = 0",
"+ for i in a:",
"+ cnt += i.count(\".\")",
"+ print((cnt - d[gx][gy]))"
]
| false | 0.048226 | 0.046572 | 1.035509 | [
"s155660033",
"s760159194"
]
|
u072717685 | p02707 | python | s408255942 | s519819035 | 184 | 118 | 35,596 | 31,612 | Accepted | Accepted | 35.87 | from collections import Counter
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0] * n
ac = Counter(a)
for i in range(n):
cnt[i] = ac[i+1]
for i2 in range(n):
print((cnt[i2]))
if __name__ == '__main__':
main() | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import pi
def main():
n, *a = map(int, read().split())
cnt = [0] * n
for ae in a:
cnt[ae-1] += 1
print(*cnt, sep='\n')
if __name__ == '__main__':
main()
| 14 | 13 | 290 | 269 | from collections import Counter
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0] * n
ac = Counter(a)
for i in range(n):
cnt[i] = ac[i + 1]
for i2 in range(n):
print((cnt[i2]))
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import pi
def main():
n, *a = map(int, read().split())
cnt = [0] * n
for ae in a:
cnt[ae - 1] += 1
print(*cnt, sep="\n")
if __name__ == "__main__":
main()
| false | 7.142857 | [
"-from collections import Counter",
"+import sys",
"+",
"+read = sys.stdin.read",
"+readlines = sys.stdin.readlines",
"+from math import pi",
"- n = int(eval(input()))",
"- a = list(map(int, input().split()))",
"+ n, *a = map(int, read().split())",
"- ac = Counter(a)",
"- for i in range(n):",
"- cnt[i] = ac[i + 1]",
"- for i2 in range(n):",
"- print((cnt[i2]))",
"+ for ae in a:",
"+ cnt[ae - 1] += 1",
"+ print(*cnt, sep=\"\\n\")"
]
| false | 0.038197 | 0.038603 | 0.989479 | [
"s408255942",
"s519819035"
]
|
u565380863 | p03373 | python | s617573857 | s716250913 | 103 | 18 | 3,064 | 3,064 | Accepted | Accepted | 82.52 | import sys
def input():
return sys.stdin.readline()[:-1]
def ii(t: type = int):
return t(eval(input()))
def il(t: type = int):
return list(map(t, input().split()))
def imi(N: int, t: type = int):
return [ii(t) for _ in range(N)]
def iml(N: int, t: type = int):
return [il(t) for _ in range(N)]
A, B, C, X, Y = il()
m = A * X + B * Y
for i in range(2, 2 * max(X, Y) + 1, 2):
tmp = A * max(X - i // 2, 0) + B * max(Y - i // 2, 0) + C * i
if tmp < m:
m = tmp
print(m)
| import sys
def input():
return sys.stdin.readline()[:-1]
def ii(t: type = int):
return t(eval(input()))
def il(t: type = int):
return list(map(t, input().split()))
def imi(N: int, t: type = int):
return [ii(t) for _ in range(N)]
def iml(N: int, t: type = int):
return [il(t) for _ in range(N)]
A, B, C, X, Y = il()
if A + B < 2 * C:
print((A * X + B * Y))
exit()
p = min(X, Y) * 2 * C
n = max(X - Y, Y - X)
if X < Y:
p += min(2 * C * n, n * B)
else:
p += min(2 * C * n, n * A)
print(p)
| 30 | 35 | 536 | 561 | import sys
def input():
return sys.stdin.readline()[:-1]
def ii(t: type = int):
return t(eval(input()))
def il(t: type = int):
return list(map(t, input().split()))
def imi(N: int, t: type = int):
return [ii(t) for _ in range(N)]
def iml(N: int, t: type = int):
return [il(t) for _ in range(N)]
A, B, C, X, Y = il()
m = A * X + B * Y
for i in range(2, 2 * max(X, Y) + 1, 2):
tmp = A * max(X - i // 2, 0) + B * max(Y - i // 2, 0) + C * i
if tmp < m:
m = tmp
print(m)
| import sys
def input():
return sys.stdin.readline()[:-1]
def ii(t: type = int):
return t(eval(input()))
def il(t: type = int):
return list(map(t, input().split()))
def imi(N: int, t: type = int):
return [ii(t) for _ in range(N)]
def iml(N: int, t: type = int):
return [il(t) for _ in range(N)]
A, B, C, X, Y = il()
if A + B < 2 * C:
print((A * X + B * Y))
exit()
p = min(X, Y) * 2 * C
n = max(X - Y, Y - X)
if X < Y:
p += min(2 * C * n, n * B)
else:
p += min(2 * C * n, n * A)
print(p)
| false | 14.285714 | [
"-m = A * X + B * Y",
"-for i in range(2, 2 * max(X, Y) + 1, 2):",
"- tmp = A * max(X - i // 2, 0) + B * max(Y - i // 2, 0) + C * i",
"- if tmp < m:",
"- m = tmp",
"-print(m)",
"+if A + B < 2 * C:",
"+ print((A * X + B * Y))",
"+ exit()",
"+p = min(X, Y) * 2 * C",
"+n = max(X - Y, Y - X)",
"+if X < Y:",
"+ p += min(2 * C * n, n * B)",
"+else:",
"+ p += min(2 * C * n, n * A)",
"+print(p)"
]
| false | 0.070215 | 0.038027 | 1.846448 | [
"s617573857",
"s716250913"
]
|
u945181840 | p03607 | python | s314000835 | s225286791 | 207 | 190 | 11,884 | 16,640 | Accepted | Accepted | 8.21 | N = int(eval(input()))
A = set([])
for i in range(N):
temp = int(eval(input()))
if temp not in A:
A.add(temp)
else:
A.remove(temp)
print((len(A))) | from collections import Counter
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
a = list(Counter(A).values())
a = [i for i in a if i % 2 == 1]
print((len(a))) | 11 | 8 | 172 | 171 | N = int(eval(input()))
A = set([])
for i in range(N):
temp = int(eval(input()))
if temp not in A:
A.add(temp)
else:
A.remove(temp)
print((len(A)))
| from collections import Counter
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
a = list(Counter(A).values())
a = [i for i in a if i % 2 == 1]
print((len(a)))
| false | 27.272727 | [
"+from collections import Counter",
"+",
"-A = set([])",
"-for i in range(N):",
"- temp = int(eval(input()))",
"- if temp not in A:",
"- A.add(temp)",
"- else:",
"- A.remove(temp)",
"-print((len(A)))",
"+A = [int(eval(input())) for i in range(N)]",
"+a = list(Counter(A).values())",
"+a = [i for i in a if i % 2 == 1]",
"+print((len(a)))"
]
| false | 0.122471 | 0.064324 | 1.903987 | [
"s314000835",
"s225286791"
]
|
u413165887 | p03096 | python | s538447583 | s291459069 | 835 | 763 | 85,668 | 73,124 | Accepted | Accepted | 8.62 | n = int(eval(input()))
c = [int(eval(input())) for _i in range(n)]
c.append(-1)
dic = {}
dp = [0 for _i in range(n+1)]
dp[n] = 1
mod = 10**9 +7
for i in range(n):
if c[i-1] != c[i]:
if c[i] in dic:
dp[i] = (dp[i-1] + dic[c[i]])%mod
else:
dp[i] = dp[i-1]
dic[c[i]] = dp[i]
else:
dp[i] = dp[i-1]
print((dp[n-1]%mod)) | n = int(eval(input()))
c = [int(eval(input())) for _i in range(n)]
c.append(-1)
dic = [-1 for _i in range(10**5 *2 +1)]
dp = [0 for _i in range(n+1)]
dp[n] = 1
mod = 10**9 +7
for i in range(n):
if c[i-1] != c[i]:
if dic[c[i]] > 0:
dp[i] = (dp[i-1] + dic[c[i]])%mod
else:
dp[i] = dp[i-1]
dic[c[i]] = dp[i]
else:
dp[i] = dp[i-1]
print((dp[n-1]%mod)) | 18 | 18 | 386 | 419 | n = int(eval(input()))
c = [int(eval(input())) for _i in range(n)]
c.append(-1)
dic = {}
dp = [0 for _i in range(n + 1)]
dp[n] = 1
mod = 10**9 + 7
for i in range(n):
if c[i - 1] != c[i]:
if c[i] in dic:
dp[i] = (dp[i - 1] + dic[c[i]]) % mod
else:
dp[i] = dp[i - 1]
dic[c[i]] = dp[i]
else:
dp[i] = dp[i - 1]
print((dp[n - 1] % mod))
| n = int(eval(input()))
c = [int(eval(input())) for _i in range(n)]
c.append(-1)
dic = [-1 for _i in range(10**5 * 2 + 1)]
dp = [0 for _i in range(n + 1)]
dp[n] = 1
mod = 10**9 + 7
for i in range(n):
if c[i - 1] != c[i]:
if dic[c[i]] > 0:
dp[i] = (dp[i - 1] + dic[c[i]]) % mod
else:
dp[i] = dp[i - 1]
dic[c[i]] = dp[i]
else:
dp[i] = dp[i - 1]
print((dp[n - 1] % mod))
| false | 0 | [
"-dic = {}",
"+dic = [-1 for _i in range(10**5 * 2 + 1)]",
"- if c[i] in dic:",
"+ if dic[c[i]] > 0:"
]
| false | 0.03977 | 0.051837 | 0.767197 | [
"s538447583",
"s291459069"
]
|
u969190727 | p03253 | python | s366068977 | s306633287 | 1,975 | 180 | 114,396 | 18,932 | Accepted | Accepted | 90.89 | import collections
import math
n,m=list(map(int,input().split()))
flag=0
P=[]
p=m
while flag==0:
cur=p
for i in range(2,int(p**0.5)+1):
if p%i==0:
P.append(i)
p//=i
break
if p==cur:
P.append(p)
flag=1
c=collections.Counter(P)
Primes=set(P)
def f(i):
return math.factorial(i)
def fn(i):
return f(n+i-1)//(f(n-1)*f(i))%(10**9+7)
ans=1
for p in Primes:
ans*=fn(c[p])
ans%=(10**9+7)
print((1 if m==1 else ans))
| import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n,m=list(map(int,input().split()))
n_max=2*(10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(list(range(n_max-1))):
FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
return (F[x]*FI[x-y]*FI[y])%mod
pf={}
for i in range(2,int(m**0.5)+1):
while m%i==0:
pf[i]=pf.get(i,0)+1
m//=i
if m>1:
pf[m]=1
ans=1
for k in list(pf.keys()):
ans=(ans*comb(n-1+pf[k],pf[k]))%mod
print(ans) | 27 | 27 | 470 | 570 | import collections
import math
n, m = list(map(int, input().split()))
flag = 0
P = []
p = m
while flag == 0:
cur = p
for i in range(2, int(p**0.5) + 1):
if p % i == 0:
P.append(i)
p //= i
break
if p == cur:
P.append(p)
flag = 1
c = collections.Counter(P)
Primes = set(P)
def f(i):
return math.factorial(i)
def fn(i):
return f(n + i - 1) // (f(n - 1) * f(i)) % (10**9 + 7)
ans = 1
for p in Primes:
ans *= fn(c[p])
ans %= 10**9 + 7
print((1 if m == 1 else ans))
| import sys
input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7
n, m = list(map(int, input().split()))
n_max = 2 * (10**5 + 1)
F, FI = [0] * (n_max + 1), [0] * (n_max + 1)
F[0], FI[0] = 1, 1
for i in range(n_max):
F[i + 1] = (F[i] * (i + 1)) % mod
FI[n_max - 1] = pow(F[n_max - 1], mod - 2, mod)
for i in reversed(list(range(n_max - 1))):
FI[i] = (FI[i + 1] * (i + 1)) % mod
def comb(x, y):
return (F[x] * FI[x - y] * FI[y]) % mod
pf = {}
for i in range(2, int(m**0.5) + 1):
while m % i == 0:
pf[i] = pf.get(i, 0) + 1
m //= i
if m > 1:
pf[m] = 1
ans = 1
for k in list(pf.keys()):
ans = (ans * comb(n - 1 + pf[k], pf[k])) % mod
print(ans)
| false | 0 | [
"-import collections",
"-import math",
"+import sys",
"+input = lambda: sys.stdin.readline().rstrip()",
"+mod = 10**9 + 7",
"-flag = 0",
"-P = []",
"-p = m",
"-while flag == 0:",
"- cur = p",
"- for i in range(2, int(p**0.5) + 1):",
"- if p % i == 0:",
"- P.append(i)",
"- p //= i",
"- break",
"- if p == cur:",
"- P.append(p)",
"- flag = 1",
"-c = collections.Counter(P)",
"-Primes = set(P)",
"+n_max = 2 * (10**5 + 1)",
"+F, FI = [0] * (n_max + 1), [0] * (n_max + 1)",
"+F[0], FI[0] = 1, 1",
"+for i in range(n_max):",
"+ F[i + 1] = (F[i] * (i + 1)) % mod",
"+FI[n_max - 1] = pow(F[n_max - 1], mod - 2, mod)",
"+for i in reversed(list(range(n_max - 1))):",
"+ FI[i] = (FI[i + 1] * (i + 1)) % mod",
"-def f(i):",
"- return math.factorial(i)",
"+def comb(x, y):",
"+ return (F[x] * FI[x - y] * FI[y]) % mod",
"-def fn(i):",
"- return f(n + i - 1) // (f(n - 1) * f(i)) % (10**9 + 7)",
"-",
"-",
"+pf = {}",
"+for i in range(2, int(m**0.5) + 1):",
"+ while m % i == 0:",
"+ pf[i] = pf.get(i, 0) + 1",
"+ m //= i",
"+if m > 1:",
"+ pf[m] = 1",
"-for p in Primes:",
"- ans *= fn(c[p])",
"- ans %= 10**9 + 7",
"-print((1 if m == 1 else ans))",
"+for k in list(pf.keys()):",
"+ ans = (ans * comb(n - 1 + pf[k], pf[k])) % mod",
"+print(ans)"
]
| false | 0.191932 | 0.30784 | 0.623478 | [
"s366068977",
"s306633287"
]
|
u588341295 | p03837 | python | s954252202 | s128380339 | 647 | 427 | 3,444 | 3,948 | Accepted | Accepted | 34 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N, M = list(map(int, input().split()))
G = [[float('inf')] * N for i in range(N)]
edges = [None] * M
for i in range(M):
a, b, c = list(map(int, input().split()))
G[a-1][b-1] = c
G[b-1][a-1] = c
edges[i] = (a-1, b-1, c)
# ワーシャルフロイドで全頂点の最短距離
for k in range(N):
for i in range(N):
for j in range(N):
if i == j:
G[i][j] = 0
else:
G[i][j] = min(G[i][j], G[i][k] + G[k][j])
ans = 0
for a, b, c in edges:
# 最短距離ではない辺の数を数える
if G[a][b] < c:
ans += 1
print(ans)
| # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def warshall_floyd(N: int, graph: list) -> list:
""" ワーシャルフロイド(頂点数, 隣接行列(0-indexed)) """
from copy import deepcopy
res = deepcopy(graph)
for i in range(N):
# 始点 = 終点、は予め距離0にしておく
res[i][i] = 0
# 全頂点の最短距離
for k in range(N):
for i in range(N):
for j in range(N):
res[i][j] = min(res[i][j], res[i][k] + res[k][j])
# 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
for i in range(N):
if res[i][i] < 0:
return []
return res
N, M = MAP()
G = list2d(N, N, INF)
for i in range(M):
a, b, c = MAP()
a -= 1; b -= 1
G[a][b] = c
G[b][a] = c
wf = warshall_floyd(N, G)
cnt = 0
for i in range(N):
for j in range(i+1, N):
# 辺があって、最短経路より長いなら使わない
if G[i][j] != INF and G[i][j] > wf[i][j]:
cnt += 1
print(cnt)
| 33 | 56 | 729 | 1,568 | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, M = list(map(int, input().split()))
G = [[float("inf")] * N for i in range(N)]
edges = [None] * M
for i in range(M):
a, b, c = list(map(int, input().split()))
G[a - 1][b - 1] = c
G[b - 1][a - 1] = c
edges[i] = (a - 1, b - 1, c)
# ワーシャルフロイドで全頂点の最短距離
for k in range(N):
for i in range(N):
for j in range(N):
if i == j:
G[i][j] = 0
else:
G[i][j] = min(G[i][j], G[i][k] + G[k][j])
ans = 0
for a, b, c in edges:
# 最短距離ではない辺の数を数える
if G[a][b] < c:
ans += 1
print(ans)
| # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
def warshall_floyd(N: int, graph: list) -> list:
"""ワーシャルフロイド(頂点数, 隣接行列(0-indexed))"""
from copy import deepcopy
res = deepcopy(graph)
for i in range(N):
# 始点 = 終点、は予め距離0にしておく
res[i][i] = 0
# 全頂点の最短距離
for k in range(N):
for i in range(N):
for j in range(N):
res[i][j] = min(res[i][j], res[i][k] + res[k][j])
# 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
for i in range(N):
if res[i][i] < 0:
return []
return res
N, M = MAP()
G = list2d(N, N, INF)
for i in range(M):
a, b, c = MAP()
a -= 1
b -= 1
G[a][b] = c
G[b][a] = c
wf = warshall_floyd(N, G)
cnt = 0
for i in range(N):
for j in range(i + 1, N):
# 辺があって、最短経路より長いなら使わない
if G[i][j] != INF and G[i][j] > wf[i][j]:
cnt += 1
print(cnt)
| false | 41.071429 | [
"+def list2d(a, b, c):",
"+ return [[c] * b for i in range(a)]",
"+",
"+",
"+def list3d(a, b, c, d):",
"+ return [[[d] * c for j in range(b)] for i in range(a)]",
"+",
"+",
"+def list4d(a, b, c, d, e):",
"+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]",
"+",
"+",
"+def ceil(x, y=1):",
"+ return int(-(-x // y))",
"+",
"+",
"+def INT():",
"+ return int(eval(input()))",
"+",
"+",
"+def MAP():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LIST(N=None):",
"+ return list(MAP()) if N is None else [INT() for i in range(N)]",
"+",
"+",
"+def Yes():",
"+ print(\"Yes\")",
"+",
"+",
"+def No():",
"+ print(\"No\")",
"+",
"+",
"+def YES():",
"+ print(\"YES\")",
"+",
"+",
"+def NO():",
"+ print(\"NO\")",
"+",
"+",
"-INF = float(\"inf\")",
"+INF = 10**18",
"-N, M = list(map(int, input().split()))",
"-G = [[float(\"inf\")] * N for i in range(N)]",
"-edges = [None] * M",
"+",
"+",
"+def warshall_floyd(N: int, graph: list) -> list:",
"+ \"\"\"ワーシャルフロイド(頂点数, 隣接行列(0-indexed))\"\"\"",
"+ from copy import deepcopy",
"+",
"+ res = deepcopy(graph)",
"+ for i in range(N):",
"+ # 始点 = 終点、は予め距離0にしておく",
"+ res[i][i] = 0",
"+ # 全頂点の最短距離",
"+ for k in range(N):",
"+ for i in range(N):",
"+ for j in range(N):",
"+ res[i][j] = min(res[i][j], res[i][k] + res[k][j])",
"+ # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする",
"+ for i in range(N):",
"+ if res[i][i] < 0:",
"+ return []",
"+ return res",
"+",
"+",
"+N, M = MAP()",
"+G = list2d(N, N, INF)",
"- a, b, c = list(map(int, input().split()))",
"- G[a - 1][b - 1] = c",
"- G[b - 1][a - 1] = c",
"- edges[i] = (a - 1, b - 1, c)",
"-# ワーシャルフロイドで全頂点の最短距離",
"-for k in range(N):",
"- for i in range(N):",
"- for j in range(N):",
"- if i == j:",
"- G[i][j] = 0",
"- else:",
"- G[i][j] = min(G[i][j], G[i][k] + G[k][j])",
"-ans = 0",
"-for a, b, c in edges:",
"- # 最短距離ではない辺の数を数える",
"- if G[a][b] < c:",
"- ans += 1",
"-print(ans)",
"+ a, b, c = MAP()",
"+ a -= 1",
"+ b -= 1",
"+ G[a][b] = c",
"+ G[b][a] = c",
"+wf = warshall_floyd(N, G)",
"+cnt = 0",
"+for i in range(N):",
"+ for j in range(i + 1, N):",
"+ # 辺があって、最短経路より長いなら使わない",
"+ if G[i][j] != INF and G[i][j] > wf[i][j]:",
"+ cnt += 1",
"+print(cnt)"
]
| false | 0.049042 | 0.053486 | 0.916908 | [
"s954252202",
"s128380339"
]
|
u996665352 | p03031 | python | s424193758 | s154648095 | 36 | 20 | 3,064 | 3,064 | Accepted | Accepted | 44.44 | N,M = list(map(int,input().split()))
in_M =[[]]*M
for m in range(M):
in_M[m] = list(map(int,input().split()))
out_M = list(map(int,input().split()))
all_on_cnt = 0
for i in range(2**N):
switch = [0]*N
for j in range(N):
if((i>>j) & 1): # iをj回右シフトさせ末尾をみる
switch[j] = 1
for j in range(M):
total = 0
for l in range(1,in_M[j][0]+1):
total += switch[in_M[j][l]-1]
if total%2 != out_M[j]:
break
else:
all_on_cnt += 1
print(all_on_cnt) | n,m = list(map(int,input().split()))
swi = []
for _ in range(m):
k, *sss = list(map(int,input().split()))
t = 0
for s in sss:
t += 1 << (s-1)
swi.append(t)
ppp = list(map(int,input().split()))
ans = 0
for bit in range(1<<n):
for s,p in zip(swi,ppp):
t = bit&s
c = bin(t).count("1") % 2
if c != p:
break
else:
ans += 1
print(ans) | 23 | 20 | 566 | 424 | N, M = list(map(int, input().split()))
in_M = [[]] * M
for m in range(M):
in_M[m] = list(map(int, input().split()))
out_M = list(map(int, input().split()))
all_on_cnt = 0
for i in range(2**N):
switch = [0] * N
for j in range(N):
if (i >> j) & 1: # iをj回右シフトさせ末尾をみる
switch[j] = 1
for j in range(M):
total = 0
for l in range(1, in_M[j][0] + 1):
total += switch[in_M[j][l] - 1]
if total % 2 != out_M[j]:
break
else:
all_on_cnt += 1
print(all_on_cnt)
| n, m = list(map(int, input().split()))
swi = []
for _ in range(m):
k, *sss = list(map(int, input().split()))
t = 0
for s in sss:
t += 1 << (s - 1)
swi.append(t)
ppp = list(map(int, input().split()))
ans = 0
for bit in range(1 << n):
for s, p in zip(swi, ppp):
t = bit & s
c = bin(t).count("1") % 2
if c != p:
break
else:
ans += 1
print(ans)
| false | 13.043478 | [
"-N, M = list(map(int, input().split()))",
"-in_M = [[]] * M",
"-for m in range(M):",
"- in_M[m] = list(map(int, input().split()))",
"-out_M = list(map(int, input().split()))",
"-all_on_cnt = 0",
"-for i in range(2**N):",
"- switch = [0] * N",
"- for j in range(N):",
"- if (i >> j) & 1: # iをj回右シフトさせ末尾をみる",
"- switch[j] = 1",
"- for j in range(M):",
"- total = 0",
"- for l in range(1, in_M[j][0] + 1):",
"- total += switch[in_M[j][l] - 1]",
"- if total % 2 != out_M[j]:",
"+n, m = list(map(int, input().split()))",
"+swi = []",
"+for _ in range(m):",
"+ k, *sss = list(map(int, input().split()))",
"+ t = 0",
"+ for s in sss:",
"+ t += 1 << (s - 1)",
"+ swi.append(t)",
"+ppp = list(map(int, input().split()))",
"+ans = 0",
"+for bit in range(1 << n):",
"+ for s, p in zip(swi, ppp):",
"+ t = bit & s",
"+ c = bin(t).count(\"1\") % 2",
"+ if c != p:",
"- all_on_cnt += 1",
"-print(all_on_cnt)",
"+ ans += 1",
"+print(ans)"
]
| false | 0.049565 | 0.04707 | 1.053016 | [
"s424193758",
"s154648095"
]
|
u102461423 | p03666 | python | s521713773 | s293856080 | 294 | 126 | 31,932 | 42,708 | Accepted | Accepted | 57.14 | import sys
input = sys.stdin.readline
# 加算・減算の回数を固定すると範囲が決まる
import numpy as np
N,A,B,C,D = list(map(int,input().split()))
# 加算の回数をもとに
rng = np.arange(N,dtype=np.int64)
upper = D*rng - C*rng[::-1]
lower = C*rng - D*rng[::-1]
answer = 'YES' if ((lower <= B-A) & (B-A <= upper)).any() else 'NO'
print(answer) | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A, B, C, D = list(map(int, read().split()))
N -= 1
x = np.arange(N + 1, dtype=np.int64) # 増加回数
low = C * x - D * (N - x)
high = D * x - C * (N - x)
diff = B - A
cond = np.any((low <= diff) & (diff <= high))
print(('YES' if cond else 'NO')) | 16 | 18 | 320 | 392 | import sys
input = sys.stdin.readline
# 加算・減算の回数を固定すると範囲が決まる
import numpy as np
N, A, B, C, D = list(map(int, input().split()))
# 加算の回数をもとに
rng = np.arange(N, dtype=np.int64)
upper = D * rng - C * rng[::-1]
lower = C * rng - D * rng[::-1]
answer = "YES" if ((lower <= B - A) & (B - A <= upper)).any() else "NO"
print(answer)
| import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A, B, C, D = list(map(int, read().split()))
N -= 1
x = np.arange(N + 1, dtype=np.int64) # 増加回数
low = C * x - D * (N - x)
high = D * x - C * (N - x)
diff = B - A
cond = np.any((low <= diff) & (diff <= high))
print(("YES" if cond else "NO"))
| false | 11.111111 | [
"-",
"-input = sys.stdin.readline",
"-# 加算・減算の回数を固定すると範囲が決まる",
"-N, A, B, C, D = list(map(int, input().split()))",
"-# 加算の回数をもとに",
"-rng = np.arange(N, dtype=np.int64)",
"-upper = D * rng - C * rng[::-1]",
"-lower = C * rng - D * rng[::-1]",
"-answer = \"YES\" if ((lower <= B - A) & (B - A <= upper)).any() else \"NO\"",
"-print(answer)",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+N, A, B, C, D = list(map(int, read().split()))",
"+N -= 1",
"+x = np.arange(N + 1, dtype=np.int64) # 増加回数",
"+low = C * x - D * (N - x)",
"+high = D * x - C * (N - x)",
"+diff = B - A",
"+cond = np.any((low <= diff) & (diff <= high))",
"+print((\"YES\" if cond else \"NO\"))"
]
| false | 0.454439 | 0.551104 | 0.824596 | [
"s521713773",
"s293856080"
]
|
u840247626 | p02258 | python | s797058703 | s221304054 | 670 | 610 | 5,620 | 5,620 | Accepted | Accepted | 8.96 | s_max = -float('inf')
s = 0
for i in range(int(eval(input()))):
r = int(eval(input()))
if i:
d = r - prev
s = max(s, 0) + d
s_max = max(s, s_max)
prev = r
print(s_max)
| s_max = -float('inf')
s = 0
for i in range(int(eval(input()))):
r = int(eval(input()))
if i:
s = max(s, 0) + r - prev
s_max = max(s, s_max)
prev = r
print(s_max)
| 10 | 9 | 174 | 165 | s_max = -float("inf")
s = 0
for i in range(int(eval(input()))):
r = int(eval(input()))
if i:
d = r - prev
s = max(s, 0) + d
s_max = max(s, s_max)
prev = r
print(s_max)
| s_max = -float("inf")
s = 0
for i in range(int(eval(input()))):
r = int(eval(input()))
if i:
s = max(s, 0) + r - prev
s_max = max(s, s_max)
prev = r
print(s_max)
| false | 10 | [
"- d = r - prev",
"- s = max(s, 0) + d",
"+ s = max(s, 0) + r - prev"
]
| false | 0.042165 | 0.039165 | 1.076605 | [
"s797058703",
"s221304054"
]
|
u760794812 | p02831 | python | s753392177 | s910210015 | 35 | 17 | 5,048 | 2,940 | Accepted | Accepted | 51.43 | import fractions
A,B = list(map(int,input().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
print((lcm(A, B))) | A,B = list(map(int,input().split()))
#a,bの最大公約数
def gcd(a, b):
while b:
a, b = b, a % b
return a
#a,bの最小公倍数
def lcm(a, b):
return a * b // gcd (a, b)
Answer = lcm(A,B)
print(Answer) | 7 | 14 | 129 | 213 | import fractions
A, B = list(map(int, input().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
print((lcm(A, B)))
| A, B = list(map(int, input().split()))
# a,bの最大公約数
def gcd(a, b):
while b:
a, b = b, a % b
return a
# a,bの最小公倍数
def lcm(a, b):
return a * b // gcd(a, b)
Answer = lcm(A, B)
print(Answer)
| false | 50 | [
"-import fractions",
"-",
"+# a,bの最大公約数",
"+def gcd(a, b):",
"+ while b:",
"+ a, b = b, a % b",
"+ return a",
"-def lcm(x, y):",
"- return (x * y) // fractions.gcd(x, y)",
"+# a,bの最小公倍数",
"+def lcm(a, b):",
"+ return a * b // gcd(a, b)",
"-print((lcm(A, B)))",
"+Answer = lcm(A, B)",
"+print(Answer)"
]
| false | 0.054849 | 0.042686 | 1.284946 | [
"s753392177",
"s910210015"
]
|
u150984829 | p02414 | python | s843984095 | s262661444 | 470 | 130 | 7,044 | 7,008 | Accepted | Accepted | 72.34 | n,m,l=list(map(int,input().split()))
a=[[int(_) for _ in input().split()] for i in range(n)]
b=[[int(_) for _ in input().split()] for i in range(m)]
c=[[0]*l for _ in range(n)]
for i in range(n):
for j in range(l):
for k in range(m):
c[i][j]+=a[i][k]*b[k][j]
for i in range(n):
print((*c[i])) | n,m,l=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[list(map(int,input().split())) for _ in range(m)]
[print(*x)for x in[[sum(s*t for s,t in zip(c,l))for l in zip(*b)]for c in a]]
| 10 | 4 | 300 | 217 | n, m, l = list(map(int, input().split()))
a = [[int(_) for _ in input().split()] for i in range(n)]
b = [[int(_) for _ in input().split()] for i in range(m)]
c = [[0] * l for _ in range(n)]
for i in range(n):
for j in range(l):
for k in range(m):
c[i][j] += a[i][k] * b[k][j]
for i in range(n):
print((*c[i]))
| n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
[print(*x) for x in [[sum(s * t for s, t in zip(c, l)) for l in zip(*b)] for c in a]]
| false | 60 | [
"-n, m, l = list(map(int, input().split()))",
"-a = [[int(_) for _ in input().split()] for i in range(n)]",
"-b = [[int(_) for _ in input().split()] for i in range(m)]",
"-c = [[0] * l for _ in range(n)]",
"-for i in range(n):",
"- for j in range(l):",
"- for k in range(m):",
"- c[i][j] += a[i][k] * b[k][j]",
"-for i in range(n):",
"- print((*c[i]))",
"+n, m, l = map(int, input().split())",
"+a = [list(map(int, input().split())) for _ in range(n)]",
"+b = [list(map(int, input().split())) for _ in range(m)]",
"+[print(*x) for x in [[sum(s * t for s, t in zip(c, l)) for l in zip(*b)] for c in a]]"
]
| false | 0.044805 | 0.044973 | 0.996268 | [
"s843984095",
"s262661444"
]
|
u163320134 | p02972 | python | s389289879 | s327969892 | 839 | 679 | 68,956 | 14,096 | Accepted | Accepted | 19.07 | def div(val):
ret=[]
for i in range(1,int(val**0.5)+1):
if val%i==0:
ret.append(i)
if val//i!=i:
ret.append(val//i)
return ret
n=int(eval(input()))
arr=list(map(int,input().split()))
cnt=[0]*n
num=0
ans=[]
for i in range(n-1,-1,-1):
if (arr[i]+cnt[i])%2==0:
continue
else:
ans.append(i+1)
num+=1
for j in div(i+1):
cnt[j-1]+=1
if num==0:
print((0))
else:
print(num)
print((*ans)) | n=int(eval(input()))
arr=list(map(int,input().split()))
flag=[-1]*n
ans=[]
for i in range(n-1,-1,-1):
cnt=0
for j in range(i,n,i+1):
if j==i:
continue
else:
if flag[j]==1:
cnt+=1
if (arr[i]+cnt)%2==0:
flag[i]=0
else:
flag[i]=1
ans.append(i+1)
num=len(ans)
if num==0:
print((0))
else:
print(num)
print((*ans)) | 27 | 23 | 458 | 374 | def div(val):
ret = []
for i in range(1, int(val**0.5) + 1):
if val % i == 0:
ret.append(i)
if val // i != i:
ret.append(val // i)
return ret
n = int(eval(input()))
arr = list(map(int, input().split()))
cnt = [0] * n
num = 0
ans = []
for i in range(n - 1, -1, -1):
if (arr[i] + cnt[i]) % 2 == 0:
continue
else:
ans.append(i + 1)
num += 1
for j in div(i + 1):
cnt[j - 1] += 1
if num == 0:
print((0))
else:
print(num)
print((*ans))
| n = int(eval(input()))
arr = list(map(int, input().split()))
flag = [-1] * n
ans = []
for i in range(n - 1, -1, -1):
cnt = 0
for j in range(i, n, i + 1):
if j == i:
continue
else:
if flag[j] == 1:
cnt += 1
if (arr[i] + cnt) % 2 == 0:
flag[i] = 0
else:
flag[i] = 1
ans.append(i + 1)
num = len(ans)
if num == 0:
print((0))
else:
print(num)
print((*ans))
| false | 14.814815 | [
"-def div(val):",
"- ret = []",
"- for i in range(1, int(val**0.5) + 1):",
"- if val % i == 0:",
"- ret.append(i)",
"- if val // i != i:",
"- ret.append(val // i)",
"- return ret",
"-",
"-",
"-cnt = [0] * n",
"-num = 0",
"+flag = [-1] * n",
"- if (arr[i] + cnt[i]) % 2 == 0:",
"- continue",
"+ cnt = 0",
"+ for j in range(i, n, i + 1):",
"+ if j == i:",
"+ continue",
"+ else:",
"+ if flag[j] == 1:",
"+ cnt += 1",
"+ if (arr[i] + cnt) % 2 == 0:",
"+ flag[i] = 0",
"+ flag[i] = 1",
"- num += 1",
"- for j in div(i + 1):",
"- cnt[j - 1] += 1",
"+num = len(ans)"
]
| false | 0.044456 | 0.037436 | 1.187524 | [
"s389289879",
"s327969892"
]
|
u017810624 | p02793 | python | s121480011 | s031793636 | 372 | 339 | 114,800 | 54,876 | Accepted | Accepted | 8.87 | def extgcd(a,b):
r=[1,0,a]
w=[0,1,b]
while w[2]!=1:
q=r[2]//w[2]
r2=w
w2=[r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
r=r2
w=w2
return [w[0],w[1]]
def mod_inv(a,m):
x=extgcd(a,m)[0]
return (m+x%m)%m
def fact(n):
fct=[]
b,e=2,0
while b*b<= n:
while n%b==0:
n=n//b
e=e + 1
if e>0:
fct.append((b, e))
b,e=b+1,0
if n>1:
fct.append((n, 1))
return fct
n=int(eval(input()))
a=list(map(int,input().split()))
l=[0 for i in range(10**6)]
mod=10**9+7
for i in range(n):
x=fact(a[i])
for j in range(len(x)):
l[x[j][0]]=max(l[x[j][0]],x[j][1])
lcm=1
for i in range(2,10**6):
lcm*=(i**l[i])
lcm%=mod
ans=0
for i in range(n):
ans+=lcm*mod_inv(a[i],mod)
ans%=mod
print(ans) | def extgcd(a,b):
r=[1,0,a]
w=[0,1,b]
while w[2]!=1:
q=r[2]//w[2]
r2=w
w2=[r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
r=r2
w=w2
return [w[0],w[1]]
def mod_inv(a,m):
x=extgcd(a,m)[0]
return (m+x%m)%m
def fact(n):
fct=[]
b,e=2,0
while b*b<=n:
while n%b==0:
n=n//b
e=e+1
if e>0:
fct.append((b,e))
b,e=b+1,0
if n>1:
fct.append((n,1))
return fct
n=int(eval(input()))
a=list(map(int,input().split()))
l=[0]*10**6
mod=10**9+7
for i in range(n):
x=fact(a[i])
for j in range(len(x)):
l[x[j][0]]=max(l[x[j][0]],x[j][1])
lcm=1
for i in range(2,10**6):
lcm*=(i**l[i])
lcm%=mod
ans=0
for i in range(n):
ans+=lcm*mod_inv(a[i],mod)
ans%=mod
print(ans) | 45 | 45 | 782 | 761 | def extgcd(a, b):
r = [1, 0, a]
w = [0, 1, b]
while w[2] != 1:
q = r[2] // w[2]
r2 = w
w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
r = r2
w = w2
return [w[0], w[1]]
def mod_inv(a, m):
x = extgcd(a, m)[0]
return (m + x % m) % m
def fact(n):
fct = []
b, e = 2, 0
while b * b <= n:
while n % b == 0:
n = n // b
e = e + 1
if e > 0:
fct.append((b, e))
b, e = b + 1, 0
if n > 1:
fct.append((n, 1))
return fct
n = int(eval(input()))
a = list(map(int, input().split()))
l = [0 for i in range(10**6)]
mod = 10**9 + 7
for i in range(n):
x = fact(a[i])
for j in range(len(x)):
l[x[j][0]] = max(l[x[j][0]], x[j][1])
lcm = 1
for i in range(2, 10**6):
lcm *= i ** l[i]
lcm %= mod
ans = 0
for i in range(n):
ans += lcm * mod_inv(a[i], mod)
ans %= mod
print(ans)
| def extgcd(a, b):
r = [1, 0, a]
w = [0, 1, b]
while w[2] != 1:
q = r[2] // w[2]
r2 = w
w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
r = r2
w = w2
return [w[0], w[1]]
def mod_inv(a, m):
x = extgcd(a, m)[0]
return (m + x % m) % m
def fact(n):
fct = []
b, e = 2, 0
while b * b <= n:
while n % b == 0:
n = n // b
e = e + 1
if e > 0:
fct.append((b, e))
b, e = b + 1, 0
if n > 1:
fct.append((n, 1))
return fct
n = int(eval(input()))
a = list(map(int, input().split()))
l = [0] * 10**6
mod = 10**9 + 7
for i in range(n):
x = fact(a[i])
for j in range(len(x)):
l[x[j][0]] = max(l[x[j][0]], x[j][1])
lcm = 1
for i in range(2, 10**6):
lcm *= i ** l[i]
lcm %= mod
ans = 0
for i in range(n):
ans += lcm * mod_inv(a[i], mod)
ans %= mod
print(ans)
| false | 0 | [
"-l = [0 for i in range(10**6)]",
"+l = [0] * 10**6"
]
| false | 1.013581 | 0.985441 | 1.028555 | [
"s121480011",
"s031793636"
]
|
u075012704 | p03579 | python | s746875903 | s081876384 | 541 | 459 | 31,084 | 31,156 | Accepted | Accepted | 15.16 | import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
G = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a, b = a-1, b-1
G[a].append(b)
G[b].append(a)
# 0は未着色を表す
color = [0] * N
# 二部グラフ判定dfs
def dfs(v, c):
color[v] = c
for to in G[v]:
if color[to] == c:
return False
if color[to] == 0 and not dfs(to, -c):
return False
return True
print((N * (N - 1) // 2 - M if not dfs(0, 1) else color.count(1) * color.count(-1) - M))
| # 忘れないように
import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
G = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
G[a].append(b)
G[b].append(a)
# 0は未着色を表す
color = [0] * N
# 二部グラフ判定dfs
def dfs(v, c):
color[v] = c
for to in G[v]:
if color[to] == c:
return False
if color[to] == 0 and not dfs(to, -c):
return False
return True
Bipartite = dfs(0, 1)
if Bipartite:
White = color.count(1)
Black = color.count(-1)
print((White * Black - M))
else:
print((N * (N - 1) // 2 - M))
| 29 | 38 | 569 | 665 | import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
G = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
G[a].append(b)
G[b].append(a)
# 0は未着色を表す
color = [0] * N
# 二部グラフ判定dfs
def dfs(v, c):
color[v] = c
for to in G[v]:
if color[to] == c:
return False
if color[to] == 0 and not dfs(to, -c):
return False
return True
print((N * (N - 1) // 2 - M if not dfs(0, 1) else color.count(1) * color.count(-1) - M))
| # 忘れないように
import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
G = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
G[a].append(b)
G[b].append(a)
# 0は未着色を表す
color = [0] * N
# 二部グラフ判定dfs
def dfs(v, c):
color[v] = c
for to in G[v]:
if color[to] == c:
return False
if color[to] == 0 and not dfs(to, -c):
return False
return True
Bipartite = dfs(0, 1)
if Bipartite:
White = color.count(1)
Black = color.count(-1)
print((White * Black - M))
else:
print((N * (N - 1) // 2 - M))
| false | 23.684211 | [
"+# 忘れないように",
"-print((N * (N - 1) // 2 - M if not dfs(0, 1) else color.count(1) * color.count(-1) - M))",
"+Bipartite = dfs(0, 1)",
"+if Bipartite:",
"+ White = color.count(1)",
"+ Black = color.count(-1)",
"+ print((White * Black - M))",
"+else:",
"+ print((N * (N - 1) // 2 - M))"
]
| false | 0.099436 | 0.03646 | 2.727226 | [
"s746875903",
"s081876384"
]
|
u604774382 | p02389 | python | s245489739 | s283183202 | 30 | 20 | 6,720 | 4,192 | Accepted | Accepted | 33.33 | #coding:utf-8
import sys
ab=sys.stdin.readline()
rect=ab.split( ' ' )
for i in range(2):
rect[i]=int( rect[i])
print(( "{} {}".format( rect[0]*rect[1], rect[0]*2+rect[1]*2) )) | import sys
a, b = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
print(( "{} {}".format( a*b, a*2+b*2 ) )) | 8 | 4 | 182 | 121 | # coding:utf-8
import sys
ab = sys.stdin.readline()
rect = ab.split(" ")
for i in range(2):
rect[i] = int(rect[i])
print(("{} {}".format(rect[0] * rect[1], rect[0] * 2 + rect[1] * 2)))
| import sys
a, b = [int(val) for val in sys.stdin.readline().split(" ")]
print(("{} {}".format(a * b, a * 2 + b * 2)))
| false | 50 | [
"-# coding:utf-8",
"-ab = sys.stdin.readline()",
"-rect = ab.split(\" \")",
"-for i in range(2):",
"- rect[i] = int(rect[i])",
"-print((\"{} {}\".format(rect[0] * rect[1], rect[0] * 2 + rect[1] * 2)))",
"+a, b = [int(val) for val in sys.stdin.readline().split(\" \")]",
"+print((\"{} {}\".format(a * b, a * 2 + b * 2)))"
]
| false | 0.037677 | 0.0391 | 0.963611 | [
"s245489739",
"s283183202"
]
|
u248670337 | p03244 | python | s574348200 | s542768237 | 120 | 87 | 24,108 | 20,572 | Accepted | Accepted | 27.5 | from collections import Counter
n=int(eval(input()))
V=list(map(int,input().split()))
E=Counter(V[::2]).most_common()
O=Counter(V[1::2]).most_common()
if E[0][0]==O[0][0]:
E2=Counter(V[1::2]).most_common()[1][1] if len(E)>1 else 0
O2=Counter(V[::2]).most_common()[1][1] if len(O)>1 else 0
print((n-E[0][1]-O[0][1] if E[0][0]!=O[0][0] else n-max(E[0][1]+E2,O[0][1]+O2))) | from collections import Counter
n=int(eval(input()))
V=list(map(int,input().split()))
E=Counter(V[::2]).most_common()+[(0,0)]
O=Counter(V[1::2]).most_common()+[(0,0)]
print((n-E[0][1]-O[0][1] if E[0][0]!=O[0][0] else n-max(E[0][1]+O[1][1],O[0][1]+E[1][1]))) | 9 | 6 | 372 | 254 | from collections import Counter
n = int(eval(input()))
V = list(map(int, input().split()))
E = Counter(V[::2]).most_common()
O = Counter(V[1::2]).most_common()
if E[0][0] == O[0][0]:
E2 = Counter(V[1::2]).most_common()[1][1] if len(E) > 1 else 0
O2 = Counter(V[::2]).most_common()[1][1] if len(O) > 1 else 0
print(
(
n - E[0][1] - O[0][1]
if E[0][0] != O[0][0]
else n - max(E[0][1] + E2, O[0][1] + O2)
)
)
| from collections import Counter
n = int(eval(input()))
V = list(map(int, input().split()))
E = Counter(V[::2]).most_common() + [(0, 0)]
O = Counter(V[1::2]).most_common() + [(0, 0)]
print(
(
n - E[0][1] - O[0][1]
if E[0][0] != O[0][0]
else n - max(E[0][1] + O[1][1], O[0][1] + E[1][1])
)
)
| false | 33.333333 | [
"-E = Counter(V[::2]).most_common()",
"-O = Counter(V[1::2]).most_common()",
"-if E[0][0] == O[0][0]:",
"- E2 = Counter(V[1::2]).most_common()[1][1] if len(E) > 1 else 0",
"- O2 = Counter(V[::2]).most_common()[1][1] if len(O) > 1 else 0",
"+E = Counter(V[::2]).most_common() + [(0, 0)]",
"+O = Counter(V[1::2]).most_common() + [(0, 0)]",
"- else n - max(E[0][1] + E2, O[0][1] + O2)",
"+ else n - max(E[0][1] + O[1][1], O[0][1] + E[1][1])"
]
| false | 0.043385 | 0.039768 | 1.090959 | [
"s574348200",
"s542768237"
]
|
u729133443 | p02937 | python | s171061961 | s737815022 | 1,986 | 1,568 | 3,856 | 3,976 | Accepted | Accepted | 21.05 | import math
import heapq
import collections
S = eval(input())
T = eval(input())
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
F1[alpha.index(S[i])] = True
for i in range(lenT):
F2[alpha.index(T[i])] = True
for i in range(26):
if not F1[i] and F2[i]:
print((-1))
exit()
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
S = S[ind+1:] + S[:ind+1]
ind = S.index(T[i])
ans += ind+1
print(ans) | import sys
import math
import bisect
import heapq
import collections
S = eval(input())
T = eval(input())
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
F1[alpha.index(S[i])] = True
for i in range(lenT):
F2[alpha.index(T[i])] = True
for i in range(26):
if not F1[i] and F2[i]:
print((-1))
sys.exit()
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
S = S[ind+1:] + S[:ind+1]
ind = S.index(T[i])
ans += ind+1
print(ans) | 28 | 30 | 523 | 554 | import math
import heapq
import collections
S = eval(input())
T = eval(input())
lenS = len(S)
lenT = len(T)
F1 = [False] * 26
F2 = [False] * 26
alpha = "abcdefghijklmnopqrstuvwxyz"
for i in range(lenS):
F1[alpha.index(S[i])] = True
for i in range(lenT):
F2[alpha.index(T[i])] = True
for i in range(26):
if not F1[i] and F2[i]:
print((-1))
exit()
ind = S.index(T[0])
ans = ind + 1
for i in range(1, lenT):
S = S[ind + 1 :] + S[: ind + 1]
ind = S.index(T[i])
ans += ind + 1
print(ans)
| import sys
import math
import bisect
import heapq
import collections
S = eval(input())
T = eval(input())
lenS = len(S)
lenT = len(T)
F1 = [False] * 26
F2 = [False] * 26
alpha = "abcdefghijklmnopqrstuvwxyz"
for i in range(lenS):
F1[alpha.index(S[i])] = True
for i in range(lenT):
F2[alpha.index(T[i])] = True
for i in range(26):
if not F1[i] and F2[i]:
print((-1))
sys.exit()
ind = S.index(T[0])
ans = ind + 1
for i in range(1, lenT):
S = S[ind + 1 :] + S[: ind + 1]
ind = S.index(T[i])
ans += ind + 1
print(ans)
| false | 6.666667 | [
"+import sys",
"+import bisect",
"- exit()",
"+ sys.exit()"
]
| false | 0.095383 | 0.118213 | 0.806879 | [
"s171061961",
"s737815022"
]
|
u620868411 | p03426 | python | s206227312 | s258851873 | 931 | 613 | 14,872 | 46,908 | Accepted | Accepted | 34.16 | # coding=utf-8
line = input().split(" ")
h = int(line[0])
w = int(line[1])
d = int(line[2])
table = [0 for _ in range(h*w+1)]
for hi in range(h):
line = list(map(int, input().split(" ")))
for wi in range(w):
table[line[wi]] = (hi+1, wi+1)
def calc(l,r):
ret = 0
if l!=r:
c1 = table[l]
c2 = table[r]
ret += abs(c1[0]-c2[0])+abs(c1[1]-c2[1])
return ret
acc = [0 for _ in range(h*w+1)]
for dd in range(1,d+1):
s = dd+d
while s<=h*w:
acc[s] = calc(s-d,s)+acc[s-d]
s += d
q = int(eval(input()))
for _ in range(q):
line = input().split(" ")
l = int(line[0])
r = int(line[1])
ret = acc[r] - acc[l]
print(ret)
| # -*- coding: utf-8 -*-
h,w,d = list(map(int, input().split()))
dd = {}
for hi in range(h):
line = list(map(int, input().split()))
for wi in range(w):
dd[line[wi]] = (hi, wi)
q = int(eval(input()))
lr = [list(map(int, input().split())) for _ in range(q)]
acc = [0]*(h*w+1)
for i in range(h*w+1):
if i<=d:
acc[i] = 0
continue
h1,w1 = dd[i]
h2,w2 = dd[i-d]
acc[i] = acc[i-d] + abs(h1-h2) + abs(w1-w2)
for (l,r) in lr:
print((acc[r] - acc[l]))
| 36 | 22 | 733 | 503 | # coding=utf-8
line = input().split(" ")
h = int(line[0])
w = int(line[1])
d = int(line[2])
table = [0 for _ in range(h * w + 1)]
for hi in range(h):
line = list(map(int, input().split(" ")))
for wi in range(w):
table[line[wi]] = (hi + 1, wi + 1)
def calc(l, r):
ret = 0
if l != r:
c1 = table[l]
c2 = table[r]
ret += abs(c1[0] - c2[0]) + abs(c1[1] - c2[1])
return ret
acc = [0 for _ in range(h * w + 1)]
for dd in range(1, d + 1):
s = dd + d
while s <= h * w:
acc[s] = calc(s - d, s) + acc[s - d]
s += d
q = int(eval(input()))
for _ in range(q):
line = input().split(" ")
l = int(line[0])
r = int(line[1])
ret = acc[r] - acc[l]
print(ret)
| # -*- coding: utf-8 -*-
h, w, d = list(map(int, input().split()))
dd = {}
for hi in range(h):
line = list(map(int, input().split()))
for wi in range(w):
dd[line[wi]] = (hi, wi)
q = int(eval(input()))
lr = [list(map(int, input().split())) for _ in range(q)]
acc = [0] * (h * w + 1)
for i in range(h * w + 1):
if i <= d:
acc[i] = 0
continue
h1, w1 = dd[i]
h2, w2 = dd[i - d]
acc[i] = acc[i - d] + abs(h1 - h2) + abs(w1 - w2)
for (l, r) in lr:
print((acc[r] - acc[l]))
| false | 38.888889 | [
"-# coding=utf-8",
"-line = input().split(\" \")",
"-h = int(line[0])",
"-w = int(line[1])",
"-d = int(line[2])",
"-table = [0 for _ in range(h * w + 1)]",
"+# -*- coding: utf-8 -*-",
"+h, w, d = list(map(int, input().split()))",
"+dd = {}",
"- line = list(map(int, input().split(\" \")))",
"+ line = list(map(int, input().split()))",
"- table[line[wi]] = (hi + 1, wi + 1)",
"-",
"-",
"-def calc(l, r):",
"- ret = 0",
"- if l != r:",
"- c1 = table[l]",
"- c2 = table[r]",
"- ret += abs(c1[0] - c2[0]) + abs(c1[1] - c2[1])",
"- return ret",
"-",
"-",
"-acc = [0 for _ in range(h * w + 1)]",
"-for dd in range(1, d + 1):",
"- s = dd + d",
"- while s <= h * w:",
"- acc[s] = calc(s - d, s) + acc[s - d]",
"- s += d",
"+ dd[line[wi]] = (hi, wi)",
"-for _ in range(q):",
"- line = input().split(\" \")",
"- l = int(line[0])",
"- r = int(line[1])",
"- ret = acc[r] - acc[l]",
"- print(ret)",
"+lr = [list(map(int, input().split())) for _ in range(q)]",
"+acc = [0] * (h * w + 1)",
"+for i in range(h * w + 1):",
"+ if i <= d:",
"+ acc[i] = 0",
"+ continue",
"+ h1, w1 = dd[i]",
"+ h2, w2 = dd[i - d]",
"+ acc[i] = acc[i - d] + abs(h1 - h2) + abs(w1 - w2)",
"+for (l, r) in lr:",
"+ print((acc[r] - acc[l]))"
]
| false | 0.045755 | 0.154534 | 0.296086 | [
"s206227312",
"s258851873"
]
|
u088552457 | p03244 | python | s686413513 | s605434838 | 125 | 114 | 26,248 | 25,860 | Accepted | Accepted | 8.8 | def main():
n = int(eval(input()))
v = input_list()
evens = []
odds = []
vs = v[:]
kind = len(set(vs))
if kind == 1:
print((n//2))
exit(0)
for i, vv in enumerate(v):
if i % 2 == 0:
evens.append(vv)
else:
odds.append(vv)
ec = collections.Counter(evens)
oc = collections.Counter(odds)
m = n//2
ans = 0
em = ec.most_common()
om = oc.most_common()
if em[0][0] == om[0][0]:
p1 = m-em[0][1] + m-om[1][1]
p2 = m-em[1][1] + m-om[0][1]
print((min(p1,p2)))
else:
print((m-em[0][1] + m-om[0][1]))
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
# 2で割り切れる回数
def divide_two(arg):
c = 0
while True:
if c >= 2:
break
if arg % 2 != 0:
break
arg //= 2
c += 1
return c
import math
import fractions
import collections
from functools import reduce
main() | import math
import fractions
from functools import reduce
def main():
n = int(eval(input()))
a = input_list()
if len(set(a)) == 1:
print((n//2))
exit(0)
evens = {}
odds = {}
for i, v in enumerate(a):
if i % 2 == 0:
if v in evens:
evens[v] += 1
else:
evens[v] = 1
else:
if v in odds:
odds[v] += 1
else:
odds[v] = 1
if len(evens) == 1 and len(odds) == 1:
print((0))
exit(0)
e = sorted(list(evens.items()), key=lambda x: x[1], reverse=True)
o = sorted(list(odds.items()), key=lambda x: x[1], reverse=True)
if e[0][0] != o[0][0]:
even_ans = (n // 2) - e[0][1]
odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[0][1]
a1 = even_ans+odd_ans
even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[0][1]
odd_ans = (n // 2) - o[0][1]
a2 = even_ans+odd_ans
print((min(a1, a2)))
else:
even_ans = (n // 2) - e[0][1]
odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[1][1]
a1 = even_ans + odd_ans
even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[1][1]
odd_ans = (n // 2) - o[0][1]
a2 = even_ans + odd_ans
print((min(a1, a2)))
# 6
# 3 1 3 2 4 2
def input_list():
return list(map(int, input().split()))
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
if __name__ == "__main__":
main()
| 65 | 69 | 1,232 | 1,756 | def main():
n = int(eval(input()))
v = input_list()
evens = []
odds = []
vs = v[:]
kind = len(set(vs))
if kind == 1:
print((n // 2))
exit(0)
for i, vv in enumerate(v):
if i % 2 == 0:
evens.append(vv)
else:
odds.append(vv)
ec = collections.Counter(evens)
oc = collections.Counter(odds)
m = n // 2
ans = 0
em = ec.most_common()
om = oc.most_common()
if em[0][0] == om[0][0]:
p1 = m - em[0][1] + m - om[1][1]
p2 = m - em[1][1] + m - om[0][1]
print((min(p1, p2)))
else:
print((m - em[0][1] + m - om[0][1]))
def input_list():
return list(map(int, input().split()))
def input_list_str():
return list(map(str, input().split()))
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
# 2で割り切れる回数
def divide_two(arg):
c = 0
while True:
if c >= 2:
break
if arg % 2 != 0:
break
arg //= 2
c += 1
return c
import math
import fractions
import collections
from functools import reduce
main()
| import math
import fractions
from functools import reduce
def main():
n = int(eval(input()))
a = input_list()
if len(set(a)) == 1:
print((n // 2))
exit(0)
evens = {}
odds = {}
for i, v in enumerate(a):
if i % 2 == 0:
if v in evens:
evens[v] += 1
else:
evens[v] = 1
else:
if v in odds:
odds[v] += 1
else:
odds[v] = 1
if len(evens) == 1 and len(odds) == 1:
print((0))
exit(0)
e = sorted(list(evens.items()), key=lambda x: x[1], reverse=True)
o = sorted(list(odds.items()), key=lambda x: x[1], reverse=True)
if e[0][0] != o[0][0]:
even_ans = (n // 2) - e[0][1]
odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[0][1]
a1 = even_ans + odd_ans
even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[0][1]
odd_ans = (n // 2) - o[0][1]
a2 = even_ans + odd_ans
print((min(a1, a2)))
else:
even_ans = (n // 2) - e[0][1]
odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[1][1]
a1 = even_ans + odd_ans
even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[1][1]
odd_ans = (n // 2) - o[0][1]
a2 = even_ans + odd_ans
print((min(a1, a2)))
# 6
# 3 1 3 2 4 2
def input_list():
return list(map(int, input().split()))
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
if __name__ == "__main__":
main()
| false | 5.797101 | [
"+import math",
"+import fractions",
"+from functools import reduce",
"+",
"+",
"- v = input_list()",
"- evens = []",
"- odds = []",
"- vs = v[:]",
"- kind = len(set(vs))",
"- if kind == 1:",
"+ a = input_list()",
"+ if len(set(a)) == 1:",
"- for i, vv in enumerate(v):",
"+ evens = {}",
"+ odds = {}",
"+ for i, v in enumerate(a):",
"- evens.append(vv)",
"+ if v in evens:",
"+ evens[v] += 1",
"+ else:",
"+ evens[v] = 1",
"- odds.append(vv)",
"- ec = collections.Counter(evens)",
"- oc = collections.Counter(odds)",
"- m = n // 2",
"- ans = 0",
"- em = ec.most_common()",
"- om = oc.most_common()",
"- if em[0][0] == om[0][0]:",
"- p1 = m - em[0][1] + m - om[1][1]",
"- p2 = m - em[1][1] + m - om[0][1]",
"- print((min(p1, p2)))",
"+ if v in odds:",
"+ odds[v] += 1",
"+ else:",
"+ odds[v] = 1",
"+ if len(evens) == 1 and len(odds) == 1:",
"+ print((0))",
"+ exit(0)",
"+ e = sorted(list(evens.items()), key=lambda x: x[1], reverse=True)",
"+ o = sorted(list(odds.items()), key=lambda x: x[1], reverse=True)",
"+ if e[0][0] != o[0][0]:",
"+ even_ans = (n // 2) - e[0][1]",
"+ odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[0][1]",
"+ a1 = even_ans + odd_ans",
"+ even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[0][1]",
"+ odd_ans = (n // 2) - o[0][1]",
"+ a2 = even_ans + odd_ans",
"+ print((min(a1, a2)))",
"- print((m - em[0][1] + m - om[0][1]))",
"+ even_ans = (n // 2) - e[0][1]",
"+ odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[1][1]",
"+ a1 = even_ans + odd_ans",
"+ even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[1][1]",
"+ odd_ans = (n // 2) - o[0][1]",
"+ a2 = even_ans + odd_ans",
"+ print((min(a1, a2)))",
"+# 6",
"+# 3 1 3 2 4 2",
"-",
"-",
"-def input_list_str():",
"- return list(map(str, input().split()))",
"-# 2で割り切れる回数",
"-def divide_two(arg):",
"- c = 0",
"- while True:",
"- if c >= 2:",
"- break",
"- if arg % 2 != 0:",
"- break",
"- arg //= 2",
"- c += 1",
"- return c",
"-",
"-",
"-import math",
"-import fractions",
"-import collections",
"-from functools import reduce",
"-",
"-main()",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.048142 | 0.045354 | 1.061462 | [
"s686413513",
"s605434838"
]
|
u319410662 | p03659 | python | s362468526 | s529891714 | 255 | 174 | 27,440 | 18,416 | Accepted | Accepted | 31.76 | N, = list(map(int, input().split()))
a = list(map(int, input().split()))
sl = [0]*N
sl[0] = a[0]
for i in range(N-1):
sl[i+1] = sl[i]+a[i+1]
sr = [0]*N
sr[N-1] = a[N-1]
for i in range(N-1,0,-1):
sr[i-1] = sr[i]+a[i-1]
r = abs(sl[0]-sr[1])
for i in range(1, N-1):
r = min(r, abs(sl[i]-sr[i+1]))
print(r) | N, = list(map(int, input().split()))
a = list(map(int, input().split()))
x = a[0]
y = sum(a) - a[0]
r = abs(x-y)
for ai in a[1:N-1]:
x += ai
y -= ai
r = min(r, abs(x-y))
print(r) | 14 | 10 | 316 | 188 | (N,) = list(map(int, input().split()))
a = list(map(int, input().split()))
sl = [0] * N
sl[0] = a[0]
for i in range(N - 1):
sl[i + 1] = sl[i] + a[i + 1]
sr = [0] * N
sr[N - 1] = a[N - 1]
for i in range(N - 1, 0, -1):
sr[i - 1] = sr[i] + a[i - 1]
r = abs(sl[0] - sr[1])
for i in range(1, N - 1):
r = min(r, abs(sl[i] - sr[i + 1]))
print(r)
| (N,) = list(map(int, input().split()))
a = list(map(int, input().split()))
x = a[0]
y = sum(a) - a[0]
r = abs(x - y)
for ai in a[1 : N - 1]:
x += ai
y -= ai
r = min(r, abs(x - y))
print(r)
| false | 28.571429 | [
"-sl = [0] * N",
"-sl[0] = a[0]",
"-for i in range(N - 1):",
"- sl[i + 1] = sl[i] + a[i + 1]",
"-sr = [0] * N",
"-sr[N - 1] = a[N - 1]",
"-for i in range(N - 1, 0, -1):",
"- sr[i - 1] = sr[i] + a[i - 1]",
"-r = abs(sl[0] - sr[1])",
"-for i in range(1, N - 1):",
"- r = min(r, abs(sl[i] - sr[i + 1]))",
"+x = a[0]",
"+y = sum(a) - a[0]",
"+r = abs(x - y)",
"+for ai in a[1 : N - 1]:",
"+ x += ai",
"+ y -= ai",
"+ r = min(r, abs(x - y))"
]
| false | 0.035128 | 0.036483 | 0.962856 | [
"s362468526",
"s529891714"
]
|
u350997995 | p03497 | python | s445177946 | s884885880 | 173 | 160 | 39,344 | 39,344 | Accepted | Accepted | 7.51 | import collections
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
c = collections.Counter(A).most_common()[::-1]
k = len(c)
if k<=K:print((0))
else: print((sum([e[1] for e in c[:k-K]]))) | from collections import Counter
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
C = Counter(A).most_common()
if len(C)<=K:
print((0))
else:
ans = 0
for c in C[:K]:
ans+=c[1]
print((N-ans)) | 7 | 11 | 207 | 236 | import collections
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = collections.Counter(A).most_common()[::-1]
k = len(c)
if k <= K:
print((0))
else:
print((sum([e[1] for e in c[: k - K]])))
| from collections import Counter
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
C = Counter(A).most_common()
if len(C) <= K:
print((0))
else:
ans = 0
for c in C[:K]:
ans += c[1]
print((N - ans))
| false | 36.363636 | [
"-import collections",
"+from collections import Counter",
"-c = collections.Counter(A).most_common()[::-1]",
"-k = len(c)",
"-if k <= K:",
"+C = Counter(A).most_common()",
"+if len(C) <= K:",
"- print((sum([e[1] for e in c[: k - K]])))",
"+ ans = 0",
"+ for c in C[:K]:",
"+ ans += c[1]",
"+ print((N - ans))"
]
| false | 0.153897 | 0.044427 | 3.464025 | [
"s445177946",
"s884885880"
]
|
u624475441 | p03296 | python | s361461470 | s189560979 | 28 | 17 | 2,940 | 2,940 | Accepted | Accepted | 39.29 | eval(input())
cnt=0
now=0
res=0
for a in map(int,input().split()):
if a==now:
cnt+=1
else:
res+=cnt//2
cnt=1
now=a
print((res+cnt//2)) | eval(input())
ans=x=0
for a in input().split():
ans+=a==x
x=a*(a!=x)
print(ans) | 12 | 6 | 173 | 86 | eval(input())
cnt = 0
now = 0
res = 0
for a in map(int, input().split()):
if a == now:
cnt += 1
else:
res += cnt // 2
cnt = 1
now = a
print((res + cnt // 2))
| eval(input())
ans = x = 0
for a in input().split():
ans += a == x
x = a * (a != x)
print(ans)
| false | 50 | [
"-cnt = 0",
"-now = 0",
"-res = 0",
"-for a in map(int, input().split()):",
"- if a == now:",
"- cnt += 1",
"- else:",
"- res += cnt // 2",
"- cnt = 1",
"- now = a",
"-print((res + cnt // 2))",
"+ans = x = 0",
"+for a in input().split():",
"+ ans += a == x",
"+ x = a * (a != x)",
"+print(ans)"
]
| false | 0.045701 | 0.045445 | 1.005635 | [
"s361461470",
"s189560979"
]
|
u289288647 | p02608 | python | s076543401 | s536208959 | 504 | 432 | 9,264 | 9,100 | Accepted | Accepted | 14.29 | n = int(eval(input()))
ans = [0 for _ in range(10050)]
for i in range(1, 105):
for j in range(1, 105):
for k in range(1, 105):
v = i*i+j*j+k*k+i*j+j*k+k*i;
if v < 10050:
ans[v] += 1
for i in range(n):
print((ans[i+1]))
| n = int(eval(input()))
ans = [0 for _ in range(10050)]
for i in range(1, 101):
for j in range(1, 101):
for k in range(1, 101):
v = i*i+j*j+k*k+i*j+j*k+k*i;
if v < 10050:
ans[v] += 1
for i in range(n):
print((ans[i+1]))
| 10 | 10 | 276 | 276 | n = int(eval(input()))
ans = [0 for _ in range(10050)]
for i in range(1, 105):
for j in range(1, 105):
for k in range(1, 105):
v = i * i + j * j + k * k + i * j + j * k + k * i
if v < 10050:
ans[v] += 1
for i in range(n):
print((ans[i + 1]))
| n = int(eval(input()))
ans = [0 for _ in range(10050)]
for i in range(1, 101):
for j in range(1, 101):
for k in range(1, 101):
v = i * i + j * j + k * k + i * j + j * k + k * i
if v < 10050:
ans[v] += 1
for i in range(n):
print((ans[i + 1]))
| false | 0 | [
"-for i in range(1, 105):",
"- for j in range(1, 105):",
"- for k in range(1, 105):",
"+for i in range(1, 101):",
"+ for j in range(1, 101):",
"+ for k in range(1, 101):"
]
| false | 3.966947 | 1.260174 | 3.147936 | [
"s076543401",
"s536208959"
]
|
u263830634 | p03252 | python | s236345121 | s166998002 | 149 | 47 | 6,704 | 6,832 | Accepted | Accepted | 68.46 | import sys
S = list(eval(input()))
T = list(eval(input()))
#print (S)
dic1 = dict()
dic2 = dict()
for i in range(len(S)):
if not S[i] in list(dic1.keys()):
dic1[S[i]] = 1
else:
dic1[S[i]] += 1
if not T[i] in list(dic2.keys()):
dic2[T[i]] = 1
else:
dic2[T[i]] += 1
#print(dic1)
dic1 = sorted(list(dic1.items()), key = lambda x:x[1])
dic2 = sorted(list(dic2.items()), key = lambda x:x[1])
for j in range(len(dic1)):
if not dic1[j][1] == dic2[j][1]:
print ('No')
sys.exit()
print ('Yes') | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
from collections import Counter
S = list(eval(input()))
T = list(eval(input()))
SC = Counter(S)
TC = Counter(T)
lstS = []
for s in SC:
lstS.append(SC[s])
lstT = []
for t in TC:
lstT.append(TC[t])
lstS.sort()
lstT.sort()
if lstS == lstT:
print ('Yes')
else:
print ('No') | 26 | 28 | 544 | 394 | import sys
S = list(eval(input()))
T = list(eval(input()))
# print (S)
dic1 = dict()
dic2 = dict()
for i in range(len(S)):
if not S[i] in list(dic1.keys()):
dic1[S[i]] = 1
else:
dic1[S[i]] += 1
if not T[i] in list(dic2.keys()):
dic2[T[i]] = 1
else:
dic2[T[i]] += 1
# print(dic1)
dic1 = sorted(list(dic1.items()), key=lambda x: x[1])
dic2 = sorted(list(dic2.items()), key=lambda x: x[1])
for j in range(len(dic1)):
if not dic1[j][1] == dic2[j][1]:
print("No")
sys.exit()
print("Yes")
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9 + 7
from collections import Counter
S = list(eval(input()))
T = list(eval(input()))
SC = Counter(S)
TC = Counter(T)
lstS = []
for s in SC:
lstS.append(SC[s])
lstT = []
for t in TC:
lstT.append(TC[t])
lstS.sort()
lstT.sort()
if lstS == lstT:
print("Yes")
else:
print("No")
| false | 7.142857 | [
"+",
"+input = sys.stdin.readline",
"+sys.setrecursionlimit(10**9)",
"+MOD = 10**9 + 7",
"+from collections import Counter",
"-# print (S)",
"-dic1 = dict()",
"-dic2 = dict()",
"-for i in range(len(S)):",
"- if not S[i] in list(dic1.keys()):",
"- dic1[S[i]] = 1",
"- else:",
"- dic1[S[i]] += 1",
"- if not T[i] in list(dic2.keys()):",
"- dic2[T[i]] = 1",
"- else:",
"- dic2[T[i]] += 1",
"-# print(dic1)",
"-dic1 = sorted(list(dic1.items()), key=lambda x: x[1])",
"-dic2 = sorted(list(dic2.items()), key=lambda x: x[1])",
"-for j in range(len(dic1)):",
"- if not dic1[j][1] == dic2[j][1]:",
"- print(\"No\")",
"- sys.exit()",
"-print(\"Yes\")",
"+SC = Counter(S)",
"+TC = Counter(T)",
"+lstS = []",
"+for s in SC:",
"+ lstS.append(SC[s])",
"+lstT = []",
"+for t in TC:",
"+ lstT.append(TC[t])",
"+lstS.sort()",
"+lstT.sort()",
"+if lstS == lstT:",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"
]
| false | 0.035801 | 0.034937 | 1.02473 | [
"s236345121",
"s166998002"
]
|
u896741788 | p02579 | python | s727807808 | s966975479 | 1,917 | 555 | 151,740 | 99,356 | Accepted | Accepted | 71.05 | import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h,w=list(map(int,input().split()))
nx,ny=list(map(int,input().split()))
gx,gy=list(map(int,input().split()))
maze=[eval(input())for i in range(h)]
from heapq import heapify, heappop, heappush
seen=set()
gx-=1;gy-=1
SIZE=h*w
hq=[(nx-1)*w+ny-1]
while hq:
d=heappop(hq)
c,d=divmod(d,SIZE)
x,y=divmod(d,w)
if w*x +y in seen:continue
seen.add(w*x +y)
if x==gx and y==gy:print(c);exit()
if x and w*(x-1)+y not in seen and maze[x-1 ][y]!=35:
heappush(hq,(c*SIZE+w*(x-1)+y))
if y and w*x+y-1 not in seen and maze[x][y-1]!=35:
heappush(hq,(c*SIZE+w*x+y-1))
if x+1<h and w*(x+1)+y not in seen and maze[x+1][y]!=35:
heappush(hq,(c*SIZE+w*(x+1)+y))
if y+1<w and w*x+y+1 not in seen and maze[x][y+1]!=35:
heappush(hq,(c*SIZE+w*x+y+1))
for i in range(max(0,x-2),min(h,x+3)):
for j in range(max(0,y-2),min(w,y+3)):
if i==x and j==y:continue
if maze[i][j]==46 and w*i + j not in seen:
heappush(hq,(c+1)*SIZE+w*i+j)
print((-1))
| import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h,w=list(map(int,input().split()))
nx,ny=list(map(int,input().split()))
gx,gy=list(map(int,input().split()))
maze=[eval(input())for i in range(h)]
#. 46 # 35
nx-=1;ny-=1;gx-=1;gy-=1
from collections import deque
dq=deque([(nx,ny)])
dq2=deque([])
T=[[float('inf')]*w for a in range(h)]
T[nx][ny]=0
moves=((1,0),(-1,0),(0,1),(0,-1))
from itertools import product as pr
Mmoves=tuple(i for i in pr((-2,-1,0,1,2),repeat=2)if i!=(0,0) )
while dq:
while dq:
x,y=dq.popleft()
for i,j in moves:
nex,ney=x+i,y+j
if not(0<=nex<h and 0<=ney<w) or maze[nex][ney]==35:continue
if T[x][y]<T[nex][ney]:
T[nex][ney]=T[x][y]
dq.append((nex,ney))
for i,j in Mmoves:
nex,ney=x+i,y+j
if not(0<=nex<h and 0<=ney<w) or maze[nex][ney]==35:continue
if T[x][y]+1<T[nex][ney]:
T[nex][ney]=T[x][y]+1
dq2.append((nex,ney))
dq,dq2=dq2,dq
if T[gx][gy]==float('inf'):print((-1))
else:print((T[gx][gy])) | 35 | 37 | 1,152 | 1,154 | import sys
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h, w = list(map(int, input().split()))
nx, ny = list(map(int, input().split()))
gx, gy = list(map(int, input().split()))
maze = [eval(input()) for i in range(h)]
from heapq import heapify, heappop, heappush
seen = set()
gx -= 1
gy -= 1
SIZE = h * w
hq = [(nx - 1) * w + ny - 1]
while hq:
d = heappop(hq)
c, d = divmod(d, SIZE)
x, y = divmod(d, w)
if w * x + y in seen:
continue
seen.add(w * x + y)
if x == gx and y == gy:
print(c)
exit()
if x and w * (x - 1) + y not in seen and maze[x - 1][y] != 35:
heappush(hq, (c * SIZE + w * (x - 1) + y))
if y and w * x + y - 1 not in seen and maze[x][y - 1] != 35:
heappush(hq, (c * SIZE + w * x + y - 1))
if x + 1 < h and w * (x + 1) + y not in seen and maze[x + 1][y] != 35:
heappush(hq, (c * SIZE + w * (x + 1) + y))
if y + 1 < w and w * x + y + 1 not in seen and maze[x][y + 1] != 35:
heappush(hq, (c * SIZE + w * x + y + 1))
for i in range(max(0, x - 2), min(h, x + 3)):
for j in range(max(0, y - 2), min(w, y + 3)):
if i == x and j == y:
continue
if maze[i][j] == 46 and w * i + j not in seen:
heappush(hq, (c + 1) * SIZE + w * i + j)
print((-1))
| import sys
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h, w = list(map(int, input().split()))
nx, ny = list(map(int, input().split()))
gx, gy = list(map(int, input().split()))
maze = [eval(input()) for i in range(h)]
# . 46 # 35
nx -= 1
ny -= 1
gx -= 1
gy -= 1
from collections import deque
dq = deque([(nx, ny)])
dq2 = deque([])
T = [[float("inf")] * w for a in range(h)]
T[nx][ny] = 0
moves = ((1, 0), (-1, 0), (0, 1), (0, -1))
from itertools import product as pr
Mmoves = tuple(i for i in pr((-2, -1, 0, 1, 2), repeat=2) if i != (0, 0))
while dq:
while dq:
x, y = dq.popleft()
for i, j in moves:
nex, ney = x + i, y + j
if not (0 <= nex < h and 0 <= ney < w) or maze[nex][ney] == 35:
continue
if T[x][y] < T[nex][ney]:
T[nex][ney] = T[x][y]
dq.append((nex, ney))
for i, j in Mmoves:
nex, ney = x + i, y + j
if not (0 <= nex < h and 0 <= ney < w) or maze[nex][ney] == 35:
continue
if T[x][y] + 1 < T[nex][ney]:
T[nex][ney] = T[x][y] + 1
dq2.append((nex, ney))
dq, dq2 = dq2, dq
if T[gx][gy] == float("inf"):
print((-1))
else:
print((T[gx][gy]))
| false | 5.405405 | [
"-from heapq import heapify, heappop, heappush",
"-",
"-seen = set()",
"+# . 46 # 35",
"+nx -= 1",
"+ny -= 1",
"-SIZE = h * w",
"-hq = [(nx - 1) * w + ny - 1]",
"-while hq:",
"- d = heappop(hq)",
"- c, d = divmod(d, SIZE)",
"- x, y = divmod(d, w)",
"- if w * x + y in seen:",
"- continue",
"- seen.add(w * x + y)",
"- if x == gx and y == gy:",
"- print(c)",
"- exit()",
"- if x and w * (x - 1) + y not in seen and maze[x - 1][y] != 35:",
"- heappush(hq, (c * SIZE + w * (x - 1) + y))",
"- if y and w * x + y - 1 not in seen and maze[x][y - 1] != 35:",
"- heappush(hq, (c * SIZE + w * x + y - 1))",
"- if x + 1 < h and w * (x + 1) + y not in seen and maze[x + 1][y] != 35:",
"- heappush(hq, (c * SIZE + w * (x + 1) + y))",
"- if y + 1 < w and w * x + y + 1 not in seen and maze[x][y + 1] != 35:",
"- heappush(hq, (c * SIZE + w * x + y + 1))",
"- for i in range(max(0, x - 2), min(h, x + 3)):",
"- for j in range(max(0, y - 2), min(w, y + 3)):",
"- if i == x and j == y:",
"+from collections import deque",
"+",
"+dq = deque([(nx, ny)])",
"+dq2 = deque([])",
"+T = [[float(\"inf\")] * w for a in range(h)]",
"+T[nx][ny] = 0",
"+moves = ((1, 0), (-1, 0), (0, 1), (0, -1))",
"+from itertools import product as pr",
"+",
"+Mmoves = tuple(i for i in pr((-2, -1, 0, 1, 2), repeat=2) if i != (0, 0))",
"+while dq:",
"+ while dq:",
"+ x, y = dq.popleft()",
"+ for i, j in moves:",
"+ nex, ney = x + i, y + j",
"+ if not (0 <= nex < h and 0 <= ney < w) or maze[nex][ney] == 35:",
"- if maze[i][j] == 46 and w * i + j not in seen:",
"- heappush(hq, (c + 1) * SIZE + w * i + j)",
"-print((-1))",
"+ if T[x][y] < T[nex][ney]:",
"+ T[nex][ney] = T[x][y]",
"+ dq.append((nex, ney))",
"+ for i, j in Mmoves:",
"+ nex, ney = x + i, y + j",
"+ if not (0 <= nex < h and 0 <= ney < w) or maze[nex][ney] == 35:",
"+ continue",
"+ if T[x][y] + 1 < T[nex][ney]:",
"+ T[nex][ney] = T[x][y] + 1",
"+ dq2.append((nex, ney))",
"+ dq, dq2 = dq2, dq",
"+if T[gx][gy] == float(\"inf\"):",
"+ print((-1))",
"+else:",
"+ print((T[gx][gy]))"
]
| false | 0.035863 | 0.057995 | 0.618373 | [
"s727807808",
"s966975479"
]
|
u729133443 | p03331 | python | s401833139 | s633042727 | 312 | 17 | 3,848 | 2,940 | Accepted | Accepted | 94.55 | n=int(eval(input()));print((min([sum(list(map(int,str(i)))+list(map(int,str(n-i))))for i in range(1, n)]))) | a=sum(int(i)for i in eval(input()));print((a if a!=1else 10)) | 1 | 1 | 99 | 53 | n = int(eval(input()))
print(
(
min(
[
sum(list(map(int, str(i))) + list(map(int, str(n - i))))
for i in range(1, n)
]
)
)
)
| a = sum(int(i) for i in eval(input()))
print((a if a != 1 else 10))
| false | 0 | [
"-n = int(eval(input()))",
"-print(",
"- (",
"- min(",
"- [",
"- sum(list(map(int, str(i))) + list(map(int, str(n - i))))",
"- for i in range(1, n)",
"- ]",
"- )",
"- )",
"-)",
"+a = sum(int(i) for i in eval(input()))",
"+print((a if a != 1 else 10))"
]
| false | 0.132092 | 0.036741 | 3.59519 | [
"s401833139",
"s633042727"
]
|
u853185302 | p02897 | python | s696451574 | s854421849 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | N = int(eval(input()))
print(((N//2)/N if N%2 == 0 else ((N+1)//2)/N)) | n = int(eval(input()))
print((-(-n//2)/n)) | 2 | 2 | 63 | 35 | N = int(eval(input()))
print(((N // 2) / N if N % 2 == 0 else ((N + 1) // 2) / N))
| n = int(eval(input()))
print((-(-n // 2) / n))
| false | 0 | [
"-N = int(eval(input()))",
"-print(((N // 2) / N if N % 2 == 0 else ((N + 1) // 2) / N))",
"+n = int(eval(input()))",
"+print((-(-n // 2) / n))"
]
| false | 0.042158 | 0.073314 | 0.575037 | [
"s696451574",
"s854421849"
]
|
u210440747 | p03295 | python | s418645657 | s722960559 | 821 | 522 | 29,324 | 28,572 | Accepted | Accepted | 36.42 | #!/usr/bin/python3
# -*- coding:utf-8 -*-
import numpy
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
db2a = defaultdict(list)
for _ in range(m):
a, b = list(map(int, input().split()))
db2a[b-1].append(a-1)
cnts = numpy.zeros(n, dtype=numpy.int)
i = 0
for b in sorted(db2a.keys()):
cnts[i:b] = cnts[i-1]
cnts[b] = max(cnts[max(db2a[b])] + 1, cnts[b-1])
i = b + 1
cnts[i:] = cnts[i-1]
print((cnts[-1]))
if __name__=='__main__':
main()
| #!/usr/bin/python3
# -*- coding:utf-8 -*-
import numpy
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
db2a = defaultdict(list)
for _ in range(m):
a, b = list(map(int, input().split()))
db2a[b-1].append(a-1)
cnt = 0
end = 0
for b in sorted(db2a.keys()):
if end <= max(db2a[b]):
cnt += 1
end = b
print(cnt)
if __name__=='__main__':
main()
| 25 | 24 | 531 | 437 | #!/usr/bin/python3
# -*- coding:utf-8 -*-
import numpy
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
db2a = defaultdict(list)
for _ in range(m):
a, b = list(map(int, input().split()))
db2a[b - 1].append(a - 1)
cnts = numpy.zeros(n, dtype=numpy.int)
i = 0
for b in sorted(db2a.keys()):
cnts[i:b] = cnts[i - 1]
cnts[b] = max(cnts[max(db2a[b])] + 1, cnts[b - 1])
i = b + 1
cnts[i:] = cnts[i - 1]
print((cnts[-1]))
if __name__ == "__main__":
main()
| #!/usr/bin/python3
# -*- coding:utf-8 -*-
import numpy
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
db2a = defaultdict(list)
for _ in range(m):
a, b = list(map(int, input().split()))
db2a[b - 1].append(a - 1)
cnt = 0
end = 0
for b in sorted(db2a.keys()):
if end <= max(db2a[b]):
cnt += 1
end = b
print(cnt)
if __name__ == "__main__":
main()
| false | 4 | [
"- cnts = numpy.zeros(n, dtype=numpy.int)",
"- i = 0",
"+ cnt = 0",
"+ end = 0",
"- cnts[i:b] = cnts[i - 1]",
"- cnts[b] = max(cnts[max(db2a[b])] + 1, cnts[b - 1])",
"- i = b + 1",
"- cnts[i:] = cnts[i - 1]",
"- print((cnts[-1]))",
"+ if end <= max(db2a[b]):",
"+ cnt += 1",
"+ end = b",
"+ print(cnt)"
]
| false | 0.207123 | 0.062339 | 3.322554 | [
"s418645657",
"s722960559"
]
|
u852690916 | p02937 | python | s608797956 | s854184768 | 245 | 107 | 47,368 | 78,560 | Accepted | Accepted | 56.33 | import sys
import bisect
def main():
input = sys.stdin.readline
s = input().rstrip()
t = input().rstrip()
letters = set(t)
indices = dict()
for l in letters:
lst = []
left = 0
while left < len(s):
i = s.find(l, left)
if i < 0: break
lst.append(i)
left = i+1
if not lst:
print((-1))
exit()
indices[l] = lst
offset = 0
cycle = 0
for l in t:
ind = indices[l]
i = bisect.bisect_left(ind, offset)
if i < len(ind):
offset = ind[i] + 1
else:
offset = ind[0] + 1
cycle += 1
if offset >= len(s):
offset %= len(s)
cycle += 1
print((len(s)*cycle + offset))
if __name__ == '__main__':
main() | # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from bisect import bisect_left
from collections import defaultdict
import sys
def main(S, T):
D = defaultdict(list)
for i, s in enumerate(S):
D[s].append(i + 1)
cycle = 0
idx = 0
N = len(S)
for t in T:
if not D[t]:
return -1
i = bisect_left(D[t], idx + 1)
if i >= len(D[t]):
cycle += 1
idx = D[t][0]
else:
idx = D[t][i]
return cycle * N + idx
if __name__ == '__main__':
input = sys.stdin.readline
s = input().rstrip()
t = input().rstrip()
ans = main(s, t)
print(ans)
| 40 | 28 | 878 | 678 | import sys
import bisect
def main():
input = sys.stdin.readline
s = input().rstrip()
t = input().rstrip()
letters = set(t)
indices = dict()
for l in letters:
lst = []
left = 0
while left < len(s):
i = s.find(l, left)
if i < 0:
break
lst.append(i)
left = i + 1
if not lst:
print((-1))
exit()
indices[l] = lst
offset = 0
cycle = 0
for l in t:
ind = indices[l]
i = bisect.bisect_left(ind, offset)
if i < len(ind):
offset = ind[i] + 1
else:
offset = ind[0] + 1
cycle += 1
if offset >= len(s):
offset %= len(s)
cycle += 1
print((len(s) * cycle + offset))
if __name__ == "__main__":
main()
| # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from bisect import bisect_left
from collections import defaultdict
import sys
def main(S, T):
D = defaultdict(list)
for i, s in enumerate(S):
D[s].append(i + 1)
cycle = 0
idx = 0
N = len(S)
for t in T:
if not D[t]:
return -1
i = bisect_left(D[t], idx + 1)
if i >= len(D[t]):
cycle += 1
idx = D[t][0]
else:
idx = D[t][i]
return cycle * N + idx
if __name__ == "__main__":
input = sys.stdin.readline
s = input().rstrip()
t = input().rstrip()
ans = main(s, t)
print(ans)
| false | 30 | [
"+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)",
"+from bisect import bisect_left",
"+from collections import defaultdict",
"-import bisect",
"-def main():",
"+def main(S, T):",
"+ D = defaultdict(list)",
"+ for i, s in enumerate(S):",
"+ D[s].append(i + 1)",
"+ cycle = 0",
"+ idx = 0",
"+ N = len(S)",
"+ for t in T:",
"+ if not D[t]:",
"+ return -1",
"+ i = bisect_left(D[t], idx + 1)",
"+ if i >= len(D[t]):",
"+ cycle += 1",
"+ idx = D[t][0]",
"+ else:",
"+ idx = D[t][i]",
"+ return cycle * N + idx",
"+",
"+",
"+if __name__ == \"__main__\":",
"- letters = set(t)",
"- indices = dict()",
"- for l in letters:",
"- lst = []",
"- left = 0",
"- while left < len(s):",
"- i = s.find(l, left)",
"- if i < 0:",
"- break",
"- lst.append(i)",
"- left = i + 1",
"- if not lst:",
"- print((-1))",
"- exit()",
"- indices[l] = lst",
"- offset = 0",
"- cycle = 0",
"- for l in t:",
"- ind = indices[l]",
"- i = bisect.bisect_left(ind, offset)",
"- if i < len(ind):",
"- offset = ind[i] + 1",
"- else:",
"- offset = ind[0] + 1",
"- cycle += 1",
"- if offset >= len(s):",
"- offset %= len(s)",
"- cycle += 1",
"- print((len(s) * cycle + offset))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+ ans = main(s, t)",
"+ print(ans)"
]
| false | 0.034767 | 0.036956 | 0.940755 | [
"s608797956",
"s854184768"
]
|
u401686269 | p03163 | python | s885537986 | s771992778 | 687 | 322 | 169,164 | 150,540 | Accepted | Accepted | 53.13 | N, W = list(map(int, input().split()))
wv = [[0 for i in range(2)] for j in range(N)]
dp = [[0 for i in range(N+1)] for j in range(W+1)]
for i in range(N):
wv[i] = list(map(int, input().split()))
for i in range(N):
for w in range(1,W+1):
if w < wv[i][0]:
dp[w][i+1] = dp[w][i]
else:
dp[w][i+1] = max(dp[w-wv[i][0]][i]+wv[i][1], dp[w][i])
print((dp[-1][-1]))
| N,W=list(map(int,input().split()))
wv = [tuple(map(int,input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1,N+1):
for j in range(1, W+1):
if j >= wv[i-1][0]:
dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
else:
dp[i][j] = dp[i-1][j]
print((dp[-1][-1])) | 15 | 13 | 391 | 339 | N, W = list(map(int, input().split()))
wv = [[0 for i in range(2)] for j in range(N)]
dp = [[0 for i in range(N + 1)] for j in range(W + 1)]
for i in range(N):
wv[i] = list(map(int, input().split()))
for i in range(N):
for w in range(1, W + 1):
if w < wv[i][0]:
dp[w][i + 1] = dp[w][i]
else:
dp[w][i + 1] = max(dp[w - wv[i][0]][i] + wv[i][1], dp[w][i])
print((dp[-1][-1]))
| N, W = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
for j in range(1, W + 1):
if j >= wv[i - 1][0]:
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wv[i - 1][0]] + wv[i - 1][1])
else:
dp[i][j] = dp[i - 1][j]
print((dp[-1][-1]))
| false | 13.333333 | [
"-wv = [[0 for i in range(2)] for j in range(N)]",
"-dp = [[0 for i in range(N + 1)] for j in range(W + 1)]",
"-for i in range(N):",
"- wv[i] = list(map(int, input().split()))",
"-for i in range(N):",
"- for w in range(1, W + 1):",
"- if w < wv[i][0]:",
"- dp[w][i + 1] = dp[w][i]",
"+wv = [tuple(map(int, input().split())) for _ in range(N)]",
"+dp = [[0] * (W + 1) for _ in range(N + 1)]",
"+for i in range(1, N + 1):",
"+ for j in range(1, W + 1):",
"+ if j >= wv[i - 1][0]:",
"+ dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wv[i - 1][0]] + wv[i - 1][1])",
"- dp[w][i + 1] = max(dp[w - wv[i][0]][i] + wv[i][1], dp[w][i])",
"+ dp[i][j] = dp[i - 1][j]"
]
| false | 0.047337 | 0.047786 | 0.990609 | [
"s885537986",
"s771992778"
]
|
u054825571 | p02924 | python | s604884871 | s019913816 | 120 | 29 | 61,608 | 9,164 | Accepted | Accepted | 75.83 | N=int(eval(input()))
print((N*(N-1)//2)) | n=int(eval(input()))
print((n*(n-1)//2)) | 2 | 2 | 33 | 33 | N = int(eval(input()))
print((N * (N - 1) // 2))
| n = int(eval(input()))
print((n * (n - 1) // 2))
| false | 0 | [
"-N = int(eval(input()))",
"-print((N * (N - 1) // 2))",
"+n = int(eval(input()))",
"+print((n * (n - 1) // 2))"
]
| false | 0.041204 | 0.046594 | 0.884333 | [
"s604884871",
"s019913816"
]
|
u922449550 | p02689 | python | s296493910 | s158761691 | 426 | 388 | 30,628 | 29,420 | Accepted | Accepted | 8.92 | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
d = [[0, -1]]
ans = 0
is_visit = [False] * N
def search(node):
global is_visit
global ans
d = [node]
while d:
node = d.pop()
h = H[node]
children = g[node]
res = True
for child in children:
_h = H[child]
res *= h > _h
if not is_visit[child]:
is_visit[child] = True
d.append(child)
ans += res
for i in range(N):
if not is_visit[i]:
is_visit[i] = True
search(i)
print(ans) | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
g[a-1].append(b-1); g[b-1].append(a-1)
ans = 0
for i in range(N):
neighbors = g[i]
h = H[i]
res = True
for node in neighbors:
res *= h > H[node]
ans += res
print(ans) | 38 | 17 | 772 | 350 | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
d = [[0, -1]]
ans = 0
is_visit = [False] * N
def search(node):
global is_visit
global ans
d = [node]
while d:
node = d.pop()
h = H[node]
children = g[node]
res = True
for child in children:
_h = H[child]
res *= h > _h
if not is_visit[child]:
is_visit[child] = True
d.append(child)
ans += res
for i in range(N):
if not is_visit[i]:
is_visit[i] = True
search(i)
print(ans)
| N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
ans = 0
for i in range(N):
neighbors = g[i]
h = H[i]
res = True
for node in neighbors:
res *= h > H[node]
ans += res
print(ans)
| false | 55.263158 | [
"-d = [[0, -1]]",
"-is_visit = [False] * N",
"-",
"-",
"-def search(node):",
"- global is_visit",
"- global ans",
"- d = [node]",
"- while d:",
"- node = d.pop()",
"- h = H[node]",
"- children = g[node]",
"- res = True",
"- for child in children:",
"- _h = H[child]",
"- res *= h > _h",
"- if not is_visit[child]:",
"- is_visit[child] = True",
"- d.append(child)",
"- ans += res",
"-",
"-",
"- if not is_visit[i]:",
"- is_visit[i] = True",
"- search(i)",
"+ neighbors = g[i]",
"+ h = H[i]",
"+ res = True",
"+ for node in neighbors:",
"+ res *= h > H[node]",
"+ ans += res"
]
| false | 0.037753 | 0.041256 | 0.915088 | [
"s296493910",
"s158761691"
]
|
u333190709 | p02844 | python | s139259923 | s083441610 | 285 | 23 | 12,020 | 3,064 | Accepted | Accepted | 91.93 | #!/usr/bin/env python3
import sys
def solve(N: int, S: str):
def nx(S):
res = [[N+1] * 10 for _ in range(N+1)]
for i in range(N-1, -1, -1):
for j in range(10):
res[i][j] = res[i+1][j]
res[i][int(S[i])] = i
return res
dp = [[0] * 3 for _ in range(N+1)]
dp[1] = [1, 0, 0]
res = nx(S)
for i in range(0, N+1):
for j in range(10):
if res[i][j] >= N: continue
if res[0][j] == res[i][j]:
dp[res[i][j]+1][0] = 1
dp[res[i][j]+1][1] += dp[i][0]
dp[res[i][j]+1][2] += dp[i][1]
res = 0
for i in range(N+1):
res += dp[i][2]
print(res)
return
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
S = next(tokens) # type: int
solve(N, S)
if __name__ == '__main__':
main()
| #!/usr/bin/env python3
import sys
def solve(N: int, S: str):
counter = 0
for i in range(1000):
c = i % 10
b = (i // 10) % 10
a = (i // 100) % 10
aa = S.find(str(a))
if aa != -1 and aa < N - 2:
bb = S[aa+1:].find(str(b))
if bb != -1 and bb < N - 1:
cc = S[aa+bb+2:].find(str(c))
if cc != -1:
counter += 1
print(counter)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
S = next(tokens) # type: int
solve(N, S)
if __name__ == '__main__':
main()
| 41 | 33 | 1,210 | 776 | #!/usr/bin/env python3
import sys
def solve(N: int, S: str):
def nx(S):
res = [[N + 1] * 10 for _ in range(N + 1)]
for i in range(N - 1, -1, -1):
for j in range(10):
res[i][j] = res[i + 1][j]
res[i][int(S[i])] = i
return res
dp = [[0] * 3 for _ in range(N + 1)]
dp[1] = [1, 0, 0]
res = nx(S)
for i in range(0, N + 1):
for j in range(10):
if res[i][j] >= N:
continue
if res[0][j] == res[i][j]:
dp[res[i][j] + 1][0] = 1
dp[res[i][j] + 1][1] += dp[i][0]
dp[res[i][j] + 1][2] += dp[i][1]
res = 0
for i in range(N + 1):
res += dp[i][2]
print(res)
return
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
S = next(tokens) # type: int
solve(N, S)
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
import sys
def solve(N: int, S: str):
counter = 0
for i in range(1000):
c = i % 10
b = (i // 10) % 10
a = (i // 100) % 10
aa = S.find(str(a))
if aa != -1 and aa < N - 2:
bb = S[aa + 1 :].find(str(b))
if bb != -1 and bb < N - 1:
cc = S[aa + bb + 2 :].find(str(c))
if cc != -1:
counter += 1
print(counter)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
S = next(tokens) # type: int
solve(N, S)
if __name__ == "__main__":
main()
| false | 19.512195 | [
"- def nx(S):",
"- res = [[N + 1] * 10 for _ in range(N + 1)]",
"- for i in range(N - 1, -1, -1):",
"- for j in range(10):",
"- res[i][j] = res[i + 1][j]",
"- res[i][int(S[i])] = i",
"- return res",
"-",
"- dp = [[0] * 3 for _ in range(N + 1)]",
"- dp[1] = [1, 0, 0]",
"- res = nx(S)",
"- for i in range(0, N + 1):",
"- for j in range(10):",
"- if res[i][j] >= N:",
"- continue",
"- if res[0][j] == res[i][j]:",
"- dp[res[i][j] + 1][0] = 1",
"- dp[res[i][j] + 1][1] += dp[i][0]",
"- dp[res[i][j] + 1][2] += dp[i][1]",
"- res = 0",
"- for i in range(N + 1):",
"- res += dp[i][2]",
"- print(res)",
"- return",
"+ counter = 0",
"+ for i in range(1000):",
"+ c = i % 10",
"+ b = (i // 10) % 10",
"+ a = (i // 100) % 10",
"+ aa = S.find(str(a))",
"+ if aa != -1 and aa < N - 2:",
"+ bb = S[aa + 1 :].find(str(b))",
"+ if bb != -1 and bb < N - 1:",
"+ cc = S[aa + bb + 2 :].find(str(c))",
"+ if cc != -1:",
"+ counter += 1",
"+ print(counter)",
"-# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)"
]
| false | 0.045702 | 0.038003 | 1.202604 | [
"s139259923",
"s083441610"
]
|
u340781749 | p03112 | python | s934505745 | s022903461 | 805 | 641 | 129,132 | 58,724 | Accepted | Accepted | 20.37 | import bisect
import sys
a, b, q = list(map(int, input().split()))
lines = sys.stdin.readlines()
sss = list(map(int, lines[:a]))
ttt = list(map(int, lines[a:a + b]))
xxx = list(map(int, lines[a + b:]))
nearest_temples = [0] * a
nearest_shrines = [0] * b
for i, s in enumerate(sss):
ti = bisect.bisect(ttt, s)
nt = 10 ** 11
if ti > 0:
nt = min(nt, abs(s - ttt[ti - 1]))
if ti < b:
nt = min(nt, abs(s - ttt[ti]))
nearest_temples[i] = nt
for i, t in enumerate(ttt):
si = bisect.bisect(sss, t)
ns = 10 ** 11
if si > 0:
ns = min(ns, abs(t - sss[si - 1]))
if si < a:
ns = min(ns, abs(t - sss[si]))
nearest_shrines[i] = ns
buf = []
for x in xxx:
si = bisect.bisect(sss, x)
ti = bisect.bisect(ttt, x)
ans = 10 ** 11
if si > 0:
ans = min(ans, x - sss[si - 1] + nearest_temples[si - 1])
if si < a:
ans = min(ans, sss[si] - x + nearest_temples[si])
if ti > 0:
ans = min(ans, x - ttt[ti - 1] + nearest_shrines[ti - 1])
if ti < b:
ans = min(ans, ttt[ti] - x + nearest_shrines[ti])
buf.append(ans)
print(('\n'.join(map(str, buf))))
| import bisect
import sys
SENTINEL = 10 ** 12
a, b, q = list(map(int, input().split()))
lines = sys.stdin.readlines()
sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL]
ttt = [-SENTINEL] + list(map(int, lines[a:a + b])) + [SENTINEL]
xxx = list(map(int, lines[a + b:]))
nearest_temples = [SENTINEL] + [0] * a + [SENTINEL]
nearest_shrines = [SENTINEL] + [0] * b + [SENTINEL]
for i, s in enumerate(sss[1:-1], start=1):
ti = bisect.bisect(ttt, s)
nearest_temples[i] = min(ttt[ti] - s, s - ttt[ti - 1])
for i, t in enumerate(ttt[1:-1], start=1):
si = bisect.bisect(sss, t)
nearest_shrines[i] = min(sss[si] - t, t - sss[si - 1])
buf = []
for x in xxx:
si = bisect.bisect(sss, x)
ti = bisect.bisect(ttt, x)
ans = min(x - sss[si - 1] + nearest_temples[si - 1],
sss[si] - x + nearest_temples[si],
x - ttt[ti - 1] + nearest_shrines[ti - 1],
ttt[ti] - x + nearest_shrines[ti])
buf.append(ans)
print(('\n'.join(map(str, buf))))
| 43 | 30 | 1,197 | 1,028 | import bisect
import sys
a, b, q = list(map(int, input().split()))
lines = sys.stdin.readlines()
sss = list(map(int, lines[:a]))
ttt = list(map(int, lines[a : a + b]))
xxx = list(map(int, lines[a + b :]))
nearest_temples = [0] * a
nearest_shrines = [0] * b
for i, s in enumerate(sss):
ti = bisect.bisect(ttt, s)
nt = 10**11
if ti > 0:
nt = min(nt, abs(s - ttt[ti - 1]))
if ti < b:
nt = min(nt, abs(s - ttt[ti]))
nearest_temples[i] = nt
for i, t in enumerate(ttt):
si = bisect.bisect(sss, t)
ns = 10**11
if si > 0:
ns = min(ns, abs(t - sss[si - 1]))
if si < a:
ns = min(ns, abs(t - sss[si]))
nearest_shrines[i] = ns
buf = []
for x in xxx:
si = bisect.bisect(sss, x)
ti = bisect.bisect(ttt, x)
ans = 10**11
if si > 0:
ans = min(ans, x - sss[si - 1] + nearest_temples[si - 1])
if si < a:
ans = min(ans, sss[si] - x + nearest_temples[si])
if ti > 0:
ans = min(ans, x - ttt[ti - 1] + nearest_shrines[ti - 1])
if ti < b:
ans = min(ans, ttt[ti] - x + nearest_shrines[ti])
buf.append(ans)
print(("\n".join(map(str, buf))))
| import bisect
import sys
SENTINEL = 10**12
a, b, q = list(map(int, input().split()))
lines = sys.stdin.readlines()
sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL]
ttt = [-SENTINEL] + list(map(int, lines[a : a + b])) + [SENTINEL]
xxx = list(map(int, lines[a + b :]))
nearest_temples = [SENTINEL] + [0] * a + [SENTINEL]
nearest_shrines = [SENTINEL] + [0] * b + [SENTINEL]
for i, s in enumerate(sss[1:-1], start=1):
ti = bisect.bisect(ttt, s)
nearest_temples[i] = min(ttt[ti] - s, s - ttt[ti - 1])
for i, t in enumerate(ttt[1:-1], start=1):
si = bisect.bisect(sss, t)
nearest_shrines[i] = min(sss[si] - t, t - sss[si - 1])
buf = []
for x in xxx:
si = bisect.bisect(sss, x)
ti = bisect.bisect(ttt, x)
ans = min(
x - sss[si - 1] + nearest_temples[si - 1],
sss[si] - x + nearest_temples[si],
x - ttt[ti - 1] + nearest_shrines[ti - 1],
ttt[ti] - x + nearest_shrines[ti],
)
buf.append(ans)
print(("\n".join(map(str, buf))))
| false | 30.232558 | [
"+SENTINEL = 10**12",
"-sss = list(map(int, lines[:a]))",
"-ttt = list(map(int, lines[a : a + b]))",
"+sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL]",
"+ttt = [-SENTINEL] + list(map(int, lines[a : a + b])) + [SENTINEL]",
"-nearest_temples = [0] * a",
"-nearest_shrines = [0] * b",
"-for i, s in enumerate(sss):",
"+nearest_temples = [SENTINEL] + [0] * a + [SENTINEL]",
"+nearest_shrines = [SENTINEL] + [0] * b + [SENTINEL]",
"+for i, s in enumerate(sss[1:-1], start=1):",
"- nt = 10**11",
"- if ti > 0:",
"- nt = min(nt, abs(s - ttt[ti - 1]))",
"- if ti < b:",
"- nt = min(nt, abs(s - ttt[ti]))",
"- nearest_temples[i] = nt",
"-for i, t in enumerate(ttt):",
"+ nearest_temples[i] = min(ttt[ti] - s, s - ttt[ti - 1])",
"+for i, t in enumerate(ttt[1:-1], start=1):",
"- ns = 10**11",
"- if si > 0:",
"- ns = min(ns, abs(t - sss[si - 1]))",
"- if si < a:",
"- ns = min(ns, abs(t - sss[si]))",
"- nearest_shrines[i] = ns",
"+ nearest_shrines[i] = min(sss[si] - t, t - sss[si - 1])",
"- ans = 10**11",
"- if si > 0:",
"- ans = min(ans, x - sss[si - 1] + nearest_temples[si - 1])",
"- if si < a:",
"- ans = min(ans, sss[si] - x + nearest_temples[si])",
"- if ti > 0:",
"- ans = min(ans, x - ttt[ti - 1] + nearest_shrines[ti - 1])",
"- if ti < b:",
"- ans = min(ans, ttt[ti] - x + nearest_shrines[ti])",
"+ ans = min(",
"+ x - sss[si - 1] + nearest_temples[si - 1],",
"+ sss[si] - x + nearest_temples[si],",
"+ x - ttt[ti - 1] + nearest_shrines[ti - 1],",
"+ ttt[ti] - x + nearest_shrines[ti],",
"+ )"
]
| false | 0.007964 | 0.040605 | 0.196124 | [
"s934505745",
"s022903461"
]
|
u768496010 | p02813 | python | s297921043 | s411255346 | 48 | 19 | 8,052 | 3,188 | Accepted | Accepted | 60.42 | n = int(eval(input()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
import itertools
plist = list(itertools.permutations([i+1 for i in range(n)]))
count = 1
resultp = 0
resultq = 0
for pp in plist:
if(list(pp) == p):
resultp = count
if (list(pp) == q):
resultq = count
count += 1
print((abs(resultp - resultq))) | import math
# 数列が何番目かを返却するメソッド
def junban(N, str):
int_list = str.split() # 入力文字を配列化
int_list = [int(i) for i in int_list]
used_list = []
num = 0
for element in int_list:
N -= 1
used_count = 0
for used in used_list:
if element > used:
used_count += 1
num += (element - 1 - used_count) * math.factorial(N)
used_list.append(element)
# print(num)
return num
# 大きさNを受け取る
N = int(eval(input()))
# 数列Pを受け取る
P = eval(input())
# 数列Qを受け取る
Q = eval(input())
# それぞれが何番目か求める
p_int = junban(N, P)
q_int = junban(N, Q)
print((abs(p_int - q_int)))
| 20 | 31 | 380 | 644 | n = int(eval(input()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
import itertools
plist = list(itertools.permutations([i + 1 for i in range(n)]))
count = 1
resultp = 0
resultq = 0
for pp in plist:
if list(pp) == p:
resultp = count
if list(pp) == q:
resultq = count
count += 1
print((abs(resultp - resultq)))
| import math
# 数列が何番目かを返却するメソッド
def junban(N, str):
int_list = str.split() # 入力文字を配列化
int_list = [int(i) for i in int_list]
used_list = []
num = 0
for element in int_list:
N -= 1
used_count = 0
for used in used_list:
if element > used:
used_count += 1
num += (element - 1 - used_count) * math.factorial(N)
used_list.append(element)
# print(num)
return num
# 大きさNを受け取る
N = int(eval(input()))
# 数列Pを受け取る
P = eval(input())
# 数列Qを受け取る
Q = eval(input())
# それぞれが何番目か求める
p_int = junban(N, P)
q_int = junban(N, Q)
print((abs(p_int - q_int)))
| false | 35.483871 | [
"-n = int(eval(input()))",
"-p = list(map(int, input().split()))",
"-q = list(map(int, input().split()))",
"-import itertools",
"+import math",
"-plist = list(itertools.permutations([i + 1 for i in range(n)]))",
"-count = 1",
"-resultp = 0",
"-resultq = 0",
"-for pp in plist:",
"- if list(pp) == p:",
"- resultp = count",
"- if list(pp) == q:",
"- resultq = count",
"- count += 1",
"-print((abs(resultp - resultq)))",
"+# 数列が何番目かを返却するメソッド",
"+def junban(N, str):",
"+ int_list = str.split() # 入力文字を配列化",
"+ int_list = [int(i) for i in int_list]",
"+ used_list = []",
"+ num = 0",
"+ for element in int_list:",
"+ N -= 1",
"+ used_count = 0",
"+ for used in used_list:",
"+ if element > used:",
"+ used_count += 1",
"+ num += (element - 1 - used_count) * math.factorial(N)",
"+ used_list.append(element)",
"+ # print(num)",
"+ return num",
"+",
"+",
"+# 大きさNを受け取る",
"+N = int(eval(input()))",
"+# 数列Pを受け取る",
"+P = eval(input())",
"+# 数列Qを受け取る",
"+Q = eval(input())",
"+# それぞれが何番目か求める",
"+p_int = junban(N, P)",
"+q_int = junban(N, Q)",
"+print((abs(p_int - q_int)))"
]
| false | 0.120349 | 0.05576 | 2.158344 | [
"s297921043",
"s411255346"
]
|
u707808519 | p02732 | python | s356582927 | s768068320 | 682 | 380 | 26,140 | 26,140 | Accepted | Accepted | 44.28 | import bisect
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = sorted(A)
cnt = [0] * (N+1)
for k in range(1, N+1):
cnt[k] = bisect.bisect_left(B, k+1)
for k in range(N):
cnt[-1-k] -= cnt[-2-k]
ALL = 0
for i in range(1, N+1):
ALL += cnt[i]*(cnt[i]-1)//2
for k in range(N):
ans = ALL - cnt[A[k]]*(cnt[A[k]]-1)//2 + (cnt[A[k]]-1)*((cnt[A[k]]-1)-1)//2
print(ans) | N = int(eval(input()))
A = list(map(int, input().split()))
cnt = [0] * (N+1)
for i in range(N):
cnt[A[i]] += 1
nsum = [cnt[n]*(cnt[n]-1)//2 for n in range(N+1)]
SUM = sum(nsum)
for k in range(N):
kadd = cnt[A[k]] - 1
print((SUM - nsum[A[k]] + kadd*(kadd-1)//2)) | 19 | 13 | 410 | 280 | import bisect
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = sorted(A)
cnt = [0] * (N + 1)
for k in range(1, N + 1):
cnt[k] = bisect.bisect_left(B, k + 1)
for k in range(N):
cnt[-1 - k] -= cnt[-2 - k]
ALL = 0
for i in range(1, N + 1):
ALL += cnt[i] * (cnt[i] - 1) // 2
for k in range(N):
ans = (
ALL
- cnt[A[k]] * (cnt[A[k]] - 1) // 2
+ (cnt[A[k]] - 1) * ((cnt[A[k]] - 1) - 1) // 2
)
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
cnt = [0] * (N + 1)
for i in range(N):
cnt[A[i]] += 1
nsum = [cnt[n] * (cnt[n] - 1) // 2 for n in range(N + 1)]
SUM = sum(nsum)
for k in range(N):
kadd = cnt[A[k]] - 1
print((SUM - nsum[A[k]] + kadd * (kadd - 1) // 2))
| false | 31.578947 | [
"-import bisect",
"-",
"-A = [int(x) for x in input().split()]",
"-B = sorted(A)",
"+A = list(map(int, input().split()))",
"-for k in range(1, N + 1):",
"- cnt[k] = bisect.bisect_left(B, k + 1)",
"+for i in range(N):",
"+ cnt[A[i]] += 1",
"+nsum = [cnt[n] * (cnt[n] - 1) // 2 for n in range(N + 1)]",
"+SUM = sum(nsum)",
"- cnt[-1 - k] -= cnt[-2 - k]",
"-ALL = 0",
"-for i in range(1, N + 1):",
"- ALL += cnt[i] * (cnt[i] - 1) // 2",
"-for k in range(N):",
"- ans = (",
"- ALL",
"- - cnt[A[k]] * (cnt[A[k]] - 1) // 2",
"- + (cnt[A[k]] - 1) * ((cnt[A[k]] - 1) - 1) // 2",
"- )",
"- print(ans)",
"+ kadd = cnt[A[k]] - 1",
"+ print((SUM - nsum[A[k]] + kadd * (kadd - 1) // 2))"
]
| false | 0.007244 | 0.037584 | 0.19274 | [
"s356582927",
"s768068320"
]
|
u119714109 | p03608 | python | s205981505 | s752295465 | 399 | 253 | 45,148 | 4,084 | Accepted | Accepted | 36.59 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n,m,r=na()
rs = na()
for i in range(r):
rs[i] -= 1
g = [[99999999999]*n for _ in range(n)]
for i in range(n):
g[i][i] = 0
for i in range(m):
a, b, c = na()
a -= 1
b -= 1
g[a][b] = g[b][a] = c
for k in range(n):
for i in range(n):
for j in range(n):
g[i][j] = min(g[i][j], g[i][k] + g[k][j])
from itertools import *
ans = 9999999999999999999
for ord in permutations(rs):
w = 0
for i in range(1, r):
w += g[ord[i-1]][ord[i]]
ans = min(ans, w)
print(ans) | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n,m,r=na()
rs = na()
for i in range(r):
rs[i] -= 1
g = [[99999999999]*n for _ in range(n)]
for i in range(n):
g[i][i] = 0
for i in range(m):
a, b, c = na()
a -= 1
b -= 1
g[a][b] = g[b][a] = c
from heapq import *
def dijkstra(g, start):
n = len(g)
ds = [1e18] * n
ds[start] = 0
h = []
heappush(h, (0, start))
while len(h) > 0:
d, cur = heappop(h)
if d != ds[cur]: continue
for e, ew in g[cur]:
if d + ew < ds[e]:
ds[e] = d + ew
heappush(h, (ds[e], e))
return ds
def dijkstra_dense(g, start):
n = len(g)
ds = [1e18] * n
ds[start] = 0
done = [0] * n
while True:
lmin = 1e19
arg = -1
for i in range(n):
if not done[i] and ds[i] < lmin:
lmin = ds[i]
arg = i
if arg == -1: break
done[arg] = 1
for i in range(n):
ds[i] = min(ds[i], lmin + g[arg][i])
return ds
dss = [None] * n
for r in rs:
dss[r] = dijkstra_dense(g, r)
from itertools import *
ans = 9999999999999999999
for ord in permutations(rs):
w = 0
for i in range(1, len(rs)):
w += dss[ord[i-1]][ord[i]]
ans = min(ans, w)
print(ans)
| 36 | 71 | 697 | 1,471 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n, m, r = na()
rs = na()
for i in range(r):
rs[i] -= 1
g = [[99999999999] * n for _ in range(n)]
for i in range(n):
g[i][i] = 0
for i in range(m):
a, b, c = na()
a -= 1
b -= 1
g[a][b] = g[b][a] = c
for k in range(n):
for i in range(n):
for j in range(n):
g[i][j] = min(g[i][j], g[i][k] + g[k][j])
from itertools import *
ans = 9999999999999999999
for ord in permutations(rs):
w = 0
for i in range(1, r):
w += g[ord[i - 1]][ord[i]]
ans = min(ans, w)
print(ans)
| import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n, m, r = na()
rs = na()
for i in range(r):
rs[i] -= 1
g = [[99999999999] * n for _ in range(n)]
for i in range(n):
g[i][i] = 0
for i in range(m):
a, b, c = na()
a -= 1
b -= 1
g[a][b] = g[b][a] = c
from heapq import *
def dijkstra(g, start):
n = len(g)
ds = [1e18] * n
ds[start] = 0
h = []
heappush(h, (0, start))
while len(h) > 0:
d, cur = heappop(h)
if d != ds[cur]:
continue
for e, ew in g[cur]:
if d + ew < ds[e]:
ds[e] = d + ew
heappush(h, (ds[e], e))
return ds
def dijkstra_dense(g, start):
n = len(g)
ds = [1e18] * n
ds[start] = 0
done = [0] * n
while True:
lmin = 1e19
arg = -1
for i in range(n):
if not done[i] and ds[i] < lmin:
lmin = ds[i]
arg = i
if arg == -1:
break
done[arg] = 1
for i in range(n):
ds[i] = min(ds[i], lmin + g[arg][i])
return ds
dss = [None] * n
for r in rs:
dss[r] = dijkstra_dense(g, r)
from itertools import *
ans = 9999999999999999999
for ord in permutations(rs):
w = 0
for i in range(1, len(rs)):
w += dss[ord[i - 1]][ord[i]]
ans = min(ans, w)
print(ans)
| false | 49.295775 | [
"-for k in range(n):",
"- for i in range(n):",
"- for j in range(n):",
"- g[i][j] = min(g[i][j], g[i][k] + g[k][j])",
"+from heapq import *",
"+",
"+",
"+def dijkstra(g, start):",
"+ n = len(g)",
"+ ds = [1e18] * n",
"+ ds[start] = 0",
"+ h = []",
"+ heappush(h, (0, start))",
"+ while len(h) > 0:",
"+ d, cur = heappop(h)",
"+ if d != ds[cur]:",
"+ continue",
"+ for e, ew in g[cur]:",
"+ if d + ew < ds[e]:",
"+ ds[e] = d + ew",
"+ heappush(h, (ds[e], e))",
"+ return ds",
"+",
"+",
"+def dijkstra_dense(g, start):",
"+ n = len(g)",
"+ ds = [1e18] * n",
"+ ds[start] = 0",
"+ done = [0] * n",
"+ while True:",
"+ lmin = 1e19",
"+ arg = -1",
"+ for i in range(n):",
"+ if not done[i] and ds[i] < lmin:",
"+ lmin = ds[i]",
"+ arg = i",
"+ if arg == -1:",
"+ break",
"+ done[arg] = 1",
"+ for i in range(n):",
"+ ds[i] = min(ds[i], lmin + g[arg][i])",
"+ return ds",
"+",
"+",
"+dss = [None] * n",
"+for r in rs:",
"+ dss[r] = dijkstra_dense(g, r)",
"- for i in range(1, r):",
"- w += g[ord[i - 1]][ord[i]]",
"+ for i in range(1, len(rs)):",
"+ w += dss[ord[i - 1]][ord[i]]"
]
| false | 0.078667 | 0.091509 | 0.859667 | [
"s205981505",
"s752295465"
]
|
u347184682 | p02832 | python | s609347469 | s262076419 | 177 | 103 | 25,768 | 32,320 | Accepted | Accepted | 41.81 | n=int(eval(input()))
a=[int(x) for x in input().rstrip().split()]
cnt=0
now=0
for i in range(n):
while(now<n):
if a[now]==i+1:
cnt+=1
break
else:
now+=1
if cnt==0:
print((-1))
else:
print((n-cnt))
| n=int(eval(input()))
a=[int(x) for x in input().rstrip().split()]
now=1
cnt=0
for i in range(n):
if now==a[i]:
now+=1
else:
cnt+=1
if n==cnt:
print((-1))
else:
print(cnt)
| 16 | 15 | 235 | 195 | n = int(eval(input()))
a = [int(x) for x in input().rstrip().split()]
cnt = 0
now = 0
for i in range(n):
while now < n:
if a[now] == i + 1:
cnt += 1
break
else:
now += 1
if cnt == 0:
print((-1))
else:
print((n - cnt))
| n = int(eval(input()))
a = [int(x) for x in input().rstrip().split()]
now = 1
cnt = 0
for i in range(n):
if now == a[i]:
now += 1
else:
cnt += 1
if n == cnt:
print((-1))
else:
print(cnt)
| false | 6.25 | [
"+now = 1",
"-now = 0",
"- while now < n:",
"- if a[now] == i + 1:",
"- cnt += 1",
"- break",
"- else:",
"- now += 1",
"-if cnt == 0:",
"+ if now == a[i]:",
"+ now += 1",
"+ else:",
"+ cnt += 1",
"+if n == cnt:",
"- print((n - cnt))",
"+ print(cnt)"
]
| false | 0.043792 | 0.044467 | 0.98481 | [
"s609347469",
"s262076419"
]
|
u644907318 | p03681 | python | s384020865 | s634041166 | 195 | 74 | 39,856 | 79,656 | Accepted | Accepted | 62.05 | p = 10**9+7
N,M = list(map(int,input().split()))
a = 1
for i in range(2,N+1):
a = (a*i)%p
b = 1
for i in range(2,M+1):
b = (b*i)%p
if M==N:
n = (2*a*b)%p
elif M==N-1 or N==M-1:
n = (a*b)%p
else:
n = 0
print(n) | p = 10**9+7
N,M = list(map(int,input().split()))
A = [1 for _ in range(N+1)]
for i in range(2,N+1):
A[i] = (i*A[i-1])%p
B = [1 for _ in range(M+1)]
for i in range(2,M+1):
B[i] = (i*B[i-1])%p
if abs(N-M)>1:
ans = 0
elif abs(N-M)==1:
ans = (A[N]*B[M])%p
elif abs(N-M)==0:
ans = (2*A[N]*B[M])%p
print(ans) | 15 | 15 | 237 | 330 | p = 10**9 + 7
N, M = list(map(int, input().split()))
a = 1
for i in range(2, N + 1):
a = (a * i) % p
b = 1
for i in range(2, M + 1):
b = (b * i) % p
if M == N:
n = (2 * a * b) % p
elif M == N - 1 or N == M - 1:
n = (a * b) % p
else:
n = 0
print(n)
| p = 10**9 + 7
N, M = list(map(int, input().split()))
A = [1 for _ in range(N + 1)]
for i in range(2, N + 1):
A[i] = (i * A[i - 1]) % p
B = [1 for _ in range(M + 1)]
for i in range(2, M + 1):
B[i] = (i * B[i - 1]) % p
if abs(N - M) > 1:
ans = 0
elif abs(N - M) == 1:
ans = (A[N] * B[M]) % p
elif abs(N - M) == 0:
ans = (2 * A[N] * B[M]) % p
print(ans)
| false | 0 | [
"-a = 1",
"+A = [1 for _ in range(N + 1)]",
"- a = (a * i) % p",
"-b = 1",
"+ A[i] = (i * A[i - 1]) % p",
"+B = [1 for _ in range(M + 1)]",
"- b = (b * i) % p",
"-if M == N:",
"- n = (2 * a * b) % p",
"-elif M == N - 1 or N == M - 1:",
"- n = (a * b) % p",
"-else:",
"- n = 0",
"-print(n)",
"+ B[i] = (i * B[i - 1]) % p",
"+if abs(N - M) > 1:",
"+ ans = 0",
"+elif abs(N - M) == 1:",
"+ ans = (A[N] * B[M]) % p",
"+elif abs(N - M) == 0:",
"+ ans = (2 * A[N] * B[M]) % p",
"+print(ans)"
]
| false | 0.03772 | 0.148711 | 0.253649 | [
"s384020865",
"s634041166"
]
|
u631277801 | p02937 | python | s869011868 | s288305394 | 1,995 | 268 | 378,916 | 54,740 | Accepted | Accepted | 86.57 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from collections import defaultdict
from bisect import bisect_right
s = ns()
t = ns()
ok = True
sset = set(list(s))
for ti in t:
if ti not in sset:
ok = False
break
if not ok:
print((-1))
else:
n = len(s)
charidx = defaultdict(list)
for i, si in enumerate(s):
charidx[si].append(i)
for i, si in enumerate(s):
charidx[si].append(n+i)
ks = list(charidx.keys())
move = [{ki: -1 for ki in ks} for _ in range(n)]
for i, si in enumerate(s):
for ki in ks:
idxlist = charidx[ki]
nexidx = bisect_right(idxlist, i)
move[i][ki] = (idxlist[nexidx] - i) % (n+1)
cur = s.index(t[:1])
ans = cur
for ti in t[1:]:
nex = move[cur][ti]
ans += nex
cur = (cur + nex) % n
print((ans+1))
| import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from bisect import bisect_right
s = ns()
t = ns()
# 判定
ok = True
sset = set(list(s))
tset = set(list(t))
for ti in tset:
if ti not in sset:
ok = False
if not ok:
print((-1))
else:
n = len(s)
nex = [[] for _ in range(26)]
sdouble = s + s
orda = ord("a")
for i, si in enumerate(sdouble):
nex[ord(si) - orda].append(i)
bef = t[:1]
cur = s.index(t[:1])
ans = cur
for ti in t[1:]:
chridx = ord(ti) - orda
dest = bisect_right(nex[chridx], cur)
ans += (nex[chridx][dest] - cur)
cur = ans % n
print((ans+1)) | 59 | 48 | 1,309 | 1,076 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
from collections import defaultdict
from bisect import bisect_right
s = ns()
t = ns()
ok = True
sset = set(list(s))
for ti in t:
if ti not in sset:
ok = False
break
if not ok:
print((-1))
else:
n = len(s)
charidx = defaultdict(list)
for i, si in enumerate(s):
charidx[si].append(i)
for i, si in enumerate(s):
charidx[si].append(n + i)
ks = list(charidx.keys())
move = [{ki: -1 for ki in ks} for _ in range(n)]
for i, si in enumerate(s):
for ki in ks:
idxlist = charidx[ki]
nexidx = bisect_right(idxlist, i)
move[i][ki] = (idxlist[nexidx] - i) % (n + 1)
cur = s.index(t[:1])
ans = cur
for ti in t[1:]:
nex = move[cur][ti]
ans += nex
cur = (cur + nex) % n
print((ans + 1))
| import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
from bisect import bisect_right
s = ns()
t = ns()
# 判定
ok = True
sset = set(list(s))
tset = set(list(t))
for ti in tset:
if ti not in sset:
ok = False
if not ok:
print((-1))
else:
n = len(s)
nex = [[] for _ in range(26)]
sdouble = s + s
orda = ord("a")
for i, si in enumerate(sdouble):
nex[ord(si) - orda].append(i)
bef = t[:1]
cur = s.index(t[:1])
ans = cur
for ti in t[1:]:
chridx = ord(ti) - orda
dest = bisect_right(nex[chridx], cur)
ans += nex[chridx][dest] - cur
cur = ans % n
print((ans + 1))
| false | 18.644068 | [
"-from collections import defaultdict",
"+# 判定",
"-for ti in t:",
"+tset = set(list(t))",
"+for ti in tset:",
"- break",
"- charidx = defaultdict(list)",
"- for i, si in enumerate(s):",
"- charidx[si].append(i)",
"- for i, si in enumerate(s):",
"- charidx[si].append(n + i)",
"- ks = list(charidx.keys())",
"- move = [{ki: -1 for ki in ks} for _ in range(n)]",
"- for i, si in enumerate(s):",
"- for ki in ks:",
"- idxlist = charidx[ki]",
"- nexidx = bisect_right(idxlist, i)",
"- move[i][ki] = (idxlist[nexidx] - i) % (n + 1)",
"+ nex = [[] for _ in range(26)]",
"+ sdouble = s + s",
"+ orda = ord(\"a\")",
"+ for i, si in enumerate(sdouble):",
"+ nex[ord(si) - orda].append(i)",
"+ bef = t[:1]",
"- nex = move[cur][ti]",
"- ans += nex",
"- cur = (cur + nex) % n",
"+ chridx = ord(ti) - orda",
"+ dest = bisect_right(nex[chridx], cur)",
"+ ans += nex[chridx][dest] - cur",
"+ cur = ans % n"
]
| false | 0.042743 | 0.0369 | 1.158347 | [
"s869011868",
"s288305394"
]
|
u054556734 | p02900 | python | s204598109 | s998716935 | 196 | 146 | 38,688 | 3,316 | Accepted | Accepted | 25.51 | import collections as col
def prime(n):
ans = []
num = n
for i in range(2,int(n**0.5)+1):
if i%2==0 and i!=2: continue
while num%i == 0: num //= i ; ans.append(i)
if num != 1: ans.append(num)
return ans
def gcd(a,b): return gcd(b,a%b) if a%b else b
a,b = list(map(int,input().split()))
primes = prime(gcd(a,b))
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)
| import collections as col
import math
def prime(n):
ans = []
num = n
for i in range(2,int(n**0.5)+1):
if i%2==0 and i!=2: continue
while num%i == 0: num //= i ; ans.append(i)
if num != 1: ans.append(num)
return ans
def gcd(a,b): return gcd(b,a%b) if a%b else b
a,b = list(map(int,input().split()))
primes = prime(gcd(a,b)) #math.gcdは使用禁止?
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)
| 19 | 20 | 427 | 456 | import collections as col
def prime(n):
ans = []
num = n
for i in range(2, int(n**0.5) + 1):
if i % 2 == 0 and i != 2:
continue
while num % i == 0:
num //= i
ans.append(i)
if num != 1:
ans.append(num)
return ans
def gcd(a, b):
return gcd(b, a % b) if a % b else b
a, b = list(map(int, input().split()))
primes = prime(gcd(a, b))
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)
| import collections as col
import math
def prime(n):
ans = []
num = n
for i in range(2, int(n**0.5) + 1):
if i % 2 == 0 and i != 2:
continue
while num % i == 0:
num //= i
ans.append(i)
if num != 1:
ans.append(num)
return ans
def gcd(a, b):
return gcd(b, a % b) if a % b else b
a, b = list(map(int, input().split()))
primes = prime(gcd(a, b)) # math.gcdは使用禁止?
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)
| false | 5 | [
"+import math",
"-primes = prime(gcd(a, b))",
"+primes = prime(gcd(a, b)) # math.gcdは使用禁止?"
]
| false | 0.044383 | 0.046777 | 0.948826 | [
"s204598109",
"s998716935"
]
|
u263830634 | p03775 | python | s898961756 | s675272188 | 35 | 28 | 3,188 | 3,064 | Accepted | Accepted | 20 | from math import sqrt
N = int(eval(input()))
n = int(sqrt(N)) + 10
def f(A, B):
a = len(str(A))
b = len(str(B))
return max(a, b)
ans = 10 ** 10
for i in range(1, n):
if (N//i) * i == N:
ans = min(ans, f(i, N//i))
print (ans) | N = int(eval(input()))
def make_divisors(n):
import math
divisors = []
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0: #割り切れるとき
divisors.append(i)
if i != n//i:
divisors.append(n//i)
divisors.sort()
return divisors
def F(A, B):
return max(len(str(A)), len(str(B)))
lst = make_divisors(N)
ans = 10 ** 18
for a in lst:
b = N // a
ans = min(ans, F(a, b))
print (ans)
| 17 | 29 | 263 | 485 | from math import sqrt
N = int(eval(input()))
n = int(sqrt(N)) + 10
def f(A, B):
a = len(str(A))
b = len(str(B))
return max(a, b)
ans = 10**10
for i in range(1, n):
if (N // i) * i == N:
ans = min(ans, f(i, N // i))
print(ans)
| N = int(eval(input()))
def make_divisors(n):
import math
divisors = []
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0: # 割り切れるとき
divisors.append(i)
if i != n // i:
divisors.append(n // i)
divisors.sort()
return divisors
def F(A, B):
return max(len(str(A)), len(str(B)))
lst = make_divisors(N)
ans = 10**18
for a in lst:
b = N // a
ans = min(ans, F(a, b))
print(ans)
| false | 41.37931 | [
"-from math import sqrt",
"-",
"-n = int(sqrt(N)) + 10",
"-def f(A, B):",
"- a = len(str(A))",
"- b = len(str(B))",
"- return max(a, b)",
"+def make_divisors(n):",
"+ import math",
"+",
"+ divisors = []",
"+ for i in range(1, int(math.sqrt(n)) + 1):",
"+ if n % i == 0: # 割り切れるとき",
"+ divisors.append(i)",
"+ if i != n // i:",
"+ divisors.append(n // i)",
"+ divisors.sort()",
"+ return divisors",
"-ans = 10**10",
"-for i in range(1, n):",
"- if (N // i) * i == N:",
"- ans = min(ans, f(i, N // i))",
"+def F(A, B):",
"+ return max(len(str(A)), len(str(B)))",
"+",
"+",
"+lst = make_divisors(N)",
"+ans = 10**18",
"+for a in lst:",
"+ b = N // a",
"+ ans = min(ans, F(a, b))"
]
| false | 0.057429 | 0.051865 | 1.107278 | [
"s898961756",
"s675272188"
]
|
u628583308 | p02726 | python | s099552901 | s244711795 | 1,210 | 1,019 | 3,948 | 3,948 | Accepted | Accepted | 15.79 | #!/usr/bin/env python3
import sys
import collections
def solve(N: int, X: int, Y: int):
def len_shortest_path(i, j, X, Y):
return min(abs(j-i), abs(X-i) + abs(Y-j) + 1)
result = collections.defaultdict(int)
for i in range(1, N+1):
for j in range(i+1, N+1):
shortest_path = len_shortest_path(i, j, X, Y)
result[shortest_path] += 1
for i in range(1, N):
print((result[i]))
def solve_slow(N: int, X: int, Y: int):
d = [[100000000 for i in range(N)] for j in range(N)]
X -= 1
Y -= 1
for i in range(N):
d[i][i] = 0
if i < N-1:
d[i][i+1] = 1
d[i+1][i] = 1
d[X][Y] = 1
d[Y][X] = 1
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
count_dict = collections.defaultdict(int)
for row in d:
for i in row:
count_dict[i] += 1
for i in range(1, N):
print((count_dict[i]))
return
def solve_slow(N: int, X: int, Y: int):
d = [[100000000 for i in range(N)] for j in range(N)]
X -= 1
Y -= 1
for i in range(N):
d[i][i] = 0
if i < N-1:
d[i][i+1] = 1
d[i+1][i] = 1
d[X][Y] = 1
d[Y][X] = 1
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
count_dict = collections.defaultdict(int)
for row in d:
for i in row:
count_dict[i] += 1
for i in range(1, N):
print((count_dict[i]))
return
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
solve(N, X, Y)
if __name__ == '__main__':
main()
| #!/usr/bin/env python3
import sys
import collections
def solve(N: int, X: int, Y: int):
X = X - 1
Y = Y - 1
counter = collections.defaultdict(int)
for i in range(N):
for j in range(i+1, N):
k = min(j - i, abs(Y-j) + abs(X-i) + 1)
counter[k] += 1
for i in range(1, N):
print((counter[i]))
return
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
solve(N, X, Y)
if __name__ == '__main__':
main()
| 85 | 32 | 2,214 | 897 | #!/usr/bin/env python3
import sys
import collections
def solve(N: int, X: int, Y: int):
def len_shortest_path(i, j, X, Y):
return min(abs(j - i), abs(X - i) + abs(Y - j) + 1)
result = collections.defaultdict(int)
for i in range(1, N + 1):
for j in range(i + 1, N + 1):
shortest_path = len_shortest_path(i, j, X, Y)
result[shortest_path] += 1
for i in range(1, N):
print((result[i]))
def solve_slow(N: int, X: int, Y: int):
d = [[100000000 for i in range(N)] for j in range(N)]
X -= 1
Y -= 1
for i in range(N):
d[i][i] = 0
if i < N - 1:
d[i][i + 1] = 1
d[i + 1][i] = 1
d[X][Y] = 1
d[Y][X] = 1
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
count_dict = collections.defaultdict(int)
for row in d:
for i in row:
count_dict[i] += 1
for i in range(1, N):
print((count_dict[i]))
return
def solve_slow(N: int, X: int, Y: int):
d = [[100000000 for i in range(N)] for j in range(N)]
X -= 1
Y -= 1
for i in range(N):
d[i][i] = 0
if i < N - 1:
d[i][i + 1] = 1
d[i + 1][i] = 1
d[X][Y] = 1
d[Y][X] = 1
for k in range(N):
for i in range(N):
for j in range(N):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
count_dict = collections.defaultdict(int)
for row in d:
for i in row:
count_dict[i] += 1
for i in range(1, N):
print((count_dict[i]))
return
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
solve(N, X, Y)
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
import sys
import collections
def solve(N: int, X: int, Y: int):
X = X - 1
Y = Y - 1
counter = collections.defaultdict(int)
for i in range(N):
for j in range(i + 1, N):
k = min(j - i, abs(Y - j) + abs(X - i) + 1)
counter[k] += 1
for i in range(1, N):
print((counter[i]))
return
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
solve(N, X, Y)
if __name__ == "__main__":
main()
| false | 62.352941 | [
"- def len_shortest_path(i, j, X, Y):",
"- return min(abs(j - i), abs(X - i) + abs(Y - j) + 1)",
"-",
"- result = collections.defaultdict(int)",
"- for i in range(1, N + 1):",
"- for j in range(i + 1, N + 1):",
"- shortest_path = len_shortest_path(i, j, X, Y)",
"- result[shortest_path] += 1",
"+ X = X - 1",
"+ Y = Y - 1",
"+ counter = collections.defaultdict(int)",
"+ for i in range(N):",
"+ for j in range(i + 1, N):",
"+ k = min(j - i, abs(Y - j) + abs(X - i) + 1)",
"+ counter[k] += 1",
"- print((result[i]))",
"-",
"-",
"-def solve_slow(N: int, X: int, Y: int):",
"- d = [[100000000 for i in range(N)] for j in range(N)]",
"- X -= 1",
"- Y -= 1",
"- for i in range(N):",
"- d[i][i] = 0",
"- if i < N - 1:",
"- d[i][i + 1] = 1",
"- d[i + 1][i] = 1",
"- d[X][Y] = 1",
"- d[Y][X] = 1",
"- for k in range(N):",
"- for i in range(N):",
"- for j in range(N):",
"- d[i][j] = min(d[i][j], d[i][k] + d[k][j])",
"- count_dict = collections.defaultdict(int)",
"- for row in d:",
"- for i in row:",
"- count_dict[i] += 1",
"- for i in range(1, N):",
"- print((count_dict[i]))",
"- return",
"-",
"-",
"-def solve_slow(N: int, X: int, Y: int):",
"- d = [[100000000 for i in range(N)] for j in range(N)]",
"- X -= 1",
"- Y -= 1",
"- for i in range(N):",
"- d[i][i] = 0",
"- if i < N - 1:",
"- d[i][i + 1] = 1",
"- d[i + 1][i] = 1",
"- d[X][Y] = 1",
"- d[Y][X] = 1",
"- for k in range(N):",
"- for i in range(N):",
"- for j in range(N):",
"- d[i][j] = min(d[i][j], d[i][k] + d[k][j])",
"- count_dict = collections.defaultdict(int)",
"- for row in d:",
"- for i in row:",
"- count_dict[i] += 1",
"- for i in range(1, N):",
"- print((count_dict[i]))",
"+ print((counter[i]))"
]
| false | 0.03942 | 0.037792 | 1.043087 | [
"s099552901",
"s244711795"
]
|
u462329577 | p02583 | python | s253434457 | s671909041 | 164 | 118 | 9,208 | 9,188 | Accepted | Accepted | 28.05 | #!/usr/bin/env python3
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]):
if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]:
cnt += 1
print(cnt)
| #!/usr/bin/env python3
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if (
l[i] != l[j]
and l[j] != l[k]
and l[i] > l[k] - l[j]
and l[k] < l[i] + l[j]
):
ans += 1
print(ans)
| 11 | 16 | 352 | 399 | #!/usr/bin/env python3
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]):
if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]:
cnt += 1
print(cnt)
| #!/usr/bin/env python3
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if (
l[i] != l[j]
and l[j] != l[k]
and l[i] > l[k] - l[j]
and l[k] < l[i] + l[j]
):
ans += 1
print(ans)
| false | 31.25 | [
"-a = list(map(int, input().split()))",
"-cnt = 0",
"+l = list(map(int, input().split()))",
"+l.sort()",
"+ans = 0",
"- if max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]):",
"- if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]:",
"- cnt += 1",
"-print(cnt)",
"+ if (",
"+ l[i] != l[j]",
"+ and l[j] != l[k]",
"+ and l[i] > l[k] - l[j]",
"+ and l[k] < l[i] + l[j]",
"+ ):",
"+ ans += 1",
"+print(ans)"
]
| false | 0.033419 | 0.033164 | 1.007693 | [
"s253434457",
"s671909041"
]
|
u304058693 | p02571 | python | s436948947 | s525678551 | 134 | 123 | 14,340 | 14,324 | Accepted | Accepted | 8.21 | s = eval(input())
t = eval(input())
cnt = []
for i in range(len(s) - len(t) + 1):
cnt1 = 0
for k in range(len(t)):
if t[k] == s[i: i + len(t)][k]:
cnt1 += 1
cnt.append(cnt1)
#print(t[i:k], s[i:], k-i)
else:
cnt.append(0)
#print(t[i:k], k - i)
#print(cnt)
print((len(t) - max(cnt)))
| s = eval(input())
t = eval(input())
cnt = []
for i in range(len(s) - len(t) + 1):
cnt1 = 0
for k in range(len(t)):
if t[k] == s[i: i + len(t)][k]:
cnt1 += 1
cnt.append(cnt1)
#print(t[i:k], s[i:], k-i)
else:
cnt.append(0)
#print(t[i:k], k - i)
#print(cnt)
print((len(t) - max(cnt)))
| 16 | 16 | 360 | 368 | s = eval(input())
t = eval(input())
cnt = []
for i in range(len(s) - len(t) + 1):
cnt1 = 0
for k in range(len(t)):
if t[k] == s[i : i + len(t)][k]:
cnt1 += 1
cnt.append(cnt1)
# print(t[i:k], s[i:], k-i)
else:
cnt.append(0)
# print(t[i:k], k - i)
# print(cnt)
print((len(t) - max(cnt)))
| s = eval(input())
t = eval(input())
cnt = []
for i in range(len(s) - len(t) + 1):
cnt1 = 0
for k in range(len(t)):
if t[k] == s[i : i + len(t)][k]:
cnt1 += 1
cnt.append(cnt1)
# print(t[i:k], s[i:], k-i)
else:
cnt.append(0)
# print(t[i:k], k - i)
# print(cnt)
print((len(t) - max(cnt)))
| false | 0 | [
"- else:",
"- cnt.append(0)",
"- # print(t[i:k], k - i)",
"+ else:",
"+ cnt.append(0)",
"+ # print(t[i:k], k - i)"
]
| false | 0.09735 | 0.124479 | 0.782056 | [
"s436948947",
"s525678551"
]
|
u631277801 | p03645 | python | s528885930 | s880516313 | 350 | 308 | 37,072 | 19,036 | Accepted | Accepted | 12 | import sys
sdin = sys.stdin.readline
N,M = list(map(int, sdin().split()))
AB = []
for i in range(M):
AB.append(tuple(map(int, sdin().split())))
to_mid = set()
from_mid = set()
for a,b in AB:
if a==1:
to_mid.add(b)
if b==N:
from_mid.add(a)
if to_mid & from_mid:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| import sys
stdin = sys.stdin
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
n,m = li()
from1 = set()
toN = set()
for _ in range(m):
a,b = li()
if a==1:
from1.add(b)
elif b==1:
from1.add(a)
elif a==n:
toN.add(b)
elif b==n:
toN.add(a)
if from1 & toN:
print("POSSIBLE")
else:
print("IMPOSSIBLE") | 21 | 33 | 371 | 718 | import sys
sdin = sys.stdin.readline
N, M = list(map(int, sdin().split()))
AB = []
for i in range(M):
AB.append(tuple(map(int, sdin().split())))
to_mid = set()
from_mid = set()
for a, b in AB:
if a == 1:
to_mid.add(b)
if b == N:
from_mid.add(a)
if to_mid & from_mid:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| import sys
stdin = sys.stdin
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
n, m = li()
from1 = set()
toN = set()
for _ in range(m):
a, b = li()
if a == 1:
from1.add(b)
elif b == 1:
from1.add(a)
elif a == n:
toN.add(b)
elif b == n:
toN.add(a)
if from1 & toN:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false | 36.363636 | [
"-sdin = sys.stdin.readline",
"-N, M = list(map(int, sdin().split()))",
"-AB = []",
"-for i in range(M):",
"- AB.append(tuple(map(int, sdin().split())))",
"-to_mid = set()",
"-from_mid = set()",
"-for a, b in AB:",
"+stdin = sys.stdin",
"+",
"+",
"+def li():",
"+ return list(map(int, stdin.readline().split()))",
"+",
"+",
"+def li_():",
"+ return [int(x) - 1 for x in stdin.readline().split()]",
"+",
"+",
"+def lf():",
"+ return list(map(float, stdin.readline().split()))",
"+",
"+",
"+def ls():",
"+ return stdin.readline().split()",
"+",
"+",
"+def ns():",
"+ return stdin.readline().rstrip()",
"+",
"+",
"+def lc():",
"+ return list(ns())",
"+",
"+",
"+def ni():",
"+ return int(stdin.readline())",
"+",
"+",
"+def nf():",
"+ return float(stdin.readline())",
"+",
"+",
"+n, m = li()",
"+from1 = set()",
"+toN = set()",
"+for _ in range(m):",
"+ a, b = li()",
"- to_mid.add(b)",
"- if b == N:",
"- from_mid.add(a)",
"-if to_mid & from_mid:",
"+ from1.add(b)",
"+ elif b == 1:",
"+ from1.add(a)",
"+ elif a == n:",
"+ toN.add(b)",
"+ elif b == n:",
"+ toN.add(a)",
"+if from1 & toN:"
]
| false | 0.035847 | 0.042412 | 0.84522 | [
"s528885930",
"s880516313"
]
|
u729133443 | p03343 | python | s078024158 | s613825070 | 1,995 | 1,558 | 3,392 | 115,036 | Accepted | Accepted | 21.9 | def main():
n,k,q,*a=list(map(int,open(0).read().split()))
s=sorted
m=1e18
for b in a:
i=[i for i,t in enumerate(a)if t<b]
l=s(u for t in[s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])]for u in t)
if len(l)>=q:m=min(m,l[q-1]-b)
print(m)
main() | n,k,q,*a=list(map(int,open(0).read().split()))
s=sorted
m=1e9
for b in a:
i=[i for i,t in enumerate(a)if t<b];l=s(sum([s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])],[]))
if len(l)>=q:m=min(m,l[q-1]-b)
print(m) | 10 | 7 | 295 | 218 | def main():
n, k, q, *a = list(map(int, open(0).read().split()))
s = sorted
m = 1e18
for b in a:
i = [i for i, t in enumerate(a) if t < b]
l = s(
u
for t in [s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])]
for u in t
)
if len(l) >= q:
m = min(m, l[q - 1] - b)
print(m)
main()
| n, k, q, *a = list(map(int, open(0).read().split()))
s = sorted
m = 1e9
for b in a:
i = [i for i, t in enumerate(a) if t < b]
l = s(sum([s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])], []))
if len(l) >= q:
m = min(m, l[q - 1] - b)
print(m)
| false | 30 | [
"-def main():",
"- n, k, q, *a = list(map(int, open(0).read().split()))",
"- s = sorted",
"- m = 1e18",
"- for b in a:",
"- i = [i for i, t in enumerate(a) if t < b]",
"- l = s(",
"- u",
"- for t in [s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])]",
"- for u in t",
"- )",
"- if len(l) >= q:",
"- m = min(m, l[q - 1] - b)",
"- print(m)",
"-",
"-",
"-main()",
"+n, k, q, *a = list(map(int, open(0).read().split()))",
"+s = sorted",
"+m = 1e9",
"+for b in a:",
"+ i = [i for i, t in enumerate(a) if t < b]",
"+ l = s(sum([s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])], []))",
"+ if len(l) >= q:",
"+ m = min(m, l[q - 1] - b)",
"+print(m)"
]
| false | 0.071191 | 0.03428 | 2.076745 | [
"s078024158",
"s613825070"
]
|
u489959379 | p02923 | python | s214211009 | s831400252 | 93 | 66 | 14,252 | 14,480 | Accepted | Accepted | 29.03 | n = int(eval(input()))
h = list(map(int, input().split()))
h.reverse()
ans = 0
value = 0
for i in range(1, n):
if h[i-1] <= h[i]:
value += 1
else:
value = 0
ans = max(ans, value)
print(ans)
| import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
H = list(map(int, input().split()))
res = 0
cnt = 0
for i in range(1, n):
if H[i - 1] >= H[i]:
cnt += 1
else:
res = max(res, cnt)
cnt = 0
res = max(res, cnt)
print(res)
if __name__ == '__main__':
resolve()
| 14 | 25 | 227 | 433 | n = int(eval(input()))
h = list(map(int, input().split()))
h.reverse()
ans = 0
value = 0
for i in range(1, n):
if h[i - 1] <= h[i]:
value += 1
else:
value = 0
ans = max(ans, value)
print(ans)
| import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
H = list(map(int, input().split()))
res = 0
cnt = 0
for i in range(1, n):
if H[i - 1] >= H[i]:
cnt += 1
else:
res = max(res, cnt)
cnt = 0
res = max(res, cnt)
print(res)
if __name__ == "__main__":
resolve()
| false | 44 | [
"-n = int(eval(input()))",
"-h = list(map(int, input().split()))",
"-h.reverse()",
"-ans = 0",
"-value = 0",
"-for i in range(1, n):",
"- if h[i - 1] <= h[i]:",
"- value += 1",
"- else:",
"- value = 0",
"- ans = max(ans, value)",
"-print(ans)",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+f_inf = float(\"inf\")",
"+mod = 10**9 + 7",
"+",
"+",
"+def resolve():",
"+ n = int(eval(input()))",
"+ H = list(map(int, input().split()))",
"+ res = 0",
"+ cnt = 0",
"+ for i in range(1, n):",
"+ if H[i - 1] >= H[i]:",
"+ cnt += 1",
"+ else:",
"+ res = max(res, cnt)",
"+ cnt = 0",
"+ res = max(res, cnt)",
"+ print(res)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ resolve()"
]
| false | 0.041121 | 0.101729 | 0.404215 | [
"s214211009",
"s831400252"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.