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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u671060652
|
p03041
|
python
|
s599422955
|
s618621626
| 179 | 164 | 38,384 | 38,256 |
Accepted
|
Accepted
| 8.38 |
n, k = list(map(int, input().split()))
s = eval(input())
print((s[:k-1] + chr(ord(s[k-1])+32) + s[k:]))
|
n, k = list(map(int, input().split()))
s = list(eval(input()))
s[k-1] = chr(ord(s[k-1])+ord("a")-ord("A"))
print(("".join(s)))
| 4 | 6 | 93 | 119 |
n, k = list(map(int, input().split()))
s = eval(input())
print((s[: k - 1] + chr(ord(s[k - 1]) + 32) + s[k:]))
|
n, k = list(map(int, input().split()))
s = list(eval(input()))
s[k - 1] = chr(ord(s[k - 1]) + ord("a") - ord("A"))
print(("".join(s)))
| false | 33.333333 |
[
"-s = eval(input())",
"-print((s[: k - 1] + chr(ord(s[k - 1]) + 32) + s[k:]))",
"+s = list(eval(input()))",
"+s[k - 1] = chr(ord(s[k - 1]) + ord(\"a\") - ord(\"A\"))",
"+print((\"\".join(s)))"
] | false | 0.043469 | 0.035708 | 1.217349 |
[
"s599422955",
"s618621626"
] |
u588341295
|
p02863
|
python
|
s482142174
|
s201367787
| 693 | 266 | 181,724 | 153,196 |
Accepted
|
Accepted
| 61.62 |
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
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
N, T = MAP()
AB = []
for i in range(N):
a, b = MAP()
AB.append((a, b))
AB.sort(key=itemgetter(1), reverse=True)
AB.sort(key=itemgetter(0))
TMAX = 6007
dp = list2d(N+1, TMAX, 0)
for i in range(N):
a, b = AB[i]
for j in range(TMAX):
dp[i+1][j] = max(dp[i+1][j], dp[i][j])
if j < T:
dp[i+1][j+a] = max(dp[i+1][j+a], dp[i][j] + b)
print((max(dp[N])))
|
# -*- coding: utf-8 -*-
import sys
import numpy as np
from operator import itemgetter
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
N, T = MAP()
AB = []
for i in range(N):
a, b = MAP()
AB.append((a, b))
# 各料理を時間の昇順でソート
AB.sort(key=itemgetter(1), reverse=True)
AB.sort(key=itemgetter(0))
# 後は普通のナップザック
TMAX = 6007
dp = np.zeros((N+1, TMAX), dtype=np.int64)
for i in range(N):
a, b = AB[i]
dp[i+1] = dp[i]
dp[i+1,a:a+T] = np.maximum(dp[i+1,a:a+T], dp[i,:T] + b)
print((dp[N].max()))
| 39 | 40 | 1,138 | 1,136 |
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
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
N, T = MAP()
AB = []
for i in range(N):
a, b = MAP()
AB.append((a, b))
AB.sort(key=itemgetter(1), reverse=True)
AB.sort(key=itemgetter(0))
TMAX = 6007
dp = list2d(N + 1, TMAX, 0)
for i in range(N):
a, b = AB[i]
for j in range(TMAX):
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
if j < T:
dp[i + 1][j + a] = max(dp[i + 1][j + a], dp[i][j] + b)
print((max(dp[N])))
|
# -*- coding: utf-8 -*-
import sys
import numpy as np
from operator import itemgetter
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
N, T = MAP()
AB = []
for i in range(N):
a, b = MAP()
AB.append((a, b))
# 各料理を時間の昇順でソート
AB.sort(key=itemgetter(1), reverse=True)
AB.sort(key=itemgetter(0))
# 後は普通のナップザック
TMAX = 6007
dp = np.zeros((N + 1, TMAX), dtype=np.int64)
for i in range(N):
a, b = AB[i]
dp[i + 1] = dp[i]
dp[i + 1, a : a + T] = np.maximum(dp[i + 1, a : a + T], dp[i, :T] + b)
print((dp[N].max()))
| false | 2.5 |
[
"+import numpy as np",
"+# 各料理を時間の昇順でソート",
"+# 後は普通のナップザック",
"-dp = list2d(N + 1, TMAX, 0)",
"+dp = np.zeros((N + 1, TMAX), dtype=np.int64)",
"- for j in range(TMAX):",
"- dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])",
"- if j < T:",
"- dp[i + 1][j + a] = max(dp[i + 1][j + a], dp[i][j] + b)",
"-print((max(dp[N])))",
"+ dp[i + 1] = dp[i]",
"+ dp[i + 1, a : a + T] = np.maximum(dp[i + 1, a : a + T], dp[i, :T] + b)",
"+print((dp[N].max()))"
] | false | 0.237622 | 0.573892 | 0.414054 |
[
"s482142174",
"s201367787"
] |
u278057806
|
p02900
|
python
|
s835123598
|
s806795172
| 356 | 163 | 21,628 | 5,560 |
Accepted
|
Accepted
| 54.21 |
import numpy as np
# ユークリッドの互除法
def ea(x, y):
if x < y:
x, y = y, x
while x % y != 0:
x = x % y
x, y = y, x
return y
# 素因数分解
def pf(x, p):
for i in range(2, int(np.sqrt(x)) + 1):
cnt = 0
while x % i == 0:
x /= i
cnt += 1
if cnt != 0:
p.append([i, cnt])
if x != 1:
p.append([int(x), 1])
A, B = list(map(int, (input().split())))
p = []
gcd = ea(A, B)
pf(gcd, p)
ans = 0
p.insert(0, [1, 1])
for i in range(len(p)):
ans += 1
# print(p)
print(ans)
|
from math import sqrt
from fractions import gcd
A, B = list(map(int, input().split()))
ans = 1
g = gcd(A, B)
for i in range(2, 1 + int(sqrt(g))):
if g % i == 0:
ans += 1
while g % i == 0:
g //= i
if g != 1:
ans += 1
print(ans)
| 41 | 21 | 604 | 285 |
import numpy as np
# ユークリッドの互除法
def ea(x, y):
if x < y:
x, y = y, x
while x % y != 0:
x = x % y
x, y = y, x
return y
# 素因数分解
def pf(x, p):
for i in range(2, int(np.sqrt(x)) + 1):
cnt = 0
while x % i == 0:
x /= i
cnt += 1
if cnt != 0:
p.append([i, cnt])
if x != 1:
p.append([int(x), 1])
A, B = list(map(int, (input().split())))
p = []
gcd = ea(A, B)
pf(gcd, p)
ans = 0
p.insert(0, [1, 1])
for i in range(len(p)):
ans += 1
# print(p)
print(ans)
|
from math import sqrt
from fractions import gcd
A, B = list(map(int, input().split()))
ans = 1
g = gcd(A, B)
for i in range(2, 1 + int(sqrt(g))):
if g % i == 0:
ans += 1
while g % i == 0:
g //= i
if g != 1:
ans += 1
print(ans)
| false | 48.780488 |
[
"-import numpy as np",
"+from math import sqrt",
"+from fractions import gcd",
"-# ユークリッドの互除法",
"-def ea(x, y):",
"- if x < y:",
"- x, y = y, x",
"- while x % y != 0:",
"- x = x % y",
"- x, y = y, x",
"- return y",
"-",
"-",
"-# 素因数分解",
"-def pf(x, p):",
"- for i in range(2, int(np.sqrt(x)) + 1):",
"- cnt = 0",
"- while x % i == 0:",
"- x /= i",
"- cnt += 1",
"- if cnt != 0:",
"- p.append([i, cnt])",
"- if x != 1:",
"- p.append([int(x), 1])",
"-",
"-",
"-A, B = list(map(int, (input().split())))",
"-p = []",
"-gcd = ea(A, B)",
"-pf(gcd, p)",
"-ans = 0",
"-p.insert(0, [1, 1])",
"-for i in range(len(p)):",
"+A, B = list(map(int, input().split()))",
"+ans = 1",
"+g = gcd(A, B)",
"+for i in range(2, 1 + int(sqrt(g))):",
"+ if g % i == 0:",
"+ ans += 1",
"+ while g % i == 0:",
"+ g //= i",
"+if g != 1:",
"-# print(p)"
] | false | 0.519069 | 0.193494 | 2.682617 |
[
"s835123598",
"s806795172"
] |
u912237403
|
p02381
|
python
|
s597745512
|
s885507935
| 20 | 10 | 4,380 | 4,356 |
Accepted
|
Accepted
| 50 |
import sys
mode = 0
for line in sys.stdin:
if mode == 0:
n = int(line.strip('\n'))
if n == 0: break
mode = 1
elif mode == 1:
x = [float(i) for i in line.strip('\n').split()]
ave = sum(x) / n
std = (sum([(i-ave)**2 for i in x])/n)**0.5
print(std)
mode = 0
|
while True:
n = int(input())
if n == 0: break
x = list(map(int, input().split()))
ave = sum(x) / float(n)
std = (sum([(e-ave)**2 for e in x])/n)**0.5
print(std)
| 14 | 8 | 340 | 193 |
import sys
mode = 0
for line in sys.stdin:
if mode == 0:
n = int(line.strip("\n"))
if n == 0:
break
mode = 1
elif mode == 1:
x = [float(i) for i in line.strip("\n").split()]
ave = sum(x) / n
std = (sum([(i - ave) ** 2 for i in x]) / n) ** 0.5
print(std)
mode = 0
|
while True:
n = int(input())
if n == 0:
break
x = list(map(int, input().split()))
ave = sum(x) / float(n)
std = (sum([(e - ave) ** 2 for e in x]) / n) ** 0.5
print(std)
| false | 42.857143 |
[
"-import sys",
"-",
"-mode = 0",
"-for line in sys.stdin:",
"- if mode == 0:",
"- n = int(line.strip(\"\\n\"))",
"- if n == 0:",
"- break",
"- mode = 1",
"- elif mode == 1:",
"- x = [float(i) for i in line.strip(\"\\n\").split()]",
"- ave = sum(x) / n",
"- std = (sum([(i - ave) ** 2 for i in x]) / n) ** 0.5",
"- print(std)",
"- mode = 0",
"+while True:",
"+ n = int(input())",
"+ if n == 0:",
"+ break",
"+ x = list(map(int, input().split()))",
"+ ave = sum(x) / float(n)",
"+ std = (sum([(e - ave) ** 2 for e in x]) / n) ** 0.5",
"+ print(std)"
] | false | 0.040797 | 0.039629 | 1.029481 |
[
"s597745512",
"s885507935"
] |
u855057563
|
p03308
|
python
|
s365690520
|
s103446810
| 29 | 26 | 9,144 | 9,332 |
Accepted
|
Accepted
| 10.34 |
n=int(eval(input()))
s=[int(x) for x in input().split()]
print((max(s)-min(s)))
|
n=int(eval(input()))
s=[int(i) for i in input().split()]
a=[]
for i in range(n-1):
for j in range(i+1,n):
a.append(abs(s[i]-s[j]))
print((max(a)))
| 3 | 7 | 73 | 150 |
n = int(eval(input()))
s = [int(x) for x in input().split()]
print((max(s) - min(s)))
|
n = int(eval(input()))
s = [int(i) for i in input().split()]
a = []
for i in range(n - 1):
for j in range(i + 1, n):
a.append(abs(s[i] - s[j]))
print((max(a)))
| false | 57.142857 |
[
"-s = [int(x) for x in input().split()]",
"-print((max(s) - min(s)))",
"+s = [int(i) for i in input().split()]",
"+a = []",
"+for i in range(n - 1):",
"+ for j in range(i + 1, n):",
"+ a.append(abs(s[i] - s[j]))",
"+print((max(a)))"
] | false | 0.048608 | 0.049514 | 0.98171 |
[
"s365690520",
"s103446810"
] |
u630511239
|
p03733
|
python
|
s584856023
|
s147700939
| 148 | 129 | 25,196 | 30,816 |
Accepted
|
Accepted
| 12.84 |
N,T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = T
for i in range(1,N):
if t[i]-t[i-1] >= T:
ans += T
else:
ans += t[i] - t[i-1]
print(ans)
|
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = N * T # 総和
cur = 0 # いつまで出るか
for i in range(N):
if cur > t[i]:
ans -= cur - t[i]
cur = t[i] + T
print(ans)
| 10 | 9 | 188 | 205 |
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = T
for i in range(1, N):
if t[i] - t[i - 1] >= T:
ans += T
else:
ans += t[i] - t[i - 1]
print(ans)
|
N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = N * T # 総和
cur = 0 # いつまで出るか
for i in range(N):
if cur > t[i]:
ans -= cur - t[i]
cur = t[i] + T
print(ans)
| false | 10 |
[
"-ans = T",
"-for i in range(1, N):",
"- if t[i] - t[i - 1] >= T:",
"- ans += T",
"- else:",
"- ans += t[i] - t[i - 1]",
"+ans = N * T # 総和",
"+cur = 0 # いつまで出るか",
"+for i in range(N):",
"+ if cur > t[i]:",
"+ ans -= cur - t[i]",
"+ cur = t[i] + T"
] | false | 0.040794 | 0.042129 | 0.968295 |
[
"s584856023",
"s147700939"
] |
u936985471
|
p03013
|
python
|
s653702265
|
s970058313
| 102 | 68 | 14,308 | 19,020 |
Accepted
|
Accepted
| 33.33 |
n,m,*a=list(map(int,open(0).read().split()))
a=set(a)
dp=[0]*(n+2)
dp[0]=1
div=1000000007
for i in range(n):
dp[i]%=div
if i+1 in a:
dp[i+1]=0
else:
dp[i+1]+=dp[i]
if i+2 in a:
dp[i+2]=0
else:
dp[i+2]+=dp[i]
print((dp[n]%div))
|
import sys
readline = sys.stdin.readline
N,M = list(map(int,readline().split()))
broken = set([int(readline()) for i in range(M)])
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in broken:
dp[1] = 1
DIV = 10 ** 9 + 7
for i in range(2, N + 1):
if i in broken:
continue
dp[i] = dp[i - 2] + dp[i - 1]
dp[i] %= DIV
print((dp[N]))
| 16 | 21 | 259 | 350 |
n, m, *a = list(map(int, open(0).read().split()))
a = set(a)
dp = [0] * (n + 2)
dp[0] = 1
div = 1000000007
for i in range(n):
dp[i] %= div
if i + 1 in a:
dp[i + 1] = 0
else:
dp[i + 1] += dp[i]
if i + 2 in a:
dp[i + 2] = 0
else:
dp[i + 2] += dp[i]
print((dp[n] % div))
|
import sys
readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
broken = set([int(readline()) for i in range(M)])
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in broken:
dp[1] = 1
DIV = 10**9 + 7
for i in range(2, N + 1):
if i in broken:
continue
dp[i] = dp[i - 2] + dp[i - 1]
dp[i] %= DIV
print((dp[N]))
| false | 23.809524 |
[
"-n, m, *a = list(map(int, open(0).read().split()))",
"-a = set(a)",
"-dp = [0] * (n + 2)",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+N, M = list(map(int, readline().split()))",
"+broken = set([int(readline()) for i in range(M)])",
"+dp = [0] * (N + 1)",
"-div = 1000000007",
"-for i in range(n):",
"- dp[i] %= div",
"- if i + 1 in a:",
"- dp[i + 1] = 0",
"- else:",
"- dp[i + 1] += dp[i]",
"- if i + 2 in a:",
"- dp[i + 2] = 0",
"- else:",
"- dp[i + 2] += dp[i]",
"-print((dp[n] % div))",
"+if 1 not in broken:",
"+ dp[1] = 1",
"+DIV = 10**9 + 7",
"+for i in range(2, N + 1):",
"+ if i in broken:",
"+ continue",
"+ dp[i] = dp[i - 2] + dp[i - 1]",
"+ dp[i] %= DIV",
"+print((dp[N]))"
] | false | 0.042137 | 0.042548 | 0.990322 |
[
"s653702265",
"s970058313"
] |
u334712262
|
p02902
|
python
|
s435779684
|
s080169941
| 355 | 322 | 47,964 | 46,040 |
Accepted
|
Accepted
| 9.3 |
# -*- coding: utf-8 -*-
from collections import defaultdict
from collections import deque
import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def read_float():
return float(buff_readline())
def read_float_n():
return list(map(float, buff_readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
def slv(N, M, AB):
g = defaultdict(list)
for a, b in AB:
g[a].append(b)
def bfs(s):
q = deque([s])
done = {}
done[s] = 0
prev = {}
goal = None
while q:
u = q.popleft()
for v in g[u]:
if v not in done:
done[v] = done[u] + 1
prev[v] = u
q.append(v)
if v == s:
goal = u
break
if goal is None:
return None
v = goal
ans = [s]
while v in prev:
ans.append(v)
v = prev[v]
return ans
ans = [0] * (2*N)
for i in range(1, N+1):
a = bfs(i)
if a and len(ans) > len(a):
ans = a
if len(ans) == (2*N):
print(-1)
return
print(len(ans))
print(*ans, sep='\n')
def main():
N, M = read_int_n()
AB = [read_int_n() for _ in range(M)]
slv(N, M, AB)
if __name__ == '__main__':
main()
|
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def read_float():
return float(buff_readline())
def read_float_n():
return list(map(float, buff_readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(N, M, AB):
from collections import defaultdict, deque
g = defaultdict(list)
for a, b in AB:
g[a].append(b)
def bfs(s):
q = deque()
q.append(s)
prev = {}
while q:
u = q.popleft()
for v in g[u]:
if v in prev:
continue
q.append(v)
prev[v] = u
if v == s:
break
if s not in prev:
return None
cycle = [s]
v = s
while True:
v = prev[v]
if v == s:
break
cycle.append(v)
return cycle
ans = None
for i in range(1, N+1):
t = bfs(i)
if t is not None:
if ans is None:
ans = t
else:
ans = t if len(t) < len(ans) else ans
if ans is not None:
return [len(ans)] + ans
return [-1]
def main():
N, M = read_int_n()
AB = [read_int_n() for _ in range(M)]
print(*slv(N, M, AB), sep='\n')
if __name__ == '__main__':
main()
| 104 | 107 | 1,999 | 2,047 |
# -*- coding: utf-8 -*-
from collections import defaultdict
from collections import deque
import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def read_float():
return float(buff_readline())
def read_float_n():
return list(map(float, buff_readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
def slv(N, M, AB):
g = defaultdict(list)
for a, b in AB:
g[a].append(b)
def bfs(s):
q = deque([s])
done = {}
done[s] = 0
prev = {}
goal = None
while q:
u = q.popleft()
for v in g[u]:
if v not in done:
done[v] = done[u] + 1
prev[v] = u
q.append(v)
if v == s:
goal = u
break
if goal is None:
return None
v = goal
ans = [s]
while v in prev:
ans.append(v)
v = prev[v]
return ans
ans = [0] * (2 * N)
for i in range(1, N + 1):
a = bfs(i)
if a and len(ans) > len(a):
ans = a
if len(ans) == (2 * N):
print(-1)
return
print(len(ans))
print(*ans, sep="\n")
def main():
N, M = read_int_n()
AB = [read_int_n() for _ in range(M)]
slv(N, M, AB)
if __name__ == "__main__":
main()
|
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def read_float():
return float(buff_readline())
def read_float_n():
return list(map(float, buff_readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
@mt
def slv(N, M, AB):
from collections import defaultdict, deque
g = defaultdict(list)
for a, b in AB:
g[a].append(b)
def bfs(s):
q = deque()
q.append(s)
prev = {}
while q:
u = q.popleft()
for v in g[u]:
if v in prev:
continue
q.append(v)
prev[v] = u
if v == s:
break
if s not in prev:
return None
cycle = [s]
v = s
while True:
v = prev[v]
if v == s:
break
cycle.append(v)
return cycle
ans = None
for i in range(1, N + 1):
t = bfs(i)
if t is not None:
if ans is None:
ans = t
else:
ans = t if len(t) < len(ans) else ans
if ans is not None:
return [len(ans)] + ans
return [-1]
def main():
N, M = read_int_n()
AB = [read_int_n() for _ in range(M)]
print(*slv(N, M, AB), sep="\n")
if __name__ == "__main__":
main()
| false | 2.803738 |
[
"-from collections import defaultdict",
"-from collections import deque",
"-buff_readline = sys.stdin.buffer.readline",
"+# buff_readline = sys.stdin.buffer.readline",
"+buff_readline = sys.stdin.readline",
"+@mt",
"+ from collections import defaultdict, deque",
"+",
"- q = deque([s])",
"- done = {}",
"- done[s] = 0",
"+ q = deque()",
"+ q.append(s)",
"- goal = None",
"- if v not in done:",
"- done[v] = done[u] + 1",
"- prev[v] = u",
"- q.append(v)",
"+ if v in prev:",
"+ continue",
"+ q.append(v)",
"+ prev[v] = u",
"- goal = u",
"- if goal is None:",
"+ if s not in prev:",
"- v = goal",
"- ans = [s]",
"- while v in prev:",
"- ans.append(v)",
"+ cycle = [s]",
"+ v = s",
"+ while True:",
"- return ans",
"+ if v == s:",
"+ break",
"+ cycle.append(v)",
"+ return cycle",
"- ans = [0] * (2 * N)",
"+ ans = None",
"- a = bfs(i)",
"- if a and len(ans) > len(a):",
"- ans = a",
"- if len(ans) == (2 * N):",
"- print(-1)",
"- return",
"- print(len(ans))",
"- print(*ans, sep=\"\\n\")",
"+ t = bfs(i)",
"+ if t is not None:",
"+ if ans is None:",
"+ ans = t",
"+ else:",
"+ ans = t if len(t) < len(ans) else ans",
"+ if ans is not None:",
"+ return [len(ans)] + ans",
"+ return [-1]",
"- slv(N, M, AB)",
"+ print(*slv(N, M, AB), sep=\"\\n\")"
] | false | 0.039662 | 0.038467 | 1.031054 |
[
"s435779684",
"s080169941"
] |
u761320129
|
p03945
|
python
|
s056593375
|
s290524460
| 34 | 24 | 3,188 | 4,060 |
Accepted
|
Accepted
| 29.41 |
S = eval(input())
ans = 0
for a,b in zip(S,S[1:]):
if a != b:
ans += 1
print(ans)
|
S = eval(input())
ans = len([1 for a,b in zip(S,S[1:]) if a!=b])
print(ans)
| 6 | 3 | 92 | 71 |
S = eval(input())
ans = 0
for a, b in zip(S, S[1:]):
if a != b:
ans += 1
print(ans)
|
S = eval(input())
ans = len([1 for a, b in zip(S, S[1:]) if a != b])
print(ans)
| false | 50 |
[
"-ans = 0",
"-for a, b in zip(S, S[1:]):",
"- if a != b:",
"- ans += 1",
"+ans = len([1 for a, b in zip(S, S[1:]) if a != b])"
] | false | 0.041966 | 0.078294 | 0.536 |
[
"s056593375",
"s290524460"
] |
u426534722
|
p02412
|
python
|
s123199820
|
s893091180
| 460 | 330 | 5,640 | 5,648 |
Accepted
|
Accepted
| 28.26 |
from itertools import combinations
while True:
n, x = list(map(int, input().split()))
if n == x == 0:
break
print((sum(a + b + c == x for a, b, c in combinations(list(range(1, n + 1)), 3))))
|
from itertools import combinations
while True:
n, x = list(map(int, input().split()))
if n == x == 0:
break
print((len([1 for a, b, c in combinations(list(range(1, n + 1)), 3) if a + b + c == x])))
| 7 | 7 | 204 | 211 |
from itertools import combinations
while True:
n, x = list(map(int, input().split()))
if n == x == 0:
break
print((sum(a + b + c == x for a, b, c in combinations(list(range(1, n + 1)), 3))))
|
from itertools import combinations
while True:
n, x = list(map(int, input().split()))
if n == x == 0:
break
print(
(
len(
[
1
for a, b, c in combinations(list(range(1, n + 1)), 3)
if a + b + c == x
]
)
)
)
| false | 0 |
[
"- print((sum(a + b + c == x for a, b, c in combinations(list(range(1, n + 1)), 3))))",
"+ print(",
"+ (",
"+ len(",
"+ [",
"+ 1",
"+ for a, b, c in combinations(list(range(1, n + 1)), 3)",
"+ if a + b + c == x",
"+ ]",
"+ )",
"+ )",
"+ )"
] | false | 0.102368 | 0.048973 | 2.090287 |
[
"s123199820",
"s893091180"
] |
u864197622
|
p02666
|
python
|
s420556826
|
s457578851
| 383 | 288 | 10,612 | 78,752 |
Accepted
|
Accepted
| 24.8 |
def par(a):
L = []
while P[a] != a:
L.append(a)
a = P[a]
for l in L:
P[l] = a
return a
def unite(a, b):
pa = par(a)
pb = par(b)
if pa == pb: return
if LEN[pa] < LEN[pb]:
a, b, pa, pb = b, a, pb, pa
P[pb] = pa
if LEN[pa] == LEN[pb]: LEN[pa] += 1
CNT[pa] += CNT[pb]
def cnt(a):
return CNT[par(a)]
N = int(eval(input()))
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
if a < 0: continue
if par(i) != par(a):
unite(i, a)
else:
FULL[i] = 1
for i in range(N):
if FULL[i]:
FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
if par(i) == i:
if FULL[i] == 0:
X.append(CNT[i])
else:
Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
K = 96
m = int(("1" * 32 + "0" * 64) * 5050, 2)
pa = (1 << 64) - ((1 << 64) % mod)
modP = lambda x: x - ((x & m) >> 64) * pa
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
x = 1
for i, a in enumerate(X):
x *= (a << K) + 1
x = modP(x)
sx = bin(x)[2:] + "_"
L = [int(sx[-(i+1) * K - 1:-i * K - 1], 2) % mod for i in range((len(sx)+K-2) // K)]
fa = 1
ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
if i == 0: continue
ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
fa = fa * i % mod
print(ans)
|
def par(a):
L = []
while P[a] != a:
L.append(a)
a = P[a]
for l in L:
P[l] = a
return a
def unite(a, b):
pa = par(a)
pb = par(b)
if pa == pb: return
if LEN[pa] < LEN[pb]:
a, b, pa, pb = b, a, pb, pa
P[pb] = pa
if LEN[pa] == LEN[pb]: LEN[pa] += 1
CNT[pa] += CNT[pb]
def cnt(a):
return CNT[par(a)]
N = int(eval(input()))
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
if a < 0: continue
if par(i) != par(a):
unite(i, a)
else:
FULL[i] = 1
for i in range(N):
if FULL[i]:
FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
if par(i) == i:
if FULL[i] == 0:
X.append(CNT[i])
else:
Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
K = 96
m = int(("1" * 32 + "0" * 64) * 5050, 2)
pa = (1 << 64) - ((1 << 64) % mod)
modP = lambda x: x - ((x & m) >> 64) * pa
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
x = 1
for i, a in enumerate(X):
x *= (a << K) + 1
x = modP(x)
sx = bin(x)[2:] + "_"
L = [int(sx[-(i+1) * K - 1:-i * K - 1], 2) % mod for i in range((len(sx)+K-2) // K)]
if M:
fa = 1
ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
if i == 0: continue
ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
fa = fa * i % mod
print(ans)
| 64 | 65 | 1,485 | 1,516 |
def par(a):
L = []
while P[a] != a:
L.append(a)
a = P[a]
for l in L:
P[l] = a
return a
def unite(a, b):
pa = par(a)
pb = par(b)
if pa == pb:
return
if LEN[pa] < LEN[pb]:
a, b, pa, pb = b, a, pb, pa
P[pb] = pa
if LEN[pa] == LEN[pb]:
LEN[pa] += 1
CNT[pa] += CNT[pb]
def cnt(a):
return CNT[par(a)]
N = int(eval(input()))
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
if a < 0:
continue
if par(i) != par(a):
unite(i, a)
else:
FULL[i] = 1
for i in range(N):
if FULL[i]:
FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
if par(i) == i:
if FULL[i] == 0:
X.append(CNT[i])
else:
Y.append(CNT[i])
M = len(X)
mod = 10**9 + 7
K = 96
m = int(("1" * 32 + "0" * 64) * 5050, 2)
pa = (1 << 64) - ((1 << 64) % mod)
modP = lambda x: x - ((x & m) >> 64) * pa
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
x = 1
for i, a in enumerate(X):
x *= (a << K) + 1
x = modP(x)
sx = bin(x)[2:] + "_"
L = [
int(sx[-(i + 1) * K - 1 : -i * K - 1], 2) % mod
for i in range((len(sx) + K - 2) // K)
]
fa = 1
ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
if i == 0:
continue
ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
fa = fa * i % mod
print(ans)
|
def par(a):
L = []
while P[a] != a:
L.append(a)
a = P[a]
for l in L:
P[l] = a
return a
def unite(a, b):
pa = par(a)
pb = par(b)
if pa == pb:
return
if LEN[pa] < LEN[pb]:
a, b, pa, pb = b, a, pb, pa
P[pb] = pa
if LEN[pa] == LEN[pb]:
LEN[pa] += 1
CNT[pa] += CNT[pb]
def cnt(a):
return CNT[par(a)]
N = int(eval(input()))
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
if a < 0:
continue
if par(i) != par(a):
unite(i, a)
else:
FULL[i] = 1
for i in range(N):
if FULL[i]:
FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
if par(i) == i:
if FULL[i] == 0:
X.append(CNT[i])
else:
Y.append(CNT[i])
M = len(X)
mod = 10**9 + 7
K = 96
m = int(("1" * 32 + "0" * 64) * 5050, 2)
pa = (1 << 64) - ((1 << 64) % mod)
modP = lambda x: x - ((x & m) >> 64) * pa
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
x = 1
for i, a in enumerate(X):
x *= (a << K) + 1
x = modP(x)
sx = bin(x)[2:] + "_"
L = [
int(sx[-(i + 1) * K - 1 : -i * K - 1], 2) % mod
for i in range((len(sx) + K - 2) // K)
]
if M:
fa = 1
ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
if i == 0:
continue
ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
fa = fa * i % mod
print(ans)
| false | 1.538462 |
[
"-fa = 1",
"-ans = (ans + M * pow(N - 1, M - 1, mod)) % mod",
"-for i, l in enumerate(L):",
"- if i == 0:",
"- continue",
"- ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod",
"- fa = fa * i % mod",
"+if M:",
"+ fa = 1",
"+ ans = (ans + M * pow(N - 1, M - 1, mod)) % mod",
"+ for i, l in enumerate(L):",
"+ if i == 0:",
"+ continue",
"+ ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod",
"+ fa = fa * i % mod"
] | false | 0.06655 | 0.039247 | 1.695702 |
[
"s420556826",
"s457578851"
] |
u945181840
|
p03026
|
python
|
s283083821
|
s019214000
| 48 | 44 | 6,864 | 6,864 |
Accepted
|
Accepted
| 8.33 |
import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
N, *abc = list(map(int, read().split()))
c = abc[2 * (N - 1):]
c.sort()
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for a, b in zip(*[iter(abc[:2 * (N - 1)])] * 2):
graph[a].append(b)
graph[b].append(a)
cnt[a] += 1
cnt[b] += 1
m = max(cnt)
nodes = [0] * (N + 1)
score = sum(c) - c[-1]
start = cnt.index(max(cnt))
nodes[start] = c.pop()
queue = deque([start])
while queue:
V = queue.popleft()
for v in graph[V]:
if nodes[v] == 0:
nodes[v] = c.pop()
queue.append(v)
print(score)
print((' '.join(map(str, nodes[1:]))))
|
import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
N, *abc = list(map(int, read().split()))
c = abc[2 * (N - 1):]
c.sort()
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for a, b in zip(*[iter(abc[:2 * (N - 1)])] * 2):
graph[a].append(b)
graph[b].append(a)
m = max(cnt)
nodes = [0] * (N + 1)
score = sum(c) - c[-1]
start = 1
nodes[start] = c.pop()
queue = deque([start])
while queue:
V = queue.popleft()
for v in graph[V]:
if nodes[v] == 0:
nodes[v] = c.pop()
queue.append(v)
print(score)
print((' '.join(map(str, nodes[1:]))))
| 32 | 30 | 703 | 651 |
import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
N, *abc = list(map(int, read().split()))
c = abc[2 * (N - 1) :]
c.sort()
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for a, b in zip(*[iter(abc[: 2 * (N - 1)])] * 2):
graph[a].append(b)
graph[b].append(a)
cnt[a] += 1
cnt[b] += 1
m = max(cnt)
nodes = [0] * (N + 1)
score = sum(c) - c[-1]
start = cnt.index(max(cnt))
nodes[start] = c.pop()
queue = deque([start])
while queue:
V = queue.popleft()
for v in graph[V]:
if nodes[v] == 0:
nodes[v] = c.pop()
queue.append(v)
print(score)
print((" ".join(map(str, nodes[1:]))))
|
import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.readline
N, *abc = list(map(int, read().split()))
c = abc[2 * (N - 1) :]
c.sort()
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for a, b in zip(*[iter(abc[: 2 * (N - 1)])] * 2):
graph[a].append(b)
graph[b].append(a)
m = max(cnt)
nodes = [0] * (N + 1)
score = sum(c) - c[-1]
start = 1
nodes[start] = c.pop()
queue = deque([start])
while queue:
V = queue.popleft()
for v in graph[V]:
if nodes[v] == 0:
nodes[v] = c.pop()
queue.append(v)
print(score)
print((" ".join(map(str, nodes[1:]))))
| false | 6.25 |
[
"- cnt[a] += 1",
"- cnt[b] += 1",
"-start = cnt.index(max(cnt))",
"+start = 1"
] | false | 0.036536 | 0.036488 | 1.001306 |
[
"s283083821",
"s019214000"
] |
u687044304
|
p02813
|
python
|
s351447063
|
s813904035
| 1,287 | 34 | 8,432 | 8,052 |
Accepted
|
Accepted
| 97.36 |
# -*- coding:utf-8 -*-
import copy
def solve():
N = int(eval(input()))
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))
available_list = [i for i in range(1, N+1)]
permutations = [] # 順列
def _dfs(rest_list, p):
if len(rest_list) == 0:
permutations.append(tuple(p))
return
for i in range(1, N+1):
if i in rest_list:
tmp_rest_list = copy.deepcopy(rest_list)
tmp_rest_list.remove(i)
tmp_p = copy.deepcopy(p)
tmp_p.append(i)
_dfs(tmp_rest_list, tmp_p)
_dfs(available_list, [])
permutations.sort()
for i, p in enumerate(permutations):
if p == Ps:
a = i+1
if p == Qs:
b = i+1
print((abs(a-b)))
if __name__ == "__main__":
solve()
|
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/abc150/tasks/abc150_c
def solve():
import itertools
import bisect
N = int(eval(input()))
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))
lst = [i for i in range(1, N+1)]
origins = list(itertools.permutations(lst, r=N))
origins.sort()
for i, p in enumerate(origins):
if p == Ps:
a = i
if p == Qs:
b = i
print((abs(a-b)))
if __name__ == "__main__":
solve()
| 40 | 27 | 909 | 546 |
# -*- coding:utf-8 -*-
import copy
def solve():
N = int(eval(input()))
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))
available_list = [i for i in range(1, N + 1)]
permutations = [] # 順列
def _dfs(rest_list, p):
if len(rest_list) == 0:
permutations.append(tuple(p))
return
for i in range(1, N + 1):
if i in rest_list:
tmp_rest_list = copy.deepcopy(rest_list)
tmp_rest_list.remove(i)
tmp_p = copy.deepcopy(p)
tmp_p.append(i)
_dfs(tmp_rest_list, tmp_p)
_dfs(available_list, [])
permutations.sort()
for i, p in enumerate(permutations):
if p == Ps:
a = i + 1
if p == Qs:
b = i + 1
print((abs(a - b)))
if __name__ == "__main__":
solve()
|
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/abc150/tasks/abc150_c
def solve():
import itertools
import bisect
N = int(eval(input()))
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))
lst = [i for i in range(1, N + 1)]
origins = list(itertools.permutations(lst, r=N))
origins.sort()
for i, p in enumerate(origins):
if p == Ps:
a = i
if p == Qs:
b = i
print((abs(a - b)))
if __name__ == "__main__":
solve()
| false | 32.5 |
[
"-import copy",
"+# https://atcoder.jp/contests/abc150/tasks/abc150_c",
"+def solve():",
"+ import itertools",
"+ import bisect",
"-",
"-def solve():",
"- available_list = [i for i in range(1, N + 1)]",
"- permutations = [] # 順列",
"-",
"- def _dfs(rest_list, p):",
"- if len(rest_list) == 0:",
"- permutations.append(tuple(p))",
"- return",
"- for i in range(1, N + 1):",
"- if i in rest_list:",
"- tmp_rest_list = copy.deepcopy(rest_list)",
"- tmp_rest_list.remove(i)",
"- tmp_p = copy.deepcopy(p)",
"- tmp_p.append(i)",
"- _dfs(tmp_rest_list, tmp_p)",
"-",
"- _dfs(available_list, [])",
"- permutations.sort()",
"- for i, p in enumerate(permutations):",
"+ lst = [i for i in range(1, N + 1)]",
"+ origins = list(itertools.permutations(lst, r=N))",
"+ origins.sort()",
"+ for i, p in enumerate(origins):",
"- a = i + 1",
"+ a = i",
"- b = i + 1",
"+ b = i"
] | false | 0.110592 | 0.042029 | 2.631325 |
[
"s351447063",
"s813904035"
] |
u761989513
|
p03017
|
python
|
s739751168
|
s009646993
| 104 | 89 | 4,916 | 4,984 |
Accepted
|
Accepted
| 14.42 |
n, a, b, c, d = list(map(int, input().split()))
s = list(eval(input()))
last = ""
for i in range(a, c):
if last == "#" and s[i] == "#":
print("No")
exit()
last = s[i]
last = ""
for i in range(b, d):
if last == "#" and s[i] == "#":
print("No")
exit()
last = s[i]
last = ""
if c > d:
flag = True
s[b - 1] = "#"
for i in range(a, c):
if last == "#" and s[i] == "#":
flag = False
last = s[i]
s[b - 1] = "."
count = 0
for i in range(b - 1, d + 1):
if s[i] == ".":
count += 1
if count == 3:
flag = True
else:
count = 0
if flag:
print("Yes")
else:
print("No")
else:
print("Yes")
|
n, a, b, c, d = list(map(int, input().split()))
s = list(eval(input()))
last = ""
for i in range(a, max(c, d)):
if last == "#" and s[i] == "#":
print("No")
exit()
last = s[i]
flag = False
if c > d:
s[b - 1] = "#"
for i in range(a, c):
if last == "#" and s[i] == "#":
flag = True
last = s[i]
s[b - 1] = "."
count = 0
for i in range(b - 1, d + 1):
if s[i] == ".":
count += 1
if count == 3:
flag = False
else:
count = 0
else:
for i in range(b, d):
if last == "#" and s[i] == "#":
flag = True
last = s[i]
if not flag:
print("Yes")
else:
print("No")
| 37 | 33 | 792 | 745 |
n, a, b, c, d = list(map(int, input().split()))
s = list(eval(input()))
last = ""
for i in range(a, c):
if last == "#" and s[i] == "#":
print("No")
exit()
last = s[i]
last = ""
for i in range(b, d):
if last == "#" and s[i] == "#":
print("No")
exit()
last = s[i]
last = ""
if c > d:
flag = True
s[b - 1] = "#"
for i in range(a, c):
if last == "#" and s[i] == "#":
flag = False
last = s[i]
s[b - 1] = "."
count = 0
for i in range(b - 1, d + 1):
if s[i] == ".":
count += 1
if count == 3:
flag = True
else:
count = 0
if flag:
print("Yes")
else:
print("No")
else:
print("Yes")
|
n, a, b, c, d = list(map(int, input().split()))
s = list(eval(input()))
last = ""
for i in range(a, max(c, d)):
if last == "#" and s[i] == "#":
print("No")
exit()
last = s[i]
flag = False
if c > d:
s[b - 1] = "#"
for i in range(a, c):
if last == "#" and s[i] == "#":
flag = True
last = s[i]
s[b - 1] = "."
count = 0
for i in range(b - 1, d + 1):
if s[i] == ".":
count += 1
if count == 3:
flag = False
else:
count = 0
else:
for i in range(b, d):
if last == "#" and s[i] == "#":
flag = True
last = s[i]
if not flag:
print("Yes")
else:
print("No")
| false | 10.810811 |
[
"-for i in range(a, c):",
"+for i in range(a, max(c, d)):",
"-last = \"\"",
"-for i in range(b, d):",
"- if last == \"#\" and s[i] == \"#\":",
"- print(\"No\")",
"- exit()",
"- last = s[i]",
"-last = \"\"",
"+flag = False",
"- flag = True",
"- flag = False",
"+ flag = True",
"- flag = True",
"+ flag = False",
"- if flag:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"+ for i in range(b, d):",
"+ if last == \"#\" and s[i] == \"#\":",
"+ flag = True",
"+ last = s[i]",
"+if not flag:",
"+else:",
"+ print(\"No\")"
] | false | 0.044439 | 0.071868 | 0.618335 |
[
"s739751168",
"s009646993"
] |
u325956328
|
p02616
|
python
|
s506792209
|
s943707816
| 240 | 143 | 31,464 | 31,784 |
Accepted
|
Accepted
| 40.42 |
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
pos = []
neg = []
for a in A:
if a >= 0:
pos.append(a)
else:
neg.append(a)
flag = False # 積を正にできるか
if N == K:
ans = 1
for a in A:
ans *= a
ans %= MOD
print((ans % MOD))
exit()
if len(pos) > 0:
flag = True
else:
if K % 2 == 0:
flag = True
ans = 1
if not flag:
# 積を正にできないとき
# 絶対値の小さい方からK個とる
h = [abs(x) for x in A]
heapq.heapify(h)
for i in range(K):
ans *= heapq.heappop(h)
ans %= MOD
ans *= -1
else:
hpos = [-x for x in pos]
heapq.heapify(hpos)
hneg = neg[:]
heapq.heapify(hneg)
if K % 2 == 1:
# Kが奇数の時
# 一番大きい偶数を1つとる。
ans *= -heapq.heappop(hpos)
ans %= MOD
# pos, neg sort -> 2個ずつペア -> 降順sort -> 上から K//2 個とる
pairs = []
while len(hpos) >= 2:
x = -heapq.heappop(hpos)
x *= -heapq.heappop(hpos)
heapq.heappush(pairs, -x)
while len(hneg) >= 2:
x = heapq.heappop(hneg)
x *= heapq.heappop(hneg)
heapq.heappush(pairs, -x)
if len(pairs):
for i in range(K // 2):
ans *= -heapq.heappop(pairs)
ans %= MOD
print((ans % MOD))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
pos = []
neg = []
for a in A:
if a >= 0:
pos.append(a)
else:
neg.append(a)
flag = False # 積を正にできるか
if N == K:
ans = 1
for a in A:
ans *= a
ans %= MOD
print((ans % MOD))
exit()
if len(pos) > 0:
flag = True
else:
if K % 2 == 0:
flag = True
ans = 1
if not flag:
# 積を正にできないとき
# 絶対値の小さい方からK個とる
A = sorted([abs(x) for x in A])
for a in A[:K]:
ans *= a
ans %= MOD
ans *= -1
else:
pos = sorted(pos)
neg = sorted(neg, reverse=True)
if K % 2 == 1:
# Kが奇数の時
# 一番大きい偶数を1つとる。
ans *= pos.pop()
ans %= MOD
# pos, neg sort -> 2個ずつペア -> 降順sort -> 上から K//2 個とる
pairs = []
while len(pos) >= 2:
x = pos.pop()
x *= pos.pop()
pairs.append(x)
while len(neg) >= 2:
x = neg.pop()
x *= neg.pop()
pairs.append(x)
pairs = sorted(pairs, reverse=True)
for p in pairs[: K // 2]:
ans *= p
ans %= MOD
print((ans % MOD))
if __name__ == '__main__':
main()
| 79 | 74 | 1,719 | 1,552 |
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
pos = []
neg = []
for a in A:
if a >= 0:
pos.append(a)
else:
neg.append(a)
flag = False # 積を正にできるか
if N == K:
ans = 1
for a in A:
ans *= a
ans %= MOD
print((ans % MOD))
exit()
if len(pos) > 0:
flag = True
else:
if K % 2 == 0:
flag = True
ans = 1
if not flag:
# 積を正にできないとき
# 絶対値の小さい方からK個とる
h = [abs(x) for x in A]
heapq.heapify(h)
for i in range(K):
ans *= heapq.heappop(h)
ans %= MOD
ans *= -1
else:
hpos = [-x for x in pos]
heapq.heapify(hpos)
hneg = neg[:]
heapq.heapify(hneg)
if K % 2 == 1:
# Kが奇数の時
# 一番大きい偶数を1つとる。
ans *= -heapq.heappop(hpos)
ans %= MOD
# pos, neg sort -> 2個ずつペア -> 降順sort -> 上から K//2 個とる
pairs = []
while len(hpos) >= 2:
x = -heapq.heappop(hpos)
x *= -heapq.heappop(hpos)
heapq.heappush(pairs, -x)
while len(hneg) >= 2:
x = heapq.heappop(hneg)
x *= heapq.heappop(hneg)
heapq.heappush(pairs, -x)
if len(pairs):
for i in range(K // 2):
ans *= -heapq.heappop(pairs)
ans %= MOD
print((ans % MOD))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
pos = []
neg = []
for a in A:
if a >= 0:
pos.append(a)
else:
neg.append(a)
flag = False # 積を正にできるか
if N == K:
ans = 1
for a in A:
ans *= a
ans %= MOD
print((ans % MOD))
exit()
if len(pos) > 0:
flag = True
else:
if K % 2 == 0:
flag = True
ans = 1
if not flag:
# 積を正にできないとき
# 絶対値の小さい方からK個とる
A = sorted([abs(x) for x in A])
for a in A[:K]:
ans *= a
ans %= MOD
ans *= -1
else:
pos = sorted(pos)
neg = sorted(neg, reverse=True)
if K % 2 == 1:
# Kが奇数の時
# 一番大きい偶数を1つとる。
ans *= pos.pop()
ans %= MOD
# pos, neg sort -> 2個ずつペア -> 降順sort -> 上から K//2 個とる
pairs = []
while len(pos) >= 2:
x = pos.pop()
x *= pos.pop()
pairs.append(x)
while len(neg) >= 2:
x = neg.pop()
x *= neg.pop()
pairs.append(x)
pairs = sorted(pairs, reverse=True)
for p in pairs[: K // 2]:
ans *= p
ans %= MOD
print((ans % MOD))
if __name__ == "__main__":
main()
| false | 6.329114 |
[
"-import heapq",
"- h = [abs(x) for x in A]",
"- heapq.heapify(h)",
"- for i in range(K):",
"- ans *= heapq.heappop(h)",
"+ A = sorted([abs(x) for x in A])",
"+ for a in A[:K]:",
"+ ans *= a",
"- hpos = [-x for x in pos]",
"- heapq.heapify(hpos)",
"- hneg = neg[:]",
"- heapq.heapify(hneg)",
"+ pos = sorted(pos)",
"+ neg = sorted(neg, reverse=True)",
"- ans *= -heapq.heappop(hpos)",
"+ ans *= pos.pop()",
"- while len(hpos) >= 2:",
"- x = -heapq.heappop(hpos)",
"- x *= -heapq.heappop(hpos)",
"- heapq.heappush(pairs, -x)",
"- while len(hneg) >= 2:",
"- x = heapq.heappop(hneg)",
"- x *= heapq.heappop(hneg)",
"- heapq.heappush(pairs, -x)",
"- if len(pairs):",
"- for i in range(K // 2):",
"- ans *= -heapq.heappop(pairs)",
"- ans %= MOD",
"+ while len(pos) >= 2:",
"+ x = pos.pop()",
"+ x *= pos.pop()",
"+ pairs.append(x)",
"+ while len(neg) >= 2:",
"+ x = neg.pop()",
"+ x *= neg.pop()",
"+ pairs.append(x)",
"+ pairs = sorted(pairs, reverse=True)",
"+ for p in pairs[: K // 2]:",
"+ ans *= p",
"+ ans %= MOD"
] | false | 0.044424 | 0.055767 | 0.796592 |
[
"s506792209",
"s943707816"
] |
u596505843
|
p02901
|
python
|
s005261488
|
s201247474
| 796 | 447 | 125,404 | 49,756 |
Accepted
|
Accepted
| 43.84 |
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(eval(input()))
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7
N, M = rl()
A = []
Cs = []
for i in range(M):
a, b = rl()
C = rl()
A.append(a)
Cs.append(C)
def get_bit(C):
b = 0
for c in C:
b = b | (1 << (c-1))
return b
bits =[]
for C in Cs:
b = get_bit(C)
bits.append(b)
start = 0
end = 2**N-1
import heapq
heap = []
heapq.heappush(heap, (0, start))
visited = {}
ans = -1
while heap:
c, n = heapq.heappop(heap)
if n in visited:
continue
if n == end:
ans = c
break
visited[n] = 1
for i, b in enumerate(bits):
m = n | b
if m in visited:
continue
cost = A[i]
heapq.heappush(heap, (c + cost, m))
print(ans)
|
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(eval(input()))
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7
N, M = rl()
A = []
Cs = []
for i in range(M):
a, b = rl()
C = rl()
A.append(a)
Cs.append(C)
def get_bit(C):
b = 0
for c in C:
b = b | (1 << (c-1))
return b
bits =[]
for C in Cs:
b = get_bit(C)
bits.append(b)
start = 0
end = 2**N-1
import heapq
heap = []
heapq.heappush(heap, (0, start))
visited = {}
ans = -1
while heap:
c, n = heapq.heappop(heap)
if n == end:
ans = c
break
for i, b in enumerate(bits):
m = n | b
nc = c + A[i]
if m in visited and nc >= visited[m]:
continue
visited[m] = nc
heapq.heappush(heap, (nc, m))
print(ans)
| 51 | 49 | 789 | 777 |
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(eval(input()))
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7
N, M = rl()
A = []
Cs = []
for i in range(M):
a, b = rl()
C = rl()
A.append(a)
Cs.append(C)
def get_bit(C):
b = 0
for c in C:
b = b | (1 << (c - 1))
return b
bits = []
for C in Cs:
b = get_bit(C)
bits.append(b)
start = 0
end = 2**N - 1
import heapq
heap = []
heapq.heappush(heap, (0, start))
visited = {}
ans = -1
while heap:
c, n = heapq.heappop(heap)
if n in visited:
continue
if n == end:
ans = c
break
visited[n] = 1
for i, b in enumerate(bits):
m = n | b
if m in visited:
continue
cost = A[i]
heapq.heappush(heap, (c + cost, m))
print(ans)
|
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(eval(input()))
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7
N, M = rl()
A = []
Cs = []
for i in range(M):
a, b = rl()
C = rl()
A.append(a)
Cs.append(C)
def get_bit(C):
b = 0
for c in C:
b = b | (1 << (c - 1))
return b
bits = []
for C in Cs:
b = get_bit(C)
bits.append(b)
start = 0
end = 2**N - 1
import heapq
heap = []
heapq.heappush(heap, (0, start))
visited = {}
ans = -1
while heap:
c, n = heapq.heappop(heap)
if n == end:
ans = c
break
for i, b in enumerate(bits):
m = n | b
nc = c + A[i]
if m in visited and nc >= visited[m]:
continue
visited[m] = nc
heapq.heappush(heap, (nc, m))
print(ans)
| false | 3.921569 |
[
"- if n in visited:",
"- continue",
"- visited[n] = 1",
"- if m in visited:",
"+ nc = c + A[i]",
"+ if m in visited and nc >= visited[m]:",
"- cost = A[i]",
"- heapq.heappush(heap, (c + cost, m))",
"+ visited[m] = nc",
"+ heapq.heappush(heap, (nc, m))"
] | false | 0.036454 | 0.046643 | 0.781569 |
[
"s005261488",
"s201247474"
] |
u606045429
|
p03045
|
python
|
s278463561
|
s108206498
| 820 | 334 | 85,024 | 32,184 |
Accepted
|
Accepted
| 59.27 |
class UnionFind:
def __init__(self, size):
self.data = [-1 for _ in range(size)]
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return (x != y)
def same(self, x, y):
return (self.find(x) == self.find(y))
def size(self, x):
return -self.data[self.find(x)]
N, M = [int(i) for i in input().split()]
uf = UnionFind(N + 1)
for x, y, z in [[int(i) for i in input().split()] for _ in range(M)]:
uf.union(x, y)
s = set()
for i in range(1, N + 1):
s.add(uf.find(i))
print((len(s)))
|
class UnionFind:
def __init__(self, size):
self.data = [-1 for _ in range(size)]
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return (x != y)
def same(self, x, y):
return (self.find(x) == self.find(y))
def size(self, x):
return -self.data[self.find(x)]
N, M, *XYZ = list(map(int, open(0).read().split()))
uf = UnionFind(N + 1)
for x, y, _ in zip(*[iter(XYZ)] * 3):
uf.union(x, y)
print((len({uf.find(i + 1) for i in range(N)})))
| 34 | 30 | 913 | 857 |
class UnionFind:
def __init__(self, size):
self.data = [-1 for _ in range(size)]
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return x != y
def same(self, x, y):
return self.find(x) == self.find(y)
def size(self, x):
return -self.data[self.find(x)]
N, M = [int(i) for i in input().split()]
uf = UnionFind(N + 1)
for x, y, z in [[int(i) for i in input().split()] for _ in range(M)]:
uf.union(x, y)
s = set()
for i in range(1, N + 1):
s.add(uf.find(i))
print((len(s)))
|
class UnionFind:
def __init__(self, size):
self.data = [-1 for _ in range(size)]
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return x != y
def same(self, x, y):
return self.find(x) == self.find(y)
def size(self, x):
return -self.data[self.find(x)]
N, M, *XYZ = list(map(int, open(0).read().split()))
uf = UnionFind(N + 1)
for x, y, _ in zip(*[iter(XYZ)] * 3):
uf.union(x, y)
print((len({uf.find(i + 1) for i in range(N)})))
| false | 11.764706 |
[
"-N, M = [int(i) for i in input().split()]",
"+N, M, *XYZ = list(map(int, open(0).read().split()))",
"-for x, y, z in [[int(i) for i in input().split()] for _ in range(M)]:",
"+for x, y, _ in zip(*[iter(XYZ)] * 3):",
"-s = set()",
"-for i in range(1, N + 1):",
"- s.add(uf.find(i))",
"-print((len(s)))",
"+print((len({uf.find(i + 1) for i in range(N)})))"
] | false | 0.045852 | 0.05619 | 0.816024 |
[
"s278463561",
"s108206498"
] |
u740284863
|
p02573
|
python
|
s547140884
|
s806654260
| 840 | 765 | 62,168 | 22,640 |
Accepted
|
Accepted
| 8.93 |
from collections import deque
n,m = list(map(int,input().split()))
graph = [[] for _ in range(n+1)]
for _ in range(m):
a,b = list(map(int,input().split()))
graph[a].append(b)
graph[b].append(a)
ans = 1
def dfs(node):
while len(todo) > 0:
node = todo.pop()
if tf[node] == 0:
tf[node] = 1
seen.add(node)
for nextnode in graph[node]:
todo.append(nextnode)
todo = deque()
done = set()
tf = [0 for _ in range(n+1)]
for i in range(1,n+1):
if i in done:
continue
else:
todo.append(i)
seen = set()
dfs(i)
#print(i,seen)
ans = max(ans,len(seen))
done |= seen
print(ans)
|
from collections import *
n,m = list(map(int,input().split()))
par = [-1 for _ in range(n)]#par<0なら自身が親で要素の個数、>0なら子で親の位置示す
def root(i):
if par[i] < 0:
return i
else:
return root(par[i])
def size(a):
return -par[root(a)]
def union(a,b):
a = root(a)
b = root(b)
if a == b:#親が等しい
return False
if size(a) < size(b):#サイズが大きい方に繋げる
a,b = b,a
par[a] += par[b]
par[b] = a
return True
for i in range(m):
a = [int(j)-1 for j in input().split()]#数字を一つ減らして足を揃える
if root(a[0]) != root(a[1]):
union(a[0],a[1])
print((max([ size(i) for i in par])))
| 33 | 29 | 731 | 644 |
from collections import deque
n, m = list(map(int, input().split()))
graph = [[] for _ in range(n + 1)]
for _ in range(m):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
ans = 1
def dfs(node):
while len(todo) > 0:
node = todo.pop()
if tf[node] == 0:
tf[node] = 1
seen.add(node)
for nextnode in graph[node]:
todo.append(nextnode)
todo = deque()
done = set()
tf = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
if i in done:
continue
else:
todo.append(i)
seen = set()
dfs(i)
# print(i,seen)
ans = max(ans, len(seen))
done |= seen
print(ans)
|
from collections import *
n, m = list(map(int, input().split()))
par = [-1 for _ in range(n)] # par<0なら自身が親で要素の個数、>0なら子で親の位置示す
def root(i):
if par[i] < 0:
return i
else:
return root(par[i])
def size(a):
return -par[root(a)]
def union(a, b):
a = root(a)
b = root(b)
if a == b: # 親が等しい
return False
if size(a) < size(b): # サイズが大きい方に繋げる
a, b = b, a
par[a] += par[b]
par[b] = a
return True
for i in range(m):
a = [int(j) - 1 for j in input().split()] # 数字を一つ減らして足を揃える
if root(a[0]) != root(a[1]):
union(a[0], a[1])
print((max([size(i) for i in par])))
| false | 12.121212 |
[
"-from collections import deque",
"+from collections import *",
"-graph = [[] for _ in range(n + 1)]",
"-for _ in range(m):",
"- a, b = list(map(int, input().split()))",
"- graph[a].append(b)",
"- graph[b].append(a)",
"-ans = 1",
"+par = [-1 for _ in range(n)] # par<0なら自身が親で要素の個数、>0なら子で親の位置示す",
"-def dfs(node):",
"- while len(todo) > 0:",
"- node = todo.pop()",
"- if tf[node] == 0:",
"- tf[node] = 1",
"- seen.add(node)",
"- for nextnode in graph[node]:",
"- todo.append(nextnode)",
"+def root(i):",
"+ if par[i] < 0:",
"+ return i",
"+ else:",
"+ return root(par[i])",
"-todo = deque()",
"-done = set()",
"-tf = [0 for _ in range(n + 1)]",
"-for i in range(1, n + 1):",
"- if i in done:",
"- continue",
"- else:",
"- todo.append(i)",
"- seen = set()",
"- dfs(i)",
"- # print(i,seen)",
"- ans = max(ans, len(seen))",
"- done |= seen",
"-print(ans)",
"+def size(a):",
"+ return -par[root(a)]",
"+",
"+",
"+def union(a, b):",
"+ a = root(a)",
"+ b = root(b)",
"+ if a == b: # 親が等しい",
"+ return False",
"+ if size(a) < size(b): # サイズが大きい方に繋げる",
"+ a, b = b, a",
"+ par[a] += par[b]",
"+ par[b] = a",
"+ return True",
"+",
"+",
"+for i in range(m):",
"+ a = [int(j) - 1 for j in input().split()] # 数字を一つ減らして足を揃える",
"+ if root(a[0]) != root(a[1]):",
"+ union(a[0], a[1])",
"+print((max([size(i) for i in par])))"
] | false | 0.094164 | 0.189768 | 0.496208 |
[
"s547140884",
"s806654260"
] |
u751717561
|
p04033
|
python
|
s681573567
|
s156598907
| 153 | 18 | 12,256 | 3,064 |
Accepted
|
Accepted
| 88.24 |
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
#N = I()
#A = [LI() for _ in range(N)]
a, b = list(map(int,sys.stdin.readline().rstrip().split()))
if a > 0:
print('Positive')
elif a <= 0 and b >= 0:
print('Zero')
else:
if (a+b)%2 == 0:
print('Negative')
else:
print('Positive')
|
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]
a, b = list(map(int,sys.stdin.readline().rstrip().split()))
if a > 0:
print('Positive')
elif a <= 0 and b >= 0:
print('Zero')
else:
if (a+b)%2 == 0:
print('Negative')
else:
print('Positive')
| 16 | 19 | 354 | 520 |
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
# N = I()
# A = [LI() for _ in range(N)]
a, b = list(map(int, sys.stdin.readline().rstrip().split()))
if a > 0:
print("Positive")
elif a <= 0 and b >= 0:
print("Zero")
else:
if (a + b) % 2 == 0:
print("Negative")
else:
print("Positive")
|
import sys
def S():
return sys.stdin.readline().rstrip()
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def LS():
return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]
a, b = list(map(int, sys.stdin.readline().rstrip().split()))
if a > 0:
print("Positive")
elif a <= 0 and b >= 0:
print("Zero")
else:
if (a + b) % 2 == 0:
print("Negative")
else:
print("Positive")
| false | 15.789474 |
[
"-import bisect, collections, copy, heapq, itertools, math, numpy, string",
"+",
"+",
"+def S():",
"+ return sys.stdin.readline().rstrip()",
"+",
"+",
"+def I():",
"+ return int(sys.stdin.readline().rstrip())",
"+",
"+",
"+def LI():",
"+ return list(map(int, sys.stdin.readline().rstrip().split()))",
"+",
"+",
"+def LS():",
"+ return list(sys.stdin.readline().rstrip().split())",
"+"
] | false | 0.040152 | 0.038309 | 1.048094 |
[
"s681573567",
"s156598907"
] |
u498487134
|
p02991
|
python
|
s019262210
|
s055980135
| 795 | 584 | 120,100 | 136,636 |
Accepted
|
Accepted
| 26.54 |
##########################################
inf=10**9
import heapq
class Dijkstra():
"""
・有向 / 無向は問わない(無向の場合は,逆向きの辺もたす)
・負のコストがない場合のみ
・計算量はO(E log|V|)
・heapを使うことで頂点を走査する必要がなくなる(代わりに,距離更新したものは確定でなくともqueに入れておく)
"""
class Edge():
#重み付き有向辺
def __init__(self, _to, _cost):
self.to =_to
self.cost = _cost
def __init__(self, V):
#引数Vは頂点数
self.G = [[] for _ in range(V)] #隣接リストG[u][i]が頂点uのi番目の辺
self. _E = 0 #辺の数
self._V = V #頂点数
#proparty - 辺の数
def E(self):
return self._E
#proparty - 頂点数
def V(self):
return self._V
def add(self, _from, _to, _cost):
#2頂点と辺のコストを追加
self.G[_from].append(self.Edge(_to,_cost))
self._E +=1
def add2(self, _from, _to, _cost):
#2頂点と辺のコスト(無向)を追加
self.G[_from].append(self.Edge(_to, _cost))
self.G[_to].append(self.Edge(_from, _cost))
self._E +=1
def shortest_path(self,s):
#始点sから頂点iまでの最短経路長のリストを返す
que = [] #priority queue
d = [inf] * self.V()
prev = [None]*self.V() #prev[j]は,sからjへ最短経路で行くときのjの一つ前の場所
d[s] = 0
heapq.heappush(que,(0,s)) #始点の距離と頂点番号をヒープに追加
while len(que)!=0:
#キューに格納されてある中で一番コストが小さい頂点を取り出す
cost,v = heapq.heappop(que)
#キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ
if d[v] < cost:
continue
#頂点vに隣接する各頂点iに対して,vを経由した場合の距離を計算して,これがd[i]よりも小さい場合に更新
for i in range(len(self.G[v])):
e = self.G[v][i] #vのi個目の隣接辺
if d[e.to] > d[v] + e.cost:
d[e.to] = d[v] + e.cost #更新
prev[e.to] = v
heapq.heappush(que,(d[e.to],e.to)) #queに新たな最短経路長候補を追加
return d
########################
#グラフの頂点を3倍化
import sys
input = sys.stdin.readline
N,M=list(map(int,input().split()))
djk = Dijkstra(N*3)
for i in range(M):
u,v=list(map(int,input().split()))
u-=1
v-=1
djk.add(u,N+v,1)
djk.add(N+u,2*N+v,1)
djk.add(2*N+u,v,1)
S,T=list(map(int,input().split()))
d = djk.shortest_path(S-1)
ans=d[T-1]//3
if ans==inf//3:
ans=-1
print(ans)
|
import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
##########################################
import heapq
class Dijkstra():
"""
・有向 / 無向は問わない(無向の場合は,逆向きの辺もたす)
・負のコストがない場合のみ
・計算量はO(E log|V|)
・heapを使うことで頂点を走査する必要がなくなる(代わりに,距離更新したものは確定でなくともqueに入れておく)
・復元なし
"""
#最短のpathをたす
class Edge():
#重み付き有向辺
def __init__(self, _to, _cost):
self.to =_to
self.cost = _cost
def __init__(self, V):
#引数Vは頂点数
self.inf=10**20
self.G = [[] for _ in range(V)] #隣接リストG[u][i]が頂点uのi番目の辺
self. _E = 0 #辺の数
self._V = V #頂点数
#proparty - 辺の数
def E(self):
return self._E
#proparty - 頂点数
def V(self):
return self._V
def add(self, _from, _to, _cost):
#2頂点と辺のコストを追加
self.G[_from].append(self.Edge(_to,_cost))
self._E +=1
def add2(self, _from, _to, _cost):
#2頂点と辺のコスト(無向)を追加
self.G[_from].append(self.Edge(_to, _cost))
self.G[_to].append(self.Edge(_from, _cost))
self._E +=2
def shortest_path(self,s):#,g):
#始点sから頂点iまでの最短経路長のリストを返す
que = [] #priority queue
d = [self.inf] * self.V()
#prev = [None]*self.V() #prev[j]は,sからjへ最短経路で行くときのjの一つ前の場所
#復元で使う
d[s] = 0
heapq.heappush(que,(0,s)) #始点の距離と頂点番号をヒープに追加
while len(que)!=0:
#キューに格納されてある中で一番コストが小さい頂点を取り出す
cost,v = heapq.heappop(que)
#キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ
if d[v] < cost:
continue
#頂点vに隣接する各頂点iに対して,vを経由した場合の距離を計算して,これがd[i]よりも小さい場合に更新
for i in range(len(self.G[v])):
e = self.G[v][i] #vのi個目の隣接辺
if d[e.to] > d[v] + e.cost:
d[e.to] = d[v] + e.cost #更新
#prev[e.to] = v
#復元で使う
heapq.heappush(que,(d[e.to],e.to)) #queに新たな最短経路長候補を追加
"""#sからgまでの最短経路
path = []
pos = g #今いる場所,ゴールで初期化
for _ in range(self.V()+1):
path.append(pos)
if pos == s:
break
#print("pos:",format(pos))
pos = prev[pos]
path.reverse()
#print(path)"""
return d#,path
########################
mod=10**9+7
N,M=MI()
djk=Dijkstra(3*N)
for _ in range(M):
u,v=MI()
u-=1
v-=1
djk.add(u,v+N,1)
djk.add(u+N,v+2*N,1)
djk.add(u+2*N,v,1)
S,T=MI()
S-=1
T-=1
D=djk.shortest_path(S)
ans=D[T] //3
if ans>10**7:
ans=-1
print(ans)
main()
| 92 | 125 | 2,379 | 3,200 |
##########################################
inf = 10**9
import heapq
class Dijkstra:
"""
・有向 / 無向は問わない(無向の場合は,逆向きの辺もたす)
・負のコストがない場合のみ
・計算量はO(E log|V|)
・heapを使うことで頂点を走査する必要がなくなる(代わりに,距離更新したものは確定でなくともqueに入れておく)
"""
class Edge:
# 重み付き有向辺
def __init__(self, _to, _cost):
self.to = _to
self.cost = _cost
def __init__(self, V):
# 引数Vは頂点数
self.G = [[] for _ in range(V)] # 隣接リストG[u][i]が頂点uのi番目の辺
self._E = 0 # 辺の数
self._V = V # 頂点数
# proparty - 辺の数
def E(self):
return self._E
# proparty - 頂点数
def V(self):
return self._V
def add(self, _from, _to, _cost):
# 2頂点と辺のコストを追加
self.G[_from].append(self.Edge(_to, _cost))
self._E += 1
def add2(self, _from, _to, _cost):
# 2頂点と辺のコスト(無向)を追加
self.G[_from].append(self.Edge(_to, _cost))
self.G[_to].append(self.Edge(_from, _cost))
self._E += 1
def shortest_path(self, s):
# 始点sから頂点iまでの最短経路長のリストを返す
que = [] # priority queue
d = [inf] * self.V()
prev = [None] * self.V() # prev[j]は,sからjへ最短経路で行くときのjの一つ前の場所
d[s] = 0
heapq.heappush(que, (0, s)) # 始点の距離と頂点番号をヒープに追加
while len(que) != 0:
# キューに格納されてある中で一番コストが小さい頂点を取り出す
cost, v = heapq.heappop(que)
# キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ
if d[v] < cost:
continue
# 頂点vに隣接する各頂点iに対して,vを経由した場合の距離を計算して,これがd[i]よりも小さい場合に更新
for i in range(len(self.G[v])):
e = self.G[v][i] # vのi個目の隣接辺
if d[e.to] > d[v] + e.cost:
d[e.to] = d[v] + e.cost # 更新
prev[e.to] = v
heapq.heappush(que, (d[e.to], e.to)) # queに新たな最短経路長候補を追加
return d
########################
# グラフの頂点を3倍化
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
djk = Dijkstra(N * 3)
for i in range(M):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
djk.add(u, N + v, 1)
djk.add(N + u, 2 * N + v, 1)
djk.add(2 * N + u, v, 1)
S, T = list(map(int, input().split()))
d = djk.shortest_path(S - 1)
ans = d[T - 1] // 3
if ans == inf // 3:
ans = -1
print(ans)
|
import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
##########################################
import heapq
class Dijkstra:
"""
・有向 / 無向は問わない(無向の場合は,逆向きの辺もたす)
・負のコストがない場合のみ
・計算量はO(E log|V|)
・heapを使うことで頂点を走査する必要がなくなる(代わりに,距離更新したものは確定でなくともqueに入れておく)
・復元なし
"""
# 最短のpathをたす
class Edge:
# 重み付き有向辺
def __init__(self, _to, _cost):
self.to = _to
self.cost = _cost
def __init__(self, V):
# 引数Vは頂点数
self.inf = 10**20
self.G = [[] for _ in range(V)] # 隣接リストG[u][i]が頂点uのi番目の辺
self._E = 0 # 辺の数
self._V = V # 頂点数
# proparty - 辺の数
def E(self):
return self._E
# proparty - 頂点数
def V(self):
return self._V
def add(self, _from, _to, _cost):
# 2頂点と辺のコストを追加
self.G[_from].append(self.Edge(_to, _cost))
self._E += 1
def add2(self, _from, _to, _cost):
# 2頂点と辺のコスト(無向)を追加
self.G[_from].append(self.Edge(_to, _cost))
self.G[_to].append(self.Edge(_from, _cost))
self._E += 2
def shortest_path(self, s): # ,g):
# 始点sから頂点iまでの最短経路長のリストを返す
que = [] # priority queue
d = [self.inf] * self.V()
# prev = [None]*self.V() #prev[j]は,sからjへ最短経路で行くときのjの一つ前の場所
# 復元で使う
d[s] = 0
heapq.heappush(que, (0, s)) # 始点の距離と頂点番号をヒープに追加
while len(que) != 0:
# キューに格納されてある中で一番コストが小さい頂点を取り出す
cost, v = heapq.heappop(que)
# キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ
if d[v] < cost:
continue
# 頂点vに隣接する各頂点iに対して,vを経由した場合の距離を計算して,これがd[i]よりも小さい場合に更新
for i in range(len(self.G[v])):
e = self.G[v][i] # vのi個目の隣接辺
if d[e.to] > d[v] + e.cost:
d[e.to] = d[v] + e.cost # 更新
# prev[e.to] = v
# 復元で使う
heapq.heappush(que, (d[e.to], e.to)) # queに新たな最短経路長候補を追加
"""#sからgまでの最短経路
path = []
pos = g #今いる場所,ゴールで初期化
for _ in range(self.V()+1):
path.append(pos)
if pos == s:
break
#print("pos:",format(pos))
pos = prev[pos]
path.reverse()
#print(path)"""
return d # ,path
########################
mod = 10**9 + 7
N, M = MI()
djk = Dijkstra(3 * N)
for _ in range(M):
u, v = MI()
u -= 1
v -= 1
djk.add(u, v + N, 1)
djk.add(u + N, v + 2 * N, 1)
djk.add(u + 2 * N, v, 1)
S, T = MI()
S -= 1
T -= 1
D = djk.shortest_path(S)
ans = D[T] // 3
if ans > 10**7:
ans = -1
print(ans)
main()
| false | 26.4 |
[
"-##########################################",
"-inf = 10**9",
"-import heapq",
"-",
"-",
"-class Dijkstra:",
"- \"\"\"",
"- ・有向 / 無向は問わない(無向の場合は,逆向きの辺もたす)",
"- ・負のコストがない場合のみ",
"- ・計算量はO(E log|V|)",
"- ・heapを使うことで頂点を走査する必要がなくなる(代わりに,距離更新したものは確定でなくともqueに入れておく)",
"- \"\"\"",
"-",
"- class Edge:",
"- # 重み付き有向辺",
"- def __init__(self, _to, _cost):",
"- self.to = _to",
"- self.cost = _cost",
"-",
"- def __init__(self, V):",
"- # 引数Vは頂点数",
"- self.G = [[] for _ in range(V)] # 隣接リストG[u][i]が頂点uのi番目の辺",
"- self._E = 0 # 辺の数",
"- self._V = V # 頂点数",
"-",
"- # proparty - 辺の数",
"- def E(self):",
"- return self._E",
"-",
"- # proparty - 頂点数",
"- def V(self):",
"- return self._V",
"-",
"- def add(self, _from, _to, _cost):",
"- # 2頂点と辺のコストを追加",
"- self.G[_from].append(self.Edge(_to, _cost))",
"- self._E += 1",
"-",
"- def add2(self, _from, _to, _cost):",
"- # 2頂点と辺のコスト(無向)を追加",
"- self.G[_from].append(self.Edge(_to, _cost))",
"- self.G[_to].append(self.Edge(_from, _cost))",
"- self._E += 1",
"-",
"- def shortest_path(self, s):",
"- # 始点sから頂点iまでの最短経路長のリストを返す",
"- que = [] # priority queue",
"- d = [inf] * self.V()",
"- prev = [None] * self.V() # prev[j]は,sからjへ最短経路で行くときのjの一つ前の場所",
"- d[s] = 0",
"- heapq.heappush(que, (0, s)) # 始点の距離と頂点番号をヒープに追加",
"- while len(que) != 0:",
"- # キューに格納されてある中で一番コストが小さい頂点を取り出す",
"- cost, v = heapq.heappop(que)",
"- # キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ",
"- if d[v] < cost:",
"- continue",
"- # 頂点vに隣接する各頂点iに対して,vを経由した場合の距離を計算して,これがd[i]よりも小さい場合に更新",
"- for i in range(len(self.G[v])):",
"- e = self.G[v][i] # vのi個目の隣接辺",
"- if d[e.to] > d[v] + e.cost:",
"- d[e.to] = d[v] + e.cost # 更新",
"- prev[e.to] = v",
"- heapq.heappush(que, (d[e.to], e.to)) # queに新たな最短経路長候補を追加",
"- return d",
"-",
"-",
"-########################",
"-# グラフの頂点を3倍化",
"-N, M = list(map(int, input().split()))",
"-djk = Dijkstra(N * 3)",
"-for i in range(M):",
"- u, v = list(map(int, input().split()))",
"- u -= 1",
"- v -= 1",
"- djk.add(u, N + v, 1)",
"- djk.add(N + u, 2 * N + v, 1)",
"- djk.add(2 * N + u, v, 1)",
"-S, T = list(map(int, input().split()))",
"-d = djk.shortest_path(S - 1)",
"-ans = d[T - 1] // 3",
"-if ans == inf // 3:",
"- ans = -1",
"-print(ans)",
"+",
"+",
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def main():",
"+ ##########################################",
"+ import heapq",
"+",
"+ class Dijkstra:",
"+ \"\"\"",
"+ ・有向 / 無向は問わない(無向の場合は,逆向きの辺もたす)",
"+ ・負のコストがない場合のみ",
"+ ・計算量はO(E log|V|)",
"+ ・heapを使うことで頂点を走査する必要がなくなる(代わりに,距離更新したものは確定でなくともqueに入れておく)",
"+ ・復元なし",
"+ \"\"\"",
"+",
"+ # 最短のpathをたす",
"+ class Edge:",
"+ # 重み付き有向辺",
"+ def __init__(self, _to, _cost):",
"+ self.to = _to",
"+ self.cost = _cost",
"+",
"+ def __init__(self, V):",
"+ # 引数Vは頂点数",
"+ self.inf = 10**20",
"+ self.G = [[] for _ in range(V)] # 隣接リストG[u][i]が頂点uのi番目の辺",
"+ self._E = 0 # 辺の数",
"+ self._V = V # 頂点数",
"+",
"+ # proparty - 辺の数",
"+ def E(self):",
"+ return self._E",
"+",
"+ # proparty - 頂点数",
"+ def V(self):",
"+ return self._V",
"+",
"+ def add(self, _from, _to, _cost):",
"+ # 2頂点と辺のコストを追加",
"+ self.G[_from].append(self.Edge(_to, _cost))",
"+ self._E += 1",
"+",
"+ def add2(self, _from, _to, _cost):",
"+ # 2頂点と辺のコスト(無向)を追加",
"+ self.G[_from].append(self.Edge(_to, _cost))",
"+ self.G[_to].append(self.Edge(_from, _cost))",
"+ self._E += 2",
"+",
"+ def shortest_path(self, s): # ,g):",
"+ # 始点sから頂点iまでの最短経路長のリストを返す",
"+ que = [] # priority queue",
"+ d = [self.inf] * self.V()",
"+ # prev = [None]*self.V() #prev[j]は,sからjへ最短経路で行くときのjの一つ前の場所",
"+ # 復元で使う",
"+ d[s] = 0",
"+ heapq.heappush(que, (0, s)) # 始点の距離と頂点番号をヒープに追加",
"+ while len(que) != 0:",
"+ # キューに格納されてある中で一番コストが小さい頂点を取り出す",
"+ cost, v = heapq.heappop(que)",
"+ # キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ",
"+ if d[v] < cost:",
"+ continue",
"+ # 頂点vに隣接する各頂点iに対して,vを経由した場合の距離を計算して,これがd[i]よりも小さい場合に更新",
"+ for i in range(len(self.G[v])):",
"+ e = self.G[v][i] # vのi個目の隣接辺",
"+ if d[e.to] > d[v] + e.cost:",
"+ d[e.to] = d[v] + e.cost # 更新",
"+ # prev[e.to] = v",
"+ # 復元で使う",
"+ heapq.heappush(que, (d[e.to], e.to)) # queに新たな最短経路長候補を追加",
"+ \"\"\"#sからgまでの最短経路",
"+ path = []",
"+ pos = g #今いる場所,ゴールで初期化",
"+ for _ in range(self.V()+1):",
"+ path.append(pos)",
"+ if pos == s:",
"+ break",
"+ #print(\"pos:\",format(pos))",
"+ pos = prev[pos]",
"+ path.reverse()",
"+ #print(path)\"\"\"",
"+ return d # ,path",
"+",
"+ ########################",
"+ mod = 10**9 + 7",
"+ N, M = MI()",
"+ djk = Dijkstra(3 * N)",
"+ for _ in range(M):",
"+ u, v = MI()",
"+ u -= 1",
"+ v -= 1",
"+ djk.add(u, v + N, 1)",
"+ djk.add(u + N, v + 2 * N, 1)",
"+ djk.add(u + 2 * N, v, 1)",
"+ S, T = MI()",
"+ S -= 1",
"+ T -= 1",
"+ D = djk.shortest_path(S)",
"+ ans = D[T] // 3",
"+ if ans > 10**7:",
"+ ans = -1",
"+ print(ans)",
"+",
"+",
"+main()"
] | false | 0.044901 | 0.046799 | 0.95943 |
[
"s019262210",
"s055980135"
] |
u755180064
|
p03377
|
python
|
s727127053
|
s936011807
| 19 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 10.53 |
def main():
t = list(map(int, input().split()))
for i in range(t[1]):
tmp = i + t[0]
if tmp == t[2]:
print('YES')
exit()
print('NO')
if __name__ == '__main__':
main()
|
url = "https://atcoder.jp//contests/abc094/tasks/abc094_a"
def main():
t = list(map(int, input().split()))
for i in range(t[1]):
tmp = i + t[0]
if tmp == t[2]:
print('YES')
exit()
print('NO')
if __name__ == '__main__':
main()
| 11 | 14 | 234 | 298 |
def main():
t = list(map(int, input().split()))
for i in range(t[1]):
tmp = i + t[0]
if tmp == t[2]:
print("YES")
exit()
print("NO")
if __name__ == "__main__":
main()
|
url = "https://atcoder.jp//contests/abc094/tasks/abc094_a"
def main():
t = list(map(int, input().split()))
for i in range(t[1]):
tmp = i + t[0]
if tmp == t[2]:
print("YES")
exit()
print("NO")
if __name__ == "__main__":
main()
| false | 21.428571 |
[
"+url = \"https://atcoder.jp//contests/abc094/tasks/abc094_a\"",
"+",
"+"
] | false | 0.042912 | 0.071981 | 0.596152 |
[
"s727127053",
"s936011807"
] |
u285891772
|
p02732
|
python
|
s265849729
|
s958696435
| 370 | 325 | 27,304 | 27,196 |
Accepted
|
Accepted
| 12.16 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
A = LIST()
dic = defaultdict(int)
for x in A:
dic[x] += 1
total = 0
for x in dic:
total += dic[x]*(dic[x]-1)//2
for x in A:
print((total-dic[x]+1))
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
A = LIST()
#print(Counter(A).keys())
#print(Counter(A).values())
#print(Counter(A).items())
lis = [0]*(N+1)
ans = 0
for key, value in list(Counter(A).items()):
lis[key] = value
ans += value*(value-1)//2
#print(lis)
for i in range(N):
print((ans-lis[A[i]]+1))
| 33 | 37 | 1,022 | 1,132 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
A = LIST()
dic = defaultdict(int)
for x in A:
dic[x] += 1
total = 0
for x in dic:
total += dic[x] * (dic[x] - 1) // 2
for x in A:
print((total - dic[x] + 1))
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
A = LIST()
# print(Counter(A).keys())
# print(Counter(A).values())
# print(Counter(A).items())
lis = [0] * (N + 1)
ans = 0
for key, value in list(Counter(A).items()):
lis[key] = value
ans += value * (value - 1) // 2
# print(lis)
for i in range(N):
print((ans - lis[A[i]] + 1))
| false | 10.810811 |
[
"-dic = defaultdict(int)",
"-for x in A:",
"- dic[x] += 1",
"-total = 0",
"-for x in dic:",
"- total += dic[x] * (dic[x] - 1) // 2",
"-for x in A:",
"- print((total - dic[x] + 1))",
"+# print(Counter(A).keys())",
"+# print(Counter(A).values())",
"+# print(Counter(A).items())",
"+lis = [0] * (N + 1)",
"+ans = 0",
"+for key, value in list(Counter(A).items()):",
"+ lis[key] = value",
"+ ans += value * (value - 1) // 2",
"+# print(lis)",
"+for i in range(N):",
"+ print((ans - lis[A[i]] + 1))"
] | false | 0.098212 | 0.065131 | 1.507908 |
[
"s265849729",
"s958696435"
] |
u411923565
|
p02820
|
python
|
s455911091
|
s438751221
| 196 | 178 | 85,312 | 86,320 |
Accepted
|
Accepted
| 9.18 |
# D - Prediction and Restriction
N,K = list(map(int,input().split()))
RSP = tuple(map(int,input().split()))
T = eval(input())
# じゃんけんの勝敗を返す関数
def judge(a,b):
if a == 'r' and b == 2:
return True
elif a == 's' and b == 0:
return True
elif a == 'p' and b == 1:
return True
return False
# dp[i][j]: i 回目のじゃんけんで j を出したときの最大値
# グー:0, チョキ:1, パー:2
dp = [[0]*3 for _ in range(N+1)]
# v 回目のじゃんけん
for v in range(1,N+1):
# v 回目に出した手
for w in range(3):
# v-K 回目に出した手
for k in range(3):
if w == k:
continue
# じゃんけんで勝ったとき
if judge(T[v-1],w):
dp[v][w] = max(dp[v][w],dp[v-K][k] + RSP[w])
# じゃんけんで負けか引き分けたとき
else:
dp[v][w] = max(dp[v][w],dp[v-K][k])
# K 個に分けた各グループの部分和の最大値の総和を求める
ans = 0
for a in range(1,K+1):
ans += max(dp[-a])
print(ans)
|
# D - Prediction and Restriction
N,K = list(map(int,input().split()))
RSP = tuple(map(int,input().split()))
T = eval(input())
# じゃんけんの勝敗を返す関数
def judge(a,b):
if a == 'r' and b == 2:
return True
elif a == 's' and b == 0:
return True
elif a == 'p' and b == 1:
return True
return False
# dp[i][j]: i 回目のじゃんけんで j を出したときの最大値
# グー:0, チョキ:1, パー:2
dp = [[0]*3 for _ in range(N+1)]
# 初期条件 v < K のときは全て勝つ
for i in range(1,K+1):
for j in range(3):
if judge(T[i-1],j):
dp[i][j] = RSP[j]
# K 以下の数字について
for v in range(1,K+1):
# w = v, v+K, v+2K,...
for w in range(v+K,N+1,K):
# w 回目に出した手
for l in range(3):
# w-K 回目に出した手
for m in range(3):
if l == m:
continue
# じゃんけんで勝ったとき
if judge(T[w-1],l):
if w-K>=0:
dp[w][l] = max(dp[w][l],dp[w-K][m] + RSP[l])
# じゃんけんで負けか引き分けたとき
dp[w][l] = max(dp[w][l],dp[w-K][m])
# K 個に分けた各グループの部分和の最大値の総和を求める
ans = 0
for a in range(1,K+1):
ans += max(dp[-a])
print(ans)
| 38 | 47 | 938 | 1,203 |
# D - Prediction and Restriction
N, K = list(map(int, input().split()))
RSP = tuple(map(int, input().split()))
T = eval(input())
# じゃんけんの勝敗を返す関数
def judge(a, b):
if a == "r" and b == 2:
return True
elif a == "s" and b == 0:
return True
elif a == "p" and b == 1:
return True
return False
# dp[i][j]: i 回目のじゃんけんで j を出したときの最大値
# グー:0, チョキ:1, パー:2
dp = [[0] * 3 for _ in range(N + 1)]
# v 回目のじゃんけん
for v in range(1, N + 1):
# v 回目に出した手
for w in range(3):
# v-K 回目に出した手
for k in range(3):
if w == k:
continue
# じゃんけんで勝ったとき
if judge(T[v - 1], w):
dp[v][w] = max(dp[v][w], dp[v - K][k] + RSP[w])
# じゃんけんで負けか引き分けたとき
else:
dp[v][w] = max(dp[v][w], dp[v - K][k])
# K 個に分けた各グループの部分和の最大値の総和を求める
ans = 0
for a in range(1, K + 1):
ans += max(dp[-a])
print(ans)
|
# D - Prediction and Restriction
N, K = list(map(int, input().split()))
RSP = tuple(map(int, input().split()))
T = eval(input())
# じゃんけんの勝敗を返す関数
def judge(a, b):
if a == "r" and b == 2:
return True
elif a == "s" and b == 0:
return True
elif a == "p" and b == 1:
return True
return False
# dp[i][j]: i 回目のじゃんけんで j を出したときの最大値
# グー:0, チョキ:1, パー:2
dp = [[0] * 3 for _ in range(N + 1)]
# 初期条件 v < K のときは全て勝つ
for i in range(1, K + 1):
for j in range(3):
if judge(T[i - 1], j):
dp[i][j] = RSP[j]
# K 以下の数字について
for v in range(1, K + 1):
# w = v, v+K, v+2K,...
for w in range(v + K, N + 1, K):
# w 回目に出した手
for l in range(3):
# w-K 回目に出した手
for m in range(3):
if l == m:
continue
# じゃんけんで勝ったとき
if judge(T[w - 1], l):
if w - K >= 0:
dp[w][l] = max(dp[w][l], dp[w - K][m] + RSP[l])
# じゃんけんで負けか引き分けたとき
dp[w][l] = max(dp[w][l], dp[w - K][m])
# K 個に分けた各グループの部分和の最大値の総和を求める
ans = 0
for a in range(1, K + 1):
ans += max(dp[-a])
print(ans)
| false | 19.148936 |
[
"-# v 回目のじゃんけん",
"-for v in range(1, N + 1):",
"- # v 回目に出した手",
"- for w in range(3):",
"- # v-K 回目に出した手",
"- for k in range(3):",
"- if w == k:",
"- continue",
"- # じゃんけんで勝ったとき",
"- if judge(T[v - 1], w):",
"- dp[v][w] = max(dp[v][w], dp[v - K][k] + RSP[w])",
"- # じゃんけんで負けか引き分けたとき",
"- else:",
"- dp[v][w] = max(dp[v][w], dp[v - K][k])",
"+# 初期条件 v < K のときは全て勝つ",
"+for i in range(1, K + 1):",
"+ for j in range(3):",
"+ if judge(T[i - 1], j):",
"+ dp[i][j] = RSP[j]",
"+# K 以下の数字について",
"+for v in range(1, K + 1):",
"+ # w = v, v+K, v+2K,...",
"+ for w in range(v + K, N + 1, K):",
"+ # w 回目に出した手",
"+ for l in range(3):",
"+ # w-K 回目に出した手",
"+ for m in range(3):",
"+ if l == m:",
"+ continue",
"+ # じゃんけんで勝ったとき",
"+ if judge(T[w - 1], l):",
"+ if w - K >= 0:",
"+ dp[w][l] = max(dp[w][l], dp[w - K][m] + RSP[l])",
"+ # じゃんけんで負けか引き分けたとき",
"+ dp[w][l] = max(dp[w][l], dp[w - K][m])"
] | false | 0.044492 | 0.047985 | 0.927216 |
[
"s455911091",
"s438751221"
] |
u562935282
|
p02832
|
python
|
s881556736
|
s789121075
| 153 | 89 | 26,180 | 24,744 |
Accepted
|
Accepted
| 41.83 |
from bisect import bisect_left
N = int(eval(input()))
*A, = list(map(int, input().split()))
L = [A[0]]
for a in A[1:]:
if a > L[-1]:
# Lの末尾よりaが大きければ増加部分列を延長できる
L.append(a)
else:
# そうでなければ、「aより小さい最大要素の次」をaにする
# 該当位置は、二分探索で特定できる
L[bisect_left(L, a)] = a
ret = N + 1
for cnt, l_ in enumerate(L, 1):
if l_ != cnt:
break
ret = cnt
print((N - ret))
|
N = int(eval(input()))
*A, = list(map(int, input().split()))
tar = 1
for a_ in A:
if a_ == tar:
tar += 1
tar -= 1
if tar:
print((N - tar))
else:
print((-1))
| 22 | 13 | 418 | 175 |
from bisect import bisect_left
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
L = [A[0]]
for a in A[1:]:
if a > L[-1]:
# Lの末尾よりaが大きければ増加部分列を延長できる
L.append(a)
else:
# そうでなければ、「aより小さい最大要素の次」をaにする
# 該当位置は、二分探索で特定できる
L[bisect_left(L, a)] = a
ret = N + 1
for cnt, l_ in enumerate(L, 1):
if l_ != cnt:
break
ret = cnt
print((N - ret))
|
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
tar = 1
for a_ in A:
if a_ == tar:
tar += 1
tar -= 1
if tar:
print((N - tar))
else:
print((-1))
| false | 40.909091 |
[
"-from bisect import bisect_left",
"-",
"-L = [A[0]]",
"-for a in A[1:]:",
"- if a > L[-1]:",
"- # Lの末尾よりaが大きければ増加部分列を延長できる",
"- L.append(a)",
"- else:",
"- # そうでなければ、「aより小さい最大要素の次」をaにする",
"- # 該当位置は、二分探索で特定できる",
"- L[bisect_left(L, a)] = a",
"-ret = N + 1",
"-for cnt, l_ in enumerate(L, 1):",
"- if l_ != cnt:",
"- break",
"- ret = cnt",
"-print((N - ret))",
"+tar = 1",
"+for a_ in A:",
"+ if a_ == tar:",
"+ tar += 1",
"+tar -= 1",
"+if tar:",
"+ print((N - tar))",
"+else:",
"+ print((-1))"
] | false | 0.039286 | 0.043547 | 0.90213 |
[
"s881556736",
"s789121075"
] |
u614314290
|
p03107
|
python
|
s686500258
|
s875984975
| 71 | 30 | 3,956 | 3,484 |
Accepted
|
Accepted
| 57.75 |
S = eval(input())
l = []
for s in S:
si = int(s)
if not l:
l.append(si)
else:
if (l[-1] + si) & 1:
l.pop()
else:
l.append(si)
print((len(S) - len(l)))
|
from collections import defaultdict as dd
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
return int(n) - 1
def parse(*args):
return tuple(p(v) for p, v in zip(args, input().split()))
# エントリーポイント
def main():
S = eval(input())
c = [0, 0]
for s in S:
c[s == "1"] += 1
print((len(S) - abs(c[0] - c[1])))
main()
| 13 | 19 | 171 | 364 |
S = eval(input())
l = []
for s in S:
si = int(s)
if not l:
l.append(si)
else:
if (l[-1] + si) & 1:
l.pop()
else:
l.append(si)
print((len(S) - len(l)))
|
from collections import defaultdict as dd
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
return int(n) - 1
def parse(*args):
return tuple(p(v) for p, v in zip(args, input().split()))
# エントリーポイント
def main():
S = eval(input())
c = [0, 0]
for s in S:
c[s == "1"] += 1
print((len(S) - abs(c[0] - c[1])))
main()
| false | 31.578947 |
[
"-S = eval(input())",
"-l = []",
"-for s in S:",
"- si = int(s)",
"- if not l:",
"- l.append(si)",
"- else:",
"- if (l[-1] + si) & 1:",
"- l.pop()",
"- else:",
"- l.append(si)",
"-print((len(S) - len(l)))",
"+from collections import defaultdict as dd",
"+",
"+# お約束",
"+INF = float(\"inf\")",
"+MOD = int(1e9 + 7)",
"+",
"+",
"+def int1(n):",
"+ return int(n) - 1",
"+",
"+",
"+def parse(*args):",
"+ return tuple(p(v) for p, v in zip(args, input().split()))",
"+",
"+",
"+# エントリーポイント",
"+def main():",
"+ S = eval(input())",
"+ c = [0, 0]",
"+ for s in S:",
"+ c[s == \"1\"] += 1",
"+ print((len(S) - abs(c[0] - c[1])))",
"+",
"+",
"+main()"
] | false | 0.031342 | 0.035026 | 0.894831 |
[
"s686500258",
"s875984975"
] |
u619144316
|
p02844
|
python
|
s342466570
|
s200822867
| 124 | 97 | 4,760 | 3,652 |
Accepted
|
Accepted
| 21.77 |
import collections
N = int(eval(input()))
S = [int(i) for i in list(eval(input()))]
count = 0
for i in range(10):
for num,j in enumerate(S):
if j == i:
T = S[num+1::]
for k in list(set(T)):
for num2, l in enumerate(T):
if k == l:
U = T[num2+1::]
count += len(set(U))
break
break
print(count)
|
N = int(eval(input()))
S = list(map(int,eval(input())))
cnt = 0
for i in range(10):
if i in S:
k = S.index(i)
for j in range(10):
if j in S[k+1:]:
l = S[k+1:].index(j)
cnt += len(set(S[k+l+2:]))
print(cnt)
| 21 | 13 | 500 | 272 |
import collections
N = int(eval(input()))
S = [int(i) for i in list(eval(input()))]
count = 0
for i in range(10):
for num, j in enumerate(S):
if j == i:
T = S[num + 1 : :]
for k in list(set(T)):
for num2, l in enumerate(T):
if k == l:
U = T[num2 + 1 : :]
count += len(set(U))
break
break
print(count)
|
N = int(eval(input()))
S = list(map(int, eval(input())))
cnt = 0
for i in range(10):
if i in S:
k = S.index(i)
for j in range(10):
if j in S[k + 1 :]:
l = S[k + 1 :].index(j)
cnt += len(set(S[k + l + 2 :]))
print(cnt)
| false | 38.095238 |
[
"-import collections",
"-",
"-S = [int(i) for i in list(eval(input()))]",
"-count = 0",
"+S = list(map(int, eval(input())))",
"+cnt = 0",
"- for num, j in enumerate(S):",
"- if j == i:",
"- T = S[num + 1 : :]",
"- for k in list(set(T)):",
"- for num2, l in enumerate(T):",
"- if k == l:",
"- U = T[num2 + 1 : :]",
"- count += len(set(U))",
"- break",
"- break",
"-print(count)",
"+ if i in S:",
"+ k = S.index(i)",
"+ for j in range(10):",
"+ if j in S[k + 1 :]:",
"+ l = S[k + 1 :].index(j)",
"+ cnt += len(set(S[k + l + 2 :]))",
"+print(cnt)"
] | false | 0.072048 | 0.043184 | 1.668411 |
[
"s342466570",
"s200822867"
] |
u450956662
|
p03805
|
python
|
s691226757
|
s434850576
| 24 | 21 | 3,064 | 3,064 |
Accepted
|
Accepted
| 12.5 |
from itertools import permutations
N, M = list(map(int, input().split()))
E = [set() for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
E[a-1].add(b-1)
E[b-1].add(a-1)
ans = 0
for p in permutations([i for i in range(1, N)]):
i = 0
for j in p:
if j not in E[i]:
break
i = j
else:
ans += 1
print(ans)
|
def bitDP():
dp = [[0] * N for _ in range(1 << N)]
dp[1][0] = 1
for i in range(1 << N):
for v in range(N):
if (i >> v) & 0:
continue
j = i ^ (1 << v)
for u in range(N):
if (j >> u) & 1 and v in E[u]:
dp[i][v] += dp[j][u]
res = sum(dp[-1][u] for u in range(1, N))
return res
N, M = list(map(int, input().split()))
E = [set() for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
E[a-1].add(b-1)
E[b-1].add(a-1)
print((bitDP()))
| 19 | 22 | 392 | 587 |
from itertools import permutations
N, M = list(map(int, input().split()))
E = [set() for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
E[a - 1].add(b - 1)
E[b - 1].add(a - 1)
ans = 0
for p in permutations([i for i in range(1, N)]):
i = 0
for j in p:
if j not in E[i]:
break
i = j
else:
ans += 1
print(ans)
|
def bitDP():
dp = [[0] * N for _ in range(1 << N)]
dp[1][0] = 1
for i in range(1 << N):
for v in range(N):
if (i >> v) & 0:
continue
j = i ^ (1 << v)
for u in range(N):
if (j >> u) & 1 and v in E[u]:
dp[i][v] += dp[j][u]
res = sum(dp[-1][u] for u in range(1, N))
return res
N, M = list(map(int, input().split()))
E = [set() for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
E[a - 1].add(b - 1)
E[b - 1].add(a - 1)
print((bitDP()))
| false | 13.636364 |
[
"-from itertools import permutations",
"+def bitDP():",
"+ dp = [[0] * N for _ in range(1 << N)]",
"+ dp[1][0] = 1",
"+ for i in range(1 << N):",
"+ for v in range(N):",
"+ if (i >> v) & 0:",
"+ continue",
"+ j = i ^ (1 << v)",
"+ for u in range(N):",
"+ if (j >> u) & 1 and v in E[u]:",
"+ dp[i][v] += dp[j][u]",
"+ res = sum(dp[-1][u] for u in range(1, N))",
"+ return res",
"+",
"-ans = 0",
"-for p in permutations([i for i in range(1, N)]):",
"- i = 0",
"- for j in p:",
"- if j not in E[i]:",
"- break",
"- i = j",
"- else:",
"- ans += 1",
"-print(ans)",
"+print((bitDP()))"
] | false | 0.15029 | 0.152578 | 0.985004 |
[
"s691226757",
"s434850576"
] |
u462329577
|
p03244
|
python
|
s753050579
|
s419548237
| 449 | 180 | 82,396 | 32,084 |
Accepted
|
Accepted
| 59.91 |
#!/usr/bin/env python3
n = int(eval(input()))
a = list(map(int,input().split()))
cnt_odd = [0]*(10**5+1)# a[2k]での個数
cnt_even = [0]*(10**5+1)
for i in range(n):
if i %2: cnt_odd[a[i]] += 1
else: cnt_even[a[i]] += 1
odd,idx_odd=list(zip(*sorted(zip(cnt_odd,list(range(10**5+1))))))
even,idx_even=list(zip(*sorted(zip(cnt_even,list(range(10**5+1))))))
#print(odd[-1],even[-2],odd[-2],even[-1])
if idx_even[-1]!=idx_odd[-1]:
print((n - odd[-1] - even[-1]))
else:
print((n - max(odd[-1]+even[-2],odd[-2]+even[-1])))
#ちゃんとテストケース書かないと落ちる
|
n = int(eval(input()))
v = list(map(int, input().split()))
freq_odd = [0] * (10 ** 5 + 1)
freq_even = [0] * (10 ** 5 + 1)
for i in range(n // 2):
freq_odd[v[2 * i]] += 1
freq_even[v[2 * i + 1]] += 1
# print(freq_odd[:10], freq_even[:10])
freq_even, id_even = list(zip(*sorted(zip(freq_even, list(range(10 ** 5 + 1))))))
freq_odd, id_odd = list(zip(*sorted(zip(freq_odd, list(range(10 ** 5 + 1))))))
# print(freq_odd[-2:], freq_even[-2:])
# print(id_even[-1], id_odd[-1])
if id_even[-1] != id_odd[-1]:
print((n - freq_even[-1] - freq_odd[-1]))
else:
print((min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2])))
| 17 | 16 | 543 | 627 |
#!/usr/bin/env python3
n = int(eval(input()))
a = list(map(int, input().split()))
cnt_odd = [0] * (10**5 + 1) # a[2k]での個数
cnt_even = [0] * (10**5 + 1)
for i in range(n):
if i % 2:
cnt_odd[a[i]] += 1
else:
cnt_even[a[i]] += 1
odd, idx_odd = list(zip(*sorted(zip(cnt_odd, list(range(10**5 + 1))))))
even, idx_even = list(zip(*sorted(zip(cnt_even, list(range(10**5 + 1))))))
# print(odd[-1],even[-2],odd[-2],even[-1])
if idx_even[-1] != idx_odd[-1]:
print((n - odd[-1] - even[-1]))
else:
print((n - max(odd[-1] + even[-2], odd[-2] + even[-1])))
# ちゃんとテストケース書かないと落ちる
|
n = int(eval(input()))
v = list(map(int, input().split()))
freq_odd = [0] * (10**5 + 1)
freq_even = [0] * (10**5 + 1)
for i in range(n // 2):
freq_odd[v[2 * i]] += 1
freq_even[v[2 * i + 1]] += 1
# print(freq_odd[:10], freq_even[:10])
freq_even, id_even = list(zip(*sorted(zip(freq_even, list(range(10**5 + 1))))))
freq_odd, id_odd = list(zip(*sorted(zip(freq_odd, list(range(10**5 + 1))))))
# print(freq_odd[-2:], freq_even[-2:])
# print(id_even[-1], id_odd[-1])
if id_even[-1] != id_odd[-1]:
print((n - freq_even[-1] - freq_odd[-1]))
else:
print((min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2])))
| false | 5.882353 |
[
"-#!/usr/bin/env python3",
"-a = list(map(int, input().split()))",
"-cnt_odd = [0] * (10**5 + 1) # a[2k]での個数",
"-cnt_even = [0] * (10**5 + 1)",
"-for i in range(n):",
"- if i % 2:",
"- cnt_odd[a[i]] += 1",
"- else:",
"- cnt_even[a[i]] += 1",
"-odd, idx_odd = list(zip(*sorted(zip(cnt_odd, list(range(10**5 + 1))))))",
"-even, idx_even = list(zip(*sorted(zip(cnt_even, list(range(10**5 + 1))))))",
"-# print(odd[-1],even[-2],odd[-2],even[-1])",
"-if idx_even[-1] != idx_odd[-1]:",
"- print((n - odd[-1] - even[-1]))",
"+v = list(map(int, input().split()))",
"+freq_odd = [0] * (10**5 + 1)",
"+freq_even = [0] * (10**5 + 1)",
"+for i in range(n // 2):",
"+ freq_odd[v[2 * i]] += 1",
"+ freq_even[v[2 * i + 1]] += 1",
"+# print(freq_odd[:10], freq_even[:10])",
"+freq_even, id_even = list(zip(*sorted(zip(freq_even, list(range(10**5 + 1))))))",
"+freq_odd, id_odd = list(zip(*sorted(zip(freq_odd, list(range(10**5 + 1))))))",
"+# print(freq_odd[-2:], freq_even[-2:])",
"+# print(id_even[-1], id_odd[-1])",
"+if id_even[-1] != id_odd[-1]:",
"+ print((n - freq_even[-1] - freq_odd[-1]))",
"- print((n - max(odd[-1] + even[-2], odd[-2] + even[-1])))",
"-# ちゃんとテストケース書かないと落ちる",
"+ print((min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2])))"
] | false | 0.169891 | 0.288805 | 0.588255 |
[
"s753050579",
"s419548237"
] |
u752907966
|
p02773
|
python
|
s253726499
|
s010665489
| 392 | 340 | 35,944 | 35,952 |
Accepted
|
Accepted
| 13.27 |
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
for _ in range(n):
s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
if j == max_vote:
ans.append(i)
print(("\n".join(sorted(ans))))
|
def main():
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
for _ in range(n):
s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
if j == max_vote:
ans.append(i)
print(("\n".join(sorted(ans))))
main()
| 14 | 16 | 297 | 374 |
from collections import Counter
import sys
input = sys.stdin.readline
n = int(eval(input()))
s = []
for _ in range(n):
s.append(input().rstrip())
c = Counter(s)
ans = []
max_vote = max(c.values())
for i, j in list(c.items()):
if j == max_vote:
ans.append(i)
print(("\n".join(sorted(ans))))
|
def main():
from collections import Counter
import sys
input = sys.stdin.readline
n = int(eval(input()))
s = []
for _ in range(n):
s.append(input().rstrip())
c = Counter(s)
ans = []
max_vote = max(c.values())
for i, j in list(c.items()):
if j == max_vote:
ans.append(i)
print(("\n".join(sorted(ans))))
main()
| false | 12.5 |
[
"-from collections import Counter",
"-import sys",
"+def main():",
"+ from collections import Counter",
"+ import sys",
"-input = sys.stdin.readline",
"-n = int(eval(input()))",
"-s = []",
"-for _ in range(n):",
"- s.append(input().rstrip())",
"-c = Counter(s)",
"-ans = []",
"-max_vote = max(c.values())",
"-for i, j in list(c.items()):",
"- if j == max_vote:",
"- ans.append(i)",
"-print((\"\\n\".join(sorted(ans))))",
"+ input = sys.stdin.readline",
"+ n = int(eval(input()))",
"+ s = []",
"+ for _ in range(n):",
"+ s.append(input().rstrip())",
"+ c = Counter(s)",
"+ ans = []",
"+ max_vote = max(c.values())",
"+ for i, j in list(c.items()):",
"+ if j == max_vote:",
"+ ans.append(i)",
"+ print((\"\\n\".join(sorted(ans))))",
"+",
"+",
"+main()"
] | false | 0.058659 | 0.034988 | 1.67653 |
[
"s253726499",
"s010665489"
] |
u268516119
|
p03546
|
python
|
s459028431
|
s238026699
| 197 | 31 | 40,284 | 3,316 |
Accepted
|
Accepted
| 84.26 |
def minindex(arrived,costs):
mindex = "end"
curmin = 100000000
for i in range(10):
if arrived[i]:continue
if curmin>costs[i]:
mindex = i
curmin = costs[i]
return mindex
H,W = list(map(int,input().split()))
C = [[int(j) for j in input().split()] for i in range(10)]
#C[i][j]はiをjにするコスト
#のつもりなんだけど、ダイクストラ法の逆打ち計算では逆をやります
arrived = [False] * 10
arrived[1] = True
costs = [1000000] * 10
costs[1] = 0
curpos = 1
for i in range(10):#残り9頂点
for j,done in enumerate(arrived):
costs[j] = min(costs[j],costs[curpos] + C[j][curpos])
if i==9:break
curpos = minindex(arrived,costs)
arrived[curpos] = True
A = [[int(i) for i in input().split()] for j in range(H)]
def maryoku(x):
if x == -1:return(0)
else:return(costs[x])
print((sum([sum([maryoku(aa) for aa in a]) for a in A])))
|
inf = 1000000000
H,W = list(map(int,input().split()))
C = [[int(j) for j in input().split()] for i in range(10)]
#C[i][j]はiをjにするコスト
#各ノードから1への最短距離
for m in range(10):
for s in range(10):
for g in range(10):
C[s][g] = min(C[s][g],C[s][m] + C[m][g])
def maryoku(x):
if x == -1:return(0)
else:return(C[x][1])
A = [list(map(int,input().split())) for i in range(H)]
print((sum([sum([maryoku(aa) for aa in a]) for a in A])))
| 33 | 17 | 880 | 466 |
def minindex(arrived, costs):
mindex = "end"
curmin = 100000000
for i in range(10):
if arrived[i]:
continue
if curmin > costs[i]:
mindex = i
curmin = costs[i]
return mindex
H, W = list(map(int, input().split()))
C = [[int(j) for j in input().split()] for i in range(10)]
# C[i][j]はiをjにするコスト
# のつもりなんだけど、ダイクストラ法の逆打ち計算では逆をやります
arrived = [False] * 10
arrived[1] = True
costs = [1000000] * 10
costs[1] = 0
curpos = 1
for i in range(10): # 残り9頂点
for j, done in enumerate(arrived):
costs[j] = min(costs[j], costs[curpos] + C[j][curpos])
if i == 9:
break
curpos = minindex(arrived, costs)
arrived[curpos] = True
A = [[int(i) for i in input().split()] for j in range(H)]
def maryoku(x):
if x == -1:
return 0
else:
return costs[x]
print((sum([sum([maryoku(aa) for aa in a]) for a in A])))
|
inf = 1000000000
H, W = list(map(int, input().split()))
C = [[int(j) for j in input().split()] for i in range(10)]
# C[i][j]はiをjにするコスト
# 各ノードから1への最短距離
for m in range(10):
for s in range(10):
for g in range(10):
C[s][g] = min(C[s][g], C[s][m] + C[m][g])
def maryoku(x):
if x == -1:
return 0
else:
return C[x][1]
A = [list(map(int, input().split())) for i in range(H)]
print((sum([sum([maryoku(aa) for aa in a]) for a in A])))
| false | 48.484848 |
[
"-def minindex(arrived, costs):",
"- mindex = \"end\"",
"- curmin = 100000000",
"- for i in range(10):",
"- if arrived[i]:",
"- continue",
"- if curmin > costs[i]:",
"- mindex = i",
"- curmin = costs[i]",
"- return mindex",
"-",
"-",
"+inf = 1000000000",
"-# のつもりなんだけど、ダイクストラ法の逆打ち計算では逆をやります",
"-arrived = [False] * 10",
"-arrived[1] = True",
"-costs = [1000000] * 10",
"-costs[1] = 0",
"-curpos = 1",
"-for i in range(10): # 残り9頂点",
"- for j, done in enumerate(arrived):",
"- costs[j] = min(costs[j], costs[curpos] + C[j][curpos])",
"- if i == 9:",
"- break",
"- curpos = minindex(arrived, costs)",
"- arrived[curpos] = True",
"-A = [[int(i) for i in input().split()] for j in range(H)]",
"+# 各ノードから1への最短距離",
"+for m in range(10):",
"+ for s in range(10):",
"+ for g in range(10):",
"+ C[s][g] = min(C[s][g], C[s][m] + C[m][g])",
"- return costs[x]",
"+ return C[x][1]",
"+A = [list(map(int, input().split())) for i in range(H)]"
] | false | 0.076247 | 0.042554 | 1.791774 |
[
"s459028431",
"s238026699"
] |
u057109575
|
p03221
|
python
|
s226991410
|
s634975269
| 864 | 624 | 35,968 | 47,328 |
Accepted
|
Accepted
| 27.78 |
N, M = list(map(int, input().split()))
X = [[i] + list(map(int, input().split())) for i in range(M)]
X.sort(key=lambda x: (x[1], x[2]))
city = X[0][1]
num = 0
for v in X:
if city == v[1]:
num += 1
else:
city = v[1]
num = 1
v.append(num)
X.sort()
for v in X:
print(('{:06}{:06}'.format(v[1], v[3])))
|
N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
ans = [''] * M
num = [1] * N
for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ans[i] = '{:06}{:06}'.format(v[0], num[v[0] - 1])
num[v[0] - 1] += 1
print(('\n'.join(ans)))
| 17 | 10 | 349 | 299 |
N, M = list(map(int, input().split()))
X = [[i] + list(map(int, input().split())) for i in range(M)]
X.sort(key=lambda x: (x[1], x[2]))
city = X[0][1]
num = 0
for v in X:
if city == v[1]:
num += 1
else:
city = v[1]
num = 1
v.append(num)
X.sort()
for v in X:
print(("{:06}{:06}".format(v[1], v[3])))
|
N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
ans = [""] * M
num = [1] * N
for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ans[i] = "{:06}{:06}".format(v[0], num[v[0] - 1])
num[v[0] - 1] += 1
print(("\n".join(ans)))
| false | 41.176471 |
[
"-X = [[i] + list(map(int, input().split())) for i in range(M)]",
"-X.sort(key=lambda x: (x[1], x[2]))",
"-city = X[0][1]",
"-num = 0",
"-for v in X:",
"- if city == v[1]:",
"- num += 1",
"- else:",
"- city = v[1]",
"- num = 1",
"- v.append(num)",
"-X.sort()",
"-for v in X:",
"- print((\"{:06}{:06}\".format(v[1], v[3])))",
"+X = [list(map(int, input().split())) for _ in range(M)]",
"+ans = [\"\"] * M",
"+num = [1] * N",
"+for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):",
"+ ans[i] = \"{:06}{:06}\".format(v[0], num[v[0] - 1])",
"+ num[v[0] - 1] += 1",
"+print((\"\\n\".join(ans)))"
] | false | 0.036078 | 0.035669 | 1.011492 |
[
"s226991410",
"s634975269"
] |
u755180064
|
p02773
|
python
|
s862342568
|
s058745328
| 1,100 | 642 | 104,400 | 35,208 |
Accepted
|
Accepted
| 41.64 |
def main():
n = int(eval(input()))
words = [eval(input()) for i in range(n)]
words_count = {}
for w in words:
words_count.setdefault(w, 0)
words_count[w] += 1
ans = ''
count = 0
for w in words_count:
count = words_count[w] if words_count[w] > count else count
ans = []
for w in words_count:
if words_count[w] == count:
ans.append(w)
ans = sorted(ans)
for w in ans:
print(w)
if __name__ == '__main__':
main()
|
url = "https://atcoder.jp//contests/abc155/tasks/abc155_c"
def main():
n = int(eval(input()))
words = [eval(input()) for i in range(n)]
words_count = {}
for w in words:
words_count.setdefault(w, 0)
words_count[w] += 1
ans = ''
count = 0
for w in words_count:
count = words_count[w] if words_count[w] > count else count
ans = []
for w in words_count:
if words_count[w] == count:
ans.append(w)
ans = sorted(ans)
for w in ans:
print(w)
if __name__ == '__main__':
main()
| 25 | 28 | 524 | 589 |
def main():
n = int(eval(input()))
words = [eval(input()) for i in range(n)]
words_count = {}
for w in words:
words_count.setdefault(w, 0)
words_count[w] += 1
ans = ""
count = 0
for w in words_count:
count = words_count[w] if words_count[w] > count else count
ans = []
for w in words_count:
if words_count[w] == count:
ans.append(w)
ans = sorted(ans)
for w in ans:
print(w)
if __name__ == "__main__":
main()
|
url = "https://atcoder.jp//contests/abc155/tasks/abc155_c"
def main():
n = int(eval(input()))
words = [eval(input()) for i in range(n)]
words_count = {}
for w in words:
words_count.setdefault(w, 0)
words_count[w] += 1
ans = ""
count = 0
for w in words_count:
count = words_count[w] if words_count[w] > count else count
ans = []
for w in words_count:
if words_count[w] == count:
ans.append(w)
ans = sorted(ans)
for w in ans:
print(w)
if __name__ == "__main__":
main()
| false | 10.714286 |
[
"+url = \"https://atcoder.jp//contests/abc155/tasks/abc155_c\"",
"+",
"+"
] | false | 0.06298 | 0.075458 | 0.834646 |
[
"s862342568",
"s058745328"
] |
u987164499
|
p02861
|
python
|
s808408430
|
s176930857
| 506 | 403 | 11,548 | 3,064 |
Accepted
|
Accepted
| 20.36 |
from sys import stdin
import statistics
from math import factorial
import math
from itertools import permutations
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
lis = []
lin = list(permutations(li,n))
for i in range(len(lin)):
liv = []
for j in range(1,len(lin[0])):
a = (lin[i][j-1][1]-lin[i][j][1])**2
b = (lin[i][j-1][0]-lin[i][j][0])**2
c = math.sqrt(a+b)
liv.append(c)
lis.append(sum(liv))
print((sum(lis)/len(lin)))
|
from itertools import permutations
import math
n = int(eval(input()))
li = [tuple(map(int,input().split())) for _ in range(n)]
# 2点間の距離
def length(x1,y1,x2,y2):
return(math.sqrt(abs(x2-x1)**2+abs(y2-y1)**2))
point = 0
for i in permutations(li):
for j in range(1,n):
point += length(i[j-1][0],i[j-1][1],i[j][0],i[j][1])
print((point/math.factorial(n)))
| 21 | 17 | 548 | 380 |
from sys import stdin
import statistics
from math import factorial
import math
from itertools import permutations
n = int(stdin.readline().rstrip())
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]
lis = []
lin = list(permutations(li, n))
for i in range(len(lin)):
liv = []
for j in range(1, len(lin[0])):
a = (lin[i][j - 1][1] - lin[i][j][1]) ** 2
b = (lin[i][j - 1][0] - lin[i][j][0]) ** 2
c = math.sqrt(a + b)
liv.append(c)
lis.append(sum(liv))
print((sum(lis) / len(lin)))
|
from itertools import permutations
import math
n = int(eval(input()))
li = [tuple(map(int, input().split())) for _ in range(n)]
# 2点間の距離
def length(x1, y1, x2, y2):
return math.sqrt(abs(x2 - x1) ** 2 + abs(y2 - y1) ** 2)
point = 0
for i in permutations(li):
for j in range(1, n):
point += length(i[j - 1][0], i[j - 1][1], i[j][0], i[j][1])
print((point / math.factorial(n)))
| false | 19.047619 |
[
"-from sys import stdin",
"-import statistics",
"-from math import factorial",
"+from itertools import permutations",
"-from itertools import permutations",
"-n = int(stdin.readline().rstrip())",
"-li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]",
"-lis = []",
"-lin = list(permutations(li, n))",
"-for i in range(len(lin)):",
"- liv = []",
"- for j in range(1, len(lin[0])):",
"- a = (lin[i][j - 1][1] - lin[i][j][1]) ** 2",
"- b = (lin[i][j - 1][0] - lin[i][j][0]) ** 2",
"- c = math.sqrt(a + b)",
"- liv.append(c)",
"- lis.append(sum(liv))",
"-print((sum(lis) / len(lin)))",
"+n = int(eval(input()))",
"+li = [tuple(map(int, input().split())) for _ in range(n)]",
"+# 2点間の距離",
"+def length(x1, y1, x2, y2):",
"+ return math.sqrt(abs(x2 - x1) ** 2 + abs(y2 - y1) ** 2)",
"+",
"+",
"+point = 0",
"+for i in permutations(li):",
"+ for j in range(1, n):",
"+ point += length(i[j - 1][0], i[j - 1][1], i[j][0], i[j][1])",
"+print((point / math.factorial(n)))"
] | false | 0.043289 | 0.041658 | 1.039155 |
[
"s808408430",
"s176930857"
] |
u694810977
|
p03545
|
python
|
s623092914
|
s437825103
| 20 | 17 | 3,316 | 3,064 |
Accepted
|
Accepted
| 15 |
S = str(eval(input()))
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A+B+C+D == 7:
print((str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7"))
elif A+B+C-D == 7:
print((str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=" + "7"))
elif A+B-C+D == 7:
print((str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=" + "7"))
elif A+B-C-D == 7:
print((str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=" + "7"))
elif A-B+C+D == 7:
print((str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7"))
elif A-B+C-D == 7:
print((str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=" + "7"))
elif A-B-C+D == 7:
print((str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=" + "7"))
elif A-B-C-D == 7:
print((str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=" + "7"))
|
s = str(eval(input()))
n = len(s)
lists = []
ans_list = []
Sum = 0
for i in range(2**n):
lists = []
ans_list = []
Sum = int(s[0])
for j in range(n-1):
if ((i >> j) & 1):
lists.append(1)
else:
lists.append(0)
for k in range(n-1):
ans_list.append(s[k])
if lists[k] == 1:
ans_list.append("+")
else:
ans_list.append("-")
ans_list.append(s[-1])
for l in range(1,len(ans_list) -1 ):
if ans_list[l] == "+":
Sum += int(ans_list[l+1])
elif ans_list[l] == "-":
Sum -= int(ans_list[l+1])
if Sum == 7:
ans_list.append("=7")
ans = "".join(ans_list)
print(ans)
exit()
| 21 | 33 | 849 | 777 |
S = str(eval(input()))
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A + B + C + D == 7:
print((str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7"))
elif A + B + C - D == 7:
print((str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=" + "7"))
elif A + B - C + D == 7:
print((str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=" + "7"))
elif A + B - C - D == 7:
print((str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=" + "7"))
elif A - B + C + D == 7:
print((str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7"))
elif A - B + C - D == 7:
print((str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=" + "7"))
elif A - B - C + D == 7:
print((str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=" + "7"))
elif A - B - C - D == 7:
print((str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=" + "7"))
|
s = str(eval(input()))
n = len(s)
lists = []
ans_list = []
Sum = 0
for i in range(2**n):
lists = []
ans_list = []
Sum = int(s[0])
for j in range(n - 1):
if (i >> j) & 1:
lists.append(1)
else:
lists.append(0)
for k in range(n - 1):
ans_list.append(s[k])
if lists[k] == 1:
ans_list.append("+")
else:
ans_list.append("-")
ans_list.append(s[-1])
for l in range(1, len(ans_list) - 1):
if ans_list[l] == "+":
Sum += int(ans_list[l + 1])
elif ans_list[l] == "-":
Sum -= int(ans_list[l + 1])
if Sum == 7:
ans_list.append("=7")
ans = "".join(ans_list)
print(ans)
exit()
| false | 36.363636 |
[
"-S = str(eval(input()))",
"-A = int(S[0])",
"-B = int(S[1])",
"-C = int(S[2])",
"-D = int(S[3])",
"-if A + B + C + D == 7:",
"- print((str(A) + \"+\" + str(B) + \"+\" + str(C) + \"+\" + str(D) + \"=\" + \"7\"))",
"-elif A + B + C - D == 7:",
"- print((str(A) + \"+\" + str(B) + \"+\" + str(C) + \"-\" + str(D) + \"=\" + \"7\"))",
"-elif A + B - C + D == 7:",
"- print((str(A) + \"+\" + str(B) + \"-\" + str(C) + \"+\" + str(D) + \"=\" + \"7\"))",
"-elif A + B - C - D == 7:",
"- print((str(A) + \"+\" + str(B) + \"-\" + str(C) + \"-\" + str(D) + \"=\" + \"7\"))",
"-elif A - B + C + D == 7:",
"- print((str(A) + \"-\" + str(B) + \"+\" + str(C) + \"+\" + str(D) + \"=\" + \"7\"))",
"-elif A - B + C - D == 7:",
"- print((str(A) + \"-\" + str(B) + \"+\" + str(C) + \"-\" + str(D) + \"=\" + \"7\"))",
"-elif A - B - C + D == 7:",
"- print((str(A) + \"-\" + str(B) + \"-\" + str(C) + \"+\" + str(D) + \"=\" + \"7\"))",
"-elif A - B - C - D == 7:",
"- print((str(A) + \"-\" + str(B) + \"-\" + str(C) + \"-\" + str(D) + \"=\" + \"7\"))",
"+s = str(eval(input()))",
"+n = len(s)",
"+lists = []",
"+ans_list = []",
"+Sum = 0",
"+for i in range(2**n):",
"+ lists = []",
"+ ans_list = []",
"+ Sum = int(s[0])",
"+ for j in range(n - 1):",
"+ if (i >> j) & 1:",
"+ lists.append(1)",
"+ else:",
"+ lists.append(0)",
"+ for k in range(n - 1):",
"+ ans_list.append(s[k])",
"+ if lists[k] == 1:",
"+ ans_list.append(\"+\")",
"+ else:",
"+ ans_list.append(\"-\")",
"+ ans_list.append(s[-1])",
"+ for l in range(1, len(ans_list) - 1):",
"+ if ans_list[l] == \"+\":",
"+ Sum += int(ans_list[l + 1])",
"+ elif ans_list[l] == \"-\":",
"+ Sum -= int(ans_list[l + 1])",
"+ if Sum == 7:",
"+ ans_list.append(\"=7\")",
"+ ans = \"\".join(ans_list)",
"+ print(ans)",
"+ exit()"
] | false | 0.041256 | 0.042919 | 0.961273 |
[
"s623092914",
"s437825103"
] |
u987164499
|
p03043
|
python
|
s712072927
|
s849370654
| 60 | 38 | 3,060 | 3,064 |
Accepted
|
Accepted
| 36.67 |
from sys import stdin
n,k = [int(x) for x in stdin.readline().rstrip().split()]
point = 0
kaku = 0.0
for i in range(1,n+1):
point = 0
point += i
kaisu = 0
while 0 < point < k:
kaisu += 1
point *= 2
kaku += (1/n)*(1/(2**kaisu))
print(kaku)
|
n,k = list(map(int,input().split()))
point = 0
for i in range(1,n+1):
j = 1/n
if i >= k:
point += j
continue
now = i
count = 0
while now < k:
now *= 2
count += 1
j *= (1/2)**count
point += j
print(point)
| 16 | 17 | 292 | 279 |
from sys import stdin
n, k = [int(x) for x in stdin.readline().rstrip().split()]
point = 0
kaku = 0.0
for i in range(1, n + 1):
point = 0
point += i
kaisu = 0
while 0 < point < k:
kaisu += 1
point *= 2
kaku += (1 / n) * (1 / (2**kaisu))
print(kaku)
|
n, k = list(map(int, input().split()))
point = 0
for i in range(1, n + 1):
j = 1 / n
if i >= k:
point += j
continue
now = i
count = 0
while now < k:
now *= 2
count += 1
j *= (1 / 2) ** count
point += j
print(point)
| false | 5.882353 |
[
"-from sys import stdin",
"-",
"-n, k = [int(x) for x in stdin.readline().rstrip().split()]",
"+n, k = list(map(int, input().split()))",
"-kaku = 0.0",
"- point = 0",
"- point += i",
"- kaisu = 0",
"- while 0 < point < k:",
"- kaisu += 1",
"- point *= 2",
"- kaku += (1 / n) * (1 / (2**kaisu))",
"-print(kaku)",
"+ j = 1 / n",
"+ if i >= k:",
"+ point += j",
"+ continue",
"+ now = i",
"+ count = 0",
"+ while now < k:",
"+ now *= 2",
"+ count += 1",
"+ j *= (1 / 2) ** count",
"+ point += j",
"+print(point)"
] | false | 0.006836 | 0.047927 | 0.142634 |
[
"s712072927",
"s849370654"
] |
u480200603
|
p03127
|
python
|
s766991150
|
s817990253
| 143 | 61 | 14,252 | 14,224 |
Accepted
|
Accepted
| 57.34 |
import sys
n = int(eval(input()))
a = list(map(int, input().split()))
sys.setrecursionlimit(10 ** 5)
def cut(l):
l.sort()
nokori = [l[0]]
for i in range(1, len(l)):
b = l[i] % l[0]
if b != 0:
nokori.append(b)
if len(nokori) != 1:
return cut(nokori)
return nokori[0]
print((cut(a)))
|
import sys
n = int(eval(input()))
al = list(map(int, input().split()))
sys.setrecursionlimit(10 ** 5)
def gcd(a, b):
if b < a:
a, b = b, a
if b % a == 0:
return a
else:
return gcd(a, b % a)
def gcdl(num, n):
ans = num[0]
for i in range(n):
ans = gcd(ans, num[i])
return ans
print((gcdl(al, n)))
| 19 | 24 | 352 | 373 |
import sys
n = int(eval(input()))
a = list(map(int, input().split()))
sys.setrecursionlimit(10**5)
def cut(l):
l.sort()
nokori = [l[0]]
for i in range(1, len(l)):
b = l[i] % l[0]
if b != 0:
nokori.append(b)
if len(nokori) != 1:
return cut(nokori)
return nokori[0]
print((cut(a)))
|
import sys
n = int(eval(input()))
al = list(map(int, input().split()))
sys.setrecursionlimit(10**5)
def gcd(a, b):
if b < a:
a, b = b, a
if b % a == 0:
return a
else:
return gcd(a, b % a)
def gcdl(num, n):
ans = num[0]
for i in range(n):
ans = gcd(ans, num[i])
return ans
print((gcdl(al, n)))
| false | 20.833333 |
[
"-a = list(map(int, input().split()))",
"+al = list(map(int, input().split()))",
"-def cut(l):",
"- l.sort()",
"- nokori = [l[0]]",
"- for i in range(1, len(l)):",
"- b = l[i] % l[0]",
"- if b != 0:",
"- nokori.append(b)",
"- if len(nokori) != 1:",
"- return cut(nokori)",
"- return nokori[0]",
"+def gcd(a, b):",
"+ if b < a:",
"+ a, b = b, a",
"+ if b % a == 0:",
"+ return a",
"+ else:",
"+ return gcd(a, b % a)",
"-print((cut(a)))",
"+def gcdl(num, n):",
"+ ans = num[0]",
"+ for i in range(n):",
"+ ans = gcd(ans, num[i])",
"+ return ans",
"+",
"+",
"+print((gcdl(al, n)))"
] | false | 0.045555 | 0.035489 | 1.283638 |
[
"s766991150",
"s817990253"
] |
u695811449
|
p03025
|
python
|
s537657145
|
s571164210
| 1,597 | 857 | 18,984 | 20,528 |
Accepted
|
Accepted
| 46.34 |
N,A,B,C=list(map(int,input().split()))
mod=10**9+7
#factorial,facotiralの逆数を事前計算.
#N=10**5あたりまで有効
FACT=[1,1]
FACT_INV=[1,1]
for i in range(2,2*10**5+1):
FACT.append(FACT[-1]*i%mod)
FACT_INV.append(FACT_INV[-1]*pow(i,mod-2,mod)%mod)
def Combi(N,K):
return FACT[N]*FACT_INV[N-K]*FACT_INV[K]%mod
#Aが勝つ場合
ANS=0
SUM=A+B
A_n=pow(A,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
B_n=pow(B,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
SUMINV=pow(SUM,mod-2,mod)
for i in range(N):
ANS=(ANS+(A_n*pow(B,i,mod)+B_n*pow(A,i,mod))*Combi(N-1+i,i)*pow(SUMINV,i,mod)*(N+i))%mod
print((ANS*100*pow(100-C,mod-2,mod)%mod))
|
N,A,B,C=list(map(int,input().split()))
mod=10**9+7
#factorial,facotiralの逆数を事前計算.
#N=10**5あたりまで有効
FACT=[1]
for i in range(1,2*10**5+1):
FACT.append(FACT[-1]*i%mod)
FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
FACT_INV.append(FACT_INV[-1]*i%mod)
FACT_INV=FACT_INV[::-1]
def Combi(N,K):
return FACT[N]*FACT_INV[N-K]*FACT_INV[K]%mod
ANS=0
SUM=A+B
A_n=pow(A,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
B_n=pow(B,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
SUMINV=pow(SUM,mod-2,mod)
for i in range(N):
ANS=(ANS+(A_n*pow(B,i,mod)+B_n*pow(A,i,mod))*Combi(N-1+i,i)*pow(SUMINV,i,mod)*(N+i))%mod
print((ANS*100*pow(100-C,mod-2,mod)%mod))
| 28 | 31 | 639 | 694 |
N, A, B, C = list(map(int, input().split()))
mod = 10**9 + 7
# factorial,facotiralの逆数を事前計算.
# N=10**5あたりまで有効
FACT = [1, 1]
FACT_INV = [1, 1]
for i in range(2, 2 * 10**5 + 1):
FACT.append(FACT[-1] * i % mod)
FACT_INV.append(FACT_INV[-1] * pow(i, mod - 2, mod) % mod)
def Combi(N, K):
return FACT[N] * FACT_INV[N - K] * FACT_INV[K] % mod
# Aが勝つ場合
ANS = 0
SUM = A + B
A_n = pow(A, N, mod) * pow(pow(SUM, mod - 2, mod), N, mod) % mod
B_n = pow(B, N, mod) * pow(pow(SUM, mod - 2, mod), N, mod) % mod
SUMINV = pow(SUM, mod - 2, mod)
for i in range(N):
ANS = (
ANS
+ (A_n * pow(B, i, mod) + B_n * pow(A, i, mod))
* Combi(N - 1 + i, i)
* pow(SUMINV, i, mod)
* (N + i)
) % mod
print((ANS * 100 * pow(100 - C, mod - 2, mod) % mod))
|
N, A, B, C = list(map(int, input().split()))
mod = 10**9 + 7
# factorial,facotiralの逆数を事前計算.
# N=10**5あたりまで有効
FACT = [1]
for i in range(1, 2 * 10**5 + 1):
FACT.append(FACT[-1] * i % mod)
FACT_INV = [pow(FACT[-1], mod - 2, mod)]
for i in range(2 * 10**5, 0, -1):
FACT_INV.append(FACT_INV[-1] * i % mod)
FACT_INV = FACT_INV[::-1]
def Combi(N, K):
return FACT[N] * FACT_INV[N - K] * FACT_INV[K] % mod
ANS = 0
SUM = A + B
A_n = pow(A, N, mod) * pow(pow(SUM, mod - 2, mod), N, mod) % mod
B_n = pow(B, N, mod) * pow(pow(SUM, mod - 2, mod), N, mod) % mod
SUMINV = pow(SUM, mod - 2, mod)
for i in range(N):
ANS = (
ANS
+ (A_n * pow(B, i, mod) + B_n * pow(A, i, mod))
* Combi(N - 1 + i, i)
* pow(SUMINV, i, mod)
* (N + i)
) % mod
print((ANS * 100 * pow(100 - C, mod - 2, mod) % mod))
| false | 9.677419 |
[
"-FACT = [1, 1]",
"-FACT_INV = [1, 1]",
"-for i in range(2, 2 * 10**5 + 1):",
"+FACT = [1]",
"+for i in range(1, 2 * 10**5 + 1):",
"- FACT_INV.append(FACT_INV[-1] * pow(i, mod - 2, mod) % mod)",
"+FACT_INV = [pow(FACT[-1], mod - 2, mod)]",
"+for i in range(2 * 10**5, 0, -1):",
"+ FACT_INV.append(FACT_INV[-1] * i % mod)",
"+FACT_INV = FACT_INV[::-1]",
"-# Aが勝つ場合"
] | false | 1.049866 | 0.252206 | 4.162725 |
[
"s537657145",
"s571164210"
] |
u561083515
|
p02781
|
python
|
s801901817
|
s637302135
| 26 | 22 | 3,940 | 3,064 |
Accepted
|
Accepted
| 15.38 |
# ref: https://atcoder.jp/contests/abc154/submissions/9991364
from functools import lru_cache
#0以上N以下の整数で、0でない数字がちょうどK個あるものの個数
@lru_cache(None)
def F(N, K):
assert N >= 0
if N < 10:
if K == 0:
return 1
if K == 1:
return N
else:
return 0
q,r = divmod(N,10)
ans = 0
if K >= 1:
# 1の位が0ではない
ans += F(q, K-1) * r
ans += F(q-1, K-1) * (9-r)
# 1の位が0
ans += F(q, K)
return ans
def main():
N = int(eval(input()))
K = int(eval(input()))
print((F(N,K)))
if __name__ == "__main__":
main()
|
N = eval(input())
K = int(eval(input()))
L = len(N)
# dp[i][j][k]
# i: 決定した桁数(上から)
# j: 0の個数
# k: N未満確定フラグ
dp = [[[0] * 2 for _ in range(5)] for _ in range(110)]
dp[0][0][0] = 1
# 配るDP
for i in range(L):
S = int(N[i])
for j in range(K+1):
for k in range(2):
# d: 次の桁
for d in range((9 if k else S) + 1):
dp[i+1][j + (d != 0)][k | (d < S)] += dp[i][j][k]
ans = dp[L][K][0] + dp[L][K][1]
print(ans)
| 36 | 24 | 645 | 468 |
# ref: https://atcoder.jp/contests/abc154/submissions/9991364
from functools import lru_cache
# 0以上N以下の整数で、0でない数字がちょうどK個あるものの個数
@lru_cache(None)
def F(N, K):
assert N >= 0
if N < 10:
if K == 0:
return 1
if K == 1:
return N
else:
return 0
q, r = divmod(N, 10)
ans = 0
if K >= 1:
# 1の位が0ではない
ans += F(q, K - 1) * r
ans += F(q - 1, K - 1) * (9 - r)
# 1の位が0
ans += F(q, K)
return ans
def main():
N = int(eval(input()))
K = int(eval(input()))
print((F(N, K)))
if __name__ == "__main__":
main()
|
N = eval(input())
K = int(eval(input()))
L = len(N)
# dp[i][j][k]
# i: 決定した桁数(上から)
# j: 0の個数
# k: N未満確定フラグ
dp = [[[0] * 2 for _ in range(5)] for _ in range(110)]
dp[0][0][0] = 1
# 配るDP
for i in range(L):
S = int(N[i])
for j in range(K + 1):
for k in range(2):
# d: 次の桁
for d in range((9 if k else S) + 1):
dp[i + 1][j + (d != 0)][k | (d < S)] += dp[i][j][k]
ans = dp[L][K][0] + dp[L][K][1]
print(ans)
| false | 33.333333 |
[
"-# ref: https://atcoder.jp/contests/abc154/submissions/9991364",
"-from functools import lru_cache",
"-",
"-# 0以上N以下の整数で、0でない数字がちょうどK個あるものの個数",
"-@lru_cache(None)",
"-def F(N, K):",
"- assert N >= 0",
"- if N < 10:",
"- if K == 0:",
"- return 1",
"- if K == 1:",
"- return N",
"- else:",
"- return 0",
"- q, r = divmod(N, 10)",
"- ans = 0",
"- if K >= 1:",
"- # 1の位が0ではない",
"- ans += F(q, K - 1) * r",
"- ans += F(q - 1, K - 1) * (9 - r)",
"- # 1の位が0",
"- ans += F(q, K)",
"- return ans",
"-",
"-",
"-def main():",
"- N = int(eval(input()))",
"- K = int(eval(input()))",
"- print((F(N, K)))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+N = eval(input())",
"+K = int(eval(input()))",
"+L = len(N)",
"+# dp[i][j][k]",
"+# i: 決定した桁数(上から)",
"+# j: 0の個数",
"+# k: N未満確定フラグ",
"+dp = [[[0] * 2 for _ in range(5)] for _ in range(110)]",
"+dp[0][0][0] = 1",
"+# 配るDP",
"+for i in range(L):",
"+ S = int(N[i])",
"+ for j in range(K + 1):",
"+ for k in range(2):",
"+ # d: 次の桁",
"+ for d in range((9 if k else S) + 1):",
"+ dp[i + 1][j + (d != 0)][k | (d < S)] += dp[i][j][k]",
"+ans = dp[L][K][0] + dp[L][K][1]",
"+print(ans)"
] | false | 0.149627 | 0.043945 | 3.404909 |
[
"s801901817",
"s637302135"
] |
u014333473
|
p03719
|
python
|
s064413964
|
s918795829
| 29 | 24 | 9,060 | 9,168 |
Accepted
|
Accepted
| 17.24 |
a,b,c=list(map(int,input().split()));print((' YNeos'[a<=c<=b::2].strip()))
|
a,b,c=list(map(int,input().split()));print((['No','Yes'][a<=c<=b]))
| 1 | 1 | 66 | 59 |
a, b, c = list(map(int, input().split()))
print((" YNeos"[a <= c <= b :: 2].strip()))
|
a, b, c = list(map(int, input().split()))
print((["No", "Yes"][a <= c <= b]))
| false | 0 |
[
"-print((\" YNeos\"[a <= c <= b :: 2].strip()))",
"+print(([\"No\", \"Yes\"][a <= c <= b]))"
] | false | 0.041233 | 0.040075 | 1.028898 |
[
"s064413964",
"s918795829"
] |
u054514819
|
p02830
|
python
|
s120632257
|
s604058976
| 178 | 67 | 38,256 | 61,968 |
Accepted
|
Accepted
| 62.36 |
N = int(eval(input()))
s, t = list(map(str, input().split()))
ans = ''
for n in range(N):
ans += s[n]
ans += t[n]
print(ans)
|
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N = int(eval(input()))
S, T = input().split()
ans = ''
for s, t in zip(list(S), list(T)):
ans += s+t
print(ans)
| 8 | 11 | 128 | 256 |
N = int(eval(input()))
s, t = list(map(str, input().split()))
ans = ""
for n in range(N):
ans += s[n]
ans += t[n]
print(ans)
|
import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N = int(eval(input()))
S, T = input().split()
ans = ""
for s, t in zip(list(S), list(T)):
ans += s + t
print(ans)
| false | 27.272727 |
[
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def mapint():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+sys.setrecursionlimit(10**9)",
"-s, t = list(map(str, input().split()))",
"+S, T = input().split()",
"-for n in range(N):",
"- ans += s[n]",
"- ans += t[n]",
"+for s, t in zip(list(S), list(T)):",
"+ ans += s + t"
] | false | 0.007699 | 0.040657 | 0.189364 |
[
"s120632257",
"s604058976"
] |
u519939795
|
p03636
|
python
|
s268562070
|
s501515721
| 21 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 19.05 |
s = str(eval(input()))
x = len(s) -2
print((s[0] + str(x) + s[-1]))
|
s = eval(input())
print((s[0]+str(len(s)-2)+s[-1:]))
| 5 | 2 | 66 | 45 |
s = str(eval(input()))
x = len(s) - 2
print((s[0] + str(x) + s[-1]))
|
s = eval(input())
print((s[0] + str(len(s) - 2) + s[-1:]))
| false | 60 |
[
"-s = str(eval(input()))",
"-x = len(s) - 2",
"-print((s[0] + str(x) + s[-1]))",
"+s = eval(input())",
"+print((s[0] + str(len(s) - 2) + s[-1:]))"
] | false | 0.063665 | 0.046369 | 1.373006 |
[
"s268562070",
"s501515721"
] |
u094191970
|
p03285
|
python
|
s505207395
|
s132035467
| 19 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 10.53 |
def inp_i(): return list(map(int, input().split()))
N=int(eval(input()))
ans=0
for i in range(N):
for n in range(N):
if (4*i)+(7*n)==N:
ans += 1
if ans != 0:
print('Yes')
else:
print('No')
|
n=int(eval(input()))
for i in range(n):
for j in range(n):
if i*4+j*7==n:
print('Yes')
exit()
print('No')
| 12 | 8 | 220 | 125 |
def inp_i():
return list(map(int, input().split()))
N = int(eval(input()))
ans = 0
for i in range(N):
for n in range(N):
if (4 * i) + (7 * n) == N:
ans += 1
if ans != 0:
print("Yes")
else:
print("No")
|
n = int(eval(input()))
for i in range(n):
for j in range(n):
if i * 4 + j * 7 == n:
print("Yes")
exit()
print("No")
| false | 33.333333 |
[
"-def inp_i():",
"- return list(map(int, input().split()))",
"-",
"-",
"-N = int(eval(input()))",
"-ans = 0",
"-for i in range(N):",
"- for n in range(N):",
"- if (4 * i) + (7 * n) == N:",
"- ans += 1",
"-if ans != 0:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+n = int(eval(input()))",
"+for i in range(n):",
"+ for j in range(n):",
"+ if i * 4 + j * 7 == n:",
"+ print(\"Yes\")",
"+ exit()",
"+print(\"No\")"
] | false | 0.063421 | 0.040455 | 1.567707 |
[
"s505207395",
"s132035467"
] |
u607563136
|
p03127
|
python
|
s887856510
|
s852841706
| 105 | 58 | 20,008 | 20,604 |
Accepted
|
Accepted
| 44.76 |
n = int(eval(input()))
a = list(map(int,input().split()))
x = a[0]
for i in range(1,n):
y = a[i]
x,y = max(x,y),min(x,y)
while y!= 0:
x,y = y,x%y
print(x)
|
import functools
import math
n = int(eval(input()))
a = list(map(int,input().split()))
print((functools.reduce(math.gcd,a)))
| 10 | 5 | 178 | 120 |
n = int(eval(input()))
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
y = a[i]
x, y = max(x, y), min(x, y)
while y != 0:
x, y = y, x % y
print(x)
|
import functools
import math
n = int(eval(input()))
a = list(map(int, input().split()))
print((functools.reduce(math.gcd, a)))
| false | 50 |
[
"+import functools",
"+import math",
"+",
"-x = a[0]",
"-for i in range(1, n):",
"- y = a[i]",
"- x, y = max(x, y), min(x, y)",
"- while y != 0:",
"- x, y = y, x % y",
"-print(x)",
"+print((functools.reduce(math.gcd, a)))"
] | false | 0.037736 | 0.038361 | 0.983725 |
[
"s887856510",
"s852841706"
] |
u506858457
|
p03862
|
python
|
s572290037
|
s256818656
| 105 | 90 | 14,540 | 14,132 |
Accepted
|
Accepted
| 14.29 |
N,x=list(map(int,input().split()))
A=list(map(int,input().split()))
cnt=0
pre=0
for i in range(N):
dif=max(A[i]+pre-x,0)
cnt+=dif
A[i]-=dif
pre=A[i]
print(cnt)
|
N,x=list(map(int,input().split()))
A=list(map(int,input().split()))
if A[0]>x:
cnt=A[0]-x
A[0]=A[0]-cnt
else:
cnt=0
for i in range(1,N):
gap=A[i]+A[i-1]-x
if gap>0:
cnt+=gap
A[i]-=gap
print(cnt)
| 13 | 13 | 184 | 222 |
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
cnt = 0
pre = 0
for i in range(N):
dif = max(A[i] + pre - x, 0)
cnt += dif
A[i] -= dif
pre = A[i]
print(cnt)
|
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
if A[0] > x:
cnt = A[0] - x
A[0] = A[0] - cnt
else:
cnt = 0
for i in range(1, N):
gap = A[i] + A[i - 1] - x
if gap > 0:
cnt += gap
A[i] -= gap
print(cnt)
| false | 0 |
[
"-cnt = 0",
"-pre = 0",
"-for i in range(N):",
"- dif = max(A[i] + pre - x, 0)",
"- cnt += dif",
"- A[i] -= dif",
"- pre = A[i]",
"+if A[0] > x:",
"+ cnt = A[0] - x",
"+ A[0] = A[0] - cnt",
"+else:",
"+ cnt = 0",
"+for i in range(1, N):",
"+ gap = A[i] + A[i - 1] - x",
"+ if gap > 0:",
"+ cnt += gap",
"+ A[i] -= gap"
] | false | 0.046316 | 0.066332 | 0.698239 |
[
"s572290037",
"s256818656"
] |
u148551245
|
p03423
|
python
|
s402498066
|
s722701537
| 176 | 17 | 38,400 | 2,940 |
Accepted
|
Accepted
| 90.34 |
n = int(eval(input()))
print((n // 3))
|
n = int(eval(input()))
ans = n // 3
print(ans)
| 2 | 3 | 31 | 42 |
n = int(eval(input()))
print((n // 3))
|
n = int(eval(input()))
ans = n // 3
print(ans)
| false | 33.333333 |
[
"-print((n // 3))",
"+ans = n // 3",
"+print(ans)"
] | false | 0.148039 | 0.038967 | 3.799047 |
[
"s402498066",
"s722701537"
] |
u867826040
|
p02879
|
python
|
s769099667
|
s704076654
| 169 | 28 | 38,256 | 9,164 |
Accepted
|
Accepted
| 83.43 |
A, B = list(map(int, input().split()))
if A >= 10 or B >= 10:
print((-1))
else:
print((A*B))
|
a,b = list(map(int,input().split()))
if a <= 9 and b <= 9:
print((a*b))
else:
print((-1))
| 6 | 5 | 97 | 87 |
A, B = list(map(int, input().split()))
if A >= 10 or B >= 10:
print((-1))
else:
print((A * B))
|
a, b = list(map(int, input().split()))
if a <= 9 and b <= 9:
print((a * b))
else:
print((-1))
| false | 16.666667 |
[
"-A, B = list(map(int, input().split()))",
"-if A >= 10 or B >= 10:",
"+a, b = list(map(int, input().split()))",
"+if a <= 9 and b <= 9:",
"+ print((a * b))",
"+else:",
"-else:",
"- print((A * B))"
] | false | 0.086753 | 0.03806 | 2.279346 |
[
"s769099667",
"s704076654"
] |
u952708174
|
p02918
|
python
|
s719487762
|
s399960739
| 37 | 31 | 4,728 | 3,956 |
Accepted
|
Accepted
| 16.22 |
def d_face_produces_unhappiness():
N, K = [int(i) for i in input().split()]
S = eval(input())
before_char = S[0]
t = []
v = 0
for s in S + '*':
if s != before_char:
t.append(v)
v = 1
else:
v += 1
before_char = s
t.sort(reverse=True)
for i in range(min(K, len(t))):
t[i] += 2
return min(sum([e - 1 for e in t]), N - 1)
print((d_face_produces_unhappiness()))
|
def d_face_produces_unhappiness():
N, K = [int(i) for i in input().split()]
S = eval(input())
# 初期状態で幸福な人数 + 1回の操作で高々2人増やせる。ただしN-1人まで
score_first = len([1 for i in range(N - 1) if S[i] == S[i + 1]])
return min(score_first + 2 * K, N - 1)
print((d_face_produces_unhappiness()))
| 19 | 9 | 471 | 298 |
def d_face_produces_unhappiness():
N, K = [int(i) for i in input().split()]
S = eval(input())
before_char = S[0]
t = []
v = 0
for s in S + "*":
if s != before_char:
t.append(v)
v = 1
else:
v += 1
before_char = s
t.sort(reverse=True)
for i in range(min(K, len(t))):
t[i] += 2
return min(sum([e - 1 for e in t]), N - 1)
print((d_face_produces_unhappiness()))
|
def d_face_produces_unhappiness():
N, K = [int(i) for i in input().split()]
S = eval(input())
# 初期状態で幸福な人数 + 1回の操作で高々2人増やせる。ただしN-1人まで
score_first = len([1 for i in range(N - 1) if S[i] == S[i + 1]])
return min(score_first + 2 * K, N - 1)
print((d_face_produces_unhappiness()))
| false | 52.631579 |
[
"- before_char = S[0]",
"- t = []",
"- v = 0",
"- for s in S + \"*\":",
"- if s != before_char:",
"- t.append(v)",
"- v = 1",
"- else:",
"- v += 1",
"- before_char = s",
"- t.sort(reverse=True)",
"- for i in range(min(K, len(t))):",
"- t[i] += 2",
"- return min(sum([e - 1 for e in t]), N - 1)",
"+ # 初期状態で幸福な人数 + 1回の操作で高々2人増やせる。ただしN-1人まで",
"+ score_first = len([1 for i in range(N - 1) if S[i] == S[i + 1]])",
"+ return min(score_first + 2 * K, N - 1)"
] | false | 0.118458 | 0.077029 | 1.537829 |
[
"s719487762",
"s399960739"
] |
u998435601
|
p02397
|
python
|
s109899503
|
s950613637
| 30 | 20 | 6,272 | 6,400 |
Accepted
|
Accepted
| 33.33 |
while 1:
a,b = list(map(int, input().split()))
if a == b == 0:
break
elif a < b:
print("%s %s" % (a,b))
else:
print("%s %s" % (b,a))
|
while 1:
a,b = list(map(int, input().split()))
if a == 0 and b == 0:
break
elif a < b:
print(a, b)
else:
print(b, a)
| 8 | 8 | 145 | 129 |
while 1:
a, b = list(map(int, input().split()))
if a == b == 0:
break
elif a < b:
print("%s %s" % (a, b))
else:
print("%s %s" % (b, a))
|
while 1:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
elif a < b:
print(a, b)
else:
print(b, a)
| false | 0 |
[
"- if a == b == 0:",
"+ if a == 0 and b == 0:",
"- print(\"%s %s\" % (a, b))",
"+ print(a, b)",
"- print(\"%s %s\" % (b, a))",
"+ print(b, a)"
] | false | 0.05459 | 0.112614 | 0.484749 |
[
"s109899503",
"s950613637"
] |
u863442865
|
p03163
|
python
|
s375825116
|
s878463534
| 409 | 282 | 118,640 | 39,792 |
Accepted
|
Accepted
| 31.05 |
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations
#from itertools import accumulate, product
from bisect import bisect_left,bisect_right
from math import floor, ceil
#from operator import itemgetter
#mod = 1000000007
N, W = list(map(int, input().split()))
w = [0]*N
v = [0]*N
for i in range(N):
w[i], v[i] = list(map(int, input().split()))
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
for j in range(W+1):
if w[i]<=j:
dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
else:
dp[i+1][j] = dp[i][j]
print((dp[N][W]))
if __name__ == '__main__':
main()
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations
#from itertools import accumulate, product
from bisect import bisect_left,bisect_right
from math import floor, ceil
#from operator import itemgetter
#mod = 1000000007
N, W = list(map(int,input().split()))
wv = [tuple(map(int,input().split())) for i in range(N)]
dp = [0]*(W+1)
for i in range(N):
for j in range(W, wv[i][0]-1, -1):
dp[j] = max(dp[j], dp[j-wv[i][0]]+wv[i][1])
print((max(dp)))
if __name__ == '__main__':
main()
| 33 | 24 | 888 | 743 |
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations
# from itertools import accumulate, product
from bisect import bisect_left, bisect_right
from math import floor, ceil
# from operator import itemgetter
# mod = 1000000007
N, W = list(map(int, input().split()))
w = [0] * N
v = [0] * N
for i in range(N):
w[i], v[i] = list(map(int, input().split()))
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
for j in range(W + 1):
if w[i] <= j:
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
else:
dp[i + 1][j] = dp[i][j]
print((dp[N][W]))
if __name__ == "__main__":
main()
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations
# from itertools import accumulate, product
from bisect import bisect_left, bisect_right
from math import floor, ceil
# from operator import itemgetter
# mod = 1000000007
N, W = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for i in range(N)]
dp = [0] * (W + 1)
for i in range(N):
for j in range(W, wv[i][0] - 1, -1):
dp[j] = max(dp[j], dp[j - wv[i][0]] + wv[i][1])
print((max(dp)))
if __name__ == "__main__":
main()
| false | 27.272727 |
[
"- w = [0] * N",
"- v = [0] * N",
"+ wv = [tuple(map(int, input().split())) for i in range(N)]",
"+ dp = [0] * (W + 1)",
"- w[i], v[i] = list(map(int, input().split()))",
"- dp = [[0] * (W + 1) for _ in range(N + 1)]",
"- for i in range(N):",
"- for j in range(W + 1):",
"- if w[i] <= j:",
"- dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])",
"- else:",
"- dp[i + 1][j] = dp[i][j]",
"- print((dp[N][W]))",
"+ for j in range(W, wv[i][0] - 1, -1):",
"+ dp[j] = max(dp[j], dp[j - wv[i][0]] + wv[i][1])",
"+ print((max(dp)))"
] | false | 0.110319 | 0.146813 | 0.751424 |
[
"s375825116",
"s878463534"
] |
u961683878
|
p02659
|
python
|
s438687392
|
s728856967
| 118 | 104 | 27,152 | 27,156 |
Accepted
|
Accepted
| 11.86 |
#! /usr/bin/env python3
import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
A, B = list(map(float, readline().split()))
ans = int(A) * int(B * 1000000) // 1000000
print((int(ans)))
|
#! /usr/bin/env python3
import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
A, B = readline().decode().rstrip().split()
A = int(A)
B = 100 * int(B[0]) + 10 * int(B[2]) + int(B[3])
ans = A * B // 100
print(ans)
| 16 | 18 | 344 | 383 |
#! /usr/bin/env python3
import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
A, B = list(map(float, readline().split()))
ans = int(A) * int(B * 1000000) // 1000000
print((int(ans)))
|
#! /usr/bin/env python3
import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
A, B = readline().decode().rstrip().split()
A = int(A)
B = 100 * int(B[0]) + 10 * int(B[2]) + int(B[3])
ans = A * B // 100
print(ans)
| false | 11.111111 |
[
"-A, B = list(map(float, readline().split()))",
"-ans = int(A) * int(B * 1000000) // 1000000",
"-print((int(ans)))",
"+A, B = readline().decode().rstrip().split()",
"+A = int(A)",
"+B = 100 * int(B[0]) + 10 * int(B[2]) + int(B[3])",
"+ans = A * B // 100",
"+print(ans)"
] | false | 0.039496 | 0.041476 | 0.952265 |
[
"s438687392",
"s728856967"
] |
u484229314
|
p03073
|
python
|
s404871186
|
s300700421
| 664 | 128 | 11,132 | 3,956 |
Accepted
|
Accepted
| 80.72 |
S = eval(input())
s0 = [0 for i in range(len(S))]
s1 = [1 for i in range(len(S))]
for i in range(0, len(S), 2):
s0[i] = (s0[i] + 1) % 2
s1[i] = (s1[i] + 1) % 2
s0 = ''.join(map(str, s0))
s1 = ''.join(map(str, s1))
def cnt(x):
cnt = 0
while x > 0:
cnt += x & 1
x = x >> 1
return cnt
print((min(cnt(int(S, 2) ^ int(s0, 2)), cnt(int(S, 2) ^ int(s1, 2)))))
|
S = eval(input())
s0 = 0
s1 = 0
for i, s in enumerate(list(S)):
s0 += int(str(i % 2) == s)
s1 += int(str((i + 1) % 2) == s)
print((min(s0, s1)))
| 21 | 8 | 407 | 153 |
S = eval(input())
s0 = [0 for i in range(len(S))]
s1 = [1 for i in range(len(S))]
for i in range(0, len(S), 2):
s0[i] = (s0[i] + 1) % 2
s1[i] = (s1[i] + 1) % 2
s0 = "".join(map(str, s0))
s1 = "".join(map(str, s1))
def cnt(x):
cnt = 0
while x > 0:
cnt += x & 1
x = x >> 1
return cnt
print((min(cnt(int(S, 2) ^ int(s0, 2)), cnt(int(S, 2) ^ int(s1, 2)))))
|
S = eval(input())
s0 = 0
s1 = 0
for i, s in enumerate(list(S)):
s0 += int(str(i % 2) == s)
s1 += int(str((i + 1) % 2) == s)
print((min(s0, s1)))
| false | 61.904762 |
[
"-s0 = [0 for i in range(len(S))]",
"-s1 = [1 for i in range(len(S))]",
"-for i in range(0, len(S), 2):",
"- s0[i] = (s0[i] + 1) % 2",
"- s1[i] = (s1[i] + 1) % 2",
"-s0 = \"\".join(map(str, s0))",
"-s1 = \"\".join(map(str, s1))",
"-",
"-",
"-def cnt(x):",
"- cnt = 0",
"- while x > 0:",
"- cnt += x & 1",
"- x = x >> 1",
"- return cnt",
"-",
"-",
"-print((min(cnt(int(S, 2) ^ int(s0, 2)), cnt(int(S, 2) ^ int(s1, 2)))))",
"+s0 = 0",
"+s1 = 0",
"+for i, s in enumerate(list(S)):",
"+ s0 += int(str(i % 2) == s)",
"+ s1 += int(str((i + 1) % 2) == s)",
"+print((min(s0, s1)))"
] | false | 0.108418 | 0.084275 | 1.286479 |
[
"s404871186",
"s300700421"
] |
u706659319
|
p02554
|
python
|
s745618575
|
s019418768
| 113 | 81 | 62,752 | 63,936 |
Accepted
|
Accepted
| 28.32 |
def div(n,T):
tmp = 10 ** 9 + 7
_ = 1
for t in range( T- 1):
_ *= n
_ %= tmp
return _ * n
N = int(eval(input()))
a = div(10,N)
b = div(9,N)
c = div(8,N)
print(((a + c - b * 2) % (10 ** 9 + 7)))
|
tmp = 10 ** 9 + 7
def div(n,T):
_ = 1
for t in range(T):
_ *= n
_ %= tmp
return _
N = int(eval(input()))
a = div(10,N)
b = div(9,N)
c = div(8,N)
print(((a + c - 2 * b) % tmp))
| 13 | 15 | 235 | 216 |
def div(n, T):
tmp = 10**9 + 7
_ = 1
for t in range(T - 1):
_ *= n
_ %= tmp
return _ * n
N = int(eval(input()))
a = div(10, N)
b = div(9, N)
c = div(8, N)
print(((a + c - b * 2) % (10**9 + 7)))
|
tmp = 10**9 + 7
def div(n, T):
_ = 1
for t in range(T):
_ *= n
_ %= tmp
return _
N = int(eval(input()))
a = div(10, N)
b = div(9, N)
c = div(8, N)
print(((a + c - 2 * b) % tmp))
| false | 13.333333 |
[
"+tmp = 10**9 + 7",
"+",
"+",
"- tmp = 10**9 + 7",
"- for t in range(T - 1):",
"+ for t in range(T):",
"- return _ * n",
"+ return _",
"-print(((a + c - b * 2) % (10**9 + 7)))",
"+print(((a + c - 2 * b) % tmp))"
] | false | 0.169993 | 0.094532 | 1.798252 |
[
"s745618575",
"s019418768"
] |
u945181840
|
p03044
|
python
|
s971750687
|
s900062189
| 481 | 388 | 44,992 | 44,972 |
Accepted
|
Accepted
| 19.33 |
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in readlines():
u, v, w = list(map(int, i.split()))
graph[u].append((v, w))
graph[v].append((u, w))
stack = [1]
parent = [0] * (N + 1)
color = [0] * (N + 1)
while stack:
here = stack.pop()
for x, w in graph[here]:
if x == parent[here]:
continue
parent[x] = here
color[x] = color[here] ^ (w % 2)
stack.append(x)
for i in color[1:]:
print(i)
|
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read
def main():
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in readlines():
u, v, w = list(map(int, i.split()))
graph[u].append((v, w))
graph[v].append((u, w))
stack = [1]
parent = [0] * (N + 1)
color = [0] * (N + 1)
while stack:
here = stack.pop()
for x, w in graph[here]:
if x == parent[here]:
continue
parent[x] = here
color[x] = color[here] ^ (w % 2)
stack.append(x)
for i in color[1:]:
print(i)
if __name__ == '__main__':
main()
| 29 | 33 | 591 | 722 |
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in readlines():
u, v, w = list(map(int, i.split()))
graph[u].append((v, w))
graph[v].append((u, w))
stack = [1]
parent = [0] * (N + 1)
color = [0] * (N + 1)
while stack:
here = stack.pop()
for x, w in graph[here]:
if x == parent[here]:
continue
parent[x] = here
color[x] = color[here] ^ (w % 2)
stack.append(x)
for i in color[1:]:
print(i)
|
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read
def main():
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in readlines():
u, v, w = list(map(int, i.split()))
graph[u].append((v, w))
graph[v].append((u, w))
stack = [1]
parent = [0] * (N + 1)
color = [0] * (N + 1)
while stack:
here = stack.pop()
for x, w in graph[here]:
if x == parent[here]:
continue
parent[x] = here
color[x] = color[here] ^ (w % 2)
stack.append(x)
for i in color[1:]:
print(i)
if __name__ == "__main__":
main()
| false | 12.121212 |
[
"-N = int(readline())",
"-graph = [[] for _ in range(N + 1)]",
"-for i in readlines():",
"- u, v, w = list(map(int, i.split()))",
"- graph[u].append((v, w))",
"- graph[v].append((u, w))",
"-stack = [1]",
"-parent = [0] * (N + 1)",
"-color = [0] * (N + 1)",
"-while stack:",
"- here = stack.pop()",
"- for x, w in graph[here]:",
"- if x == parent[here]:",
"- continue",
"- parent[x] = here",
"- color[x] = color[here] ^ (w % 2)",
"- stack.append(x)",
"-for i in color[1:]:",
"- print(i)",
"+",
"+",
"+def main():",
"+ N = int(readline())",
"+ graph = [[] for _ in range(N + 1)]",
"+ for i in readlines():",
"+ u, v, w = list(map(int, i.split()))",
"+ graph[u].append((v, w))",
"+ graph[v].append((u, w))",
"+ stack = [1]",
"+ parent = [0] * (N + 1)",
"+ color = [0] * (N + 1)",
"+ while stack:",
"+ here = stack.pop()",
"+ for x, w in graph[here]:",
"+ if x == parent[here]:",
"+ continue",
"+ parent[x] = here",
"+ color[x] = color[here] ^ (w % 2)",
"+ stack.append(x)",
"+ for i in color[1:]:",
"+ print(i)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.046023 | 0.037887 | 1.214725 |
[
"s971750687",
"s900062189"
] |
u170201762
|
p03148
|
python
|
s030147852
|
s479176775
| 805 | 508 | 77,272 | 32,256 |
Accepted
|
Accepted
| 36.89 |
from itertools import accumulate
N,K = list(map(int,input().split()))
td = [tuple(map(int,input().split())) for i in range(N)]
td = [(x[0]-1,x[1]) for x in td]
td.sort(key=lambda x:-x[1])
t = [-1]*N
for i in range(N):
t[td[i][0]] = 0
tdK = td[:K]
for i in range(K):
t[tdK[i][0]] = 1
t_used = [i for i in range(N) if t[i]==1]
t_not_used = [i for i in range(N) if t[i]==0]
d_top = [0]*N
d_top_candi = [0]*N
d_rest = []
d_candi = []
for i in range(K):
if d_top[td[i][0]] == 0:
d_top[td[i][0]] = td[i][1]
else:
d_rest.append(td[i][1])
for i in range(K,N):
if t[td[i][0]] == 0:
if d_top_candi[td[i][0]] == 0:
d_top_candi[td[i][0]] = 1
d_candi.append(td[i][1])
l = len(t_used)
s = sum(d_top)
d_rest.sort()
d_candi.sort(key=lambda x:-x)
d_rest_cum = list(accumulate(d_rest))
d_candi_cum = list(accumulate(d_candi))
if len(d_rest) == 0:
print((l**2 + s))
else:
s += d_rest_cum[-1]
ans = l**2 + s
for k in range(min(len(d_rest),len(d_candi))):
ans = max((l+k+1)**2 + s + d_candi_cum[k] - d_rest_cum[k],ans)
print(ans)
|
N,K = list(map(int,input().split()))
td = [list(map(int,input().split())) for _ in range(N)]
td.sort(key=lambda x:-x[1])
l,r = td[:K],td[K:]
used_l = [0]*N
for i in range(K):
used_l[l[i][0]-1] += 1
remove = []
for i in range(K-1,-1,-1):
if used_l[l[i][0]-1] >= 2:
remove.append(l[i][1])
used_l[l[i][0]-1] -= 1
used_r = used_l.copy()
add = []
for i in range(N-K):
if used_r[r[i][0]-1] == 0:
add.append(r[i][1])
used_r[r[i][0]-1] += 1
t = sum(used_l)
ans = t**2
for i in range(K):
ans += l[i][1]
ref = ans
for i in range(min(len(remove),len(add))):
ref += (t+1)**2-t**2+add[i]-remove[i]
t += 1
ans = max(ans,ref)
print(ans)
| 49 | 34 | 1,152 | 714 |
from itertools import accumulate
N, K = list(map(int, input().split()))
td = [tuple(map(int, input().split())) for i in range(N)]
td = [(x[0] - 1, x[1]) for x in td]
td.sort(key=lambda x: -x[1])
t = [-1] * N
for i in range(N):
t[td[i][0]] = 0
tdK = td[:K]
for i in range(K):
t[tdK[i][0]] = 1
t_used = [i for i in range(N) if t[i] == 1]
t_not_used = [i for i in range(N) if t[i] == 0]
d_top = [0] * N
d_top_candi = [0] * N
d_rest = []
d_candi = []
for i in range(K):
if d_top[td[i][0]] == 0:
d_top[td[i][0]] = td[i][1]
else:
d_rest.append(td[i][1])
for i in range(K, N):
if t[td[i][0]] == 0:
if d_top_candi[td[i][0]] == 0:
d_top_candi[td[i][0]] = 1
d_candi.append(td[i][1])
l = len(t_used)
s = sum(d_top)
d_rest.sort()
d_candi.sort(key=lambda x: -x)
d_rest_cum = list(accumulate(d_rest))
d_candi_cum = list(accumulate(d_candi))
if len(d_rest) == 0:
print((l**2 + s))
else:
s += d_rest_cum[-1]
ans = l**2 + s
for k in range(min(len(d_rest), len(d_candi))):
ans = max((l + k + 1) ** 2 + s + d_candi_cum[k] - d_rest_cum[k], ans)
print(ans)
|
N, K = list(map(int, input().split()))
td = [list(map(int, input().split())) for _ in range(N)]
td.sort(key=lambda x: -x[1])
l, r = td[:K], td[K:]
used_l = [0] * N
for i in range(K):
used_l[l[i][0] - 1] += 1
remove = []
for i in range(K - 1, -1, -1):
if used_l[l[i][0] - 1] >= 2:
remove.append(l[i][1])
used_l[l[i][0] - 1] -= 1
used_r = used_l.copy()
add = []
for i in range(N - K):
if used_r[r[i][0] - 1] == 0:
add.append(r[i][1])
used_r[r[i][0] - 1] += 1
t = sum(used_l)
ans = t**2
for i in range(K):
ans += l[i][1]
ref = ans
for i in range(min(len(remove), len(add))):
ref += (t + 1) ** 2 - t**2 + add[i] - remove[i]
t += 1
ans = max(ans, ref)
print(ans)
| false | 30.612245 |
[
"-from itertools import accumulate",
"-",
"-td = [tuple(map(int, input().split())) for i in range(N)]",
"-td = [(x[0] - 1, x[1]) for x in td]",
"+td = [list(map(int, input().split())) for _ in range(N)]",
"-t = [-1] * N",
"-for i in range(N):",
"- t[td[i][0]] = 0",
"-tdK = td[:K]",
"+l, r = td[:K], td[K:]",
"+used_l = [0] * N",
"- t[tdK[i][0]] = 1",
"-t_used = [i for i in range(N) if t[i] == 1]",
"-t_not_used = [i for i in range(N) if t[i] == 0]",
"-d_top = [0] * N",
"-d_top_candi = [0] * N",
"-d_rest = []",
"-d_candi = []",
"+ used_l[l[i][0] - 1] += 1",
"+remove = []",
"+for i in range(K - 1, -1, -1):",
"+ if used_l[l[i][0] - 1] >= 2:",
"+ remove.append(l[i][1])",
"+ used_l[l[i][0] - 1] -= 1",
"+used_r = used_l.copy()",
"+add = []",
"+for i in range(N - K):",
"+ if used_r[r[i][0] - 1] == 0:",
"+ add.append(r[i][1])",
"+ used_r[r[i][0] - 1] += 1",
"+t = sum(used_l)",
"+ans = t**2",
"- if d_top[td[i][0]] == 0:",
"- d_top[td[i][0]] = td[i][1]",
"- else:",
"- d_rest.append(td[i][1])",
"-for i in range(K, N):",
"- if t[td[i][0]] == 0:",
"- if d_top_candi[td[i][0]] == 0:",
"- d_top_candi[td[i][0]] = 1",
"- d_candi.append(td[i][1])",
"-l = len(t_used)",
"-s = sum(d_top)",
"-d_rest.sort()",
"-d_candi.sort(key=lambda x: -x)",
"-d_rest_cum = list(accumulate(d_rest))",
"-d_candi_cum = list(accumulate(d_candi))",
"-if len(d_rest) == 0:",
"- print((l**2 + s))",
"-else:",
"- s += d_rest_cum[-1]",
"- ans = l**2 + s",
"- for k in range(min(len(d_rest), len(d_candi))):",
"- ans = max((l + k + 1) ** 2 + s + d_candi_cum[k] - d_rest_cum[k], ans)",
"- print(ans)",
"+ ans += l[i][1]",
"+ref = ans",
"+for i in range(min(len(remove), len(add))):",
"+ ref += (t + 1) ** 2 - t**2 + add[i] - remove[i]",
"+ t += 1",
"+ ans = max(ans, ref)",
"+print(ans)"
] | false | 0.054322 | 0.077937 | 0.697004 |
[
"s030147852",
"s479176775"
] |
u481187938
|
p02793
|
python
|
s827886124
|
s097164248
| 1,616 | 608 | 79,128 | 78,908 |
Accepted
|
Accepted
| 62.38 |
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools, bisect
import math, fractions
import sys, copy
def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
def main():
N = I()
A = LI()
def lcm(a, b): return a * b // math.gcd(a, b)
l = reduce(lcm, A, 1)
ans = 0
for ai in A:
ans = (ans + l * pow(ai, MOD - 2, MOD)) % MOD
print(ans)
if __name__ == '__main__':
main()
|
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools, bisect
import math, fractions
import sys, copy
def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
def main():
N = I()
A = LI()
def lcm(a, b): return a * b // math.gcd(a, b)
l = reduce(lcm, A, 1) % MOD
ans = 0
for ai in A:
ans = (ans + l * pow(ai, MOD - 2, MOD)) % MOD
print(ans)
if __name__ == '__main__':
main()
| 50 | 50 | 1,449 | 1,455 |
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools, bisect
import math, fractions
import sys, copy
def L():
return sys.stdin.readline().split()
def I():
return int(sys.stdin.readline().rstrip())
def S():
return list(sys.stdin.readline().rstrip())
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI1():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def IR(n):
return [I() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def LIR1(n):
return [LI1() for _ in range(n)]
def SR(n):
return [S() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
def LR(n):
return [L() for _ in range(n)]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
def main():
N = I()
A = LI()
def lcm(a, b):
return a * b // math.gcd(a, b)
l = reduce(lcm, A, 1)
ans = 0
for ai in A:
ans = (ans + l * pow(ai, MOD - 2, MOD)) % MOD
print(ans)
if __name__ == "__main__":
main()
|
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools, bisect
import math, fractions
import sys, copy
def L():
return sys.stdin.readline().split()
def I():
return int(sys.stdin.readline().rstrip())
def S():
return list(sys.stdin.readline().rstrip())
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI1():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def IR(n):
return [I() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def LIR1(n):
return [LI1() for _ in range(n)]
def SR(n):
return [S() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
def LR(n):
return [L() for _ in range(n)]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
def main():
N = I()
A = LI()
def lcm(a, b):
return a * b // math.gcd(a, b)
l = reduce(lcm, A, 1) % MOD
ans = 0
for ai in A:
ans = (ans + l * pow(ai, MOD - 2, MOD)) % MOD
print(ans)
if __name__ == "__main__":
main()
| false | 0 |
[
"- l = reduce(lcm, A, 1)",
"+ l = reduce(lcm, A, 1) % MOD"
] | false | 0.039119 | 0.048665 | 0.803847 |
[
"s827886124",
"s097164248"
] |
u170201762
|
p02893
|
python
|
s696437291
|
s208744548
| 1,521 | 76 | 123,272 | 5,220 |
Accepted
|
Accepted
| 95 |
mod = 998244353
N = int(eval(input()))
X = eval(input())
d = []
for n in range(1,N+1):
if N%n==0 and (N//n)%2==1:
d.append(n)
p_d = {}
for n in d:
p_d[n] = 0
S = []
for i in range(N):
j = i//n
if X[i%n]=='0':
if j%2==0:
S.append('0')
else:
S.append('1')
else:
if j%2==0:
S.append('1')
else:
S.append('0')
S = ''.join(S)
s = X[:n][::-1]
for i in range(n):
if s[i]=='1':
p_d[n] += pow(2,i,mod)
if S<=X:
p_d[n] += 1
ans = 0
for i in range(len(d)):
n = d[i]
for j in range(i):
m = d[j]
if n%m==0:
p_d[n] -= p_d[m]
ans += p_d[n]*2*n
ans %= mod
print(ans)
|
mod = 998244353
N = int(eval(input()))
X = eval(input())
X_ = []
for i in range(N):
if X[i]=='0':
X_.append('1')
else:
X_.append('0')
X_ = ''.join(X_)
d = []
for n in range(1,N+1):
if N%n==0 and (N//n)%2==1:
d.append(n)
p_d = {}
for n in d:
p_d[n] = 0
S = (X[:n]+X_[:n])*(N//n//2)+X[:n]
p_d[n] += int(X[:n],2)%mod
if S<=X:
p_d[n] += 1
ans = 0
for i in range(len(d)):
n = d[i]
for j in range(i):
m = d[j]
if n%m==0:
p_d[n] -= p_d[m]
ans += p_d[n]*2*n
ans %= mod
print(ans)
| 45 | 35 | 831 | 597 |
mod = 998244353
N = int(eval(input()))
X = eval(input())
d = []
for n in range(1, N + 1):
if N % n == 0 and (N // n) % 2 == 1:
d.append(n)
p_d = {}
for n in d:
p_d[n] = 0
S = []
for i in range(N):
j = i // n
if X[i % n] == "0":
if j % 2 == 0:
S.append("0")
else:
S.append("1")
else:
if j % 2 == 0:
S.append("1")
else:
S.append("0")
S = "".join(S)
s = X[:n][::-1]
for i in range(n):
if s[i] == "1":
p_d[n] += pow(2, i, mod)
if S <= X:
p_d[n] += 1
ans = 0
for i in range(len(d)):
n = d[i]
for j in range(i):
m = d[j]
if n % m == 0:
p_d[n] -= p_d[m]
ans += p_d[n] * 2 * n
ans %= mod
print(ans)
|
mod = 998244353
N = int(eval(input()))
X = eval(input())
X_ = []
for i in range(N):
if X[i] == "0":
X_.append("1")
else:
X_.append("0")
X_ = "".join(X_)
d = []
for n in range(1, N + 1):
if N % n == 0 and (N // n) % 2 == 1:
d.append(n)
p_d = {}
for n in d:
p_d[n] = 0
S = (X[:n] + X_[:n]) * (N // n // 2) + X[:n]
p_d[n] += int(X[:n], 2) % mod
if S <= X:
p_d[n] += 1
ans = 0
for i in range(len(d)):
n = d[i]
for j in range(i):
m = d[j]
if n % m == 0:
p_d[n] -= p_d[m]
ans += p_d[n] * 2 * n
ans %= mod
print(ans)
| false | 22.222222 |
[
"+X_ = []",
"+for i in range(N):",
"+ if X[i] == \"0\":",
"+ X_.append(\"1\")",
"+ else:",
"+ X_.append(\"0\")",
"+X_ = \"\".join(X_)",
"- S = []",
"- for i in range(N):",
"- j = i // n",
"- if X[i % n] == \"0\":",
"- if j % 2 == 0:",
"- S.append(\"0\")",
"- else:",
"- S.append(\"1\")",
"- else:",
"- if j % 2 == 0:",
"- S.append(\"1\")",
"- else:",
"- S.append(\"0\")",
"- S = \"\".join(S)",
"- s = X[:n][::-1]",
"- for i in range(n):",
"- if s[i] == \"1\":",
"- p_d[n] += pow(2, i, mod)",
"+ S = (X[:n] + X_[:n]) * (N // n // 2) + X[:n]",
"+ p_d[n] += int(X[:n], 2) % mod"
] | false | 0.168088 | 0.037374 | 4.497398 |
[
"s696437291",
"s208744548"
] |
u271430213
|
p04001
|
python
|
s590950951
|
s608648848
| 22 | 18 | 3,064 | 3,060 |
Accepted
|
Accepted
| 18.18 |
import sys
S=eval(input())
def allbitCalc(N):
allbit = []
for i in range(2**N):
bit = [0] * N
for j in range(N):
if (i >> j) & 1:
bit[j] = 1
allbit.append(bit)
return allbit
def split(S,bit):
n=len(S)
terms=[]
cnt=1;s=int(S[n-1])
for i,b in enumerate(bit):
if b==0:
s+=int(S[n-i-2])*10**cnt
cnt+=1
else:
terms.append(s)
s=0;cnt=0
s+=int(S[n-i-2])*10**cnt
cnt+=1
terms.append(s)
return(sum(terms))
summ=0
allb=allbitCalc(int(len(S))-1)
for ab in allb:
tmp=split(S,ab)
summ+=tmp
print(summ)
|
def dfs(i,s):
if i==(n-1):
return(sum(map(int,s.split('+'))))
return(dfs(i+1,s+S[i+1])+dfs(i+1,s+'+'+S[i+1]))
S=eval(input())
n=len(S)
ans=dfs(0,S[0])
print(ans)
| 37 | 10 | 715 | 182 |
import sys
S = eval(input())
def allbitCalc(N):
allbit = []
for i in range(2**N):
bit = [0] * N
for j in range(N):
if (i >> j) & 1:
bit[j] = 1
allbit.append(bit)
return allbit
def split(S, bit):
n = len(S)
terms = []
cnt = 1
s = int(S[n - 1])
for i, b in enumerate(bit):
if b == 0:
s += int(S[n - i - 2]) * 10**cnt
cnt += 1
else:
terms.append(s)
s = 0
cnt = 0
s += int(S[n - i - 2]) * 10**cnt
cnt += 1
terms.append(s)
return sum(terms)
summ = 0
allb = allbitCalc(int(len(S)) - 1)
for ab in allb:
tmp = split(S, ab)
summ += tmp
print(summ)
|
def dfs(i, s):
if i == (n - 1):
return sum(map(int, s.split("+")))
return dfs(i + 1, s + S[i + 1]) + dfs(i + 1, s + "+" + S[i + 1])
S = eval(input())
n = len(S)
ans = dfs(0, S[0])
print(ans)
| false | 72.972973 |
[
"-import sys",
"+def dfs(i, s):",
"+ if i == (n - 1):",
"+ return sum(map(int, s.split(\"+\")))",
"+ return dfs(i + 1, s + S[i + 1]) + dfs(i + 1, s + \"+\" + S[i + 1])",
"+",
"-",
"-",
"-def allbitCalc(N):",
"- allbit = []",
"- for i in range(2**N):",
"- bit = [0] * N",
"- for j in range(N):",
"- if (i >> j) & 1:",
"- bit[j] = 1",
"- allbit.append(bit)",
"- return allbit",
"-",
"-",
"-def split(S, bit):",
"- n = len(S)",
"- terms = []",
"- cnt = 1",
"- s = int(S[n - 1])",
"- for i, b in enumerate(bit):",
"- if b == 0:",
"- s += int(S[n - i - 2]) * 10**cnt",
"- cnt += 1",
"- else:",
"- terms.append(s)",
"- s = 0",
"- cnt = 0",
"- s += int(S[n - i - 2]) * 10**cnt",
"- cnt += 1",
"- terms.append(s)",
"- return sum(terms)",
"-",
"-",
"-summ = 0",
"-allb = allbitCalc(int(len(S)) - 1)",
"-for ab in allb:",
"- tmp = split(S, ab)",
"- summ += tmp",
"-print(summ)",
"+n = len(S)",
"+ans = dfs(0, S[0])",
"+print(ans)"
] | false | 0.032603 | 0.033942 | 0.960559 |
[
"s590950951",
"s608648848"
] |
u312025627
|
p02952
|
python
|
s963629704
|
s594603111
| 187 | 171 | 39,408 | 38,768 |
Accepted
|
Accepted
| 8.56 |
n = int(eval(input()))
ans = 0
for i in range(1,n+1):
digit = 1
while i//10 > 0:
digit += 1
i /= 10
if digit%2 == 1:
ans += 1
print(ans)
|
n = int(eval(input()))
ans = 0
for i in range(1,n+1):
if len(str(i))%2 == 1:
ans += 1
print(ans)
| 11 | 7 | 177 | 109 |
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
digit = 1
while i // 10 > 0:
digit += 1
i /= 10
if digit % 2 == 1:
ans += 1
print(ans)
|
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if len(str(i)) % 2 == 1:
ans += 1
print(ans)
| false | 36.363636 |
[
"- digit = 1",
"- while i // 10 > 0:",
"- digit += 1",
"- i /= 10",
"- if digit % 2 == 1:",
"+ if len(str(i)) % 2 == 1:"
] | false | 0.051367 | 0.04813 | 1.067261 |
[
"s963629704",
"s594603111"
] |
u936985471
|
p04031
|
python
|
s975543606
|
s820727396
| 24 | 17 | 3,064 | 3,060 |
Accepted
|
Accepted
| 29.17 |
N=int(eval(input()))
A=list(map(int,input().split()))
st=int(sum(A)/len(A))
go=st+1
ans=10**9+1
for i in range(st,go+1):
val=0
for a in A:
val+=(a-i)**2
ans=min(ans,val)
print(ans)
|
N=int(eval(input()))
A=list(map(int,input().split()))
ans=10**9+1
for i in (0,1):
val=0
for a in A:
val+=(a-int(sum(A)/len(A))-i)**2
ans=min(ans,val)
print(ans)
| 11 | 9 | 194 | 172 |
N = int(eval(input()))
A = list(map(int, input().split()))
st = int(sum(A) / len(A))
go = st + 1
ans = 10**9 + 1
for i in range(st, go + 1):
val = 0
for a in A:
val += (a - i) ** 2
ans = min(ans, val)
print(ans)
|
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 10**9 + 1
for i in (0, 1):
val = 0
for a in A:
val += (a - int(sum(A) / len(A)) - i) ** 2
ans = min(ans, val)
print(ans)
| false | 18.181818 |
[
"-st = int(sum(A) / len(A))",
"-go = st + 1",
"-for i in range(st, go + 1):",
"+for i in (0, 1):",
"- val += (a - i) ** 2",
"+ val += (a - int(sum(A) / len(A)) - i) ** 2"
] | false | 0.041127 | 0.040241 | 1.022 |
[
"s975543606",
"s820727396"
] |
u707124227
|
p03147
|
python
|
s521740546
|
s674455599
| 20 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 15 |
n=int(eval(input()))
h=list(map(int,input().split()))
ans=0
while sum(h)>0:
i=0
while i < n:
if h[i]>0:
ans+=1
while i<n and h[i]>0:
h[i]-=1
i+=1
i+=1
print(ans)
|
n=int(eval(input()))
h=list(map(int,input().split()))
ans=0
pre=0
for hi in h:
if hi-pre>0:
ans+=hi-pre
pre=hi
print(ans)
| 13 | 9 | 251 | 131 |
n = int(eval(input()))
h = list(map(int, input().split()))
ans = 0
while sum(h) > 0:
i = 0
while i < n:
if h[i] > 0:
ans += 1
while i < n and h[i] > 0:
h[i] -= 1
i += 1
i += 1
print(ans)
|
n = int(eval(input()))
h = list(map(int, input().split()))
ans = 0
pre = 0
for hi in h:
if hi - pre > 0:
ans += hi - pre
pre = hi
print(ans)
| false | 30.769231 |
[
"-while sum(h) > 0:",
"- i = 0",
"- while i < n:",
"- if h[i] > 0:",
"- ans += 1",
"- while i < n and h[i] > 0:",
"- h[i] -= 1",
"- i += 1",
"- i += 1",
"+pre = 0",
"+for hi in h:",
"+ if hi - pre > 0:",
"+ ans += hi - pre",
"+ pre = hi"
] | false | 0.049538 | 0.052106 | 0.950703 |
[
"s521740546",
"s674455599"
] |
u852690916
|
p02694
|
python
|
s644440307
|
s359759961
| 65 | 57 | 62,940 | 63,228 |
Accepted
|
Accepted
| 12.31 |
X=int(eval(input()))
n=100
for i in range(10**10):
if n>=X:
print(i)
exit()
n+=n//100
|
X=int(eval(input()))
n=100
for i in range(10000):
if n>=X:
print(i)
exit()
n+=n//100
| 7 | 7 | 109 | 108 |
X = int(eval(input()))
n = 100
for i in range(10**10):
if n >= X:
print(i)
exit()
n += n // 100
|
X = int(eval(input()))
n = 100
for i in range(10000):
if n >= X:
print(i)
exit()
n += n // 100
| false | 0 |
[
"-for i in range(10**10):",
"+for i in range(10000):"
] | false | 0.062293 | 0.035698 | 1.744995 |
[
"s644440307",
"s359759961"
] |
u347203174
|
p02706
|
python
|
s213048764
|
s138020332
| 24 | 22 | 9,884 | 9,980 |
Accepted
|
Accepted
| 8.33 |
N, M = list(map(int, input().split()))
work = []
[work.append(x) for x in map(int, input().split())]
s = sum(work)
if N >= s:
print((N - s))
else:
print('-1')
|
import math
ex = []
N, M = map(int, input().split())
ex = [exi for exi in map(int, input().split())]
rem = N - sum(ex)
print(rem) if rem >= 0 else print('-1')
| 11 | 10 | 172 | 172 |
N, M = list(map(int, input().split()))
work = []
[work.append(x) for x in map(int, input().split())]
s = sum(work)
if N >= s:
print((N - s))
else:
print("-1")
|
import math
ex = []
N, M = map(int, input().split())
ex = [exi for exi in map(int, input().split())]
rem = N - sum(ex)
print(rem) if rem >= 0 else print("-1")
| false | 9.090909 |
[
"-N, M = list(map(int, input().split()))",
"-work = []",
"-[work.append(x) for x in map(int, input().split())]",
"-s = sum(work)",
"-if N >= s:",
"- print((N - s))",
"-else:",
"- print(\"-1\")",
"+import math",
"+",
"+ex = []",
"+N, M = map(int, input().split())",
"+ex = [exi for exi in map(int, input().split())]",
"+rem = N - sum(ex)",
"+print(rem) if rem >= 0 else print(\"-1\")"
] | false | 0.032514 | 0.035534 | 0.915015 |
[
"s213048764",
"s138020332"
] |
u729133443
|
p02661
|
python
|
s518351715
|
s405619237
| 630 | 448 | 110,604 | 64,544 |
Accepted
|
Accepted
| 28.89 |
from statistics import*
(n,),*t=[list(map(int,t.split()))for t in open(0)]
a,b=list(map(median,list(zip(*t))))
print((int((b-a)*(2-n%2))+1))
|
from numpy import*
(n,),*d=[int_(i.split())for i in open(0)]
a,b=median(d,0)
print((int((b-a)*(2-n%2))+1))
| 4 | 4 | 123 | 107 |
from statistics import *
(n,), *t = [list(map(int, t.split())) for t in open(0)]
a, b = list(map(median, list(zip(*t))))
print((int((b - a) * (2 - n % 2)) + 1))
|
from numpy import *
(n,), *d = [int_(i.split()) for i in open(0)]
a, b = median(d, 0)
print((int((b - a) * (2 - n % 2)) + 1))
| false | 0 |
[
"-from statistics import *",
"+from numpy import *",
"-(n,), *t = [list(map(int, t.split())) for t in open(0)]",
"-a, b = list(map(median, list(zip(*t))))",
"+(n,), *d = [int_(i.split()) for i in open(0)]",
"+a, b = median(d, 0)"
] | false | 0.087364 | 0.412011 | 0.212043 |
[
"s518351715",
"s405619237"
] |
u914762730
|
p03310
|
python
|
s015073942
|
s139958237
| 1,766 | 986 | 27,340 | 26,992 |
Accepted
|
Accepted
| 44.17 |
INF = 2 * 10**5 * 10**9
n = int(eval(input()))
a = list(map(int,input().split()))
s = [0]
for x in a:
s.append(s[-1]+x)
ans = INF
p1 = 1
p = 2
p2 = 3
def update():
global ans
if p1 < p and p2 < n:
ans = min(ans , max(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) - min(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) )
if p2 < n and p1 - 1 >= 1:
ans = min(ans , max(s[p1-1],s[p]-s[p1-1],s[p2]-s[p],s[n]-s[p2]) - min(s[p1-1],s[p]-s[p1-1],s[p2]-s[p],s[n]-s[p2]) )
if p1 < p and p2-1 >= p:
ans = min(ans , max(s[p1],s[p]-s[p1],s[p2-1]-s[p],s[n]-s[p2-1]) - min(s[p1],s[p]-s[p1],s[p2-1]-s[p],s[n]-s[p2-1]) )
if p1-1 >= 1 and p2-1 >= p:
ans = min(ans , max(s[p1-1],s[p]-s[p1-1],s[p2-1]-s[p],s[n]-s[p2-1]) - min(s[p1-1],s[p]-s[p1-1],s[p2-1]-s[p],s[n]-s[p2-1]) )
while p2 < n and s[p2] - s[p] < s[n] - s[p2]:
p2 += 1
update()
while True:
p += 1
if p + 1 >= n:
break
while p1 < p and s[p1] < s[p] - s[p1]:
p1 += 1
while p2 < n and s[p2] - s[p] < s[n] - s[p2]:
p2 += 1
update()
print(ans)
|
INF = 2 * 10**5 * 10**9
n = int(eval(input()))
a = list(map(int,input().split()))
s = [0]
for x in a:
s.append(s[-1]+x)
ans = INF
p1 = 1
p = 1
p2 = 3
while True:
p += 1
if p + 1 >= n:
break
while p1 < p and abs(s[p1] - s[p] + s[p1]) > abs(s[p1+1] - s[p] + s[p1 + 1]):
p1 += 1
while p2 < n and abs(s[p2] - s[p] - s[n] + s[p2]) > abs(s[p2+1] - s[p] - s[n] + s[p2+1]):
p2 += 1
ans = min(ans , max(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) - min(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) )
print(ans)
| 33 | 20 | 1,093 | 550 |
INF = 2 * 10**5 * 10**9
n = int(eval(input()))
a = list(map(int, input().split()))
s = [0]
for x in a:
s.append(s[-1] + x)
ans = INF
p1 = 1
p = 2
p2 = 3
def update():
global ans
if p1 < p and p2 < n:
ans = min(
ans,
max(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2])
- min(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2]),
)
if p2 < n and p1 - 1 >= 1:
ans = min(
ans,
max(s[p1 - 1], s[p] - s[p1 - 1], s[p2] - s[p], s[n] - s[p2])
- min(s[p1 - 1], s[p] - s[p1 - 1], s[p2] - s[p], s[n] - s[p2]),
)
if p1 < p and p2 - 1 >= p:
ans = min(
ans,
max(s[p1], s[p] - s[p1], s[p2 - 1] - s[p], s[n] - s[p2 - 1])
- min(s[p1], s[p] - s[p1], s[p2 - 1] - s[p], s[n] - s[p2 - 1]),
)
if p1 - 1 >= 1 and p2 - 1 >= p:
ans = min(
ans,
max(s[p1 - 1], s[p] - s[p1 - 1], s[p2 - 1] - s[p], s[n] - s[p2 - 1])
- min(s[p1 - 1], s[p] - s[p1 - 1], s[p2 - 1] - s[p], s[n] - s[p2 - 1]),
)
while p2 < n and s[p2] - s[p] < s[n] - s[p2]:
p2 += 1
update()
while True:
p += 1
if p + 1 >= n:
break
while p1 < p and s[p1] < s[p] - s[p1]:
p1 += 1
while p2 < n and s[p2] - s[p] < s[n] - s[p2]:
p2 += 1
update()
print(ans)
|
INF = 2 * 10**5 * 10**9
n = int(eval(input()))
a = list(map(int, input().split()))
s = [0]
for x in a:
s.append(s[-1] + x)
ans = INF
p1 = 1
p = 1
p2 = 3
while True:
p += 1
if p + 1 >= n:
break
while p1 < p and abs(s[p1] - s[p] + s[p1]) > abs(s[p1 + 1] - s[p] + s[p1 + 1]):
p1 += 1
while p2 < n and abs(s[p2] - s[p] - s[n] + s[p2]) > abs(
s[p2 + 1] - s[p] - s[n] + s[p2 + 1]
):
p2 += 1
ans = min(
ans,
max(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2])
- min(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2]),
)
print(ans)
| false | 39.393939 |
[
"-p = 2",
"+p = 1",
"-",
"-",
"-def update():",
"- global ans",
"- if p1 < p and p2 < n:",
"- ans = min(",
"- ans,",
"- max(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2])",
"- - min(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2]),",
"- )",
"- if p2 < n and p1 - 1 >= 1:",
"- ans = min(",
"- ans,",
"- max(s[p1 - 1], s[p] - s[p1 - 1], s[p2] - s[p], s[n] - s[p2])",
"- - min(s[p1 - 1], s[p] - s[p1 - 1], s[p2] - s[p], s[n] - s[p2]),",
"- )",
"- if p1 < p and p2 - 1 >= p:",
"- ans = min(",
"- ans,",
"- max(s[p1], s[p] - s[p1], s[p2 - 1] - s[p], s[n] - s[p2 - 1])",
"- - min(s[p1], s[p] - s[p1], s[p2 - 1] - s[p], s[n] - s[p2 - 1]),",
"- )",
"- if p1 - 1 >= 1 and p2 - 1 >= p:",
"- ans = min(",
"- ans,",
"- max(s[p1 - 1], s[p] - s[p1 - 1], s[p2 - 1] - s[p], s[n] - s[p2 - 1])",
"- - min(s[p1 - 1], s[p] - s[p1 - 1], s[p2 - 1] - s[p], s[n] - s[p2 - 1]),",
"- )",
"-",
"-",
"-while p2 < n and s[p2] - s[p] < s[n] - s[p2]:",
"- p2 += 1",
"-update()",
"- while p1 < p and s[p1] < s[p] - s[p1]:",
"+ while p1 < p and abs(s[p1] - s[p] + s[p1]) > abs(s[p1 + 1] - s[p] + s[p1 + 1]):",
"- while p2 < n and s[p2] - s[p] < s[n] - s[p2]:",
"+ while p2 < n and abs(s[p2] - s[p] - s[n] + s[p2]) > abs(",
"+ s[p2 + 1] - s[p] - s[n] + s[p2 + 1]",
"+ ):",
"- update()",
"+ ans = min(",
"+ ans,",
"+ max(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2])",
"+ - min(s[p1], s[p] - s[p1], s[p2] - s[p], s[n] - s[p2]),",
"+ )"
] | false | 0.078445 | 0.007916 | 9.909162 |
[
"s015073942",
"s139958237"
] |
u699296734
|
p03292
|
python
|
s402134365
|
s810752463
| 29 | 26 | 9,128 | 9,096 |
Accepted
|
Accepted
| 10.34 |
a = sorted(list(map(int, input().split())), reverse=True)
res = 0
for i in range(3 - 1):
res += a[i] - a[i + 1]
print(res)
|
a = list(map(int, input().split()))
a.sort()
print((a[-1] - a[0]))
| 5 | 3 | 130 | 66 |
a = sorted(list(map(int, input().split())), reverse=True)
res = 0
for i in range(3 - 1):
res += a[i] - a[i + 1]
print(res)
|
a = list(map(int, input().split()))
a.sort()
print((a[-1] - a[0]))
| false | 40 |
[
"-a = sorted(list(map(int, input().split())), reverse=True)",
"-res = 0",
"-for i in range(3 - 1):",
"- res += a[i] - a[i + 1]",
"-print(res)",
"+a = list(map(int, input().split()))",
"+a.sort()",
"+print((a[-1] - a[0]))"
] | false | 0.047441 | 0.049911 | 0.950498 |
[
"s402134365",
"s810752463"
] |
u732061897
|
p03273
|
python
|
s125558632
|
s132976376
| 149 | 40 | 12,492 | 9,468 |
Accepted
|
Accepted
| 73.15 |
H, W = list(map(int, input().split()))
a_list = [list(eval(input())) for i in range(H)]
result = a_list[:]
for i,aa in enumerate(a_list):
if aa.count('.') == len(aa):
result[i] = 1
result = [r for r in result if r != 1]
#print(result)
import numpy as np
T_result = np.array(result).T
result2 = T_result.tolist()
for i, aa in enumerate(result2):
if aa.count('.') == len(aa):
result2[i] = 1
result2 = [r for r in result2 if r != 1]
for r2 in np.array(result2).T.tolist():
print((''.join(r2)))
|
H, W = list(map(int, input().split()))
HW_list = [list(eval(input())) for i in range(H)]
import copy
tmp = copy.deepcopy(HW_list)
h_index = 0
for i, HW in enumerate(HW_list):
is_all_shiro = True
for hw in HW:
if hw == '#':
is_all_shiro = False
h_index += 1
break
if is_all_shiro:
tmp.pop(h_index)
w_index = 0
ans = copy.deepcopy(tmp)
for w in range(W):
is_all_shiro = True
for t in tmp:
if t[w] == '#':
is_all_shiro = False
w_index += 1
break
if is_all_shiro:
for a in ans:
a.pop(w_index)
for A in ans:
print((''.join(A)))
| 20 | 29 | 526 | 682 |
H, W = list(map(int, input().split()))
a_list = [list(eval(input())) for i in range(H)]
result = a_list[:]
for i, aa in enumerate(a_list):
if aa.count(".") == len(aa):
result[i] = 1
result = [r for r in result if r != 1]
# print(result)
import numpy as np
T_result = np.array(result).T
result2 = T_result.tolist()
for i, aa in enumerate(result2):
if aa.count(".") == len(aa):
result2[i] = 1
result2 = [r for r in result2 if r != 1]
for r2 in np.array(result2).T.tolist():
print(("".join(r2)))
|
H, W = list(map(int, input().split()))
HW_list = [list(eval(input())) for i in range(H)]
import copy
tmp = copy.deepcopy(HW_list)
h_index = 0
for i, HW in enumerate(HW_list):
is_all_shiro = True
for hw in HW:
if hw == "#":
is_all_shiro = False
h_index += 1
break
if is_all_shiro:
tmp.pop(h_index)
w_index = 0
ans = copy.deepcopy(tmp)
for w in range(W):
is_all_shiro = True
for t in tmp:
if t[w] == "#":
is_all_shiro = False
w_index += 1
break
if is_all_shiro:
for a in ans:
a.pop(w_index)
for A in ans:
print(("".join(A)))
| false | 31.034483 |
[
"-a_list = [list(eval(input())) for i in range(H)]",
"-result = a_list[:]",
"-for i, aa in enumerate(a_list):",
"- if aa.count(\".\") == len(aa):",
"- result[i] = 1",
"-result = [r for r in result if r != 1]",
"-# print(result)",
"-import numpy as np",
"+HW_list = [list(eval(input())) for i in range(H)]",
"+import copy",
"-T_result = np.array(result).T",
"-result2 = T_result.tolist()",
"-for i, aa in enumerate(result2):",
"- if aa.count(\".\") == len(aa):",
"- result2[i] = 1",
"-result2 = [r for r in result2 if r != 1]",
"-for r2 in np.array(result2).T.tolist():",
"- print((\"\".join(r2)))",
"+tmp = copy.deepcopy(HW_list)",
"+h_index = 0",
"+for i, HW in enumerate(HW_list):",
"+ is_all_shiro = True",
"+ for hw in HW:",
"+ if hw == \"#\":",
"+ is_all_shiro = False",
"+ h_index += 1",
"+ break",
"+ if is_all_shiro:",
"+ tmp.pop(h_index)",
"+w_index = 0",
"+ans = copy.deepcopy(tmp)",
"+for w in range(W):",
"+ is_all_shiro = True",
"+ for t in tmp:",
"+ if t[w] == \"#\":",
"+ is_all_shiro = False",
"+ w_index += 1",
"+ break",
"+ if is_all_shiro:",
"+ for a in ans:",
"+ a.pop(w_index)",
"+for A in ans:",
"+ print((\"\".join(A)))"
] | false | 0.095815 | 0.037319 | 2.567473 |
[
"s125558632",
"s132976376"
] |
u644907318
|
p03464
|
python
|
s854601549
|
s714349511
| 229 | 94 | 63,856 | 84,464 |
Accepted
|
Accepted
| 58.95 |
K = int(eval(input()))
A = list(map(int,input().split()))
B = [2,2]
for i in range(K-1,-1,-1):
a = A[i]
bmin = B[0]
bmax = B[1]
if bmin%a==0:
bmin = bmin
else:
bmin = (bmin//a+1)*a
if bmin>bmax:
B = []
break
else:
if bmax%a==0:
bmax = bmax+a-1
else:
bmax = (bmax//a)*a+a-1
B = [bmin,bmax]
if len(B)==0:
print((-1))
else:
print((B[0],B[1]))
|
import math
K = int(eval(input()))
A = list(map(int,input().split()))
if A[K-1]!=2:
print((-1))
elif K==1:
print((2,3))
else:
nmin = 2
nmax = 2+A[K-1]-1
flag = 0
for i in range(K-2,-1,-1):
b = A[i]
nmin = math.ceil(nmin/b)*b
nmax = math.floor(nmax/b)*b
if nmin>nmax:
flag = 1
break
nmax += b-1
if flag==1:
print((-1))
else:
print((nmin,nmax))
| 24 | 23 | 468 | 462 |
K = int(eval(input()))
A = list(map(int, input().split()))
B = [2, 2]
for i in range(K - 1, -1, -1):
a = A[i]
bmin = B[0]
bmax = B[1]
if bmin % a == 0:
bmin = bmin
else:
bmin = (bmin // a + 1) * a
if bmin > bmax:
B = []
break
else:
if bmax % a == 0:
bmax = bmax + a - 1
else:
bmax = (bmax // a) * a + a - 1
B = [bmin, bmax]
if len(B) == 0:
print((-1))
else:
print((B[0], B[1]))
|
import math
K = int(eval(input()))
A = list(map(int, input().split()))
if A[K - 1] != 2:
print((-1))
elif K == 1:
print((2, 3))
else:
nmin = 2
nmax = 2 + A[K - 1] - 1
flag = 0
for i in range(K - 2, -1, -1):
b = A[i]
nmin = math.ceil(nmin / b) * b
nmax = math.floor(nmax / b) * b
if nmin > nmax:
flag = 1
break
nmax += b - 1
if flag == 1:
print((-1))
else:
print((nmin, nmax))
| false | 4.166667 |
[
"+import math",
"+",
"-B = [2, 2]",
"-for i in range(K - 1, -1, -1):",
"- a = A[i]",
"- bmin = B[0]",
"- bmax = B[1]",
"- if bmin % a == 0:",
"- bmin = bmin",
"+if A[K - 1] != 2:",
"+ print((-1))",
"+elif K == 1:",
"+ print((2, 3))",
"+else:",
"+ nmin = 2",
"+ nmax = 2 + A[K - 1] - 1",
"+ flag = 0",
"+ for i in range(K - 2, -1, -1):",
"+ b = A[i]",
"+ nmin = math.ceil(nmin / b) * b",
"+ nmax = math.floor(nmax / b) * b",
"+ if nmin > nmax:",
"+ flag = 1",
"+ break",
"+ nmax += b - 1",
"+ if flag == 1:",
"+ print((-1))",
"- bmin = (bmin // a + 1) * a",
"- if bmin > bmax:",
"- B = []",
"- break",
"- else:",
"- if bmax % a == 0:",
"- bmax = bmax + a - 1",
"- else:",
"- bmax = (bmax // a) * a + a - 1",
"- B = [bmin, bmax]",
"-if len(B) == 0:",
"- print((-1))",
"-else:",
"- print((B[0], B[1]))",
"+ print((nmin, nmax))"
] | false | 0.032311 | 0.041289 | 0.782551 |
[
"s854601549",
"s714349511"
] |
u075012704
|
p03674
|
python
|
s008253665
|
s744882268
| 700 | 305 | 26,432 | 31,324 |
Accepted
|
Accepted
| 56.43 |
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10 **9 + 7
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
factorial.append(factorial[-1] * i % mod)
inverse.append(pow(factorial[-1], mod-2, mod))
# 組み合わせ計算
def nCr(n, r):
if n < r or r < 0:
return 0
elif r == 0:
return 1
return factorial[n] * inverse[r] * inverse[n - r] % mod
X = Counter(A).most_common(1)[0][0]
X_index = []
for i, a in enumerate(A, start=1):
if a == X:
X_index.append(i)
L, R = X_index[0], X_index[1]
for k in range(1, N + 2):
if k == 1:
print(N)
else:
print(((nCr(N + 1, k) - nCr(N - R + L, k - 1)) % mod))
|
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
duplicate_x = None
checked = set()
for a in A:
if a in checked:
duplicate_x = a
checked.add(a)
x_l_index = A.index(duplicate_x)
x_r_index = N + 1 - A[::-1].index(duplicate_x) - 1
# 逆元の前計算
factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, N + 2):
factorial.append((factorial[-1] * i) % MOD)
invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
inverse.append((inverse[-1] * invere_base[-1]) % MOD)
def nCr(n, r):
if not 0 <= r <= n:
return 0
return factorial[n] * inverse[r] * inverse[n - r] % MOD
for k in range(1, N + 1 + 1):
print(((nCr(N + 1, k) - nCr(max(0, x_l_index) + max(N + 1 - x_r_index - 1, 0), k - 1)) % MOD))
| 35 | 35 | 749 | 818 |
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N + 2):
factorial.append(factorial[-1] * i % mod)
inverse.append(pow(factorial[-1], mod - 2, mod))
# 組み合わせ計算
def nCr(n, r):
if n < r or r < 0:
return 0
elif r == 0:
return 1
return factorial[n] * inverse[r] * inverse[n - r] % mod
X = Counter(A).most_common(1)[0][0]
X_index = []
for i, a in enumerate(A, start=1):
if a == X:
X_index.append(i)
L, R = X_index[0], X_index[1]
for k in range(1, N + 2):
if k == 1:
print(N)
else:
print(((nCr(N + 1, k) - nCr(N - R + L, k - 1)) % mod))
|
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
duplicate_x = None
checked = set()
for a in A:
if a in checked:
duplicate_x = a
checked.add(a)
x_l_index = A.index(duplicate_x)
x_r_index = N + 1 - A[::-1].index(duplicate_x) - 1
# 逆元の前計算
factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, N + 2):
factorial.append((factorial[-1] * i) % MOD)
invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
inverse.append((inverse[-1] * invere_base[-1]) % MOD)
def nCr(n, r):
if not 0 <= r <= n:
return 0
return factorial[n] * inverse[r] * inverse[n - r] % MOD
for k in range(1, N + 1 + 1):
print(
(
(
nCr(N + 1, k)
- nCr(max(0, x_l_index) + max(N + 1 - x_r_index - 1, 0), k - 1)
)
% MOD
)
)
| false | 0 |
[
"-from collections import Counter",
"-",
"-mod = 10**9 + 7",
"-# 階乗 & 逆元計算",
"-factorial = [1]",
"-inverse = [1]",
"-for i in range(1, N + 2):",
"- factorial.append(factorial[-1] * i % mod)",
"- inverse.append(pow(factorial[-1], mod - 2, mod))",
"-# 組み合わせ計算",
"-def nCr(n, r):",
"- if n < r or r < 0:",
"- return 0",
"- elif r == 0:",
"- return 1",
"- return factorial[n] * inverse[r] * inverse[n - r] % mod",
"+MOD = 10**9 + 7",
"+duplicate_x = None",
"+checked = set()",
"+for a in A:",
"+ if a in checked:",
"+ duplicate_x = a",
"+ checked.add(a)",
"+x_l_index = A.index(duplicate_x)",
"+x_r_index = N + 1 - A[::-1].index(duplicate_x) - 1",
"+# 逆元の前計算",
"+factorial = [1, 1]",
"+inverse = [1, 1]",
"+invere_base = [0, 1]",
"+for i in range(2, N + 2):",
"+ factorial.append((factorial[-1] * i) % MOD)",
"+ invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)",
"+ inverse.append((inverse[-1] * invere_base[-1]) % MOD)",
"-X = Counter(A).most_common(1)[0][0]",
"-X_index = []",
"-for i, a in enumerate(A, start=1):",
"- if a == X:",
"- X_index.append(i)",
"-L, R = X_index[0], X_index[1]",
"-for k in range(1, N + 2):",
"- if k == 1:",
"- print(N)",
"- else:",
"- print(((nCr(N + 1, k) - nCr(N - R + L, k - 1)) % mod))",
"+def nCr(n, r):",
"+ if not 0 <= r <= n:",
"+ return 0",
"+ return factorial[n] * inverse[r] * inverse[n - r] % MOD",
"+",
"+",
"+for k in range(1, N + 1 + 1):",
"+ print(",
"+ (",
"+ (",
"+ nCr(N + 1, k)",
"+ - nCr(max(0, x_l_index) + max(N + 1 - x_r_index - 1, 0), k - 1)",
"+ )",
"+ % MOD",
"+ )",
"+ )"
] | false | 0.068856 | 0.069677 | 0.988226 |
[
"s008253665",
"s744882268"
] |
u625729943
|
p02594
|
python
|
s256582394
|
s622666546
| 137 | 73 | 65,236 | 65,096 |
Accepted
|
Accepted
| 46.72 |
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')
N = int(input())
if 30<=N:
print('Yes')
else:
print('No')
|
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial # , gcd
from bisect import bisect_left, bisect_right # bisect_left(list, value)
sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")
X = int(input())
print('Yes') if 30<=X else print('No')
| 18 | 15 | 467 | 461 |
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial # , gcd
from bisect import bisect_left, bisect_right # bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9 + 7
def input():
return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")
N = int(input())
if 30 <= N:
print("Yes")
else:
print("No")
|
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial # , gcd
from bisect import bisect_left, bisect_right # bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")
X = int(input())
print("Yes") if 30 <= X else print("No")
| false | 16.666667 |
[
"-",
"-",
"-def input():",
"- return sys.stdin.readline()[:-1]",
"-",
"-",
"+input = lambda: sys.stdin.readline()[:-1]",
"-N = int(input())",
"-if 30 <= N:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+X = int(input())",
"+print(\"Yes\") if 30 <= X else print(\"No\")"
] | false | 0.061631 | 0.095336 | 0.646462 |
[
"s256582394",
"s622666546"
] |
u104675693
|
p02953
|
python
|
s679991767
|
s047015401
| 86 | 68 | 14,396 | 15,020 |
Accepted
|
Accepted
| 20.93 |
#from:#7967379
N = int(eval(input()))
W = list(map(int, input().split()))
judge = True
for i in range(N-1):
if W[i]<W[i+1]:
W[i+1]-=1
if W[i]>W[i+1]:
judge = False
break
print(('Yes' if judge else 'No'))
'''
in [1]:
4
4 3 5 6
out [1]:
No
'''
|
N = int(eval(input()))
H = list(map(int, input().split()))
Frg = True #True => 'Yes'
for i in range(N-1, 1,-1):
if H[i-1] > H[i]:
H[i-1] -= 1
if H[i-1] > H[i]:
Frg = False
break
print(('Yes' if Frg else 'No'))
| 20 | 13 | 276 | 238 |
# from:#7967379
N = int(eval(input()))
W = list(map(int, input().split()))
judge = True
for i in range(N - 1):
if W[i] < W[i + 1]:
W[i + 1] -= 1
if W[i] > W[i + 1]:
judge = False
break
print(("Yes" if judge else "No"))
"""
in [1]:
4
4 3 5 6
out [1]:
No
"""
|
N = int(eval(input()))
H = list(map(int, input().split()))
Frg = True # True => 'Yes'
for i in range(N - 1, 1, -1):
if H[i - 1] > H[i]:
H[i - 1] -= 1
if H[i - 1] > H[i]:
Frg = False
break
print(("Yes" if Frg else "No"))
| false | 35 |
[
"-# from:#7967379",
"-W = list(map(int, input().split()))",
"-judge = True",
"-for i in range(N - 1):",
"- if W[i] < W[i + 1]:",
"- W[i + 1] -= 1",
"- if W[i] > W[i + 1]:",
"- judge = False",
"- break",
"-print((\"Yes\" if judge else \"No\"))",
"-\"\"\"",
"-in [1]:",
"- 4",
"- 4 3 5 6",
"-out [1]:",
"- No",
"-\"\"\"",
"+H = list(map(int, input().split()))",
"+Frg = True # True => 'Yes'",
"+for i in range(N - 1, 1, -1):",
"+ if H[i - 1] > H[i]:",
"+ H[i - 1] -= 1",
"+ if H[i - 1] > H[i]:",
"+ Frg = False",
"+ break",
"+print((\"Yes\" if Frg else \"No\"))"
] | false | 0.036115 | 0.03678 | 0.981938 |
[
"s679991767",
"s047015401"
] |
u691018832
|
p03475
|
python
|
s188024760
|
s285612733
| 102 | 80 | 3,188 | 3,188 |
Accepted
|
Accepted
| 21.57 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n = int(readline())
cfs = [list(map(int, readline().split())) for i in range(n - 1)]
for i in range(n - 1):
cnt = 0
for j in range(i, n - 1):
if cnt < cfs[j][1]:
cnt = cfs[j][1]
elif cnt % cfs[j][2] == 0:
pass
else:
cnt += cfs[j][2] - (cnt % cfs[j][2])
cnt += cfs[j][0]
print(cnt)
print((0))
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n = int(readline())
csf = [list(map(int, readline().split())) for _ in range(n - 1)]
for i, (c, s, _) in enumerate(csf):
s += c
for cc, ss, ff in csf[i + 1:]:
if s < ss:
s = ss
elif s % ff != 0:
s += ff - (s % ff)
s += cc
print(s)
print((0))
| 20 | 18 | 537 | 465 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n = int(readline())
cfs = [list(map(int, readline().split())) for i in range(n - 1)]
for i in range(n - 1):
cnt = 0
for j in range(i, n - 1):
if cnt < cfs[j][1]:
cnt = cfs[j][1]
elif cnt % cfs[j][2] == 0:
pass
else:
cnt += cfs[j][2] - (cnt % cfs[j][2])
cnt += cfs[j][0]
print(cnt)
print((0))
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n = int(readline())
csf = [list(map(int, readline().split())) for _ in range(n - 1)]
for i, (c, s, _) in enumerate(csf):
s += c
for cc, ss, ff in csf[i + 1 :]:
if s < ss:
s = ss
elif s % ff != 0:
s += ff - (s % ff)
s += cc
print(s)
print((0))
| false | 10 |
[
"-cfs = [list(map(int, readline().split())) for i in range(n - 1)]",
"-for i in range(n - 1):",
"- cnt = 0",
"- for j in range(i, n - 1):",
"- if cnt < cfs[j][1]:",
"- cnt = cfs[j][1]",
"- elif cnt % cfs[j][2] == 0:",
"- pass",
"- else:",
"- cnt += cfs[j][2] - (cnt % cfs[j][2])",
"- cnt += cfs[j][0]",
"- print(cnt)",
"+csf = [list(map(int, readline().split())) for _ in range(n - 1)]",
"+for i, (c, s, _) in enumerate(csf):",
"+ s += c",
"+ for cc, ss, ff in csf[i + 1 :]:",
"+ if s < ss:",
"+ s = ss",
"+ elif s % ff != 0:",
"+ s += ff - (s % ff)",
"+ s += cc",
"+ print(s)"
] | false | 0.037217 | 0.037509 | 0.992204 |
[
"s188024760",
"s285612733"
] |
u509739538
|
p02787
|
python
|
s152645546
|
s981021194
| 1,356 | 360 | 3,188 | 3,188 |
Accepted
|
Accepted
| 73.45 |
h,n = list(map(int,input().split()))
ab = []
for i in range(n):
a,b = list(map(int,input().split()))
ab.append([a,b])
#ab.sort(key=lambda x: x[2], reverse=True)
if h==9999 and n==10:
print((139815))
exit()
#bubble sort
for i in range(n-1,-1,-1):
for j in range(0,i):
if ab[j][0]*ab[j+1][1]<ab[j+1][0]*ab[j][1]:
tmp = ab[j]
ab[j] = ab[j+1]
ab[j+1] = tmp
ans = 0
anslist = []
def indexH(h,arr):
li = []
for i in range(len(arr)):
if arr[i][0]>=h:
li.append(i)
return li[::-1]
while 1:
if len(ab)==0:
break
if max(ab, key=lambda x:x[0])[0]<h:
h-=ab[0][0]
ans+=ab[0][1]
#print(h,ans)
else:
c = 0
index = indexH(h,ab)
#print(h,index,ab,ab)
for i in range(len(index)):
anslist.append(ans+ab[index[i]][1])
ab.pop(index[i])
print((min(anslist)))
|
h,n = list(map(int,input().split()))
ab = []
for i in range(n):
a,b = list(map(int,input().split()))
ab.append([a,b])
#ab.sort(key=lambda x: x[2], reverse=True)
if h==9999 and n==10:
print((139815))
exit()
#bubble sort
for i in range(n-1,-1,-1):
for j in range(0,i):
if ab[j][0]*ab[j+1][1]<ab[j+1][0]*ab[j][1]:
tmp = ab[j]
ab[j] = ab[j+1]
ab[j+1] = tmp
ans = 0
anslist = []
def indexH(h,arr):
li = []
for i in range(len(arr)):
if arr[i][0]>=h:
li.append(i)
return li[::-1]
while 1:
if len(ab)==0:
break
maxa = max(ab, key=lambda x:x[0])[0]
if maxa<h:
x = (h-maxa)//ab[0][0]
h-=ab[0][0]*max(x,1)
ans+=ab[0][1]*max(x,1)
#print(h,ans)
else:
c = 0
index = indexH(h,ab)
#print(h,index,ab,ab)
for i in range(len(index)):
anslist.append(ans+ab[index[i]][1])
ab.pop(index[i])
print((min(anslist)))
| 49 | 51 | 876 | 937 |
h, n = list(map(int, input().split()))
ab = []
for i in range(n):
a, b = list(map(int, input().split()))
ab.append([a, b])
# ab.sort(key=lambda x: x[2], reverse=True)
if h == 9999 and n == 10:
print((139815))
exit()
# bubble sort
for i in range(n - 1, -1, -1):
for j in range(0, i):
if ab[j][0] * ab[j + 1][1] < ab[j + 1][0] * ab[j][1]:
tmp = ab[j]
ab[j] = ab[j + 1]
ab[j + 1] = tmp
ans = 0
anslist = []
def indexH(h, arr):
li = []
for i in range(len(arr)):
if arr[i][0] >= h:
li.append(i)
return li[::-1]
while 1:
if len(ab) == 0:
break
if max(ab, key=lambda x: x[0])[0] < h:
h -= ab[0][0]
ans += ab[0][1]
# print(h,ans)
else:
c = 0
index = indexH(h, ab)
# print(h,index,ab,ab)
for i in range(len(index)):
anslist.append(ans + ab[index[i]][1])
ab.pop(index[i])
print((min(anslist)))
|
h, n = list(map(int, input().split()))
ab = []
for i in range(n):
a, b = list(map(int, input().split()))
ab.append([a, b])
# ab.sort(key=lambda x: x[2], reverse=True)
if h == 9999 and n == 10:
print((139815))
exit()
# bubble sort
for i in range(n - 1, -1, -1):
for j in range(0, i):
if ab[j][0] * ab[j + 1][1] < ab[j + 1][0] * ab[j][1]:
tmp = ab[j]
ab[j] = ab[j + 1]
ab[j + 1] = tmp
ans = 0
anslist = []
def indexH(h, arr):
li = []
for i in range(len(arr)):
if arr[i][0] >= h:
li.append(i)
return li[::-1]
while 1:
if len(ab) == 0:
break
maxa = max(ab, key=lambda x: x[0])[0]
if maxa < h:
x = (h - maxa) // ab[0][0]
h -= ab[0][0] * max(x, 1)
ans += ab[0][1] * max(x, 1)
# print(h,ans)
else:
c = 0
index = indexH(h, ab)
# print(h,index,ab,ab)
for i in range(len(index)):
anslist.append(ans + ab[index[i]][1])
ab.pop(index[i])
print((min(anslist)))
| false | 3.921569 |
[
"- if max(ab, key=lambda x: x[0])[0] < h:",
"- h -= ab[0][0]",
"- ans += ab[0][1]",
"+ maxa = max(ab, key=lambda x: x[0])[0]",
"+ if maxa < h:",
"+ x = (h - maxa) // ab[0][0]",
"+ h -= ab[0][0] * max(x, 1)",
"+ ans += ab[0][1] * max(x, 1)"
] | false | 0.040063 | 0.076899 | 0.520985 |
[
"s152645546",
"s981021194"
] |
u620084012
|
p03324
|
python
|
s478948457
|
s891720907
| 166 | 18 | 38,384 | 2,940 |
Accepted
|
Accepted
| 89.16 |
D, N = list(map(int,input().split()))
if N != 100:
print((str(N)+"0"*(D*2)))
else:
print(((N+1)*(100**D)))
|
D, N = list(map(int,input().split()))
if D == 0:
if N < 100:
print(N)
else:
print((101))
elif D == 1:
if N < 100:
print((N*100))
else:
print((10100))
else:
if N < 100:
print((N*10000))
else:
print((1010000))
| 5 | 16 | 109 | 279 |
D, N = list(map(int, input().split()))
if N != 100:
print((str(N) + "0" * (D * 2)))
else:
print(((N + 1) * (100**D)))
|
D, N = list(map(int, input().split()))
if D == 0:
if N < 100:
print(N)
else:
print((101))
elif D == 1:
if N < 100:
print((N * 100))
else:
print((10100))
else:
if N < 100:
print((N * 10000))
else:
print((1010000))
| false | 68.75 |
[
"-if N != 100:",
"- print((str(N) + \"0\" * (D * 2)))",
"+if D == 0:",
"+ if N < 100:",
"+ print(N)",
"+ else:",
"+ print((101))",
"+elif D == 1:",
"+ if N < 100:",
"+ print((N * 100))",
"+ else:",
"+ print((10100))",
"- print(((N + 1) * (100**D)))",
"+ if N < 100:",
"+ print((N * 10000))",
"+ else:",
"+ print((1010000))"
] | false | 0.04001 | 0.035684 | 1.121228 |
[
"s478948457",
"s891720907"
] |
u729133443
|
p02983
|
python
|
s527483931
|
s248750117
| 526 | 44 | 2,940 | 2,940 |
Accepted
|
Accepted
| 91.63 |
l,r=list(map(int,input().split()));s=list(range(l,r+1));print((+(r-l<2019)and min(i*j%2019for i in s for j in s if i<j)))
|
l,r=list(map(int,input().split()));s=list(range(l,r+1));print((+(r-l<2e3)and min(i*j%2019for i in s for j in s if i<j)))
| 1 | 1 | 107 | 106 |
l, r = list(map(int, input().split()))
s = list(range(l, r + 1))
print((+(r - l < 2019) and min(i * j % 2019 for i in s for j in s if i < j)))
|
l, r = list(map(int, input().split()))
s = list(range(l, r + 1))
print((+(r - l < 2e3) and min(i * j % 2019 for i in s for j in s if i < j)))
| false | 0 |
[
"-print((+(r - l < 2019) and min(i * j % 2019 for i in s for j in s if i < j)))",
"+print((+(r - l < 2e3) and min(i * j % 2019 for i in s for j in s if i < j)))"
] | false | 0.041002 | 0.039247 | 1.04471 |
[
"s527483931",
"s248750117"
] |
u761529120
|
p03038
|
python
|
s388432019
|
s840739565
| 955 | 707 | 88,240 | 92,568 |
Accepted
|
Accepted
| 25.97 |
import sys
from collections import defaultdict
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
d = defaultdict(int)
for _ in range(M):
B, C = list(map(int, input().split()))
d[C] += B
for a in A:
d[a] += 1
sort_d = sorted(list(d.items()),reverse = True)
cnt = 0
ans = 0
for i,j in sort_d:
if cnt + j < N:
ans += i * j
cnt += j
elif cnt + j >= N:
if cnt == N:
break
ans += i * (N - cnt)
break
print(ans)
main()
|
from collections import defaultdict
def main():
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
d = defaultdict(int)
for i in range(M):
B, C = list(map(int, input().split()))
d[C] += B
for a in A:
d[a] += 1
ans = 0
cnt = 0
for i in sorted(list(d.keys()),reverse=True):
if cnt + d[i] < N:
ans += d[i] * i
cnt += d[i]
else:
ans += i * (N - cnt)
cnt = N
break
print(ans)
if __name__ == "__main__":
main()
| 33 | 30 | 661 | 590 |
import sys
from collections import defaultdict
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
d = defaultdict(int)
for _ in range(M):
B, C = list(map(int, input().split()))
d[C] += B
for a in A:
d[a] += 1
sort_d = sorted(list(d.items()), reverse=True)
cnt = 0
ans = 0
for i, j in sort_d:
if cnt + j < N:
ans += i * j
cnt += j
elif cnt + j >= N:
if cnt == N:
break
ans += i * (N - cnt)
break
print(ans)
main()
|
from collections import defaultdict
def main():
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
d = defaultdict(int)
for i in range(M):
B, C = list(map(int, input().split()))
d[C] += B
for a in A:
d[a] += 1
ans = 0
cnt = 0
for i in sorted(list(d.keys()), reverse=True):
if cnt + d[i] < N:
ans += d[i] * i
cnt += d[i]
else:
ans += i * (N - cnt)
cnt = N
break
print(ans)
if __name__ == "__main__":
main()
| false | 9.090909 |
[
"-import sys",
"-",
"-input = sys.stdin.readline",
"- for _ in range(M):",
"+ for i in range(M):",
"- sort_d = sorted(list(d.items()), reverse=True)",
"+ ans = 0",
"- ans = 0",
"- for i, j in sort_d:",
"- if cnt + j < N:",
"- ans += i * j",
"- cnt += j",
"- elif cnt + j >= N:",
"- if cnt == N:",
"- break",
"+ for i in sorted(list(d.keys()), reverse=True):",
"+ if cnt + d[i] < N:",
"+ ans += d[i] * i",
"+ cnt += d[i]",
"+ else:",
"+ cnt = N",
"-main()",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.047601 | 0.043642 | 1.090738 |
[
"s388432019",
"s840739565"
] |
u767664985
|
p02947
|
python
|
s782698790
|
s885584078
| 378 | 343 | 23,436 | 19,760 |
Accepted
|
Accepted
| 9.26 |
import collections
N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
n = c[si]
ans += n * (n - 1) // 2
print(ans)
|
from collections import Counter
N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = Counter(s)
ans = 0
for ci in list(c.values()):
ans += ci * (ci - 1) // 2
print(ans)
| 10 | 12 | 201 | 199 |
import collections
N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
n = c[si]
ans += n * (n - 1) // 2
print(ans)
|
from collections import Counter
N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = Counter(s)
ans = 0
for ci in list(c.values()):
ans += ci * (ci - 1) // 2
print(ans)
| false | 16.666667 |
[
"-import collections",
"+from collections import Counter",
"-c = collections.Counter(s)",
"+c = Counter(s)",
"-for si in set(s):",
"- n = c[si]",
"- ans += n * (n - 1) // 2",
"+for ci in list(c.values()):",
"+ ans += ci * (ci - 1) // 2"
] | false | 0.034928 | 0.03737 | 0.934642 |
[
"s782698790",
"s885584078"
] |
u451017206
|
p03213
|
python
|
s932274890
|
s394350764
| 1,395 | 18 | 3,064 | 3,064 |
Accepted
|
Accepted
| 98.71 |
N = int(eval(input()))
from math import ceil, sqrt, factorial
from itertools import permutations
def eratosthenes(n):
l = [1 for i in range(n+1)]
l[0] = l[1] = 0
for i in range(2, ceil(sqrt(n))):
if l[i] == 0: continue
for j in range(i*2, n+1, i):
l[j] = 0
return l
m = factorial(N)
ans = set()
p = eratosthenes(530)
p = [i for i,v in enumerate(p) if v ]
for i in p:
a = i**74
if not m % a:
ans.add(a)
break
for a,b in permutations(p,2):
c = a**2*b**24
if not m % c:
ans.add(c)
c = a**4*b**14
if not m % c:
ans.add(c)
for a,b,c in permutations(p, 3):
d = a**2 * b**4 * c ** 4
if not m % d:
ans.add(d)
print((len(ans)))
|
N = int(eval(input()))
p = [0] * (N+1)
def is_prime(n):
for i in range(2, n):
if not n % i:
return False
return True
def n(m):
return sum([True for i in p if i >= m])
l = [i for i in range(2, N+1) if is_prime(i)]
for i in range(2, N+1):
for j in l:
while not i % j:
p[j] += 1
i //= j
print((n(74) +
(n(2)-1) * n(24) +
(n(2)-2) * ((n(4)-1) * n(4))//2 +
(n(4)-1) * n(14)))
| 39 | 26 | 772 | 480 |
N = int(eval(input()))
from math import ceil, sqrt, factorial
from itertools import permutations
def eratosthenes(n):
l = [1 for i in range(n + 1)]
l[0] = l[1] = 0
for i in range(2, ceil(sqrt(n))):
if l[i] == 0:
continue
for j in range(i * 2, n + 1, i):
l[j] = 0
return l
m = factorial(N)
ans = set()
p = eratosthenes(530)
p = [i for i, v in enumerate(p) if v]
for i in p:
a = i**74
if not m % a:
ans.add(a)
break
for a, b in permutations(p, 2):
c = a**2 * b**24
if not m % c:
ans.add(c)
c = a**4 * b**14
if not m % c:
ans.add(c)
for a, b, c in permutations(p, 3):
d = a**2 * b**4 * c**4
if not m % d:
ans.add(d)
print((len(ans)))
|
N = int(eval(input()))
p = [0] * (N + 1)
def is_prime(n):
for i in range(2, n):
if not n % i:
return False
return True
def n(m):
return sum([True for i in p if i >= m])
l = [i for i in range(2, N + 1) if is_prime(i)]
for i in range(2, N + 1):
for j in l:
while not i % j:
p[j] += 1
i //= j
print(
(
n(74)
+ (n(2) - 1) * n(24)
+ (n(2) - 2) * ((n(4) - 1) * n(4)) // 2
+ (n(4) - 1) * n(14)
)
)
| false | 33.333333 |
[
"-from math import ceil, sqrt, factorial",
"-from itertools import permutations",
"+p = [0] * (N + 1)",
"-def eratosthenes(n):",
"- l = [1 for i in range(n + 1)]",
"- l[0] = l[1] = 0",
"- for i in range(2, ceil(sqrt(n))):",
"- if l[i] == 0:",
"- continue",
"- for j in range(i * 2, n + 1, i):",
"- l[j] = 0",
"- return l",
"+def is_prime(n):",
"+ for i in range(2, n):",
"+ if not n % i:",
"+ return False",
"+ return True",
"-m = factorial(N)",
"-ans = set()",
"-p = eratosthenes(530)",
"-p = [i for i, v in enumerate(p) if v]",
"-for i in p:",
"- a = i**74",
"- if not m % a:",
"- ans.add(a)",
"- break",
"-for a, b in permutations(p, 2):",
"- c = a**2 * b**24",
"- if not m % c:",
"- ans.add(c)",
"- c = a**4 * b**14",
"- if not m % c:",
"- ans.add(c)",
"-for a, b, c in permutations(p, 3):",
"- d = a**2 * b**4 * c**4",
"- if not m % d:",
"- ans.add(d)",
"-print((len(ans)))",
"+def n(m):",
"+ return sum([True for i in p if i >= m])",
"+",
"+",
"+l = [i for i in range(2, N + 1) if is_prime(i)]",
"+for i in range(2, N + 1):",
"+ for j in l:",
"+ while not i % j:",
"+ p[j] += 1",
"+ i //= j",
"+print(",
"+ (",
"+ n(74)",
"+ + (n(2) - 1) * n(24)",
"+ + (n(2) - 2) * ((n(4) - 1) * n(4)) // 2",
"+ + (n(4) - 1) * n(14)",
"+ )",
"+)"
] | false | 1.982292 | 0.048888 | 40.547526 |
[
"s932274890",
"s394350764"
] |
u874723578
|
p03449
|
python
|
s760449490
|
s071901701
| 20 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 15 |
n = int(eval(input()))
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
ans = 0
for i in range(n):
total = 0
num = i
while num >= 0:
total += c1[num]
num -= 1
for j in range(i,n):
total += c2[j]
ans = max(ans, total)
print(ans)
|
n = int(eval(input()))
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
ans = 0
for i in range(n):
ans = max(ans, sum(c1[:i+1] + c2[i:]))
print(ans)
| 15 | 9 | 306 | 182 |
n = int(eval(input()))
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
ans = 0
for i in range(n):
total = 0
num = i
while num >= 0:
total += c1[num]
num -= 1
for j in range(i, n):
total += c2[j]
ans = max(ans, total)
print(ans)
|
n = int(eval(input()))
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
ans = 0
for i in range(n):
ans = max(ans, sum(c1[: i + 1] + c2[i:]))
print(ans)
| false | 40 |
[
"- total = 0",
"- num = i",
"- while num >= 0:",
"- total += c1[num]",
"- num -= 1",
"- for j in range(i, n):",
"- total += c2[j]",
"- ans = max(ans, total)",
"+ ans = max(ans, sum(c1[: i + 1] + c2[i:]))"
] | false | 0.140135 | 0.049085 | 2.854974 |
[
"s760449490",
"s071901701"
] |
u760831084
|
p03807
|
python
|
s642668517
|
s782067871
| 57 | 50 | 16,992 | 16,816 |
Accepted
|
Accepted
| 12.28 |
n = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for a in A:
if a % 2 != 0:
cnt += 1
if cnt % 2 == 0:
print('YES')
else:
print('NO')
|
n = int(eval(input()))
a = list(map(int, input().split()))
print(('YES' if sum(a) % 2 == 0 else 'NO'))
| 12 | 3 | 171 | 90 |
n = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for a in A:
if a % 2 != 0:
cnt += 1
if cnt % 2 == 0:
print("YES")
else:
print("NO")
|
n = int(eval(input()))
a = list(map(int, input().split()))
print(("YES" if sum(a) % 2 == 0 else "NO"))
| false | 75 |
[
"-A = list(map(int, input().split()))",
"-cnt = 0",
"-for a in A:",
"- if a % 2 != 0:",
"- cnt += 1",
"-if cnt % 2 == 0:",
"- print(\"YES\")",
"-else:",
"- print(\"NO\")",
"+a = list(map(int, input().split()))",
"+print((\"YES\" if sum(a) % 2 == 0 else \"NO\"))"
] | false | 0.0438 | 0.12522 | 0.349784 |
[
"s642668517",
"s782067871"
] |
u418149936
|
p02701
|
python
|
s067815438
|
s289495827
| 281 | 257 | 30,924 | 31,088 |
Accepted
|
Accepted
| 8.54 |
N = int(eval(input()))
ls = { eval(input()) for i in range(N)}
print((len(ls)))
|
N = int(eval(input()))
print((len({ eval(input()) for i in range(N) })))
| 3 | 2 | 67 | 59 |
N = int(eval(input()))
ls = {eval(input()) for i in range(N)}
print((len(ls)))
|
N = int(eval(input()))
print((len({eval(input()) for i in range(N)})))
| false | 33.333333 |
[
"-ls = {eval(input()) for i in range(N)}",
"-print((len(ls)))",
"+print((len({eval(input()) for i in range(N)})))"
] | false | 0.033909 | 0.033786 | 1.003646 |
[
"s067815438",
"s289495827"
] |
u971091945
|
p02860
|
python
|
s853015371
|
s340698692
| 19 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 10.53 |
import math
n = int(eval(input()))
a = list(eval(input()))
even = math.floor(n/2)
b=a[:even]
c=a[even:]
if b==c:
print("Yes")
else:
print("No")
|
n = int(eval(input()))
s = eval(input())
even =n//2
a = s[:even]
b = s[even:]
if a==b:
print("Yes")
else:
print("No")
| 14 | 12 | 156 | 127 |
import math
n = int(eval(input()))
a = list(eval(input()))
even = math.floor(n / 2)
b = a[:even]
c = a[even:]
if b == c:
print("Yes")
else:
print("No")
|
n = int(eval(input()))
s = eval(input())
even = n // 2
a = s[:even]
b = s[even:]
if a == b:
print("Yes")
else:
print("No")
| false | 14.285714 |
[
"-import math",
"-",
"-a = list(eval(input()))",
"-even = math.floor(n / 2)",
"-b = a[:even]",
"-c = a[even:]",
"-if b == c:",
"+s = eval(input())",
"+even = n // 2",
"+a = s[:even]",
"+b = s[even:]",
"+if a == b:"
] | false | 0.044814 | 0.046302 | 0.96786 |
[
"s853015371",
"s340698692"
] |
u188827677
|
p03324
|
python
|
s705157667
|
s712574560
| 29 | 25 | 8,992 | 9,088 |
Accepted
|
Accepted
| 13.79 |
d,n = list(map(int, input().split()))
if n == 100: print((100**d*101))
else: print((100**d*n))
|
d,n = list(map(int, input().split()))
if d == 0:
if n == 100: print((101))
else: print(n)
elif d == 1:
if n == 100: print((n*100+100))
else: print((n*100))
else:
if n == 100: print((n*(100**2)+10000))
else: print((n*(100**2)))
| 4 | 11 | 88 | 233 |
d, n = list(map(int, input().split()))
if n == 100:
print((100**d * 101))
else:
print((100**d * n))
|
d, n = list(map(int, input().split()))
if d == 0:
if n == 100:
print((101))
else:
print(n)
elif d == 1:
if n == 100:
print((n * 100 + 100))
else:
print((n * 100))
else:
if n == 100:
print((n * (100**2) + 10000))
else:
print((n * (100**2)))
| false | 63.636364 |
[
"-if n == 100:",
"- print((100**d * 101))",
"+if d == 0:",
"+ if n == 100:",
"+ print((101))",
"+ else:",
"+ print(n)",
"+elif d == 1:",
"+ if n == 100:",
"+ print((n * 100 + 100))",
"+ else:",
"+ print((n * 100))",
"- print((100**d * n))",
"+ if n == 100:",
"+ print((n * (100**2) + 10000))",
"+ else:",
"+ print((n * (100**2)))"
] | false | 0.082456 | 0.103909 | 0.79354 |
[
"s705157667",
"s712574560"
] |
u296518383
|
p02813
|
python
|
s046567144
|
s019403878
| 218 | 180 | 49,264 | 44,912 |
Accepted
|
Accepted
| 17.43 |
from itertools import permutations
N = int(eval(input()))
P = "".join(list(input().split()))
Q = "".join(list(input().split()))
#print("P:", P)
A = ""
for i in range(1, N + 1):
A += str(i)
A = list(permutations(A, N))
A.sort()
#print("A:", A)
B = []
for i in range(len(A)):
B.append("".join(A[i]))
for i in range(len(B)):
if P == B[i]:
a = i
if Q == B[i]:
b = i
print((abs(a-b)))
|
from itertools import permutations
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = list(permutations(list(range(1, N + 1))))
#print("A:", A)
print((abs((A.index(P) - A.index(Q)))))
| 25 | 10 | 420 | 231 |
from itertools import permutations
N = int(eval(input()))
P = "".join(list(input().split()))
Q = "".join(list(input().split()))
# print("P:", P)
A = ""
for i in range(1, N + 1):
A += str(i)
A = list(permutations(A, N))
A.sort()
# print("A:", A)
B = []
for i in range(len(A)):
B.append("".join(A[i]))
for i in range(len(B)):
if P == B[i]:
a = i
if Q == B[i]:
b = i
print((abs(a - b)))
|
from itertools import permutations
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = list(permutations(list(range(1, N + 1))))
# print("A:", A)
print((abs((A.index(P) - A.index(Q)))))
| false | 60 |
[
"-P = \"\".join(list(input().split()))",
"-Q = \"\".join(list(input().split()))",
"-# print(\"P:\", P)",
"-A = \"\"",
"-for i in range(1, N + 1):",
"- A += str(i)",
"-A = list(permutations(A, N))",
"-A.sort()",
"+P = tuple(map(int, input().split()))",
"+Q = tuple(map(int, input().split()))",
"+A = list(permutations(list(range(1, N + 1))))",
"-B = []",
"-for i in range(len(A)):",
"- B.append(\"\".join(A[i]))",
"-for i in range(len(B)):",
"- if P == B[i]:",
"- a = i",
"- if Q == B[i]:",
"- b = i",
"-print((abs(a - b)))",
"+print((abs((A.index(P) - A.index(Q)))))"
] | false | 0.04658 | 0.039269 | 1.186185 |
[
"s046567144",
"s019403878"
] |
u418826171
|
p02572
|
python
|
s627732178
|
s058462088
| 185 | 167 | 31,760 | 31,608 |
Accepted
|
Accepted
| 9.73 |
N = int(eval(input()))
A = tuple(map(int,input().split()))
mod = 10**9+7
B = [0]*N
for i in range(N):
B[i] = A[i]**2
s1, s2 = 0, 0
for i in range(N):
s1 += A[i]
s2 += B[i]
s1 = s1**2
ans = (s1 -s2)//2%mod
print(ans)
|
N = int(eval(input()))
A = tuple(map(int,input().split()))
mod = 10**9+7
ans = 0
s = (sum(A) - A[0])%mod
for i in range(N-1):
if s < 0:
s += mod
ans += A[i]*s%mod
ans %= mod
s -= A[i+1]
print(ans)
| 13 | 12 | 234 | 225 |
N = int(eval(input()))
A = tuple(map(int, input().split()))
mod = 10**9 + 7
B = [0] * N
for i in range(N):
B[i] = A[i] ** 2
s1, s2 = 0, 0
for i in range(N):
s1 += A[i]
s2 += B[i]
s1 = s1**2
ans = (s1 - s2) // 2 % mod
print(ans)
|
N = int(eval(input()))
A = tuple(map(int, input().split()))
mod = 10**9 + 7
ans = 0
s = (sum(A) - A[0]) % mod
for i in range(N - 1):
if s < 0:
s += mod
ans += A[i] * s % mod
ans %= mod
s -= A[i + 1]
print(ans)
| false | 7.692308 |
[
"-B = [0] * N",
"-for i in range(N):",
"- B[i] = A[i] ** 2",
"-s1, s2 = 0, 0",
"-for i in range(N):",
"- s1 += A[i]",
"- s2 += B[i]",
"-s1 = s1**2",
"-ans = (s1 - s2) // 2 % mod",
"+ans = 0",
"+s = (sum(A) - A[0]) % mod",
"+for i in range(N - 1):",
"+ if s < 0:",
"+ s += mod",
"+ ans += A[i] * s % mod",
"+ ans %= mod",
"+ s -= A[i + 1]"
] | false | 0.101097 | 0.034964 | 2.891495 |
[
"s627732178",
"s058462088"
] |
u604522449
|
p02573
|
python
|
s599560784
|
s834306286
| 675 | 473 | 18,472 | 19,728 |
Accepted
|
Accepted
| 29.93 |
N, M = list(map(int, input().split()))
par = [i for i in range(N)]
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x, y):
x = find(x)
y = find(y)
if x > y:
par[x] = y
find(x)
else:
par[y] = x
find(y)
if M > 0:
for i in range(M):
a, b = list(map(int, input().split()))
unite(a - 1, b - 1)
ans = [0] * N
Max = 0
for i in range(N):
find(i)
for i in par:
ans[i] += 1
for i in ans:
if i > Max:
Max = i
print(Max)
else:
print((1))
|
import sys,os
import math
from fractions import Fraction
from collections import defaultdict
from random import randint
# sys.stderr=open('err.txt','w')
# sys.stdout=open('output.txt','w')
# sys.stdin=open('input.txt','r')
def linput():
return list(minput())
def minput():
return list(map(int, sys.stdin.readline().strip().split()))
###############################################################
def make_set(a):
parent[a]=a
sizen[a]=1
def find_set(a):
if parent[a]==a:
return a
parent[a]=find_set(parent[a])
return parent[a]
def union_set(a,b):
x=find_set(a)
y=find_set(b)
if x==y:
return
else:
if sizen[x]>sizen[y]:
parent[y]=x
sizen[x]+=sizen[y]
else:
parent[x]=y
sizen[y]+=sizen[x]
n,m=minput()
parent=[0]*n
sizen=[0]*n
for i in range(n):
make_set(i)
ans=0
for i in range(m):
x,y=minput()
if x>y:
x,y=y,x
x=x-1
y=y-1
union_set(x,y)
# print(parent)
di = defaultdict(int)
# for i in parent:
# di[i]+=1
# print(di)
for v in sizen:
ans=max(ans,v)
print(ans)
| 40 | 63 | 591 | 1,189 |
N, M = list(map(int, input().split()))
par = [i for i in range(N)]
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x, y):
x = find(x)
y = find(y)
if x > y:
par[x] = y
find(x)
else:
par[y] = x
find(y)
if M > 0:
for i in range(M):
a, b = list(map(int, input().split()))
unite(a - 1, b - 1)
ans = [0] * N
Max = 0
for i in range(N):
find(i)
for i in par:
ans[i] += 1
for i in ans:
if i > Max:
Max = i
print(Max)
else:
print((1))
|
import sys, os
import math
from fractions import Fraction
from collections import defaultdict
from random import randint
# sys.stderr=open('err.txt','w')
# sys.stdout=open('output.txt','w')
# sys.stdin=open('input.txt','r')
def linput():
return list(minput())
def minput():
return list(map(int, sys.stdin.readline().strip().split()))
###############################################################
def make_set(a):
parent[a] = a
sizen[a] = 1
def find_set(a):
if parent[a] == a:
return a
parent[a] = find_set(parent[a])
return parent[a]
def union_set(a, b):
x = find_set(a)
y = find_set(b)
if x == y:
return
else:
if sizen[x] > sizen[y]:
parent[y] = x
sizen[x] += sizen[y]
else:
parent[x] = y
sizen[y] += sizen[x]
n, m = minput()
parent = [0] * n
sizen = [0] * n
for i in range(n):
make_set(i)
ans = 0
for i in range(m):
x, y = minput()
if x > y:
x, y = y, x
x = x - 1
y = y - 1
union_set(x, y)
# print(parent)
di = defaultdict(int)
# for i in parent:
# di[i]+=1
# print(di)
for v in sizen:
ans = max(ans, v)
print(ans)
| false | 36.507937 |
[
"-N, M = list(map(int, input().split()))",
"-par = [i for i in range(N)]",
"+import sys, os",
"+import math",
"+from fractions import Fraction",
"+from collections import defaultdict",
"+from random import randint",
"+",
"+# sys.stderr=open('err.txt','w')",
"+# sys.stdout=open('output.txt','w')",
"+# sys.stdin=open('input.txt','r')",
"+def linput():",
"+ return list(minput())",
"-def find(x):",
"- if par[x] == x:",
"- return x",
"- else:",
"- par[x] = find(par[x])",
"- return par[x]",
"+def minput():",
"+ return list(map(int, sys.stdin.readline().strip().split()))",
"-def unite(x, y):",
"- x = find(x)",
"- y = find(y)",
"- if x > y:",
"- par[x] = y",
"- find(x)",
"- else:",
"- par[y] = x",
"- find(y)",
"+###############################################################",
"+def make_set(a):",
"+ parent[a] = a",
"+ sizen[a] = 1",
"-if M > 0:",
"- for i in range(M):",
"- a, b = list(map(int, input().split()))",
"- unite(a - 1, b - 1)",
"- ans = [0] * N",
"- Max = 0",
"- for i in range(N):",
"- find(i)",
"- for i in par:",
"- ans[i] += 1",
"- for i in ans:",
"- if i > Max:",
"- Max = i",
"- print(Max)",
"-else:",
"- print((1))",
"+def find_set(a):",
"+ if parent[a] == a:",
"+ return a",
"+ parent[a] = find_set(parent[a])",
"+ return parent[a]",
"+",
"+",
"+def union_set(a, b):",
"+ x = find_set(a)",
"+ y = find_set(b)",
"+ if x == y:",
"+ return",
"+ else:",
"+ if sizen[x] > sizen[y]:",
"+ parent[y] = x",
"+ sizen[x] += sizen[y]",
"+ else:",
"+ parent[x] = y",
"+ sizen[y] += sizen[x]",
"+",
"+",
"+n, m = minput()",
"+parent = [0] * n",
"+sizen = [0] * n",
"+for i in range(n):",
"+ make_set(i)",
"+ans = 0",
"+for i in range(m):",
"+ x, y = minput()",
"+ if x > y:",
"+ x, y = y, x",
"+ x = x - 1",
"+ y = y - 1",
"+ union_set(x, y)",
"+# print(parent)",
"+di = defaultdict(int)",
"+# for i in parent:",
"+# di[i]+=1",
"+# print(di)",
"+for v in sizen:",
"+ ans = max(ans, v)",
"+print(ans)"
] | false | 0.039047 | 0.040655 | 0.960454 |
[
"s599560784",
"s834306286"
] |
u691896522
|
p02787
|
python
|
s303058568
|
s225687110
| 976 | 619 | 270,088 | 125,564 |
Accepted
|
Accepted
| 36.58 |
h, n = list(map(int, input().split()))
inf = 10**12
data = []
for i in range(n):
data.append(list(map(int, input().split())))
dp = [[inf for i in range(h+1 + 10**4)] for j in range(n+1)]
for i in range(n):
dp[i][0] = 0
for i in range(n):
a, b = data[i]
for j in range(h+1+10**4):
if j - a >= 0:
dp[i+1][j] = min(dp[i+1][j-a] + b, dp[i][j])
else:
dp[i+1][j] = min(b, dp[i][j])
print((dp[-1][h]))
|
h, n = list(map(int, input().split()))
inf = 10**10
dp = [[inf for i in range(h+1)] for j in range(n+1)]
#dp[i][j] := i番目の魔法まで考えたとき、hpをh減らす最小コスト
dp[0][0] = 0
for i in range(1,n+1):
damage, cost = list(map(int, input().split()))
for j in range(h+1):
if j - damage < 0:
dp[i][j] = min(cost, dp[i][j], dp[i-1][j])
else:
dp[i][j] = min(dp[i][j - damage] + cost, dp[i-1][j])
print((dp[-1][h]))
| 16 | 13 | 457 | 434 |
h, n = list(map(int, input().split()))
inf = 10**12
data = []
for i in range(n):
data.append(list(map(int, input().split())))
dp = [[inf for i in range(h + 1 + 10**4)] for j in range(n + 1)]
for i in range(n):
dp[i][0] = 0
for i in range(n):
a, b = data[i]
for j in range(h + 1 + 10**4):
if j - a >= 0:
dp[i + 1][j] = min(dp[i + 1][j - a] + b, dp[i][j])
else:
dp[i + 1][j] = min(b, dp[i][j])
print((dp[-1][h]))
|
h, n = list(map(int, input().split()))
inf = 10**10
dp = [[inf for i in range(h + 1)] for j in range(n + 1)]
# dp[i][j] := i番目の魔法まで考えたとき、hpをh減らす最小コスト
dp[0][0] = 0
for i in range(1, n + 1):
damage, cost = list(map(int, input().split()))
for j in range(h + 1):
if j - damage < 0:
dp[i][j] = min(cost, dp[i][j], dp[i - 1][j])
else:
dp[i][j] = min(dp[i][j - damage] + cost, dp[i - 1][j])
print((dp[-1][h]))
| false | 18.75 |
[
"-inf = 10**12",
"-data = []",
"-for i in range(n):",
"- data.append(list(map(int, input().split())))",
"-dp = [[inf for i in range(h + 1 + 10**4)] for j in range(n + 1)]",
"-for i in range(n):",
"- dp[i][0] = 0",
"-for i in range(n):",
"- a, b = data[i]",
"- for j in range(h + 1 + 10**4):",
"- if j - a >= 0:",
"- dp[i + 1][j] = min(dp[i + 1][j - a] + b, dp[i][j])",
"+inf = 10**10",
"+dp = [[inf for i in range(h + 1)] for j in range(n + 1)]",
"+# dp[i][j] := i番目の魔法まで考えたとき、hpをh減らす最小コスト",
"+dp[0][0] = 0",
"+for i in range(1, n + 1):",
"+ damage, cost = list(map(int, input().split()))",
"+ for j in range(h + 1):",
"+ if j - damage < 0:",
"+ dp[i][j] = min(cost, dp[i][j], dp[i - 1][j])",
"- dp[i + 1][j] = min(b, dp[i][j])",
"+ dp[i][j] = min(dp[i][j - damage] + cost, dp[i - 1][j])"
] | false | 0.150718 | 0.078627 | 1.916866 |
[
"s303058568",
"s225687110"
] |
u457601965
|
p02923
|
python
|
s953412088
|
s046939956
| 885 | 83 | 20,516 | 20,568 |
Accepted
|
Accepted
| 90.62 |
n = int(eval(input()))
h = list(map(int, input().split()))
nm = len(h)
ans = 0
for _ in range(nm):
cnt = 0
while True:
if len(h) == 1:
break
if h[0] >= h[1]:
cnt += 1
h.pop(0)
else:
h.pop(0)
break
ans = max(ans, cnt)
print(ans)
|
N = int(eval(input()))
N_List = list(map(int,input().split()))
ans = 0
cans = 0
for i in range(1,N):
if N_List[i] <= N_List[i-1]:
cans += 1
if cans > ans:
ans = cans
if N_List[i] > N_List[i-1]:
cans = 0
print(ans)
| 17 | 13 | 334 | 260 |
n = int(eval(input()))
h = list(map(int, input().split()))
nm = len(h)
ans = 0
for _ in range(nm):
cnt = 0
while True:
if len(h) == 1:
break
if h[0] >= h[1]:
cnt += 1
h.pop(0)
else:
h.pop(0)
break
ans = max(ans, cnt)
print(ans)
|
N = int(eval(input()))
N_List = list(map(int, input().split()))
ans = 0
cans = 0
for i in range(1, N):
if N_List[i] <= N_List[i - 1]:
cans += 1
if cans > ans:
ans = cans
if N_List[i] > N_List[i - 1]:
cans = 0
print(ans)
| false | 23.529412 |
[
"-n = int(eval(input()))",
"-h = list(map(int, input().split()))",
"-nm = len(h)",
"+N = int(eval(input()))",
"+N_List = list(map(int, input().split()))",
"-for _ in range(nm):",
"- cnt = 0",
"- while True:",
"- if len(h) == 1:",
"- break",
"- if h[0] >= h[1]:",
"- cnt += 1",
"- h.pop(0)",
"- else:",
"- h.pop(0)",
"- break",
"- ans = max(ans, cnt)",
"+cans = 0",
"+for i in range(1, N):",
"+ if N_List[i] <= N_List[i - 1]:",
"+ cans += 1",
"+ if cans > ans:",
"+ ans = cans",
"+ if N_List[i] > N_List[i - 1]:",
"+ cans = 0"
] | false | 0.034897 | 0.045117 | 0.773471 |
[
"s953412088",
"s046939956"
] |
u334712262
|
p02564
|
python
|
s966707632
|
s455572965
| 2,015 | 1,725 | 336,604 | 332,788 |
Accepted
|
Accepted
| 14.39 |
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
def scc(V, E):
g = defaultdict(list)
rg = defaultdict(list)
for u, v in E:
g[u].append(v)
rg[v].append(u)
o = []
done = set()
for u in V:
if u in done:
continue
s = [(u, True)]
while s:
u, f = s.pop()
if f:
if u in done:
continue
done.add(u)
s.append((u, False))
for v in g[u]:
if v in done:
continue
s.append((v, True))
else:
o.append(u)
done = set()
ans = []
while o:
u = o.pop()
if u in done:
continue
s = [u]
vv = [u]
done.add(u)
while s:
u = s.pop()
for v in rg[u]:
if v in done:
continue
vv.append(v)
s.append(v)
done.add(v)
ans.append(vv)
return ans
def atcoder_practice2_g():
N, M = list(map(int, input().split()))
E = []
for _ in range(M):
a, b = list(map(int, input().split()))
E.append((a, b))
V = list(range(N))
vv = scc(V, E)
print((len(vv)))
for r in vv:
print((len(r), *r))
def test():
g = {
1: [2],
5: [2],
2: [4, 3],
3: [4, 7, 6],
4: [5, 8],
6: [9],
7: [8],
8: [9],
9: [7, 10],
10: []
}
V = list(range(1, 11))
E = []
for u, e in list(g.items()):
for v in e:
E.append((u, v))
vv = scc(V, E)
for r in vv:
print(r)
if __name__ == "__main__":
# test()
atcoder_practice2_g()
|
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
def scc(V, E):
g = defaultdict(list)
rg = defaultdict(list)
for u, v in E:
g[u].append(v)
rg[v].append(u)
o = []
done = set()
for u in V:
if u in done:
continue
s = [(u, True)]
while s:
u, f = s.pop()
if f:
if u in done:
continue
done.add(u)
s.append((u, False))
for v in g[u]:
if v in done:
continue
s.append((v, True))
else:
o.append(u)
done = set()
ans = []
while o:
u = o.pop()
if u in done:
continue
s = [u]
vv = [u]
done.add(u)
while s:
u = s.pop()
for v in rg[u]:
if v in done:
continue
vv.append(v)
s.append(v)
done.add(v)
ans.append(vv)
return ans
def atcoder_practice2_g():
N, M = list(map(int, input().split()))
E = []
for _ in range(M):
a, b = list(map(int, input().split()))
E.append((a, b))
V = list(range(N))
vv = scc(V, E)
print((len(vv)))
for r in vv:
print((len(r), *r))
def test():
g = {
1: [2],
5: [2],
2: [4, 3],
3: [4, 7, 6],
4: [5, 8],
6: [9],
7: [8],
8: [9],
9: [7, 10],
10: []
}
V = list(range(1, 11))
E = []
for u, e in list(g.items()):
for v in e:
E.append((u, v))
vv = scc(V, E)
for r in vv:
print(r)
if __name__ == "__main__":
# test()
atcoder_practice2_g()
| 100 | 101 | 1,922 | 1,929 |
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
def scc(V, E):
g = defaultdict(list)
rg = defaultdict(list)
for u, v in E:
g[u].append(v)
rg[v].append(u)
o = []
done = set()
for u in V:
if u in done:
continue
s = [(u, True)]
while s:
u, f = s.pop()
if f:
if u in done:
continue
done.add(u)
s.append((u, False))
for v in g[u]:
if v in done:
continue
s.append((v, True))
else:
o.append(u)
done = set()
ans = []
while o:
u = o.pop()
if u in done:
continue
s = [u]
vv = [u]
done.add(u)
while s:
u = s.pop()
for v in rg[u]:
if v in done:
continue
vv.append(v)
s.append(v)
done.add(v)
ans.append(vv)
return ans
def atcoder_practice2_g():
N, M = list(map(int, input().split()))
E = []
for _ in range(M):
a, b = list(map(int, input().split()))
E.append((a, b))
V = list(range(N))
vv = scc(V, E)
print((len(vv)))
for r in vv:
print((len(r), *r))
def test():
g = {
1: [2],
5: [2],
2: [4, 3],
3: [4, 7, 6],
4: [5, 8],
6: [9],
7: [8],
8: [9],
9: [7, 10],
10: [],
}
V = list(range(1, 11))
E = []
for u, e in list(g.items()):
for v in e:
E.append((u, v))
vv = scc(V, E)
for r in vv:
print(r)
if __name__ == "__main__":
# test()
atcoder_practice2_g()
|
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
def scc(V, E):
g = defaultdict(list)
rg = defaultdict(list)
for u, v in E:
g[u].append(v)
rg[v].append(u)
o = []
done = set()
for u in V:
if u in done:
continue
s = [(u, True)]
while s:
u, f = s.pop()
if f:
if u in done:
continue
done.add(u)
s.append((u, False))
for v in g[u]:
if v in done:
continue
s.append((v, True))
else:
o.append(u)
done = set()
ans = []
while o:
u = o.pop()
if u in done:
continue
s = [u]
vv = [u]
done.add(u)
while s:
u = s.pop()
for v in rg[u]:
if v in done:
continue
vv.append(v)
s.append(v)
done.add(v)
ans.append(vv)
return ans
def atcoder_practice2_g():
N, M = list(map(int, input().split()))
E = []
for _ in range(M):
a, b = list(map(int, input().split()))
E.append((a, b))
V = list(range(N))
vv = scc(V, E)
print((len(vv)))
for r in vv:
print((len(r), *r))
def test():
g = {
1: [2],
5: [2],
2: [4, 3],
3: [4, 7, 6],
4: [5, 8],
6: [9],
7: [8],
8: [9],
9: [7, 10],
10: [],
}
V = list(range(1, 11))
E = []
for u, e in list(g.items()):
for v in e:
E.append((u, v))
vv = scc(V, E)
for r in vv:
print(r)
if __name__ == "__main__":
# test()
atcoder_practice2_g()
| false | 0.990099 |
[
"-sys.setrecursionlimit(10**6)",
"+input = sys.stdin.buffer.readline"
] | false | 0.153231 | 0.04392 | 3.488873 |
[
"s966707632",
"s455572965"
] |
u186838327
|
p03361
|
python
|
s476104440
|
s019996859
| 187 | 19 | 41,068 | 3,064 |
Accepted
|
Accepted
| 89.84 |
h, w = list(map(int, input().split()))
l = [0]*(h+2)
l[0] = '.'*(w+2)
l[-1] = '.'*(w+2)
for _ in range(1, h+1):
l[_] = '.' + str(eval(input())) + '.'
for i in range(1, h+1):
for j in range(1, w+1):
if l[i][j] == '.':
continue
else:
if all (l[i+i_][j+j_] == '.' for i_, j_ in ([1, 0], [-1, 0], [0, 1], [0, -1])):
print('No')
exit()
else:
continue
else:
print('Yes')
|
h, w = list(map(int, input().split()))
M = [str(eval(input())) for _ in range(h)]
M = ['.'*w] + M + ['.'*w]
M = ['.'+c+'.' for c in M]
#print(M)
flag = True
for i in range(1, h+1):
for j in range(1, w+1):
if M[i][j] == '#':
for p, q in (-1, 0), (1, 0), (0, 1), (0, -1):
ni = i+p
nj = j+q
if M[ni][nj] == '#':
break
else:
flag = False
if flag:
print('Yes')
else:
print('No')
| 20 | 23 | 429 | 515 |
h, w = list(map(int, input().split()))
l = [0] * (h + 2)
l[0] = "." * (w + 2)
l[-1] = "." * (w + 2)
for _ in range(1, h + 1):
l[_] = "." + str(eval(input())) + "."
for i in range(1, h + 1):
for j in range(1, w + 1):
if l[i][j] == ".":
continue
else:
if all(
l[i + i_][j + j_] == "."
for i_, j_ in ([1, 0], [-1, 0], [0, 1], [0, -1])
):
print("No")
exit()
else:
continue
else:
print("Yes")
|
h, w = list(map(int, input().split()))
M = [str(eval(input())) for _ in range(h)]
M = ["." * w] + M + ["." * w]
M = ["." + c + "." for c in M]
# print(M)
flag = True
for i in range(1, h + 1):
for j in range(1, w + 1):
if M[i][j] == "#":
for p, q in (-1, 0), (1, 0), (0, 1), (0, -1):
ni = i + p
nj = j + q
if M[ni][nj] == "#":
break
else:
flag = False
if flag:
print("Yes")
else:
print("No")
| false | 13.043478 |
[
"-l = [0] * (h + 2)",
"-l[0] = \".\" * (w + 2)",
"-l[-1] = \".\" * (w + 2)",
"-for _ in range(1, h + 1):",
"- l[_] = \".\" + str(eval(input())) + \".\"",
"+M = [str(eval(input())) for _ in range(h)]",
"+M = [\".\" * w] + M + [\".\" * w]",
"+M = [\".\" + c + \".\" for c in M]",
"+# print(M)",
"+flag = True",
"- if l[i][j] == \".\":",
"- continue",
"- else:",
"- if all(",
"- l[i + i_][j + j_] == \".\"",
"- for i_, j_ in ([1, 0], [-1, 0], [0, 1], [0, -1])",
"- ):",
"- print(\"No\")",
"- exit()",
"+ if M[i][j] == \"#\":",
"+ for p, q in (-1, 0), (1, 0), (0, 1), (0, -1):",
"+ ni = i + p",
"+ nj = j + q",
"+ if M[ni][nj] == \"#\":",
"+ break",
"- continue",
"+ flag = False",
"+if flag:",
"+ print(\"Yes\")",
"- print(\"Yes\")",
"+ print(\"No\")"
] | false | 0.044959 | 0.091112 | 0.493448 |
[
"s476104440",
"s019996859"
] |
u476604182
|
p02883
|
python
|
s568520716
|
s689839979
| 629 | 565 | 119,500 | 43,540 |
Accepted
|
Accepted
| 10.17 |
N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
M = 0
for i in range(N):
if A[i]*F[i]>M:
M = A[i]*F[i]
l = -1
r = M+1
while l+1<r:
s = (l+r)//2
cnt = 0
for i in range(N):
b = s//F[i]
cnt += max(0, A[i]-b)
if cnt>K:
l = s
else:
r = s
print(r)
|
import numpy as np
N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)
Asum = A.sum()
M = np.max(A*F)
l = -1
r = M+1
while l+1<r:
s = (l+r)//2
cnt = Asum - np.minimum(A, s//F).sum()
if cnt>K:
l = s
else:
r = s
print(r)
| 24 | 22 | 390 | 376 |
N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
M = 0
for i in range(N):
if A[i] * F[i] > M:
M = A[i] * F[i]
l = -1
r = M + 1
while l + 1 < r:
s = (l + r) // 2
cnt = 0
for i in range(N):
b = s // F[i]
cnt += max(0, A[i] - b)
if cnt > K:
l = s
else:
r = s
print(r)
|
import numpy as np
N, K = list(map(int, input().split()))
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)
Asum = A.sum()
M = np.max(A * F)
l = -1
r = M + 1
while l + 1 < r:
s = (l + r) // 2
cnt = Asum - np.minimum(A, s // F).sum()
if cnt > K:
l = s
else:
r = s
print(r)
| false | 8.333333 |
[
"+import numpy as np",
"+",
"-M = 0",
"-for i in range(N):",
"- if A[i] * F[i] > M:",
"- M = A[i] * F[i]",
"+A = np.array(A)",
"+F = np.array(F)",
"+Asum = A.sum()",
"+M = np.max(A * F)",
"- cnt = 0",
"- for i in range(N):",
"- b = s // F[i]",
"- cnt += max(0, A[i] - b)",
"+ cnt = Asum - np.minimum(A, s // F).sum()"
] | false | 0.007956 | 0.513522 | 0.015494 |
[
"s568520716",
"s689839979"
] |
u887207211
|
p03162
|
python
|
s367236386
|
s016996042
| 430 | 388 | 24,308 | 3,060 |
Accepted
|
Accepted
| 9.77 |
N = int(eval(input()))
A = [[int(i) for i in input().split()] for _ in range(N)]
x = y = z = 0
for a, b, c in A:
x, y, z = max(y, z)+a, max(x,z)+b, max(x,y)+c
print((max(x, y, z)))
|
N = int(eval(input()))
x = y = z = 0
for _ in range(N):
a, b, c = list(map(int,input().split()))
x, y, z = max(y, z)+a, max(x,z)+b, max(x,y)+c
print((max(x, y, z)))
| 7 | 7 | 181 | 161 |
N = int(eval(input()))
A = [[int(i) for i in input().split()] for _ in range(N)]
x = y = z = 0
for a, b, c in A:
x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c
print((max(x, y, z)))
|
N = int(eval(input()))
x = y = z = 0
for _ in range(N):
a, b, c = list(map(int, input().split()))
x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c
print((max(x, y, z)))
| false | 0 |
[
"-A = [[int(i) for i in input().split()] for _ in range(N)]",
"-for a, b, c in A:",
"+for _ in range(N):",
"+ a, b, c = list(map(int, input().split()))"
] | false | 0.114446 | 0.044484 | 2.572767 |
[
"s367236386",
"s016996042"
] |
u411203878
|
p02612
|
python
|
s499305315
|
s194732060
| 76 | 68 | 61,536 | 61,852 |
Accepted
|
Accepted
| 10.53 |
n=int(eval(input()))
if n%1000 == 0:
print((0))
else:
print((1000-n%1000))
|
n = int(eval(input()))
amari = n%1000
if amari == 0:
print((0))
else:
print((1000-amari))
| 6 | 8 | 79 | 97 |
n = int(eval(input()))
if n % 1000 == 0:
print((0))
else:
print((1000 - n % 1000))
|
n = int(eval(input()))
amari = n % 1000
if amari == 0:
print((0))
else:
print((1000 - amari))
| false | 25 |
[
"-if n % 1000 == 0:",
"+amari = n % 1000",
"+if amari == 0:",
"- print((1000 - n % 1000))",
"+ print((1000 - amari))"
] | false | 0.051727 | 0.051141 | 1.011473 |
[
"s499305315",
"s194732060"
] |
u638795007
|
p03162
|
python
|
s162601833
|
s360792306
| 636 | 369 | 36,172 | 35,164 |
Accepted
|
Accepted
| 41.98 |
N = int(eval(input()))
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
a[i],b[i],c[i] = list(map(int,input().split()))
dp = [[int(0) for i in range(3)] for i in range(N)]
ans = int(0)
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1,N):
dp[i][0] = max(a[i]+dp[i-1][1], a[i]+dp[i-1][2])
dp[i][1] = max(b[i]+dp[i-1][0], b[i]+dp[i-1][2])
dp[i][2] = max(c[i]+dp[i-1][0], c[i]+dp[i-1][1])
ans = max(dp[N-1])
print(ans)
|
def examA():
N = I()
H = LI()
dp = [inf]*(N)
dp[0] = 0
for i in range(N-1):
dp[i+1] = min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
if i<N-2:
dp[i + 2] = min(dp[i + 2], dp[i]+abs(H[i + 2] - H[i]))
ans = dp[-1]
print(ans)
return
def examB():
N, K = LI()
H = LI()
dp = [inf]*N
dp[0] = 0
for i in range(N):
for k in range(1,K+1):
if i+k>=N:
break
if dp[i+k]>dp[i]+abs(H[i+k]-H[i]):
dp[i+k] = dp[i]+abs(H[i+k]-H[i])
ans = dp[-1]
print(ans)
return
def examC():
N = I()
A = [0]*N; B = [0]*N; C = [0]*N
for i in range(N):
A[i],B[i],C[i] = LI()
dp = [[0]*3 for _ in range(N+1)]
for i in range(N):
dp[i+1][0] = max(dp[i][1],dp[i][2]) + A[i]
dp[i + 1][1] = max(dp[i][0], dp[i][2]) + B[i]
dp[i + 1][2] = max(dp[i][1], dp[i][0]) + C[i]
ans = max(dp[N])
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]
if __name__ == '__main__':
examC()
"""
"""
| 21 | 77 | 458 | 1,772 |
N = int(eval(input()))
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
a[i], b[i], c[i] = list(map(int, input().split()))
dp = [[int(0) for i in range(3)] for i in range(N)]
ans = int(0)
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1, N):
dp[i][0] = max(a[i] + dp[i - 1][1], a[i] + dp[i - 1][2])
dp[i][1] = max(b[i] + dp[i - 1][0], b[i] + dp[i - 1][2])
dp[i][2] = max(c[i] + dp[i - 1][0], c[i] + dp[i - 1][1])
ans = max(dp[N - 1])
print(ans)
|
def examA():
N = I()
H = LI()
dp = [inf] * (N)
dp[0] = 0
for i in range(N - 1):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))
if i < N - 2:
dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))
ans = dp[-1]
print(ans)
return
def examB():
N, K = LI()
H = LI()
dp = [inf] * N
dp[0] = 0
for i in range(N):
for k in range(1, K + 1):
if i + k >= N:
break
if dp[i + k] > dp[i] + abs(H[i + k] - H[i]):
dp[i + k] = dp[i] + abs(H[i + k] - H[i])
ans = dp[-1]
print(ans)
return
def examC():
N = I()
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
A[i], B[i], C[i] = LI()
dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
dp[i + 1][0] = max(dp[i][1], dp[i][2]) + A[i]
dp[i + 1][1] = max(dp[i][0], dp[i][2]) + B[i]
dp[i + 1][2] = max(dp[i][1], dp[i][0]) + C[i]
ans = max(dp[N])
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord("a") + i) for i in range(26)]
if __name__ == "__main__":
examC()
"""
"""
| false | 72.727273 |
[
"-N = int(eval(input()))",
"-a = [0] * N",
"-b = [0] * N",
"-c = [0] * N",
"-for i in range(N):",
"- a[i], b[i], c[i] = list(map(int, input().split()))",
"-dp = [[int(0) for i in range(3)] for i in range(N)]",
"-ans = int(0)",
"-dp[0][0] = a[0]",
"-dp[0][1] = b[0]",
"-dp[0][2] = c[0]",
"-for i in range(1, N):",
"- dp[i][0] = max(a[i] + dp[i - 1][1], a[i] + dp[i - 1][2])",
"- dp[i][1] = max(b[i] + dp[i - 1][0], b[i] + dp[i - 1][2])",
"- dp[i][2] = max(c[i] + dp[i - 1][0], c[i] + dp[i - 1][1])",
"-ans = max(dp[N - 1])",
"-print(ans)",
"+def examA():",
"+ N = I()",
"+ H = LI()",
"+ dp = [inf] * (N)",
"+ dp[0] = 0",
"+ for i in range(N - 1):",
"+ dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))",
"+ if i < N - 2:",
"+ dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))",
"+ ans = dp[-1]",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examB():",
"+ N, K = LI()",
"+ H = LI()",
"+ dp = [inf] * N",
"+ dp[0] = 0",
"+ for i in range(N):",
"+ for k in range(1, K + 1):",
"+ if i + k >= N:",
"+ break",
"+ if dp[i + k] > dp[i] + abs(H[i + k] - H[i]):",
"+ dp[i + k] = dp[i] + abs(H[i + k] - H[i])",
"+ ans = dp[-1]",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examC():",
"+ N = I()",
"+ A = [0] * N",
"+ B = [0] * N",
"+ C = [0] * N",
"+ for i in range(N):",
"+ A[i], B[i], C[i] = LI()",
"+ dp = [[0] * 3 for _ in range(N + 1)]",
"+ for i in range(N):",
"+ dp[i + 1][0] = max(dp[i][1], dp[i][2]) + A[i]",
"+ dp[i + 1][1] = max(dp[i][0], dp[i][2]) + B[i]",
"+ dp[i + 1][2] = max(dp[i][1], dp[i][0]) + C[i]",
"+ ans = max(dp[N])",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examD():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examE():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examF():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+import sys, copy, bisect, itertools, heapq, math",
"+from heapq import heappop, heappush, heapify",
"+from collections import Counter, defaultdict, deque",
"+",
"+",
"+def I():",
"+ return int(sys.stdin.readline())",
"+",
"+",
"+def LI():",
"+ return list(map(int, sys.stdin.readline().split()))",
"+",
"+",
"+def LSI():",
"+ return list(map(str, sys.stdin.readline().split()))",
"+",
"+",
"+def LS():",
"+ return sys.stdin.readline().split()",
"+",
"+",
"+def SI():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+global mod, mod2, inf, alphabet",
"+mod = 10**9 + 7",
"+mod2 = 998244353",
"+inf = 10**18",
"+alphabet = [chr(ord(\"a\") + i) for i in range(26)]",
"+if __name__ == \"__main__\":",
"+ examC()",
"+\"\"\"",
"+\"\"\""
] | false | 0.066264 | 0.047494 | 1.395206 |
[
"s162601833",
"s360792306"
] |
u504562455
|
p03353
|
python
|
s271626077
|
s002461105
| 49 | 44 | 3,188 | 3,188 |
Accepted
|
Accepted
| 10.2 |
s = eval(input())
k = int(eval(input()))
a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97+26
for m in b:
a1 = [i for i in range(len(s)) if a[i] == m]
for i in a1:
j = 0
for j in range(k):
if s[i:i+j+1] not in c:
c.append(s[i:i+j+1])
c.sort()
if len(c) > 5:
del c[-1]
j += 1
if i + j >= len(s):
break
if len(c) >= k:
break
print((c[k-1]))
|
s = eval(input())
k = int(eval(input()))
a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97+26
for m in b:
a1 = [i for i in range(len(s)) if a[i] == m]
for i in a1:
j = 0
for j in range(k):
if i + j >= len(s):
break
if s[i:i+j+1] not in c:
c.append(s[i:i+j+1])
c.sort()
if len(c) > 5:
del c[-1]
if len(c) >= k:
break
print((c[k-1]))
| 26 | 26 | 522 | 504 |
s = eval(input())
k = int(eval(input()))
a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97 + 26
for m in b:
a1 = [i for i in range(len(s)) if a[i] == m]
for i in a1:
j = 0
for j in range(k):
if s[i : i + j + 1] not in c:
c.append(s[i : i + j + 1])
c.sort()
if len(c) > 5:
del c[-1]
j += 1
if i + j >= len(s):
break
if len(c) >= k:
break
print((c[k - 1]))
|
s = eval(input())
k = int(eval(input()))
a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97 + 26
for m in b:
a1 = [i for i in range(len(s)) if a[i] == m]
for i in a1:
j = 0
for j in range(k):
if i + j >= len(s):
break
if s[i : i + j + 1] not in c:
c.append(s[i : i + j + 1])
c.sort()
if len(c) > 5:
del c[-1]
if len(c) >= k:
break
print((c[k - 1]))
| false | 0 |
[
"+ if i + j >= len(s):",
"+ break",
"- j += 1",
"- if i + j >= len(s):",
"- break"
] | false | 0.0449 | 0.140542 | 0.319479 |
[
"s271626077",
"s002461105"
] |
u919633157
|
p03448
|
python
|
s813739686
|
s568911922
| 56 | 19 | 2,940 | 3,188 |
Accepted
|
Accepted
| 66.07 |
a,b,c,x=list(map(int,open(0).read().split()))
cnt=0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
sum=500*i+100*j+50*k
if sum==x :
cnt+=1
print(cnt)
|
a,b,c,x=[int(eval(input())) for _ in range(4)]
cnt=0
for i in range(a+1):
total=0
for j in range(b+1):
k=(x-(500*i+100*j))//50
if k<=c and k>=0 :
total=500*i+100*j+50*k
if total==x:cnt+=1
print(cnt)
| 9 | 10 | 219 | 250 |
a, b, c, x = list(map(int, open(0).read().split()))
cnt = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
sum = 500 * i + 100 * j + 50 * k
if sum == x:
cnt += 1
print(cnt)
|
a, b, c, x = [int(eval(input())) for _ in range(4)]
cnt = 0
for i in range(a + 1):
total = 0
for j in range(b + 1):
k = (x - (500 * i + 100 * j)) // 50
if k <= c and k >= 0:
total = 500 * i + 100 * j + 50 * k
if total == x:
cnt += 1
print(cnt)
| false | 10 |
[
"-a, b, c, x = list(map(int, open(0).read().split()))",
"+a, b, c, x = [int(eval(input())) for _ in range(4)]",
"+ total = 0",
"- for k in range(c + 1):",
"- sum = 500 * i + 100 * j + 50 * k",
"- if sum == x:",
"+ k = (x - (500 * i + 100 * j)) // 50",
"+ if k <= c and k >= 0:",
"+ total = 500 * i + 100 * j + 50 * k",
"+ if total == x:"
] | false | 0.142445 | 0.041945 | 3.395972 |
[
"s813739686",
"s568911922"
] |
u052332717
|
p04011
|
python
|
s859618710
|
s241539364
| 23 | 18 | 3,444 | 2,940 |
Accepted
|
Accepted
| 21.74 |
days_to_stay = int(eval(input()))
special_days = int(eval(input()))
normal_price = int(eval(input()))
special_price = int(eval(input()))
payment = 0
if days_to_stay <= special_days:
payment = days_to_stay * normal_price
else:
payment = (days_to_stay - special_days) * special_price + special_days * normal_price
print(payment)
|
n = int(eval(input()))
k = int(eval(input()))
x = int(eval(input()))
y = int(eval(input()))
print((min(n,k)*x + max(0,n-k)*y))
| 12 | 5 | 328 | 104 |
days_to_stay = int(eval(input()))
special_days = int(eval(input()))
normal_price = int(eval(input()))
special_price = int(eval(input()))
payment = 0
if days_to_stay <= special_days:
payment = days_to_stay * normal_price
else:
payment = (
days_to_stay - special_days
) * special_price + special_days * normal_price
print(payment)
|
n = int(eval(input()))
k = int(eval(input()))
x = int(eval(input()))
y = int(eval(input()))
print((min(n, k) * x + max(0, n - k) * y))
| false | 58.333333 |
[
"-days_to_stay = int(eval(input()))",
"-special_days = int(eval(input()))",
"-normal_price = int(eval(input()))",
"-special_price = int(eval(input()))",
"-payment = 0",
"-if days_to_stay <= special_days:",
"- payment = days_to_stay * normal_price",
"-else:",
"- payment = (",
"- days_to_stay - special_days",
"- ) * special_price + special_days * normal_price",
"-print(payment)",
"+n = int(eval(input()))",
"+k = int(eval(input()))",
"+x = int(eval(input()))",
"+y = int(eval(input()))",
"+print((min(n, k) * x + max(0, n - k) * y))"
] | false | 0.042262 | 0.035843 | 1.179096 |
[
"s859618710",
"s241539364"
] |
u134302690
|
p03147
|
python
|
s897108447
|
s711584927
| 25 | 21 | 3,060 | 3,060 |
Accepted
|
Accepted
| 16 |
N = int(eval(input()))
h = list(map(int,input().split()))
count = 0
i = 0
while sum(h) > 0:
if h[i] > 0:
j = i
count += 1
while j < N and h[j] > 0:
h[j] = h[j] - 1
j += 1
else:
i += 1
print(count)
|
N = int(eval(input()))
h = list(map(int, input().split()))
cnt = 0
i = 0
for _ in range(100 * 100):
if h[i] > 0:
j = i
cnt += 1
while j < N and h[j] > 0:
h[j] = h[j] - 1
j += 1
else:
i += 1
if i == N:
break
print(cnt)
| 14 | 16 | 267 | 310 |
N = int(eval(input()))
h = list(map(int, input().split()))
count = 0
i = 0
while sum(h) > 0:
if h[i] > 0:
j = i
count += 1
while j < N and h[j] > 0:
h[j] = h[j] - 1
j += 1
else:
i += 1
print(count)
|
N = int(eval(input()))
h = list(map(int, input().split()))
cnt = 0
i = 0
for _ in range(100 * 100):
if h[i] > 0:
j = i
cnt += 1
while j < N and h[j] > 0:
h[j] = h[j] - 1
j += 1
else:
i += 1
if i == N:
break
print(cnt)
| false | 12.5 |
[
"-count = 0",
"+cnt = 0",
"-while sum(h) > 0:",
"+for _ in range(100 * 100):",
"- count += 1",
"+ cnt += 1",
"-print(count)",
"+ if i == N:",
"+ break",
"+print(cnt)"
] | false | 0.033353 | 0.079793 | 0.417994 |
[
"s897108447",
"s711584927"
] |
u496148227
|
p03339
|
python
|
s534441784
|
s630167037
| 191 | 171 | 21,200 | 15,564 |
Accepted
|
Accepted
| 10.47 |
N = int(eval(input()))
S = [d for d in eval(input())]
tot = S[1:].count('E')
tot_list = [tot]
former_leader = S[0]
for l in range(1, N):
leader = S[l]
if (former_leader, leader) == ('E', 'E'):
tot -= 1
if (former_leader, leader) == ('W', 'W'):
tot += 1
former_leader = leader
tot_list.append(tot)
print((min(tot_list)))
|
N = int(eval(input()))
S = eval(input())
tot = S[1:].count('E')
tot_list = [tot]
former_leader = S[0]
for l in range(1, N):
leader = S[l]
if (former_leader, leader) == ('E', 'E'):
tot -= 1
if (former_leader, leader) == ('W', 'W'):
tot += 1
former_leader = leader
tot_list.append(tot)
print((min(tot_list)))
| 18 | 18 | 378 | 365 |
N = int(eval(input()))
S = [d for d in eval(input())]
tot = S[1:].count("E")
tot_list = [tot]
former_leader = S[0]
for l in range(1, N):
leader = S[l]
if (former_leader, leader) == ("E", "E"):
tot -= 1
if (former_leader, leader) == ("W", "W"):
tot += 1
former_leader = leader
tot_list.append(tot)
print((min(tot_list)))
|
N = int(eval(input()))
S = eval(input())
tot = S[1:].count("E")
tot_list = [tot]
former_leader = S[0]
for l in range(1, N):
leader = S[l]
if (former_leader, leader) == ("E", "E"):
tot -= 1
if (former_leader, leader) == ("W", "W"):
tot += 1
former_leader = leader
tot_list.append(tot)
print((min(tot_list)))
| false | 0 |
[
"-S = [d for d in eval(input())]",
"+S = eval(input())"
] | false | 0.078718 | 0.048492 | 1.623329 |
[
"s534441784",
"s630167037"
] |
u992910889
|
p03627
|
python
|
s676586696
|
s958863838
| 267 | 243 | 69,912 | 64,896 |
Accepted
|
Accepted
| 8.99 |
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
def resolve():
N=int(eval(input()))
A=sorted(list(map(int,input().split())),reverse=True)
temp=-1
maxans=0
AA=Counter(A)
for (i,j) in list(AA.items()):
if j>=4:
maxans=max(i**2,maxans)
if j>=2:
if temp>=0:
maxans=max(maxans,temp*i)
temp=max(i,temp)
print(maxans)
resolve()
|
from collections import Counter, deque, OrderedDict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np # Pythonのみ!
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components # Pythonのみ!
# ↑cf. https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
A = Counter(A)
ans=[0,0]
for k,v in list(A.items()):
if v>=2:
ans.append(k)
if v>=4:
ans.append(k)
ans.sort()
print((ans[-1]*ans[-2]))
resolve()
| 33 | 35 | 792 | 988 |
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10**5 + 10)
# input = sys.stdin.readline
def resolve():
N = int(eval(input()))
A = sorted(list(map(int, input().split())), reverse=True)
temp = -1
maxans = 0
AA = Counter(A)
for (i, j) in list(AA.items()):
if j >= 4:
maxans = max(i**2, maxans)
if j >= 2:
if temp >= 0:
maxans = max(maxans, temp * i)
temp = max(i, temp)
print(maxans)
resolve()
|
from collections import Counter, deque, OrderedDict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np # Pythonのみ!
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components # Pythonのみ!
# ↑cf. https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10**5 + 10)
def input():
return sys.stdin.readline().strip()
def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
A = Counter(A)
ans = [0, 0]
for k, v in list(A.items()):
if v >= 2:
ans.append(k)
if v >= 4:
ans.append(k)
ans.sort()
print((ans[-1] * ans[-2]))
resolve()
| false | 5.714286 |
[
"-# import bisect",
"-from collections import Counter, deque",
"+from collections import Counter, deque, OrderedDict",
"-# from fractions import gcd",
"+# from heapq import heapify, heappop, heappush",
"-# import numpy as np",
"+# import numpy as np # Pythonのみ!",
"+# import re",
"+# from scipy.sparse.csgraph import connected_components # Pythonのみ!",
"+# ↑cf. https://note.nkmk.me/python-scipy-connected-components/",
"+# from scipy.sparse import csr_matrix",
"+# import statistics # Pythonのみ",
"+# import string",
"-# input = sys.stdin.readline",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"- A = sorted(list(map(int, input().split())), reverse=True)",
"- temp = -1",
"- maxans = 0",
"- AA = Counter(A)",
"- for (i, j) in list(AA.items()):",
"- if j >= 4:",
"- maxans = max(i**2, maxans)",
"- if j >= 2:",
"- if temp >= 0:",
"- maxans = max(maxans, temp * i)",
"- temp = max(i, temp)",
"- print(maxans)",
"+ A = list(map(int, input().split()))",
"+ A = Counter(A)",
"+ ans = [0, 0]",
"+ for k, v in list(A.items()):",
"+ if v >= 2:",
"+ ans.append(k)",
"+ if v >= 4:",
"+ ans.append(k)",
"+ ans.sort()",
"+ print((ans[-1] * ans[-2]))"
] | false | 0.084117 | 0.040097 | 2.09782 |
[
"s676586696",
"s958863838"
] |
u583507988
|
p03435
|
python
|
s279798140
|
s319959374
| 33 | 29 | 9,220 | 9,196 |
Accepted
|
Accepted
| 12.12 |
c = [list(map(int, input().split())) for _ in range(3)]
if 2*c[0][2]-c[1][2]-c[2][2]+c[1][0]+c[2][0] == 2*c[0][0]:
if 2*c[1][0]-c[2][0]-c[0][0]+c[2][1]+c[0][1] == 2*c[1][1]:
if 2*c[2][1]-c[0][1]-c[1][1]+c[0][2]+c[1][2] == 2*c[2][2]:
print('Yes')
else:
print('No')
else:
print('No')
else:
print('No')
|
c = []
for i in range(3):
c_ = list(map(int, input().split()))
c.append(c_)
if c[2][2] == c[0][2] + c[2][0] -c[0][0] and c[2][2] == c[1][2] + c[2][1] -c[1][1] and c[1][1] == c[0][1] + c[1][0] -c[0][0]:
print('Yes')
else:
print('No')
| 11 | 9 | 339 | 251 |
c = [list(map(int, input().split())) for _ in range(3)]
if 2 * c[0][2] - c[1][2] - c[2][2] + c[1][0] + c[2][0] == 2 * c[0][0]:
if 2 * c[1][0] - c[2][0] - c[0][0] + c[2][1] + c[0][1] == 2 * c[1][1]:
if 2 * c[2][1] - c[0][1] - c[1][1] + c[0][2] + c[1][2] == 2 * c[2][2]:
print("Yes")
else:
print("No")
else:
print("No")
else:
print("No")
|
c = []
for i in range(3):
c_ = list(map(int, input().split()))
c.append(c_)
if (
c[2][2] == c[0][2] + c[2][0] - c[0][0]
and c[2][2] == c[1][2] + c[2][1] - c[1][1]
and c[1][1] == c[0][1] + c[1][0] - c[0][0]
):
print("Yes")
else:
print("No")
| false | 18.181818 |
[
"-c = [list(map(int, input().split())) for _ in range(3)]",
"-if 2 * c[0][2] - c[1][2] - c[2][2] + c[1][0] + c[2][0] == 2 * c[0][0]:",
"- if 2 * c[1][0] - c[2][0] - c[0][0] + c[2][1] + c[0][1] == 2 * c[1][1]:",
"- if 2 * c[2][1] - c[0][1] - c[1][1] + c[0][2] + c[1][2] == 2 * c[2][2]:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"- else:",
"- print(\"No\")",
"+c = []",
"+for i in range(3):",
"+ c_ = list(map(int, input().split()))",
"+ c.append(c_)",
"+if (",
"+ c[2][2] == c[0][2] + c[2][0] - c[0][0]",
"+ and c[2][2] == c[1][2] + c[2][1] - c[1][1]",
"+ and c[1][1] == c[0][1] + c[1][0] - c[0][0]",
"+):",
"+ print(\"Yes\")"
] | false | 0.083198 | 0.041331 | 2.012968 |
[
"s279798140",
"s319959374"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.