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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u244459371
|
p03112
|
python
|
s065029715
|
s678096319
| 1,494
| 761
| 90,584
| 69,084
|
Accepted
|
Accepted
| 49.06
|
from bisect import bisect_left, bisect_right
a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
q = [int(eval(input())) for _ in range(q)]
for qi in q:
qans = 10**18
ai = bisect_left(s, qi)
bi = bisect_left(t, qi)
ac = []
bc = []
for i in range(2):
if (0 <= ai + i < a):
ac.append(ai + i);
if (0 <= ai - i < a):
ac.append(ai - i);
for i in range(2):
if (0 <= bi + i < b):
bc.append(bi + i);
if (0 <= bi - i < b):
bc.append(bi - i);
for i in ac:
for j in bc:
aa = s[i];
bb = t[j];
if (max(aa, bb) <= qi):
qans = min(qans, qi - min(aa, bb))
elif (qi <= min(aa, bb)):
qans = min(qans, max(aa, bb) - qi)
else:
qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
print(qans)
|
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
q = [int(eval(input())) for _ in range(q)]
for qi in q:
qans = 10**18
ai = bisect_left(s, qi)
bi = bisect_left(t, qi)
ac = []
bc = []
for i in range(2):
if (0 <= ai + i < a):
ac.append(ai + i);
if (0 <= ai - i < a):
ac.append(ai - i);
for i in range(2):
if (0 <= bi + i < b):
bc.append(bi + i);
if (0 <= bi - i < b):
bc.append(bi - i);
for i in ac:
for j in bc:
aa = s[i];
bb = t[j];
if (max(aa, bb) <= qi):
qans = min(qans, qi - min(aa, bb))
elif (qi <= min(aa, bb)):
qans = min(qans, max(aa, bb) - qi)
else:
qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
print(qans)
| 32
| 34
| 1,022
| 1,062
|
from bisect import bisect_left, bisect_right
a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
q = [int(eval(input())) for _ in range(q)]
for qi in q:
qans = 10**18
ai = bisect_left(s, qi)
bi = bisect_left(t, qi)
ac = []
bc = []
for i in range(2):
if 0 <= ai + i < a:
ac.append(ai + i)
if 0 <= ai - i < a:
ac.append(ai - i)
for i in range(2):
if 0 <= bi + i < b:
bc.append(bi + i)
if 0 <= bi - i < b:
bc.append(bi - i)
for i in ac:
for j in bc:
aa = s[i]
bb = t[j]
if max(aa, bb) <= qi:
qans = min(qans, qi - min(aa, bb))
elif qi <= min(aa, bb):
qans = min(qans, max(aa, bb) - qi)
else:
qans = min(
qans,
min(abs(aa - qi), abs(bb - qi)) * 2
+ max(abs(aa - qi), abs(bb - qi)),
)
print(qans)
|
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
q = [int(eval(input())) for _ in range(q)]
for qi in q:
qans = 10**18
ai = bisect_left(s, qi)
bi = bisect_left(t, qi)
ac = []
bc = []
for i in range(2):
if 0 <= ai + i < a:
ac.append(ai + i)
if 0 <= ai - i < a:
ac.append(ai - i)
for i in range(2):
if 0 <= bi + i < b:
bc.append(bi + i)
if 0 <= bi - i < b:
bc.append(bi - i)
for i in ac:
for j in bc:
aa = s[i]
bb = t[j]
if max(aa, bb) <= qi:
qans = min(qans, qi - min(aa, bb))
elif qi <= min(aa, bb):
qans = min(qans, max(aa, bb) - qi)
else:
qans = min(
qans,
min(abs(aa - qi), abs(bb - qi)) * 2
+ max(abs(aa - qi), abs(bb - qi)),
)
print(qans)
| false
| 5.882353
|
[
"+import sys",
"+input = sys.stdin.readline"
] | false
| 0.036044
| 0.036464
| 0.988467
|
[
"s065029715",
"s678096319"
] |
u215286521
|
p02700
|
python
|
s144829882
|
s654938019
| 98
| 23
| 26,988
| 9,556
|
Accepted
|
Accepted
| 76.53
|
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return eval(input())
def I(): return int(eval(input()))
def MS(): return list(map(str,input().split()))
def MI(): return list(map(int,input().split()))
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in eval(input())]
def LLI(): return [list(map(int, l.split() )) for l in eval(input())]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
A,B,C,D = MI()
t = A
a = C
for i in range(100):
a -= B
if a <= 0:
print("Yes")
exit()
t -= D
if t <= 0:
print("No")
exit()
|
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
# import numpy as np
def S(): return eval(input())
def I(): return int(eval(input()))
def MS(): return list(map(str,input().split()))
def MI(): return list(map(int,input().split()))
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in eval(input())]
def LLI(): return [list(map(int, l.split() )) for l in eval(input())]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
A,B,C,D = MI()
x = -(-A//D)
y = -(-C//B)
if x >= y:
print("Yes")
else:
print("No")
# for i in range(100):
# a -= B
# if a <= 0:
# print("Yes")
# exit()
# t -= D
# if t <= 0:
# print("No")
# exit()
| 31
| 36
| 816
| 906
|
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S():
return eval(input())
def I():
return int(eval(input()))
def MS():
return list(map(str, input().split()))
def MI():
return list(map(int, input().split()))
def FLI():
return [int(i) for i in input().split()]
def LS():
return list(MS())
def LI():
return list(MI())
def LLS():
return [list(map(str, l.split())) for l in eval(input())]
def LLI():
return [list(map(int, l.split())) for l in eval(input())]
def LLSN(n: int):
return [LS() for _ in range(n)]
def LLIN(n: int):
return [LI() for _ in range(n)]
A, B, C, D = MI()
t = A
a = C
for i in range(100):
a -= B
if a <= 0:
print("Yes")
exit()
t -= D
if t <= 0:
print("No")
exit()
|
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, deque
from functools import reduce
# import numpy as np
def S():
return eval(input())
def I():
return int(eval(input()))
def MS():
return list(map(str, input().split()))
def MI():
return list(map(int, input().split()))
def FLI():
return [int(i) for i in input().split()]
def LS():
return list(MS())
def LI():
return list(MI())
def LLS():
return [list(map(str, l.split())) for l in eval(input())]
def LLI():
return [list(map(int, l.split())) for l in eval(input())]
def LLSN(n: int):
return [LS() for _ in range(n)]
def LLIN(n: int):
return [LI() for _ in range(n)]
A, B, C, D = MI()
x = -(-A // D)
y = -(-C // B)
if x >= y:
print("Yes")
else:
print("No")
# for i in range(100):
# a -= B
# if a <= 0:
# print("Yes")
# exit()
# t -= D
# if t <= 0:
# print("No")
# exit()
| false
| 13.888889
|
[
"-import numpy as np",
"-",
"+# import numpy as np",
"-t = A",
"-a = C",
"-for i in range(100):",
"- a -= B",
"- if a <= 0:",
"- print(\"Yes\")",
"- exit()",
"- t -= D",
"- if t <= 0:",
"- print(\"No\")",
"- exit()",
"+x = -(-A // D)",
"+y = -(-C // B)",
"+if x >= y:",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")",
"+# for i in range(100):",
"+# a -= B",
"+# if a <= 0:",
"+# print(\"Yes\")",
"+# exit()",
"+# t -= D",
"+# if t <= 0:",
"+# print(\"No\")",
"+# exit()"
] | false
| 0.110119
| 0.034819
| 3.162571
|
[
"s144829882",
"s654938019"
] |
u123756661
|
p03999
|
python
|
s417952502
|
s003384804
| 43
| 20
| 2,692
| 3,060
|
Accepted
|
Accepted
| 53.49
|
s=input()
t=len(s)-1
tmp=2**t
ans=0
for i in range(tmp):
p=bin(i)[2:]
p='0'*(t-len(p))+p
x=''
for j,k in enumerate(s):
x+=k
if j!=t and p[j]=='1':
x+='+'
ans+=eval(x)
print(ans)
|
#!/usr/bin/env python3
s=eval(input())
ans=tmp=0
t=len(s)
for i in range(1<<(t-1)):
# print(i)
tmp=int(s[0])
for j in range(t-1):
if (i & (1<<j)):
tmp*=10
tmp+=int(s[j+1])
else:
ans+=tmp
tmp=int(s[j+1])
ans+=tmp
print(ans)
| 14
| 19
| 241
| 316
|
s = input()
t = len(s) - 1
tmp = 2**t
ans = 0
for i in range(tmp):
p = bin(i)[2:]
p = "0" * (t - len(p)) + p
x = ""
for j, k in enumerate(s):
x += k
if j != t and p[j] == "1":
x += "+"
ans += eval(x)
print(ans)
|
#!/usr/bin/env python3
s = eval(input())
ans = tmp = 0
t = len(s)
for i in range(1 << (t - 1)):
# print(i)
tmp = int(s[0])
for j in range(t - 1):
if i & (1 << j):
tmp *= 10
tmp += int(s[j + 1])
else:
ans += tmp
tmp = int(s[j + 1])
ans += tmp
print(ans)
| false
| 26.315789
|
[
"-s = input()",
"-t = len(s) - 1",
"-tmp = 2**t",
"-ans = 0",
"-for i in range(tmp):",
"- p = bin(i)[2:]",
"- p = \"0\" * (t - len(p)) + p",
"- x = \"\"",
"- for j, k in enumerate(s):",
"- x += k",
"- if j != t and p[j] == \"1\":",
"- x += \"+\"",
"- ans += eval(x)",
"+#!/usr/bin/env python3",
"+s = eval(input())",
"+ans = tmp = 0",
"+t = len(s)",
"+for i in range(1 << (t - 1)):",
"+ # print(i)",
"+ tmp = int(s[0])",
"+ for j in range(t - 1):",
"+ if i & (1 << j):",
"+ tmp *= 10",
"+ tmp += int(s[j + 1])",
"+ else:",
"+ ans += tmp",
"+ tmp = int(s[j + 1])",
"+ ans += tmp"
] | false
| 0.040534
| 0.077803
| 0.520977
|
[
"s417952502",
"s003384804"
] |
u729133443
|
p03088
|
python
|
s968410757
|
s869707114
| 308
| 70
| 52,700
| 3,316
|
Accepted
|
Accepted
| 77.27
|
n=int(eval(input()))
A,C,G,T,M=0,1,2,3,10**9+7
r=range
dp=[[[[0]*4for k in r(4)]for j in r(4)]for i in r(n+1)]
dp[0][T][T][T]=1
for i in r(1,n+1):
for j in r(4):
for k in r(4):
for l in r(4):
for m in r(4):
if any(t==(k,l,m)for t in((A,G,C),(A,C,G),(G,A,C)))or(j,l,m)==(A,G,C)or(j,k,m)==(A,G,C):continue
dp[i][k][l][m]=(dp[i][k][l][m]+dp[i-1][j][k][l])%M
print((sum(dp[n][i][j][k]for i in r(4)for j in r(4)for k in r(4))%M))
|
n=int(eval(input()))
A,C,G,T,M,R=0,1,2,3,10**9+7,list(range(4))
dp=[[[[0]*4for k in R]for j in R]for i in range(n+1)]
dp[0][T][T][T]=1
for i in range(1,n+1):
for j in R:
for k in R:
for l in R:
for m in R:
if not(any(t==(k,l,m)for t in((A,G,C),(A,C,G),(G,A,C)))or(j,l,m)==(A,G,C)or(j,k,m)==(A,G,C)):dp[i][k][l][m]=(dp[i][k][l][m]+dp[i-1][j][k][l])%M
print((sum(c for a in dp[n]for b in a for c in b)%M))
| 13
| 11
| 468
| 429
|
n = int(eval(input()))
A, C, G, T, M = 0, 1, 2, 3, 10**9 + 7
r = range
dp = [[[[0] * 4 for k in r(4)] for j in r(4)] for i in r(n + 1)]
dp[0][T][T][T] = 1
for i in r(1, n + 1):
for j in r(4):
for k in r(4):
for l in r(4):
for m in r(4):
if (
any(t == (k, l, m) for t in ((A, G, C), (A, C, G), (G, A, C)))
or (j, l, m) == (A, G, C)
or (j, k, m) == (A, G, C)
):
continue
dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M
print((sum(dp[n][i][j][k] for i in r(4) for j in r(4) for k in r(4)) % M))
|
n = int(eval(input()))
A, C, G, T, M, R = 0, 1, 2, 3, 10**9 + 7, list(range(4))
dp = [[[[0] * 4 for k in R] for j in R] for i in range(n + 1)]
dp[0][T][T][T] = 1
for i in range(1, n + 1):
for j in R:
for k in R:
for l in R:
for m in R:
if not (
any(t == (k, l, m) for t in ((A, G, C), (A, C, G), (G, A, C)))
or (j, l, m) == (A, G, C)
or (j, k, m) == (A, G, C)
):
dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M
print((sum(c for a in dp[n] for b in a for c in b) % M))
| false
| 15.384615
|
[
"-A, C, G, T, M = 0, 1, 2, 3, 10**9 + 7",
"-r = range",
"-dp = [[[[0] * 4 for k in r(4)] for j in r(4)] for i in r(n + 1)]",
"+A, C, G, T, M, R = 0, 1, 2, 3, 10**9 + 7, list(range(4))",
"+dp = [[[[0] * 4 for k in R] for j in R] for i in range(n + 1)]",
"-for i in r(1, n + 1):",
"- for j in r(4):",
"- for k in r(4):",
"- for l in r(4):",
"- for m in r(4):",
"- if (",
"+for i in range(1, n + 1):",
"+ for j in R:",
"+ for k in R:",
"+ for l in R:",
"+ for m in R:",
"+ if not (",
"- continue",
"- dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M",
"-print((sum(dp[n][i][j][k] for i in r(4) for j in r(4) for k in r(4)) % M))",
"+ dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M",
"+print((sum(c for a in dp[n] for b in a for c in b) % M))"
] | false
| 0.191094
| 0.084648
| 2.257497
|
[
"s968410757",
"s869707114"
] |
u724687935
|
p02555
|
python
|
s806569708
|
s975843851
| 64
| 27
| 63,916
| 9,144
|
Accepted
|
Accepted
| 57.81
|
MOD = 10 ** 9 + 7
S = int(eval(input()))
dp = [0] * (S + 1)
dp[0] = 1
for i in range(3, S + 1):
if i >= 1:
dp[i] += dp[i - 1]
if i >= 3:
dp[i] += dp[i - 3]
dp[i] %= MOD
print((dp[S]))
|
MOD = 10 ** 9 + 7
def prepare(n):
global MOD
modFacts = [0] * (n + 1)
modFacts[0] = 1
for i in range(n):
modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD
invs = [1] * (n + 1)
invs[n] = pow(modFacts[n], MOD - 2, MOD)
for i in range(n, 1, -1):
invs[i - 1] = (invs[i] * i) % MOD
return modFacts, invs
def comb(n, r):
global MOD, modFacts, invs
return (modFacts[n] * invs[n - r] * invs[r]) % MOD
def perm(n, r):
global MOD, modFacts, invs
return (modFacts[n] * invs[n - r]) % MOD
S = int(eval(input()))
modFacts, invs = prepare(S)
ans = 0
for k in range(1, S // 3 + 1):
s = S - 3 * k
cnt = comb(k - 1 + s, s)
ans += cnt
ans %= MOD
print(ans)
| 12
| 37
| 216
| 757
|
MOD = 10**9 + 7
S = int(eval(input()))
dp = [0] * (S + 1)
dp[0] = 1
for i in range(3, S + 1):
if i >= 1:
dp[i] += dp[i - 1]
if i >= 3:
dp[i] += dp[i - 3]
dp[i] %= MOD
print((dp[S]))
|
MOD = 10**9 + 7
def prepare(n):
global MOD
modFacts = [0] * (n + 1)
modFacts[0] = 1
for i in range(n):
modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD
invs = [1] * (n + 1)
invs[n] = pow(modFacts[n], MOD - 2, MOD)
for i in range(n, 1, -1):
invs[i - 1] = (invs[i] * i) % MOD
return modFacts, invs
def comb(n, r):
global MOD, modFacts, invs
return (modFacts[n] * invs[n - r] * invs[r]) % MOD
def perm(n, r):
global MOD, modFacts, invs
return (modFacts[n] * invs[n - r]) % MOD
S = int(eval(input()))
modFacts, invs = prepare(S)
ans = 0
for k in range(1, S // 3 + 1):
s = S - 3 * k
cnt = comb(k - 1 + s, s)
ans += cnt
ans %= MOD
print(ans)
| false
| 67.567568
|
[
"+",
"+",
"+def prepare(n):",
"+ global MOD",
"+ modFacts = [0] * (n + 1)",
"+ modFacts[0] = 1",
"+ for i in range(n):",
"+ modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD",
"+ invs = [1] * (n + 1)",
"+ invs[n] = pow(modFacts[n], MOD - 2, MOD)",
"+ for i in range(n, 1, -1):",
"+ invs[i - 1] = (invs[i] * i) % MOD",
"+ return modFacts, invs",
"+",
"+",
"+def comb(n, r):",
"+ global MOD, modFacts, invs",
"+ return (modFacts[n] * invs[n - r] * invs[r]) % MOD",
"+",
"+",
"+def perm(n, r):",
"+ global MOD, modFacts, invs",
"+ return (modFacts[n] * invs[n - r]) % MOD",
"+",
"+",
"-dp = [0] * (S + 1)",
"-dp[0] = 1",
"-for i in range(3, S + 1):",
"- if i >= 1:",
"- dp[i] += dp[i - 1]",
"- if i >= 3:",
"- dp[i] += dp[i - 3]",
"- dp[i] %= MOD",
"-print((dp[S]))",
"+modFacts, invs = prepare(S)",
"+ans = 0",
"+for k in range(1, S // 3 + 1):",
"+ s = S - 3 * k",
"+ cnt = comb(k - 1 + s, s)",
"+ ans += cnt",
"+ ans %= MOD",
"+print(ans)"
] | false
| 0.037928
| 0.037611
| 1.008425
|
[
"s806569708",
"s975843851"
] |
u936985471
|
p03274
|
python
|
s470579986
|
s498030381
| 94
| 83
| 14,384
| 15,020
|
Accepted
|
Accepted
| 11.7
|
N,K=list(map(int,input().split()))
X=list(map(int,input().split()))
def culclen(l,r):
if X[l]*X[r]>=0:
return max(abs(X[l]),abs(X[r]))
else:
ldis=abs(X[l])
rdis=abs(X[r])
return min(ldis,rdis)*2+max(ldis,rdis)
ans=10**9
for x in range(len(X)-K+1):
ans=min(ans,culclen(x,x+K-1))
print(ans)
|
N,K=list(map(int,input().split()))
X=list(map(int,input().split()))
def culclen(l,r):
return abs(X[r]-X[l])+min(abs(X[l]),abs(X[r]))
ans=10**9
for x in range(len(X)-K+1):
ans=min(ans,culclen(x,x+K-1))
print(ans)
| 15
| 10
| 321
| 221
|
N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
def culclen(l, r):
if X[l] * X[r] >= 0:
return max(abs(X[l]), abs(X[r]))
else:
ldis = abs(X[l])
rdis = abs(X[r])
return min(ldis, rdis) * 2 + max(ldis, rdis)
ans = 10**9
for x in range(len(X) - K + 1):
ans = min(ans, culclen(x, x + K - 1))
print(ans)
|
N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
def culclen(l, r):
return abs(X[r] - X[l]) + min(abs(X[l]), abs(X[r]))
ans = 10**9
for x in range(len(X) - K + 1):
ans = min(ans, culclen(x, x + K - 1))
print(ans)
| false
| 33.333333
|
[
"- if X[l] * X[r] >= 0:",
"- return max(abs(X[l]), abs(X[r]))",
"- else:",
"- ldis = abs(X[l])",
"- rdis = abs(X[r])",
"- return min(ldis, rdis) * 2 + max(ldis, rdis)",
"+ return abs(X[r] - X[l]) + min(abs(X[l]), abs(X[r]))"
] | false
| 0.037857
| 0.046783
| 0.809204
|
[
"s470579986",
"s498030381"
] |
u119148115
|
p02580
|
python
|
s093994339
|
s586537359
| 522
| 468
| 213,620
| 167,916
|
Accepted
|
Accepted
| 10.34
|
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split()) #空白あり
def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし
H,W,M = MI()
hw = [tuple(MI()) for _ in range(M)]
A = [0]*(H+1)
B = [0]*(W+1)
from collections import defaultdict
d = defaultdict(int)
for h,w in hw:
A[h] += 1
B[w] += 1
d[(h,w)] = 1
ma = max(A)
mb = max(B)
ans = ma+mb
C,D = [],[]
for i in range(1,H+1):
if A[i] == ma:
C.append(i)
for i in range(1,W+1):
if B[i] == mb:
D.append(i)
if len(C)*len(D) > M:
print(ans)
else:
for i in C:
for j in D:
if d[(i,j)] == 0:
print(ans)
exit()
print((ans-1))
|
import sys
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W,M = MI()
X = [0]*(H+1) # X[i] = x座標がiである爆破対象はいくつあるか
Y = [0]*(W+1) # Y[i] = y座標がiである爆破対象はいくつあるか
from collections import defaultdict
d = defaultdict(int) # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する
for i in range(M):
h,w = MI()
X[h] += 1
Y[w] += 1
d[(h,w)] = 1
mx = max(X)
my = max(Y)
ans = mx+my
A = [i for i in range(1,H+1) if X[i] == mx]
B = [i for i in range(1,W+1) if Y[i] == my]
if len(A)*len(B) > M:
print(ans)
else:
for i in A:
for j in B:
if d[(i,j)] == 0:
print(ans)
exit()
print((ans-1))
| 44
| 32
| 1,069
| 686
|
import sys
sys.setrecursionlimit(10**7)
def I():
return int(sys.stdin.readline().rstrip())
def MI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def LI():
return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり
def LI2():
return list(map(int, sys.stdin.readline().rstrip())) # 空白なし
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split()) # 空白あり
def LS2():
return list(sys.stdin.readline().rstrip()) # 空白なし
H, W, M = MI()
hw = [tuple(MI()) for _ in range(M)]
A = [0] * (H + 1)
B = [0] * (W + 1)
from collections import defaultdict
d = defaultdict(int)
for h, w in hw:
A[h] += 1
B[w] += 1
d[(h, w)] = 1
ma = max(A)
mb = max(B)
ans = ma + mb
C, D = [], []
for i in range(1, H + 1):
if A[i] == ma:
C.append(i)
for i in range(1, W + 1):
if B[i] == mb:
D.append(i)
if len(C) * len(D) > M:
print(ans)
else:
for i in C:
for j in D:
if d[(i, j)] == 0:
print(ans)
exit()
print((ans - 1))
|
import sys
def MI():
return list(map(int, sys.stdin.readline().rstrip().split()))
H, W, M = MI()
X = [0] * (H + 1) # X[i] = x座標がiである爆破対象はいくつあるか
Y = [0] * (W + 1) # Y[i] = y座標がiである爆破対象はいくつあるか
from collections import defaultdict
d = defaultdict(int) # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する
for i in range(M):
h, w = MI()
X[h] += 1
Y[w] += 1
d[(h, w)] = 1
mx = max(X)
my = max(Y)
ans = mx + my
A = [i for i in range(1, H + 1) if X[i] == mx]
B = [i for i in range(1, W + 1) if Y[i] == my]
if len(A) * len(B) > M:
print(ans)
else:
for i in A:
for j in B:
if d[(i, j)] == 0:
print(ans)
exit()
print((ans - 1))
| false
| 27.272727
|
[
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def I():",
"- return int(sys.stdin.readline().rstrip())",
"-def LI():",
"- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり",
"-",
"-",
"-def LI2():",
"- return list(map(int, sys.stdin.readline().rstrip())) # 空白なし",
"-",
"-",
"-def S():",
"- return sys.stdin.readline().rstrip()",
"-",
"-",
"-def LS():",
"- return list(sys.stdin.readline().rstrip().split()) # 空白あり",
"-",
"-",
"-def LS2():",
"- return list(sys.stdin.readline().rstrip()) # 空白なし",
"-",
"-",
"-hw = [tuple(MI()) for _ in range(M)]",
"-A = [0] * (H + 1)",
"-B = [0] * (W + 1)",
"+X = [0] * (H + 1) # X[i] = x座標がiである爆破対象はいくつあるか",
"+Y = [0] * (W + 1) # Y[i] = y座標がiである爆破対象はいくつあるか",
"-d = defaultdict(int)",
"-for h, w in hw:",
"- A[h] += 1",
"- B[w] += 1",
"+d = defaultdict(int) # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する",
"+for i in range(M):",
"+ h, w = MI()",
"+ X[h] += 1",
"+ Y[w] += 1",
"-ma = max(A)",
"-mb = max(B)",
"-ans = ma + mb",
"-C, D = [], []",
"-for i in range(1, H + 1):",
"- if A[i] == ma:",
"- C.append(i)",
"-for i in range(1, W + 1):",
"- if B[i] == mb:",
"- D.append(i)",
"-if len(C) * len(D) > M:",
"+mx = max(X)",
"+my = max(Y)",
"+ans = mx + my",
"+A = [i for i in range(1, H + 1) if X[i] == mx]",
"+B = [i for i in range(1, W + 1) if Y[i] == my]",
"+if len(A) * len(B) > M:",
"- for i in C:",
"- for j in D:",
"+ for i in A:",
"+ for j in B:"
] | false
| 0.037063
| 0.043361
| 0.854765
|
[
"s093994339",
"s586537359"
] |
u077291787
|
p03524
|
python
|
s457861506
|
s895886806
| 26
| 19
| 3,436
| 3,188
|
Accepted
|
Accepted
| 26.92
|
# cf17-finalB - Palindrome-phobia
from collections import Counter
def main():
S = input().rstrip()
C = list(Counter(S).values())
flg = [len(C) == 1 and sum(C) == 1] # e.g. "a"
flg += [len(C) == 2 and sum(C) == 2] # "ab"
flg += [len(C) == 3 and max(C) - min(C) <= 1] # "abcab"
print(("YES" if any(flg) else "NO"))
if __name__ == "__main__":
main()
|
# cf17-finalB - Palindrome-phobia
def main():
S = input().rstrip()
C = [S.count(i) for i in "abc"]
flg = max(C) - min(C) <= 1
print(("YES" if flg else "NO"))
if __name__ == "__main__":
main()
| 15
| 10
| 387
| 220
|
# cf17-finalB - Palindrome-phobia
from collections import Counter
def main():
S = input().rstrip()
C = list(Counter(S).values())
flg = [len(C) == 1 and sum(C) == 1] # e.g. "a"
flg += [len(C) == 2 and sum(C) == 2] # "ab"
flg += [len(C) == 3 and max(C) - min(C) <= 1] # "abcab"
print(("YES" if any(flg) else "NO"))
if __name__ == "__main__":
main()
|
# cf17-finalB - Palindrome-phobia
def main():
S = input().rstrip()
C = [S.count(i) for i in "abc"]
flg = max(C) - min(C) <= 1
print(("YES" if flg else "NO"))
if __name__ == "__main__":
main()
| false
| 33.333333
|
[
"-from collections import Counter",
"-",
"-",
"- C = list(Counter(S).values())",
"- flg = [len(C) == 1 and sum(C) == 1] # e.g. \"a\"",
"- flg += [len(C) == 2 and sum(C) == 2] # \"ab\"",
"- flg += [len(C) == 3 and max(C) - min(C) <= 1] # \"abcab\"",
"- print((\"YES\" if any(flg) else \"NO\"))",
"+ C = [S.count(i) for i in \"abc\"]",
"+ flg = max(C) - min(C) <= 1",
"+ print((\"YES\" if flg else \"NO\"))"
] | false
| 0.03948
| 0.038902
| 1.014862
|
[
"s457861506",
"s895886806"
] |
u117193815
|
p02819
|
python
|
s635919999
|
s563523738
| 320
| 274
| 3,064
| 3,060
|
Accepted
|
Accepted
| 14.37
|
x=int(eval(input()))
cont=0
for i in range(x,10**12):
for j in range(2,i):
if i%j==0:
cont+=1
if cont==0:
print(i)
exit()
cont=0
|
x=int(eval(input()))
j=x
while True:
cnt=0
for i in range(2,j+1):
if j%i==0:
cnt+=1
if cnt==1:
print(j)
exit()
else:
j+=1
| 10
| 12
| 181
| 186
|
x = int(eval(input()))
cont = 0
for i in range(x, 10**12):
for j in range(2, i):
if i % j == 0:
cont += 1
if cont == 0:
print(i)
exit()
cont = 0
|
x = int(eval(input()))
j = x
while True:
cnt = 0
for i in range(2, j + 1):
if j % i == 0:
cnt += 1
if cnt == 1:
print(j)
exit()
else:
j += 1
| false
| 16.666667
|
[
"-cont = 0",
"-for i in range(x, 10**12):",
"- for j in range(2, i):",
"- if i % j == 0:",
"- cont += 1",
"- if cont == 0:",
"- print(i)",
"+j = x",
"+while True:",
"+ cnt = 0",
"+ for i in range(2, j + 1):",
"+ if j % i == 0:",
"+ cnt += 1",
"+ if cnt == 1:",
"+ print(j)",
"- cont = 0",
"+ else:",
"+ j += 1"
] | false
| 0.053401
| 0.050522
| 1.056977
|
[
"s635919999",
"s563523738"
] |
u671060652
|
p03207
|
python
|
s608417123
|
s827706749
| 269
| 81
| 63,980
| 61,464
|
Accepted
|
Accepted
| 69.89
|
import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
p = []
for i in range(n):
p.append(int(eval(input())))
print((sum(p)-max(p)//2))
|
def main():
n = int(eval(input()))
# t, a = map(int, input().split())
# h = list(map(int, input().split()))
# s = input()
p = []
for i in range(n):
p.append(int(eval(input())))
maxi = max(p)
print((sum(p) - maxi//2))
if __name__ == '__main__':
main()
| 12
| 17
| 181
| 306
|
import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
p = []
for i in range(n):
p.append(int(eval(input())))
print((sum(p) - max(p) // 2))
|
def main():
n = int(eval(input()))
# t, a = map(int, input().split())
# h = list(map(int, input().split()))
# s = input()
p = []
for i in range(n):
p.append(int(eval(input())))
maxi = max(p)
print((sum(p) - maxi // 2))
if __name__ == "__main__":
main()
| false
| 29.411765
|
[
"-import itertools",
"-import math",
"-import fractions",
"-import functools",
"-import copy",
"+def main():",
"+ n = int(eval(input()))",
"+ # t, a = map(int, input().split())",
"+ # h = list(map(int, input().split()))",
"+ # s = input()",
"+ p = []",
"+ for i in range(n):",
"+ p.append(int(eval(input())))",
"+ maxi = max(p)",
"+ print((sum(p) - maxi // 2))",
"-n = int(eval(input()))",
"-p = []",
"-for i in range(n):",
"- p.append(int(eval(input())))",
"-print((sum(p) - max(p) // 2))",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false
| 0.08398
| 0.067593
| 1.242432
|
[
"s608417123",
"s827706749"
] |
u690536347
|
p02975
|
python
|
s228440919
|
s495312257
| 59
| 53
| 14,468
| 14,468
|
Accepted
|
Accepted
| 10.17
|
from collections import Counter
N = int(eval(input()))
*a, = list(map(int, input().split()))
c = Counter(a)
used = set(c.keys())
size = len(used)
def check():
if 0 in used:
if size==1 or (size==2 and c[0]==N//3):
return True
elif size==3:
s, t, u = used
if s^t^u==0 and c[s]==c[t]==c[u]:
return True
return False
print(("Yes" if check() else "No"))
|
from collections import Counter
N = int(eval(input()))
*a, = list(map(int, input().split()))
c = Counter(a)
b = len(list(c.keys()))
def check():
if 0 in list(c.keys()):
if b==1 or (b==2 and c[0]==N//3):
return True
elif b==3:
s, t, u = list(c.keys())
if s^t^u==0 and c[s]==c[t]==c[u]:
return True
return False
print(("Yes" if check() else "No"))
| 19
| 18
| 415
| 393
|
from collections import Counter
N = int(eval(input()))
(*a,) = list(map(int, input().split()))
c = Counter(a)
used = set(c.keys())
size = len(used)
def check():
if 0 in used:
if size == 1 or (size == 2 and c[0] == N // 3):
return True
elif size == 3:
s, t, u = used
if s ^ t ^ u == 0 and c[s] == c[t] == c[u]:
return True
return False
print(("Yes" if check() else "No"))
|
from collections import Counter
N = int(eval(input()))
(*a,) = list(map(int, input().split()))
c = Counter(a)
b = len(list(c.keys()))
def check():
if 0 in list(c.keys()):
if b == 1 or (b == 2 and c[0] == N // 3):
return True
elif b == 3:
s, t, u = list(c.keys())
if s ^ t ^ u == 0 and c[s] == c[t] == c[u]:
return True
return False
print(("Yes" if check() else "No"))
| false
| 5.263158
|
[
"-used = set(c.keys())",
"-size = len(used)",
"+b = len(list(c.keys()))",
"- if 0 in used:",
"- if size == 1 or (size == 2 and c[0] == N // 3):",
"+ if 0 in list(c.keys()):",
"+ if b == 1 or (b == 2 and c[0] == N // 3):",
"- elif size == 3:",
"- s, t, u = used",
"+ elif b == 3:",
"+ s, t, u = list(c.keys())"
] | false
| 0.032631
| 0.040928
| 0.797278
|
[
"s228440919",
"s495312257"
] |
u644907318
|
p03013
|
python
|
s384405611
|
s083263853
| 492
| 185
| 51,180
| 87,692
|
Accepted
|
Accepted
| 62.4
|
p = 10**9+7
N,M = list(map(int,input().split()))
A = [0 for _ in range(N+1)]
for _ in range(M):
i = int(eval(input()))
A[i] = 1
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
if A[i]==0:
dp[i] = dp[i-1]
if i>=2:
dp[i] = (dp[i]+dp[i-2])%p
print((dp[N]))
|
p = 10**9+7
N,M = list(map(int,input().split()))
A = {i:0 for i in range(N+1)}
for _ in range(M):
A[int(eval(input()))] = 1
dp = [0 for _ in range(N+1)]
dp[N] = 1
for i in range(N-1,-1,-1):
if A[i]==1:continue
if A[i+1]==0:
dp[i] = dp[i+1]
if i+2<=N and A[i+2]==0:
dp[i] = (dp[i]+dp[i+2])%p
print((dp[0]))
| 14
| 14
| 306
| 336
|
p = 10**9 + 7
N, M = list(map(int, input().split()))
A = [0 for _ in range(N + 1)]
for _ in range(M):
i = int(eval(input()))
A[i] = 1
dp = [0 for _ in range(N + 1)]
dp[0] = 1
for i in range(1, N + 1):
if A[i] == 0:
dp[i] = dp[i - 1]
if i >= 2:
dp[i] = (dp[i] + dp[i - 2]) % p
print((dp[N]))
|
p = 10**9 + 7
N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N + 1)}
for _ in range(M):
A[int(eval(input()))] = 1
dp = [0 for _ in range(N + 1)]
dp[N] = 1
for i in range(N - 1, -1, -1):
if A[i] == 1:
continue
if A[i + 1] == 0:
dp[i] = dp[i + 1]
if i + 2 <= N and A[i + 2] == 0:
dp[i] = (dp[i] + dp[i + 2]) % p
print((dp[0]))
| false
| 0
|
[
"-A = [0 for _ in range(N + 1)]",
"+A = {i: 0 for i in range(N + 1)}",
"- i = int(eval(input()))",
"- A[i] = 1",
"+ A[int(eval(input()))] = 1",
"-dp[0] = 1",
"-for i in range(1, N + 1):",
"- if A[i] == 0:",
"- dp[i] = dp[i - 1]",
"- if i >= 2:",
"- dp[i] = (dp[i] + dp[i - 2]) % p",
"-print((dp[N]))",
"+dp[N] = 1",
"+for i in range(N - 1, -1, -1):",
"+ if A[i] == 1:",
"+ continue",
"+ if A[i + 1] == 0:",
"+ dp[i] = dp[i + 1]",
"+ if i + 2 <= N and A[i + 2] == 0:",
"+ dp[i] = (dp[i] + dp[i + 2]) % p",
"+print((dp[0]))"
] | false
| 0.034203
| 0.03312
| 1.032709
|
[
"s384405611",
"s083263853"
] |
u994521204
|
p02715
|
python
|
s245203526
|
s167473042
| 510
| 92
| 11,236
| 69,104
|
Accepted
|
Accepted
| 81.96
|
# 解説AC
mod = 10 ** 9 + 7
n, k = list(map(int, input().split()))
dp = [-1] * (k + 1)
ans = 0
for i in range(k, 0, -1):
dp[i] = pow(k // i, n, mod)
t = 0
t += 2 * i
while t <= k:
dp[i] -= dp[t]
dp[i] %= mod
t += i
ans += i * dp[i]
ans %= mod
print(ans)
|
n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7
dp = [0] * (k + 1)
ans = 0
for i in range(k, 0, -1):
num = k // i
dp[i] += pow(num, n, mod)
for j in range(1, num):
dp[i] -= dp[(j + 1) * i]
ans += i * dp[i]
ans %= mod
print(ans)
| 16
| 13
| 308
| 272
|
# 解説AC
mod = 10**9 + 7
n, k = list(map(int, input().split()))
dp = [-1] * (k + 1)
ans = 0
for i in range(k, 0, -1):
dp[i] = pow(k // i, n, mod)
t = 0
t += 2 * i
while t <= k:
dp[i] -= dp[t]
dp[i] %= mod
t += i
ans += i * dp[i]
ans %= mod
print(ans)
|
n, k = list(map(int, input().split()))
mod = 10**9 + 7
dp = [0] * (k + 1)
ans = 0
for i in range(k, 0, -1):
num = k // i
dp[i] += pow(num, n, mod)
for j in range(1, num):
dp[i] -= dp[(j + 1) * i]
ans += i * dp[i]
ans %= mod
print(ans)
| false
| 18.75
|
[
"-# 解説AC",
"+n, k = list(map(int, input().split()))",
"-n, k = list(map(int, input().split()))",
"-dp = [-1] * (k + 1)",
"+dp = [0] * (k + 1)",
"- dp[i] = pow(k // i, n, mod)",
"- t = 0",
"- t += 2 * i",
"- while t <= k:",
"- dp[i] -= dp[t]",
"- dp[i] %= mod",
"- t += i",
"+ num = k // i",
"+ dp[i] += pow(num, n, mod)",
"+ for j in range(1, num):",
"+ dp[i] -= dp[(j + 1) * i]"
] | false
| 0.26827
| 0.368653
| 0.727705
|
[
"s245203526",
"s167473042"
] |
u347640436
|
p02701
|
python
|
s070222702
|
s504229583
| 303
| 260
| 35,272
| 30,984
|
Accepted
|
Accepted
| 14.19
|
N = int(eval(input()))
d = {}
for _ in range(N):
S = eval(input())
d.setdefault(S, 0)
d[S] += 1
print((len(list(d.keys()))))
|
N = int(eval(input()))
print((len(set(eval(input()) for _ in range(N)))))
| 8
| 3
| 125
| 63
|
N = int(eval(input()))
d = {}
for _ in range(N):
S = eval(input())
d.setdefault(S, 0)
d[S] += 1
print((len(list(d.keys()))))
|
N = int(eval(input()))
print((len(set(eval(input()) for _ in range(N)))))
| false
| 62.5
|
[
"-d = {}",
"-for _ in range(N):",
"- S = eval(input())",
"- d.setdefault(S, 0)",
"- d[S] += 1",
"-print((len(list(d.keys()))))",
"+print((len(set(eval(input()) for _ in range(N)))))"
] | false
| 0.045822
| 0.046508
| 0.985264
|
[
"s070222702",
"s504229583"
] |
u556594202
|
p03455
|
python
|
s336141719
|
s687401158
| 28
| 23
| 8,988
| 9,064
|
Accepted
|
Accepted
| 17.86
|
a,b = list(map(int,input().split()))
print(("Even" if a*b%2==0 else "Odd"))
|
a,b=list(map(int,input().split()))
print(("Odd" if a*b%2 else "Even"))
| 2
| 2
| 74
| 63
|
a, b = list(map(int, input().split()))
print(("Even" if a * b % 2 == 0 else "Odd"))
|
a, b = list(map(int, input().split()))
print(("Odd" if a * b % 2 else "Even"))
| false
| 0
|
[
"-print((\"Even\" if a * b % 2 == 0 else \"Odd\"))",
"+print((\"Odd\" if a * b % 2 else \"Even\"))"
] | false
| 0.038315
| 0.121527
| 0.315277
|
[
"s336141719",
"s687401158"
] |
u561083515
|
p02972
|
python
|
s136432159
|
s051875349
| 539
| 336
| 14,140
| 70,108
|
Accepted
|
Accepted
| 37.66
|
def main():
N = int(input())
A = [int(i) for i in input().split()]
box = [0] * N
for i in range(N - 1, -1, -1):
# ボールの総数
cnt = 0
# (i + 1)の倍数
num = i + 1
while num <= N:
cnt += box[num - 1]
num += (i + 1)
if cnt % 2 != A[i]:
box[i] = 1
ans = [idx + 1 for idx in range(N) if box[idx]]
print(len(ans))
if ans:
print(*ans, sep=" ")
if __name__ == "__main__":
main()
|
N = int(eval(input()))
A = [int(i) for i in input().split()]
box = [0] * N
for i in range(N - 1, -1, -1):
cnt = 0
num = i + 1
while num <= N:
cnt += box[num - 1]
num += i + 1
if cnt % 2 != A[i]:
box[i] = 1
ans = [idx + 1 for idx in range(N) if box[idx]]
print((len(ans)))
print((*ans))
| 25
| 18
| 523
| 344
|
def main():
N = int(input())
A = [int(i) for i in input().split()]
box = [0] * N
for i in range(N - 1, -1, -1):
# ボールの総数
cnt = 0
# (i + 1)の倍数
num = i + 1
while num <= N:
cnt += box[num - 1]
num += i + 1
if cnt % 2 != A[i]:
box[i] = 1
ans = [idx + 1 for idx in range(N) if box[idx]]
print(len(ans))
if ans:
print(*ans, sep=" ")
if __name__ == "__main__":
main()
|
N = int(eval(input()))
A = [int(i) for i in input().split()]
box = [0] * N
for i in range(N - 1, -1, -1):
cnt = 0
num = i + 1
while num <= N:
cnt += box[num - 1]
num += i + 1
if cnt % 2 != A[i]:
box[i] = 1
ans = [idx + 1 for idx in range(N) if box[idx]]
print((len(ans)))
print((*ans))
| false
| 28
|
[
"-def main():",
"- N = int(input())",
"- A = [int(i) for i in input().split()]",
"- box = [0] * N",
"- for i in range(N - 1, -1, -1):",
"- # ボールの総数",
"- cnt = 0",
"- # (i + 1)の倍数",
"- num = i + 1",
"- while num <= N:",
"- cnt += box[num - 1]",
"- num += i + 1",
"- if cnt % 2 != A[i]:",
"- box[i] = 1",
"- ans = [idx + 1 for idx in range(N) if box[idx]]",
"- print(len(ans))",
"- if ans:",
"- print(*ans, sep=\" \")",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+N = int(eval(input()))",
"+A = [int(i) for i in input().split()]",
"+box = [0] * N",
"+for i in range(N - 1, -1, -1):",
"+ cnt = 0",
"+ num = i + 1",
"+ while num <= N:",
"+ cnt += box[num - 1]",
"+ num += i + 1",
"+ if cnt % 2 != A[i]:",
"+ box[i] = 1",
"+ans = [idx + 1 for idx in range(N) if box[idx]]",
"+print((len(ans)))",
"+print((*ans))"
] | false
| 0.037243
| 0.034858
| 1.068395
|
[
"s136432159",
"s051875349"
] |
u631025015
|
p02713
|
python
|
s564243533
|
s006689515
| 454
| 390
| 9,204
| 9,212
|
Accepted
|
Accepted
| 14.1
|
def gcd(a, b):
while b != 0 :
t = a % b
a = b
b = t
return a
sum = 0
N=int(eval(input("")))
for a in range(1, N + 1):
for b in range(1, N + 1):
x = gcd(a, b)
if x == 1:
sum = sum + N
elif x == 2:
sum = sum + (N + 1) // 2 + N // 2 * 2
elif x == 3:
sum = sum + N // 3 * 3 + (N - N // 3)
else:
for c in range(1, N + 1):
sum = sum + gcd(x, c)
print(sum)
|
def gcd(a, b):
while b != 0 :
t = a % b
a = b
b = t
return a
sum = 0
N=int(eval(input("")))
for a in range(1, N + 1):
for b in range(1, N + 1):
x = gcd(a, b)
if x == 1:
sum = sum + N
elif x == 2:
sum = sum + (N + 1) // 2 + N // 2 * 2
elif x == 3:
sum = sum + N // 3 * 3 + (N - N // 3)
elif x == 5:
sum = sum + N // 5 * 5 + (N - N // 5)
else:
for c in range(1, N + 1):
sum = sum + gcd(x, c)
print(sum)
| 22
| 24
| 513
| 586
|
def gcd(a, b):
while b != 0:
t = a % b
a = b
b = t
return a
sum = 0
N = int(eval(input("")))
for a in range(1, N + 1):
for b in range(1, N + 1):
x = gcd(a, b)
if x == 1:
sum = sum + N
elif x == 2:
sum = sum + (N + 1) // 2 + N // 2 * 2
elif x == 3:
sum = sum + N // 3 * 3 + (N - N // 3)
else:
for c in range(1, N + 1):
sum = sum + gcd(x, c)
print(sum)
|
def gcd(a, b):
while b != 0:
t = a % b
a = b
b = t
return a
sum = 0
N = int(eval(input("")))
for a in range(1, N + 1):
for b in range(1, N + 1):
x = gcd(a, b)
if x == 1:
sum = sum + N
elif x == 2:
sum = sum + (N + 1) // 2 + N // 2 * 2
elif x == 3:
sum = sum + N // 3 * 3 + (N - N // 3)
elif x == 5:
sum = sum + N // 5 * 5 + (N - N // 5)
else:
for c in range(1, N + 1):
sum = sum + gcd(x, c)
print(sum)
| false
| 8.333333
|
[
"+ elif x == 5:",
"+ sum = sum + N // 5 * 5 + (N - N // 5)"
] | false
| 0.078614
| 0.159266
| 0.493599
|
[
"s564243533",
"s006689515"
] |
u820351940
|
p03168
|
python
|
s035750675
|
s081206915
| 1,954
| 958
| 219,656
| 237,576
|
Accepted
|
Accepted
| 50.97
|
import sys
sys.setrecursionlimit(10 ** 6)
import functools
import operator
n = int(eval(input()))
p = list(map(float, input().split()))
half = n // 2 + 1
dp = [[None] * (n + 1) for _ in range(n + 1)]
def dfs(n=half, depth=n - 1):
if depth < 0:
return 0
if dp[n][depth] is not None:
return dp[n][depth]
if n == 0:
r = functools.reduce(operator.mul, [1 - x for x in p[:depth + 1]])
elif (n - 1) == depth:
r = functools.reduce(operator.mul, p[:depth + 1])
else:
r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])
dp[n][depth] = r
return r
print((sum(dfs(i) for i in range(half, n + 1))))
|
import sys
sys.setrecursionlimit(10 ** 6)
import functools
import operator
n = int(eval(input()))
p = list(map(float, input().split()))
half = n // 2 + 1
dp = [[None] * (n + 1) for _ in range(n + 1)]
# def dfs(n, depth=n - 1):
# if depth < 0:
# return 0
#
# if dp[n][depth] is not None:
# return dp[n][depth]
#
# if n == 0:
# r = functools.reduce(operator.mul, map(lambda x: 1 - x, p[:depth + 1]))
# elif (n - 1) == depth:
# r = functools.reduce(operator.mul, p[:depth + 1])
# else:
# r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])
# dp[n][depth] = r
# return r
#
# print(sum(dfs(i) for i in range(half, n + 1)))
for i in range(0, n + 1):
for depth in range(-1, n):
if depth == -1:
dp[i][depth] = 0
elif i == 0:
dp[i][depth] = functools.reduce(operator.mul, [1 - x for x in p[:depth + 1]])
elif (i - 1) == depth:
dp[i][depth] = functools.reduce(operator.mul, p[:depth + 1])
else:
dp[i][depth] = dp[i - 1][depth - 1] * p[depth] + dp[i][depth - 1] * (1 - p[depth])
print((sum(dp[i][n - 1] for i in range(half, n + 1))))
| 27
| 40
| 704
| 1,237
|
import sys
sys.setrecursionlimit(10**6)
import functools
import operator
n = int(eval(input()))
p = list(map(float, input().split()))
half = n // 2 + 1
dp = [[None] * (n + 1) for _ in range(n + 1)]
def dfs(n=half, depth=n - 1):
if depth < 0:
return 0
if dp[n][depth] is not None:
return dp[n][depth]
if n == 0:
r = functools.reduce(operator.mul, [1 - x for x in p[: depth + 1]])
elif (n - 1) == depth:
r = functools.reduce(operator.mul, p[: depth + 1])
else:
r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])
dp[n][depth] = r
return r
print((sum(dfs(i) for i in range(half, n + 1))))
|
import sys
sys.setrecursionlimit(10**6)
import functools
import operator
n = int(eval(input()))
p = list(map(float, input().split()))
half = n // 2 + 1
dp = [[None] * (n + 1) for _ in range(n + 1)]
# def dfs(n, depth=n - 1):
# if depth < 0:
# return 0
#
# if dp[n][depth] is not None:
# return dp[n][depth]
#
# if n == 0:
# r = functools.reduce(operator.mul, map(lambda x: 1 - x, p[:depth + 1]))
# elif (n - 1) == depth:
# r = functools.reduce(operator.mul, p[:depth + 1])
# else:
# r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])
# dp[n][depth] = r
# return r
#
# print(sum(dfs(i) for i in range(half, n + 1)))
for i in range(0, n + 1):
for depth in range(-1, n):
if depth == -1:
dp[i][depth] = 0
elif i == 0:
dp[i][depth] = functools.reduce(
operator.mul, [1 - x for x in p[: depth + 1]]
)
elif (i - 1) == depth:
dp[i][depth] = functools.reduce(operator.mul, p[: depth + 1])
else:
dp[i][depth] = dp[i - 1][depth - 1] * p[depth] + dp[i][depth - 1] * (
1 - p[depth]
)
print((sum(dp[i][n - 1] for i in range(half, n + 1))))
| false
| 32.5
|
[
"-",
"-",
"-def dfs(n=half, depth=n - 1):",
"- if depth < 0:",
"- return 0",
"- if dp[n][depth] is not None:",
"- return dp[n][depth]",
"- if n == 0:",
"- r = functools.reduce(operator.mul, [1 - x for x in p[: depth + 1]])",
"- elif (n - 1) == depth:",
"- r = functools.reduce(operator.mul, p[: depth + 1])",
"- else:",
"- r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])",
"- dp[n][depth] = r",
"- return r",
"-",
"-",
"-print((sum(dfs(i) for i in range(half, n + 1))))",
"+# def dfs(n, depth=n - 1):",
"+# if depth < 0:",
"+# return 0",
"+#",
"+# if dp[n][depth] is not None:",
"+# return dp[n][depth]",
"+#",
"+# if n == 0:",
"+# r = functools.reduce(operator.mul, map(lambda x: 1 - x, p[:depth + 1]))",
"+# elif (n - 1) == depth:",
"+# r = functools.reduce(operator.mul, p[:depth + 1])",
"+# else:",
"+# r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])",
"+# dp[n][depth] = r",
"+# return r",
"+#",
"+# print(sum(dfs(i) for i in range(half, n + 1)))",
"+for i in range(0, n + 1):",
"+ for depth in range(-1, n):",
"+ if depth == -1:",
"+ dp[i][depth] = 0",
"+ elif i == 0:",
"+ dp[i][depth] = functools.reduce(",
"+ operator.mul, [1 - x for x in p[: depth + 1]]",
"+ )",
"+ elif (i - 1) == depth:",
"+ dp[i][depth] = functools.reduce(operator.mul, p[: depth + 1])",
"+ else:",
"+ dp[i][depth] = dp[i - 1][depth - 1] * p[depth] + dp[i][depth - 1] * (",
"+ 1 - p[depth]",
"+ )",
"+print((sum(dp[i][n - 1] for i in range(half, n + 1))))"
] | false
| 0.007709
| 0.03784
| 0.203722
|
[
"s035750675",
"s081206915"
] |
u968166680
|
p02918
|
python
|
s960679938
|
s885371774
| 60
| 41
| 9,824
| 9,220
|
Accepted
|
Accepted
| 31.67
|
import sys
from itertools import groupby
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K = list(map(int, readline().split()))
S = readline().strip()
ans = groups = 0
for k, g in groupby(S):
ans += len(list(g)) - 1
groups += 1
ans += 2 * K
if ans > N - 1:
ans = N - 1
print(ans)
return
if __name__ == '__main__':
main()
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K = list(map(int, readline().split()))
S = readline().strip()
ans = 0
for i in range(N-1):
if S[i] == S[i+1]:
ans += 1
ans += 2 * K
if ans > N - 1:
ans = N - 1
print(ans)
return
if __name__ == '__main__':
main()
| 30
| 29
| 525
| 478
|
import sys
from itertools import groupby
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K = list(map(int, readline().split()))
S = readline().strip()
ans = groups = 0
for k, g in groupby(S):
ans += len(list(g)) - 1
groups += 1
ans += 2 * K
if ans > N - 1:
ans = N - 1
print(ans)
return
if __name__ == "__main__":
main()
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, K = list(map(int, readline().split()))
S = readline().strip()
ans = 0
for i in range(N - 1):
if S[i] == S[i + 1]:
ans += 1
ans += 2 * K
if ans > N - 1:
ans = N - 1
print(ans)
return
if __name__ == "__main__":
main()
| false
| 3.333333
|
[
"-from itertools import groupby",
"- ans = groups = 0",
"- for k, g in groupby(S):",
"- ans += len(list(g)) - 1",
"- groups += 1",
"+ ans = 0",
"+ for i in range(N - 1):",
"+ if S[i] == S[i + 1]:",
"+ ans += 1"
] | false
| 0.051689
| 0.035537
| 1.454485
|
[
"s960679938",
"s885371774"
] |
u977193988
|
p03759
|
python
|
s256025016
|
s503441281
| 22
| 17
| 3,316
| 2,940
|
Accepted
|
Accepted
| 22.73
|
a=[int(i) for i in input().split()]
if (a[2]+a[0])/2==a[1]:
print('YES')
else:
print('NO')
|
a,b,c=list(map(int,input().split()))
if (a+c)/2==b:
print('YES')
else:
print('NO')
| 5
| 5
| 102
| 88
|
a = [int(i) for i in input().split()]
if (a[2] + a[0]) / 2 == a[1]:
print("YES")
else:
print("NO")
|
a, b, c = list(map(int, input().split()))
if (a + c) / 2 == b:
print("YES")
else:
print("NO")
| false
| 0
|
[
"-a = [int(i) for i in input().split()]",
"-if (a[2] + a[0]) / 2 == a[1]:",
"+a, b, c = list(map(int, input().split()))",
"+if (a + c) / 2 == b:"
] | false
| 0.044214
| 0.044365
| 0.996584
|
[
"s256025016",
"s503441281"
] |
u379959788
|
p02988
|
python
|
s252709806
|
s497284254
| 22
| 17
| 3,316
| 3,060
|
Accepted
|
Accepted
| 22.73
|
#B
n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
if p[i-1] < p[i] and p[i] < p[i+1]:
ans += 1
if p[i-1] > p[i] and p[i] > p[i+1]:
ans += 1
print(ans)
|
n = int(eval(input()))
p = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
if p[i-1] < p[i] and p[i] < p[i+1]:
count += 1
elif p[i-1] > p[i] and p[i] > p[i+1]:
count += 1
else:
pass
print(count)
| 10
| 12
| 221
| 254
|
# B
n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
if p[i - 1] < p[i] and p[i] < p[i + 1]:
ans += 1
if p[i - 1] > p[i] and p[i] > p[i + 1]:
ans += 1
print(ans)
|
n = int(eval(input()))
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
if p[i - 1] < p[i] and p[i] < p[i + 1]:
count += 1
elif p[i - 1] > p[i] and p[i] > p[i + 1]:
count += 1
else:
pass
print(count)
| false
| 16.666667
|
[
"-# B",
"-ans = 0",
"+count = 0",
"- ans += 1",
"- if p[i - 1] > p[i] and p[i] > p[i + 1]:",
"- ans += 1",
"-print(ans)",
"+ count += 1",
"+ elif p[i - 1] > p[i] and p[i] > p[i + 1]:",
"+ count += 1",
"+ else:",
"+ pass",
"+print(count)"
] | false
| 0.042476
| 0.033498
| 1.267998
|
[
"s252709806",
"s497284254"
] |
u353895424
|
p03673
|
python
|
s684495955
|
s588114646
| 231
| 150
| 26,892
| 32,516
|
Accepted
|
Accepted
| 35.06
|
from queue import deque
n = int(eval(input()))
a = list(map(int, input().split()))
b = deque()
for i in range(n):
if i%2 == 0:
b.append(a[i])
else:
b.appendleft(a[i])
ans = list(b)
if n%2 != 0:
ans = ans[::-1]
print((*ans))
|
from collections import deque
n = int(eval(input()))
A = list(map(int, input().split()))
B = deque()
for i in range(n):
if i%2 == 0:
B.append(A[i])
else:
B.appendleft(A[i])
B = list(B)
if n%2 != 0:
B = B[::-1]
print((*B))
| 19
| 15
| 267
| 266
|
from queue import deque
n = int(eval(input()))
a = list(map(int, input().split()))
b = deque()
for i in range(n):
if i % 2 == 0:
b.append(a[i])
else:
b.appendleft(a[i])
ans = list(b)
if n % 2 != 0:
ans = ans[::-1]
print((*ans))
|
from collections import deque
n = int(eval(input()))
A = list(map(int, input().split()))
B = deque()
for i in range(n):
if i % 2 == 0:
B.append(A[i])
else:
B.appendleft(A[i])
B = list(B)
if n % 2 != 0:
B = B[::-1]
print((*B))
| false
| 21.052632
|
[
"-from queue import deque",
"+from collections import deque",
"-a = list(map(int, input().split()))",
"-b = deque()",
"+A = list(map(int, input().split()))",
"+B = deque()",
"- b.append(a[i])",
"+ B.append(A[i])",
"- b.appendleft(a[i])",
"-ans = list(b)",
"+ B.appendleft(A[i])",
"+B = list(B)",
"- ans = ans[::-1]",
"-print((*ans))",
"+ B = B[::-1]",
"+print((*B))"
] | false
| 0.044314
| 0.037908
| 1.168971
|
[
"s684495955",
"s588114646"
] |
u672475305
|
p02996
|
python
|
s136992174
|
s891333202
| 979
| 902
| 53,596
| 54,212
|
Accepted
|
Accepted
| 7.87
|
n = int(eval(input()))
lst = [list(map(int,input().split())) for _ in range(n)]
lst.sort(key = lambda x:x[1])
time = 0
for x,y in lst:
time += x
if time > y:
print('No')
break
else:
print('Yes')
|
n = int(eval(input()))
lst = [list(map(int,input().split())) for _ in range(n)]
lst.sort(key = lambda x:x[1])
time = 0
for x,y in lst:
time += x
if time > y:
print('No')
exit()
else:
print('Yes')
| 12
| 12
| 228
| 229
|
n = int(eval(input()))
lst = [list(map(int, input().split())) for _ in range(n)]
lst.sort(key=lambda x: x[1])
time = 0
for x, y in lst:
time += x
if time > y:
print("No")
break
else:
print("Yes")
|
n = int(eval(input()))
lst = [list(map(int, input().split())) for _ in range(n)]
lst.sort(key=lambda x: x[1])
time = 0
for x, y in lst:
time += x
if time > y:
print("No")
exit()
else:
print("Yes")
| false
| 0
|
[
"- break",
"+ exit()"
] | false
| 0.039351
| 0.039525
| 0.995594
|
[
"s136992174",
"s891333202"
] |
u028260664
|
p03854
|
python
|
s616693511
|
s844044381
| 168
| 69
| 39,920
| 3,316
|
Accepted
|
Accepted
| 58.93
|
def check(s):
s = s.replace('eraser', '')
s = s.replace('erase', '')
s = s.replace('dreamer', '')
s = s.replace('dream', '')
if len(s) != 0:
return 'NO'
return 'YES'
print((check(eval(input()))))
|
# Me
def check(s):
words = [
'dream',
'dreamer',
'erase',
'eraser',
]
while len(s) != 0:
flag = False
for w in words:
if s[-len(w):] == w:
s = s[:-len(w)]
flag = True
break
if not flag:
return 'NO'
return 'YES'
print((check(eval(input()))))
| 11
| 22
| 232
| 424
|
def check(s):
s = s.replace("eraser", "")
s = s.replace("erase", "")
s = s.replace("dreamer", "")
s = s.replace("dream", "")
if len(s) != 0:
return "NO"
return "YES"
print((check(eval(input()))))
|
# Me
def check(s):
words = [
"dream",
"dreamer",
"erase",
"eraser",
]
while len(s) != 0:
flag = False
for w in words:
if s[-len(w) :] == w:
s = s[: -len(w)]
flag = True
break
if not flag:
return "NO"
return "YES"
print((check(eval(input()))))
| false
| 50
|
[
"+# Me",
"- s = s.replace(\"eraser\", \"\")",
"- s = s.replace(\"erase\", \"\")",
"- s = s.replace(\"dreamer\", \"\")",
"- s = s.replace(\"dream\", \"\")",
"- if len(s) != 0:",
"- return \"NO\"",
"+ words = [",
"+ \"dream\",",
"+ \"dreamer\",",
"+ \"erase\",",
"+ \"eraser\",",
"+ ]",
"+ while len(s) != 0:",
"+ flag = False",
"+ for w in words:",
"+ if s[-len(w) :] == w:",
"+ s = s[: -len(w)]",
"+ flag = True",
"+ break",
"+ if not flag:",
"+ return \"NO\""
] | false
| 0.048727
| 0.041918
| 1.162456
|
[
"s616693511",
"s844044381"
] |
u312025627
|
p03424
|
python
|
s508284590
|
s340890713
| 181
| 17
| 38,384
| 2,940
|
Accepted
|
Accepted
| 90.61
|
def main():
N = int(eval(input()))
A = [i for i in input().split()]
ans = ["Three", "Four"]
print((ans[0] if len(set(A)) == 3 else ans[1]))
if __name__ == '__main__':
main()
|
def main():
N = int(eval(input()))
A = {i for i in input().split()}
if "Y" in A:
print("Four")
else:
print("Three")
if __name__ == '__main__':
main()
| 9
| 11
| 196
| 192
|
def main():
N = int(eval(input()))
A = [i for i in input().split()]
ans = ["Three", "Four"]
print((ans[0] if len(set(A)) == 3 else ans[1]))
if __name__ == "__main__":
main()
|
def main():
N = int(eval(input()))
A = {i for i in input().split()}
if "Y" in A:
print("Four")
else:
print("Three")
if __name__ == "__main__":
main()
| false
| 18.181818
|
[
"- A = [i for i in input().split()]",
"- ans = [\"Three\", \"Four\"]",
"- print((ans[0] if len(set(A)) == 3 else ans[1]))",
"+ A = {i for i in input().split()}",
"+ if \"Y\" in A:",
"+ print(\"Four\")",
"+ else:",
"+ print(\"Three\")"
] | false
| 0.034765
| 0.066759
| 0.520755
|
[
"s508284590",
"s340890713"
] |
u871352270
|
p02767
|
python
|
s942376474
|
s521453177
| 184
| 167
| 39,536
| 38,768
|
Accepted
|
Accepted
| 9.24
|
N = int(eval(input()))
X = list(map(int, input().split()))
Min = 1e10
for p in range(1,101):
Min = min(Min,sum(list([(x-p)**2 for x in X])))
print(Min)
|
N = int(eval(input()))
X = list(map(int, input().split()))
Min = 1e10
for p in range(1,101):
Min = min(Min,sum([(x-p)**2 for x in X]))
print(Min)
| 6
| 6
| 159
| 153
|
N = int(eval(input()))
X = list(map(int, input().split()))
Min = 1e10
for p in range(1, 101):
Min = min(Min, sum(list([(x - p) ** 2 for x in X])))
print(Min)
|
N = int(eval(input()))
X = list(map(int, input().split()))
Min = 1e10
for p in range(1, 101):
Min = min(Min, sum([(x - p) ** 2 for x in X]))
print(Min)
| false
| 0
|
[
"- Min = min(Min, sum(list([(x - p) ** 2 for x in X])))",
"+ Min = min(Min, sum([(x - p) ** 2 for x in X]))"
] | false
| 0.03909
| 0.036369
| 1.074836
|
[
"s942376474",
"s521453177"
] |
u562016607
|
p03438
|
python
|
s924031745
|
s917351909
| 40
| 30
| 5,052
| 4,600
|
Accepted
|
Accepted
| 25
|
N = int(eval(input()))
st = input().split()
a = [0 for i in range(N)]
A = 0
for i in range(N):
a[i] = int(st[i])
A += a[i]
st = input().split()
b = [0 for i in range(N)]
B = 0
for i in range(N):
b[i] = int(st[i])
B += b[i]
def cost(n):
if n == 0:
return [0, 0]
elif n < 0:
return [0, -n]
elif n > 0 and n % 2 == 0:
return [n//2, 0]
else:
return [(n+1)//2, 1]
K = B - A
PC = 0
MC = 0
for i in range(N):
c = cost(b[i] - a[i])
PC += c[0]
MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
print("Yes")
else:
print("No")
|
N = int(eval(input()))
a = [int(i) for i in input().split()]
A = sum(a)
b = [int(i) for i in input().split()]
B = sum(b)
def cost(n):
if n == 0:
return [0, 0]
elif n < 0:
return [0, -n]
elif n > 0 and n % 2 == 0:
return [n//2, 0]
else:
return [(n+1)//2, 1]
K = B - A
PC = 0
MC = 0
for i in range(N):
c = cost(b[i] - a[i])
PC += c[0]
MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
print("Yes")
else:
print("No")
| 34
| 26
| 638
| 512
|
N = int(eval(input()))
st = input().split()
a = [0 for i in range(N)]
A = 0
for i in range(N):
a[i] = int(st[i])
A += a[i]
st = input().split()
b = [0 for i in range(N)]
B = 0
for i in range(N):
b[i] = int(st[i])
B += b[i]
def cost(n):
if n == 0:
return [0, 0]
elif n < 0:
return [0, -n]
elif n > 0 and n % 2 == 0:
return [n // 2, 0]
else:
return [(n + 1) // 2, 1]
K = B - A
PC = 0
MC = 0
for i in range(N):
c = cost(b[i] - a[i])
PC += c[0]
MC += c[1]
if PC <= K and MC <= K and ((K - PC) * 2 == (K - MC)):
print("Yes")
else:
print("No")
|
N = int(eval(input()))
a = [int(i) for i in input().split()]
A = sum(a)
b = [int(i) for i in input().split()]
B = sum(b)
def cost(n):
if n == 0:
return [0, 0]
elif n < 0:
return [0, -n]
elif n > 0 and n % 2 == 0:
return [n // 2, 0]
else:
return [(n + 1) // 2, 1]
K = B - A
PC = 0
MC = 0
for i in range(N):
c = cost(b[i] - a[i])
PC += c[0]
MC += c[1]
if PC <= K and MC <= K and ((K - PC) * 2 == (K - MC)):
print("Yes")
else:
print("No")
| false
| 23.529412
|
[
"-st = input().split()",
"-a = [0 for i in range(N)]",
"-A = 0",
"-for i in range(N):",
"- a[i] = int(st[i])",
"- A += a[i]",
"-st = input().split()",
"-b = [0 for i in range(N)]",
"-B = 0",
"-for i in range(N):",
"- b[i] = int(st[i])",
"- B += b[i]",
"+a = [int(i) for i in input().split()]",
"+A = sum(a)",
"+b = [int(i) for i in input().split()]",
"+B = sum(b)"
] | false
| 0.045908
| 0.046919
| 0.978446
|
[
"s924031745",
"s917351909"
] |
u796942881
|
p02759
|
python
|
s498820034
|
s059820041
| 20
| 17
| 3,060
| 2,940
|
Accepted
|
Accepted
| 15
|
def main():
N = int(eval(input()))
print(((N + 1) // 2))
return
main()
|
def main():
N = int(eval(input()))
print((-(-N // 2)))
return
main()
| 7
| 7
| 83
| 81
|
def main():
N = int(eval(input()))
print(((N + 1) // 2))
return
main()
|
def main():
N = int(eval(input()))
print((-(-N // 2)))
return
main()
| false
| 0
|
[
"- print(((N + 1) // 2))",
"+ print((-(-N // 2)))"
] | false
| 0.053251
| 0.052417
| 1.015915
|
[
"s498820034",
"s059820041"
] |
u072717685
|
p02606
|
python
|
s734158519
|
s446226866
| 27
| 23
| 9,056
| 9,152
|
Accepted
|
Accepted
| 14.81
|
import sys
read = sys.stdin.read
from itertools import accumulate
def main():
l, r, d = list(map(int, input().split()))
res = 0
for i1 in range(l, r + 1):
res += i1 % d == 0
print(res)
if __name__ == '__main__':
main()
|
def main():
l, r, d = list(map(int, input().split()))
res = r // d - (l-1) // d
print(res)
if __name__ == '__main__':
main()
| 14
| 7
| 256
| 142
|
import sys
read = sys.stdin.read
from itertools import accumulate
def main():
l, r, d = list(map(int, input().split()))
res = 0
for i1 in range(l, r + 1):
res += i1 % d == 0
print(res)
if __name__ == "__main__":
main()
|
def main():
l, r, d = list(map(int, input().split()))
res = r // d - (l - 1) // d
print(res)
if __name__ == "__main__":
main()
| false
| 50
|
[
"-import sys",
"-",
"-read = sys.stdin.read",
"-from itertools import accumulate",
"-",
"-",
"- res = 0",
"- for i1 in range(l, r + 1):",
"- res += i1 % d == 0",
"+ res = r // d - (l - 1) // d"
] | false
| 0.066265
| 0.047522
| 1.394403
|
[
"s734158519",
"s446226866"
] |
u374551537
|
p02725
|
python
|
s994086119
|
s728366758
| 184
| 115
| 28,100
| 26,444
|
Accepted
|
Accepted
| 37.5
|
List = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(0,List[1]):
A.append(A[i]+List[0])
D = []
for i in range(0,List[1]):
D.append(A[i+List[1]-1]-A[i])
print((min(D)))
|
List = list(map(int, input().split()))
A = list(map(int, input().split()))
D = []
for i in range(1,List[1]):
D.append(A[i]-A[i-1])
D.append(A[0]+List[0]-A[List[1]-1])
print((List[0]-max(D)))
| 11
| 10
| 223
| 204
|
List = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(0, List[1]):
A.append(A[i] + List[0])
D = []
for i in range(0, List[1]):
D.append(A[i + List[1] - 1] - A[i])
print((min(D)))
|
List = list(map(int, input().split()))
A = list(map(int, input().split()))
D = []
for i in range(1, List[1]):
D.append(A[i] - A[i - 1])
D.append(A[0] + List[0] - A[List[1] - 1])
print((List[0] - max(D)))
| false
| 9.090909
|
[
"-for i in range(0, List[1]):",
"- A.append(A[i] + List[0])",
"-for i in range(0, List[1]):",
"- D.append(A[i + List[1] - 1] - A[i])",
"-print((min(D)))",
"+for i in range(1, List[1]):",
"+ D.append(A[i] - A[i - 1])",
"+D.append(A[0] + List[0] - A[List[1] - 1])",
"+print((List[0] - max(D)))"
] | false
| 0.006916
| 0.068675
| 0.1007
|
[
"s994086119",
"s728366758"
] |
u955248595
|
p03828
|
python
|
s992604669
|
s168923655
| 40
| 35
| 9,476
| 9,212
|
Accepted
|
Accepted
| 12.5
|
from operator import mul
from functools import reduce
def PrimeDecomp(N,ConcFlag):
if ConcFlag:
if N<=1:
return [1],1
else:
I = 2
PrimeDec = []
DivCount = 1
while I*I<=N:
Cnt = 0
while N%I==0:
N //= I
PrimeDec.append(I)
DivCount *= (Cnt+1)
I += 1
if N>=2:
PrimeDec.append(N)
DivCount *= 2
return PrimeDec,DivCount
else:
if N<=1:
return [1],[1],1
else:
I = 2
PrimeDec = []
PrimeCnt = []
DivCount = 1
while I*I<=N:
Cnt = 0
while N%I==0:
N //= I
Cnt += 1
if Cnt>=1:
PrimeDec.append(I)
PrimeCnt.append(Cnt)
DivCount *= (Cnt+1)
I += 1
if N>=2:
PrimeDec.append(N)
PrimeCnt.append(1)
DivCount *= 2
return PrimeDec,PrimeCnt,DivCount
def DivisorFactorial(N,FactDec,FactCnt,MemoFlag):
if MemoFlag:
if N<=1:
FDivCnt = 1
return FactDec,FactCnt,FDivCnt
else:
PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)
for TP in range(0,len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = reduce(mul,[(T+1) for T in FactCnt])
return FactDec,FactCnt,FDivCnt
else:
if N<=1:
FDivCnt = 1
return FactDec,FactCnt,FDivCnt
else:
for TN in range(2,N+1):
PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)
for TP in range(0,len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = reduce(mul,[(T+1) for T in FactCnt])
return FactDec,FactCnt,FDivCnt
N = int(eval(input()))
FactDec,FactCnt,FDivCnt = DivisorFactorial(N,[],[],False)
print((FDivCnt%(10**9+7)))
|
def PrimeDecomp(N,ConcFlag):
if ConcFlag:
if N<=1:
return [1],1
else:
I = 2
PrimeDec = []
DivCount = 1
while I*I<=N:
Cnt = 0
while N%I==0:
N //= I
PrimeDec.append(I)
DivCount *= (Cnt+1)
I += 1
if N>=2:
PrimeDec.append(N)
DivCount *= 2
return PrimeDec,DivCount
else:
if N<=1:
return [1],[1],1
else:
I = 2
PrimeDec = []
PrimeCnt = []
DivCount = 1
while I*I<=N:
Cnt = 0
while N%I==0:
N //= I
Cnt += 1
if Cnt>=1:
PrimeDec.append(I)
PrimeCnt.append(Cnt)
DivCount *= (Cnt+1)
I += 1
if N>=2:
PrimeDec.append(N)
PrimeCnt.append(1)
DivCount *= 2
return PrimeDec,PrimeCnt,DivCount
def DivisorFactorial(N,FactDec,FactCnt,MemoFlag,Mod,ModFlag):
if MemoFlag:
if N<=1:
FDivCnt = 1
return FactDec,FactCnt,FDivCnt
else:
PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)
for TP in range(0,len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = 1
for TF in FactCnt:
FDivCnt = [FDivCnt*(TF+1),(FDivCnt*(TF+1))%Mod][ModFlag]
return FactDec,FactCnt,FDivCnt
else:
if N<=1:
FDivCnt = 1
return FactDec,FactCnt,FDivCnt
else:
for TN in range(2,N+1):
PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)
for TP in range(0,len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = 1
for TF in FactCnt:
FDivCnt = [FDivCnt*(TF+1),(FDivCnt*(TF+1))%Mod][ModFlag]
return FactDec,FactCnt,FDivCnt
FactDec,FactCnt,FDivCnt = DivisorFactorial(int(eval(input())),[],[],False,10**9+7,True)
print(FDivCnt)
| 79
| 79
| 2,619
| 2,701
|
from operator import mul
from functools import reduce
def PrimeDecomp(N, ConcFlag):
if ConcFlag:
if N <= 1:
return [1], 1
else:
I = 2
PrimeDec = []
DivCount = 1
while I * I <= N:
Cnt = 0
while N % I == 0:
N //= I
PrimeDec.append(I)
DivCount *= Cnt + 1
I += 1
if N >= 2:
PrimeDec.append(N)
DivCount *= 2
return PrimeDec, DivCount
else:
if N <= 1:
return [1], [1], 1
else:
I = 2
PrimeDec = []
PrimeCnt = []
DivCount = 1
while I * I <= N:
Cnt = 0
while N % I == 0:
N //= I
Cnt += 1
if Cnt >= 1:
PrimeDec.append(I)
PrimeCnt.append(Cnt)
DivCount *= Cnt + 1
I += 1
if N >= 2:
PrimeDec.append(N)
PrimeCnt.append(1)
DivCount *= 2
return PrimeDec, PrimeCnt, DivCount
def DivisorFactorial(N, FactDec, FactCnt, MemoFlag):
if MemoFlag:
if N <= 1:
FDivCnt = 1
return FactDec, FactCnt, FDivCnt
else:
PrimeDec, PrimeCnt, _ = PrimeDecomp(N, False)
for TP in range(0, len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = reduce(mul, [(T + 1) for T in FactCnt])
return FactDec, FactCnt, FDivCnt
else:
if N <= 1:
FDivCnt = 1
return FactDec, FactCnt, FDivCnt
else:
for TN in range(2, N + 1):
PrimeDec, PrimeCnt, _ = PrimeDecomp(TN, False)
for TP in range(0, len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = reduce(mul, [(T + 1) for T in FactCnt])
return FactDec, FactCnt, FDivCnt
N = int(eval(input()))
FactDec, FactCnt, FDivCnt = DivisorFactorial(N, [], [], False)
print((FDivCnt % (10**9 + 7)))
|
def PrimeDecomp(N, ConcFlag):
if ConcFlag:
if N <= 1:
return [1], 1
else:
I = 2
PrimeDec = []
DivCount = 1
while I * I <= N:
Cnt = 0
while N % I == 0:
N //= I
PrimeDec.append(I)
DivCount *= Cnt + 1
I += 1
if N >= 2:
PrimeDec.append(N)
DivCount *= 2
return PrimeDec, DivCount
else:
if N <= 1:
return [1], [1], 1
else:
I = 2
PrimeDec = []
PrimeCnt = []
DivCount = 1
while I * I <= N:
Cnt = 0
while N % I == 0:
N //= I
Cnt += 1
if Cnt >= 1:
PrimeDec.append(I)
PrimeCnt.append(Cnt)
DivCount *= Cnt + 1
I += 1
if N >= 2:
PrimeDec.append(N)
PrimeCnt.append(1)
DivCount *= 2
return PrimeDec, PrimeCnt, DivCount
def DivisorFactorial(N, FactDec, FactCnt, MemoFlag, Mod, ModFlag):
if MemoFlag:
if N <= 1:
FDivCnt = 1
return FactDec, FactCnt, FDivCnt
else:
PrimeDec, PrimeCnt, _ = PrimeDecomp(N, False)
for TP in range(0, len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = 1
for TF in FactCnt:
FDivCnt = [FDivCnt * (TF + 1), (FDivCnt * (TF + 1)) % Mod][ModFlag]
return FactDec, FactCnt, FDivCnt
else:
if N <= 1:
FDivCnt = 1
return FactDec, FactCnt, FDivCnt
else:
for TN in range(2, N + 1):
PrimeDec, PrimeCnt, _ = PrimeDecomp(TN, False)
for TP in range(0, len(PrimeDec)):
if PrimeDec[TP] in set(FactDec):
FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]
else:
FactDec.append(PrimeDec[TP])
FactCnt.append(PrimeCnt[TP])
FDivCnt = 1
for TF in FactCnt:
FDivCnt = [FDivCnt * (TF + 1), (FDivCnt * (TF + 1)) % Mod][ModFlag]
return FactDec, FactCnt, FDivCnt
FactDec, FactCnt, FDivCnt = DivisorFactorial(
int(eval(input())), [], [], False, 10**9 + 7, True
)
print(FDivCnt)
| false
| 0
|
[
"-from operator import mul",
"-from functools import reduce",
"-",
"-",
"-def DivisorFactorial(N, FactDec, FactCnt, MemoFlag):",
"+def DivisorFactorial(N, FactDec, FactCnt, MemoFlag, Mod, ModFlag):",
"- FDivCnt = reduce(mul, [(T + 1) for T in FactCnt])",
"+ FDivCnt = 1",
"+ for TF in FactCnt:",
"+ FDivCnt = [FDivCnt * (TF + 1), (FDivCnt * (TF + 1)) % Mod][ModFlag]",
"- FDivCnt = reduce(mul, [(T + 1) for T in FactCnt])",
"+ FDivCnt = 1",
"+ for TF in FactCnt:",
"+ FDivCnt = [FDivCnt * (TF + 1), (FDivCnt * (TF + 1)) % Mod][ModFlag]",
"-N = int(eval(input()))",
"-FactDec, FactCnt, FDivCnt = DivisorFactorial(N, [], [], False)",
"-print((FDivCnt % (10**9 + 7)))",
"+FactDec, FactCnt, FDivCnt = DivisorFactorial(",
"+ int(eval(input())), [], [], False, 10**9 + 7, True",
"+)",
"+print(FDivCnt)"
] | false
| 0.051561
| 0.05142
| 1.002752
|
[
"s992604669",
"s168923655"
] |
u365686736
|
p02396
|
python
|
s527663453
|
s784333727
| 70
| 50
| 6,256
| 5,676
|
Accepted
|
Accepted
| 28.57
|
a=[]
b=eval(input())
while b!="0":
a.append(b)
b=eval(input())
for c in range(len(a)):print(("Case "+str(c+1)+": "+ a[c]))
|
import sys
a=1
for b in sys.stdin:
b=b.strip()
if b=='0':break
print(f'Case {a}: {b}')
a+=1
| 6
| 7
| 126
| 101
|
a = []
b = eval(input())
while b != "0":
a.append(b)
b = eval(input())
for c in range(len(a)):
print(("Case " + str(c + 1) + ": " + a[c]))
|
import sys
a = 1
for b in sys.stdin:
b = b.strip()
if b == "0":
break
print(f"Case {a}: {b}")
a += 1
| false
| 14.285714
|
[
"-a = []",
"-b = eval(input())",
"-while b != \"0\":",
"- a.append(b)",
"- b = eval(input())",
"-for c in range(len(a)):",
"- print((\"Case \" + str(c + 1) + \": \" + a[c]))",
"+import sys",
"+",
"+a = 1",
"+for b in sys.stdin:",
"+ b = b.strip()",
"+ if b == \"0\":",
"+ break",
"+ print(f\"Case {a}: {b}\")",
"+ a += 1"
] | false
| 0.035897
| 0.037332
| 0.961547
|
[
"s527663453",
"s784333727"
] |
u425762225
|
p02767
|
python
|
s900663892
|
s085796499
| 182
| 32
| 38,512
| 9,112
|
Accepted
|
Accepted
| 82.42
|
N = int(eval(input()))
x = list(map(int,input().split()))
l=[]
for p in range(1,101):
sum=0
for i in range(N):
sum += (x[i]-p)**2
l.append(sum)
print((sorted(l)[0]))
|
#!/usr/bin/env python3
# from numba import njit
# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left
INF = pow(10,6)
# @njit
def solve(n,a):
res = INF
for i in range(1,101):
res = min(res,sum(pow(i-x,2) for x in a))
return res
def main():
N = int(eval(input()))
# N,M = map(int,input().split())
a = list(map(int,input().split()))
print((solve(N,a)))
return
if __name__ == '__main__':
main()
| 14
| 30
| 191
| 549
|
N = int(eval(input()))
x = list(map(int, input().split()))
l = []
for p in range(1, 101):
sum = 0
for i in range(N):
sum += (x[i] - p) ** 2
l.append(sum)
print((sorted(l)[0]))
|
#!/usr/bin/env python3
# from numba import njit
# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left
INF = pow(10, 6)
# @njit
def solve(n, a):
res = INF
for i in range(1, 101):
res = min(res, sum(pow(i - x, 2) for x in a))
return res
def main():
N = int(eval(input()))
# N,M = map(int,input().split())
a = list(map(int, input().split()))
print((solve(N, a)))
return
if __name__ == "__main__":
main()
| false
| 53.333333
|
[
"-N = int(eval(input()))",
"-x = list(map(int, input().split()))",
"-l = []",
"-for p in range(1, 101):",
"- sum = 0",
"- for i in range(N):",
"- sum += (x[i] - p) ** 2",
"- l.append(sum)",
"-print((sorted(l)[0]))",
"+#!/usr/bin/env python3",
"+# from numba import njit",
"+# from collections import Counter",
"+# from itertools import accumulate",
"+# import numpy as np",
"+# from heapq import heappop,heappush",
"+# from bisect import bisect_left",
"+INF = pow(10, 6)",
"+# @njit",
"+def solve(n, a):",
"+ res = INF",
"+ for i in range(1, 101):",
"+ res = min(res, sum(pow(i - x, 2) for x in a))",
"+ return res",
"+",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ # N,M = map(int,input().split())",
"+ a = list(map(int, input().split()))",
"+ print((solve(N, a)))",
"+ return",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false
| 0.007885
| 0.041546
| 0.189795
|
[
"s900663892",
"s085796499"
] |
u777283665
|
p03017
|
python
|
s381006097
|
s764539985
| 50
| 32
| 3,572
| 3,572
|
Accepted
|
Accepted
| 36
|
n, a, b, c, d = list(map(int, input().split()))
a, b, c, d = a-1, b-1, c-1, d-1
s = eval(input())
if "##" in s[a:d]:
print("No")
exit()
if c < d:
for i in range(b, d):
if s[i:i+2] == "##":
print("No")
exit()
print("Yes")
else:
for i in range(b, d+1):
if s[i] != "#" and s[i-1] == "." and s[i+1] == ".":
print("Yes")
exit()
print("No")
|
n, a, b, c, d = list(map(int, input().split()))
a, b, c, d = a-1, b-1, c-1, d-1
s = eval(input())
if c < d:
if "##" in s[a:d]:
print("No")
exit()
print("Yes")
else:
for i in range(b, d+1):
if s[i] != "#" and s[i-1] == "." and s[i+1] == ".":
print("Yes")
exit()
print("No")
| 23
| 18
| 437
| 345
|
n, a, b, c, d = list(map(int, input().split()))
a, b, c, d = a - 1, b - 1, c - 1, d - 1
s = eval(input())
if "##" in s[a:d]:
print("No")
exit()
if c < d:
for i in range(b, d):
if s[i : i + 2] == "##":
print("No")
exit()
print("Yes")
else:
for i in range(b, d + 1):
if s[i] != "#" and s[i - 1] == "." and s[i + 1] == ".":
print("Yes")
exit()
print("No")
|
n, a, b, c, d = list(map(int, input().split()))
a, b, c, d = a - 1, b - 1, c - 1, d - 1
s = eval(input())
if c < d:
if "##" in s[a:d]:
print("No")
exit()
print("Yes")
else:
for i in range(b, d + 1):
if s[i] != "#" and s[i - 1] == "." and s[i + 1] == ".":
print("Yes")
exit()
print("No")
| false
| 21.73913
|
[
"-if \"##\" in s[a:d]:",
"- print(\"No\")",
"- exit()",
"- for i in range(b, d):",
"- if s[i : i + 2] == \"##\":",
"- print(\"No\")",
"- exit()",
"+ if \"##\" in s[a:d]:",
"+ print(\"No\")",
"+ exit()"
] | false
| 0.044157
| 0.043448
| 1.016309
|
[
"s381006097",
"s764539985"
] |
u761087127
|
p02773
|
python
|
s342856533
|
s694057022
| 607
| 515
| 35,816
| 37,488
|
Accepted
|
Accepted
| 15.16
|
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k,v in c.items() if m==v])
[print(k) for k in ans]
|
from collections import Counter
N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k,v in list(c.items()) if m==v])
print(('\n'.join(ans)))
| 8
| 8
| 194
| 193
|
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k, v in c.items() if m == v])
[print(k) for k in ans]
|
from collections import Counter
N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k, v in list(c.items()) if m == v])
print(("\n".join(ans)))
| false
| 0
|
[
"-N = int(input())",
"-S = [input() for _ in range(N)]",
"+N = int(eval(input()))",
"+S = [eval(input()) for _ in range(N)]",
"-ans = sorted([k for k, v in c.items() if m == v])",
"-[print(k) for k in ans]",
"+ans = sorted([k for k, v in list(c.items()) if m == v])",
"+print((\"\\n\".join(ans)))"
] | false
| 0.044037
| 0.048301
| 0.911719
|
[
"s342856533",
"s694057022"
] |
u887207211
|
p03309
|
python
|
s964358334
|
s976672899
| 235
| 192
| 26,132
| 27,580
|
Accepted
|
Accepted
| 18.3
|
N = int(eval(input()))
A = list(map(int,input().split()))
tmp = []
for i in range(N):
tmp.append(A[i] - (i+1))
tmp.sort()
mid = tmp[int(N/2)]
ans = 0
for i in range(N):
ans += abs(tmp[i] - mid)
print(ans)
|
N = int(eval(input()))
A = list(map(int,input().split()))
tmp = sorted([A[i-1] - i for i in range(1, N+1)])
mid = tmp[int(N/2)]
print((sum([abs(t - mid) for t in tmp])))
| 11
| 5
| 212
| 165
|
N = int(eval(input()))
A = list(map(int, input().split()))
tmp = []
for i in range(N):
tmp.append(A[i] - (i + 1))
tmp.sort()
mid = tmp[int(N / 2)]
ans = 0
for i in range(N):
ans += abs(tmp[i] - mid)
print(ans)
|
N = int(eval(input()))
A = list(map(int, input().split()))
tmp = sorted([A[i - 1] - i for i in range(1, N + 1)])
mid = tmp[int(N / 2)]
print((sum([abs(t - mid) for t in tmp])))
| false
| 54.545455
|
[
"-tmp = []",
"-for i in range(N):",
"- tmp.append(A[i] - (i + 1))",
"-tmp.sort()",
"+tmp = sorted([A[i - 1] - i for i in range(1, N + 1)])",
"-ans = 0",
"-for i in range(N):",
"- ans += abs(tmp[i] - mid)",
"-print(ans)",
"+print((sum([abs(t - mid) for t in tmp])))"
] | false
| 0.068271
| 0.045154
| 1.511959
|
[
"s964358334",
"s976672899"
] |
u017415492
|
p03062
|
python
|
s035788219
|
s661136553
| 130
| 78
| 14,412
| 19,916
|
Accepted
|
Accepted
| 40
|
n=int(eval(input()))
d=list(map(int,input().split()))
k=[]
t=0
ans=0
for i in range(n):
ans+=abs(d[i])
if d[i]<=0:
t+=1
for i in range(len(d)):
k.append(abs(d[i]))
k.sort()
if t%2:
ans-=2*k[0]
print(ans)
|
n=int(eval(input()))
a=list(map(int,input().split()))
count=0
ans=[]
for i in range(n):
ans.append(abs(a[i]))
if a[i]<0:
count+=1
if count%2==0:
print((sum(ans)))
else:
print((sum(ans)-2*min(ans)))
| 15
| 14
| 223
| 216
|
n = int(eval(input()))
d = list(map(int, input().split()))
k = []
t = 0
ans = 0
for i in range(n):
ans += abs(d[i])
if d[i] <= 0:
t += 1
for i in range(len(d)):
k.append(abs(d[i]))
k.sort()
if t % 2:
ans -= 2 * k[0]
print(ans)
|
n = int(eval(input()))
a = list(map(int, input().split()))
count = 0
ans = []
for i in range(n):
ans.append(abs(a[i]))
if a[i] < 0:
count += 1
if count % 2 == 0:
print((sum(ans)))
else:
print((sum(ans) - 2 * min(ans)))
| false
| 6.666667
|
[
"-d = list(map(int, input().split()))",
"-k = []",
"-t = 0",
"-ans = 0",
"+a = list(map(int, input().split()))",
"+count = 0",
"+ans = []",
"- ans += abs(d[i])",
"- if d[i] <= 0:",
"- t += 1",
"-for i in range(len(d)):",
"- k.append(abs(d[i]))",
"-k.sort()",
"-if t % 2:",
"- ans -= 2 * k[0]",
"-print(ans)",
"+ ans.append(abs(a[i]))",
"+ if a[i] < 0:",
"+ count += 1",
"+if count % 2 == 0:",
"+ print((sum(ans)))",
"+else:",
"+ print((sum(ans) - 2 * min(ans)))"
] | false
| 0.047497
| 0.044205
| 1.074476
|
[
"s035788219",
"s661136553"
] |
u327466606
|
p03608
|
python
|
s879136561
|
s129953058
| 798
| 540
| 24,512
| 17,892
|
Accepted
|
Accepted
| 32.33
|
N,M,NR = list(map(int,input().split()))
R = list([int(x) - 1 for x in input().split()])
import scipy.sparse as ss
import numpy as np
G = ss.dok_matrix((N,N), dtype=np.uint32)
def it():
for _ in range(M):
a,b,c = list(map(int,input().split()))
a -= 1
b -= 1
yield ((a,b),c)
yield ((b,a),c)
G.update(it())
D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False)
def it2():
from itertools import permutations
for p in permutations(R):
pp = iter(p)
next(pp)
yield sum(D[a,b] for a,b in zip(p,pp))
print((int(min(it2()))))
|
N,M,NR = list(map(int,input().split()))
R = list([int(x) - 1 for x in input().split()])
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
G = np.zeros((N,N))
for _ in range(M):
a,b,c = list(map(int,input().split()))
G[a-1,b-1] = c
floyd_warshall(G, directed=False, overwrite=True)
def it2():
from itertools import permutations
for p in permutations(R):
pp = iter(p)
next(pp)
yield sum(G[a,b] for a,b in zip(p,pp))
print((int(min(it2()))))
| 29
| 23
| 583
| 495
|
N, M, NR = list(map(int, input().split()))
R = list([int(x) - 1 for x in input().split()])
import scipy.sparse as ss
import numpy as np
G = ss.dok_matrix((N, N), dtype=np.uint32)
def it():
for _ in range(M):
a, b, c = list(map(int, input().split()))
a -= 1
b -= 1
yield ((a, b), c)
yield ((b, a), c)
G.update(it())
D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False)
def it2():
from itertools import permutations
for p in permutations(R):
pp = iter(p)
next(pp)
yield sum(D[a, b] for a, b in zip(p, pp))
print((int(min(it2()))))
|
N, M, NR = list(map(int, input().split()))
R = list([int(x) - 1 for x in input().split()])
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
G = np.zeros((N, N))
for _ in range(M):
a, b, c = list(map(int, input().split()))
G[a - 1, b - 1] = c
floyd_warshall(G, directed=False, overwrite=True)
def it2():
from itertools import permutations
for p in permutations(R):
pp = iter(p)
next(pp)
yield sum(G[a, b] for a, b in zip(p, pp))
print((int(min(it2()))))
| false
| 20.689655
|
[
"-import scipy.sparse as ss",
"+from scipy.sparse.csgraph import floyd_warshall",
"-G = ss.dok_matrix((N, N), dtype=np.uint32)",
"-",
"-",
"-def it():",
"- for _ in range(M):",
"- a, b, c = list(map(int, input().split()))",
"- a -= 1",
"- b -= 1",
"- yield ((a, b), c)",
"- yield ((b, a), c)",
"-",
"-",
"-G.update(it())",
"-D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False)",
"+G = np.zeros((N, N))",
"+for _ in range(M):",
"+ a, b, c = list(map(int, input().split()))",
"+ G[a - 1, b - 1] = c",
"+floyd_warshall(G, directed=False, overwrite=True)",
"- yield sum(D[a, b] for a, b in zip(p, pp))",
"+ yield sum(G[a, b] for a, b in zip(p, pp))"
] | false
| 0.692332
| 0.334539
| 2.06951
|
[
"s879136561",
"s129953058"
] |
u623231048
|
p03240
|
python
|
s360599187
|
s333293913
| 2,908
| 31
| 3,064
| 3,064
|
Accepted
|
Accepted
| 98.93
|
n = int(eval(input()))
li = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
if li[i][2] != 0:
h1 = li[i][2]
break
flag = True
flag2 = False
for i in range(10**9):
if flag2 == True: break
for X in range(101):
for Y in range(101):
h = h1 + i
flag = True
for j in range(n):
if max(h - abs(li[j][0]-X) - abs(li[j][1]-Y),0) != li[j][2]:
flag = False
break
if flag == True:
print((X,Y,h))
flag2 = True
if flag2 == True: break
h = h1 - i
flag = True
for j in range(n):
if max(h - abs(li[j][0]-X) - abs(li[j][1]-Y),0) != li[j][2]:
flag = False
break
if flag == True:
print((X,Y,h))
flag2 = True
|
n = int(eval(input()))
li = [list(map(int,input().split())) for i in range(n)]
li.sort(key=lambda x: x[2])
a,b,c = li[-1]
for x in range(101):
for y in range(101):
h = abs(x-a) + abs(y-b) + c
if all(k == max(h-abs(x-i)-abs(y-j),0) for i,j,k in li):
print((x,y,h))
exit()
| 34
| 11
| 955
| 318
|
n = int(eval(input()))
li = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
if li[i][2] != 0:
h1 = li[i][2]
break
flag = True
flag2 = False
for i in range(10**9):
if flag2 == True:
break
for X in range(101):
for Y in range(101):
h = h1 + i
flag = True
for j in range(n):
if max(h - abs(li[j][0] - X) - abs(li[j][1] - Y), 0) != li[j][2]:
flag = False
break
if flag == True:
print((X, Y, h))
flag2 = True
if flag2 == True:
break
h = h1 - i
flag = True
for j in range(n):
if max(h - abs(li[j][0] - X) - abs(li[j][1] - Y), 0) != li[j][2]:
flag = False
break
if flag == True:
print((X, Y, h))
flag2 = True
|
n = int(eval(input()))
li = [list(map(int, input().split())) for i in range(n)]
li.sort(key=lambda x: x[2])
a, b, c = li[-1]
for x in range(101):
for y in range(101):
h = abs(x - a) + abs(y - b) + c
if all(k == max(h - abs(x - i) - abs(y - j), 0) for i, j, k in li):
print((x, y, h))
exit()
| false
| 67.647059
|
[
"-for i in range(n):",
"- if li[i][2] != 0:",
"- h1 = li[i][2]",
"- break",
"-flag = True",
"-flag2 = False",
"-for i in range(10**9):",
"- if flag2 == True:",
"- break",
"- for X in range(101):",
"- for Y in range(101):",
"- h = h1 + i",
"- flag = True",
"- for j in range(n):",
"- if max(h - abs(li[j][0] - X) - abs(li[j][1] - Y), 0) != li[j][2]:",
"- flag = False",
"- break",
"- if flag == True:",
"- print((X, Y, h))",
"- flag2 = True",
"- if flag2 == True:",
"- break",
"- h = h1 - i",
"- flag = True",
"- for j in range(n):",
"- if max(h - abs(li[j][0] - X) - abs(li[j][1] - Y), 0) != li[j][2]:",
"- flag = False",
"- break",
"- if flag == True:",
"- print((X, Y, h))",
"- flag2 = True",
"+li.sort(key=lambda x: x[2])",
"+a, b, c = li[-1]",
"+for x in range(101):",
"+ for y in range(101):",
"+ h = abs(x - a) + abs(y - b) + c",
"+ if all(k == max(h - abs(x - i) - abs(y - j), 0) for i, j, k in li):",
"+ print((x, y, h))",
"+ exit()"
] | false
| 0.09115
| 0.047142
| 1.93351
|
[
"s360599187",
"s333293913"
] |
u375695365
|
p02995
|
python
|
s626267486
|
s875269265
| 57
| 35
| 5,560
| 5,048
|
Accepted
|
Accepted
| 38.6
|
import fractions
a,b,c,d=list(map(int,input().split()))
x1=b//c-(a-1)//c #cの割れるやつ
x2=b//d-(a-1)//d #dの割れるやつ
sks=c * d // fractions.gcd(c,d)#最小公倍数 普通ならmathメソッドにある
x3=b//sks-(a-1)//sks#c*dの割れるやつ
ans=b-a+1-(x1+x2-x3)
print (ans)
|
#二回目
import fractions
a,b,c,d=list(map(int,input().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
ans1=b
a-=1
ans2=0
ans1-=b//c
ans1-=b//d
ans1+=b//(lcm(c,d))
#print(ans1)
ans2+=a//c
ans2+=a//d
ans2-=a//(lcm(c,d))
print((ans1-(a-ans2)))
| 8
| 20
| 227
| 271
|
import fractions
a, b, c, d = list(map(int, input().split()))
x1 = b // c - (a - 1) // c # cの割れるやつ
x2 = b // d - (a - 1) // d # dの割れるやつ
sks = c * d // fractions.gcd(c, d) # 最小公倍数 普通ならmathメソッドにある
x3 = b // sks - (a - 1) // sks # c*dの割れるやつ
ans = b - a + 1 - (x1 + x2 - x3)
print(ans)
|
# 二回目
import fractions
a, b, c, d = list(map(int, input().split()))
def lcm(x, y):
return (x * y) // fractions.gcd(x, y)
ans1 = b
a -= 1
ans2 = 0
ans1 -= b // c
ans1 -= b // d
ans1 += b // (lcm(c, d))
# print(ans1)
ans2 += a // c
ans2 += a // d
ans2 -= a // (lcm(c, d))
print((ans1 - (a - ans2)))
| false
| 60
|
[
"+# 二回目",
"-x1 = b // c - (a - 1) // c # cの割れるやつ",
"-x2 = b // d - (a - 1) // d # dの割れるやつ",
"-sks = c * d // fractions.gcd(c, d) # 最小公倍数 普通ならmathメソッドにある",
"-x3 = b // sks - (a - 1) // sks # c*dの割れるやつ",
"-ans = b - a + 1 - (x1 + x2 - x3)",
"-print(ans)",
"+",
"+",
"+def lcm(x, y):",
"+ return (x * y) // fractions.gcd(x, y)",
"+",
"+",
"+ans1 = b",
"+a -= 1",
"+ans2 = 0",
"+ans1 -= b // c",
"+ans1 -= b // d",
"+ans1 += b // (lcm(c, d))",
"+# print(ans1)",
"+ans2 += a // c",
"+ans2 += a // d",
"+ans2 -= a // (lcm(c, d))",
"+print((ans1 - (a - ans2)))"
] | false
| 0.05878
| 0.13297
| 0.44205
|
[
"s626267486",
"s875269265"
] |
u218834617
|
p02570
|
python
|
s766716549
|
s629217465
| 69
| 59
| 61,200
| 61,540
|
Accepted
|
Accepted
| 14.49
|
d,t,s=list(map(int,input().split()))
print(('Yes' if d/s<=t else 'No'))
|
d,t,s=list(map(int,input().split()))
print(('Yes' if s*t>=d else 'No'))
| 2
| 2
| 65
| 65
|
d, t, s = list(map(int, input().split()))
print(("Yes" if d / s <= t else "No"))
|
d, t, s = list(map(int, input().split()))
print(("Yes" if s * t >= d else "No"))
| false
| 0
|
[
"-print((\"Yes\" if d / s <= t else \"No\"))",
"+print((\"Yes\" if s * t >= d else \"No\"))"
] | false
| 0.04065
| 0.036807
| 1.10443
|
[
"s766716549",
"s629217465"
] |
u619631862
|
p03292
|
python
|
s910099124
|
s623990399
| 190
| 165
| 38,496
| 38,384
|
Accepted
|
Accepted
| 13.16
|
def i1():
return int(eval(input()))
def i2():
return [int(i) for i in input().split()]
a=i2()
a.sort()
a=a[::-1]
print((a[0]-a[2]))
|
def i1():
return int(eval(input()))
def i2():
return [int(i) for i in input().split()]
a=i2()
b=[]
a.sort()
print((abs(a[0]-a[1])+abs(a[2]-a[1])))
| 8
| 8
| 132
| 148
|
def i1():
return int(eval(input()))
def i2():
return [int(i) for i in input().split()]
a = i2()
a.sort()
a = a[::-1]
print((a[0] - a[2]))
|
def i1():
return int(eval(input()))
def i2():
return [int(i) for i in input().split()]
a = i2()
b = []
a.sort()
print((abs(a[0] - a[1]) + abs(a[2] - a[1])))
| false
| 0
|
[
"+b = []",
"-a = a[::-1]",
"-print((a[0] - a[2]))",
"+print((abs(a[0] - a[1]) + abs(a[2] - a[1])))"
] | false
| 0.145609
| 0.123087
| 1.182982
|
[
"s910099124",
"s623990399"
] |
u544050502
|
p03543
|
python
|
s966907413
|
s841608038
| 19
| 17
| 2,940
| 2,940
|
Accepted
|
Accepted
| 10.53
|
N=eval(input())
answer="No"
for i in range(len(N)-2):
if N[i]==N[i+1]:
if N[i+1]==N[i+2]:
answer="Yes"
print(answer)
|
N=eval(input())
print(("Yes" if (N[0]==N[1]==N[2])or(N[1]==N[2]==N[3]) else "No" ))
| 7
| 2
| 128
| 76
|
N = eval(input())
answer = "No"
for i in range(len(N) - 2):
if N[i] == N[i + 1]:
if N[i + 1] == N[i + 2]:
answer = "Yes"
print(answer)
|
N = eval(input())
print(("Yes" if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]) else "No"))
| false
| 71.428571
|
[
"-answer = \"No\"",
"-for i in range(len(N) - 2):",
"- if N[i] == N[i + 1]:",
"- if N[i + 1] == N[i + 2]:",
"- answer = \"Yes\"",
"-print(answer)",
"+print((\"Yes\" if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]) else \"No\"))"
] | false
| 0.044942
| 0.044662
| 1.006281
|
[
"s966907413",
"s841608038"
] |
u256256172
|
p02416
|
python
|
s143471884
|
s257654986
| 60
| 20
| 7,660
| 7,648
|
Accepted
|
Accepted
| 66.67
|
while True:
n = list(eval(input()))
if n[0] == '0':
break
sum = 0
for i in n:
sum += int(i)
print(sum)
|
while True:
n = eval(input())
if n == '0':
break
sum = 0
for i in n:
sum += int(i)
print(sum)
| 8
| 8
| 139
| 130
|
while True:
n = list(eval(input()))
if n[0] == "0":
break
sum = 0
for i in n:
sum += int(i)
print(sum)
|
while True:
n = eval(input())
if n == "0":
break
sum = 0
for i in n:
sum += int(i)
print(sum)
| false
| 0
|
[
"- n = list(eval(input()))",
"- if n[0] == \"0\":",
"+ n = eval(input())",
"+ if n == \"0\":"
] | false
| 0.043965
| 0.039224
| 1.120865
|
[
"s143471884",
"s257654986"
] |
u562935282
|
p02755
|
python
|
s069821825
|
s575243768
| 22
| 17
| 3,064
| 3,060
|
Accepted
|
Accepted
| 22.73
|
def main():
A, B = list(map(int, input().split()))
for x in range(10000):
if int(x * 0.08) == A and int(x * 0.1) == B:
print(x)
return
print((-1))
if __name__ == '__main__':
main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
|
def main():
from math import ceil
A, B = list(map(int, input().split()))
la, ra = ceil(A * 12.5), ceil((A + 1) * 12.5)
lb, rb = B * 10, (B + 1) * 10
L, R = max(la, lb), min(ra, rb) # [L,R)
if L >= R:
print((-1))
return
print(L)
if __name__ == '__main__':
main()
| 22
| 19
| 380
| 328
|
def main():
A, B = list(map(int, input().split()))
for x in range(10000):
if int(x * 0.08) == A and int(x * 0.1) == B:
print(x)
return
print((-1))
if __name__ == "__main__":
main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
|
def main():
from math import ceil
A, B = list(map(int, input().split()))
la, ra = ceil(A * 12.5), ceil((A + 1) * 12.5)
lb, rb = B * 10, (B + 1) * 10
L, R = max(la, lb), min(ra, rb) # [L,R)
if L >= R:
print((-1))
return
print(L)
if __name__ == "__main__":
main()
| false
| 13.636364
|
[
"+ from math import ceil",
"+",
"- for x in range(10000):",
"- if int(x * 0.08) == A and int(x * 0.1) == B:",
"- print(x)",
"- return",
"- print((-1))",
"+ la, ra = ceil(A * 12.5), ceil((A + 1) * 12.5)",
"+ lb, rb = B * 10, (B + 1) * 10",
"+ L, R = max(la, lb), min(ra, rb) # [L,R)",
"+ if L >= R:",
"+ print((-1))",
"+ return",
"+ print(L)",
"-# import sys",
"-#",
"-# sys.setrecursionlimit(10 ** 7)",
"-#",
"-# input = sys.stdin.readline",
"-# rstrip()",
"-# int(input())",
"-# map(int, input().split())"
] | false
| 0.042703
| 0.03683
| 1.159465
|
[
"s069821825",
"s575243768"
] |
u608088992
|
p03037
|
python
|
s434079804
|
s490104449
| 206
| 160
| 7,436
| 6,900
|
Accepted
|
Accepted
| 22.33
|
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
a, b = max(a, b), min(a, b)
while a % b > 0: a, b = b, a % b
return b
def solve():
N, M = list(map(int, line_input()))
gate = [0 for n in range(N+1)]
for i in range(M):
l, r = list(map(int, line_input()))
gate[l-1] += 1
gate[r] -= 1
ans = (1 if gate[0] == M else 0)
for i in range(1, N):
gate[i] = gate[i] + gate[i-1]
if gate[i] == M: ans += 1
print(ans)
return 0
if __name__ == "__main__":
solve()
|
import sys
def solve():
input = sys.stdin.readline
N, M = list(map(int, input().split()))
count = [0] * (N + 1)
for _ in range(M):
l, r = list(map(int, input().split()))
count[l - 1] += 1
count[r] -= 1
ans = (1 if count[0] == M else 0)
for i in range(1, N):
count[i] += count[i - 1]
if count[i] == M: ans += 1
print(ans)
return 0
if __name__ =="__main__":
solve()
| 25
| 20
| 687
| 449
|
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input():
return F.readline().strip("\n")
def line_input():
return F.readline().strip("\n").split()
def gcd(a, b):
a, b = max(a, b), min(a, b)
while a % b > 0:
a, b = b, a % b
return b
def solve():
N, M = list(map(int, line_input()))
gate = [0 for n in range(N + 1)]
for i in range(M):
l, r = list(map(int, line_input()))
gate[l - 1] += 1
gate[r] -= 1
ans = 1 if gate[0] == M else 0
for i in range(1, N):
gate[i] = gate[i] + gate[i - 1]
if gate[i] == M:
ans += 1
print(ans)
return 0
if __name__ == "__main__":
solve()
|
import sys
def solve():
input = sys.stdin.readline
N, M = list(map(int, input().split()))
count = [0] * (N + 1)
for _ in range(M):
l, r = list(map(int, input().split()))
count[l - 1] += 1
count[r] -= 1
ans = 1 if count[0] == M else 0
for i in range(1, N):
count[i] += count[i - 1]
if count[i] == M:
ans += 1
print(ans)
return 0
if __name__ == "__main__":
solve()
| false
| 20
|
[
"-import sys, math, collections, heapq, itertools",
"-",
"-F = sys.stdin",
"-",
"-",
"-def single_input():",
"- return F.readline().strip(\"\\n\")",
"-",
"-",
"-def line_input():",
"- return F.readline().strip(\"\\n\").split()",
"-",
"-",
"-def gcd(a, b):",
"- a, b = max(a, b), min(a, b)",
"- while a % b > 0:",
"- a, b = b, a % b",
"- return b",
"+import sys",
"- N, M = list(map(int, line_input()))",
"- gate = [0 for n in range(N + 1)]",
"- for i in range(M):",
"- l, r = list(map(int, line_input()))",
"- gate[l - 1] += 1",
"- gate[r] -= 1",
"- ans = 1 if gate[0] == M else 0",
"+ input = sys.stdin.readline",
"+ N, M = list(map(int, input().split()))",
"+ count = [0] * (N + 1)",
"+ for _ in range(M):",
"+ l, r = list(map(int, input().split()))",
"+ count[l - 1] += 1",
"+ count[r] -= 1",
"+ ans = 1 if count[0] == M else 0",
"- gate[i] = gate[i] + gate[i - 1]",
"- if gate[i] == M:",
"+ count[i] += count[i - 1]",
"+ if count[i] == M:"
] | false
| 0.046753
| 0.058314
| 0.80176
|
[
"s434079804",
"s490104449"
] |
u314188085
|
p02873
|
python
|
s730370126
|
s736526805
| 323
| 278
| 29,056
| 28,916
|
Accepted
|
Accepted
| 13.93
|
S = eval(input())
n = [0]*(len(S)+1)
if S[0]=='<':
n[0]==0
if S[-1]=='>':
n[-1]==0
for i in range(1,len(S)):
if S[i-1]=='<' and S[i]=='<':
n[i] = n[i-1]+1
n[i+1]=n[i]+1
elif S[i-1]=='>' and S[i]=='<':
n[i] = 0
n[i+1]=1
for i in range(len(S)-1,-1,-1):
if S[i]=='>':
n[i]=max(n[i],n[i+1]+1)
print((sum(n)))
|
S = eval(input())
n = [0]*(len(S)+1)
if S[0]=='<':
n[0]==0
for i in range(0,len(S)):
if S[i]=='>':
n[i+1]=0
else:
n[i+1]=n[i]+1
for i in range(len(S)-1,-1,-1):
if S[i]=='>':
n[i]=max(n[i],n[i+1]+1)
print((sum(n)))
| 20
| 16
| 394
| 279
|
S = eval(input())
n = [0] * (len(S) + 1)
if S[0] == "<":
n[0] == 0
if S[-1] == ">":
n[-1] == 0
for i in range(1, len(S)):
if S[i - 1] == "<" and S[i] == "<":
n[i] = n[i - 1] + 1
n[i + 1] = n[i] + 1
elif S[i - 1] == ">" and S[i] == "<":
n[i] = 0
n[i + 1] = 1
for i in range(len(S) - 1, -1, -1):
if S[i] == ">":
n[i] = max(n[i], n[i + 1] + 1)
print((sum(n)))
|
S = eval(input())
n = [0] * (len(S) + 1)
if S[0] == "<":
n[0] == 0
for i in range(0, len(S)):
if S[i] == ">":
n[i + 1] = 0
else:
n[i + 1] = n[i] + 1
for i in range(len(S) - 1, -1, -1):
if S[i] == ">":
n[i] = max(n[i], n[i + 1] + 1)
print((sum(n)))
| false
| 20
|
[
"-if S[-1] == \">\":",
"- n[-1] == 0",
"-for i in range(1, len(S)):",
"- if S[i - 1] == \"<\" and S[i] == \"<\":",
"- n[i] = n[i - 1] + 1",
"+for i in range(0, len(S)):",
"+ if S[i] == \">\":",
"+ n[i + 1] = 0",
"+ else:",
"- elif S[i - 1] == \">\" and S[i] == \"<\":",
"- n[i] = 0",
"- n[i + 1] = 1"
] | false
| 0.04208
| 0.046671
| 0.901642
|
[
"s730370126",
"s736526805"
] |
u186838327
|
p03645
|
python
|
s980062235
|
s965441851
| 930
| 358
| 49,112
| 108,128
|
Accepted
|
Accepted
| 61.51
|
n, m = list(map(int, input().split()))
l1 = [0]*n
l2 = [0]*n
for i in range(m):
a, b = list(map(int, input().split()))
a, b = a-1, b-1
if a == 0:
l1[b] = 1
elif b == n-1:
l2[a] = 1
else:
continue
for j in range(n):
if l1[j] == 1 and l2[j] == 1:
print('POSSIBLE')
exit()
else:
print('IMPOSSIBLE')
|
n, m = list(map(int, input().split()))
S = set()
for i in range(m):
a, b = list(map(int, input().split()))
a, b = a-1, b-1
S.add((a, b))
for i in range(1, n-1):
if (0, i) in S and (i, n-1) in S:
print('POSSIBLE')
exit()
else:
print('IMPOSSIBLE')
| 21
| 13
| 343
| 283
|
n, m = list(map(int, input().split()))
l1 = [0] * n
l2 = [0] * n
for i in range(m):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
if a == 0:
l1[b] = 1
elif b == n - 1:
l2[a] = 1
else:
continue
for j in range(n):
if l1[j] == 1 and l2[j] == 1:
print("POSSIBLE")
exit()
else:
print("IMPOSSIBLE")
|
n, m = list(map(int, input().split()))
S = set()
for i in range(m):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
S.add((a, b))
for i in range(1, n - 1):
if (0, i) in S and (i, n - 1) in S:
print("POSSIBLE")
exit()
else:
print("IMPOSSIBLE")
| false
| 38.095238
|
[
"-l1 = [0] * n",
"-l2 = [0] * n",
"+S = set()",
"- if a == 0:",
"- l1[b] = 1",
"- elif b == n - 1:",
"- l2[a] = 1",
"- else:",
"- continue",
"-for j in range(n):",
"- if l1[j] == 1 and l2[j] == 1:",
"+ S.add((a, b))",
"+for i in range(1, n - 1):",
"+ if (0, i) in S and (i, n - 1) in S:"
] | false
| 0.04124
| 0.069607
| 0.592469
|
[
"s980062235",
"s965441851"
] |
u416758623
|
p03944
|
python
|
s680520097
|
s181745304
| 90
| 28
| 3,188
| 9,104
|
Accepted
|
Accepted
| 68.89
|
from operator import itemgetter
w, h, n = list(map(int, input().split()))
binary = [[0 for _ in range(h)] for i in range(w)]
for i in range(n):
x,y,a = list(map(int, input().split()))
if a == 1:
for j in range(x):
for k in range(h):
binary[j][k] += 1
elif a == 2:
for j in range(x,w):
for k in range(h):
binary[j][k] += 1
elif a == 3:
for j in range(w):
for k in range(y):
binary[j][k] += 1
elif a == 4:
for j in range(w):
for k in range(y,h):
binary[j][k] += 1
total = 0
for i in range(len(binary)):
total += binary[i].count(0)
print(total)
|
w, h, n = list(map(int, input().split()))
W = [1] * w
H = [1] * h
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for j in range(x):
W[j] = 0
elif a == 2:
for j in range(x, w):
W[j] = 0
elif a == 3:
for j in range(y):
H[j] = 0
elif a == 4:
for j in range(y, h):
H[j] = 0
print((sum(W) * sum(H)))
| 28
| 19
| 728
| 424
|
from operator import itemgetter
w, h, n = list(map(int, input().split()))
binary = [[0 for _ in range(h)] for i in range(w)]
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for j in range(x):
for k in range(h):
binary[j][k] += 1
elif a == 2:
for j in range(x, w):
for k in range(h):
binary[j][k] += 1
elif a == 3:
for j in range(w):
for k in range(y):
binary[j][k] += 1
elif a == 4:
for j in range(w):
for k in range(y, h):
binary[j][k] += 1
total = 0
for i in range(len(binary)):
total += binary[i].count(0)
print(total)
|
w, h, n = list(map(int, input().split()))
W = [1] * w
H = [1] * h
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for j in range(x):
W[j] = 0
elif a == 2:
for j in range(x, w):
W[j] = 0
elif a == 3:
for j in range(y):
H[j] = 0
elif a == 4:
for j in range(y, h):
H[j] = 0
print((sum(W) * sum(H)))
| false
| 32.142857
|
[
"-from operator import itemgetter",
"-",
"-binary = [[0 for _ in range(h)] for i in range(w)]",
"+W = [1] * w",
"+H = [1] * h",
"- for k in range(h):",
"- binary[j][k] += 1",
"+ W[j] = 0",
"- for k in range(h):",
"- binary[j][k] += 1",
"+ W[j] = 0",
"- for j in range(w):",
"- for k in range(y):",
"- binary[j][k] += 1",
"+ for j in range(y):",
"+ H[j] = 0",
"- for j in range(w):",
"- for k in range(y, h):",
"- binary[j][k] += 1",
"-total = 0",
"-for i in range(len(binary)):",
"- total += binary[i].count(0)",
"-print(total)",
"+ for j in range(y, h):",
"+ H[j] = 0",
"+print((sum(W) * sum(H)))"
] | false
| 0.105566
| 0.143097
| 0.73772
|
[
"s680520097",
"s181745304"
] |
u561231954
|
p03329
|
python
|
s238047340
|
s100932649
| 539
| 267
| 29,428
| 12,676
|
Accepted
|
Accepted
| 50.46
|
def main():
n=int(eval(input()))
mon6=[6]
mon9=[1]
for i in range(5):
mon6.append(6*mon6[i])
mon9.append(9*mon9[i])
mon=mon6+mon9
mon.sort()
inf=10**9
dp=[[inf]*(n+1) for i in range(13)]
for i in range(13):
dp[i][0]=0
for i in range(12):
for j in range(1,n+1):
if j-mon[i]>=0:
dp[i+1][j]=min(dp[i+1][j-mon[i]]+1,dp[i][j])
else:
dp[i+1][j]=dp[i][j]
print((dp[-1][-1]))
if __name__=='__main__':
main()
|
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
def main():
N = int(eval(input()))
money = [1]
for i in range(10):
money.append(money[-1]*6)
money.append(9)
for i in range(9):
money.append(money[-1]*9)
dp = [INF] * (1 + N)
dp[0] = 0
for m in money:
for j in range(m,N + 1):
dp[j] = min(dp[j],dp[j - m] + 1)
ans = dp[-1]
print(ans)
if __name__ == '__main__':
main()
| 25
| 23
| 565
| 494
|
def main():
n = int(eval(input()))
mon6 = [6]
mon9 = [1]
for i in range(5):
mon6.append(6 * mon6[i])
mon9.append(9 * mon9[i])
mon = mon6 + mon9
mon.sort()
inf = 10**9
dp = [[inf] * (n + 1) for i in range(13)]
for i in range(13):
dp[i][0] = 0
for i in range(12):
for j in range(1, n + 1):
if j - mon[i] >= 0:
dp[i + 1][j] = min(dp[i + 1][j - mon[i]] + 1, dp[i][j])
else:
dp[i + 1][j] = dp[i][j]
print((dp[-1][-1]))
if __name__ == "__main__":
main()
|
import sys
sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
def main():
N = int(eval(input()))
money = [1]
for i in range(10):
money.append(money[-1] * 6)
money.append(9)
for i in range(9):
money.append(money[-1] * 9)
dp = [INF] * (1 + N)
dp[0] = 0
for m in money:
for j in range(m, N + 1):
dp[j] = min(dp[j], dp[j - m] + 1)
ans = dp[-1]
print(ans)
if __name__ == "__main__":
main()
| false
| 8
|
[
"+import sys",
"+",
"+sys.setrecursionlimit(10000000)",
"+MOD = 10**9 + 7",
"+INF = 10**15",
"+",
"+",
"- n = int(eval(input()))",
"- mon6 = [6]",
"- mon9 = [1]",
"- for i in range(5):",
"- mon6.append(6 * mon6[i])",
"- mon9.append(9 * mon9[i])",
"- mon = mon6 + mon9",
"- mon.sort()",
"- inf = 10**9",
"- dp = [[inf] * (n + 1) for i in range(13)]",
"- for i in range(13):",
"- dp[i][0] = 0",
"- for i in range(12):",
"- for j in range(1, n + 1):",
"- if j - mon[i] >= 0:",
"- dp[i + 1][j] = min(dp[i + 1][j - mon[i]] + 1, dp[i][j])",
"- else:",
"- dp[i + 1][j] = dp[i][j]",
"- print((dp[-1][-1]))",
"+ N = int(eval(input()))",
"+ money = [1]",
"+ for i in range(10):",
"+ money.append(money[-1] * 6)",
"+ money.append(9)",
"+ for i in range(9):",
"+ money.append(money[-1] * 9)",
"+ dp = [INF] * (1 + N)",
"+ dp[0] = 0",
"+ for m in money:",
"+ for j in range(m, N + 1):",
"+ dp[j] = min(dp[j], dp[j - m] + 1)",
"+ ans = dp[-1]",
"+ print(ans)"
] | false
| 0.093595
| 0.068167
| 1.373027
|
[
"s238047340",
"s100932649"
] |
u564525445
|
p02678
|
python
|
s512377529
|
s081139689
| 1,638
| 564
| 120,224
| 35,668
|
Accepted
|
Accepted
| 65.57
|
N, M = list(map(int, input().split()))
A, B = [], []
graph = [[] for i in range(N+1)]
for i in range(M):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
graph[a].append(b)
graph[b].append(a)
class Rs():
def __init__(self):
self.Rs = []
def append(self, R):
self.Rs.append(R)
def search(self):
count = 1
new_nodes, count = self._search(1, count)
while count < N:
_new_nodes = set()
for num in new_nodes:
_new_node, count = self._search(num, count)
_new_nodes.update(_new_node)
new_nodes = _new_nodes
return [ self.Rs[i].fastest_room for i in range(1,len(self.Rs)) ]
def _search(self, num, count):
r = self.Rs[num-1]
cons = r.connection
new_nodes = set()
cons -= r.searched_from
for con in cons:
if len(self.Rs[con-1].searched_from) == 0:
self.Rs[con-1].fastest_room = num
self.Rs[con-1].searched_from.add(num)
new_nodes.add(con)
count += 1
else:
continue
return new_nodes, count
class R():
def __init__(self, num, connection):
self.num = num
self.connection = connection
self.searched_from = set([])
self.fastest_room = None
r = Rs()
for i in range(N):
r.append(R(i+1, set(graph[i+1])))
l = r.search()
print("Yes")
for room in l:
print(room)
|
from collections import deque
N, M = list(map(int, input().split()))
A, B = [], []
graph = [[] for i in range(N+1)]
for i in range(M):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
visited = [False for i in range(N+1)]
signs = [-1 for i in range(N+1)]
D = deque([1])
while D:
n = D.popleft()
for node in graph[n]:
if visited[node] is True:
continue
else:
visited[node] = True
signs[node] = n
D.append(node)
print("Yes")
for sign in signs[2:]:
print(sign)
| 61
| 26
| 1,569
| 592
|
N, M = list(map(int, input().split()))
A, B = [], []
graph = [[] for i in range(N + 1)]
for i in range(M):
a, b = list(map(int, input().split()))
A.append(a)
B.append(b)
graph[a].append(b)
graph[b].append(a)
class Rs:
def __init__(self):
self.Rs = []
def append(self, R):
self.Rs.append(R)
def search(self):
count = 1
new_nodes, count = self._search(1, count)
while count < N:
_new_nodes = set()
for num in new_nodes:
_new_node, count = self._search(num, count)
_new_nodes.update(_new_node)
new_nodes = _new_nodes
return [self.Rs[i].fastest_room for i in range(1, len(self.Rs))]
def _search(self, num, count):
r = self.Rs[num - 1]
cons = r.connection
new_nodes = set()
cons -= r.searched_from
for con in cons:
if len(self.Rs[con - 1].searched_from) == 0:
self.Rs[con - 1].fastest_room = num
self.Rs[con - 1].searched_from.add(num)
new_nodes.add(con)
count += 1
else:
continue
return new_nodes, count
class R:
def __init__(self, num, connection):
self.num = num
self.connection = connection
self.searched_from = set([])
self.fastest_room = None
r = Rs()
for i in range(N):
r.append(R(i + 1, set(graph[i + 1])))
l = r.search()
print("Yes")
for room in l:
print(room)
|
from collections import deque
N, M = list(map(int, input().split()))
A, B = [], []
graph = [[] for i in range(N + 1)]
for i in range(M):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
visited = [False for i in range(N + 1)]
signs = [-1 for i in range(N + 1)]
D = deque([1])
while D:
n = D.popleft()
for node in graph[n]:
if visited[node] is True:
continue
else:
visited[node] = True
signs[node] = n
D.append(node)
print("Yes")
for sign in signs[2:]:
print(sign)
| false
| 57.377049
|
[
"+from collections import deque",
"+",
"- A.append(a)",
"- B.append(b)",
"-",
"-",
"-class Rs:",
"- def __init__(self):",
"- self.Rs = []",
"-",
"- def append(self, R):",
"- self.Rs.append(R)",
"-",
"- def search(self):",
"- count = 1",
"- new_nodes, count = self._search(1, count)",
"- while count < N:",
"- _new_nodes = set()",
"- for num in new_nodes:",
"- _new_node, count = self._search(num, count)",
"- _new_nodes.update(_new_node)",
"- new_nodes = _new_nodes",
"- return [self.Rs[i].fastest_room for i in range(1, len(self.Rs))]",
"-",
"- def _search(self, num, count):",
"- r = self.Rs[num - 1]",
"- cons = r.connection",
"- new_nodes = set()",
"- cons -= r.searched_from",
"- for con in cons:",
"- if len(self.Rs[con - 1].searched_from) == 0:",
"- self.Rs[con - 1].fastest_room = num",
"- self.Rs[con - 1].searched_from.add(num)",
"- new_nodes.add(con)",
"- count += 1",
"- else:",
"- continue",
"- return new_nodes, count",
"-",
"-",
"-class R:",
"- def __init__(self, num, connection):",
"- self.num = num",
"- self.connection = connection",
"- self.searched_from = set([])",
"- self.fastest_room = None",
"-",
"-",
"-r = Rs()",
"-for i in range(N):",
"- r.append(R(i + 1, set(graph[i + 1])))",
"-l = r.search()",
"+visited = [False for i in range(N + 1)]",
"+signs = [-1 for i in range(N + 1)]",
"+D = deque([1])",
"+while D:",
"+ n = D.popleft()",
"+ for node in graph[n]:",
"+ if visited[node] is True:",
"+ continue",
"+ else:",
"+ visited[node] = True",
"+ signs[node] = n",
"+ D.append(node)",
"-for room in l:",
"- print(room)",
"+for sign in signs[2:]:",
"+ print(sign)"
] | false
| 0.127547
| 0.038565
| 3.307327
|
[
"s512377529",
"s081139689"
] |
u021019433
|
p02959
|
python
|
s475567297
|
s221775916
| 170
| 143
| 16,576
| 16,044
|
Accepted
|
Accepted
| 15.88
|
R = lambda: list(map(int, input().split()))
eval(input())
a, b = list(R()), R()
r = 0
for i, u in enumerate(b):
x = min(a[i], u)
y = min(a[i + 1], u - x)
a[i + 1] -= y
r += x + y
print(r)
|
R = lambda: list(map(int, input().split()))
eval(input())
a, b = list(R()), R()
r = y = 0
for u, v, w in zip(b, a, a[1:]):
x = min(v - y, u)
y = min(w, u - x)
r += x + y
print(r)
| 10
| 9
| 201
| 187
|
R = lambda: list(map(int, input().split()))
eval(input())
a, b = list(R()), R()
r = 0
for i, u in enumerate(b):
x = min(a[i], u)
y = min(a[i + 1], u - x)
a[i + 1] -= y
r += x + y
print(r)
|
R = lambda: list(map(int, input().split()))
eval(input())
a, b = list(R()), R()
r = y = 0
for u, v, w in zip(b, a, a[1:]):
x = min(v - y, u)
y = min(w, u - x)
r += x + y
print(r)
| false
| 10
|
[
"-r = 0",
"-for i, u in enumerate(b):",
"- x = min(a[i], u)",
"- y = min(a[i + 1], u - x)",
"- a[i + 1] -= y",
"+r = y = 0",
"+for u, v, w in zip(b, a, a[1:]):",
"+ x = min(v - y, u)",
"+ y = min(w, u - x)"
] | false
| 0.036528
| 0.033267
| 1.098039
|
[
"s475567297",
"s221775916"
] |
u546285759
|
p00433
|
python
|
s670271414
|
s053127752
| 30
| 20
| 7,732
| 7,692
|
Accepted
|
Accepted
| 33.33
|
scores = [list(map(int, input().split())) for _ in range(2)]
print((max(sum(scores[0]), sum(scores[1]))))
|
print((max(sum(map(int, input().split())), sum(map(int, input().split())))))
| 2
| 1
| 104
| 74
|
scores = [list(map(int, input().split())) for _ in range(2)]
print((max(sum(scores[0]), sum(scores[1]))))
|
print((max(sum(map(int, input().split())), sum(map(int, input().split())))))
| false
| 50
|
[
"-scores = [list(map(int, input().split())) for _ in range(2)]",
"-print((max(sum(scores[0]), sum(scores[1]))))",
"+print((max(sum(map(int, input().split())), sum(map(int, input().split())))))"
] | false
| 0.084703
| 0.064628
| 1.310627
|
[
"s670271414",
"s053127752"
] |
u394721319
|
p02994
|
python
|
s884792170
|
s266888085
| 175
| 28
| 38,256
| 9,160
|
Accepted
|
Accepted
| 84
|
N,L = [int(i) for i in input().split()]
A = [L+i for i in range(N)]
tmp = 1000
ind = 0
for i in range(N):
if tmp > abs(A[i]):
tmp = abs(A[i])
ind = i
print((sum(A)-A[ind]))
|
N,L = [int(i) for i in input().split()]
A = [i+L-1 for i in range(1,N+1)]
B = [abs(i+L-1) for i in range(1,N+1)]
print((sum(A)-A[B.index(min(B))]))
| 11
| 6
| 203
| 153
|
N, L = [int(i) for i in input().split()]
A = [L + i for i in range(N)]
tmp = 1000
ind = 0
for i in range(N):
if tmp > abs(A[i]):
tmp = abs(A[i])
ind = i
print((sum(A) - A[ind]))
|
N, L = [int(i) for i in input().split()]
A = [i + L - 1 for i in range(1, N + 1)]
B = [abs(i + L - 1) for i in range(1, N + 1)]
print((sum(A) - A[B.index(min(B))]))
| false
| 45.454545
|
[
"-A = [L + i for i in range(N)]",
"-tmp = 1000",
"-ind = 0",
"-for i in range(N):",
"- if tmp > abs(A[i]):",
"- tmp = abs(A[i])",
"- ind = i",
"-print((sum(A) - A[ind]))",
"+A = [i + L - 1 for i in range(1, N + 1)]",
"+B = [abs(i + L - 1) for i in range(1, N + 1)]",
"+print((sum(A) - A[B.index(min(B))]))"
] | false
| 0.04073
| 0.033442
| 1.217918
|
[
"s884792170",
"s266888085"
] |
u729133443
|
p03238
|
python
|
s257819133
|
s072317399
| 21
| 17
| 3,316
| 3,064
|
Accepted
|
Accepted
| 19.05
|
def toInteger(string):
integer = int(string)
return integer
def myInput():
s = eval(input())
i = toInteger(s)
return i
def isEqual(a, b):
try:
1 / (a - b)
except:
return True
return False
def isValue1(v):
boolean = isEqual(v, 1)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def isValue2(v):
boolean = isEqual(v, 2)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def printString(String):
print(String)
def printHelloWorld():
printString('Hello World')
def printInteger(integer):
print(integer)
def sumTwoValues(a, b):
c = a + b
return c
def solve(v):
boolean1 = isValue1(v)
boolean2 = isValue2(v)
if isEqual(boolean1, True) == True:
printHelloWorld()
elif isEqual(boolean2, True) == True:
a = myInput()
b = myInput()
c = sumTwoValues(a, b)
printInteger(c)
else:
None
a = myInput()
solve(a)
|
def toInteger(string):
try:
integer = int(string)
return integer
except:
print('Number Format Exception')
exit()
def myInput():
s = eval(input())
i = toInteger(s)
return i
def isEqual(a, b):
try:
1 / (a - b)
except:
return True
return False
def isValue1(v):
boolean = isEqual(v, 1)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def isValue2(v):
boolean = isEqual(v, 2)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def printString(String):
print(String)
def printHelloWorld():
printString('Hello World')
def printInteger(integer):
print(integer)
def sumTwoValues(a, b):
c = a + b
return c
def solve(v):
boolean1 = isValue1(v)
boolean2 = isValue2(v)
if isEqual(boolean1, True) == True:
printHelloWorld()
elif isEqual(boolean2, True) == True:
a = myInput()
b = myInput()
c = sumTwoValues(a, b)
printInteger(c)
else:
None
def main():
a = myInput()
solve(a)
main()
| 62
| 69
| 1,089
| 1,191
|
def toInteger(string):
integer = int(string)
return integer
def myInput():
s = eval(input())
i = toInteger(s)
return i
def isEqual(a, b):
try:
1 / (a - b)
except:
return True
return False
def isValue1(v):
boolean = isEqual(v, 1)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def isValue2(v):
boolean = isEqual(v, 2)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def printString(String):
print(String)
def printHelloWorld():
printString("Hello World")
def printInteger(integer):
print(integer)
def sumTwoValues(a, b):
c = a + b
return c
def solve(v):
boolean1 = isValue1(v)
boolean2 = isValue2(v)
if isEqual(boolean1, True) == True:
printHelloWorld()
elif isEqual(boolean2, True) == True:
a = myInput()
b = myInput()
c = sumTwoValues(a, b)
printInteger(c)
else:
None
a = myInput()
solve(a)
|
def toInteger(string):
try:
integer = int(string)
return integer
except:
print("Number Format Exception")
exit()
def myInput():
s = eval(input())
i = toInteger(s)
return i
def isEqual(a, b):
try:
1 / (a - b)
except:
return True
return False
def isValue1(v):
boolean = isEqual(v, 1)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def isValue2(v):
boolean = isEqual(v, 2)
if isEqual(boolean, True) == True:
return True
elif isEqual(boolean, False) == True:
return False
else:
None
def printString(String):
print(String)
def printHelloWorld():
printString("Hello World")
def printInteger(integer):
print(integer)
def sumTwoValues(a, b):
c = a + b
return c
def solve(v):
boolean1 = isValue1(v)
boolean2 = isValue2(v)
if isEqual(boolean1, True) == True:
printHelloWorld()
elif isEqual(boolean2, True) == True:
a = myInput()
b = myInput()
c = sumTwoValues(a, b)
printInteger(c)
else:
None
def main():
a = myInput()
solve(a)
main()
| false
| 10.144928
|
[
"- integer = int(string)",
"- return integer",
"+ try:",
"+ integer = int(string)",
"+ return integer",
"+ except:",
"+ print(\"Number Format Exception\")",
"+ exit()",
"-a = myInput()",
"-solve(a)",
"+def main():",
"+ a = myInput()",
"+ solve(a)",
"+",
"+",
"+main()"
] | false
| 0.045311
| 0.124277
| 0.364599
|
[
"s257819133",
"s072317399"
] |
u254871849
|
p02987
|
python
|
s340405127
|
s804367277
| 21
| 17
| 3,316
| 2,940
|
Accepted
|
Accepted
| 19.05
|
# 2019-11-15 00:35:39(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np
def main():
s = sys.stdin.readline().rstrip()
for v in list(collections.Counter(s).values()):
if v == 2:
continue
else:
ans = 'No'
break
else:
ans = 'Yes'
print(ans)
if __name__ == "__main__":
main()
|
import sys
s = sys.stdin.readline().rstrip()
def main():
for char in set(s):
if s.count(char) != 2:
return 'No'
return 'Yes'
if __name__ == '__main__':
ans = main()
print(ans)
| 27
| 13
| 633
| 226
|
# 2019-11-15 00:35:39(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np
def main():
s = sys.stdin.readline().rstrip()
for v in list(collections.Counter(s).values()):
if v == 2:
continue
else:
ans = "No"
break
else:
ans = "Yes"
print(ans)
if __name__ == "__main__":
main()
|
import sys
s = sys.stdin.readline().rstrip()
def main():
for char in set(s):
if s.count(char) != 2:
return "No"
return "Yes"
if __name__ == "__main__":
ans = main()
print(ans)
| false
| 51.851852
|
[
"-# 2019-11-15 00:35:39(JST)",
"-import collections",
"-# import math",
"-# from string import ascii_lowercase, ascii_uppercase, digits",
"-# from bisect import bisect_left as bi_l, bisect_right as bi_r",
"-# import itertools",
"-# from functools import reduce",
"-# import operator as op",
"-# from scipy.misc import comb # float",
"-# import numpy as np",
"+s = sys.stdin.readline().rstrip()",
"+",
"+",
"- s = sys.stdin.readline().rstrip()",
"- for v in list(collections.Counter(s).values()):",
"- if v == 2:",
"- continue",
"- else:",
"- ans = \"No\"",
"- break",
"- else:",
"- ans = \"Yes\"",
"- print(ans)",
"+ for char in set(s):",
"+ if s.count(char) != 2:",
"+ return \"No\"",
"+ return \"Yes\"",
"- main()",
"+ ans = main()",
"+ print(ans)"
] | false
| 0.055236
| 0.035846
| 1.540916
|
[
"s340405127",
"s804367277"
] |
u883621917
|
p02831
|
python
|
s265822925
|
s091687830
| 183
| 63
| 38,640
| 61,416
|
Accepted
|
Accepted
| 65.57
|
import sys
input = sys.stdin.readline
a, b = [int(i) for i in input().split()]
small = min(a,b)
big = max(a,b)
multi = 1
ans = big
while True:
ans = big * multi
if (ans % small) == 0:
break
multi += 1
print(ans)
|
import sys
iput = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
a, b = list(map(int, input().split()))
def gcd(big, small):
if small == 0:
return big
else:
return gcd(small, big % small)
# gcd(a, b) * lcm(a, b) == a * b
def lcm(a, b):
# 除算を先にしてオーバーフローのリスクを軽減する
# FYI: https://qiita.com/drken/items/0c88a37eec520f82b788#2-2-%E5%8D%98%E7%B4%94%E3%81%AA%E6%9C%80%E5%B0%8F%E5%85%AC%E5%80%8D%E6%95%B0%E3%82%B2%E3%83%BC
return (a // gcd(a, b)) * b
print((lcm(a, b)))
| 16
| 19
| 250
| 515
|
import sys
input = sys.stdin.readline
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)
multi = 1
ans = big
while True:
ans = big * multi
if (ans % small) == 0:
break
multi += 1
print(ans)
|
import sys
iput = sys.stdin.readline
sys.setrecursionlimit(10**7)
a, b = list(map(int, input().split()))
def gcd(big, small):
if small == 0:
return big
else:
return gcd(small, big % small)
# gcd(a, b) * lcm(a, b) == a * b
def lcm(a, b):
# 除算を先にしてオーバーフローのリスクを軽減する
# FYI: https://qiita.com/drken/items/0c88a37eec520f82b788#2-2-%E5%8D%98%E7%B4%94%E3%81%AA%E6%9C%80%E5%B0%8F%E5%85%AC%E5%80%8D%E6%95%B0%E3%82%B2%E3%83%BC
return (a // gcd(a, b)) * b
print((lcm(a, b)))
| false
| 15.789474
|
[
"-input = sys.stdin.readline",
"-a, b = [int(i) for i in input().split()]",
"-small = min(a, b)",
"-big = max(a, b)",
"-multi = 1",
"-ans = big",
"-while True:",
"- ans = big * multi",
"- if (ans % small) == 0:",
"- break",
"- multi += 1",
"-print(ans)",
"+iput = sys.stdin.readline",
"+sys.setrecursionlimit(10**7)",
"+a, b = list(map(int, input().split()))",
"+",
"+",
"+def gcd(big, small):",
"+ if small == 0:",
"+ return big",
"+ else:",
"+ return gcd(small, big % small)",
"+",
"+",
"+# gcd(a, b) * lcm(a, b) == a * b",
"+def lcm(a, b):",
"+ # 除算を先にしてオーバーフローのリスクを軽減する",
"+ # FYI: https://qiita.com/drken/items/0c88a37eec520f82b788#2-2-%E5%8D%98%E7%B4%94%E3%81%AA%E6%9C%80%E5%B0%8F%E5%85%AC%E5%80%8D%E6%95%B0%E3%82%B2%E3%83%BC",
"+ return (a // gcd(a, b)) * b",
"+",
"+",
"+print((lcm(a, b)))"
] | false
| 0.09975
| 0.085259
| 1.16997
|
[
"s265822925",
"s091687830"
] |
u941047297
|
p03545
|
python
|
s698543486
|
s510720818
| 180
| 20
| 38,256
| 3,060
|
Accepted
|
Accepted
| 88.89
|
S = list(eval(input()))
for i in range(2 ** 3):
pm = ['-'] * 3
for j in range(3):
if i >> j & 1:
pm[j] = '+'
ans = [None] * 7
ans[::2] = S
ans[1::2] = pm
ans = ''.join(ans)
if eval(ans) == 7:
print((ans + '=7'))
break
|
n = eval(input())
for i in range(2 ** 3):
op = ['+'] * 3
for j in range(3):
if i >> j & 1:
op[j] = '-'
f = [0] * 7
f[::2] = n
f[1::2] = op
f = ''.join(f)
if eval(f) == 7:
print((''.join([f, '=7'])))
exit()
| 13
| 13
| 285
| 274
|
S = list(eval(input()))
for i in range(2**3):
pm = ["-"] * 3
for j in range(3):
if i >> j & 1:
pm[j] = "+"
ans = [None] * 7
ans[::2] = S
ans[1::2] = pm
ans = "".join(ans)
if eval(ans) == 7:
print((ans + "=7"))
break
|
n = eval(input())
for i in range(2**3):
op = ["+"] * 3
for j in range(3):
if i >> j & 1:
op[j] = "-"
f = [0] * 7
f[::2] = n
f[1::2] = op
f = "".join(f)
if eval(f) == 7:
print(("".join([f, "=7"])))
exit()
| false
| 0
|
[
"-S = list(eval(input()))",
"+n = eval(input())",
"- pm = [\"-\"] * 3",
"+ op = [\"+\"] * 3",
"- pm[j] = \"+\"",
"- ans = [None] * 7",
"- ans[::2] = S",
"- ans[1::2] = pm",
"- ans = \"\".join(ans)",
"- if eval(ans) == 7:",
"- print((ans + \"=7\"))",
"- break",
"+ op[j] = \"-\"",
"+ f = [0] * 7",
"+ f[::2] = n",
"+ f[1::2] = op",
"+ f = \"\".join(f)",
"+ if eval(f) == 7:",
"+ print((\"\".join([f, \"=7\"])))",
"+ exit()"
] | false
| 0.083299
| 0.037355
| 2.229929
|
[
"s698543486",
"s510720818"
] |
u092301301
|
p02714
|
python
|
s570129745
|
s652317934
| 1,997
| 139
| 27,240
| 68,684
|
Accepted
|
Accepted
| 93.04
|
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline
def I(): return list(map(int,inp().split()))
from collections import Counter
from numpy import prod
n=I()[0]
s=eval(input())
cut=0
for i in range(len(s)):
for j in range(i+1,len(s)):
if 2*j-i>=len(s): break
if len({s[i],s[j],s[2*j-i]})==3:
cut+=1
d=Counter(s)
if len(d)<3: print((0))
else: print((prod(list(d.values()))-cut))
|
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline
def I(): return list(map(int,inp().split()))
from collections import Counter
n=I()[0]
s=eval(input())
cut=0
for i in range(len(s)):
for j in range(i+1,len(s)):
if 2*j-i>=len(s): break
if not(s[i]==s[j] or s[i]==s[2*j-i] or s[j]==s[2*j-i]):
cut+=1
d=Counter(s) ; mul=1
for i in list(d.values()):
mul*=i
if len(d)<3: print((0))
else: print((mul-cut))
| 19
| 22
| 489
| 528
|
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline
def I():
return list(map(int, inp().split()))
from collections import Counter
from numpy import prod
n = I()[0]
s = eval(input())
cut = 0
for i in range(len(s)):
for j in range(i + 1, len(s)):
if 2 * j - i >= len(s):
break
if len({s[i], s[j], s[2 * j - i]}) == 3:
cut += 1
d = Counter(s)
if len(d) < 3:
print((0))
else:
print((prod(list(d.values())) - cut))
|
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline
def I():
return list(map(int, inp().split()))
from collections import Counter
n = I()[0]
s = eval(input())
cut = 0
for i in range(len(s)):
for j in range(i + 1, len(s)):
if 2 * j - i >= len(s):
break
if not (s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]):
cut += 1
d = Counter(s)
mul = 1
for i in list(d.values()):
mul *= i
if len(d) < 3:
print((0))
else:
print((mul - cut))
| false
| 13.636364
|
[
"-from numpy import prod",
"- if len({s[i], s[j], s[2 * j - i]}) == 3:",
"+ if not (s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]):",
"+mul = 1",
"+for i in list(d.values()):",
"+ mul *= i",
"- print((prod(list(d.values())) - cut))",
"+ print((mul - cut))"
] | false
| 0.451749
| 0.035908
| 12.580902
|
[
"s570129745",
"s652317934"
] |
u070201429
|
p02662
|
python
|
s896467308
|
s065596990
| 1,943
| 142
| 182,736
| 72,172
|
Accepted
|
Accepted
| 92.69
|
mod = 998244353
n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
while a[-1] > s:
a.pop(-1)
if a == []:
print((0))
exit()
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
newdp = [2 * j for j in dp]
for j in range(s - i + 1):
newdp[j+i] += dp[j]
dp = newdp
print((dp[s] * pow(2, n - len(a), mod) % mod))
|
mod = 998244353
n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
while a[-1] > s:
a.pop(-1)
if a == []:
print((0))
exit()
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
newdp = [2 * j % mod for j in dp]
for j in range(s - i + 1):
newdp[j+i] += dp[j]
dp = newdp
print((dp[s] * pow(2, n - len(a), mod) % mod))
| 22
| 22
| 390
| 396
|
mod = 998244353
n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
while a[-1] > s:
a.pop(-1)
if a == []:
print((0))
exit()
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
newdp = [2 * j for j in dp]
for j in range(s - i + 1):
newdp[j + i] += dp[j]
dp = newdp
print((dp[s] * pow(2, n - len(a), mod) % mod))
|
mod = 998244353
n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
while a[-1] > s:
a.pop(-1)
if a == []:
print((0))
exit()
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
newdp = [2 * j % mod for j in dp]
for j in range(s - i + 1):
newdp[j + i] += dp[j]
dp = newdp
print((dp[s] * pow(2, n - len(a), mod) % mod))
| false
| 0
|
[
"- newdp = [2 * j for j in dp]",
"+ newdp = [2 * j % mod for j in dp]"
] | false
| 0.07626
| 0.035468
| 2.15011
|
[
"s896467308",
"s065596990"
] |
u251515715
|
p03309
|
python
|
s540765122
|
s352728407
| 787
| 718
| 136,916
| 137,088
|
Accepted
|
Accepted
| 8.77
|
n=int(eval(input()))
a=list(map(int,input().split()))
b_low=-1*(10**12)
b_high=10**12
b_low_d=sum([abs(a[i]-(b_low+2+i)) for i in range(n)])-sum([abs(a[i]-(b_low+1+i)) for i in range(n)])
b_high_d=sum([abs(a[i]-(b_high+2+i)) for i in range(n)])-sum([abs(a[i]-(b_high+1+i)) for i in range(n)])
while b_high-b_low>10:
b_tmp=(b_low+b_high)//2
b_tmp_d=sum([abs(a[i]-(b_tmp+2+i)) for i in range(n)])-sum([abs(a[i]-(b_tmp+1+i)) for i in range(n)])
if b_tmp_d>0:
b_high=b_tmp
else:
b_low=b_tmp
ans=10**20
for j in range(b_low,b_high):
ans=min(ans,sum([abs(a[i]-(j+2+i)) for i in range(n)]))
print(ans)
|
n=int(eval(input()))
a=list(map(int,input().split()))
b_low=-1*(10**10)
b_high=10**10
b_low_d=sum([abs(a[i]-(b_low+2+i)) for i in range(n)])-sum([abs(a[i]-(b_low+1+i)) for i in range(n)])
b_high_d=sum([abs(a[i]-(b_high+2+i)) for i in range(n)])-sum([abs(a[i]-(b_high+1+i)) for i in range(n)])
while b_high-b_low>10:
b_tmp=(b_low+b_high)//2
b_tmp_d=sum([abs(a[i]-(b_tmp+2+i)) for i in range(n)])-sum([abs(a[i]-(b_tmp+1+i)) for i in range(n)])
if b_tmp_d>0:
b_high=b_tmp
else:
b_low=b_tmp
ans=10**20
for j in range(b_low,b_high):
ans=min(ans,sum([abs(a[i]-(j+2+i)) for i in range(n)]))
print(ans)
| 21
| 21
| 630
| 630
|
n = int(eval(input()))
a = list(map(int, input().split()))
b_low = -1 * (10**12)
b_high = 10**12
b_low_d = sum([abs(a[i] - (b_low + 2 + i)) for i in range(n)]) - sum(
[abs(a[i] - (b_low + 1 + i)) for i in range(n)]
)
b_high_d = sum([abs(a[i] - (b_high + 2 + i)) for i in range(n)]) - sum(
[abs(a[i] - (b_high + 1 + i)) for i in range(n)]
)
while b_high - b_low > 10:
b_tmp = (b_low + b_high) // 2
b_tmp_d = sum([abs(a[i] - (b_tmp + 2 + i)) for i in range(n)]) - sum(
[abs(a[i] - (b_tmp + 1 + i)) for i in range(n)]
)
if b_tmp_d > 0:
b_high = b_tmp
else:
b_low = b_tmp
ans = 10**20
for j in range(b_low, b_high):
ans = min(ans, sum([abs(a[i] - (j + 2 + i)) for i in range(n)]))
print(ans)
|
n = int(eval(input()))
a = list(map(int, input().split()))
b_low = -1 * (10**10)
b_high = 10**10
b_low_d = sum([abs(a[i] - (b_low + 2 + i)) for i in range(n)]) - sum(
[abs(a[i] - (b_low + 1 + i)) for i in range(n)]
)
b_high_d = sum([abs(a[i] - (b_high + 2 + i)) for i in range(n)]) - sum(
[abs(a[i] - (b_high + 1 + i)) for i in range(n)]
)
while b_high - b_low > 10:
b_tmp = (b_low + b_high) // 2
b_tmp_d = sum([abs(a[i] - (b_tmp + 2 + i)) for i in range(n)]) - sum(
[abs(a[i] - (b_tmp + 1 + i)) for i in range(n)]
)
if b_tmp_d > 0:
b_high = b_tmp
else:
b_low = b_tmp
ans = 10**20
for j in range(b_low, b_high):
ans = min(ans, sum([abs(a[i] - (j + 2 + i)) for i in range(n)]))
print(ans)
| false
| 0
|
[
"-b_low = -1 * (10**12)",
"-b_high = 10**12",
"+b_low = -1 * (10**10)",
"+b_high = 10**10"
] | false
| 0.106548
| 0.04041
| 2.636685
|
[
"s540765122",
"s352728407"
] |
u489959379
|
p03645
|
python
|
s939035005
|
s956588879
| 1,847
| 732
| 89,056
| 38,320
|
Accepted
|
Accepted
| 60.37
|
import sys
import heapq
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, m = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edge[a - 1].append([1, b - 1])
edge[b - 1].append([1, a - 1])
# ダイクストラ法:O(ElogV)
def dijkstra_heap(s):
# 始点sから各頂点への最短距離
d = [float("inf")] * n
used = [True] * n # True:未確定
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist, e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
# まだ使われてない頂点の中から最小の距離のものを探す
if not used[minedge[1]]:
continue
v = minedge[1]
d[v] = minedge[0]
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist, [e[0] + d[v], e[1]])
return d
L = dijkstra_heap(n - 1)
if L[0] <= 2:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
if __name__ == '__main__':
resolve()
|
# https://atcoder.jp/contests/abc068/submissions/12987221
# C - Cat Snuke and a Voyage
import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, m = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
for i in edge[0]:
if n - 1 in set(edge[i]):
print("POSSIBLE")
break
else:
print("IMPOSSIBLE")
if __name__ == '__main__':
resolve()
| 50
| 28
| 1,210
| 603
|
import sys
import heapq
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, m = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edge[a - 1].append([1, b - 1])
edge[b - 1].append([1, a - 1])
# ダイクストラ法:O(ElogV)
def dijkstra_heap(s):
# 始点sから各頂点への最短距離
d = [float("inf")] * n
used = [True] * n # True:未確定
d[s] = 0
used[s] = False
edgelist = []
for e in edge[s]:
heapq.heappush(edgelist, e)
while len(edgelist):
minedge = heapq.heappop(edgelist)
# まだ使われてない頂点の中から最小の距離のものを探す
if not used[minedge[1]]:
continue
v = minedge[1]
d[v] = minedge[0]
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist, [e[0] + d[v], e[1]])
return d
L = dijkstra_heap(n - 1)
if L[0] <= 2:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
if __name__ == "__main__":
resolve()
|
# https://atcoder.jp/contests/abc068/submissions/12987221
# C - Cat Snuke and a Voyage
import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, m = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(m):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
for i in edge[0]:
if n - 1 in set(edge[i]):
print("POSSIBLE")
break
else:
print("IMPOSSIBLE")
if __name__ == "__main__":
resolve()
| false
| 44
|
[
"+# https://atcoder.jp/contests/abc068/submissions/12987221",
"+# C - Cat Snuke and a Voyage",
"-import heapq",
"- edge[a - 1].append([1, b - 1])",
"- edge[b - 1].append([1, a - 1])",
"- # ダイクストラ法:O(ElogV)",
"- def dijkstra_heap(s):",
"- # 始点sから各頂点への最短距離",
"- d = [float(\"inf\")] * n",
"- used = [True] * n # True:未確定",
"- d[s] = 0",
"- used[s] = False",
"- edgelist = []",
"- for e in edge[s]:",
"- heapq.heappush(edgelist, e)",
"- while len(edgelist):",
"- minedge = heapq.heappop(edgelist)",
"- # まだ使われてない頂点の中から最小の距離のものを探す",
"- if not used[minedge[1]]:",
"- continue",
"- v = minedge[1]",
"- d[v] = minedge[0]",
"- used[v] = False",
"- for e in edge[v]:",
"- if used[e[1]]:",
"- heapq.heappush(edgelist, [e[0] + d[v], e[1]])",
"- return d",
"-",
"- L = dijkstra_heap(n - 1)",
"- if L[0] <= 2:",
"- print(\"POSSIBLE\")",
"+ edge[a - 1].append(b - 1)",
"+ edge[b - 1].append(a - 1)",
"+ for i in edge[0]:",
"+ if n - 1 in set(edge[i]):",
"+ print(\"POSSIBLE\")",
"+ break"
] | false
| 0.147653
| 0.047332
| 3.119539
|
[
"s939035005",
"s956588879"
] |
u312695001
|
p03557
|
python
|
s622285569
|
s372837472
| 547
| 335
| 34,204
| 17,704
|
Accepted
|
Accepted
| 38.76
|
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
x = 0
z = 0
for y in B:
while x < N and A[x] < y:
x = x + 1
while z < N and C[z] <= y:
z = z + 1
ans = ans + x*(N-z)
print(ans)
|
from bisect import bisect_right, bisect_left
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
A_on_B = 0
C_under_B = 0
for y in B:
A_on_B = bisect_left(A, y)
C_under_B = N - bisect_right(C, y)
ans = ans + A_on_B*C_under_B
print(ans)
| 23
| 20
| 374
| 393
|
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
x = 0
z = 0
for y in B:
while x < N and A[x] < y:
x = x + 1
while z < N and C[z] <= y:
z = z + 1
ans = ans + x * (N - z)
print(ans)
|
from bisect import bisect_right, bisect_left
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
A_on_B = 0
C_under_B = 0
for y in B:
A_on_B = bisect_left(A, y)
C_under_B = N - bisect_right(C, y)
ans = ans + A_on_B * C_under_B
print(ans)
| false
| 13.043478
|
[
"-import numpy as np",
"+from bisect import bisect_right, bisect_left",
"-x = 0",
"-z = 0",
"+A_on_B = 0",
"+C_under_B = 0",
"- while x < N and A[x] < y:",
"- x = x + 1",
"- while z < N and C[z] <= y:",
"- z = z + 1",
"- ans = ans + x * (N - z)",
"+ A_on_B = bisect_left(A, y)",
"+ C_under_B = N - bisect_right(C, y)",
"+ ans = ans + A_on_B * C_under_B"
] | false
| 0.044476
| 0.048571
| 0.915694
|
[
"s622285569",
"s372837472"
] |
u163907160
|
p02756
|
python
|
s442162296
|
s425239078
| 412
| 381
| 4,468
| 7,688
|
Accepted
|
Accepted
| 7.52
|
S=eval(input())
Q=int(eval(input()))
Rev=True
front=''
back=''
for i in range(Q):
a=eval(input())
if a=='1':
Rev=not(Rev)
else:
b,c,x=a.split()
if c == '1':
if Rev:
front += x
else:
back += x
else:
if Rev:
back += x
else:
front += x
if Rev:
print((front[::-1] + S + back))
else:
print((back[::-1]+S[::-1]+front))
|
S=list(eval(input()))
Q=int(eval(input()))
Rev=True
front=[]
back=[]
for i in range(Q):
a=eval(input())
if a=='1':
Rev=not(Rev)
else:
b,c,x=a.split()
if c == '1':
if Rev:
front.append(x)
else:
back.append(x)
else:
if Rev:
back.append(x)
else:
front.append(x)
if Rev:
front.reverse()
front.extend(S)
front.extend(back)
print(("".join(front)))
else:
back.reverse()
S.reverse()
back.extend(S)
back.extend(front)
print(("".join(back)))
| 25
| 32
| 479
| 633
|
S = eval(input())
Q = int(eval(input()))
Rev = True
front = ""
back = ""
for i in range(Q):
a = eval(input())
if a == "1":
Rev = not (Rev)
else:
b, c, x = a.split()
if c == "1":
if Rev:
front += x
else:
back += x
else:
if Rev:
back += x
else:
front += x
if Rev:
print((front[::-1] + S + back))
else:
print((back[::-1] + S[::-1] + front))
|
S = list(eval(input()))
Q = int(eval(input()))
Rev = True
front = []
back = []
for i in range(Q):
a = eval(input())
if a == "1":
Rev = not (Rev)
else:
b, c, x = a.split()
if c == "1":
if Rev:
front.append(x)
else:
back.append(x)
else:
if Rev:
back.append(x)
else:
front.append(x)
if Rev:
front.reverse()
front.extend(S)
front.extend(back)
print(("".join(front)))
else:
back.reverse()
S.reverse()
back.extend(S)
back.extend(front)
print(("".join(back)))
| false
| 21.875
|
[
"-S = eval(input())",
"+S = list(eval(input()))",
"-front = \"\"",
"-back = \"\"",
"+front = []",
"+back = []",
"- front += x",
"+ front.append(x)",
"- back += x",
"+ back.append(x)",
"- back += x",
"+ back.append(x)",
"- front += x",
"+ front.append(x)",
"- print((front[::-1] + S + back))",
"+ front.reverse()",
"+ front.extend(S)",
"+ front.extend(back)",
"+ print((\"\".join(front)))",
"- print((back[::-1] + S[::-1] + front))",
"+ back.reverse()",
"+ S.reverse()",
"+ back.extend(S)",
"+ back.extend(front)",
"+ print((\"\".join(back)))"
] | false
| 0.036638
| 0.036687
| 0.99865
|
[
"s442162296",
"s425239078"
] |
u678167152
|
p03635
|
python
|
s890187929
|
s774311056
| 174
| 64
| 38,512
| 61,772
|
Accepted
|
Accepted
| 63.22
|
N, M = list(map(int, input().split()))
ans=(N-1)*(M-1)
print(ans)
|
N, M = list(map(int, input().split()))
print(((N-1)*(M-1)))
| 4
| 2
| 63
| 52
|
N, M = list(map(int, input().split()))
ans = (N - 1) * (M - 1)
print(ans)
|
N, M = list(map(int, input().split()))
print(((N - 1) * (M - 1)))
| false
| 50
|
[
"-ans = (N - 1) * (M - 1)",
"-print(ans)",
"+print(((N - 1) * (M - 1)))"
] | false
| 0.044286
| 0.038144
| 1.161037
|
[
"s890187929",
"s774311056"
] |
u308033440
|
p02261
|
python
|
s824703209
|
s521199493
| 240
| 20
| 5,608
| 5,608
|
Accepted
|
Accepted
| 91.67
|
# #バブルソート
# def BubbleSort(C,N):
# for i in range (0,N,1):
# for j in range(N-1,i-1,-1):
# if int(C[j][1:2]) < int(C[j-1][1:2]):
# tmp = C[j]
# C[j] = C[j-1]
# C[j-1] = tmp
# print(' '.join(C))
#バブルソート
def BubbleSort(C,N):
flag = 1
while flag:
flag = 0
for j in range(N-1,0,-1):
if int(C[j][1:2]) < int(C[j-1][1:2]):
tmp = C[j]
C[j] = C[j-1]
C[j-1] = tmp
flag = 1
print((' '.join(C)))
#選択ソート
def SelectionSort(C,N):
for i in range(0,N,1):
minj = i
for j in range(i,N,1):
if int(C[j][1:2]) < int(C[minj][1:2]):
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
print((' '.join(C)))
#安定かどうかの判定
def isStable(inp, out,N):
for i in range(0,N):
for j in range(i+1,N):
for a in range(0,N):
for b in range(a+1,N):
# print("inp(i,j):",inp[i],inp[j],"out(b,a):",out[b],out[a]+"\n")
if int(inp[i][1]) == int(inp[j][1]) and inp[i] == out[b] and inp[j] == out[a]:
print('Not stable')
return
print('Stable')
#愚直に調べるパターン
N = int(eval(input()))
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()
BubbleSort(Bubble_A,N)
isStable(A,Bubble_A,N)
SelectionSort(Selection_A,N)
isStable(A,Selection_A,N)
|
#バブルソート
def BubbleSort(C,N):
for i in range (0,N,1):
for j in range(N-1,i,-1):
if int(C[j][1:2]) < int(C[j-1][1:2]):
tmp = C[j]
C[j] = C[j-1]
C[j-1] = tmp
print((' '.join(C)))
#選択ソート
def SelectionSort(C,N):
for i in range(0,N,1):
minj = i
for j in range(i,N,1):
if int(C[j][1:2]) < int(C[minj][1:2]):
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
print((' '.join(C)))
N = int(eval(input()))
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()
BubbleSort(Bubble_A,N)
print("Stable")
SelectionSort(Selection_A,N)
flag = True
for Bubble,Selection in zip(Bubble_A,Selection_A):
if Bubble != Selection:
flag = False
if flag :
print("Stable")
else:
print("Not stable")
| 61
| 43
| 1,593
| 915
|
# #バブルソート
# def BubbleSort(C,N):
# for i in range (0,N,1):
# for j in range(N-1,i-1,-1):
# if int(C[j][1:2]) < int(C[j-1][1:2]):
# tmp = C[j]
# C[j] = C[j-1]
# C[j-1] = tmp
# print(' '.join(C))
# バブルソート
def BubbleSort(C, N):
flag = 1
while flag:
flag = 0
for j in range(N - 1, 0, -1):
if int(C[j][1:2]) < int(C[j - 1][1:2]):
tmp = C[j]
C[j] = C[j - 1]
C[j - 1] = tmp
flag = 1
print((" ".join(C)))
# 選択ソート
def SelectionSort(C, N):
for i in range(0, N, 1):
minj = i
for j in range(i, N, 1):
if int(C[j][1:2]) < int(C[minj][1:2]):
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
print((" ".join(C)))
# 安定かどうかの判定
def isStable(inp, out, N):
for i in range(0, N):
for j in range(i + 1, N):
for a in range(0, N):
for b in range(a + 1, N):
# print("inp(i,j):",inp[i],inp[j],"out(b,a):",out[b],out[a]+"\n")
if (
int(inp[i][1]) == int(inp[j][1])
and inp[i] == out[b]
and inp[j] == out[a]
):
print("Not stable")
return
print("Stable")
# 愚直に調べるパターン
N = int(eval(input()))
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()
BubbleSort(Bubble_A, N)
isStable(A, Bubble_A, N)
SelectionSort(Selection_A, N)
isStable(A, Selection_A, N)
|
# バブルソート
def BubbleSort(C, N):
for i in range(0, N, 1):
for j in range(N - 1, i, -1):
if int(C[j][1:2]) < int(C[j - 1][1:2]):
tmp = C[j]
C[j] = C[j - 1]
C[j - 1] = tmp
print((" ".join(C)))
# 選択ソート
def SelectionSort(C, N):
for i in range(0, N, 1):
minj = i
for j in range(i, N, 1):
if int(C[j][1:2]) < int(C[minj][1:2]):
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
print((" ".join(C)))
N = int(eval(input()))
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()
BubbleSort(Bubble_A, N)
print("Stable")
SelectionSort(Selection_A, N)
flag = True
for Bubble, Selection in zip(Bubble_A, Selection_A):
if Bubble != Selection:
flag = False
if flag:
print("Stable")
else:
print("Not stable")
| false
| 29.508197
|
[
"-# #バブルソート",
"-# def BubbleSort(C,N):",
"-# for i in range (0,N,1):",
"-# for j in range(N-1,i-1,-1):",
"-# if int(C[j][1:2]) < int(C[j-1][1:2]):",
"-# tmp = C[j]",
"-# C[j] = C[j-1]",
"-# C[j-1] = tmp",
"-# print(' '.join(C))",
"- flag = 1",
"- while flag:",
"- flag = 0",
"- for j in range(N - 1, 0, -1):",
"+ for i in range(0, N, 1):",
"+ for j in range(N - 1, i, -1):",
"- flag = 1",
"-# 安定かどうかの判定",
"-def isStable(inp, out, N):",
"- for i in range(0, N):",
"- for j in range(i + 1, N):",
"- for a in range(0, N):",
"- for b in range(a + 1, N):",
"- # print(\"inp(i,j):\",inp[i],inp[j],\"out(b,a):\",out[b],out[a]+\"\\n\")",
"- if (",
"- int(inp[i][1]) == int(inp[j][1])",
"- and inp[i] == out[b]",
"- and inp[j] == out[a]",
"- ):",
"- print(\"Not stable\")",
"- return",
"- print(\"Stable\")",
"-",
"-",
"-# 愚直に調べるパターン",
"-isStable(A, Bubble_A, N)",
"+print(\"Stable\")",
"-isStable(A, Selection_A, N)",
"+flag = True",
"+for Bubble, Selection in zip(Bubble_A, Selection_A):",
"+ if Bubble != Selection:",
"+ flag = False",
"+if flag:",
"+ print(\"Stable\")",
"+else:",
"+ print(\"Not stable\")"
] | false
| 0.156106
| 0.044612
| 3.499172
|
[
"s824703209",
"s521199493"
] |
u226155577
|
p03676
|
python
|
s376288592
|
s056877046
| 698
| 645
| 17,092
| 20,272
|
Accepted
|
Accepted
| 7.59
|
n,*A=list(map(int,open(0).read().split()))
f=[1]*(n+2);r=f[:]
MOD=10**9+7
for i in range(n+1):f[i+1]=e=f[i]*-~i%MOD;r[i+1]=pow(e,MOD-2,MOD)
B=[0]*(n+1)
for a in A:B[a]+=1
i=B.index(2)
L=A.index(i);R=A.index(i,L+1)
for k in range(1,n+2):
print(((f[n+1]*r[k]*r[n+1-k]-(k<=L+n+1-R and f[L-1+n+1-R]*r[k-1]*r[L+n+1-k-R]))%MOD))
|
n,*A=list(map(int,open(0).read().split()));n+=1;f=[1]*-~n;r=f[:];M=10**9+7
for a in A:r[a]+=1
i=r.index(3);d=A.index;L=d(i);L+=n-d(i,L+1);*X,=list(range(1,n+1))
for i in X:f[i]=e=f[i-1]*i%M;r[i]=pow(e,M-2,M)
for k in X:print(((f[n]*r[k]*r[n-k]-(k<=L)*(f[L-1]*r[k-1]*r[L-k]))%M))
| 10
| 5
| 327
| 269
|
n, *A = list(map(int, open(0).read().split()))
f = [1] * (n + 2)
r = f[:]
MOD = 10**9 + 7
for i in range(n + 1):
f[i + 1] = e = f[i] * -~i % MOD
r[i + 1] = pow(e, MOD - 2, MOD)
B = [0] * (n + 1)
for a in A:
B[a] += 1
i = B.index(2)
L = A.index(i)
R = A.index(i, L + 1)
for k in range(1, n + 2):
print(
(
(
f[n + 1] * r[k] * r[n + 1 - k]
- (
k <= L + n + 1 - R
and f[L - 1 + n + 1 - R] * r[k - 1] * r[L + n + 1 - k - R]
)
)
% MOD
)
)
|
n, *A = list(map(int, open(0).read().split()))
n += 1
f = [1] * -~n
r = f[:]
M = 10**9 + 7
for a in A:
r[a] += 1
i = r.index(3)
d = A.index
L = d(i)
L += n - d(i, L + 1)
(*X,) = list(range(1, n + 1))
for i in X:
f[i] = e = f[i - 1] * i % M
r[i] = pow(e, M - 2, M)
for k in X:
print(((f[n] * r[k] * r[n - k] - (k <= L) * (f[L - 1] * r[k - 1] * r[L - k])) % M))
| false
| 50
|
[
"-f = [1] * (n + 2)",
"+n += 1",
"+f = [1] * -~n",
"-MOD = 10**9 + 7",
"-for i in range(n + 1):",
"- f[i + 1] = e = f[i] * -~i % MOD",
"- r[i + 1] = pow(e, MOD - 2, MOD)",
"-B = [0] * (n + 1)",
"+M = 10**9 + 7",
"- B[a] += 1",
"-i = B.index(2)",
"-L = A.index(i)",
"-R = A.index(i, L + 1)",
"-for k in range(1, n + 2):",
"- print(",
"- (",
"- (",
"- f[n + 1] * r[k] * r[n + 1 - k]",
"- - (",
"- k <= L + n + 1 - R",
"- and f[L - 1 + n + 1 - R] * r[k - 1] * r[L + n + 1 - k - R]",
"- )",
"- )",
"- % MOD",
"- )",
"- )",
"+ r[a] += 1",
"+i = r.index(3)",
"+d = A.index",
"+L = d(i)",
"+L += n - d(i, L + 1)",
"+(*X,) = list(range(1, n + 1))",
"+for i in X:",
"+ f[i] = e = f[i - 1] * i % M",
"+ r[i] = pow(e, M - 2, M)",
"+for k in X:",
"+ print(((f[n] * r[k] * r[n - k] - (k <= L) * (f[L - 1] * r[k - 1] * r[L - k])) % M))"
] | false
| 0.041946
| 0.042045
| 0.997643
|
[
"s376288592",
"s056877046"
] |
u187516587
|
p02702
|
python
|
s408821732
|
s921327687
| 1,889
| 1,446
| 78,932
| 72,140
|
Accepted
|
Accepted
| 23.45
|
S=eval(input())
a=0
b=[0]*2019
No=[None]*2019
for i in S:
l=No.copy()
k=int(i)
for j in range(2019):
l[(j*10+k)%2019]=b[j]
l[k]+=1
a+=l[0]
b=l
print(a)
|
def main():
S=eval(input())
a=0
b=[0]*2019
No=[0]*2019
for i in S:
l=No.copy()
k=int(i)
for j in range(2019):
l[(j*10+k)%2019]=b[j]
l[k]+=1
a+=l[0]
b=l
print(a)
main()
| 13
| 15
| 190
| 260
|
S = eval(input())
a = 0
b = [0] * 2019
No = [None] * 2019
for i in S:
l = No.copy()
k = int(i)
for j in range(2019):
l[(j * 10 + k) % 2019] = b[j]
l[k] += 1
a += l[0]
b = l
print(a)
|
def main():
S = eval(input())
a = 0
b = [0] * 2019
No = [0] * 2019
for i in S:
l = No.copy()
k = int(i)
for j in range(2019):
l[(j * 10 + k) % 2019] = b[j]
l[k] += 1
a += l[0]
b = l
print(a)
main()
| false
| 13.333333
|
[
"-S = eval(input())",
"-a = 0",
"-b = [0] * 2019",
"-No = [None] * 2019",
"-for i in S:",
"- l = No.copy()",
"- k = int(i)",
"- for j in range(2019):",
"- l[(j * 10 + k) % 2019] = b[j]",
"- l[k] += 1",
"- a += l[0]",
"- b = l",
"-print(a)",
"+def main():",
"+ S = eval(input())",
"+ a = 0",
"+ b = [0] * 2019",
"+ No = [0] * 2019",
"+ for i in S:",
"+ l = No.copy()",
"+ k = int(i)",
"+ for j in range(2019):",
"+ l[(j * 10 + k) % 2019] = b[j]",
"+ l[k] += 1",
"+ a += l[0]",
"+ b = l",
"+ print(a)",
"+",
"+",
"+main()"
] | false
| 0.037274
| 0.037294
| 0.999476
|
[
"s408821732",
"s921327687"
] |
u947883560
|
p03003
|
python
|
s025410988
|
s659483101
| 451
| 376
| 73,180
| 73,308
|
Accepted
|
Accepted
| 16.63
|
#!/usr/bin/env python3
import sys
INF = float("inf")
MOD = 1000000007 # type: int
def solve(N: int, M: int, S: "List[int]", T: "List[int]"):
DP = [[1]*(N+1) for _ in range(M+1)]
for i in range(1, N+1):
for j in range(1, M+1):
DP[j][i] = DP[j-1][i] + DP[j][i-1] - \
DP[j-1][i-1]
DP[j][i] %= MOD
if S[i-1] == T[j-1]:
DP[j][i] += DP[j-1][i-1]
DP[j][i] %= MOD
# print(*DP, sep="\n")
print(DP[M][N])
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
M = int(next(tokens)) # type: int
S = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
T = [int(next(tokens)) for _ in range(M)] # type: "List[int]"
solve(N, M, S, T)
if __name__ == '__main__':
main()
|
#!/usr/bin/env python3
import sys
INF = float("inf")
MOD = 1000000007 # type: int
def solve(N: int, M: int, S: "List[int]", T: "List[int]"):
DP = [[1]*(N+1) for _ in range(M+1)]
for j in range(1, M+1):
for i in range(1, N+1):
DP[j][i] = DP[j-1][i] + DP[j][i-1] - \
DP[j-1][i-1]
DP[j][i] %= MOD
if S[i-1] == T[j-1]:
DP[j][i] += DP[j-1][i-1]
DP[j][i] %= MOD
# print(*DP, sep="\n")
print(DP[M][N])
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
M = int(next(tokens)) # type: int
S = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
T = [int(next(tokens)) for _ in range(M)] # type: "List[int]"
solve(N, M, S, T)
if __name__ == '__main__':
main()
| 38
| 38
| 986
| 986
|
#!/usr/bin/env python3
import sys
INF = float("inf")
MOD = 1000000007 # type: int
def solve(N: int, M: int, S: "List[int]", T: "List[int]"):
DP = [[1] * (N + 1) for _ in range(M + 1)]
for i in range(1, N + 1):
for j in range(1, M + 1):
DP[j][i] = DP[j - 1][i] + DP[j][i - 1] - DP[j - 1][i - 1]
DP[j][i] %= MOD
if S[i - 1] == T[j - 1]:
DP[j][i] += DP[j - 1][i - 1]
DP[j][i] %= MOD
# print(*DP, sep="\n")
print(DP[M][N])
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
M = int(next(tokens)) # type: int
S = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
T = [int(next(tokens)) for _ in range(M)] # type: "List[int]"
solve(N, M, S, T)
if __name__ == "__main__":
main()
|
#!/usr/bin/env python3
import sys
INF = float("inf")
MOD = 1000000007 # type: int
def solve(N: int, M: int, S: "List[int]", T: "List[int]"):
DP = [[1] * (N + 1) for _ in range(M + 1)]
for j in range(1, M + 1):
for i in range(1, N + 1):
DP[j][i] = DP[j - 1][i] + DP[j][i - 1] - DP[j - 1][i - 1]
DP[j][i] %= MOD
if S[i - 1] == T[j - 1]:
DP[j][i] += DP[j - 1][i - 1]
DP[j][i] %= MOD
# print(*DP, sep="\n")
print(DP[M][N])
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
M = int(next(tokens)) # type: int
S = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
T = [int(next(tokens)) for _ in range(M)] # type: "List[int]"
solve(N, M, S, T)
if __name__ == "__main__":
main()
| false
| 0
|
[
"- for i in range(1, N + 1):",
"- for j in range(1, M + 1):",
"+ for j in range(1, M + 1):",
"+ for i in range(1, N + 1):"
] | false
| 0.049792
| 0.048407
| 1.028616
|
[
"s025410988",
"s659483101"
] |
u987164499
|
p02995
|
python
|
s943107406
|
s032856332
| 36
| 28
| 5,048
| 9,144
|
Accepted
|
Accepted
| 22.22
|
from sys import stdin
import fractions
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = fractions.gcd(c, d)
koubai = c * d // fractions.gcd(c, d)
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print((b_s - a_s))
|
from math import gcd
def lcm(x, y):
return (x * y)//gcd(x, y)
a,b,c,d = list(map(int,input().split()))
cd = lcm(c,d)
ab = b-a+1
print((ab-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//cd-(a-1)//cd)))
| 8
| 11
| 274
| 199
|
from sys import stdin
import fractions
a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = fractions.gcd(c, d)
koubai = c * d // fractions.gcd(c, d)
b_s = b - b // c - b // d + b // koubai
a_s = a - 1 - (a - 1) // c - (a - 1) // d + (a - 1) // koubai
print((b_s - a_s))
|
from math import gcd
def lcm(x, y):
return (x * y) // gcd(x, y)
a, b, c, d = list(map(int, input().split()))
cd = lcm(c, d)
ab = b - a + 1
print(
(ab - (b // c - (a - 1) // c) - (b // d - (a - 1) // d) + (b // cd - (a - 1) // cd))
)
| false
| 27.272727
|
[
"-from sys import stdin",
"-import fractions",
"+from math import gcd",
"-a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]",
"-kouyaku = fractions.gcd(c, d)",
"-koubai = c * d // fractions.gcd(c, d)",
"-b_s = b - b // c - b // d + b // koubai",
"-a_s = a - 1 - (a - 1) // c - (a - 1) // d + (a - 1) // koubai",
"-print((b_s - a_s))",
"+",
"+def lcm(x, y):",
"+ return (x * y) // gcd(x, y)",
"+",
"+",
"+a, b, c, d = list(map(int, input().split()))",
"+cd = lcm(c, d)",
"+ab = b - a + 1",
"+print(",
"+ (ab - (b // c - (a - 1) // c) - (b // d - (a - 1) // d) + (b // cd - (a - 1) // cd))",
"+)"
] | false
| 0.138782
| 0.092428
| 1.501515
|
[
"s943107406",
"s032856332"
] |
u222668979
|
p02572
|
python
|
s233620152
|
s793976692
| 137
| 126
| 102,008
| 94,208
|
Accepted
|
Accepted
| 8.03
|
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans, acc = 0, list(accumulate(a))
for i in range(n - 1):
ans += a[i] * (acc[-1] - acc[i])
ans %= mod
print(ans)
|
n = int(eval(input()))
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math
for i in range(n):
reje = num - a[i]
k += reje * a[i]
x = k//2
t = 10 ** 9 + 7
ans = x % t
print(ans)
| 11
| 15
| 236
| 211
|
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans, acc = 0, list(accumulate(a))
for i in range(n - 1):
ans += a[i] * (acc[-1] - acc[i])
ans %= mod
print(ans)
|
n = int(eval(input()))
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math
for i in range(n):
reje = num - a[i]
k += reje * a[i]
x = k // 2
t = 10**9 + 7
ans = x % t
print(ans)
| false
| 26.666667
|
[
"-from itertools import accumulate",
"-",
"-mod = 10**9 + 7",
"-ans, acc = 0, list(accumulate(a))",
"-for i in range(n - 1):",
"- ans += a[i] * (acc[-1] - acc[i])",
"- ans %= mod",
"+k = 0",
"+num = sum(a)",
"+import math",
"+",
"+for i in range(n):",
"+ reje = num - a[i]",
"+ k += reje * a[i]",
"+x = k // 2",
"+t = 10**9 + 7",
"+ans = x % t"
] | false
| 0.101134
| 0.068079
| 1.485533
|
[
"s233620152",
"s793976692"
] |
u170183831
|
p03687
|
python
|
s427628114
|
s787406507
| 237
| 211
| 43,112
| 42,348
|
Accepted
|
Accepted
| 10.97
|
from collections import Counter
def solve(s):
cs = Counter(s).most_common()
m = len(s)
for c in cs:
news = list(s)
size = len(s)
count = 0
while len(Counter(news[:size]).most_common()) > 1:
for i in range(size - 1):
if news[i] != c[0] and news[i + 1] == c[0]:
news[i] = c[0]
size -= 1
count += 1
if count < m:
m = count
return m
_s = eval(input())
print((solve(_s)))
|
from collections import Counter
def solve(s):
cs = Counter(s)
m = len(s)
for c in cs:
news = list(s)
size = len(s)
count = 0
while len(Counter(news[:size])) > 1:
for i in range(size - 1):
if news[i] != c[0] and news[i + 1] == c[0]:
news[i] = c[0]
size -= 1
count += 1
if count < m:
m = count
return m
_s = eval(input())
print((solve(_s)))
| 21
| 21
| 521
| 493
|
from collections import Counter
def solve(s):
cs = Counter(s).most_common()
m = len(s)
for c in cs:
news = list(s)
size = len(s)
count = 0
while len(Counter(news[:size]).most_common()) > 1:
for i in range(size - 1):
if news[i] != c[0] and news[i + 1] == c[0]:
news[i] = c[0]
size -= 1
count += 1
if count < m:
m = count
return m
_s = eval(input())
print((solve(_s)))
|
from collections import Counter
def solve(s):
cs = Counter(s)
m = len(s)
for c in cs:
news = list(s)
size = len(s)
count = 0
while len(Counter(news[:size])) > 1:
for i in range(size - 1):
if news[i] != c[0] and news[i + 1] == c[0]:
news[i] = c[0]
size -= 1
count += 1
if count < m:
m = count
return m
_s = eval(input())
print((solve(_s)))
| false
| 0
|
[
"- cs = Counter(s).most_common()",
"+ cs = Counter(s)",
"- while len(Counter(news[:size]).most_common()) > 1:",
"+ while len(Counter(news[:size])) > 1:"
] | false
| 0.035182
| 0.036387
| 0.966895
|
[
"s427628114",
"s787406507"
] |
u077291787
|
p03665
|
python
|
s494490743
|
s482440762
| 21
| 18
| 3,316
| 3,060
|
Accepted
|
Accepted
| 14.29
|
# AGC017A - Biscuits
def main():
n, p = tuple(map(int, input().rstrip().split()))
A = tuple([int(x) % 2 for x in input().rstrip().split()])
if sum(A) == 0: # all numbers are even
print((2 ** n if p == 0 else 0))
else:
print((2 ** (n - 1)))
if __name__ == "__main__":
main()
|
# AGC017A - Biscuits
def main():
N, P, *A = list(map(int, open(0).read().split()))
total = sum(i % 2 for i in A)
if total == 0: # all numbers are even
flg = P == 0
print((2 ** N if flg else 0))
else:
print((2 ** (N - 1)))
if __name__ == "__main__":
main()
| 12
| 13
| 324
| 304
|
# AGC017A - Biscuits
def main():
n, p = tuple(map(int, input().rstrip().split()))
A = tuple([int(x) % 2 for x in input().rstrip().split()])
if sum(A) == 0: # all numbers are even
print((2**n if p == 0 else 0))
else:
print((2 ** (n - 1)))
if __name__ == "__main__":
main()
|
# AGC017A - Biscuits
def main():
N, P, *A = list(map(int, open(0).read().split()))
total = sum(i % 2 for i in A)
if total == 0: # all numbers are even
flg = P == 0
print((2**N if flg else 0))
else:
print((2 ** (N - 1)))
if __name__ == "__main__":
main()
| false
| 7.692308
|
[
"- n, p = tuple(map(int, input().rstrip().split()))",
"- A = tuple([int(x) % 2 for x in input().rstrip().split()])",
"- if sum(A) == 0: # all numbers are even",
"- print((2**n if p == 0 else 0))",
"+ N, P, *A = list(map(int, open(0).read().split()))",
"+ total = sum(i % 2 for i in A)",
"+ if total == 0: # all numbers are even",
"+ flg = P == 0",
"+ print((2**N if flg else 0))",
"- print((2 ** (n - 1)))",
"+ print((2 ** (N - 1)))"
] | false
| 0.048655
| 0.048841
| 0.996193
|
[
"s494490743",
"s482440762"
] |
u197968862
|
p03163
|
python
|
s619754183
|
s962483579
| 1,109
| 688
| 310,068
| 171,784
|
Accepted
|
Accepted
| 37.96
|
n, w = list(map(int,input().split()))
wv = [list(map(int,input().split())) for _ in range(n)]
def knapsack(n,w,wv):
inf = float('inf')
dp = [[-inf for _ in range(w+1)] for _ in range(n+1)]
for i in range(w+1): dp[0][i] = 0
for i in range(n):
for w in range(w+1):
if wv[i][0]<=w:
dp[i+1][w] = max(dp[i][w-wv[i][0]]+wv[i][1],dp[i][w])
else:
dp[i+1][w] = dp[i][w]
return dp[n][w]
print((knapsack(n,w,wv)))
|
n, w = list(map(int,input().split()))
wv = [list(map(int,input().split())) for _ in range(n)]
dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
for i in range(n):
for j in range(w+1):
if wv[i][0] <= j:
dp[i+1][j] = max(dp[i][j-wv[i][0]]+wv[i][1],dp[i][j])
else:
dp[i+1][j] = dp[i][j]
print((max(dp[-1])))
| 17
| 13
| 497
| 356
|
n, w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]
def knapsack(n, w, wv):
inf = float("inf")
dp = [[-inf for _ in range(w + 1)] for _ in range(n + 1)]
for i in range(w + 1):
dp[0][i] = 0
for i in range(n):
for w in range(w + 1):
if wv[i][0] <= w:
dp[i + 1][w] = max(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])
else:
dp[i + 1][w] = dp[i][w]
return dp[n][w]
print((knapsack(n, w, wv)))
|
n, w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
for i in range(n):
for j in range(w + 1):
if wv[i][0] <= j:
dp[i + 1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])
else:
dp[i + 1][j] = dp[i][j]
print((max(dp[-1])))
| false
| 23.529412
|
[
"-",
"-",
"-def knapsack(n, w, wv):",
"- inf = float(\"inf\")",
"- dp = [[-inf for _ in range(w + 1)] for _ in range(n + 1)]",
"- for i in range(w + 1):",
"- dp[0][i] = 0",
"- for i in range(n):",
"- for w in range(w + 1):",
"- if wv[i][0] <= w:",
"- dp[i + 1][w] = max(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])",
"- else:",
"- dp[i + 1][w] = dp[i][w]",
"- return dp[n][w]",
"-",
"-",
"-print((knapsack(n, w, wv)))",
"+dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]",
"+for i in range(n):",
"+ for j in range(w + 1):",
"+ if wv[i][0] <= j:",
"+ dp[i + 1][j] = max(dp[i][j - wv[i][0]] + wv[i][1], dp[i][j])",
"+ else:",
"+ dp[i + 1][j] = dp[i][j]",
"+print((max(dp[-1])))"
] | false
| 0.045877
| 0.044283
| 1.035992
|
[
"s619754183",
"s962483579"
] |
u652583512
|
p02606
|
python
|
s857152574
|
s826348907
| 150
| 100
| 61,316
| 61,712
|
Accepted
|
Accepted
| 33.33
|
L, R, D = list(map(int, input().split()))
ans = 0
for i in range(L, R + 1):
if i % D == 0:
ans += 1
print(ans)
|
L, R, D = list(map(int, input().split()))
first = L + (D - (L % D)) % D
last = R - (R % D)
ans = 0
if L <= first <= R and L <= last <= R:
ans = (last - first) // D + 1
print(ans)
| 8
| 10
| 126
| 189
|
L, R, D = list(map(int, input().split()))
ans = 0
for i in range(L, R + 1):
if i % D == 0:
ans += 1
print(ans)
|
L, R, D = list(map(int, input().split()))
first = L + (D - (L % D)) % D
last = R - (R % D)
ans = 0
if L <= first <= R and L <= last <= R:
ans = (last - first) // D + 1
print(ans)
| false
| 20
|
[
"+first = L + (D - (L % D)) % D",
"+last = R - (R % D)",
"-for i in range(L, R + 1):",
"- if i % D == 0:",
"- ans += 1",
"+if L <= first <= R and L <= last <= R:",
"+ ans = (last - first) // D + 1"
] | false
| 0.049325
| 0.049957
| 0.987356
|
[
"s857152574",
"s826348907"
] |
u941753895
|
p03044
|
python
|
s922669593
|
s131994766
| 871
| 394
| 88,008
| 83,476
|
Accepted
|
Accepted
| 54.76
|
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
visited=[False]*(10**5)
ans=[-1]*(10**5)
def f(n,edges,s):
all_visited=True
for i in range(n):
if visited[i]==False:
all_visited=False
break
if all_visited:
return
for x,c in edges[s]:
if visited[x]:
continue
if ans[s]==0:
if c%2==1:
ans[x]=1
else:
ans[x]=0
else:
if c%2==1:
ans[x]=0
else:
ans[x]=1
visited[x]=True
f(n,edges,x)
def main():
n=I()
edges=[[] for _ in range(n)]
for _ in range(n-1):
a,b,c=LI()
a-=1
b-=1
edges[a].append([b,c])
edges[b].append([a,c])
ans[0]=0
visited[0]=True
f(n,edges,0)
for x in ans[:n]:
print(x)
main()
# print(main())
|
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
color=[-1]*100100
G=[[] for _ in range(100100)]
def f(st):
st_c=color[st]
for v,d in G[st]:
if color[v]!=-1:
continue
if d%2==0:
color[v]=st_c
else:
color[v]=abs(st_c-1)
f(v)
def main():
n=I()
for _ in range(n-1):
a,b,c=LI()
a-=1
b-=1
G[a].append((b,c))
G[b].append((a,c))
color[0]=0
f(0)
for i in range(n):
print((color[i]))
main()
# print(main())
| 63
| 48
| 1,229
| 979
|
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
visited = [False] * (10**5)
ans = [-1] * (10**5)
def f(n, edges, s):
all_visited = True
for i in range(n):
if visited[i] == False:
all_visited = False
break
if all_visited:
return
for x, c in edges[s]:
if visited[x]:
continue
if ans[s] == 0:
if c % 2 == 1:
ans[x] = 1
else:
ans[x] = 0
else:
if c % 2 == 1:
ans[x] = 0
else:
ans[x] = 1
visited[x] = True
f(n, edges, x)
def main():
n = I()
edges = [[] for _ in range(n)]
for _ in range(n - 1):
a, b, c = LI()
a -= 1
b -= 1
edges[a].append([b, c])
edges[b].append([a, c])
ans[0] = 0
visited[0] = True
f(n, edges, 0)
for x in ans[:n]:
print(x)
main()
# print(main())
|
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
color = [-1] * 100100
G = [[] for _ in range(100100)]
def f(st):
st_c = color[st]
for v, d in G[st]:
if color[v] != -1:
continue
if d % 2 == 0:
color[v] = st_c
else:
color[v] = abs(st_c - 1)
f(v)
def main():
n = I()
for _ in range(n - 1):
a, b, c = LI()
a -= 1
b -= 1
G[a].append((b, c))
G[b].append((a, c))
color[0] = 0
f(0)
for i in range(n):
print((color[i]))
main()
# print(main())
| false
| 23.809524
|
[
"-def LF():",
"- return [float(x) for x in sys.stdin.readline().split()]",
"+# def LF(): return [float(x) for x in sys.stdin.readline().split()]",
"+def I():",
"+ return int(sys.stdin.readline())",
"-def I():",
"- return int(sys.stdin.readline())",
"+def F():",
"+ return float(sys.stdin.readline())",
"-visited = [False] * (10**5)",
"-ans = [-1] * (10**5)",
"+color = [-1] * 100100",
"+G = [[] for _ in range(100100)]",
"-def f(n, edges, s):",
"- all_visited = True",
"- for i in range(n):",
"- if visited[i] == False:",
"- all_visited = False",
"- break",
"- if all_visited:",
"- return",
"- for x, c in edges[s]:",
"- if visited[x]:",
"+def f(st):",
"+ st_c = color[st]",
"+ for v, d in G[st]:",
"+ if color[v] != -1:",
"- if ans[s] == 0:",
"- if c % 2 == 1:",
"- ans[x] = 1",
"- else:",
"- ans[x] = 0",
"+ if d % 2 == 0:",
"+ color[v] = st_c",
"- if c % 2 == 1:",
"- ans[x] = 0",
"- else:",
"- ans[x] = 1",
"- visited[x] = True",
"- f(n, edges, x)",
"+ color[v] = abs(st_c - 1)",
"+ f(v)",
"- edges = [[] for _ in range(n)]",
"- edges[a].append([b, c])",
"- edges[b].append([a, c])",
"- ans[0] = 0",
"- visited[0] = True",
"- f(n, edges, 0)",
"- for x in ans[:n]:",
"- print(x)",
"+ G[a].append((b, c))",
"+ G[b].append((a, c))",
"+ color[0] = 0",
"+ f(0)",
"+ for i in range(n):",
"+ print((color[i]))"
] | false
| 0.047422
| 0.073035
| 0.649302
|
[
"s922669593",
"s131994766"
] |
u680851063
|
p03212
|
python
|
s340676170
|
s582467731
| 118
| 55
| 25,004
| 8,052
|
Accepted
|
Accepted
| 53.39
|
from itertools import product
n = int(eval(input()))
a = ['7','5','3']
x =[]
for i in range(3,11):
x += list(product(a, repeat = i))
y = []
for j in x:
if '7' in j and '5' in j and '3' in j:
y.append(j)
z = []
for k in range(len(y)):
z.append(''.join(y[k]))
z = [int(_) for _ in z]
b = 0
for p in z:
if p <= n:
b += 1
print(b)
|
from itertools import product
l = []
for _ in range(3,10):
tmp = list(product('753', repeat = _))
l += tmp
m = []
for i in l:
if len(set(i)) == 3:
m.append(int(''.join(i)))
n = int(eval(input()))
ans = 0
for j in m:
if j <= n:
ans += 1
print(ans)
| 22
| 18
| 377
| 291
|
from itertools import product
n = int(eval(input()))
a = ["7", "5", "3"]
x = []
for i in range(3, 11):
x += list(product(a, repeat=i))
y = []
for j in x:
if "7" in j and "5" in j and "3" in j:
y.append(j)
z = []
for k in range(len(y)):
z.append("".join(y[k]))
z = [int(_) for _ in z]
b = 0
for p in z:
if p <= n:
b += 1
print(b)
|
from itertools import product
l = []
for _ in range(3, 10):
tmp = list(product("753", repeat=_))
l += tmp
m = []
for i in l:
if len(set(i)) == 3:
m.append(int("".join(i)))
n = int(eval(input()))
ans = 0
for j in m:
if j <= n:
ans += 1
print(ans)
| false
| 18.181818
|
[
"+l = []",
"+for _ in range(3, 10):",
"+ tmp = list(product(\"753\", repeat=_))",
"+ l += tmp",
"+m = []",
"+for i in l:",
"+ if len(set(i)) == 3:",
"+ m.append(int(\"\".join(i)))",
"-a = [\"7\", \"5\", \"3\"]",
"-x = []",
"-for i in range(3, 11):",
"- x += list(product(a, repeat=i))",
"-y = []",
"-for j in x:",
"- if \"7\" in j and \"5\" in j and \"3\" in j:",
"- y.append(j)",
"-z = []",
"-for k in range(len(y)):",
"- z.append(\"\".join(y[k]))",
"-z = [int(_) for _ in z]",
"-b = 0",
"-for p in z:",
"- if p <= n:",
"- b += 1",
"-print(b)",
"+ans = 0",
"+for j in m:",
"+ if j <= n:",
"+ ans += 1",
"+print(ans)"
] | false
| 0.226305
| 0.192854
| 1.173451
|
[
"s340676170",
"s582467731"
] |
u512266180
|
p03200
|
python
|
s446304858
|
s793536201
| 115
| 100
| 3,500
| 3,500
|
Accepted
|
Accepted
| 13.04
|
s=eval(input())
count=0
b=s.count("B")
w=s.count("W")
for x in range(len(s)):
if s[x:x+1] == "B":
count += w
b-=1
elif s[x:x+1] == "W":
w-=1
if w == 0:
break
print(count)
|
s=eval(input())
count=0
b=s.count("B")
w=s.count("W")
for x in range(len(s)):
if s[x:x+1] == "B":
count += w
b-=1
elif s[x:x+1] == "W":
w-=1
print(count)
| 14
| 12
| 222
| 199
|
s = eval(input())
count = 0
b = s.count("B")
w = s.count("W")
for x in range(len(s)):
if s[x : x + 1] == "B":
count += w
b -= 1
elif s[x : x + 1] == "W":
w -= 1
if w == 0:
break
print(count)
|
s = eval(input())
count = 0
b = s.count("B")
w = s.count("W")
for x in range(len(s)):
if s[x : x + 1] == "B":
count += w
b -= 1
elif s[x : x + 1] == "W":
w -= 1
print(count)
| false
| 14.285714
|
[
"- if w == 0:",
"- break"
] | false
| 0.031905
| 0.032968
| 0.967753
|
[
"s446304858",
"s793536201"
] |
u631277801
|
p03223
|
python
|
s631954117
|
s040714831
| 870
| 788
| 11,856
| 10,616
|
Accepted
|
Accepted
| 9.43
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from collections import deque
n = ni()
a = []
for _ in range(n):
a.append(ni())
mx_cent = [ai for ai in a]
mn_cent = [ai for ai in a]
a.sort()
a = deque(a)
mx_cent = deque([ai for ai in a])
mn_cent = deque([ai for ai in a])
bmx = deque([mx_cent.pop()])
bmn = deque([mn_cent.popleft()])
cnt = 0
while len(mx_cent) > 1:
lf = 0
rt = 0
if cnt % 2 == 0:
lf = mx_cent.popleft()
rt = mx_cent.popleft()
else:
lf = mx_cent.pop()
rt = mx_cent.pop()
bmx.appendleft(lf)
bmx.append(rt)
if cnt % 2 == 0:
lf = mn_cent.pop()
rt = mn_cent.pop()
else:
lf = mn_cent.popleft()
rt = mn_cent.popleft()
bmn.appendleft(lf)
bmn.append(rt)
cnt += 1
if len(mx_cent) == 1:
last = mx_cent.pop()
if abs(bmx[0] - last) > abs(bmx[-1] - last):
bmx.appendleft(last)
else:
bmx.append(last)
last = mn_cent.pop()
if abs(bmn[0] - last) > abs(bmn[-1] - last):
bmn.appendleft(last)
else:
bmn.append(last)
diffmx, diffmn = 0, 0
for i in range(n-1):
diffmx += abs(bmx[i+1] - bmx[i])
diffmn += abs(bmn[i+1] - bmn[i])
print((max(diffmx, diffmn)))
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from collections import deque
n = ni()
a = [ni() for _ in range(n)]
a.sort()
b = a.copy()
c = a.copy()
# 小さい順に詰める
bdeq = deque(b)
bret = deque()
bret.append(bdeq.popleft())
push_small = False
while len(bdeq) > 1:
if push_small:
bret.append(bdeq.popleft())
bret.appendleft(bdeq.popleft())
push_small = False
else:
bret.append(bdeq.pop())
bret.appendleft(bdeq.pop())
push_small = True
if len(bdeq) > 0:
if abs(bdeq[0] - bret[0]) > abs(bdeq[0] - bret[-1]):
bret.appendleft(bdeq[0])
else:
bret.append(bdeq[0])
# 大きい順に詰める
cdeq = deque(c)
cret = deque()
cret.append(cdeq.pop())
push_small = True
while len(cdeq) > 1:
if push_small:
cret.append(cdeq.popleft())
cret.appendleft(cdeq.popleft())
push_small = False
else:
cret.append(cdeq.pop())
cret.appendleft(cdeq.pop())
push_small = True
if len(cdeq) > 0:
if abs(cdeq[0] - cret[0]) > abs(cdeq[0] - cret[-1]):
cret.appendleft(cdeq[0])
else:
cret.append(cdeq[0])
# 答えが大きいほうを選択
bans = 0
for i in range(n-1):
bans += abs(bret[i] - bret[i+1])
cans = 0
for i in range(n-1):
cans += abs(cret[i] - cret[i+1])
print((max(bans, cans)))
| 83
| 80
| 1,756
| 1,760
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
from collections import deque
n = ni()
a = []
for _ in range(n):
a.append(ni())
mx_cent = [ai for ai in a]
mn_cent = [ai for ai in a]
a.sort()
a = deque(a)
mx_cent = deque([ai for ai in a])
mn_cent = deque([ai for ai in a])
bmx = deque([mx_cent.pop()])
bmn = deque([mn_cent.popleft()])
cnt = 0
while len(mx_cent) > 1:
lf = 0
rt = 0
if cnt % 2 == 0:
lf = mx_cent.popleft()
rt = mx_cent.popleft()
else:
lf = mx_cent.pop()
rt = mx_cent.pop()
bmx.appendleft(lf)
bmx.append(rt)
if cnt % 2 == 0:
lf = mn_cent.pop()
rt = mn_cent.pop()
else:
lf = mn_cent.popleft()
rt = mn_cent.popleft()
bmn.appendleft(lf)
bmn.append(rt)
cnt += 1
if len(mx_cent) == 1:
last = mx_cent.pop()
if abs(bmx[0] - last) > abs(bmx[-1] - last):
bmx.appendleft(last)
else:
bmx.append(last)
last = mn_cent.pop()
if abs(bmn[0] - last) > abs(bmn[-1] - last):
bmn.appendleft(last)
else:
bmn.append(last)
diffmx, diffmn = 0, 0
for i in range(n - 1):
diffmx += abs(bmx[i + 1] - bmx[i])
diffmn += abs(bmn[i + 1] - bmn[i])
print((max(diffmx, diffmn)))
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
from collections import deque
n = ni()
a = [ni() for _ in range(n)]
a.sort()
b = a.copy()
c = a.copy()
# 小さい順に詰める
bdeq = deque(b)
bret = deque()
bret.append(bdeq.popleft())
push_small = False
while len(bdeq) > 1:
if push_small:
bret.append(bdeq.popleft())
bret.appendleft(bdeq.popleft())
push_small = False
else:
bret.append(bdeq.pop())
bret.appendleft(bdeq.pop())
push_small = True
if len(bdeq) > 0:
if abs(bdeq[0] - bret[0]) > abs(bdeq[0] - bret[-1]):
bret.appendleft(bdeq[0])
else:
bret.append(bdeq[0])
# 大きい順に詰める
cdeq = deque(c)
cret = deque()
cret.append(cdeq.pop())
push_small = True
while len(cdeq) > 1:
if push_small:
cret.append(cdeq.popleft())
cret.appendleft(cdeq.popleft())
push_small = False
else:
cret.append(cdeq.pop())
cret.appendleft(cdeq.pop())
push_small = True
if len(cdeq) > 0:
if abs(cdeq[0] - cret[0]) > abs(cdeq[0] - cret[-1]):
cret.appendleft(cdeq[0])
else:
cret.append(cdeq[0])
# 答えが大きいほうを選択
bans = 0
for i in range(n - 1):
bans += abs(bret[i] - bret[i + 1])
cans = 0
for i in range(n - 1):
cans += abs(cret[i] - cret[i + 1])
print((max(bans, cans)))
| false
| 3.614458
|
[
"-sys.setrecursionlimit(10**5)",
"+sys.setrecursionlimit(10**7)",
"-a = []",
"-for _ in range(n):",
"- a.append(ni())",
"-mx_cent = [ai for ai in a]",
"-mn_cent = [ai for ai in a]",
"+a = [ni() for _ in range(n)]",
"-a = deque(a)",
"-mx_cent = deque([ai for ai in a])",
"-mn_cent = deque([ai for ai in a])",
"-bmx = deque([mx_cent.pop()])",
"-bmn = deque([mn_cent.popleft()])",
"-cnt = 0",
"-while len(mx_cent) > 1:",
"- lf = 0",
"- rt = 0",
"- if cnt % 2 == 0:",
"- lf = mx_cent.popleft()",
"- rt = mx_cent.popleft()",
"+b = a.copy()",
"+c = a.copy()",
"+# 小さい順に詰める",
"+bdeq = deque(b)",
"+bret = deque()",
"+bret.append(bdeq.popleft())",
"+push_small = False",
"+while len(bdeq) > 1:",
"+ if push_small:",
"+ bret.append(bdeq.popleft())",
"+ bret.appendleft(bdeq.popleft())",
"+ push_small = False",
"- lf = mx_cent.pop()",
"- rt = mx_cent.pop()",
"- bmx.appendleft(lf)",
"- bmx.append(rt)",
"- if cnt % 2 == 0:",
"- lf = mn_cent.pop()",
"- rt = mn_cent.pop()",
"+ bret.append(bdeq.pop())",
"+ bret.appendleft(bdeq.pop())",
"+ push_small = True",
"+if len(bdeq) > 0:",
"+ if abs(bdeq[0] - bret[0]) > abs(bdeq[0] - bret[-1]):",
"+ bret.appendleft(bdeq[0])",
"- lf = mn_cent.popleft()",
"- rt = mn_cent.popleft()",
"- bmn.appendleft(lf)",
"- bmn.append(rt)",
"- cnt += 1",
"-if len(mx_cent) == 1:",
"- last = mx_cent.pop()",
"- if abs(bmx[0] - last) > abs(bmx[-1] - last):",
"- bmx.appendleft(last)",
"+ bret.append(bdeq[0])",
"+# 大きい順に詰める",
"+cdeq = deque(c)",
"+cret = deque()",
"+cret.append(cdeq.pop())",
"+push_small = True",
"+while len(cdeq) > 1:",
"+ if push_small:",
"+ cret.append(cdeq.popleft())",
"+ cret.appendleft(cdeq.popleft())",
"+ push_small = False",
"- bmx.append(last)",
"- last = mn_cent.pop()",
"- if abs(bmn[0] - last) > abs(bmn[-1] - last):",
"- bmn.appendleft(last)",
"+ cret.append(cdeq.pop())",
"+ cret.appendleft(cdeq.pop())",
"+ push_small = True",
"+if len(cdeq) > 0:",
"+ if abs(cdeq[0] - cret[0]) > abs(cdeq[0] - cret[-1]):",
"+ cret.appendleft(cdeq[0])",
"- bmn.append(last)",
"-diffmx, diffmn = 0, 0",
"+ cret.append(cdeq[0])",
"+# 答えが大きいほうを選択",
"+bans = 0",
"- diffmx += abs(bmx[i + 1] - bmx[i])",
"- diffmn += abs(bmn[i + 1] - bmn[i])",
"-print((max(diffmx, diffmn)))",
"+ bans += abs(bret[i] - bret[i + 1])",
"+cans = 0",
"+for i in range(n - 1):",
"+ cans += abs(cret[i] - cret[i + 1])",
"+print((max(bans, cans)))"
] | false
| 0.049777
| 0.048845
| 1.019079
|
[
"s631954117",
"s040714831"
] |
u408260374
|
p02373
|
python
|
s176470227
|
s573156179
| 2,750
| 2,390
| 73,588
| 40,292
|
Accepted
|
Accepted
| 13.09
|
import sys
if sys.version[0] == '2':
range, input = xrange, raw_input
class Edge:
def __init__(self, dst, weight):
self.dst, self.weight = dst, weight
def __lt__(self, e):
return self.weight > e.weight
class Graph:
def __init__(self, V):
self.V = V
self.E = [[] for _ in range(V)]
def add_edge(self, src, dst, weight):
self.E[src].append(Edge(dst, weight))
class HeavyLightDecomposition:
def __init__(self, g, root=0):
self.g = g
self.vid, self.head, self.heavy, self.parent = [0] * g.V, [-1] * g.V, [-1] * g.V, [-1] * g.V
self.dfs(root)
self.bfs(root)
def dfs(self, root):
stack = [(root, -1, False)]
sub, max_sub = [1] * self.g.V, [(0, -1)] * self.g.V
while stack:
v, par, flag = stack.pop()
if not flag:
self.parent[v] = par
stack.append((v, par, True))
stack.extend((e.dst, v, False) for e in self.g.E[v] if e.dst != par)
else:
if par != -1:
sub[par] += sub[v]
max_sub[par] = max(max_sub[par], (sub[v], v))
self.heavy[v] = max_sub[v][1]
def bfs(self, root=0):
from collections import deque
k, que = 0, deque([root])
while que:
r = v = que.popleft()
while v != -1:
self.vid[v], self.head[v] = k, r
for e in self.g.E[v]:
if e.dst != self.parent[v] and e.dst != self.heavy[v]:
que.append(e.dst)
k += 1
v = self.heavy[v]
def lca(self, u, v):
while self.head[u] != self.head[v]:
if self.vid[u] > self.vid[v]:
u, v = v, u
v = self.parent[self.head[v]]
else:
if self.vid[u] > self.vid[v]:
u, v = v, u
return u
N = int(eval(input()))
g = Graph(N)
for i in range(N):
for c in map(int, input().split()[1:]):
g.add_edge(i, c, 1)
g.add_edge(c, i, 1)
hld = HeavyLightDecomposition(g)
Q = int(eval(input()))
for _ in range(Q):
u, v = list(map(int, input().split()))
print((hld.lca(u, v)))
|
import sys
if sys.version[0] == '2':
range, input = xrange, raw_input
class HeavyLightDecomposition:
def __init__(self, g, root=0):
self.g = g
self.vid, self.head, self.heavy, self.parent = [0] * len(g), [-1] * len(g), [-1] * len(g), [-1] * len(g)
self.dfs(root)
self.bfs(root)
def dfs(self, root):
stack = [(root, -1, False)]
sub, max_sub = [1] * len(self.g), [(0, -1)] * len(self.g)
while stack:
v, par, flag = stack.pop()
if not flag:
self.parent[v] = par
stack.append((v, par, True))
stack.extend((c, v, False) for c in self.g[v] if c != par)
else:
if par != -1:
sub[par] += sub[v]
max_sub[par] = max(max_sub[par], (sub[v], v))
self.heavy[v] = max_sub[v][1]
def bfs(self, root=0):
from collections import deque
k, que = 0, deque([root])
while que:
r = v = que.popleft()
while v != -1:
self.vid[v], self.head[v] = k, r
for c in self.g[v]:
if c != self.parent[v] and c != self.heavy[v]:
que.append(c)
k += 1
v = self.heavy[v]
def lca(self, u, v):
while self.head[u] != self.head[v]:
if self.vid[u] > self.vid[v]:
u, v = v, u
v = self.parent[self.head[v]]
else:
if self.vid[u] > self.vid[v]:
u, v = v, u
return u
N = int(eval(input()))
g = [[] for _ in range(N)]
for i in range(N):
for c in map(int, input().split()[1:]):
g[i].append(c)
g[c].append(i)
hld = HeavyLightDecomposition(g)
Q = int(eval(input()))
for _ in range(Q):
u, v = list(map(int, input().split()))
print((hld.lca(u, v)))
| 78
| 61
| 2,311
| 1,943
|
import sys
if sys.version[0] == "2":
range, input = xrange, raw_input
class Edge:
def __init__(self, dst, weight):
self.dst, self.weight = dst, weight
def __lt__(self, e):
return self.weight > e.weight
class Graph:
def __init__(self, V):
self.V = V
self.E = [[] for _ in range(V)]
def add_edge(self, src, dst, weight):
self.E[src].append(Edge(dst, weight))
class HeavyLightDecomposition:
def __init__(self, g, root=0):
self.g = g
self.vid, self.head, self.heavy, self.parent = (
[0] * g.V,
[-1] * g.V,
[-1] * g.V,
[-1] * g.V,
)
self.dfs(root)
self.bfs(root)
def dfs(self, root):
stack = [(root, -1, False)]
sub, max_sub = [1] * self.g.V, [(0, -1)] * self.g.V
while stack:
v, par, flag = stack.pop()
if not flag:
self.parent[v] = par
stack.append((v, par, True))
stack.extend((e.dst, v, False) for e in self.g.E[v] if e.dst != par)
else:
if par != -1:
sub[par] += sub[v]
max_sub[par] = max(max_sub[par], (sub[v], v))
self.heavy[v] = max_sub[v][1]
def bfs(self, root=0):
from collections import deque
k, que = 0, deque([root])
while que:
r = v = que.popleft()
while v != -1:
self.vid[v], self.head[v] = k, r
for e in self.g.E[v]:
if e.dst != self.parent[v] and e.dst != self.heavy[v]:
que.append(e.dst)
k += 1
v = self.heavy[v]
def lca(self, u, v):
while self.head[u] != self.head[v]:
if self.vid[u] > self.vid[v]:
u, v = v, u
v = self.parent[self.head[v]]
else:
if self.vid[u] > self.vid[v]:
u, v = v, u
return u
N = int(eval(input()))
g = Graph(N)
for i in range(N):
for c in map(int, input().split()[1:]):
g.add_edge(i, c, 1)
g.add_edge(c, i, 1)
hld = HeavyLightDecomposition(g)
Q = int(eval(input()))
for _ in range(Q):
u, v = list(map(int, input().split()))
print((hld.lca(u, v)))
|
import sys
if sys.version[0] == "2":
range, input = xrange, raw_input
class HeavyLightDecomposition:
def __init__(self, g, root=0):
self.g = g
self.vid, self.head, self.heavy, self.parent = (
[0] * len(g),
[-1] * len(g),
[-1] * len(g),
[-1] * len(g),
)
self.dfs(root)
self.bfs(root)
def dfs(self, root):
stack = [(root, -1, False)]
sub, max_sub = [1] * len(self.g), [(0, -1)] * len(self.g)
while stack:
v, par, flag = stack.pop()
if not flag:
self.parent[v] = par
stack.append((v, par, True))
stack.extend((c, v, False) for c in self.g[v] if c != par)
else:
if par != -1:
sub[par] += sub[v]
max_sub[par] = max(max_sub[par], (sub[v], v))
self.heavy[v] = max_sub[v][1]
def bfs(self, root=0):
from collections import deque
k, que = 0, deque([root])
while que:
r = v = que.popleft()
while v != -1:
self.vid[v], self.head[v] = k, r
for c in self.g[v]:
if c != self.parent[v] and c != self.heavy[v]:
que.append(c)
k += 1
v = self.heavy[v]
def lca(self, u, v):
while self.head[u] != self.head[v]:
if self.vid[u] > self.vid[v]:
u, v = v, u
v = self.parent[self.head[v]]
else:
if self.vid[u] > self.vid[v]:
u, v = v, u
return u
N = int(eval(input()))
g = [[] for _ in range(N)]
for i in range(N):
for c in map(int, input().split()[1:]):
g[i].append(c)
g[c].append(i)
hld = HeavyLightDecomposition(g)
Q = int(eval(input()))
for _ in range(Q):
u, v = list(map(int, input().split()))
print((hld.lca(u, v)))
| false
| 21.794872
|
[
"-class Edge:",
"- def __init__(self, dst, weight):",
"- self.dst, self.weight = dst, weight",
"-",
"- def __lt__(self, e):",
"- return self.weight > e.weight",
"-",
"-",
"-class Graph:",
"- def __init__(self, V):",
"- self.V = V",
"- self.E = [[] for _ in range(V)]",
"-",
"- def add_edge(self, src, dst, weight):",
"- self.E[src].append(Edge(dst, weight))",
"-",
"-",
"- [0] * g.V,",
"- [-1] * g.V,",
"- [-1] * g.V,",
"- [-1] * g.V,",
"+ [0] * len(g),",
"+ [-1] * len(g),",
"+ [-1] * len(g),",
"+ [-1] * len(g),",
"- sub, max_sub = [1] * self.g.V, [(0, -1)] * self.g.V",
"+ sub, max_sub = [1] * len(self.g), [(0, -1)] * len(self.g)",
"- stack.extend((e.dst, v, False) for e in self.g.E[v] if e.dst != par)",
"+ stack.extend((c, v, False) for c in self.g[v] if c != par)",
"- for e in self.g.E[v]:",
"- if e.dst != self.parent[v] and e.dst != self.heavy[v]:",
"- que.append(e.dst)",
"+ for c in self.g[v]:",
"+ if c != self.parent[v] and c != self.heavy[v]:",
"+ que.append(c)",
"-g = Graph(N)",
"+g = [[] for _ in range(N)]",
"- g.add_edge(i, c, 1)",
"- g.add_edge(c, i, 1)",
"+ g[i].append(c)",
"+ g[c].append(i)"
] | false
| 0.038616
| 0.066828
| 0.577838
|
[
"s176470227",
"s573156179"
] |
u618940213
|
p03910
|
python
|
s969676173
|
s386433168
| 1,422
| 33
| 9,172
| 9,176
|
Accepted
|
Accepted
| 97.68
|
n = int(eval(input()))
m = -1
for i in range(1, n+1):
if i * (i - 1) < 2 * n <= i * (i + 1):
m = i
top = m * (m + 1) // 2
for i in range(0, m):
if top - i == n:
ng = i
break
for i in range(1, m+1):
if i == ng:
continue
print(i)
|
n = int(eval(input()))
m = -1
for i in range(1, n+1):
if i * (i - 1) < 2 * n <= i * (i + 1):
m = i
break
top = m * (m + 1) // 2
for i in range(0, m):
if top - i == n:
ng = i
break
for i in range(1, m+1):
if i == ng:
continue
print(i)
| 14
| 15
| 282
| 297
|
n = int(eval(input()))
m = -1
for i in range(1, n + 1):
if i * (i - 1) < 2 * n <= i * (i + 1):
m = i
top = m * (m + 1) // 2
for i in range(0, m):
if top - i == n:
ng = i
break
for i in range(1, m + 1):
if i == ng:
continue
print(i)
|
n = int(eval(input()))
m = -1
for i in range(1, n + 1):
if i * (i - 1) < 2 * n <= i * (i + 1):
m = i
break
top = m * (m + 1) // 2
for i in range(0, m):
if top - i == n:
ng = i
break
for i in range(1, m + 1):
if i == ng:
continue
print(i)
| false
| 6.666667
|
[
"+ break"
] | false
| 0.054483
| 0.031181
| 1.747318
|
[
"s969676173",
"s386433168"
] |
u810356688
|
p02732
|
python
|
s498812068
|
s857657234
| 472
| 343
| 89,564
| 26,636
|
Accepted
|
Accepted
| 27.33
|
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter,defaultdict
from operator import mul
from functools import reduce
def cmb1(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1,r + 1)))
return over // under
def main():
n=int(eval(input()))
A=[int(_) for _ in input().split()]
A_c=Counter(A)
combi=0
for ac in list(A_c.items()):
if ac[1]>=2:
combi+=cmb1(ac[1],2)
for i in range(n):
print((combi-(A_c[A[i]]-1)))
if __name__=='__main__':
main()
|
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import mul
from functools import reduce
def cmb1(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1,r + 1)))
return over // under
def main():
n=int(eval(input()))
A=[int(_) for _ in input().split()]
A_c=Counter(A)
combi=0
for ac in list(A_c.items()):
if ac[1]>=2:
combi+=cmb1(ac[1],2)
for i in range(n):
print((combi-(A_c[A[i]]-1)))
if __name__=='__main__':
main()
| 26
| 28
| 630
| 622
|
import sys
def input():
return sys.stdin.readline().rstrip()
from collections import Counter, defaultdict
from operator import mul
from functools import reduce
def cmb1(n, r):
r = min(n - r, r)
if r == 0:
return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1, r + 1)))
return over // under
def main():
n = int(eval(input()))
A = [int(_) for _ in input().split()]
A_c = Counter(A)
combi = 0
for ac in list(A_c.items()):
if ac[1] >= 2:
combi += cmb1(ac[1], 2)
for i in range(n):
print((combi - (A_c[A[i]] - 1)))
if __name__ == "__main__":
main()
|
import sys
def input():
return sys.stdin.readline().rstrip()
from collections import Counter
from operator import mul
from functools import reduce
def cmb1(n, r):
r = min(n - r, r)
if r == 0:
return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1, r + 1)))
return over // under
def main():
n = int(eval(input()))
A = [int(_) for _ in input().split()]
A_c = Counter(A)
combi = 0
for ac in list(A_c.items()):
if ac[1] >= 2:
combi += cmb1(ac[1], 2)
for i in range(n):
print((combi - (A_c[A[i]] - 1)))
if __name__ == "__main__":
main()
| false
| 7.142857
|
[
"-from collections import Counter, defaultdict",
"+from collections import Counter"
] | false
| 0.295841
| 0.158769
| 1.863338
|
[
"s498812068",
"s857657234"
] |
u724687935
|
p03612
|
python
|
s172500215
|
s841389320
| 101
| 89
| 14,008
| 14,008
|
Accepted
|
Accepted
| 11.88
|
N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
t = 'o' if P[0] == 1 else 'x'
j = 0 if t == 'o' else 1
L = []
for i, p in enumerate(P):
s = 'o' if p == (i + 1) else 'x'
if s == t:
cnt += 1
else:
L.append(cnt)
cnt = 1
t = s
L.append(cnt)
ans = 0
for i, n in enumerate(L):
if i % 2 == j:
ans += (n + 2 - 1) // 2
print(ans)
|
N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
ans = 0
t = 'o' if P[0] == 1 else 'x'
for i, p in enumerate(P):
s = 'o' if p == (i + 1) else 'x'
if s == t:
cnt += 1
else:
if t == 'o':
ans += (cnt + 2 - 1) // 2
cnt = 1
t = s
else:
if t == 'o':
ans += (cnt + 2 - 1) // 2
print(ans)
| 23
| 20
| 415
| 382
|
N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
t = "o" if P[0] == 1 else "x"
j = 0 if t == "o" else 1
L = []
for i, p in enumerate(P):
s = "o" if p == (i + 1) else "x"
if s == t:
cnt += 1
else:
L.append(cnt)
cnt = 1
t = s
L.append(cnt)
ans = 0
for i, n in enumerate(L):
if i % 2 == j:
ans += (n + 2 - 1) // 2
print(ans)
|
N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
ans = 0
t = "o" if P[0] == 1 else "x"
for i, p in enumerate(P):
s = "o" if p == (i + 1) else "x"
if s == t:
cnt += 1
else:
if t == "o":
ans += (cnt + 2 - 1) // 2
cnt = 1
t = s
else:
if t == "o":
ans += (cnt + 2 - 1) // 2
print(ans)
| false
| 13.043478
|
[
"+ans = 0",
"-j = 0 if t == \"o\" else 1",
"-L = []",
"- L.append(cnt)",
"+ if t == \"o\":",
"+ ans += (cnt + 2 - 1) // 2",
"-L.append(cnt)",
"-ans = 0",
"-for i, n in enumerate(L):",
"- if i % 2 == j:",
"- ans += (n + 2 - 1) // 2",
"+else:",
"+ if t == \"o\":",
"+ ans += (cnt + 2 - 1) // 2"
] | false
| 0.078253
| 0.089368
| 0.875628
|
[
"s172500215",
"s841389320"
] |
u083668616
|
p03210
|
python
|
s346702965
|
s376625298
| 13
| 10
| 2,568
| 2,568
|
Accepted
|
Accepted
| 23.08
|
shichigosan = [7, 5, 3]
X = int(input())
ans = 'NO'
for i in range(0, 3):
if X == shichigosan[i]: ans = 'YES'
print(ans)
|
lst = [7, 5, 3]
X = int(input())
if X in lst: print('YES')
else: print('NO')
| 9
| 4
| 135
| 81
|
shichigosan = [7, 5, 3]
X = int(input())
ans = "NO"
for i in range(0, 3):
if X == shichigosan[i]:
ans = "YES"
print(ans)
|
lst = [7, 5, 3]
X = int(input())
if X in lst:
print("YES")
else:
print("NO")
| false
| 55.555556
|
[
"-shichigosan = [7, 5, 3]",
"+lst = [7, 5, 3]",
"-ans = \"NO\"",
"-for i in range(0, 3):",
"- if X == shichigosan[i]:",
"- ans = \"YES\"",
"-print(ans)",
"+if X in lst:",
"+ print(\"YES\")",
"+else:",
"+ print(\"NO\")"
] | false
| 0.042748
| 0.038305
| 1.115988
|
[
"s346702965",
"s376625298"
] |
u623819879
|
p02901
|
python
|
s825210706
|
s013046464
| 1,049
| 716
| 150,872
| 73,572
|
Accepted
|
Accepted
| 31.74
|
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random
def I():
return int(input())
def MI():
return map(int,input().split())
def LI():
return [int(i) for i in input().split()]
def LI_():
return [int(i)-1 for i in input().split()]
def StoI():
return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
if show_flg:
print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
#show_flg=True
n,m=MI()
t=1<<n
key=[]
for i in range(m):
a,b=MI()
c=0
for j in LI_():
c+=1<<j
key.append((a,c))
inf=float('inf')
dp=[[inf]*(m+1) for _ in range(t)]
#dp[stat][m] # min value using up to m and open stat
dp[0][0]=0
for j in range(1,m+1):
for i in range(t):
cost,ck=key[j-1]
show(i,j,'|',dp[ck|i][j],min(dp[ck|i][j-1],dp[i][j-1]+cost))
dp[ck|i][j]=min(dp[ck|i][j],dp[ck|i][j-1],dp[i][j-1]+cost)
dp[i][j]=min(dp[i][j],dp[i][j-1])
for i in dp:
show(*i)
ans=dp[t-1][m] if dp[t-1][m]!=inf else -1
print(ans)
|
from subprocess import*
with open('e.cpp','w')as f:f.write(r"""
#include <bits/stdc++.h>
using namespace std;
const int maxs = 4096;
int dp[maxs];
int main() {
memset(dp, 0x3f, 16384);
dp[0] = 0;
int n, m;
cin >> n >> m;
while (m--) {
int a, b, s = 0;
cin >> a >> b;
while (b--) {
int c;
cin >> c;
s ^= 1 << c - 1;
}
dp[s] = min(dp[s], a);
}
for (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all)
dp[sub] = min(dp[sub], dp[sub ^ 1 << i]);
for (int s = 0; s != (1 << n); ++s) if (s != (s & -s))
for (int t = s - 1 & s; t != s; t = t - 1 & s)
dp[s] = min(dp[s], dp[t] + dp[s ^ t]);
int mask = (1 << n) - 1;
if (dp[mask] == 0x3f3f3f3f) dp[mask] = -1;
cout << dp[mask] << endl;
}""")
call(('g++','e.cpp'))
call('./a.out')
| 57
| 34
| 1,305
| 839
|
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
# import math
# import time
import random
def I():
return int(input())
def MI():
return map(int, input().split())
def LI():
return [int(i) for i in input().split()]
def LI_():
return [int(i) - 1 for i in input().split()]
def StoI():
return [ord(i) - 97 for i in input()]
def show(*inp, end="\n"):
if show_flg:
print(*inp, end=end)
YN = ["Yes", "No"]
mo = 10**9 + 7
# ts=time.time()
sys.setrecursionlimit(10**6)
# input=sys.stdin.readline
show_flg = False
# show_flg=True
n, m = MI()
t = 1 << n
key = []
for i in range(m):
a, b = MI()
c = 0
for j in LI_():
c += 1 << j
key.append((a, c))
inf = float("inf")
dp = [[inf] * (m + 1) for _ in range(t)]
# dp[stat][m] # min value using up to m and open stat
dp[0][0] = 0
for j in range(1, m + 1):
for i in range(t):
cost, ck = key[j - 1]
show(i, j, "|", dp[ck | i][j], min(dp[ck | i][j - 1], dp[i][j - 1] + cost))
dp[ck | i][j] = min(dp[ck | i][j], dp[ck | i][j - 1], dp[i][j - 1] + cost)
dp[i][j] = min(dp[i][j], dp[i][j - 1])
for i in dp:
show(*i)
ans = dp[t - 1][m] if dp[t - 1][m] != inf else -1
print(ans)
|
from subprocess import *
with open("e.cpp", "w") as f:
f.write(
r"""
#include <bits/stdc++.h>
using namespace std;
const int maxs = 4096;
int dp[maxs];
int main() {
memset(dp, 0x3f, 16384);
dp[0] = 0;
int n, m;
cin >> n >> m;
while (m--) {
int a, b, s = 0;
cin >> a >> b;
while (b--) {
int c;
cin >> c;
s ^= 1 << c - 1;
}
dp[s] = min(dp[s], a);
}
for (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all)
dp[sub] = min(dp[sub], dp[sub ^ 1 << i]);
for (int s = 0; s != (1 << n); ++s) if (s != (s & -s))
for (int t = s - 1 & s; t != s; t = t - 1 & s)
dp[s] = min(dp[s], dp[t] + dp[s ^ t]);
int mask = (1 << n) - 1;
if (dp[mask] == 0x3f3f3f3f) dp[mask] = -1;
cout << dp[mask] << endl;
}"""
)
call(("g++", "e.cpp"))
call("./a.out")
| false
| 40.350877
|
[
"-from heapq import heappush, heappop",
"-from collections import deque, defaultdict, Counter",
"-import itertools",
"-from itertools import permutations, combinations",
"-import sys",
"-import bisect",
"-import string",
"+from subprocess import *",
"-# import math",
"-# import time",
"-import random",
"-",
"-",
"-def I():",
"- return int(input())",
"-",
"-",
"-def MI():",
"- return map(int, input().split())",
"-",
"-",
"-def LI():",
"- return [int(i) for i in input().split()]",
"-",
"-",
"-def LI_():",
"- return [int(i) - 1 for i in input().split()]",
"-",
"-",
"-def StoI():",
"- return [ord(i) - 97 for i in input()]",
"-",
"-",
"-def show(*inp, end=\"\\n\"):",
"- if show_flg:",
"- print(*inp, end=end)",
"-",
"-",
"-YN = [\"Yes\", \"No\"]",
"-mo = 10**9 + 7",
"-# ts=time.time()",
"-sys.setrecursionlimit(10**6)",
"-# input=sys.stdin.readline",
"-show_flg = False",
"-# show_flg=True",
"-n, m = MI()",
"-t = 1 << n",
"-key = []",
"-for i in range(m):",
"- a, b = MI()",
"- c = 0",
"- for j in LI_():",
"- c += 1 << j",
"- key.append((a, c))",
"-inf = float(\"inf\")",
"-dp = [[inf] * (m + 1) for _ in range(t)]",
"-# dp[stat][m] # min value using up to m and open stat",
"-dp[0][0] = 0",
"-for j in range(1, m + 1):",
"- for i in range(t):",
"- cost, ck = key[j - 1]",
"- show(i, j, \"|\", dp[ck | i][j], min(dp[ck | i][j - 1], dp[i][j - 1] + cost))",
"- dp[ck | i][j] = min(dp[ck | i][j], dp[ck | i][j - 1], dp[i][j - 1] + cost)",
"- dp[i][j] = min(dp[i][j], dp[i][j - 1])",
"-for i in dp:",
"- show(*i)",
"-ans = dp[t - 1][m] if dp[t - 1][m] != inf else -1",
"-print(ans)",
"+with open(\"e.cpp\", \"w\") as f:",
"+ f.write(",
"+ r\"\"\"",
"+#include <bits/stdc++.h>",
"+using namespace std;",
"+const int maxs = 4096;",
"+int dp[maxs];",
"+int main() {",
"+\tmemset(dp, 0x3f, 16384);",
"+\tdp[0] = 0;",
"+\tint n, m;",
"+\tcin >> n >> m;",
"+\twhile (m--) {",
"+\t\tint a, b, s = 0;",
"+\t\tcin >> a >> b;",
"+\t\twhile (b--) {",
"+\t\t\tint c;",
"+\t\t\tcin >> c;",
"+\t\t\ts ^= 1 << c - 1;",
"+\t\t}",
"+\t\tdp[s] = min(dp[s], a);",
"+\t}",
"+\tfor (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all)",
"+\t\tdp[sub] = min(dp[sub], dp[sub ^ 1 << i]);",
"+\tfor (int s = 0; s != (1 << n); ++s) if (s != (s & -s))",
"+\t\tfor (int t = s - 1 & s; t != s; t = t - 1 & s)",
"+\t\t\tdp[s] = min(dp[s], dp[t] + dp[s ^ t]);",
"+\tint mask = (1 << n) - 1;",
"+\tif (dp[mask] == 0x3f3f3f3f) dp[mask] = -1;",
"+\tcout << dp[mask] << endl;",
"+}\"\"\"",
"+ )",
"+call((\"g++\", \"e.cpp\"))",
"+call(\"./a.out\")"
] | false
| 0.040965
| 1.666217
| 0.024586
|
[
"s825210706",
"s013046464"
] |
u346812984
|
p02743
|
python
|
s598962648
|
s119802826
| 36
| 17
| 5,204
| 2,940
|
Accepted
|
Accepted
| 52.78
|
from decimal import Decimal
a, b, c = list(map(int, input().split()))
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
print("Yes")
else:
print("No")
|
a, b, c = list(map(int, input().split()))
if c - a - b <= 0:
print("No")
else:
if (c - a - b) ** 2 - 4 * a * b > 0:
print("Yes")
else:
print("No")
| 7
| 8
| 172
| 176
|
from decimal import Decimal
a, b, c = list(map(int, input().split()))
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
print("Yes")
else:
print("No")
|
a, b, c = list(map(int, input().split()))
if c - a - b <= 0:
print("No")
else:
if (c - a - b) ** 2 - 4 * a * b > 0:
print("Yes")
else:
print("No")
| false
| 12.5
|
[
"-from decimal import Decimal",
"-",
"-if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():",
"- print(\"Yes\")",
"+if c - a - b <= 0:",
"+ print(\"No\")",
"- print(\"No\")",
"+ if (c - a - b) ** 2 - 4 * a * b > 0:",
"+ print(\"Yes\")",
"+ else:",
"+ print(\"No\")"
] | false
| 0.049768
| 0.06768
| 0.735334
|
[
"s598962648",
"s119802826"
] |
u323680411
|
p03944
|
python
|
s599103797
|
s879840900
| 417
| 166
| 12,516
| 3,064
|
Accepted
|
Accepted
| 60.19
|
import numpy as np
from sys import stdin
def main():
w = next_int()
h = next_int()
n = next_int()
arr = np.ones((h, w), dtype=np.int)
for i in range(n):
xi, yi, a = list(map(int, input().split()))
for y in range(h):
for x in range(w):
if a == 1:
if x < xi:
arr[y][x] = 0
if a == 2:
if x >= xi:
arr[y][x] = 0
if a == 3:
if y < yi:
arr[y][x] = 0
if a == 4:
if y >= yi:
arr[y][x] = 0
ans = arr.sum()
print(ans)
def next_int():
return int(next_str())
def next_str():
result = ""
while True:
tmp = stdin.read(1)
if tmp.strip() != "":
result += tmp
elif tmp != '\r':
break
return result
if __name__ == '__main__':
main()
|
from sys import stdin
def main():
w = next_int()
h = next_int()
n = next_int()
arr = [[1] * w for _ in range(h)]
for i in range(n):
xi, yi, a = list(map(int, input().split()))
for y in range(h):
for x in range(w):
if a == 1:
if x < xi:
arr[y][x] = 0
if a == 2:
if x >= xi:
arr[y][x] = 0
if a == 3:
if y < yi:
arr[y][x] = 0
if a == 4:
if y >= yi:
arr[y][x] = 0
ans = 0
for y in range(h):
ans += sum(arr[y])
print(ans)
def next_int():
return int(next_str())
def next_str():
result = ""
while True:
tmp = stdin.read(1)
if tmp.strip() != "":
result += tmp
elif tmp != '\r':
break
return result
if __name__ == '__main__':
main()
| 49
| 50
| 1,031
| 1,053
|
import numpy as np
from sys import stdin
def main():
w = next_int()
h = next_int()
n = next_int()
arr = np.ones((h, w), dtype=np.int)
for i in range(n):
xi, yi, a = list(map(int, input().split()))
for y in range(h):
for x in range(w):
if a == 1:
if x < xi:
arr[y][x] = 0
if a == 2:
if x >= xi:
arr[y][x] = 0
if a == 3:
if y < yi:
arr[y][x] = 0
if a == 4:
if y >= yi:
arr[y][x] = 0
ans = arr.sum()
print(ans)
def next_int():
return int(next_str())
def next_str():
result = ""
while True:
tmp = stdin.read(1)
if tmp.strip() != "":
result += tmp
elif tmp != "\r":
break
return result
if __name__ == "__main__":
main()
|
from sys import stdin
def main():
w = next_int()
h = next_int()
n = next_int()
arr = [[1] * w for _ in range(h)]
for i in range(n):
xi, yi, a = list(map(int, input().split()))
for y in range(h):
for x in range(w):
if a == 1:
if x < xi:
arr[y][x] = 0
if a == 2:
if x >= xi:
arr[y][x] = 0
if a == 3:
if y < yi:
arr[y][x] = 0
if a == 4:
if y >= yi:
arr[y][x] = 0
ans = 0
for y in range(h):
ans += sum(arr[y])
print(ans)
def next_int():
return int(next_str())
def next_str():
result = ""
while True:
tmp = stdin.read(1)
if tmp.strip() != "":
result += tmp
elif tmp != "\r":
break
return result
if __name__ == "__main__":
main()
| false
| 2
|
[
"-import numpy as np",
"- arr = np.ones((h, w), dtype=np.int)",
"+ arr = [[1] * w for _ in range(h)]",
"- ans = arr.sum()",
"+ ans = 0",
"+ for y in range(h):",
"+ ans += sum(arr[y])"
] | false
| 0.789439
| 0.121
| 6.524274
|
[
"s599103797",
"s879840900"
] |
u597436499
|
p03493
|
python
|
s656407695
|
s016763858
| 19
| 17
| 2,940
| 3,060
|
Accepted
|
Accepted
| 10.53
|
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
s = ns()
ans = 0
for i in s:
if i == '1':
ans += 1
else:
pass
print(ans)
|
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
s = ns()
ans = 0
if s[0] == '1':
ans += 1
if s[1] == '1':
ans += 1
if s[2] == '1':
ans += 1
print(ans)
| 16
| 17
| 251
| 270
|
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
s = ns()
ans = 0
for i in s:
if i == "1":
ans += 1
else:
pass
print(ans)
|
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
s = ns()
ans = 0
if s[0] == "1":
ans += 1
if s[1] == "1":
ans += 1
if s[2] == "1":
ans += 1
print(ans)
| false
| 5.882353
|
[
"-for i in s:",
"- if i == \"1\":",
"- ans += 1",
"- else:",
"- pass",
"+if s[0] == \"1\":",
"+ ans += 1",
"+if s[1] == \"1\":",
"+ ans += 1",
"+if s[2] == \"1\":",
"+ ans += 1"
] | false
| 0.180651
| 0.04762
| 3.793602
|
[
"s656407695",
"s016763858"
] |
u606045429
|
p02868
|
python
|
s955585706
|
s412630868
| 677
| 588
| 54,244
| 50,164
|
Accepted
|
Accepted
| 13.15
|
from heapq import heappush, heappop
INF = float("inf")
N, M, *LRC = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for i in range(N - 1):
E[i + 1].append((i, 0))
for l, r, c in zip(*[iter(LRC)] * 3):
E[l - 1].append((r - 1, c))
D = [INF] * N
D[0] = 0
Q = [(0, 0)]
while Q:
dist, cur = heappop(Q)
for nxt, cost in E[cur]:
cand = dist + cost
if D[nxt] > cand:
D[nxt] = cand
heappush(Q, (cand, nxt))
print((-1 if D[N - 1] == INF else D[N - 1]))
|
from heapq import heappush, heappop
INF = float("inf")
N, M, *LRC = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for i in range(N - 1):
E[i + 1].append((i, 0))
for l, r, c in zip(*[iter(LRC)] * 3):
E[l - 1].append((r - 1, c))
D = [INF] * N
D[0] = 0
Q = [0]
while Q:
t = heappop(Q)
dist, cur = divmod(t, N)
for nxt, cost in E[cur]:
cand = dist + cost
if D[nxt] > cand:
D[nxt] = cand
heappush(Q, cand * N + nxt)
print((-1 if D[N - 1] == INF else D[N - 1]))
| 25
| 26
| 539
| 558
|
from heapq import heappush, heappop
INF = float("inf")
N, M, *LRC = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for i in range(N - 1):
E[i + 1].append((i, 0))
for l, r, c in zip(*[iter(LRC)] * 3):
E[l - 1].append((r - 1, c))
D = [INF] * N
D[0] = 0
Q = [(0, 0)]
while Q:
dist, cur = heappop(Q)
for nxt, cost in E[cur]:
cand = dist + cost
if D[nxt] > cand:
D[nxt] = cand
heappush(Q, (cand, nxt))
print((-1 if D[N - 1] == INF else D[N - 1]))
|
from heapq import heappush, heappop
INF = float("inf")
N, M, *LRC = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for i in range(N - 1):
E[i + 1].append((i, 0))
for l, r, c in zip(*[iter(LRC)] * 3):
E[l - 1].append((r - 1, c))
D = [INF] * N
D[0] = 0
Q = [0]
while Q:
t = heappop(Q)
dist, cur = divmod(t, N)
for nxt, cost in E[cur]:
cand = dist + cost
if D[nxt] > cand:
D[nxt] = cand
heappush(Q, cand * N + nxt)
print((-1 if D[N - 1] == INF else D[N - 1]))
| false
| 3.846154
|
[
"-Q = [(0, 0)]",
"+Q = [0]",
"- dist, cur = heappop(Q)",
"+ t = heappop(Q)",
"+ dist, cur = divmod(t, N)",
"- heappush(Q, (cand, nxt))",
"+ heappush(Q, cand * N + nxt)"
] | false
| 0.038703
| 0.039189
| 0.987584
|
[
"s955585706",
"s412630868"
] |
u896741788
|
p03426
|
python
|
s347284975
|
s136548269
| 950
| 307
| 23,812
| 36,940
|
Accepted
|
Accepted
| 67.68
|
h,w,d=list(map(int,input().split()))
ind={}
for i in range(h):
l=list(map(int,input().split()))
for j in range(w):
ind[l[j]]=(i,j)
dp=[0]*(h*w)
for i in range(d+1,h*w+1):
x,y=ind[i]
z,q=ind[i-d]
dp[i-1]=abs(z-x)+abs(y-q)+dp[i-d-1]
q=int(eval(input()))
for i in range(q):
l,r=list(map(int,input().split()))
print((dp[r-1]-dp[l-1]))
|
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h,w,d=list(map(int,input().split()))
inds={}
for i in range(h):
for D,j in enumerate(input().split()):
inds[int(j)-1]=(i,D)
nows=[[0]for c in range(d)]
for k in range(d,h*w):
a,b=inds[k]
x,y=inds[k-d]
k%=d
nows[k].append(nows[k][-1]+abs(a-x)+abs(b-y))
q=eval(input())
for i in inputs():
l,r=list(map(int,i.split()))
l-=1;r-=1
l,b=divmod(l,d)
r,b=divmod(r,d)
print((nows[b][r]-nows[b][l]))
| 18
| 23
| 366
| 546
|
h, w, d = list(map(int, input().split()))
ind = {}
for i in range(h):
l = list(map(int, input().split()))
for j in range(w):
ind[l[j]] = (i, j)
dp = [0] * (h * w)
for i in range(d + 1, h * w + 1):
x, y = ind[i]
z, q = ind[i - d]
dp[i - 1] = abs(z - x) + abs(y - q) + dp[i - d - 1]
q = int(eval(input()))
for i in range(q):
l, r = list(map(int, input().split()))
print((dp[r - 1] - dp[l - 1]))
|
import sys
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
h, w, d = list(map(int, input().split()))
inds = {}
for i in range(h):
for D, j in enumerate(input().split()):
inds[int(j) - 1] = (i, D)
nows = [[0] for c in range(d)]
for k in range(d, h * w):
a, b = inds[k]
x, y = inds[k - d]
k %= d
nows[k].append(nows[k][-1] + abs(a - x) + abs(b - y))
q = eval(input())
for i in inputs():
l, r = list(map(int, i.split()))
l -= 1
r -= 1
l, b = divmod(l, d)
r, b = divmod(r, d)
print((nows[b][r] - nows[b][l]))
| false
| 21.73913
|
[
"+import sys",
"+",
"+input = sys.stdin.buffer.readline",
"+inputs = sys.stdin.buffer.readlines",
"+sys.setrecursionlimit(10**9)",
"-ind = {}",
"+inds = {}",
"- l = list(map(int, input().split()))",
"- for j in range(w):",
"- ind[l[j]] = (i, j)",
"-dp = [0] * (h * w)",
"-for i in range(d + 1, h * w + 1):",
"- x, y = ind[i]",
"- z, q = ind[i - d]",
"- dp[i - 1] = abs(z - x) + abs(y - q) + dp[i - d - 1]",
"-q = int(eval(input()))",
"-for i in range(q):",
"- l, r = list(map(int, input().split()))",
"- print((dp[r - 1] - dp[l - 1]))",
"+ for D, j in enumerate(input().split()):",
"+ inds[int(j) - 1] = (i, D)",
"+nows = [[0] for c in range(d)]",
"+for k in range(d, h * w):",
"+ a, b = inds[k]",
"+ x, y = inds[k - d]",
"+ k %= d",
"+ nows[k].append(nows[k][-1] + abs(a - x) + abs(b - y))",
"+q = eval(input())",
"+for i in inputs():",
"+ l, r = list(map(int, i.split()))",
"+ l -= 1",
"+ r -= 1",
"+ l, b = divmod(l, d)",
"+ r, b = divmod(r, d)",
"+ print((nows[b][r] - nows[b][l]))"
] | false
| 0.043418
| 0.067922
| 0.639237
|
[
"s347284975",
"s136548269"
] |
u230621983
|
p02947
|
python
|
s216574417
|
s659113731
| 360
| 226
| 19,760
| 24,184
|
Accepted
|
Accepted
| 37.22
|
from collections import Counter
n = int(eval(input()))
s = [''.join(sorted(eval(input()))) for _ in range(n)]
c = Counter(s)
cnt = 0
for key in c:
val = c[key]
cnt += val*(val-1)//2
print(cnt)
|
from collections import Counter
n = int(eval(input()))
l = [''.join(sorted(eval(input()))) for i in range(n)]
c = Counter(l)
cnt = 0
for val in list(c.values()):
cnt += val * (val-1) //2
print(cnt)
| 13
| 10
| 204
| 198
|
from collections import Counter
n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
c = Counter(s)
cnt = 0
for key in c:
val = c[key]
cnt += val * (val - 1) // 2
print(cnt)
|
from collections import Counter
n = int(eval(input()))
l = ["".join(sorted(eval(input()))) for i in range(n)]
c = Counter(l)
cnt = 0
for val in list(c.values()):
cnt += val * (val - 1) // 2
print(cnt)
| false
| 23.076923
|
[
"-s = [\"\".join(sorted(eval(input()))) for _ in range(n)]",
"-c = Counter(s)",
"+l = [\"\".join(sorted(eval(input()))) for i in range(n)]",
"+c = Counter(l)",
"-for key in c:",
"- val = c[key]",
"+for val in list(c.values()):"
] | false
| 0.042304
| 0.042475
| 0.99597
|
[
"s216574417",
"s659113731"
] |
u945405878
|
p02659
|
python
|
s063969051
|
s498029663
| 30
| 20
| 10,060
| 9,100
|
Accepted
|
Accepted
| 33.33
|
from math import floor
from decimal import Decimal
a, b = input().split()
a = int(a)
b = Decimal(b)
print((floor(a * b)))
|
a, b = input().split(" ")
A, B = int(a), float(b)
B100 = round(B * 100)
C = A * B100
ans = C // 100
print(ans)
| 6
| 6
| 124
| 115
|
from math import floor
from decimal import Decimal
a, b = input().split()
a = int(a)
b = Decimal(b)
print((floor(a * b)))
|
a, b = input().split(" ")
A, B = int(a), float(b)
B100 = round(B * 100)
C = A * B100
ans = C // 100
print(ans)
| false
| 0
|
[
"-from math import floor",
"-from decimal import Decimal",
"-",
"-a, b = input().split()",
"-a = int(a)",
"-b = Decimal(b)",
"-print((floor(a * b)))",
"+a, b = input().split(\" \")",
"+A, B = int(a), float(b)",
"+B100 = round(B * 100)",
"+C = A * B100",
"+ans = C // 100",
"+print(ans)"
] | false
| 0.044224
| 0.043029
| 1.027767
|
[
"s063969051",
"s498029663"
] |
u607075479
|
p02573
|
python
|
s946542516
|
s663730951
| 453
| 404
| 137,768
| 132,700
|
Accepted
|
Accepted
| 10.82
|
import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(eval(input()))
NMI = lambda: list(map(int, input().split()))
NLI = lambda: list(NMI())
SI = lambda: eval(input())
#隣接リスト 1-index
def make_adjlist_nond(n, edges):
res = [[] for _ in range(n+1)]
for edge in edges:
res[edge[0]].append(edge[1])
res[edge[1]].append(edge[0])
return res
def main():
N, M = NMI()
F = {}
for _ in range(M):
a, b = NMI()
F[(a, b)] = 1
tree = make_adjlist_nond(N, list(F.keys()))
ans = 0
seen = [0] * (N + 1)
for start in range(1, N+1):
que = deque()
que.append(start)
seen[start] = 1
fri_cnt = 1
while que:
now = que.popleft()
for goto in tree[now]:
if seen[goto]:
continue
seen[goto] = 1
fri_cnt += 1
que.append(goto)
ans = max(fri_cnt, ans)
print(ans)
if __name__ == "__main__":
main()
|
import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(eval(input()))
NMI = lambda: list(map(int, input().split()))
NLI = lambda: list(NMI())
SI = lambda: eval(input())
#隣接リスト 1-index
def make_adjlist_nond(n, edges):
res = [[] for _ in range(n+1)]
for edge in edges:
res[edge[0]].append(edge[1])
res[edge[1]].append(edge[0])
return res
def main():
N, M = NMI()
F = [NLI() for _ in range(M)]
tree = make_adjlist_nond(N, F)
ans = 0
seen = [0] * (N + 1)
for start in range(1, N+1):
que = deque()
que.append(start)
seen[start] = 1
fri_cnt = 1
while que:
now = que.popleft()
for goto in tree[now]:
if seen[goto]:
continue
seen[goto] = 1
fri_cnt += 1
que.append(goto)
ans = max(fri_cnt, ans)
print(ans)
if __name__ == "__main__":
main()
| 56
| 53
| 1,161
| 1,102
|
import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(eval(input()))
NMI = lambda: list(map(int, input().split()))
NLI = lambda: list(NMI())
SI = lambda: eval(input())
# 隣接リスト 1-index
def make_adjlist_nond(n, edges):
res = [[] for _ in range(n + 1)]
for edge in edges:
res[edge[0]].append(edge[1])
res[edge[1]].append(edge[0])
return res
def main():
N, M = NMI()
F = {}
for _ in range(M):
a, b = NMI()
F[(a, b)] = 1
tree = make_adjlist_nond(N, list(F.keys()))
ans = 0
seen = [0] * (N + 1)
for start in range(1, N + 1):
que = deque()
que.append(start)
seen[start] = 1
fri_cnt = 1
while que:
now = que.popleft()
for goto in tree[now]:
if seen[goto]:
continue
seen[goto] = 1
fri_cnt += 1
que.append(goto)
ans = max(fri_cnt, ans)
print(ans)
if __name__ == "__main__":
main()
|
import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(eval(input()))
NMI = lambda: list(map(int, input().split()))
NLI = lambda: list(NMI())
SI = lambda: eval(input())
# 隣接リスト 1-index
def make_adjlist_nond(n, edges):
res = [[] for _ in range(n + 1)]
for edge in edges:
res[edge[0]].append(edge[1])
res[edge[1]].append(edge[0])
return res
def main():
N, M = NMI()
F = [NLI() for _ in range(M)]
tree = make_adjlist_nond(N, F)
ans = 0
seen = [0] * (N + 1)
for start in range(1, N + 1):
que = deque()
que.append(start)
seen[start] = 1
fri_cnt = 1
while que:
now = que.popleft()
for goto in tree[now]:
if seen[goto]:
continue
seen[goto] = 1
fri_cnt += 1
que.append(goto)
ans = max(fri_cnt, ans)
print(ans)
if __name__ == "__main__":
main()
| false
| 5.357143
|
[
"- F = {}",
"- for _ in range(M):",
"- a, b = NMI()",
"- F[(a, b)] = 1",
"- tree = make_adjlist_nond(N, list(F.keys()))",
"+ F = [NLI() for _ in range(M)]",
"+ tree = make_adjlist_nond(N, F)"
] | false
| 0.10645
| 0.103657
| 1.026946
|
[
"s946542516",
"s663730951"
] |
u678167152
|
p03557
|
python
|
s052043023
|
s825601809
| 301
| 207
| 23,328
| 104,324
|
Accepted
|
Accepted
| 31.23
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
ans = 0
for b in B:
ans += bisect_left(A,b) * (N - bisect_right(C,b))
print(ans)
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import *
ans = 0
for b in B:
a = bisect_left(A,b)
c = N-bisect_right(C,b)
ans += a*c
print(ans)
| 17
| 14
| 345
| 278
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
ans = 0
for b in B:
ans += bisect_left(A, b) * (N - bisect_right(C, b))
print(ans)
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import *
ans = 0
for b in B:
a = bisect_left(A, b)
c = N - bisect_right(C, b)
ans += a * c
print(ans)
| false
| 17.647059
|
[
"-from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort",
"+from bisect import *",
"- ans += bisect_left(A, b) * (N - bisect_right(C, b))",
"+ a = bisect_left(A, b)",
"+ c = N - bisect_right(C, b)",
"+ ans += a * c"
] | false
| 0.080236
| 0.045348
| 1.769328
|
[
"s052043023",
"s825601809"
] |
u263660661
|
p02773
|
python
|
s281098925
|
s540387963
| 816
| 691
| 46,348
| 35,220
|
Accepted
|
Accepted
| 15.32
|
n = int(eval(input()))
s = []
for i in range(n):
s.append(eval(input()))
d = {}
for word in s:
if word not in list(d.keys()):
d[word] = 1
else:
d[word] += 1
max_v = max(d.values())
d = sorted(list(d.items()), key=lambda x: x[0])
for k, v in d:
if v == max_v:
print(k)
|
n = int(eval(input()))
s = []
for i in range(n):
s.append(eval(input()))
dic = {}
for x in s:
if x in list(dic.keys()):
dic[x] += 1
else:
dic[x] = 1
max_v = max(dic.values())
a = []
for k, v in list(dic.items()):
if v == max_v:
a.append(k)
ans = sorted(a)
for a in ans:
print(a)
| 18
| 22
| 304
| 324
|
n = int(eval(input()))
s = []
for i in range(n):
s.append(eval(input()))
d = {}
for word in s:
if word not in list(d.keys()):
d[word] = 1
else:
d[word] += 1
max_v = max(d.values())
d = sorted(list(d.items()), key=lambda x: x[0])
for k, v in d:
if v == max_v:
print(k)
|
n = int(eval(input()))
s = []
for i in range(n):
s.append(eval(input()))
dic = {}
for x in s:
if x in list(dic.keys()):
dic[x] += 1
else:
dic[x] = 1
max_v = max(dic.values())
a = []
for k, v in list(dic.items()):
if v == max_v:
a.append(k)
ans = sorted(a)
for a in ans:
print(a)
| false
| 18.181818
|
[
"-d = {}",
"-for word in s:",
"- if word not in list(d.keys()):",
"- d[word] = 1",
"+dic = {}",
"+for x in s:",
"+ if x in list(dic.keys()):",
"+ dic[x] += 1",
"- d[word] += 1",
"-max_v = max(d.values())",
"-d = sorted(list(d.items()), key=lambda x: x[0])",
"-for k, v in d:",
"+ dic[x] = 1",
"+max_v = max(dic.values())",
"+a = []",
"+for k, v in list(dic.items()):",
"- print(k)",
"+ a.append(k)",
"+ans = sorted(a)",
"+for a in ans:",
"+ print(a)"
] | false
| 0.044692
| 0.102323
| 0.436779
|
[
"s281098925",
"s540387963"
] |
u077291787
|
p03354
|
python
|
s166264147
|
s398334772
| 480
| 388
| 25,184
| 35,324
|
Accepted
|
Accepted
| 19.17
|
# ABC097D - Equals (ARC097D)
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, N): # construct a Union-Find tree (1-idx)
self.parent = [i for i in range(N + 1)]
self.rank = [0] * (N + 1)
def find(self, x): # find the group (root) of a vertex
if self.parent[x] == x:
return x
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def is_same(self, x, y): # check two vertices are in the same group
return self.find(x) == self.find(y)
def unite(self, x, y): # unite two groups
x, y = self.find(x), self.find(y)
if x == y: # the same group
return
# unite a small one to a bigger one to balance trees
if self.rank[x] < self.rank[y]:
self.parent[x] = y
else:
self.parent[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def main():
# check i and Pi are connected components or not
N, M = tuple(map(int, input().split()))
P = tuple(map(int, input().split()))
E = tuple(tuple(map(int, input().split())) for _ in range(M))
U = UnionFind(N) # construct a Union-Find tree (1-idx)
for v, u in E: # connected components are in the same group
U.unite(v, u)
ans = sum(U.is_same(i, p) for i, p in enumerate(P, 1))
print(ans)
if __name__ == "__main__":
main()
|
# ABC097D - Equals (ARC097D)
class UnionFind: # O(α(N))
def __init__(self, N): # construct a Union-Find tree (1-idx)
self.parent = [i for i in range(N + 1)]
self.rank = [0] * (N + 1)
def find(self, x): # find the group (root) of a vertex
if self.parent[x] == x:
return x
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def is_same(self, x, y): # check two vertices are in the same group
return self.find(x) == self.find(y)
def unite(self, x, y): # unite two groups
x, y = self.find(x), self.find(y)
if x == y: # the same group
return
# unite a small one to a bigger one to balance trees
if self.rank[x] < self.rank[y]:
self.parent[x] = y
else:
self.parent[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def main():
# check i and Pi are connected components or not
N, M, *A = list(map(int, open(0).read().split()))
P, E = A[:N], A[N:]
U = UnionFind(N) # construct a Union-Find tree (1-idx)
for v, u in zip(*[iter(E)] * 2): # connected components are in the same group
U.unite(v, u)
ans = sum(U.is_same(i, p) for i, p in enumerate(P, 1))
print(ans)
if __name__ == "__main__":
main()
| 46
| 41
| 1,472
| 1,377
|
# ABC097D - Equals (ARC097D)
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, N): # construct a Union-Find tree (1-idx)
self.parent = [i for i in range(N + 1)]
self.rank = [0] * (N + 1)
def find(self, x): # find the group (root) of a vertex
if self.parent[x] == x:
return x
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def is_same(self, x, y): # check two vertices are in the same group
return self.find(x) == self.find(y)
def unite(self, x, y): # unite two groups
x, y = self.find(x), self.find(y)
if x == y: # the same group
return
# unite a small one to a bigger one to balance trees
if self.rank[x] < self.rank[y]:
self.parent[x] = y
else:
self.parent[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def main():
# check i and Pi are connected components or not
N, M = tuple(map(int, input().split()))
P = tuple(map(int, input().split()))
E = tuple(tuple(map(int, input().split())) for _ in range(M))
U = UnionFind(N) # construct a Union-Find tree (1-idx)
for v, u in E: # connected components are in the same group
U.unite(v, u)
ans = sum(U.is_same(i, p) for i, p in enumerate(P, 1))
print(ans)
if __name__ == "__main__":
main()
|
# ABC097D - Equals (ARC097D)
class UnionFind: # O(α(N))
def __init__(self, N): # construct a Union-Find tree (1-idx)
self.parent = [i for i in range(N + 1)]
self.rank = [0] * (N + 1)
def find(self, x): # find the group (root) of a vertex
if self.parent[x] == x:
return x
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def is_same(self, x, y): # check two vertices are in the same group
return self.find(x) == self.find(y)
def unite(self, x, y): # unite two groups
x, y = self.find(x), self.find(y)
if x == y: # the same group
return
# unite a small one to a bigger one to balance trees
if self.rank[x] < self.rank[y]:
self.parent[x] = y
else:
self.parent[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def main():
# check i and Pi are connected components or not
N, M, *A = list(map(int, open(0).read().split()))
P, E = A[:N], A[N:]
U = UnionFind(N) # construct a Union-Find tree (1-idx)
for v, u in zip(*[iter(E)] * 2): # connected components are in the same group
U.unite(v, u)
ans = sum(U.is_same(i, p) for i, p in enumerate(P, 1))
print(ans)
if __name__ == "__main__":
main()
| false
| 10.869565
|
[
"-import sys",
"-",
"-input = sys.stdin.readline",
"-",
"-",
"-class UnionFind:",
"+class UnionFind: # O(α(N))",
"- N, M = tuple(map(int, input().split()))",
"- P = tuple(map(int, input().split()))",
"- E = tuple(tuple(map(int, input().split())) for _ in range(M))",
"+ N, M, *A = list(map(int, open(0).read().split()))",
"+ P, E = A[:N], A[N:]",
"- for v, u in E: # connected components are in the same group",
"+ for v, u in zip(*[iter(E)] * 2): # connected components are in the same group"
] | false
| 0.037626
| 0.038673
| 0.972926
|
[
"s166264147",
"s398334772"
] |
u077898957
|
p03378
|
python
|
s949557277
|
s698342466
| 20
| 18
| 3,060
| 2,940
|
Accepted
|
Accepted
| 10
|
n,m,x = list(map(int,input().split()))
a = list(map(int,input().split()))
c = 0
d = 0
for i in range(x):
if i in a:
c += 1
for i in range(x+1,n+1):
if i in a:
d += 1
print((min(c,d)))
|
n,m,x=list(map(int,input().split()))
A=list(map(int,input().split()))
left=0
right=0
for a in A:
if a<x:
left+=1
else:
right+=1
print((min(left,right)))
| 11
| 10
| 210
| 178
|
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))
c = 0
d = 0
for i in range(x):
if i in a:
c += 1
for i in range(x + 1, n + 1):
if i in a:
d += 1
print((min(c, d)))
|
n, m, x = list(map(int, input().split()))
A = list(map(int, input().split()))
left = 0
right = 0
for a in A:
if a < x:
left += 1
else:
right += 1
print((min(left, right)))
| false
| 9.090909
|
[
"-a = list(map(int, input().split()))",
"-c = 0",
"-d = 0",
"-for i in range(x):",
"- if i in a:",
"- c += 1",
"-for i in range(x + 1, n + 1):",
"- if i in a:",
"- d += 1",
"-print((min(c, d)))",
"+A = list(map(int, input().split()))",
"+left = 0",
"+right = 0",
"+for a in A:",
"+ if a < x:",
"+ left += 1",
"+ else:",
"+ right += 1",
"+print((min(left, right)))"
] | false
| 0.038588
| 0.041839
| 0.922288
|
[
"s949557277",
"s698342466"
] |
u111365362
|
p02954
|
python
|
s398050780
|
s833076307
| 888
| 121
| 11,000
| 14,400
|
Accepted
|
Accepted
| 86.37
|
s = eval(input())
n = len(s)
up = []
down = []
parity = 0
for i in range(1,n):
if s[i] != s[i-1]:
if parity == 0:
down.append(i)
else:
up.append(i)
parity = 1 - parity
ans = [0 for i in range(n)]
#print(up,down)
for i in range(n):
if s[i] == 'R':
diff = down[0] - i
if diff % 2 == 1:
ans[down[0]-1] += 1
else:
ans[down[0]] += 1
else:
diff = i - down[0]
if diff % 2 == 1:
ans[down[0]-1] += 1
else:
ans[down[0]] += 1
if up != []:
if i+1 == up[0]:
del down[0]
del up[0]
ANS = list(map(str,ans))
print((' '.join(ANS)))
|
s = eval(input())
n = len(s)
up = []
down = []
for i in range(1,n):
if s[i] != s[i-1]:
if s[i] == 'L':
down.append(i)
else:
up.append(i)
ans = [0 for _ in range(n)]
try:
top = up[0]
except:
top = 2 * n
bottom = down[0]
count = 0
for i in range(n):
diff = i - bottom
if diff % 2 == 0:
ans[bottom] += 1
else:
ans[bottom-1] += 1
#print(ans)
if i+1 == top:
count += 1
try:
top = up[count]
except:
pass
bottom = down[count]
print((' '.join(map(str,ans))))
| 33
| 32
| 634
| 545
|
s = eval(input())
n = len(s)
up = []
down = []
parity = 0
for i in range(1, n):
if s[i] != s[i - 1]:
if parity == 0:
down.append(i)
else:
up.append(i)
parity = 1 - parity
ans = [0 for i in range(n)]
# print(up,down)
for i in range(n):
if s[i] == "R":
diff = down[0] - i
if diff % 2 == 1:
ans[down[0] - 1] += 1
else:
ans[down[0]] += 1
else:
diff = i - down[0]
if diff % 2 == 1:
ans[down[0] - 1] += 1
else:
ans[down[0]] += 1
if up != []:
if i + 1 == up[0]:
del down[0]
del up[0]
ANS = list(map(str, ans))
print((" ".join(ANS)))
|
s = eval(input())
n = len(s)
up = []
down = []
for i in range(1, n):
if s[i] != s[i - 1]:
if s[i] == "L":
down.append(i)
else:
up.append(i)
ans = [0 for _ in range(n)]
try:
top = up[0]
except:
top = 2 * n
bottom = down[0]
count = 0
for i in range(n):
diff = i - bottom
if diff % 2 == 0:
ans[bottom] += 1
else:
ans[bottom - 1] += 1
# print(ans)
if i + 1 == top:
count += 1
try:
top = up[count]
except:
pass
bottom = down[count]
print((" ".join(map(str, ans))))
| false
| 3.030303
|
[
"-parity = 0",
"- if parity == 0:",
"+ if s[i] == \"L\":",
"- parity = 1 - parity",
"-ans = [0 for i in range(n)]",
"-# print(up,down)",
"+ans = [0 for _ in range(n)]",
"+try:",
"+ top = up[0]",
"+except:",
"+ top = 2 * n",
"+bottom = down[0]",
"+count = 0",
"- if s[i] == \"R\":",
"- diff = down[0] - i",
"- if diff % 2 == 1:",
"- ans[down[0] - 1] += 1",
"- else:",
"- ans[down[0]] += 1",
"+ diff = i - bottom",
"+ if diff % 2 == 0:",
"+ ans[bottom] += 1",
"- diff = i - down[0]",
"- if diff % 2 == 1:",
"- ans[down[0] - 1] += 1",
"- else:",
"- ans[down[0]] += 1",
"- if up != []:",
"- if i + 1 == up[0]:",
"- del down[0]",
"- del up[0]",
"-ANS = list(map(str, ans))",
"-print((\" \".join(ANS)))",
"+ ans[bottom - 1] += 1",
"+ # print(ans)",
"+ if i + 1 == top:",
"+ count += 1",
"+ try:",
"+ top = up[count]",
"+ except:",
"+ pass",
"+ bottom = down[count]",
"+print((\" \".join(map(str, ans))))"
] | false
| 0.046535
| 0.045248
| 1.028443
|
[
"s398050780",
"s833076307"
] |
u863442865
|
p02972
|
python
|
s257025571
|
s913713533
| 423
| 316
| 14,436
| 65,656
|
Accepted
|
Accepted
| 25.3
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
#from itertools import product
from bisect import bisect_left,bisect_right
import heapq
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
res = []
#dp[i]:i番目の箱に入ってるかどうか
dp = [0]*n
#iの倍数の箱を調べる
for i in range(n, 0, -1):
#調べる箱列挙
t = 0
for j in range(i, n+1, i):
t += dp[j-1]
if t%2 != a[i-1]:
res.append(i)
dp[i-1] = 1
if not 1 in a:
print((0))
else:
if len(res)>0:
print((len(res)))
print((*res))
else:
print((-1))
if __name__ == '__main__':
main()
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
#from itertools import product
from bisect import bisect_left,bisect_right
import heapq
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
res = []
#dp[i]:i番目の箱に入ってるかどうか
dp = [0]*n
#iの倍数の箱を調べる
for i in range(n, 0, -1):
#調べる箱列挙
t = 0
for j in range(i, n+1, i):
t += dp[j-1]
if t%2 != a[i-1]:
res.append(i)
dp[i-1] = 1
if not 1 in a:
print((0))
else:
print((len(res)))
print((*res))
if __name__ == '__main__':
main()
| 43
| 40
| 1,027
| 957
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
# from itertools import product
from bisect import bisect_left, bisect_right
import heapq
from math import floor, ceil
# from operator import itemgetter
# inf = 10**17
# mod = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
res = []
# dp[i]:i番目の箱に入ってるかどうか
dp = [0] * n
# iの倍数の箱を調べる
for i in range(n, 0, -1):
# 調べる箱列挙
t = 0
for j in range(i, n + 1, i):
t += dp[j - 1]
if t % 2 != a[i - 1]:
res.append(i)
dp[i - 1] = 1
if not 1 in a:
print((0))
else:
if len(res) > 0:
print((len(res)))
print((*res))
else:
print((-1))
if __name__ == "__main__":
main()
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby
# from itertools import product
from bisect import bisect_left, bisect_right
import heapq
from math import floor, ceil
# from operator import itemgetter
# inf = 10**17
# mod = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
res = []
# dp[i]:i番目の箱に入ってるかどうか
dp = [0] * n
# iの倍数の箱を調べる
for i in range(n, 0, -1):
# 調べる箱列挙
t = 0
for j in range(i, n + 1, i):
t += dp[j - 1]
if t % 2 != a[i - 1]:
res.append(i)
dp[i - 1] = 1
if not 1 in a:
print((0))
else:
print((len(res)))
print((*res))
if __name__ == "__main__":
main()
| false
| 6.976744
|
[
"- if len(res) > 0:",
"- print((len(res)))",
"- print((*res))",
"- else:",
"- print((-1))",
"+ print((len(res)))",
"+ print((*res))"
] | false
| 0.032924
| 0.034577
| 0.952206
|
[
"s257025571",
"s913713533"
] |
u119148115
|
p02571
|
python
|
s174421383
|
s177790722
| 126
| 62
| 64,828
| 65,288
|
Accepted
|
Accepted
| 50.79
|
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split()) #空白あり
def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし
S = LS2()
T = LS2()
s = len(S)
t = len(T)
ans = 10**5
for i in range(s-t+1):
count = 0
for j in range(t):
if T[j] != S[i+j]:
count += 1
ans = min(ans,count)
print(ans)
|
import sys
def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし
S = LS2()
T = LS2()
s = len(S)
t = len(T)
ans = 10**5
for i in range(s-t+1):
count = 0
for j in range(t):
if T[j] != S[i+j]:
count += 1
ans = min(ans,count)
print(ans)
| 26
| 18
| 707
| 293
|
import sys
sys.setrecursionlimit(10**7)
def I():
return int(sys.stdin.readline().rstrip())
def MI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def LI():
return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり
def LI2():
return list(map(int, sys.stdin.readline().rstrip())) # 空白なし
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split()) # 空白あり
def LS2():
return list(sys.stdin.readline().rstrip()) # 空白なし
S = LS2()
T = LS2()
s = len(S)
t = len(T)
ans = 10**5
for i in range(s - t + 1):
count = 0
for j in range(t):
if T[j] != S[i + j]:
count += 1
ans = min(ans, count)
print(ans)
|
import sys
def LS2():
return list(sys.stdin.readline().rstrip()) # 空白なし
S = LS2()
T = LS2()
s = len(S)
t = len(T)
ans = 10**5
for i in range(s - t + 1):
count = 0
for j in range(t):
if T[j] != S[i + j]:
count += 1
ans = min(ans, count)
print(ans)
| false
| 30.769231
|
[
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def I():",
"- return int(sys.stdin.readline().rstrip())",
"-",
"-",
"-def MI():",
"- return list(map(int, sys.stdin.readline().rstrip().split()))",
"-",
"-",
"-def LI():",
"- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり",
"-",
"-",
"-def LI2():",
"- return list(map(int, sys.stdin.readline().rstrip())) # 空白なし",
"-",
"-",
"-def S():",
"- return sys.stdin.readline().rstrip()",
"-",
"-",
"-def LS():",
"- return list(sys.stdin.readline().rstrip().split()) # 空白あり"
] | false
| 0.035916
| 0.03736
| 0.96137
|
[
"s174421383",
"s177790722"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.