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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u972591645
|
p02726
|
python
|
s860711510
|
s511726967
| 1,079 | 808 | 9,216 | 9,404 |
Accepted
|
Accepted
| 25.12 |
n, x, y = list(map(int, input().split()))
l = [0] * (n-1)
for i in range(1, n):
for j in range(i+1, n+1):
s = min(j-i, abs(x-i)+abs(j-y)+1)
l[s-1] += 1
for i in l:
print(i)
|
def main():
import sys
readline = sys.stdin.buffer.readline
n, x, y = list(map(int, readline().split()))
l = [0] * (n-1)
for i in range(1, n):
for j in range(i+1, n+1):
s = min(j-i, abs(x-i)+abs(j-y)+1)
l[s-1] += 1
for i in l:
print(i)
if __name__ == "__main__":
main()
| 9 | 16 | 199 | 349 |
n, x, y = list(map(int, input().split()))
l = [0] * (n - 1)
for i in range(1, n):
for j in range(i + 1, n + 1):
s = min(j - i, abs(x - i) + abs(j - y) + 1)
l[s - 1] += 1
for i in l:
print(i)
|
def main():
import sys
readline = sys.stdin.buffer.readline
n, x, y = list(map(int, readline().split()))
l = [0] * (n - 1)
for i in range(1, n):
for j in range(i + 1, n + 1):
s = min(j - i, abs(x - i) + abs(j - y) + 1)
l[s - 1] += 1
for i in l:
print(i)
if __name__ == "__main__":
main()
| false | 43.75 |
[
"-n, x, y = list(map(int, input().split()))",
"-l = [0] * (n - 1)",
"-for i in range(1, n):",
"- for j in range(i + 1, n + 1):",
"- s = min(j - i, abs(x - i) + abs(j - y) + 1)",
"- l[s - 1] += 1",
"-for i in l:",
"- print(i)",
"+def main():",
"+ import sys",
"+",
"+ readline = sys.stdin.buffer.readline",
"+ n, x, y = list(map(int, readline().split()))",
"+ l = [0] * (n - 1)",
"+ for i in range(1, n):",
"+ for j in range(i + 1, n + 1):",
"+ s = min(j - i, abs(x - i) + abs(j - y) + 1)",
"+ l[s - 1] += 1",
"+ for i in l:",
"+ print(i)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.047317 | 0.117668 | 0.402125 |
[
"s860711510",
"s511726967"
] |
u729133443
|
p02610
|
python
|
s304175750
|
s711060838
| 1,515 | 924 | 49,536 | 51,496 |
Accepted
|
Accepted
| 39.01 |
from heapq import*
i=input
for s in[0]*int(i()):
n,x,*y=int(i()),[]
for _ in'_'*n:k,l,r=t=[*list(map(int,i().split()))];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
for x in x,y:
x.sort();n=len(x);h=[(0,0)]*n*2
while h:
while[[n]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r))
s+=heappop(h)[~(n>0)];n-=1
print(s)
|
from heapq import*
i=input
for s in[0]*int(i()):
n,x,*y=int(i()),[]
for _ in'_'*n:k,l,r=t=[*list(map(int,i().split()))];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
for x in x,y:
h=[]
for k,l,r in sorted(x):
s+=r
if k:s+=l-r;heappush(h,l-r)
if len(h)>k:s-=heappop(h)
print(s)
| 11 | 12 | 317 | 287 |
from heapq import *
i = input
for s in [0] * int(i()):
n, x, *y = int(i()), []
for _ in "_" * n:
k, l, r = t = [*list(map(int, i().split()))]
x += [t] * (l > r)
y += [[n - k, r, l]] * (l <= r)
for x in x, y:
x.sort()
n = len(x)
h = [(0, 0)] * n * 2
while h:
while [[n]] < x[-1:]:
k, l, r = x.pop()
heappush(h, (r - l, l, r))
s += heappop(h)[~(n > 0)]
n -= 1
print(s)
|
from heapq import *
i = input
for s in [0] * int(i()):
n, x, *y = int(i()), []
for _ in "_" * n:
k, l, r = t = [*list(map(int, i().split()))]
x += [t] * (l > r)
y += [[n - k, r, l]] * (l <= r)
for x in x, y:
h = []
for k, l, r in sorted(x):
s += r
if k:
s += l - r
heappush(h, l - r)
if len(h) > k:
s -= heappop(h)
print(s)
| false | 8.333333 |
[
"- x.sort()",
"- n = len(x)",
"- h = [(0, 0)] * n * 2",
"- while h:",
"- while [[n]] < x[-1:]:",
"- k, l, r = x.pop()",
"- heappush(h, (r - l, l, r))",
"- s += heappop(h)[~(n > 0)]",
"- n -= 1",
"+ h = []",
"+ for k, l, r in sorted(x):",
"+ s += r",
"+ if k:",
"+ s += l - r",
"+ heappush(h, l - r)",
"+ if len(h) > k:",
"+ s -= heappop(h)"
] | false | 0.032744 | 0.041223 | 0.794331 |
[
"s304175750",
"s711060838"
] |
u188827677
|
p03037
|
python
|
s600209170
|
s698380012
| 418 | 302 | 3,064 | 11,020 |
Accepted
|
Accepted
| 27.75 |
n,m = list(map(int, input().split()))
lr = [0, 10**6]
for _ in range(m):
t = sorted(list(map(int, input().split())))
lr[0] = max(lr[0], t[0])
lr[1] = min(lr[1], t[1])
ans = lr[1] - lr[0] + 1
if ans < 0:
print((0))
else:
print(ans)
|
N,M = list(map(int, input().split()))
L = []
R = []
for _ in range(M):
l,r = list(map(int, input().split()))
L.append(l)
R.append(r)
ans = min(R)-max(L)+1
if ans < 0:
print((0))
else:
print(ans)
| 12 | 14 | 244 | 207 |
n, m = list(map(int, input().split()))
lr = [0, 10**6]
for _ in range(m):
t = sorted(list(map(int, input().split())))
lr[0] = max(lr[0], t[0])
lr[1] = min(lr[1], t[1])
ans = lr[1] - lr[0] + 1
if ans < 0:
print((0))
else:
print(ans)
|
N, M = list(map(int, input().split()))
L = []
R = []
for _ in range(M):
l, r = list(map(int, input().split()))
L.append(l)
R.append(r)
ans = min(R) - max(L) + 1
if ans < 0:
print((0))
else:
print(ans)
| false | 14.285714 |
[
"-n, m = list(map(int, input().split()))",
"-lr = [0, 10**6]",
"-for _ in range(m):",
"- t = sorted(list(map(int, input().split())))",
"- lr[0] = max(lr[0], t[0])",
"- lr[1] = min(lr[1], t[1])",
"-ans = lr[1] - lr[0] + 1",
"+N, M = list(map(int, input().split()))",
"+L = []",
"+R = []",
"+for _ in range(M):",
"+ l, r = list(map(int, input().split()))",
"+ L.append(l)",
"+ R.append(r)",
"+ans = min(R) - max(L) + 1"
] | false | 0.038162 | 0.039065 | 0.976894 |
[
"s600209170",
"s698380012"
] |
u638795007
|
p03136
|
python
|
s641017196
|
s038414276
| 180 | 47 | 38,384 | 4,976 |
Accepted
|
Accepted
| 73.89 |
def examA():
T, X = LI()
ans = T/X
print(ans)
return
def examB():
N = I()
L = LI()
ans = "Yes"
if max(L)*2>=sum(L):
ans = "No"
print(ans)
return
import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')
if __name__ == '__main__':
examB()
|
def examA():
N = I()
L = LI()
L.sort()
if sum(L)<=L[-1]*2:
print("No")
else:
print("Yes")
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]
sys.setrecursionlimit(10**7)
if __name__ == '__main__':
examA()
"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""
| 28 | 65 | 691 | 1,230 |
def examA():
T, X = LI()
ans = T / X
print(ans)
return
def examB():
N = I()
L = LI()
ans = "Yes"
if max(L) * 2 >= sum(L):
ans = "No"
print(ans)
return
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float("inf")
if __name__ == "__main__":
examB()
|
def examA():
N = I()
L = LI()
L.sort()
if sum(L) <= L[-1] * 2:
print("No")
else:
print("Yes")
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
import sys, bisect, itertools, heapq, math, random
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I():
return int(readline())
def LI():
return list(map(int, readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10 ** (-12)
alphabet = [chr(ord("a") + i) for i in range(26)]
sys.setrecursionlimit(10**7)
if __name__ == "__main__":
examA()
"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""
| false | 56.923077 |
[
"- T, X = LI()",
"- ans = T / X",
"+ N = I()",
"+ L = LI()",
"+ L.sort()",
"+ if sum(L) <= L[-1] * 2:",
"+ print(\"No\")",
"+ else:",
"+ print(\"Yes\")",
"+ return",
"+",
"+",
"+def examB():",
"+ ans = 0",
"-def examB():",
"- N = I()",
"- L = LI()",
"- ans = \"Yes\"",
"- if max(L) * 2 >= sum(L):",
"- ans = \"No\"",
"+def examC():",
"+ ans = 0",
"-import sys, copy, bisect, itertools, heapq, math",
"+def examD():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examE():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examF():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+import sys, bisect, itertools, heapq, math, random",
"+from copy import deepcopy",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+",
"- return int(sys.stdin.readline())",
"+ return int(readline())",
"- return list(map(int, sys.stdin.readline().split()))",
"+ return list(map(int, readline().split()))",
"+global mod, mod2, inf, alphabet, _ep",
"-inf = float(\"inf\")",
"+mod2 = 998244353",
"+inf = 10**18",
"+_ep = 10 ** (-12)",
"+alphabet = [chr(ord(\"a\") + i) for i in range(26)]",
"+sys.setrecursionlimit(10**7)",
"- examB()",
"+ examA()",
"+\"\"\"",
"+142",
"+12 9 1445 0 1",
"+asd dfg hj o o",
"+aidn",
"+\"\"\""
] | false | 0.037128 | 0.037053 | 1.002016 |
[
"s641017196",
"s038414276"
] |
u247366051
|
p03997
|
python
|
s231002048
|
s120851620
| 17 | 10 | 2,940 | 2,568 |
Accepted
|
Accepted
| 41.18 |
a,b,h=int(eval(input())),int(eval(input())),int(eval(input()))
print((int((a+b)*h/2)))
|
a = eval(input())
b = eval(input())
h = eval(input())
print(((a+b)*h/2))
| 2 | 4 | 67 | 55 |
a, b, h = int(eval(input())), int(eval(input())), int(eval(input()))
print((int((a + b) * h / 2)))
|
a = eval(input())
b = eval(input())
h = eval(input())
print(((a + b) * h / 2))
| false | 50 |
[
"-a, b, h = int(eval(input())), int(eval(input())), int(eval(input()))",
"-print((int((a + b) * h / 2)))",
"+a = eval(input())",
"+b = eval(input())",
"+h = eval(input())",
"+print(((a + b) * h / 2))"
] | false | 0.041552 | 0.037799 | 1.099284 |
[
"s231002048",
"s120851620"
] |
u052747412
|
p02396
|
python
|
s346362118
|
s549776664
| 60 | 50 | 8,088 | 8,020 |
Accepted
|
Accepted
| 16.67 |
import sys
i = 1
for line in sys.stdin.readlines():
x = line.strip()
if x != "0":
print(("Case {}: {}".format(i, x)))
i += 1
|
import sys
i = 1
for line in sys.stdin.readlines():
x = line.strip()
if x == "0":
break
print(("Case {}: {}".format(i, x)))
i += 1
| 8 | 9 | 150 | 161 |
import sys
i = 1
for line in sys.stdin.readlines():
x = line.strip()
if x != "0":
print(("Case {}: {}".format(i, x)))
i += 1
|
import sys
i = 1
for line in sys.stdin.readlines():
x = line.strip()
if x == "0":
break
print(("Case {}: {}".format(i, x)))
i += 1
| false | 11.111111 |
[
"- if x != \"0\":",
"- print((\"Case {}: {}\".format(i, x)))",
"+ if x == \"0\":",
"+ break",
"+ print((\"Case {}: {}\".format(i, x)))"
] | false | 0.124477 | 0.048613 | 2.560567 |
[
"s346362118",
"s549776664"
] |
u392319141
|
p03988
|
python
|
s359947544
|
s741629686
| 27 | 21 | 3,424 | 3,316 |
Accepted
|
Accepted
| 22.22 |
from collections import Counter, deque
N = int(eval(input()))
A = list(map(int, input().split()))
cntA = Counter(A)
valA = list(set(A))
valA.sort(reverse=True)
pathLeng = [0] * (N + 1)
if cntA[valA[0]] < 2 or cntA[valA[-1]] > 2:
print('Impossible')
exit()
pathLeng[1] = valA[0]
pathLeng[2] = valA[0]
cntA[valA[0]] -= 2
maxNode = 2
pr = [[] for _ in range(N + 1)]
ch = [[] for _ in range(N + 1)]
for i, a in enumerate(valA[1:], start=2):
if a == valA[-1] and cntA[valA[-1]] == 1:
prevLeft = maxNode
prevRight = maxNode - 1
maxNode += 1
ch[prevLeft].append(maxNode)
ch[prevRight].append(maxNode)
pr[maxNode].append(prevLeft)
pr[maxNode].append(prevRight)
pathLeng[maxNode] = valA[-1]
cntA[valA[-1]] -= 1
break
prevLeft = (i - 1) * 2 - 1
prevRight = (i - 1) * 2
nowLeft = i * 2 - 1
nowRight = i * 2
maxNode = max(maxNode, nowRight)
if maxNode > N:
print('Impossible')
exit()
pathLeng[nowLeft] = a
pathLeng[nowRight] = a
cntA[a] -= 2
ch[prevLeft].append(nowLeft)
ch[prevRight].append(nowRight)
pr[nowLeft].append(prevLeft)
pr[nowRight].append(prevRight)
else:
ch[maxNode].append(maxNode - 1)
pr[maxNode - 1].append(maxNode)
for a, c in list(cntA.items()):
for _ in range(c):
maxNode += 1
i = pathLeng.index(a)
ch[maxNode].append(ch[i][0])
pr[ch[i][0]].append(maxNode)
pathLeng[maxNode] = a
cntA[a] -= 1
def search(index):
visited = [False] * (N + 1)
visited[index] = True
st = deque([(index, 0)])
ret = 0
while st:
now, d = st.pop()
ret = max(ret, d)
for to in pr[now]:
if not visited[to]:
st.append((to, d + 1))
visited[to] = True
for to in ch[now]:
if not visited[to]:
st.append((to, d + 1))
visited[to] = True
return ret
for i, d in enumerate(pathLeng[1:], start=1):
if search(i) != d:
print('Impossible')
exit()
for v in list(cntA.values()):
if v != 0:
print('Impossible')
exit()
A.sort()
pathLeng.sort()
if A == pathLeng[1:]:
print('Possible')
else:
print('Impossible')
|
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
cntA = Counter(A)
valA= list(set(A))
valA.sort()
if valA[-1] % 2 == 1:
if valA[0] != -(-valA[-1] // 2) or cntA[valA[0]] != 2:
print('Impossible')
exit()
for a in range(valA[0], valA[-1] + 1):
if cntA[a] < 2:
print('Impossible')
exit()
else:
if valA[0] != valA[-1] // 2 or cntA[valA[0]] != 1:
print('Impossible')
exit()
for a in range(valA[0] + 1, valA[-1] + 1):
if cntA[a] < 2:
print('Impossible')
exit()
print('Possible')
| 105 | 28 | 2,388 | 652 |
from collections import Counter, deque
N = int(eval(input()))
A = list(map(int, input().split()))
cntA = Counter(A)
valA = list(set(A))
valA.sort(reverse=True)
pathLeng = [0] * (N + 1)
if cntA[valA[0]] < 2 or cntA[valA[-1]] > 2:
print("Impossible")
exit()
pathLeng[1] = valA[0]
pathLeng[2] = valA[0]
cntA[valA[0]] -= 2
maxNode = 2
pr = [[] for _ in range(N + 1)]
ch = [[] for _ in range(N + 1)]
for i, a in enumerate(valA[1:], start=2):
if a == valA[-1] and cntA[valA[-1]] == 1:
prevLeft = maxNode
prevRight = maxNode - 1
maxNode += 1
ch[prevLeft].append(maxNode)
ch[prevRight].append(maxNode)
pr[maxNode].append(prevLeft)
pr[maxNode].append(prevRight)
pathLeng[maxNode] = valA[-1]
cntA[valA[-1]] -= 1
break
prevLeft = (i - 1) * 2 - 1
prevRight = (i - 1) * 2
nowLeft = i * 2 - 1
nowRight = i * 2
maxNode = max(maxNode, nowRight)
if maxNode > N:
print("Impossible")
exit()
pathLeng[nowLeft] = a
pathLeng[nowRight] = a
cntA[a] -= 2
ch[prevLeft].append(nowLeft)
ch[prevRight].append(nowRight)
pr[nowLeft].append(prevLeft)
pr[nowRight].append(prevRight)
else:
ch[maxNode].append(maxNode - 1)
pr[maxNode - 1].append(maxNode)
for a, c in list(cntA.items()):
for _ in range(c):
maxNode += 1
i = pathLeng.index(a)
ch[maxNode].append(ch[i][0])
pr[ch[i][0]].append(maxNode)
pathLeng[maxNode] = a
cntA[a] -= 1
def search(index):
visited = [False] * (N + 1)
visited[index] = True
st = deque([(index, 0)])
ret = 0
while st:
now, d = st.pop()
ret = max(ret, d)
for to in pr[now]:
if not visited[to]:
st.append((to, d + 1))
visited[to] = True
for to in ch[now]:
if not visited[to]:
st.append((to, d + 1))
visited[to] = True
return ret
for i, d in enumerate(pathLeng[1:], start=1):
if search(i) != d:
print("Impossible")
exit()
for v in list(cntA.values()):
if v != 0:
print("Impossible")
exit()
A.sort()
pathLeng.sort()
if A == pathLeng[1:]:
print("Possible")
else:
print("Impossible")
|
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
cntA = Counter(A)
valA = list(set(A))
valA.sort()
if valA[-1] % 2 == 1:
if valA[0] != -(-valA[-1] // 2) or cntA[valA[0]] != 2:
print("Impossible")
exit()
for a in range(valA[0], valA[-1] + 1):
if cntA[a] < 2:
print("Impossible")
exit()
else:
if valA[0] != valA[-1] // 2 or cntA[valA[0]] != 1:
print("Impossible")
exit()
for a in range(valA[0] + 1, valA[-1] + 1):
if cntA[a] < 2:
print("Impossible")
exit()
print("Possible")
| false | 73.333333 |
[
"-from collections import Counter, deque",
"+from collections import Counter",
"-valA.sort(reverse=True)",
"-pathLeng = [0] * (N + 1)",
"-if cntA[valA[0]] < 2 or cntA[valA[-1]] > 2:",
"- print(\"Impossible\")",
"- exit()",
"-pathLeng[1] = valA[0]",
"-pathLeng[2] = valA[0]",
"-cntA[valA[0]] -= 2",
"-maxNode = 2",
"-pr = [[] for _ in range(N + 1)]",
"-ch = [[] for _ in range(N + 1)]",
"-for i, a in enumerate(valA[1:], start=2):",
"- if a == valA[-1] and cntA[valA[-1]] == 1:",
"- prevLeft = maxNode",
"- prevRight = maxNode - 1",
"- maxNode += 1",
"- ch[prevLeft].append(maxNode)",
"- ch[prevRight].append(maxNode)",
"- pr[maxNode].append(prevLeft)",
"- pr[maxNode].append(prevRight)",
"- pathLeng[maxNode] = valA[-1]",
"- cntA[valA[-1]] -= 1",
"- break",
"- prevLeft = (i - 1) * 2 - 1",
"- prevRight = (i - 1) * 2",
"- nowLeft = i * 2 - 1",
"- nowRight = i * 2",
"- maxNode = max(maxNode, nowRight)",
"- if maxNode > N:",
"+valA.sort()",
"+if valA[-1] % 2 == 1:",
"+ if valA[0] != -(-valA[-1] // 2) or cntA[valA[0]] != 2:",
"- pathLeng[nowLeft] = a",
"- pathLeng[nowRight] = a",
"- cntA[a] -= 2",
"- ch[prevLeft].append(nowLeft)",
"- ch[prevRight].append(nowRight)",
"- pr[nowLeft].append(prevLeft)",
"- pr[nowRight].append(prevRight)",
"+ for a in range(valA[0], valA[-1] + 1):",
"+ if cntA[a] < 2:",
"+ print(\"Impossible\")",
"+ exit()",
"- ch[maxNode].append(maxNode - 1)",
"- pr[maxNode - 1].append(maxNode)",
"-for a, c in list(cntA.items()):",
"- for _ in range(c):",
"- maxNode += 1",
"- i = pathLeng.index(a)",
"- ch[maxNode].append(ch[i][0])",
"- pr[ch[i][0]].append(maxNode)",
"- pathLeng[maxNode] = a",
"- cntA[a] -= 1",
"-",
"-",
"-def search(index):",
"- visited = [False] * (N + 1)",
"- visited[index] = True",
"- st = deque([(index, 0)])",
"- ret = 0",
"- while st:",
"- now, d = st.pop()",
"- ret = max(ret, d)",
"- for to in pr[now]:",
"- if not visited[to]:",
"- st.append((to, d + 1))",
"- visited[to] = True",
"- for to in ch[now]:",
"- if not visited[to]:",
"- st.append((to, d + 1))",
"- visited[to] = True",
"- return ret",
"-",
"-",
"-for i, d in enumerate(pathLeng[1:], start=1):",
"- if search(i) != d:",
"+ if valA[0] != valA[-1] // 2 or cntA[valA[0]] != 1:",
"-for v in list(cntA.values()):",
"- if v != 0:",
"- print(\"Impossible\")",
"- exit()",
"-A.sort()",
"-pathLeng.sort()",
"-if A == pathLeng[1:]:",
"- print(\"Possible\")",
"-else:",
"- print(\"Impossible\")",
"+ for a in range(valA[0] + 1, valA[-1] + 1):",
"+ if cntA[a] < 2:",
"+ print(\"Impossible\")",
"+ exit()",
"+print(\"Possible\")"
] | false | 0.069362 | 0.037784 | 1.835781 |
[
"s359947544",
"s741629686"
] |
u513081876
|
p03611
|
python
|
s185959936
|
s212145291
| 169 | 83 | 14,428 | 13,964 |
Accepted
|
Accepted
| 50.89 |
import bisect
N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
ans = 0
for i in set(A):
l = bisect.bisect_left(A, i-1)
r = bisect.bisect_right(A, i+1)
ans = max(ans, r-l)
print(ans)
|
N = int(eval(input()))
A = [int(i) for i in input().split()]
num = [0] * (10**5+2)
for i in A:
num[i] += 1
num[i+1] += 1
num[i+2] += 1
print((max(num)))
| 10 | 10 | 218 | 167 |
import bisect
N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
ans = 0
for i in set(A):
l = bisect.bisect_left(A, i - 1)
r = bisect.bisect_right(A, i + 1)
ans = max(ans, r - l)
print(ans)
|
N = int(eval(input()))
A = [int(i) for i in input().split()]
num = [0] * (10**5 + 2)
for i in A:
num[i] += 1
num[i + 1] += 1
num[i + 2] += 1
print((max(num)))
| false | 0 |
[
"-import bisect",
"-",
"-A = sorted([int(i) for i in input().split()])",
"-ans = 0",
"-for i in set(A):",
"- l = bisect.bisect_left(A, i - 1)",
"- r = bisect.bisect_right(A, i + 1)",
"- ans = max(ans, r - l)",
"-print(ans)",
"+A = [int(i) for i in input().split()]",
"+num = [0] * (10**5 + 2)",
"+for i in A:",
"+ num[i] += 1",
"+ num[i + 1] += 1",
"+ num[i + 2] += 1",
"+print((max(num)))"
] | false | 0.042235 | 0.057357 | 0.736359 |
[
"s185959936",
"s212145291"
] |
u753803401
|
p03311
|
python
|
s971053235
|
s585487558
| 299 | 269 | 92,368 | 73,840 |
Accepted
|
Accepted
| 10.03 |
def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
b = []
for i, v in enumerate(a):
b.append(v - (i + 1))
b.sort()
t = b[len(b) // 2]
s = 0
for i, v in enumerate(a):
s += abs(v - (t + (i + 1)))
print(s)
if __name__ == '__main__':
slove()
|
import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
for i in range(n):
a[i] -= i + 1
a.sort()
t1 = 0
t2 = 0
for i in range(n):
t1 += abs(a[i] - a[n//2])
t2 += abs(a[i] - a[n//2 - 1])
print((min(t1, t2)))
if __name__ == '__main__':
solve()
| 18 | 21 | 400 | 415 |
def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip("\n"))
a = list(map(int, input().rstrip("\n").split()))
b = []
for i, v in enumerate(a):
b.append(v - (i + 1))
b.sort()
t = b[len(b) // 2]
s = 0
for i, v in enumerate(a):
s += abs(v - (t + (i + 1)))
print(s)
if __name__ == "__main__":
slove()
|
import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
a = list(map(int, readline().split()))
for i in range(n):
a[i] -= i + 1
a.sort()
t1 = 0
t2 = 0
for i in range(n):
t1 += abs(a[i] - a[n // 2])
t2 += abs(a[i] - a[n // 2 - 1])
print((min(t1, t2)))
if __name__ == "__main__":
solve()
| false | 14.285714 |
[
"-def slove():",
"- import sys",
"+import sys",
"- input = sys.stdin.readline",
"- n = int(input().rstrip(\"\\n\"))",
"- a = list(map(int, input().rstrip(\"\\n\").split()))",
"- b = []",
"- for i, v in enumerate(a):",
"- b.append(v - (i + 1))",
"- b.sort()",
"- t = b[len(b) // 2]",
"- s = 0",
"- for i, v in enumerate(a):",
"- s += abs(v - (t + (i + 1)))",
"- print(s)",
"+",
"+def solve():",
"+ readline = sys.stdin.buffer.readline",
"+ mod = 10**9 + 7",
"+ n = int(readline())",
"+ a = list(map(int, readline().split()))",
"+ for i in range(n):",
"+ a[i] -= i + 1",
"+ a.sort()",
"+ t1 = 0",
"+ t2 = 0",
"+ for i in range(n):",
"+ t1 += abs(a[i] - a[n // 2])",
"+ t2 += abs(a[i] - a[n // 2 - 1])",
"+ print((min(t1, t2)))",
"- slove()",
"+ solve()"
] | false | 0.047047 | 0.046486 | 1.012055 |
[
"s971053235",
"s585487558"
] |
u072053884
|
p02268
|
python
|
s050619473
|
s908029947
| 550 | 480 | 18,820 | 18,976 |
Accepted
|
Accepted
| 12.73 |
n = int(eval(input()))
S = list(map(int, input().split(' ')))
q = eval(input())
T = list(map(int, input().split(' ')))
cnt = 0
for i in T:
left = 0
right = n
while left < right:
mid = (left + right) // 2
if S[mid] == i:
cnt += 1
break
elif i < S[mid]:
right = mid
else:
left = mid + 1
print(cnt)
|
n = int(eval(input()))
S = tuple(map(int, input().split(' ')))
q = eval(input())
T = tuple(map(int, input().split(' ')))
cnt = 0
for i in T:
left = 0
right = n
while left < right:
mid = (left + right) // 2
if S[mid] == i:
cnt += 1
break
elif i < S[mid]:
right = mid
else:
left = mid + 1
print(cnt)
| 22 | 22 | 400 | 402 |
n = int(eval(input()))
S = list(map(int, input().split(" ")))
q = eval(input())
T = list(map(int, input().split(" ")))
cnt = 0
for i in T:
left = 0
right = n
while left < right:
mid = (left + right) // 2
if S[mid] == i:
cnt += 1
break
elif i < S[mid]:
right = mid
else:
left = mid + 1
print(cnt)
|
n = int(eval(input()))
S = tuple(map(int, input().split(" ")))
q = eval(input())
T = tuple(map(int, input().split(" ")))
cnt = 0
for i in T:
left = 0
right = n
while left < right:
mid = (left + right) // 2
if S[mid] == i:
cnt += 1
break
elif i < S[mid]:
right = mid
else:
left = mid + 1
print(cnt)
| false | 0 |
[
"-S = list(map(int, input().split(\" \")))",
"+S = tuple(map(int, input().split(\" \")))",
"-T = list(map(int, input().split(\" \")))",
"+T = tuple(map(int, input().split(\" \")))"
] | false | 0.044925 | 0.172599 | 0.260284 |
[
"s050619473",
"s908029947"
] |
u282228874
|
p03805
|
python
|
s211942752
|
s228624862
| 29 | 25 | 3,064 | 3,064 |
Accepted
|
Accepted
| 13.79 |
from itertools import permutations
n,m = list(map(int,input().split()))
D = [[0]*n for i in range(n)]
for i in range(m):
a,b = list(map(int,input().split()))
D[a-1][b-1] = 1
D[b-1][a-1] = 1
cnt = 0
for a in permutations(list(range(n))):
if a[0] != 0:
break
tmp = 1
for i in range(n-1):
tmp = tmp * D[a[i]][a[i+1]]
cnt += tmp
print(cnt)
|
n,m = list(map(int, input().split()))
D = [list() for i in range(n)]
for i in range(m):
a,b = list(map(int,input().split()))
D[a-1].append(b-1)
D[b-1].append(a-1)
d = [0]*n
d[0] = 1
cnt = 0
def dfs(x):
global cnt
if all(d):
cnt += 1
return
for i in D[x]:
if d[i] == 0:
d[i] = 1
dfs(i)
d[i] = 0
dfs(0)
print(cnt)
| 17 | 24 | 345 | 367 |
from itertools import permutations
n, m = list(map(int, input().split()))
D = [[0] * n for i in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
D[a - 1][b - 1] = 1
D[b - 1][a - 1] = 1
cnt = 0
for a in permutations(list(range(n))):
if a[0] != 0:
break
tmp = 1
for i in range(n - 1):
tmp = tmp * D[a[i]][a[i + 1]]
cnt += tmp
print(cnt)
|
n, m = list(map(int, input().split()))
D = [list() for i in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
D[a - 1].append(b - 1)
D[b - 1].append(a - 1)
d = [0] * n
d[0] = 1
cnt = 0
def dfs(x):
global cnt
if all(d):
cnt += 1
return
for i in D[x]:
if d[i] == 0:
d[i] = 1
dfs(i)
d[i] = 0
dfs(0)
print(cnt)
| false | 29.166667 |
[
"-from itertools import permutations",
"-",
"-D = [[0] * n for i in range(n)]",
"+D = [list() for i in range(n)]",
"- D[a - 1][b - 1] = 1",
"- D[b - 1][a - 1] = 1",
"+ D[a - 1].append(b - 1)",
"+ D[b - 1].append(a - 1)",
"+d = [0] * n",
"+d[0] = 1",
"-for a in permutations(list(range(n))):",
"- if a[0] != 0:",
"- break",
"- tmp = 1",
"- for i in range(n - 1):",
"- tmp = tmp * D[a[i]][a[i + 1]]",
"- cnt += tmp",
"+",
"+",
"+def dfs(x):",
"+ global cnt",
"+ if all(d):",
"+ cnt += 1",
"+ return",
"+ for i in D[x]:",
"+ if d[i] == 0:",
"+ d[i] = 1",
"+ dfs(i)",
"+ d[i] = 0",
"+",
"+",
"+dfs(0)"
] | false | 0.049413 | 0.035773 | 1.381273 |
[
"s211942752",
"s228624862"
] |
u922487073
|
p02713
|
python
|
s965954810
|
s482918560
| 1,395 | 478 | 9,320 | 69,376 |
Accepted
|
Accepted
| 65.73 |
import math
K = int(eval(input()))
# table = np.zeros((K,K), dtype="int16")
table = [[0] * K for i in range(K)]
for a in range(K):
for b in range(a, K):
tmp = math.gcd(a+1, b+1)
table[a][b] = tmp
table[b][a] = tmp
res = 0
for a in range(K):
for b in range(K):
for c in range(K):
res += table[table[a][b]-1][c]
print(res)
|
import math
K = int(eval(input()))
res = 0
for a in range(K):
for b in range(K):
for c in range(K):
res += math.gcd(math.gcd(a+1, b+1), c+1)
print(res)
| 18 | 9 | 391 | 181 |
import math
K = int(eval(input()))
# table = np.zeros((K,K), dtype="int16")
table = [[0] * K for i in range(K)]
for a in range(K):
for b in range(a, K):
tmp = math.gcd(a + 1, b + 1)
table[a][b] = tmp
table[b][a] = tmp
res = 0
for a in range(K):
for b in range(K):
for c in range(K):
res += table[table[a][b] - 1][c]
print(res)
|
import math
K = int(eval(input()))
res = 0
for a in range(K):
for b in range(K):
for c in range(K):
res += math.gcd(math.gcd(a + 1, b + 1), c + 1)
print(res)
| false | 50 |
[
"-# table = np.zeros((K,K), dtype=\"int16\")",
"-table = [[0] * K for i in range(K)]",
"-for a in range(K):",
"- for b in range(a, K):",
"- tmp = math.gcd(a + 1, b + 1)",
"- table[a][b] = tmp",
"- table[b][a] = tmp",
"- res += table[table[a][b] - 1][c]",
"+ res += math.gcd(math.gcd(a + 1, b + 1), c + 1)"
] | false | 0.128502 | 0.037877 | 3.392596 |
[
"s965954810",
"s482918560"
] |
u059940903
|
p02873
|
python
|
s173179482
|
s827039810
| 223 | 202 | 47,944 | 47,688 |
Accepted
|
Accepted
| 9.42 |
S = eval(input())
nums = [0] * (len(S)+1)
pos = 0
count = 0
pre_count = 0
now = '>'
for (i, s) in enumerate(S):
if s != now:
if s == '<':
nums[pos] = max(pre_count, count)
while pos != i:
pos += 1
count -= 1
nums[pos] = count
else:
pos = i
pre_count = count+1
count = 1
now = s
else:
count += 1
if s == '<':
nums[i] = count
if now == '<':
nums[i+1] = count+1
if s == '>':
nums[pos] = max(pre_count, count)
while pos != i+1:
pos += 1
count -= 1
nums[pos] = count
print((sum(nums)))
|
S = eval(input())
A = [0] * (len(S)+1)
sstreak = 0
bstreak = 0
for i in range(len(S)):
if S[i] == "<":
if 0 < bstreak:
A[i-bstreak] = max(bstreak, sstreak)
bstreak -= 1
while 0 < bstreak:
A[i-bstreak] = bstreak
bstreak -= 1
sstreak = 0
A[i] = sstreak
sstreak += 1
else:
bstreak += 1
i+=1
if S[-1] == "<":
A[i] = sstreak
if 0 < bstreak:
A[i-bstreak] = max(bstreak, sstreak)
bstreak -= 1
while 0 < bstreak:
A[i-bstreak] = bstreak
bstreak -= 1
print((sum(A)))
| 34 | 30 | 609 | 556 |
S = eval(input())
nums = [0] * (len(S) + 1)
pos = 0
count = 0
pre_count = 0
now = ">"
for (i, s) in enumerate(S):
if s != now:
if s == "<":
nums[pos] = max(pre_count, count)
while pos != i:
pos += 1
count -= 1
nums[pos] = count
else:
pos = i
pre_count = count + 1
count = 1
now = s
else:
count += 1
if s == "<":
nums[i] = count
if now == "<":
nums[i + 1] = count + 1
if s == ">":
nums[pos] = max(pre_count, count)
while pos != i + 1:
pos += 1
count -= 1
nums[pos] = count
print((sum(nums)))
|
S = eval(input())
A = [0] * (len(S) + 1)
sstreak = 0
bstreak = 0
for i in range(len(S)):
if S[i] == "<":
if 0 < bstreak:
A[i - bstreak] = max(bstreak, sstreak)
bstreak -= 1
while 0 < bstreak:
A[i - bstreak] = bstreak
bstreak -= 1
sstreak = 0
A[i] = sstreak
sstreak += 1
else:
bstreak += 1
i += 1
if S[-1] == "<":
A[i] = sstreak
if 0 < bstreak:
A[i - bstreak] = max(bstreak, sstreak)
bstreak -= 1
while 0 < bstreak:
A[i - bstreak] = bstreak
bstreak -= 1
print((sum(A)))
| false | 11.764706 |
[
"-nums = [0] * (len(S) + 1)",
"-pos = 0",
"-count = 0",
"-pre_count = 0",
"-now = \">\"",
"-for (i, s) in enumerate(S):",
"- if s != now:",
"- if s == \"<\":",
"- nums[pos] = max(pre_count, count)",
"- while pos != i:",
"- pos += 1",
"- count -= 1",
"- nums[pos] = count",
"- else:",
"- pos = i",
"- pre_count = count + 1",
"- count = 1",
"- now = s",
"+A = [0] * (len(S) + 1)",
"+sstreak = 0",
"+bstreak = 0",
"+for i in range(len(S)):",
"+ if S[i] == \"<\":",
"+ if 0 < bstreak:",
"+ A[i - bstreak] = max(bstreak, sstreak)",
"+ bstreak -= 1",
"+ while 0 < bstreak:",
"+ A[i - bstreak] = bstreak",
"+ bstreak -= 1",
"+ sstreak = 0",
"+ A[i] = sstreak",
"+ sstreak += 1",
"- count += 1",
"- if s == \"<\":",
"- nums[i] = count",
"-if now == \"<\":",
"- nums[i + 1] = count + 1",
"-if s == \">\":",
"- nums[pos] = max(pre_count, count)",
"- while pos != i + 1:",
"- pos += 1",
"- count -= 1",
"- nums[pos] = count",
"-print((sum(nums)))",
"+ bstreak += 1",
"+i += 1",
"+if S[-1] == \"<\":",
"+ A[i] = sstreak",
"+if 0 < bstreak:",
"+ A[i - bstreak] = max(bstreak, sstreak)",
"+ bstreak -= 1",
"+ while 0 < bstreak:",
"+ A[i - bstreak] = bstreak",
"+ bstreak -= 1",
"+print((sum(A)))"
] | false | 0.042694 | 0.039895 | 1.070179 |
[
"s173179482",
"s827039810"
] |
u305366205
|
p02767
|
python
|
s516683755
|
s521349152
| 21 | 17 | 3,064 | 3,060 |
Accepted
|
Accepted
| 19.05 |
n = int(eval(input()))
x = list(map(int, input().split()))
ans = float('inf')
for i in range(101):
now = 0
for j in range(n):
now += (x[j] - i) ** 2
ans = min(ans, now)
print(ans)
|
n = int(eval(input()))
x = list(map(int, input().split()))
avg = sum(x) / n
if avg % 1 >= 0.5:
avg += 1
avg = int(avg)
ans = 0
for xi in x:
ans += (xi - avg) ** 2
print(ans)
| 9 | 10 | 202 | 184 |
n = int(eval(input()))
x = list(map(int, input().split()))
ans = float("inf")
for i in range(101):
now = 0
for j in range(n):
now += (x[j] - i) ** 2
ans = min(ans, now)
print(ans)
|
n = int(eval(input()))
x = list(map(int, input().split()))
avg = sum(x) / n
if avg % 1 >= 0.5:
avg += 1
avg = int(avg)
ans = 0
for xi in x:
ans += (xi - avg) ** 2
print(ans)
| false | 10 |
[
"-ans = float(\"inf\")",
"-for i in range(101):",
"- now = 0",
"- for j in range(n):",
"- now += (x[j] - i) ** 2",
"- ans = min(ans, now)",
"+avg = sum(x) / n",
"+if avg % 1 >= 0.5:",
"+ avg += 1",
"+avg = int(avg)",
"+ans = 0",
"+for xi in x:",
"+ ans += (xi - avg) ** 2"
] | false | 0.047067 | 0.046696 | 1.007938 |
[
"s516683755",
"s521349152"
] |
u476604182
|
p02788
|
python
|
s959763116
|
s387549781
| 1,738 | 1,108 | 132,824 | 44,644 |
Accepted
|
Accepted
| 36.25 |
from math import ceil
from collections import deque
N, D, H = list(map(int, input().split()))
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h/H)] for x, h in Monsters]
ans = 0
acc = 0
deq = deque([])
for x, h in Monsters:
while deq and x>deq[0][0]:
lim, dam = deq.popleft()
acc -= dam
c = max(0, h-acc)
ans += c
acc += c
if c:
deq += [(x+2*D, c)]
print(ans)
|
from collections import deque
N, D, A = list(map(int, input().split()))
ls = []
for i in range(N):
x,h = list(map(int, input().split()))
h = h//A if h%A==0 else h//A+1
ls += [(x,h)]
ls.sort(key=lambda x:x[0])
deq = deque([])
ans = 0
acc = 0
for i in range(N):
x, h = ls[i]
while deq and deq[0][0]<x:
y, d = deq.popleft()
acc -= d
n = max(0,h-acc)
ans += n
acc += n
if n:
deq += [(x+2*D,n)]
print(ans)
| 22 | 22 | 448 | 439 |
from math import ceil
from collections import deque
N, D, H = list(map(int, input().split()))
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / H)] for x, h in Monsters]
ans = 0
acc = 0
deq = deque([])
for x, h in Monsters:
while deq and x > deq[0][0]:
lim, dam = deq.popleft()
acc -= dam
c = max(0, h - acc)
ans += c
acc += c
if c:
deq += [(x + 2 * D, c)]
print(ans)
|
from collections import deque
N, D, A = list(map(int, input().split()))
ls = []
for i in range(N):
x, h = list(map(int, input().split()))
h = h // A if h % A == 0 else h // A + 1
ls += [(x, h)]
ls.sort(key=lambda x: x[0])
deq = deque([])
ans = 0
acc = 0
for i in range(N):
x, h = ls[i]
while deq and deq[0][0] < x:
y, d = deq.popleft()
acc -= d
n = max(0, h - acc)
ans += n
acc += n
if n:
deq += [(x + 2 * D, n)]
print(ans)
| false | 0 |
[
"-from math import ceil",
"-N, D, H = list(map(int, input().split()))",
"-Monsters = sorted([list(map(int, input().split())) for i in range(N)])",
"-Monsters = [[x, ceil(h / H)] for x, h in Monsters]",
"+N, D, A = list(map(int, input().split()))",
"+ls = []",
"+for i in range(N):",
"+ x, h = list(map(int, input().split()))",
"+ h = h // A if h % A == 0 else h // A + 1",
"+ ls += [(x, h)]",
"+ls.sort(key=lambda x: x[0])",
"+deq = deque([])",
"-deq = deque([])",
"-for x, h in Monsters:",
"- while deq and x > deq[0][0]:",
"- lim, dam = deq.popleft()",
"- acc -= dam",
"- c = max(0, h - acc)",
"- ans += c",
"- acc += c",
"- if c:",
"- deq += [(x + 2 * D, c)]",
"+for i in range(N):",
"+ x, h = ls[i]",
"+ while deq and deq[0][0] < x:",
"+ y, d = deq.popleft()",
"+ acc -= d",
"+ n = max(0, h - acc)",
"+ ans += n",
"+ acc += n",
"+ if n:",
"+ deq += [(x + 2 * D, n)]"
] | false | 0.102243 | 0.077875 | 1.312907 |
[
"s959763116",
"s387549781"
] |
u309120194
|
p02813
|
python
|
s244114434
|
s465696203
| 50 | 42 | 13,944 | 13,984 |
Accepted
|
Accepted
| 16 |
import itertools
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsが使える
# permutations(関数)にlistを渡すと、順列を生成!
l = [i for i in range(1, N+1)]
permutations_l = list(itertools.permutations(l))
a, b = 0, 0
for i, R in enumerate(permutations_l):
if R == P: a = i
for i, R in enumerate(permutations_l):
if R == Q: b = i
print((abs(a-b)))
|
import itertools
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsで順列を生成できる!
l = [i for i in range(1, N+1)]
permutations_l = list(itertools.permutations(l))
a, b = 0, 0
for i, R in enumerate(permutations_l):
if R == P: a = i
if R == Q: b = i
print((abs(a-b)))
| 20 | 18 | 445 | 376 |
import itertools
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsが使える
# permutations(関数)にlistを渡すと、順列を生成!
l = [i for i in range(1, N + 1)]
permutations_l = list(itertools.permutations(l))
a, b = 0, 0
for i, R in enumerate(permutations_l):
if R == P:
a = i
for i, R in enumerate(permutations_l):
if R == Q:
b = i
print((abs(a - b)))
|
import itertools
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsで順列を生成できる!
l = [i for i in range(1, N + 1)]
permutations_l = list(itertools.permutations(l))
a, b = 0, 0
for i, R in enumerate(permutations_l):
if R == P:
a = i
if R == Q:
b = i
print((abs(a - b)))
| false | 10 |
[
"-# Pythonならitertoolsが使える",
"-# permutations(関数)にlistを渡すと、順列を生成!",
"+# Pythonならitertoolsで順列を生成できる!",
"-for i, R in enumerate(permutations_l):"
] | false | 0.0307 | 0.031732 | 0.967485 |
[
"s244114434",
"s465696203"
] |
u882832697
|
p02603
|
python
|
s017093033
|
s677013337
| 92 | 63 | 62,032 | 61,900 |
Accepted
|
Accepted
| 31.52 |
n = int(eval(input()))
a = list(map(int,input().split()))
m = 1000
stocks = 0
drops = [False]*(n-1)
for i in range(n-1):
if a[i] > a[i+1]:
drops[i] = True
for i in range(n-1):
if drops[i]:
m+=stocks*a[i]
stocks = 0
else:
stocks+=m//a[i]
m -= (m//a[i])*a[i]
print((m + stocks*a[-1]))
|
def main():
N=int(eval(input()))
A=list(map(int,input().split()))
ans=1000
stocks=0
for i in range(N-1):
if A[i]>A[i+1]:
ans+=stocks*A[i]
stocks=0
else:
stocks+=(ans//A[i])
ans-=(ans//A[i])*A[i]
print((ans+stocks*A[-1]))
if __name__=='__main__':
main()
| 16 | 15 | 341 | 350 |
n = int(eval(input()))
a = list(map(int, input().split()))
m = 1000
stocks = 0
drops = [False] * (n - 1)
for i in range(n - 1):
if a[i] > a[i + 1]:
drops[i] = True
for i in range(n - 1):
if drops[i]:
m += stocks * a[i]
stocks = 0
else:
stocks += m // a[i]
m -= (m // a[i]) * a[i]
print((m + stocks * a[-1]))
|
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 1000
stocks = 0
for i in range(N - 1):
if A[i] > A[i + 1]:
ans += stocks * A[i]
stocks = 0
else:
stocks += ans // A[i]
ans -= (ans // A[i]) * A[i]
print((ans + stocks * A[-1]))
if __name__ == "__main__":
main()
| false | 6.25 |
[
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-m = 1000",
"-stocks = 0",
"-drops = [False] * (n - 1)",
"-for i in range(n - 1):",
"- if a[i] > a[i + 1]:",
"- drops[i] = True",
"-for i in range(n - 1):",
"- if drops[i]:",
"- m += stocks * a[i]",
"- stocks = 0",
"- else:",
"- stocks += m // a[i]",
"- m -= (m // a[i]) * a[i]",
"-print((m + stocks * a[-1]))",
"+def main():",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ ans = 1000",
"+ stocks = 0",
"+ for i in range(N - 1):",
"+ if A[i] > A[i + 1]:",
"+ ans += stocks * A[i]",
"+ stocks = 0",
"+ else:",
"+ stocks += ans // A[i]",
"+ ans -= (ans // A[i]) * A[i]",
"+ print((ans + stocks * A[-1]))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.071756 | 0.03819 | 1.878911 |
[
"s017093033",
"s677013337"
] |
u864197622
|
p02736
|
python
|
s623088556
|
s721226170
| 595 | 33 | 87,536 | 6,748 |
Accepted
|
Accepted
| 94.45 |
def popcount_parity(x):
x ^= x >> 1
x ^= x >> 2
x ^= x >> 4
x ^= x >> 8
x ^= x >> 16
x ^= x >> 32
x ^= x >> 64
x ^= x >> 128
x ^= x >> 256
x ^= x >> 512
x ^= x >> 1024
x ^= x >> 2048
x ^= x >> 4096
x ^= x >> 8192
x ^= x >> 16384
x ^= x >> 32768
x ^= x >> 65536
x ^= x >> 131072
x ^= x >> 262144
x ^= x >> 524288
return x & 1
N = int(eval(input())) - 1
s = 1
while N:
l = N & -N
s *= 1 + (1 << l)
N ^= l
A = eval(input())
if "2" in A:
a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
print((popcount_parity(a & s)))
else:
a = int(A.replace("1", "0").replace("3", "1"), 2)
print((popcount_parity(a & s) * 2))
|
def popcount_parity(x):
x ^= x >> 1
x ^= x >> 2
x ^= x >> 4
x ^= x >> 8
x ^= x >> 16
x ^= x >> 32
x ^= x >> 64
x ^= x >> 128
x ^= x >> 256
x ^= x >> 512
x ^= x >> 1024
x ^= x >> 2048
x ^= x >> 4096
x ^= x >> 8192
x ^= x >> 16384
x ^= x >> 32768
x ^= x >> 65536
x ^= x >> 131072
x ^= x >> 262144
x ^= x >> 524288
return x & 1
N = int(eval(input())) - 1
s = 1
while N:
l = N & -N
s |= s << l
N ^= l
A = eval(input())
if "2" in A:
a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
print((popcount_parity(a & s)))
else:
a = int(A.replace("1", "0").replace("3", "1"), 2)
print((popcount_parity(a & s) * 2))
| 37 | 37 | 759 | 753 |
def popcount_parity(x):
x ^= x >> 1
x ^= x >> 2
x ^= x >> 4
x ^= x >> 8
x ^= x >> 16
x ^= x >> 32
x ^= x >> 64
x ^= x >> 128
x ^= x >> 256
x ^= x >> 512
x ^= x >> 1024
x ^= x >> 2048
x ^= x >> 4096
x ^= x >> 8192
x ^= x >> 16384
x ^= x >> 32768
x ^= x >> 65536
x ^= x >> 131072
x ^= x >> 262144
x ^= x >> 524288
return x & 1
N = int(eval(input())) - 1
s = 1
while N:
l = N & -N
s *= 1 + (1 << l)
N ^= l
A = eval(input())
if "2" in A:
a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
print((popcount_parity(a & s)))
else:
a = int(A.replace("1", "0").replace("3", "1"), 2)
print((popcount_parity(a & s) * 2))
|
def popcount_parity(x):
x ^= x >> 1
x ^= x >> 2
x ^= x >> 4
x ^= x >> 8
x ^= x >> 16
x ^= x >> 32
x ^= x >> 64
x ^= x >> 128
x ^= x >> 256
x ^= x >> 512
x ^= x >> 1024
x ^= x >> 2048
x ^= x >> 4096
x ^= x >> 8192
x ^= x >> 16384
x ^= x >> 32768
x ^= x >> 65536
x ^= x >> 131072
x ^= x >> 262144
x ^= x >> 524288
return x & 1
N = int(eval(input())) - 1
s = 1
while N:
l = N & -N
s |= s << l
N ^= l
A = eval(input())
if "2" in A:
a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
print((popcount_parity(a & s)))
else:
a = int(A.replace("1", "0").replace("3", "1"), 2)
print((popcount_parity(a & s) * 2))
| false | 0 |
[
"- s *= 1 + (1 << l)",
"+ s |= s << l"
] | false | 0.048217 | 0.035796 | 1.346968 |
[
"s623088556",
"s721226170"
] |
u754022296
|
p02924
|
python
|
s650243317
|
s332935432
| 20 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 15 |
a=int(eval(input()))
print((a*(a-1)//2))
|
a=int(eval(input()))
print((a*a-a>>1))
| 2 | 2 | 33 | 31 |
a = int(eval(input()))
print((a * (a - 1) // 2))
|
a = int(eval(input()))
print((a * a - a >> 1))
| false | 0 |
[
"-print((a * (a - 1) // 2))",
"+print((a * a - a >> 1))"
] | false | 0.062604 | 0.064378 | 0.972455 |
[
"s650243317",
"s332935432"
] |
u653837719
|
p02762
|
python
|
s075553915
|
s991231246
| 1,593 | 997 | 112,472 | 102,876 |
Accepted
|
Accepted
| 37.41 |
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
# sizeの大きいほうがx
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
def same(x, y):
return find(x) == find(y)
def size(x):
return -par[find(x)]
n, m, k = map(int, input().split())
par = [-1] * n
friend = [0] * n
for _ in range(m):
a, b = map(int, input().split())
union(a-1, b-1)
friend[a-1] += 1
friend[b-1] += 1
block = [[] for _ in range(n)]
for _ in range(k):
c, d = map(int, input().split())
block[c-1].append(d-1)
block[d-1].append(c-1)
for i in range(n):
ans = size(i) - friend[i] - 1
for j in block[i]:
if same(i, j):
ans -= 1
print(ans, end=' ')
|
import sys
input = sys.stdin.readline
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
# sizeの大きいほうがx
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
def same(x, y):
return find(x) == find(y)
def size(x):
return -par[find(x)]
n, m, k = map(int, input().split())
par = [-1] * n
friend = [0] * n
for _ in range(m):
a, b = map(int, input().split())
union(a-1, b-1)
friend[a-1] += 1
friend[b-1] += 1
block = [[] for _ in range(n)]
for _ in range(k):
c, d = map(int, input().split())
block[c-1].append(d-1)
block[d-1].append(c-1)
for i in range(n):
ans = size(i) - friend[i] - 1
for j in block[i]:
if same(i, j):
ans -= 1
print(ans, end=' ')
| 52 | 56 | 911 | 959 |
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
# sizeの大きいほうがx
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
def same(x, y):
return find(x) == find(y)
def size(x):
return -par[find(x)]
n, m, k = map(int, input().split())
par = [-1] * n
friend = [0] * n
for _ in range(m):
a, b = map(int, input().split())
union(a - 1, b - 1)
friend[a - 1] += 1
friend[b - 1] += 1
block = [[] for _ in range(n)]
for _ in range(k):
c, d = map(int, input().split())
block[c - 1].append(d - 1)
block[d - 1].append(c - 1)
for i in range(n):
ans = size(i) - friend[i] - 1
for j in block[i]:
if same(i, j):
ans -= 1
print(ans, end=" ")
|
import sys
input = sys.stdin.readline
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
# sizeの大きいほうがx
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
def same(x, y):
return find(x) == find(y)
def size(x):
return -par[find(x)]
n, m, k = map(int, input().split())
par = [-1] * n
friend = [0] * n
for _ in range(m):
a, b = map(int, input().split())
union(a - 1, b - 1)
friend[a - 1] += 1
friend[b - 1] += 1
block = [[] for _ in range(n)]
for _ in range(k):
c, d = map(int, input().split())
block[c - 1].append(d - 1)
block[d - 1].append(c - 1)
for i in range(n):
ans = size(i) - friend[i] - 1
for j in block[i]:
if same(i, j):
ans -= 1
print(ans, end=" ")
| false | 7.142857 |
[
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+"
] | false | 0.036727 | 0.036507 | 1.00603 |
[
"s075553915",
"s991231246"
] |
u334667251
|
p00523
|
python
|
s901602988
|
s562242933
| 1,150 | 800 | 20,948 | 21,052 |
Accepted
|
Accepted
| 30.43 |
def d(p, q):
return pos[p] - pos[q]
def solve():
p0, p1, p2 = 0, 0, 0
best = 1
while p0 < N:
if p1 <= p0: p1 = p0 + 1
while d(p1, p0) <= best and p1 - p0 < N:
p1 += 1
if d(p1, p0) <= best:
p0 += 1
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
continue
if p2 <= p1: p2 = p1 + 1
while d(p2,p1) < d(p1, p0) and p2 - p0 < N:
p2 += 1
if d(p2, p1) < d(p1, p0):
p0 += 1
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
continue
if L - d(p2, p0) >= d(p1, p0):
best = d(p1, p0)
if best >= L//3:
return best
else:
p0 += 1
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
return best
N = int(eval(input()))
A = [0] * N
L = 0
for i in range(N):
A[i] = int(eval(input()))
L += A[i]
pos = [0] * (2*N)
for i in range(1, 2*N):
pos[i] = pos[i-1] + A[(i-1)%N]
print((solve()))
|
def solve():
p0, p1, p2 = 0, 1, 2
best = 1
succ = True
while p0 < N-1:
if not succ:
p0 += 1
while d[p2]- d[p1] > d[p1]- d[p0]:
p2 -= 1
succ = False
while p1 - p0 < N - 1 and d[p1] - d[p0] <= best:
p1 += 1
d0 = d[p1] - d[p0]
if d0 <= best:
continue
while p2 - p0 < N and d[p2] - d[p1] < d0:
p2 += 1
if d[p2] - d[p1] < d0:
continue
if L - (d[p2] - d[p0]) >= d0:
best = d0
if best >= L//3:
return best
succ = True
return best
N = int(eval(input()))
A = [0] * N
L = 0
for i in range(N):
A[i] = int(eval(input()))
L += A[i]
d = [0] * (2*N)
for i in range(1, 2*N):
d[i] = d[i-1] + A[(i-1)%N]
print((solve()))
| 48 | 42 | 1,105 | 872 |
def d(p, q):
return pos[p] - pos[q]
def solve():
p0, p1, p2 = 0, 0, 0
best = 1
while p0 < N:
if p1 <= p0:
p1 = p0 + 1
while d(p1, p0) <= best and p1 - p0 < N:
p1 += 1
if d(p1, p0) <= best:
p0 += 1
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
continue
if p2 <= p1:
p2 = p1 + 1
while d(p2, p1) < d(p1, p0) and p2 - p0 < N:
p2 += 1
if d(p2, p1) < d(p1, p0):
p0 += 1
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
continue
if L - d(p2, p0) >= d(p1, p0):
best = d(p1, p0)
if best >= L // 3:
return best
else:
p0 += 1
while d(p2, p1) > d(p1, p0) and p2 > p1:
p2 -= 1
return best
N = int(eval(input()))
A = [0] * N
L = 0
for i in range(N):
A[i] = int(eval(input()))
L += A[i]
pos = [0] * (2 * N)
for i in range(1, 2 * N):
pos[i] = pos[i - 1] + A[(i - 1) % N]
print((solve()))
|
def solve():
p0, p1, p2 = 0, 1, 2
best = 1
succ = True
while p0 < N - 1:
if not succ:
p0 += 1
while d[p2] - d[p1] > d[p1] - d[p0]:
p2 -= 1
succ = False
while p1 - p0 < N - 1 and d[p1] - d[p0] <= best:
p1 += 1
d0 = d[p1] - d[p0]
if d0 <= best:
continue
while p2 - p0 < N and d[p2] - d[p1] < d0:
p2 += 1
if d[p2] - d[p1] < d0:
continue
if L - (d[p2] - d[p0]) >= d0:
best = d0
if best >= L // 3:
return best
succ = True
return best
N = int(eval(input()))
A = [0] * N
L = 0
for i in range(N):
A[i] = int(eval(input()))
L += A[i]
d = [0] * (2 * N)
for i in range(1, 2 * N):
d[i] = d[i - 1] + A[(i - 1) % N]
print((solve()))
| false | 12.5 |
[
"-def d(p, q):",
"- return pos[p] - pos[q]",
"-",
"-",
"- p0, p1, p2 = 0, 0, 0",
"+ p0, p1, p2 = 0, 1, 2",
"- while p0 < N:",
"- if p1 <= p0:",
"- p1 = p0 + 1",
"- while d(p1, p0) <= best and p1 - p0 < N:",
"+ succ = True",
"+ while p0 < N - 1:",
"+ if not succ:",
"+ p0 += 1",
"+ while d[p2] - d[p1] > d[p1] - d[p0]:",
"+ p2 -= 1",
"+ succ = False",
"+ while p1 - p0 < N - 1 and d[p1] - d[p0] <= best:",
"- if d(p1, p0) <= best:",
"- p0 += 1",
"- while d(p2, p1) > d(p1, p0) and p2 > p1:",
"- p2 -= 1",
"+ d0 = d[p1] - d[p0]",
"+ if d0 <= best:",
"- if p2 <= p1:",
"- p2 = p1 + 1",
"- while d(p2, p1) < d(p1, p0) and p2 - p0 < N:",
"+ while p2 - p0 < N and d[p2] - d[p1] < d0:",
"- if d(p2, p1) < d(p1, p0):",
"- p0 += 1",
"- while d(p2, p1) > d(p1, p0) and p2 > p1:",
"- p2 -= 1",
"+ if d[p2] - d[p1] < d0:",
"- if L - d(p2, p0) >= d(p1, p0):",
"- best = d(p1, p0)",
"+ if L - (d[p2] - d[p0]) >= d0:",
"+ best = d0",
"- else:",
"- p0 += 1",
"- while d(p2, p1) > d(p1, p0) and p2 > p1:",
"- p2 -= 1",
"+ succ = True",
"-pos = [0] * (2 * N)",
"+d = [0] * (2 * N)",
"- pos[i] = pos[i - 1] + A[(i - 1) % N]",
"+ d[i] = d[i - 1] + A[(i - 1) % N]"
] | false | 0.042715 | 0.100143 | 0.426539 |
[
"s901602988",
"s562242933"
] |
u021019433
|
p02918
|
python
|
s998930225
|
s214638602
| 33 | 29 | 3,316 | 3,316 |
Accepted
|
Accepted
| 12.12 |
from itertools import groupby
n, k = list(map(int, input().split()))
print((n - max(1, sum(map(bool, groupby(eval(input())))) - 2 * k)))
|
from itertools import groupby
n, k = list(map(int, input().split()))
print((n - max(1, sum(1 for _ in groupby(eval(input()))) - 2 * k)))
| 4 | 4 | 127 | 127 |
from itertools import groupby
n, k = list(map(int, input().split()))
print((n - max(1, sum(map(bool, groupby(eval(input())))) - 2 * k)))
|
from itertools import groupby
n, k = list(map(int, input().split()))
print((n - max(1, sum(1 for _ in groupby(eval(input()))) - 2 * k)))
| false | 0 |
[
"-print((n - max(1, sum(map(bool, groupby(eval(input())))) - 2 * k)))",
"+print((n - max(1, sum(1 for _ in groupby(eval(input()))) - 2 * k)))"
] | false | 0.070515 | 0.111162 | 0.634345 |
[
"s998930225",
"s214638602"
] |
u003475507
|
p02659
|
python
|
s844675584
|
s072608865
| 30 | 20 | 10,000 | 9,072 |
Accepted
|
Accepted
| 33.33 |
import math
import decimal
n,k =input().split()
a=decimal.Decimal(n) * decimal.Decimal(k)
print((math.floor(a)))
|
a,b = input().split()
a=int(a)
b=int(b.replace(".",""))
print((a*b//100))
| 8 | 4 | 120 | 75 |
import math
import decimal
n, k = input().split()
a = decimal.Decimal(n) * decimal.Decimal(k)
print((math.floor(a)))
|
a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
print((a * b // 100))
| false | 50 |
[
"-import math",
"-import decimal",
"-",
"-n, k = input().split()",
"-a = decimal.Decimal(n) * decimal.Decimal(k)",
"-print((math.floor(a)))",
"+a, b = input().split()",
"+a = int(a)",
"+b = int(b.replace(\".\", \"\"))",
"+print((a * b // 100))"
] | false | 0.051386 | 0.039211 | 1.310493 |
[
"s844675584",
"s072608865"
] |
u623819879
|
p02929
|
python
|
s027083890
|
s866579399
| 238 | 213 | 62,412 | 42,204 |
Accepted
|
Accepted
| 10.5 |
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
return input().split()
def MI():
return list(map(int,input().split()))
def I():
return int(eval(input()))
def LI():
return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
#mo=998244353
#input=sys.stdin.readline
n=I()
s=list(eval(input()))
ans=0
t=[]
l,r=0,0
for i in range(n*2):
if i==0:
t+=['L']
l+=1
continue
if ((l-r)%2==1 and s[i]=='W') or ((l-r)%2==0 and s[i]=='B'):
t+=['L']
l+=1
else:
t+=['R']
r+=1
if t.count('L')!=n:
print((0))
exit()
#print(s,t)
L,R=0,0
ans=1
for i in t:
if i=='L':
L+=1
if i=='R':
ans*=L-R
ans%=mo
R+=1
f=1
for i in range(2,n+1):
f*=i
f%=mo
print(((ans*f)%mo))
|
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
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 ItoS(nn):
return chr(nn+97)
def GI(V,E,Directed=False,index=0):
org_inp=[]
g=[[] for i in range(n)]
for i in range(E):
inp=LI()
org_inp.append(inp)
if index==0:
inp[0]-=1
inp[1]-=1
if len(inp)==2:
a,b=inp
g[a].append(b)
if not Directed:
g[b].append(a)
elif len(inp)==3:
a,b,c=inp
aa=(inp[0],inp[2])
bb=(inp[1],inp[2])
g[a].append(bb)
if not Directed:
g[b].append(aa)
return g,org_inp
def bit_combination(k,n=2):
rt=[]
for tb in range(n**k):
s=[tb//(n**bt)%n for bt in range(k)]
rt+=[s]
return rt
def show(*inp,end='\n'):
if show_flg:
print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
def ran_input():
import random
n=random.randint(4,16)
rmin,rmax=1,10
a=[random.randint(rmin,rmax) for _ in range(n)]
return n,a
show_flg=False
show_flg=True
ans=1
n=I()
s=input()
l,r=0,0
for i in range(n*2):
t=1 if s[i]=='B' else 0
if (l-r+t)%2==1:
l+=1
else:
ans*=(l-r)
ans%=mo
r+=1
if i>=n:
ans*=i-n+1
ans%=mo
if r-l!=0:
print(0)
else:
print(ans)
| 57 | 93 | 1,017 | 2,026 |
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
from itertools import permutations, groupby
import sys
import bisect
import string
alp = string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
return input().split()
def MI():
return list(map(int, input().split()))
def I():
return int(eval(input()))
def LI():
return [int(i) for i in input().split()]
YN = ["Yes", "No"]
mo = 10**9 + 7
# mo=998244353
# input=sys.stdin.readline
n = I()
s = list(eval(input()))
ans = 0
t = []
l, r = 0, 0
for i in range(n * 2):
if i == 0:
t += ["L"]
l += 1
continue
if ((l - r) % 2 == 1 and s[i] == "W") or ((l - r) % 2 == 0 and s[i] == "B"):
t += ["L"]
l += 1
else:
t += ["R"]
r += 1
if t.count("L") != n:
print((0))
exit()
# print(s,t)
L, R = 0, 0
ans = 1
for i in t:
if i == "L":
L += 1
if i == "R":
ans *= L - R
ans %= mo
R += 1
f = 1
for i in range(2, n + 1):
f *= i
f %= mo
print(((ans * f) % mo))
|
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, groupby
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 ItoS(nn):
return chr(nn + 97)
def GI(V, E, Directed=False, index=0):
org_inp = []
g = [[] for i in range(n)]
for i in range(E):
inp = LI()
org_inp.append(inp)
if index == 0:
inp[0] -= 1
inp[1] -= 1
if len(inp) == 2:
a, b = inp
g[a].append(b)
if not Directed:
g[b].append(a)
elif len(inp) == 3:
a, b, c = inp
aa = (inp[0], inp[2])
bb = (inp[1], inp[2])
g[a].append(bb)
if not Directed:
g[b].append(aa)
return g, org_inp
def bit_combination(k, n=2):
rt = []
for tb in range(n**k):
s = [tb // (n**bt) % n for bt in range(k)]
rt += [s]
return rt
def show(*inp, end="\n"):
if show_flg:
print(*inp, end=end)
YN = ["Yes", "No"]
mo = 10**9 + 7
inf = float("inf")
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**5)
input = lambda: sys.stdin.readline().rstrip()
def ran_input():
import random
n = random.randint(4, 16)
rmin, rmax = 1, 10
a = [random.randint(rmin, rmax) for _ in range(n)]
return n, a
show_flg = False
show_flg = True
ans = 1
n = I()
s = input()
l, r = 0, 0
for i in range(n * 2):
t = 1 if s[i] == "B" else 0
if (l - r + t) % 2 == 1:
l += 1
else:
ans *= l - r
ans %= mo
r += 1
if i >= n:
ans *= i - n + 1
ans %= mo
if r - l != 0:
print(0)
else:
print(ans)
| false | 38.709677 |
[
"-from heapq import heappush, heappop",
"+from heapq import heappush, heappop, heapify",
"-from itertools import permutations, groupby",
"+import itertools",
"+from itertools import permutations, combinations, groupby",
"-",
"-alp = string.ascii_lowercase",
"-sys.setrecursionlimit(10**6)",
"+import math",
"+import time",
"+import random",
"-def SI():",
"- return input().split()",
"+def I():",
"+ return int(input())",
"- return list(map(int, input().split()))",
"-",
"-",
"-def I():",
"- return int(eval(input()))",
"+ return map(int, input().split())",
"+def LI_():",
"+ return [int(i) - 1 for i in input().split()]",
"+",
"+",
"+def StoI():",
"+ return [ord(i) - 97 for i in input()]",
"+",
"+",
"+def ItoS(nn):",
"+ return chr(nn + 97)",
"+",
"+",
"+def GI(V, E, Directed=False, index=0):",
"+ org_inp = []",
"+ g = [[] for i in range(n)]",
"+ for i in range(E):",
"+ inp = LI()",
"+ org_inp.append(inp)",
"+ if index == 0:",
"+ inp[0] -= 1",
"+ inp[1] -= 1",
"+ if len(inp) == 2:",
"+ a, b = inp",
"+ g[a].append(b)",
"+ if not Directed:",
"+ g[b].append(a)",
"+ elif len(inp) == 3:",
"+ a, b, c = inp",
"+ aa = (inp[0], inp[2])",
"+ bb = (inp[1], inp[2])",
"+ g[a].append(bb)",
"+ if not Directed:",
"+ g[b].append(aa)",
"+ return g, org_inp",
"+",
"+",
"+def bit_combination(k, n=2):",
"+ rt = []",
"+ for tb in range(n**k):",
"+ s = [tb // (n**bt) % n for bt in range(k)]",
"+ rt += [s]",
"+ return rt",
"+",
"+",
"+def show(*inp, end=\"\\n\"):",
"+ if show_flg:",
"+ print(*inp, end=end)",
"+",
"+",
"-# mo=998244353",
"-# input=sys.stdin.readline",
"+inf = float(\"inf\")",
"+l_alp = string.ascii_lowercase",
"+u_alp = string.ascii_uppercase",
"+ts = time.time()",
"+# sys.setrecursionlimit(10**5)",
"+input = lambda: sys.stdin.readline().rstrip()",
"+",
"+",
"+def ran_input():",
"+ import random",
"+",
"+ n = random.randint(4, 16)",
"+ rmin, rmax = 1, 10",
"+ a = [random.randint(rmin, rmax) for _ in range(n)]",
"+ return n, a",
"+",
"+",
"+show_flg = False",
"+show_flg = True",
"+ans = 1",
"-s = list(eval(input()))",
"-ans = 0",
"-t = []",
"+s = input()",
"- if i == 0:",
"- t += [\"L\"]",
"- l += 1",
"- continue",
"- if ((l - r) % 2 == 1 and s[i] == \"W\") or ((l - r) % 2 == 0 and s[i] == \"B\"):",
"- t += [\"L\"]",
"+ t = 1 if s[i] == \"B\" else 0",
"+ if (l - r + t) % 2 == 1:",
"- t += [\"R\"]",
"+ ans *= l - r",
"+ ans %= mo",
"-if t.count(\"L\") != n:",
"- print((0))",
"- exit()",
"-# print(s,t)",
"-L, R = 0, 0",
"-ans = 1",
"-for i in t:",
"- if i == \"L\":",
"- L += 1",
"- if i == \"R\":",
"- ans *= L - R",
"+ if i >= n:",
"+ ans *= i - n + 1",
"- R += 1",
"-f = 1",
"-for i in range(2, n + 1):",
"- f *= i",
"- f %= mo",
"-print(((ans * f) % mo))",
"+if r - l != 0:",
"+ print(0)",
"+else:",
"+ print(ans)"
] | false | 0.043532 | 0.043219 | 1.007232 |
[
"s027083890",
"s866579399"
] |
u098223184
|
p03775
|
python
|
s675678227
|
s279287622
| 42 | 38 | 9,144 | 9,092 |
Accepted
|
Accepted
| 9.52 |
import math
n=int(eval(input()))
ans=10
for i in range(1,int(math.sqrt(n))+1):
if n%i==0:
b=int(n/i)
f=max(len(str(i)),len(str(b)))
ans=min(f,ans)
print(ans)
|
import math
n=int(eval(input()))
ans=100
for a in range(1,int(math.sqrt(n))+1):
if n%a==0:
m=max(len(str(a)),len(str(n//a)))
ans=min(ans,m)
print(ans)
| 9 | 8 | 187 | 171 |
import math
n = int(eval(input()))
ans = 10
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0:
b = int(n / i)
f = max(len(str(i)), len(str(b)))
ans = min(f, ans)
print(ans)
|
import math
n = int(eval(input()))
ans = 100
for a in range(1, int(math.sqrt(n)) + 1):
if n % a == 0:
m = max(len(str(a)), len(str(n // a)))
ans = min(ans, m)
print(ans)
| false | 11.111111 |
[
"-ans = 10",
"-for i in range(1, int(math.sqrt(n)) + 1):",
"- if n % i == 0:",
"- b = int(n / i)",
"- f = max(len(str(i)), len(str(b)))",
"- ans = min(f, ans)",
"+ans = 100",
"+for a in range(1, int(math.sqrt(n)) + 1):",
"+ if n % a == 0:",
"+ m = max(len(str(a)), len(str(n // a)))",
"+ ans = min(ans, m)"
] | false | 0.117719 | 0.04576 | 2.572542 |
[
"s675678227",
"s279287622"
] |
u987170100
|
p02725
|
python
|
s934697878
|
s913200068
| 185 | 145 | 26,444 | 24,908 |
Accepted
|
Accepted
| 21.62 |
K, N = list(map(int, input().split()))
lst = [int(x) for x in input().split()]
a = lst[0]
m = 0
for i in range(N - 1):
m = max(m, (lst[i + 1] - a) - (lst[i] - a))
print((K - max(m, K - (lst[-1] - a))))
|
K, N = list(map(int, input().split()))
lst = [int(x) for x in input().split()]
m = K - lst[-1] + lst[0]
for i in range(N - 1):
m = max(m, lst[i + 1] - lst[i])
print((K - m))
| 8 | 7 | 206 | 176 |
K, N = list(map(int, input().split()))
lst = [int(x) for x in input().split()]
a = lst[0]
m = 0
for i in range(N - 1):
m = max(m, (lst[i + 1] - a) - (lst[i] - a))
print((K - max(m, K - (lst[-1] - a))))
|
K, N = list(map(int, input().split()))
lst = [int(x) for x in input().split()]
m = K - lst[-1] + lst[0]
for i in range(N - 1):
m = max(m, lst[i + 1] - lst[i])
print((K - m))
| false | 12.5 |
[
"-a = lst[0]",
"-m = 0",
"+m = K - lst[-1] + lst[0]",
"- m = max(m, (lst[i + 1] - a) - (lst[i] - a))",
"-print((K - max(m, K - (lst[-1] - a))))",
"+ m = max(m, lst[i + 1] - lst[i])",
"+print((K - m))"
] | false | 0.037927 | 0.048045 | 0.789423 |
[
"s934697878",
"s913200068"
] |
u647766105
|
p00693
|
python
|
s617465576
|
s059358499
| 990 | 700 | 4,432 | 5,268 |
Accepted
|
Accepted
| 29.29 |
while True:
N, M = list(map(int, input().split()))
if (N, M) == (0, 0):
break
rules = []
for _ in range(N):
f, p1, p2 = input().split()
rules += [(f, p1+p2)]
rules = rules[::-1]
def check(s):
def match(pattern, address):
for p, a in zip(pattern, address):
if p == "?":
continue
if p != a:
return False
return True
a1, a2, _ = s.split()
for flag, pattern in rules:
if flag == "permit" and match(pattern, a1+a2):
return True
if flag == "deny" and match(pattern, a1+a2):
return False
ans = list(filter(check, [input() for _ in range(M)]))
print(len(ans))
if len(ans) != 0:
print("\n".join(ans))
|
import re
while True:
N, M = list(map(int, input().split()))
if (N, M) == (0, 0):
break
rules = []
for _ in range(N):
f, p1, p2 = input().replace("?", "\d").split()
rules += [(f, re.compile(p1+p2))]
rules = rules[::-1]
def check(s):
a1, a2, _ = s.split()
a = a1 + a2
for f, r in rules:
if f == "permit" and r.match(a):
return True
if f == "deny" and r.match(a):
return False
ans = list(filter(check, [input() for _ in range(M)]))
print(len(ans))
if len(ans) != 0:
print("\n".join(ans))
| 27 | 22 | 861 | 662 |
while True:
N, M = list(map(int, input().split()))
if (N, M) == (0, 0):
break
rules = []
for _ in range(N):
f, p1, p2 = input().split()
rules += [(f, p1 + p2)]
rules = rules[::-1]
def check(s):
def match(pattern, address):
for p, a in zip(pattern, address):
if p == "?":
continue
if p != a:
return False
return True
a1, a2, _ = s.split()
for flag, pattern in rules:
if flag == "permit" and match(pattern, a1 + a2):
return True
if flag == "deny" and match(pattern, a1 + a2):
return False
ans = list(filter(check, [input() for _ in range(M)]))
print(len(ans))
if len(ans) != 0:
print("\n".join(ans))
|
import re
while True:
N, M = list(map(int, input().split()))
if (N, M) == (0, 0):
break
rules = []
for _ in range(N):
f, p1, p2 = input().replace("?", "\d").split()
rules += [(f, re.compile(p1 + p2))]
rules = rules[::-1]
def check(s):
a1, a2, _ = s.split()
a = a1 + a2
for f, r in rules:
if f == "permit" and r.match(a):
return True
if f == "deny" and r.match(a):
return False
ans = list(filter(check, [input() for _ in range(M)]))
print(len(ans))
if len(ans) != 0:
print("\n".join(ans))
| false | 18.518519 |
[
"+import re",
"+",
"- f, p1, p2 = input().split()",
"- rules += [(f, p1 + p2)]",
"+ f, p1, p2 = input().replace(\"?\", \"\\d\").split()",
"+ rules += [(f, re.compile(p1 + p2))]",
"- def match(pattern, address):",
"- for p, a in zip(pattern, address):",
"- if p == \"?\":",
"- continue",
"- if p != a:",
"- return False",
"- return True",
"-",
"- for flag, pattern in rules:",
"- if flag == \"permit\" and match(pattern, a1 + a2):",
"+ a = a1 + a2",
"+ for f, r in rules:",
"+ if f == \"permit\" and r.match(a):",
"- if flag == \"deny\" and match(pattern, a1 + a2):",
"+ if f == \"deny\" and r.match(a):"
] | false | 0.082319 | 0.04312 | 1.909073 |
[
"s617465576",
"s059358499"
] |
u517797706
|
p02596
|
python
|
s876135236
|
s146160318
| 505 | 177 | 77,904 | 9,092 |
Accepted
|
Accepted
| 64.95 |
if __name__ == '__main__':
k = int(eval(input()))
# mod K 問題
s = set()
x = 7 % k
i = 1
cnt = -1
while x not in s:
if x == 0:
cnt = i
break
s.add(x)
x = (10 * x + 7) % k
i += 1
print(cnt)
|
if __name__ == '__main__':
k = int(eval(input()))
x = 0
for i in range(10**6):
x = (10 * x + 7) % k
if x == 0:
print((i+1))
exit()
print((-1))
| 20 | 10 | 227 | 157 |
if __name__ == "__main__":
k = int(eval(input()))
# mod K 問題
s = set()
x = 7 % k
i = 1
cnt = -1
while x not in s:
if x == 0:
cnt = i
break
s.add(x)
x = (10 * x + 7) % k
i += 1
print(cnt)
|
if __name__ == "__main__":
k = int(eval(input()))
x = 0
for i in range(10**6):
x = (10 * x + 7) % k
if x == 0:
print((i + 1))
exit()
print((-1))
| false | 50 |
[
"- # mod K 問題",
"- s = set()",
"- x = 7 % k",
"- i = 1",
"- cnt = -1",
"- while x not in s:",
"+ x = 0",
"+ for i in range(10**6):",
"+ x = (10 * x + 7) % k",
"- cnt = i",
"- break",
"- s.add(x)",
"- x = (10 * x + 7) % k",
"- i += 1",
"- print(cnt)",
"+ print((i + 1))",
"+ exit()",
"+ print((-1))"
] | false | 0.220515 | 0.092328 | 2.388382 |
[
"s876135236",
"s146160318"
] |
u047796752
|
p03575
|
python
|
s770111076
|
s825609140
| 212 | 190 | 42,588 | 39,792 |
Accepted
|
Accepted
| 10.38 |
class Unionfind:
def __init__(self, n):
self.par = [-1]*n
self.rank = [1]*n
def root(self, x):
p = x
while not self.par[p]<0:
p = self.par[p]
while x!=p:
tmp = x
x = self.par[x]
self.par[tmp] = p
return p
def unite(self, x, y):
rx, ry = self.root(x), self.root(y)
if rx==ry: return False
if self.rank[rx]<self.rank[ry]:
rx, ry = ry, rx
self.par[rx] += self.par[ry]
self.par[ry] = rx
if self.rank[rx]==self.rank[ry]:
self.rank[rx] += 1
def is_same(self, x, y):
return self.root(x)==self.root(y)
def count(self, x):
return -self.par[self.root(x)]
N, M = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(M):
uf = Unionfind(N)
for j in range(M):
if j==i:
continue
a, b = ab[j][0], ab[j][1]
uf.unite(a-1, b-1)
if uf.count(0)!=N:
ans += 1
print(ans)
|
from collections import *
def bfs():
q = deque([0])
visited = [False]*N
visited[0] = True
while q:
v = q.popleft()
for nv in range(N):
if G[v][nv]==1:
if not visited[nv]:
visited[nv] = True
q.append(nv)
return False in visited
N, M = list(map(int, input().split()))
G = [[0]*N for _ in range(N)]
edges = []
for _ in range(M):
a, b = list(map(int, input().split()))
G[a-1][b-1] = 1
G[b-1][a-1] = 1
edges.append((a-1, b-1))
ans = 0
for a, b in edges:
G[a][b] = 0
G[b][a] = 0
if bfs():
ans += 1
G[a][b] = 1
G[b][a] = 1
print(ans)
| 56 | 41 | 1,217 | 741 |
class Unionfind:
def __init__(self, n):
self.par = [-1] * n
self.rank = [1] * n
def root(self, x):
p = x
while not self.par[p] < 0:
p = self.par[p]
while x != p:
tmp = x
x = self.par[x]
self.par[tmp] = p
return p
def unite(self, x, y):
rx, ry = self.root(x), self.root(y)
if rx == ry:
return False
if self.rank[rx] < self.rank[ry]:
rx, ry = ry, rx
self.par[rx] += self.par[ry]
self.par[ry] = rx
if self.rank[rx] == self.rank[ry]:
self.rank[rx] += 1
def is_same(self, x, y):
return self.root(x) == self.root(y)
def count(self, x):
return -self.par[self.root(x)]
N, M = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(M):
uf = Unionfind(N)
for j in range(M):
if j == i:
continue
a, b = ab[j][0], ab[j][1]
uf.unite(a - 1, b - 1)
if uf.count(0) != N:
ans += 1
print(ans)
|
from collections import *
def bfs():
q = deque([0])
visited = [False] * N
visited[0] = True
while q:
v = q.popleft()
for nv in range(N):
if G[v][nv] == 1:
if not visited[nv]:
visited[nv] = True
q.append(nv)
return False in visited
N, M = list(map(int, input().split()))
G = [[0] * N for _ in range(N)]
edges = []
for _ in range(M):
a, b = list(map(int, input().split()))
G[a - 1][b - 1] = 1
G[b - 1][a - 1] = 1
edges.append((a - 1, b - 1))
ans = 0
for a, b in edges:
G[a][b] = 0
G[b][a] = 0
if bfs():
ans += 1
G[a][b] = 1
G[b][a] = 1
print(ans)
| false | 26.785714 |
[
"-class Unionfind:",
"- def __init__(self, n):",
"- self.par = [-1] * n",
"- self.rank = [1] * n",
"+from collections import *",
"- def root(self, x):",
"- p = x",
"- while not self.par[p] < 0:",
"- p = self.par[p]",
"- while x != p:",
"- tmp = x",
"- x = self.par[x]",
"- self.par[tmp] = p",
"- return p",
"- def unite(self, x, y):",
"- rx, ry = self.root(x), self.root(y)",
"- if rx == ry:",
"- return False",
"- if self.rank[rx] < self.rank[ry]:",
"- rx, ry = ry, rx",
"- self.par[rx] += self.par[ry]",
"- self.par[ry] = rx",
"- if self.rank[rx] == self.rank[ry]:",
"- self.rank[rx] += 1",
"-",
"- def is_same(self, x, y):",
"- return self.root(x) == self.root(y)",
"-",
"- def count(self, x):",
"- return -self.par[self.root(x)]",
"+def bfs():",
"+ q = deque([0])",
"+ visited = [False] * N",
"+ visited[0] = True",
"+ while q:",
"+ v = q.popleft()",
"+ for nv in range(N):",
"+ if G[v][nv] == 1:",
"+ if not visited[nv]:",
"+ visited[nv] = True",
"+ q.append(nv)",
"+ return False in visited",
"-ab = [tuple(map(int, input().split())) for _ in range(M)]",
"+G = [[0] * N for _ in range(N)]",
"+edges = []",
"+for _ in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ G[a - 1][b - 1] = 1",
"+ G[b - 1][a - 1] = 1",
"+ edges.append((a - 1, b - 1))",
"-for i in range(M):",
"- uf = Unionfind(N)",
"- for j in range(M):",
"- if j == i:",
"- continue",
"- a, b = ab[j][0], ab[j][1]",
"- uf.unite(a - 1, b - 1)",
"- if uf.count(0) != N:",
"+for a, b in edges:",
"+ G[a][b] = 0",
"+ G[b][a] = 0",
"+ if bfs():",
"+ G[a][b] = 1",
"+ G[b][a] = 1"
] | false | 0.045084 | 0.08252 | 0.546333 |
[
"s770111076",
"s825609140"
] |
u562016607
|
p03098
|
python
|
s023823663
|
s382070621
| 851 | 768 | 42,684 | 41,144 |
Accepted
|
Accepted
| 9.75 |
N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]
def I(s):
r=[0]*N
for i in range(N):r[s[i]]=i
return r
def T(s,t):return [s[t[i]] for i in range(N)]
m=[[0 for i in [0]*N] for i in [0]*6]
for i in range(N):m[0][i]=p[i];m[1][i]=q[i]
for i in range(4):m[i+2]=T(m[i+1],I(m[i]))
def E(s,k):
if k%2==0:
return E(T(s,s),k//2) if k!=0 else list(range(N))
else:
return T(E(T(s,s),k//2),s)
t=E(T(T(T(q,I(p)),I(q)),p),~-K//6);print((" ".join([str(i+1) for i in T(T(t,m[~-K%6]),I(t))])))
|
N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()];T=lambda s,t:[s[t[i]] for i in range(N)];m=[[0 for i in [0]*N] for i in [0]*6];m[0]=p;m[1]=q
def I(s):
r=[0]*N
for i in range(N):r[s[i]]=i
return r
for i in range(4):m[i+2]=T(m[i+1],I(m[i]))
E=lambda s,k:(E(T(s,s),k//2) if k!=0 else list(range(N)))if k%2==0 else T(E(T(s,s),k//2),s);t=E(T(T(T(q,I(p)),I(q)),p),~-K//6);print((" ".join([str(i+1) for i in T(T(t,m[~-K%6]),I(t))])))
| 15 | 7 | 553 | 490 |
N, K = list(map(int, input().split()))
p = [int(i) - 1 for i in input().split()]
q = [int(i) - 1 for i in input().split()]
def I(s):
r = [0] * N
for i in range(N):
r[s[i]] = i
return r
def T(s, t):
return [s[t[i]] for i in range(N)]
m = [[0 for i in [0] * N] for i in [0] * 6]
for i in range(N):
m[0][i] = p[i]
m[1][i] = q[i]
for i in range(4):
m[i + 2] = T(m[i + 1], I(m[i]))
def E(s, k):
if k % 2 == 0:
return E(T(s, s), k // 2) if k != 0 else list(range(N))
else:
return T(E(T(s, s), k // 2), s)
t = E(T(T(T(q, I(p)), I(q)), p), ~-K // 6)
print((" ".join([str(i + 1) for i in T(T(t, m[~-K % 6]), I(t))])))
|
N, K = list(map(int, input().split()))
p = [int(i) - 1 for i in input().split()]
q = [int(i) - 1 for i in input().split()]
T = lambda s, t: [s[t[i]] for i in range(N)]
m = [[0 for i in [0] * N] for i in [0] * 6]
m[0] = p
m[1] = q
def I(s):
r = [0] * N
for i in range(N):
r[s[i]] = i
return r
for i in range(4):
m[i + 2] = T(m[i + 1], I(m[i]))
E = (
lambda s, k: (E(T(s, s), k // 2) if k != 0 else list(range(N)))
if k % 2 == 0
else T(E(T(s, s), k // 2), s)
)
t = E(T(T(T(q, I(p)), I(q)), p), ~-K // 6)
print((" ".join([str(i + 1) for i in T(T(t, m[~-K % 6]), I(t))])))
| false | 53.333333 |
[
"+T = lambda s, t: [s[t[i]] for i in range(N)]",
"+m = [[0 for i in [0] * N] for i in [0] * 6]",
"+m[0] = p",
"+m[1] = q",
"-def T(s, t):",
"- return [s[t[i]] for i in range(N)]",
"-",
"-",
"-m = [[0 for i in [0] * N] for i in [0] * 6]",
"-for i in range(N):",
"- m[0][i] = p[i]",
"- m[1][i] = q[i]",
"-",
"-",
"-def E(s, k):",
"- if k % 2 == 0:",
"- return E(T(s, s), k // 2) if k != 0 else list(range(N))",
"- else:",
"- return T(E(T(s, s), k // 2), s)",
"-",
"-",
"+E = (",
"+ lambda s, k: (E(T(s, s), k // 2) if k != 0 else list(range(N)))",
"+ if k % 2 == 0",
"+ else T(E(T(s, s), k // 2), s)",
"+)"
] | false | 0.043077 | 0.03965 | 1.086417 |
[
"s023823663",
"s382070621"
] |
u039623862
|
p03556
|
python
|
s540156699
|
s290008372
| 28 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 39.29 |
n = int(eval(input()))
for i in range(n+1):
if (i+1)**2 > n:
print((i**2))
exit()
|
n = int(eval(input()))
l = 0
r = n + 1
while l + 1 < r:
m = l + (r - l) // 2
if m**2 > n:
r = m
else:
l = m
print((l**2))
| 5 | 11 | 97 | 153 |
n = int(eval(input()))
for i in range(n + 1):
if (i + 1) ** 2 > n:
print((i**2))
exit()
|
n = int(eval(input()))
l = 0
r = n + 1
while l + 1 < r:
m = l + (r - l) // 2
if m**2 > n:
r = m
else:
l = m
print((l**2))
| false | 54.545455 |
[
"-for i in range(n + 1):",
"- if (i + 1) ** 2 > n:",
"- print((i**2))",
"- exit()",
"+l = 0",
"+r = n + 1",
"+while l + 1 < r:",
"+ m = l + (r - l) // 2",
"+ if m**2 > n:",
"+ r = m",
"+ else:",
"+ l = m",
"+print((l**2))"
] | false | 0.064056 | 0.077696 | 0.824444 |
[
"s540156699",
"s290008372"
] |
u832039789
|
p03260
|
python
|
s326173447
|
s504092045
| 19 | 17 | 3,316 | 2,940 |
Accepted
|
Accepted
| 10.53 |
a,b = list(map(int,input().split()))
for c in range(1,4):
if a*b*c%2==1:
print('Yes')
exit()
print('No')
|
if 2 in list(map(int,input().split())):
print('No')
else:
print('Yes')
| 6 | 4 | 123 | 82 |
a, b = list(map(int, input().split()))
for c in range(1, 4):
if a * b * c % 2 == 1:
print("Yes")
exit()
print("No")
|
if 2 in list(map(int, input().split())):
print("No")
else:
print("Yes")
| false | 33.333333 |
[
"-a, b = list(map(int, input().split()))",
"-for c in range(1, 4):",
"- if a * b * c % 2 == 1:",
"- print(\"Yes\")",
"- exit()",
"-print(\"No\")",
"+if 2 in list(map(int, input().split())):",
"+ print(\"No\")",
"+else:",
"+ print(\"Yes\")"
] | false | 0.047917 | 0.047681 | 1.004954 |
[
"s326173447",
"s504092045"
] |
u476604182
|
p03297
|
python
|
s864149604
|
s332397904
| 46 | 37 | 5,432 | 5,212 |
Accepted
|
Accepted
| 19.57 |
from fractions import gcd
T,*L = list(map(int, open(0).read().split()))
for a,b,c,d in zip(*[iter(L)]*4):
if b>d:
print('No')
continue
if a<b:
print('No')
continue
if c>b:
print('Yes')
continue
g = gcd(b,d)
x = a-b
M = ((c-x)//g+1)*g+x
if M>=b:
print('Yes')
else:
print('No')
|
from fractions import gcd
T,*L = list(map(int, open(0).read().split()))
for a,b,c,d in zip(*[iter(L)]*4):
if b>d:
print('No')
continue
if a<b:
print('No')
continue
g = gcd(b,d)
x = a-b
M = ((c-x)//g+1)*g+x
if M>=b:
print('Yes')
else:
print('No')
| 19 | 16 | 336 | 292 |
from fractions import gcd
T, *L = list(map(int, open(0).read().split()))
for a, b, c, d in zip(*[iter(L)] * 4):
if b > d:
print("No")
continue
if a < b:
print("No")
continue
if c > b:
print("Yes")
continue
g = gcd(b, d)
x = a - b
M = ((c - x) // g + 1) * g + x
if M >= b:
print("Yes")
else:
print("No")
|
from fractions import gcd
T, *L = list(map(int, open(0).read().split()))
for a, b, c, d in zip(*[iter(L)] * 4):
if b > d:
print("No")
continue
if a < b:
print("No")
continue
g = gcd(b, d)
x = a - b
M = ((c - x) // g + 1) * g + x
if M >= b:
print("Yes")
else:
print("No")
| false | 15.789474 |
[
"- if c > b:",
"- print(\"Yes\")",
"- continue"
] | false | 0.079827 | 0.119836 | 0.666132 |
[
"s864149604",
"s332397904"
] |
u968166680
|
p02819
|
python
|
s411466516
|
s827251908
| 142 | 69 | 80,472 | 63,280 |
Accepted
|
Accepted
| 51.41 |
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def prime_numbers(n):
if n < 2:
return []
m = (n + 1) // 2
p = [1] * m
for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
if p[i]:
p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)
a = [2 * i + 1 for i in range(m) if p[i]]
a[0] = 2
return a
def main():
X = int(readline())
P = prime_numbers(10 ** 6)
ans = P[bisect_left(P, X)]
print(ans)
return
if __name__ == '__main__':
main()
|
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def is_prime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def main():
X = int(readline())
while not is_prime(X):
X += 1
print(X)
return
if __name__ == '__main__':
main()
| 38 | 32 | 731 | 527 |
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def prime_numbers(n):
if n < 2:
return []
m = (n + 1) // 2
p = [1] * m
for i in range(1, int((n**0.5 - 1) / 2) + 1):
if p[i]:
p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (
((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1
)
a = [2 * i + 1 for i in range(m) if p[i]]
a[0] = 2
return a
def main():
X = int(readline())
P = prime_numbers(10**6)
ans = P[bisect_left(P, X)]
print(ans)
return
if __name__ == "__main__":
main()
|
import sys
from bisect import bisect_left
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def is_prime(n):
if n == 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def main():
X = int(readline())
while not is_prime(X):
X += 1
print(X)
return
if __name__ == "__main__":
main()
| false | 15.789474 |
[
"-def prime_numbers(n):",
"- if n < 2:",
"- return []",
"- m = (n + 1) // 2",
"- p = [1] * m",
"- for i in range(1, int((n**0.5 - 1) / 2) + 1):",
"- if p[i]:",
"- p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (",
"- ((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1",
"- )",
"- a = [2 * i + 1 for i in range(m) if p[i]]",
"- a[0] = 2",
"- return a",
"+def is_prime(n):",
"+ if n == 1:",
"+ return False",
"+ for i in range(2, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ return False",
"+ return True",
"- P = prime_numbers(10**6)",
"- ans = P[bisect_left(P, X)]",
"- print(ans)",
"+ while not is_prime(X):",
"+ X += 1",
"+ print(X)"
] | false | 0.156793 | 0.124223 | 1.262195 |
[
"s411466516",
"s827251908"
] |
u280984565
|
p03137
|
python
|
s792477127
|
s008165976
| 331 | 228 | 62,760 | 57,384 |
Accepted
|
Accepted
| 31.12 |
M, N = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
Y = []
for i in range(N - 1):
Y.append((i, X[i + 1] - X[i]))
Y.sort(key=lambda y: y[1], reverse=True)
Y = Y[:M - 1]
Y.sort(key=lambda y: y[0])
p = 0
c = 0
for i, y in Y:
c += X[i] - X[p]
p = i + 1
c += X[-1] - X[p]
print(c)
|
M, N = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
Y = []
for i in range(N - 1):
Y.append(X[i + 1] - X[i])
Y.sort()
if M < N:
c = X[-1] - X[0] - sum(Y[N - M:])
else:
c = 0
print(c)
| 21 | 18 | 339 | 243 |
M, N = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
Y = []
for i in range(N - 1):
Y.append((i, X[i + 1] - X[i]))
Y.sort(key=lambda y: y[1], reverse=True)
Y = Y[: M - 1]
Y.sort(key=lambda y: y[0])
p = 0
c = 0
for i, y in Y:
c += X[i] - X[p]
p = i + 1
c += X[-1] - X[p]
print(c)
|
M, N = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
Y = []
for i in range(N - 1):
Y.append(X[i + 1] - X[i])
Y.sort()
if M < N:
c = X[-1] - X[0] - sum(Y[N - M :])
else:
c = 0
print(c)
| false | 14.285714 |
[
"- Y.append((i, X[i + 1] - X[i]))",
"-Y.sort(key=lambda y: y[1], reverse=True)",
"-Y = Y[: M - 1]",
"-Y.sort(key=lambda y: y[0])",
"-p = 0",
"-c = 0",
"-for i, y in Y:",
"- c += X[i] - X[p]",
"- p = i + 1",
"-c += X[-1] - X[p]",
"+ Y.append(X[i + 1] - X[i])",
"+Y.sort()",
"+if M < N:",
"+ c = X[-1] - X[0] - sum(Y[N - M :])",
"+else:",
"+ c = 0"
] | false | 0.038006 | 0.043986 | 0.864049 |
[
"s792477127",
"s008165976"
] |
u562935282
|
p03241
|
python
|
s464453324
|
s061176138
| 32 | 26 | 3,060 | 3,060 |
Accepted
|
Accepted
| 18.75 |
n, m = list(map(int, input().split()))
lstDiv = []
k = 1
while k * k <= m:
div, r = divmod(m, k)
if r == 0:
lstDiv.append(k)
lstDiv.append(div)
k += 1
lstDiv = sorted(lstDiv, reverse=True)
for div in lstDiv:
if div * n <= m:
print(div)
break
|
from bisect import bisect_left
n, m = list(map(int, input().split()))
st = set()
i = 1
while i * i <= m:
if m % i == 0:
st.add(i)
st.add(m // i)
i += 1
divs = tuple(sorted(st))
i = bisect_left(divs, n)
print((m // divs[i]))
| 17 | 15 | 302 | 257 |
n, m = list(map(int, input().split()))
lstDiv = []
k = 1
while k * k <= m:
div, r = divmod(m, k)
if r == 0:
lstDiv.append(k)
lstDiv.append(div)
k += 1
lstDiv = sorted(lstDiv, reverse=True)
for div in lstDiv:
if div * n <= m:
print(div)
break
|
from bisect import bisect_left
n, m = list(map(int, input().split()))
st = set()
i = 1
while i * i <= m:
if m % i == 0:
st.add(i)
st.add(m // i)
i += 1
divs = tuple(sorted(st))
i = bisect_left(divs, n)
print((m // divs[i]))
| false | 11.764706 |
[
"+from bisect import bisect_left",
"+",
"-lstDiv = []",
"-k = 1",
"-while k * k <= m:",
"- div, r = divmod(m, k)",
"- if r == 0:",
"- lstDiv.append(k)",
"- lstDiv.append(div)",
"- k += 1",
"-lstDiv = sorted(lstDiv, reverse=True)",
"-for div in lstDiv:",
"- if div * n <= m:",
"- print(div)",
"- break",
"+st = set()",
"+i = 1",
"+while i * i <= m:",
"+ if m % i == 0:",
"+ st.add(i)",
"+ st.add(m // i)",
"+ i += 1",
"+divs = tuple(sorted(st))",
"+i = bisect_left(divs, n)",
"+print((m // divs[i]))"
] | false | 0.042464 | 0.062436 | 0.680118 |
[
"s464453324",
"s061176138"
] |
u968404618
|
p03474
|
python
|
s043641793
|
s261187734
| 30 | 27 | 9,024 | 9,176 |
Accepted
|
Accepted
| 10 |
a, b = list(map(int, input().split()))
S = eval(input())
if "-" in S[:a] or "-" in S[a+1:]:
print("No")
elif "-" == S[a]:
print("Yes")
else:
print("No")
|
a, b = list(map(int, input().split()))
S = eval(input())
for i in range(len(S)):
if (i == a and S[i] != "-") or (i != a and S[i] =="-"):
print("No")
exit()
print("Yes")
| 9 | 8 | 163 | 174 |
a, b = list(map(int, input().split()))
S = eval(input())
if "-" in S[:a] or "-" in S[a + 1 :]:
print("No")
elif "-" == S[a]:
print("Yes")
else:
print("No")
|
a, b = list(map(int, input().split()))
S = eval(input())
for i in range(len(S)):
if (i == a and S[i] != "-") or (i != a and S[i] == "-"):
print("No")
exit()
print("Yes")
| false | 11.111111 |
[
"-if \"-\" in S[:a] or \"-\" in S[a + 1 :]:",
"- print(\"No\")",
"-elif \"-\" == S[a]:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+for i in range(len(S)):",
"+ if (i == a and S[i] != \"-\") or (i != a and S[i] == \"-\"):",
"+ print(\"No\")",
"+ exit()",
"+print(\"Yes\")"
] | false | 0.136314 | 0.26622 | 0.512035 |
[
"s043641793",
"s261187734"
] |
u761320129
|
p03140
|
python
|
s521717418
|
s820611594
| 22 | 17 | 3,316 | 3,060 |
Accepted
|
Accepted
| 22.73 |
N = int(eval(input()))
A,B,C = eval(input()),eval(input()),eval(input())
ans = 0
for a,b,c in zip(A,B,C):
if a != b and b != c and c != a:
ans += 2
elif a == b == c:
ans += 0
else:
ans += 1
print(ans)
|
N = int(eval(input()))
A = eval(input())
B = eval(input())
C = eval(input())
ans = 0
for a,b,c in zip(A,B,C):
if a==b==c: continue
if a==b or b==c or c==a:
ans += 1
else:
ans += 2
print(ans)
| 11 | 12 | 222 | 205 |
N = int(eval(input()))
A, B, C = eval(input()), eval(input()), eval(input())
ans = 0
for a, b, c in zip(A, B, C):
if a != b and b != c and c != a:
ans += 2
elif a == b == c:
ans += 0
else:
ans += 1
print(ans)
|
N = int(eval(input()))
A = eval(input())
B = eval(input())
C = eval(input())
ans = 0
for a, b, c in zip(A, B, C):
if a == b == c:
continue
if a == b or b == c or c == a:
ans += 1
else:
ans += 2
print(ans)
| false | 8.333333 |
[
"-A, B, C = eval(input()), eval(input()), eval(input())",
"+A = eval(input())",
"+B = eval(input())",
"+C = eval(input())",
"- if a != b and b != c and c != a:",
"+ if a == b == c:",
"+ continue",
"+ if a == b or b == c or c == a:",
"+ ans += 1",
"+ else:",
"- elif a == b == c:",
"- ans += 0",
"- else:",
"- ans += 1"
] | false | 0.160549 | 0.044919 | 3.574213 |
[
"s521717418",
"s820611594"
] |
u353895424
|
p03555
|
python
|
s717459249
|
s490404496
| 179 | 17 | 38,256 | 2,940 |
Accepted
|
Accepted
| 90.5 |
s1 = list(eval(input()))
s2 = list(eval(input()))
if s1 == s2[::-1]:
print("YES")
else:
print("NO")
|
c1 = eval(input())
c2 = eval(input())
if c1[0] == c2[-1] and c1[1] == c2[-2] and c1[2] == c2[-3]:
print("YES")
else:
print("NO")
| 7 | 7 | 102 | 131 |
s1 = list(eval(input()))
s2 = list(eval(input()))
if s1 == s2[::-1]:
print("YES")
else:
print("NO")
|
c1 = eval(input())
c2 = eval(input())
if c1[0] == c2[-1] and c1[1] == c2[-2] and c1[2] == c2[-3]:
print("YES")
else:
print("NO")
| false | 0 |
[
"-s1 = list(eval(input()))",
"-s2 = list(eval(input()))",
"-if s1 == s2[::-1]:",
"+c1 = eval(input())",
"+c2 = eval(input())",
"+if c1[0] == c2[-1] and c1[1] == c2[-2] and c1[2] == c2[-3]:"
] | false | 0.064721 | 0.045677 | 1.416929 |
[
"s717459249",
"s490404496"
] |
u608088992
|
p02873
|
python
|
s507996089
|
s849396902
| 355 | 288 | 23,348 | 23,452 |
Accepted
|
Accepted
| 18.87 |
def solve():
S = eval(input())
lenS = len(S)
sumS = 0
N = [0] * (lenS + 1)
zero = set()
if S[0] == "<": zero |= {0}
for i in range(lenS - 1):
if S[i] == ">" and S[i+1] == "<": zero |= {i+1}
if S[lenS-1] == ">": zero |= {lenS}
for start in zero:
pointer = start
while pointer <= lenS - 1:
if S[pointer] == "<":N[pointer + 1] = max(N[pointer] + 1, N[pointer + 1])
else: break
pointer += 1
pointer = start - 1
while pointer >= 0:
if S[pointer] == ">": N[pointer] = max(N[pointer + 1] + 1, N[pointer])
else: break
pointer -= 1
#print(N)
print((sum(N)))
return 0
if __name__ == "__main__": solve()
|
import sys
def solve():
S = eval(input())
N = len(S)
A = [0] * (N + 1)
init = []
for i in range(N - 1):
if S[i] == ">" and S[i + 1] == "<": init.append(i + 1)
#right
if S[0] == "<":
d = 1
A[d] = A[d - 1] + 1
while d <= N - 1:
if S[d] == ">": break
d += 1
A[d] = A[d-1] + 1
for s in init:
d = s + 1
A[d] = A[d - 1] + 1
while d <= N - 1:
if S[d] == ">": break
d += 1
A[d] = A[d-1] + 1
#left
if S[N - 1] == ">":
d = N - 1
while d >= 0:
if S[d] == "<": break
A[d] = max(A[d], A[d+1] + 1)
d -= 1
for s in init:
d = s - 1
while d >= 0:
if S[d] == "<": break
A[d] = max(A[d], A[d+1] + 1)
d -= 1
print((sum(A)))
#print(A)
return 0
if __name__ == "__main__":
solve()
| 30 | 49 | 787 | 1,010 |
def solve():
S = eval(input())
lenS = len(S)
sumS = 0
N = [0] * (lenS + 1)
zero = set()
if S[0] == "<":
zero |= {0}
for i in range(lenS - 1):
if S[i] == ">" and S[i + 1] == "<":
zero |= {i + 1}
if S[lenS - 1] == ">":
zero |= {lenS}
for start in zero:
pointer = start
while pointer <= lenS - 1:
if S[pointer] == "<":
N[pointer + 1] = max(N[pointer] + 1, N[pointer + 1])
else:
break
pointer += 1
pointer = start - 1
while pointer >= 0:
if S[pointer] == ">":
N[pointer] = max(N[pointer + 1] + 1, N[pointer])
else:
break
pointer -= 1
# print(N)
print((sum(N)))
return 0
if __name__ == "__main__":
solve()
|
import sys
def solve():
S = eval(input())
N = len(S)
A = [0] * (N + 1)
init = []
for i in range(N - 1):
if S[i] == ">" and S[i + 1] == "<":
init.append(i + 1)
# right
if S[0] == "<":
d = 1
A[d] = A[d - 1] + 1
while d <= N - 1:
if S[d] == ">":
break
d += 1
A[d] = A[d - 1] + 1
for s in init:
d = s + 1
A[d] = A[d - 1] + 1
while d <= N - 1:
if S[d] == ">":
break
d += 1
A[d] = A[d - 1] + 1
# left
if S[N - 1] == ">":
d = N - 1
while d >= 0:
if S[d] == "<":
break
A[d] = max(A[d], A[d + 1] + 1)
d -= 1
for s in init:
d = s - 1
while d >= 0:
if S[d] == "<":
break
A[d] = max(A[d], A[d + 1] + 1)
d -= 1
print((sum(A)))
# print(A)
return 0
if __name__ == "__main__":
solve()
| false | 38.77551 |
[
"+import sys",
"+",
"+",
"- lenS = len(S)",
"- sumS = 0",
"- N = [0] * (lenS + 1)",
"- zero = set()",
"+ N = len(S)",
"+ A = [0] * (N + 1)",
"+ init = []",
"+ for i in range(N - 1):",
"+ if S[i] == \">\" and S[i + 1] == \"<\":",
"+ init.append(i + 1)",
"+ # right",
"- zero |= {0}",
"- for i in range(lenS - 1):",
"- if S[i] == \">\" and S[i + 1] == \"<\":",
"- zero |= {i + 1}",
"- if S[lenS - 1] == \">\":",
"- zero |= {lenS}",
"- for start in zero:",
"- pointer = start",
"- while pointer <= lenS - 1:",
"- if S[pointer] == \"<\":",
"- N[pointer + 1] = max(N[pointer] + 1, N[pointer + 1])",
"- else:",
"+ d = 1",
"+ A[d] = A[d - 1] + 1",
"+ while d <= N - 1:",
"+ if S[d] == \">\":",
"- pointer += 1",
"- pointer = start - 1",
"- while pointer >= 0:",
"- if S[pointer] == \">\":",
"- N[pointer] = max(N[pointer + 1] + 1, N[pointer])",
"- else:",
"+ d += 1",
"+ A[d] = A[d - 1] + 1",
"+ for s in init:",
"+ d = s + 1",
"+ A[d] = A[d - 1] + 1",
"+ while d <= N - 1:",
"+ if S[d] == \">\":",
"- pointer -= 1",
"- # print(N)",
"- print((sum(N)))",
"+ d += 1",
"+ A[d] = A[d - 1] + 1",
"+ # left",
"+ if S[N - 1] == \">\":",
"+ d = N - 1",
"+ while d >= 0:",
"+ if S[d] == \"<\":",
"+ break",
"+ A[d] = max(A[d], A[d + 1] + 1)",
"+ d -= 1",
"+ for s in init:",
"+ d = s - 1",
"+ while d >= 0:",
"+ if S[d] == \"<\":",
"+ break",
"+ A[d] = max(A[d], A[d + 1] + 1)",
"+ d -= 1",
"+ print((sum(A)))",
"+ # print(A)"
] | false | 0.041831 | 0.042309 | 0.988704 |
[
"s507996089",
"s849396902"
] |
u606045429
|
p03911
|
python
|
s701112162
|
s409781943
| 610 | 502 | 9,176 | 9,660 |
Accepted
|
Accepted
| 17.7 |
class UnionFind:
def __init__(self, size):
self.data = [-1] * size
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return (x != y)
def same(self, x, y):
return (self.find(x) == self.find(y))
N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
for i in range(1, N + 1):
K, *L = list(map(int, input().split()))
for l in L:
uf.union(i, l + N)
if all(uf.same(i, N) for i in range(1, N)):
print("YES")
else:
print("NO")
|
class UnionFind:
def __init__(self, size):
self.data = [-1] * size
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return (x != y)
def same(self, x, y):
return (self.find(x) == self.find(y))
def size(self, x):
return -self.data[self.find(x)]
N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
used = [False] * (M + 1)
for i in range(1, N + 1):
K, *L = list(map(int, input().split()))
for l in L:
uf.union(i, l + N)
used[l] = True
if uf.size(1) - sum(used) == N:
print("YES")
else:
print("NO")
| 31 | 40 | 717 | 969 |
class UnionFind:
def __init__(self, size):
self.data = [-1] * size
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return x != y
def same(self, x, y):
return self.find(x) == self.find(y)
N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
for i in range(1, N + 1):
K, *L = list(map(int, input().split()))
for l in L:
uf.union(i, l + N)
if all(uf.same(i, N) for i in range(1, N)):
print("YES")
else:
print("NO")
|
class UnionFind:
def __init__(self, size):
self.data = [-1] * size
def find(self, x):
if self.data[x] < 0:
return x
else:
self.data[x] = self.find(self.data[x])
return self.data[x]
def union(self, x, y):
x, y = self.find(x), self.find(y)
if x != y:
if self.data[y] < self.data[x]:
x, y = y, x
self.data[x] += self.data[y]
self.data[y] = x
return x != y
def same(self, x, y):
return self.find(x) == self.find(y)
def size(self, x):
return -self.data[self.find(x)]
N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
used = [False] * (M + 1)
for i in range(1, N + 1):
K, *L = list(map(int, input().split()))
for l in L:
uf.union(i, l + N)
used[l] = True
if uf.size(1) - sum(used) == N:
print("YES")
else:
print("NO")
| false | 22.5 |
[
"+ def size(self, x):",
"+ return -self.data[self.find(x)]",
"+",
"+used = [False] * (M + 1)",
"-if all(uf.same(i, N) for i in range(1, N)):",
"+ used[l] = True",
"+if uf.size(1) - sum(used) == N:"
] | false | 0.032789 | 0.04182 | 0.784061 |
[
"s701112162",
"s409781943"
] |
u572193732
|
p02659
|
python
|
s085823682
|
s088722285
| 25 | 23 | 10,060 | 9,160 |
Accepted
|
Accepted
| 8 |
import decimal
A, B = list(map(float, input().split()))
A = str(A)
B = str(B)
ans = decimal.Decimal(A) * decimal.Decimal(B)
print((int(ans)))
|
A, B = input().split()
A = int(A)
B = round(float(B) * 100)
print((A * B // 100))
| 8 | 6 | 142 | 86 |
import decimal
A, B = list(map(float, input().split()))
A = str(A)
B = str(B)
ans = decimal.Decimal(A) * decimal.Decimal(B)
print((int(ans)))
|
A, B = input().split()
A = int(A)
B = round(float(B) * 100)
print((A * B // 100))
| false | 25 |
[
"-import decimal",
"-",
"-A, B = list(map(float, input().split()))",
"-A = str(A)",
"-B = str(B)",
"-ans = decimal.Decimal(A) * decimal.Decimal(B)",
"-print((int(ans)))",
"+A, B = input().split()",
"+A = int(A)",
"+B = round(float(B) * 100)",
"+print((A * B // 100))"
] | false | 0.041487 | 0.036727 | 1.129611 |
[
"s085823682",
"s088722285"
] |
u781262926
|
p02960
|
python
|
s454284590
|
s142701806
| 830 | 555 | 61,916 | 61,916 |
Accepted
|
Accepted
| 33.13 |
S = input().strip()
mod = 10**9 + 7
d = {i:i*10%13 for i in range(13)}
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
if c != '?':
c = int(c)
for j in range(13):
dp[i][(d[j] + c) % 13] = dp[i-1][j] % mod
else:
for c in range(10):
for j in range(13):
k = (d[j] + c) % 13
dp[i][k] = (dp[i][k] + dp[i-1][j]) % mod
print((dp[-1][5]))
|
S = input().strip()
mod = 10**9 + 7
d = [i*10%13 for i in range(13)]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
if c != '?':
c = int(c)
for j in range(13):
dp[i][(d[j] + c) % 13] = dp[i-1][j]
else:
for c in range(10):
for j in range(13):
k = (d[j] + c) % 13
dp[i][k] += dp[i-1][j]
for j in range(13):
dp[i][j] %= mod
print((dp[-1][5]))
| 16 | 18 | 464 | 496 |
S = input().strip()
mod = 10**9 + 7
d = {i: i * 10 % 13 for i in range(13)}
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
if c != "?":
c = int(c)
for j in range(13):
dp[i][(d[j] + c) % 13] = dp[i - 1][j] % mod
else:
for c in range(10):
for j in range(13):
k = (d[j] + c) % 13
dp[i][k] = (dp[i][k] + dp[i - 1][j]) % mod
print((dp[-1][5]))
|
S = input().strip()
mod = 10**9 + 7
d = [i * 10 % 13 for i in range(13)]
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
for i, c in enumerate(S, 1):
if c != "?":
c = int(c)
for j in range(13):
dp[i][(d[j] + c) % 13] = dp[i - 1][j]
else:
for c in range(10):
for j in range(13):
k = (d[j] + c) % 13
dp[i][k] += dp[i - 1][j]
for j in range(13):
dp[i][j] %= mod
print((dp[-1][5]))
| false | 11.111111 |
[
"-d = {i: i * 10 % 13 for i in range(13)}",
"+d = [i * 10 % 13 for i in range(13)]",
"- dp[i][(d[j] + c) % 13] = dp[i - 1][j] % mod",
"+ dp[i][(d[j] + c) % 13] = dp[i - 1][j]",
"- dp[i][k] = (dp[i][k] + dp[i - 1][j]) % mod",
"+ dp[i][k] += dp[i - 1][j]",
"+ for j in range(13):",
"+ dp[i][j] %= mod"
] | false | 0.046222 | 0.042736 | 1.081572 |
[
"s454284590",
"s142701806"
] |
u861141787
|
p03721
|
python
|
s599816762
|
s236552821
| 476 | 324 | 27,872 | 5,900 |
Accepted
|
Accepted
| 31.93 |
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
t = 0
for i in range(n):
t += ab[i][1]
if t >= k:
print((ab[i][0]))
break
|
n, k = list(map(int, input().split()))
amax = 100000
cnt = [0 for _ in range(amax+1)]
for i in range(n):
a, b = list(map(int, input().split()))
cnt[a] += b
for i in range(1, amax+1):
if k <= cnt[i]:
print(i)
break
k -= cnt[i]
| 11 | 14 | 208 | 261 |
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
t = 0
for i in range(n):
t += ab[i][1]
if t >= k:
print((ab[i][0]))
break
|
n, k = list(map(int, input().split()))
amax = 100000
cnt = [0 for _ in range(amax + 1)]
for i in range(n):
a, b = list(map(int, input().split()))
cnt[a] += b
for i in range(1, amax + 1):
if k <= cnt[i]:
print(i)
break
k -= cnt[i]
| false | 21.428571 |
[
"-ab = [list(map(int, input().split())) for _ in range(n)]",
"-ab.sort()",
"-t = 0",
"+amax = 100000",
"+cnt = [0 for _ in range(amax + 1)]",
"- t += ab[i][1]",
"- if t >= k:",
"- print((ab[i][0]))",
"+ a, b = list(map(int, input().split()))",
"+ cnt[a] += b",
"+for i in range(1, amax + 1):",
"+ if k <= cnt[i]:",
"+ print(i)",
"+ k -= cnt[i]"
] | false | 0.037443 | 0.042801 | 0.874814 |
[
"s599816762",
"s236552821"
] |
u867848444
|
p03026
|
python
|
s306922830
|
s468277302
| 385 | 73 | 51,416 | 7,568 |
Accepted
|
Accepted
| 81.04 |
#グラフの連結成分を調べる
def Graph(ab):
G=[[] for i in range(n)]
for a,b in ab:
G[a-1].append(b)
G[b-1].append(a)
return G
#BFS
from collections import deque
def bfs(G, v, p):
point = [0] * n
q=deque()
q.append((v, p))
point[0] = c.pop(0)
score = 0
while q:
#qの先頭を取り出す
V, P = q.popleft()
for next_v in G[V - 1]:
if next_v == P:continue
q.append((next_v, V))
temp = c.pop(0)
score += temp
point[next_v - 1] = temp
return point, score
n = int(eval(input()))
ab = [list(map(int,input().split())) for i in range(n - 1)]
c = list(map(int,input().split()))
c = sorted(c, reverse=True)
G = Graph(ab)
point, score = bfs(G, 1, -1)
print(score)
print((*point))
|
#グラフの連結成分を調べる
def Graph(ab):
G=[[] for i in range(n)]
for a,b in ab:
G[a-1].append(b)
G[b-1].append(a)
return G
from collections import deque
def bfs(v, p):
q = deque()
q.append((v, p))
rec[v - 1] = c.pop()
while c:
V, P = q.popleft()
for nv in G[V - 1]:
if nv == P:continue
rec[nv - 1] = c.pop()
q.append((nv, V))
n = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(n - 1)]
c = list(map(int, input().split()))
c.sort()
G = Graph(ab)
print((sum(c[:-1])))
rec = [0] * n
bfs(1, -1)
print((*rec))
| 38 | 28 | 813 | 631 |
# グラフの連結成分を調べる
def Graph(ab):
G = [[] for i in range(n)]
for a, b in ab:
G[a - 1].append(b)
G[b - 1].append(a)
return G
# BFS
from collections import deque
def bfs(G, v, p):
point = [0] * n
q = deque()
q.append((v, p))
point[0] = c.pop(0)
score = 0
while q:
# qの先頭を取り出す
V, P = q.popleft()
for next_v in G[V - 1]:
if next_v == P:
continue
q.append((next_v, V))
temp = c.pop(0)
score += temp
point[next_v - 1] = temp
return point, score
n = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(n - 1)]
c = list(map(int, input().split()))
c = sorted(c, reverse=True)
G = Graph(ab)
point, score = bfs(G, 1, -1)
print(score)
print((*point))
|
# グラフの連結成分を調べる
def Graph(ab):
G = [[] for i in range(n)]
for a, b in ab:
G[a - 1].append(b)
G[b - 1].append(a)
return G
from collections import deque
def bfs(v, p):
q = deque()
q.append((v, p))
rec[v - 1] = c.pop()
while c:
V, P = q.popleft()
for nv in G[V - 1]:
if nv == P:
continue
rec[nv - 1] = c.pop()
q.append((nv, V))
n = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(n - 1)]
c = list(map(int, input().split()))
c.sort()
G = Graph(ab)
print((sum(c[:-1])))
rec = [0] * n
bfs(1, -1)
print((*rec))
| false | 26.315789 |
[
"-# BFS",
"-def bfs(G, v, p):",
"- point = [0] * n",
"+def bfs(v, p):",
"- point[0] = c.pop(0)",
"- score = 0",
"- while q:",
"- # qの先頭を取り出す",
"+ rec[v - 1] = c.pop()",
"+ while c:",
"- for next_v in G[V - 1]:",
"- if next_v == P:",
"+ for nv in G[V - 1]:",
"+ if nv == P:",
"- q.append((next_v, V))",
"- temp = c.pop(0)",
"- score += temp",
"- point[next_v - 1] = temp",
"- return point, score",
"+ rec[nv - 1] = c.pop()",
"+ q.append((nv, V))",
"-c = sorted(c, reverse=True)",
"+c.sort()",
"-point, score = bfs(G, 1, -1)",
"-print(score)",
"-print((*point))",
"+print((sum(c[:-1])))",
"+rec = [0] * n",
"+bfs(1, -1)",
"+print((*rec))"
] | false | 0.090095 | 0.073422 | 1.227086 |
[
"s306922830",
"s468277302"
] |
u863442865
|
p02990
|
python
|
s352163663
|
s395206444
| 235 | 160 | 3,700 | 3,700 |
Accepted
|
Accepted
| 31.91 |
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
def extgcd(a, b):
if b == 0:
return a, 1, 0
else:
d, x, y = extgcd(b, a % b)
x -= (a // b) * y
return d, y, x
def modinv(a, mod):
return extgcd(a, mod)[1] % mod
def modcomb(n, k, mod):
q, a = 1, 1
for i in range(n-k+1, n+1):
q = (q * i) % mod
for i in range(2, k+1):
a = (a * i) % mod
return int(q * modinv(a, mod) % mod)
n,k = list(map(int, input().split()))
#k個ある青のボールをi個に分ける
for i in range(1, k+1):
if i > n-k+1:
print((0))
else:
print(((modcomb(k-1, k-i, mod) * modcomb(n-k+1, i, mod))% mod))
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
def nCr(n, r, mod):#mod=10**9+7
r = min(r, n-r)
numer = denom = 1
for i in range(1, r+1):
numer = numer * (n+1-i) % mod
denom = denom * i % mod
return numer * pow(denom, mod-2, mod) % mod
n,k = list(map(int, input().split()))
#k個ある青のボールをi個に分ける
for i in range(1, k+1):
if i > n-k+1:
print((0))
else:
print(((nCr(k-1, k-i, mod) * nCr(n-k+1, i, mod))% mod))
if __name__ == '__main__':
main()
| 45 | 34 | 1,240 | 997 |
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
def extgcd(a, b):
if b == 0:
return a, 1, 0
else:
d, x, y = extgcd(b, a % b)
x -= (a // b) * y
return d, y, x
def modinv(a, mod):
return extgcd(a, mod)[1] % mod
def modcomb(n, k, mod):
q, a = 1, 1
for i in range(n - k + 1, n + 1):
q = (q * i) % mod
for i in range(2, k + 1):
a = (a * i) % mod
return int(q * modinv(a, mod) % mod)
n, k = list(map(int, input().split()))
# k個ある青のボールをi個に分ける
for i in range(1, k + 1):
if i > n - k + 1:
print((0))
else:
print(((modcomb(k - 1, k - i, mod) * modcomb(n - k + 1, i, mod)) % mod))
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
def nCr(n, r, mod): # mod=10**9+7
r = min(r, n - r)
numer = denom = 1
for i in range(1, r + 1):
numer = numer * (n + 1 - i) % mod
denom = denom * i % mod
return numer * pow(denom, mod - 2, mod) % mod
n, k = list(map(int, input().split()))
# k個ある青のボールをi個に分ける
for i in range(1, k + 1):
if i > n - k + 1:
print((0))
else:
print(((nCr(k - 1, k - i, mod) * nCr(n - k + 1, i, mod)) % mod))
if __name__ == "__main__":
main()
| false | 24.444444 |
[
"- def extgcd(a, b):",
"- if b == 0:",
"- return a, 1, 0",
"- else:",
"- d, x, y = extgcd(b, a % b)",
"- x -= (a // b) * y",
"- return d, y, x",
"-",
"- def modinv(a, mod):",
"- return extgcd(a, mod)[1] % mod",
"-",
"- def modcomb(n, k, mod):",
"- q, a = 1, 1",
"- for i in range(n - k + 1, n + 1):",
"- q = (q * i) % mod",
"- for i in range(2, k + 1):",
"- a = (a * i) % mod",
"- return int(q * modinv(a, mod) % mod)",
"+ def nCr(n, r, mod): # mod=10**9+7",
"+ r = min(r, n - r)",
"+ numer = denom = 1",
"+ for i in range(1, r + 1):",
"+ numer = numer * (n + 1 - i) % mod",
"+ denom = denom * i % mod",
"+ return numer * pow(denom, mod - 2, mod) % mod",
"- print(((modcomb(k - 1, k - i, mod) * modcomb(n - k + 1, i, mod)) % mod))",
"+ print(((nCr(k - 1, k - i, mod) * nCr(n - k + 1, i, mod)) % mod))"
] | false | 0.168493 | 0.214273 | 0.786351 |
[
"s352163663",
"s395206444"
] |
u094191970
|
p02756
|
python
|
s636799660
|
s835627587
| 515 | 450 | 8,436 | 8,436 |
Accepted
|
Accepted
| 12.62 |
from collections import deque
s=deque(eval(input()))
q=int(eval(input()))
rev=0
for i in range(q):
l=list(input().split())
if len(l)==1:
rev+=1
else:
t,f,c=l[0],l[1],l[2]
if rev%2==0:
if f=='1':
s.appendleft(c)
else:
s.append(c)
else:
if f=='1':
s.append(c)
else:
s.appendleft(c)
if rev%2==1:
s.reverse()
print((''.join(s)))
|
from collections import deque
s=deque(eval(input()))
q=int(eval(input()))
rev=0
for i in range(q):
l=input().split()
if len(l)==1:
rev+=1
else:
t,f,c=l[0],l[1],l[2]
if rev%2==0:
if f=='1':
s.appendleft(c)
else:
s.append(c)
else:
if f=='1':
s.append(c)
else:
s.appendleft(c)
if rev%2==1:
s.reverse()
print((''.join(s)))
| 27 | 27 | 420 | 414 |
from collections import deque
s = deque(eval(input()))
q = int(eval(input()))
rev = 0
for i in range(q):
l = list(input().split())
if len(l) == 1:
rev += 1
else:
t, f, c = l[0], l[1], l[2]
if rev % 2 == 0:
if f == "1":
s.appendleft(c)
else:
s.append(c)
else:
if f == "1":
s.append(c)
else:
s.appendleft(c)
if rev % 2 == 1:
s.reverse()
print(("".join(s)))
|
from collections import deque
s = deque(eval(input()))
q = int(eval(input()))
rev = 0
for i in range(q):
l = input().split()
if len(l) == 1:
rev += 1
else:
t, f, c = l[0], l[1], l[2]
if rev % 2 == 0:
if f == "1":
s.appendleft(c)
else:
s.append(c)
else:
if f == "1":
s.append(c)
else:
s.appendleft(c)
if rev % 2 == 1:
s.reverse()
print(("".join(s)))
| false | 0 |
[
"- l = list(input().split())",
"+ l = input().split()"
] | false | 0.044449 | 0.044424 | 1.000555 |
[
"s636799660",
"s835627587"
] |
u761062383
|
p03363
|
python
|
s131984736
|
s027786285
| 1,523 | 255 | 46,876 | 46,844 |
Accepted
|
Accepted
| 83.26 |
def resolve():
import math as m
from collections import defaultdict
N = int(eval(input()))
A = [int(i) for i in input().split()]
preSum = [0] * (N + 1)
dd = defaultdict(int)
dd[0] = 1
for i in range(N):
preSum[i + 1] = preSum[i] + A[i]
dd[preSum[i] + A[i]] += 1
sumA = 0
for key in list(dd.keys()):
if dd[key] > 1:
sumA += m.factorial(dd[key]) // (m.factorial(dd[key] - 2) * 2)
print(sumA)
resolve()
|
def resolve():
from collections import defaultdict
N = int(eval(input()))
A = [int(i) for i in input().split()]
preSum = [0] * (N + 1)
dd = defaultdict(int)
dd[0] = 1
for i in range(N):
preSum[i + 1] = preSum[i] + A[i]
dd[preSum[i] + A[i]] += 1
sumA = 0
for key in list(dd.keys()):
if dd[key] > 1:
sumA += dd[key] * (dd[key] - 1) // 2
print(sumA)
resolve()
| 19 | 18 | 488 | 440 |
def resolve():
import math as m
from collections import defaultdict
N = int(eval(input()))
A = [int(i) for i in input().split()]
preSum = [0] * (N + 1)
dd = defaultdict(int)
dd[0] = 1
for i in range(N):
preSum[i + 1] = preSum[i] + A[i]
dd[preSum[i] + A[i]] += 1
sumA = 0
for key in list(dd.keys()):
if dd[key] > 1:
sumA += m.factorial(dd[key]) // (m.factorial(dd[key] - 2) * 2)
print(sumA)
resolve()
|
def resolve():
from collections import defaultdict
N = int(eval(input()))
A = [int(i) for i in input().split()]
preSum = [0] * (N + 1)
dd = defaultdict(int)
dd[0] = 1
for i in range(N):
preSum[i + 1] = preSum[i] + A[i]
dd[preSum[i] + A[i]] += 1
sumA = 0
for key in list(dd.keys()):
if dd[key] > 1:
sumA += dd[key] * (dd[key] - 1) // 2
print(sumA)
resolve()
| false | 5.263158 |
[
"- import math as m",
"- sumA += m.factorial(dd[key]) // (m.factorial(dd[key] - 2) * 2)",
"+ sumA += dd[key] * (dd[key] - 1) // 2"
] | false | 0.042838 | 0.037082 | 1.155228 |
[
"s131984736",
"s027786285"
] |
u465900169
|
p02713
|
python
|
s746036750
|
s712058016
| 1,810 | 1,161 | 9,164 | 72,484 |
Accepted
|
Accepted
| 35.86 |
from math import gcd
N = int(eval(input()))
ans = 0
for i in range(1,N+1):
for j in range(1,N+1):
for k in range(1,N+1):
ans += gcd(gcd(i,j),k)
print(ans)
|
K = int(eval(input()))
total = 0
def gdc(x,y):
if x%y==0:
return y
return gdc(y, x%y)
for a in range(K):
for b in range(K):
for c in range(K):
total += gdc(c+1, gdc(b+1, a+1))
print(total)
| 9 | 14 | 170 | 219 |
from math import gcd
N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
for j in range(1, N + 1):
for k in range(1, N + 1):
ans += gcd(gcd(i, j), k)
print(ans)
|
K = int(eval(input()))
total = 0
def gdc(x, y):
if x % y == 0:
return y
return gdc(y, x % y)
for a in range(K):
for b in range(K):
for c in range(K):
total += gdc(c + 1, gdc(b + 1, a + 1))
print(total)
| false | 35.714286 |
[
"-from math import gcd",
"+K = int(eval(input()))",
"+total = 0",
"-N = int(eval(input()))",
"-ans = 0",
"-for i in range(1, N + 1):",
"- for j in range(1, N + 1):",
"- for k in range(1, N + 1):",
"- ans += gcd(gcd(i, j), k)",
"-print(ans)",
"+",
"+def gdc(x, y):",
"+ if x % y == 0:",
"+ return y",
"+ return gdc(y, x % y)",
"+",
"+",
"+for a in range(K):",
"+ for b in range(K):",
"+ for c in range(K):",
"+ total += gdc(c + 1, gdc(b + 1, a + 1))",
"+print(total)"
] | false | 0.142963 | 0.072941 | 1.959988 |
[
"s746036750",
"s712058016"
] |
u848647227
|
p03341
|
python
|
s706565632
|
s536563881
| 159 | 136 | 17,540 | 3,672 |
Accepted
|
Accepted
| 14.47 |
a = int(eval(input()))
ar = list(eval(input()))
wc = 0
ec = ar.count("E")
br = []
for i in range(a):
if ar[i] == "E":
ec -= 1
br.append(ec + wc)
if ar[i] == "W":
wc += 1
print((min(br)))
|
a = int(eval(input()))
ar = eval(input())
n = ar.count("E")
if ar[0] == "E":
n -= 1
mi = n
for i in range(1,a):
if ar[i] == "E":
n -= 1
if ar[i-1] == "W":
n += 1
if n < mi:
mi = n
print(mi)
| 12 | 14 | 211 | 230 |
a = int(eval(input()))
ar = list(eval(input()))
wc = 0
ec = ar.count("E")
br = []
for i in range(a):
if ar[i] == "E":
ec -= 1
br.append(ec + wc)
if ar[i] == "W":
wc += 1
print((min(br)))
|
a = int(eval(input()))
ar = eval(input())
n = ar.count("E")
if ar[0] == "E":
n -= 1
mi = n
for i in range(1, a):
if ar[i] == "E":
n -= 1
if ar[i - 1] == "W":
n += 1
if n < mi:
mi = n
print(mi)
| false | 14.285714 |
[
"-ar = list(eval(input()))",
"-wc = 0",
"-ec = ar.count(\"E\")",
"-br = []",
"-for i in range(a):",
"+ar = eval(input())",
"+n = ar.count(\"E\")",
"+if ar[0] == \"E\":",
"+ n -= 1",
"+mi = n",
"+for i in range(1, a):",
"- ec -= 1",
"- br.append(ec + wc)",
"- if ar[i] == \"W\":",
"- wc += 1",
"-print((min(br)))",
"+ n -= 1",
"+ if ar[i - 1] == \"W\":",
"+ n += 1",
"+ if n < mi:",
"+ mi = n",
"+print(mi)"
] | false | 0.049274 | 0.045455 | 1.084024 |
[
"s706565632",
"s536563881"
] |
u077291787
|
p03476
|
python
|
s968585270
|
s921242760
| 278 | 156 | 22,276 | 25,076 |
Accepted
|
Accepted
| 43.88 |
# ABC084D - 2017-like Number
import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right
def get_primes(n: int) -> list:
# return a list of primes <= n
n += 1 # include n itself
sieve = [1] * n
for i in range(3, int(n ** 0.5) + 1, 2):
if sieve[i]:
sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
return [2] + [i for i in range(3, n, 2) if sieve[i]]
def main():
Q = int(input())
A = tuple(tuple(map(int, input().split())) for _ in range(Q))
P = get_primes(10 ** 5)
S = set(P)
selected_P = [p for p in P if (p + 1) // 2 in S]
bsr, bsl = bisect_right, bisect_left
ans = [bsr(selected_P, r) - bsl(selected_P, l) for l, r in A]
print(*ans, sep="\n")
if __name__ == "__main__":
main()
|
# ABC084D - 2017-like Number
from bisect import bisect_left as bsl, bisect_right as bsr
def get_primes(n: int) -> list:
# return a list of primes <= n
sieve = [1] * n
for i in range(3, int(n ** 0.5) + 1, 2):
if sieve[i]:
sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
return [2] + [i for i in range(3, n, 2) if sieve[i]]
def main():
Q, *LR = list(map(int, open(0).read().split()))
P = get_primes(10 ** 5 + 1)
S = set(P)
selected_P = [p for p in P if (p + 1) // 2 in S] # 2017-like primes
# the number of 2017-like primes b/w l, r -> bisect[r] - bisect[l]
ans = [bsr(selected_P, r) - bsl(selected_P, l) for l, r in zip(*[iter(LR)] * 2)]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| 30 | 25 | 829 | 810 |
# ABC084D - 2017-like Number
import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right
def get_primes(n: int) -> list:
# return a list of primes <= n
n += 1 # include n itself
sieve = [1] * n
for i in range(3, int(n**0.5) + 1, 2):
if sieve[i]:
sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
return [2] + [i for i in range(3, n, 2) if sieve[i]]
def main():
Q = int(input())
A = tuple(tuple(map(int, input().split())) for _ in range(Q))
P = get_primes(10**5)
S = set(P)
selected_P = [p for p in P if (p + 1) // 2 in S]
bsr, bsl = bisect_right, bisect_left
ans = [bsr(selected_P, r) - bsl(selected_P, l) for l, r in A]
print(*ans, sep="\n")
if __name__ == "__main__":
main()
|
# ABC084D - 2017-like Number
from bisect import bisect_left as bsl, bisect_right as bsr
def get_primes(n: int) -> list:
# return a list of primes <= n
sieve = [1] * n
for i in range(3, int(n**0.5) + 1, 2):
if sieve[i]:
sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
return [2] + [i for i in range(3, n, 2) if sieve[i]]
def main():
Q, *LR = list(map(int, open(0).read().split()))
P = get_primes(10**5 + 1)
S = set(P)
selected_P = [p for p in P if (p + 1) // 2 in S] # 2017-like primes
# the number of 2017-like primes b/w l, r -> bisect[r] - bisect[l]
ans = [bsr(selected_P, r) - bsl(selected_P, l) for l, r in zip(*[iter(LR)] * 2)]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| false | 16.666667 |
[
"-import sys",
"-",
"-input = sys.stdin.readline",
"-from bisect import bisect_left, bisect_right",
"+from bisect import bisect_left as bsl, bisect_right as bsr",
"- n += 1 # include n itself",
"- Q = int(input())",
"- A = tuple(tuple(map(int, input().split())) for _ in range(Q))",
"- P = get_primes(10**5)",
"+ Q, *LR = list(map(int, open(0).read().split()))",
"+ P = get_primes(10**5 + 1)",
"- selected_P = [p for p in P if (p + 1) // 2 in S]",
"- bsr, bsl = bisect_right, bisect_left",
"- ans = [bsr(selected_P, r) - bsl(selected_P, l) for l, r in A]",
"- print(*ans, sep=\"\\n\")",
"+ selected_P = [p for p in P if (p + 1) // 2 in S] # 2017-like primes",
"+ # the number of 2017-like primes b/w l, r -> bisect[r] - bisect[l]",
"+ ans = [bsr(selected_P, r) - bsl(selected_P, l) for l, r in zip(*[iter(LR)] * 2)]",
"+ print((\"\\n\".join(map(str, ans))))"
] | false | 0.04618 | 0.172893 | 0.267103 |
[
"s968585270",
"s921242760"
] |
u777283665
|
p03013
|
python
|
s484521990
|
s540846546
| 239 | 196 | 7,668 | 7,668 |
Accepted
|
Accepted
| 17.99 |
n, m = list(map(int, input().split()))
broken = [0] * (n+1)
dp = [0] * (n+1)
for _ in range(m):
broken[int(eval(input()))] = 1
if sum(broken[-2:]) == 2:
print((0))
exit()
dp[0] = 1
if broken[1] == 1:
dp[1] = 0
else:
dp[1] = 1
if n == 1:
print((dp[n]))
exit()
else:
for i in range(2, n+1):
if broken[i] == 1:
continue
else:
dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
print((dp[n]))
|
n, m = list(map(int, input().split()))
broken = [0] * (n+1)
dp = [0] * (n+1)
for _ in range(m):
broken[int(eval(input()))] = 1
if broken[-1] == 1 and broken[-2] == 1:
print((0))
exit()
dp[0] = 1
if broken[1] == 1:
dp[1] = 0
else:
dp[1] = 1
if n == 1:
print((dp[n]))
exit()
else:
for i in range(2, n+1):
if broken[i] == 1:
continue
else:
dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
print((dp[n]))
| 29 | 29 | 436 | 450 |
n, m = list(map(int, input().split()))
broken = [0] * (n + 1)
dp = [0] * (n + 1)
for _ in range(m):
broken[int(eval(input()))] = 1
if sum(broken[-2:]) == 2:
print((0))
exit()
dp[0] = 1
if broken[1] == 1:
dp[1] = 0
else:
dp[1] = 1
if n == 1:
print((dp[n]))
exit()
else:
for i in range(2, n + 1):
if broken[i] == 1:
continue
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print((dp[n]))
|
n, m = list(map(int, input().split()))
broken = [0] * (n + 1)
dp = [0] * (n + 1)
for _ in range(m):
broken[int(eval(input()))] = 1
if broken[-1] == 1 and broken[-2] == 1:
print((0))
exit()
dp[0] = 1
if broken[1] == 1:
dp[1] = 0
else:
dp[1] = 1
if n == 1:
print((dp[n]))
exit()
else:
for i in range(2, n + 1):
if broken[i] == 1:
continue
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print((dp[n]))
| false | 0 |
[
"- if sum(broken[-2:]) == 2:",
"+ if broken[-1] == 1 and broken[-2] == 1:"
] | false | 0.051075 | 0.051533 | 0.991105 |
[
"s484521990",
"s540846546"
] |
u682672120
|
p02984
|
python
|
s779955860
|
s779446637
| 132 | 94 | 86,148 | 93,224 |
Accepted
|
Accepted
| 28.79 |
import itertools
n = int(eval(input()))
a_list = list(map(int, input().split()))
xn = sum(a_list) // 2 - sum(a_list[:n-1:2])
x = a_list[-1] - xn
for a in a_list:
print((x * 2))
x = a - x
|
n = int(eval(input()))
a_list = list(map(int, input().split()))
x = sum(a_list[::2]) - sum(a_list) // 2
ans = []
for a in a_list:
ans.append(str(x * 2))
x = a - x
print((' '.join(ans)))
| 10 | 8 | 197 | 192 |
import itertools
n = int(eval(input()))
a_list = list(map(int, input().split()))
xn = sum(a_list) // 2 - sum(a_list[: n - 1 : 2])
x = a_list[-1] - xn
for a in a_list:
print((x * 2))
x = a - x
|
n = int(eval(input()))
a_list = list(map(int, input().split()))
x = sum(a_list[::2]) - sum(a_list) // 2
ans = []
for a in a_list:
ans.append(str(x * 2))
x = a - x
print((" ".join(ans)))
| false | 20 |
[
"-import itertools",
"-",
"-xn = sum(a_list) // 2 - sum(a_list[: n - 1 : 2])",
"-x = a_list[-1] - xn",
"+x = sum(a_list[::2]) - sum(a_list) // 2",
"+ans = []",
"- print((x * 2))",
"+ ans.append(str(x * 2))",
"+print((\" \".join(ans)))"
] | false | 0.040414 | 0.040871 | 0.988822 |
[
"s779955860",
"s779446637"
] |
u133936772
|
p02598
|
python
|
s070547953
|
s624291667
| 1,332 | 914 | 30,848 | 31,240 |
Accepted
|
Accepted
| 31.38 |
f=lambda:[*list(map(int,input().split()))]
n,k=f()
a=f()
a=[i*100 for i in a]
# Binary Search
def ok(x):
c=0
for i in a:
c+=0--i//x
return c<=n+k
l,r=0,10**11+1
while r-l>1:
m=l+r>>1
if ok(m): r=m
else: l=m
t=0--r//100
print((t-ok(t-1) if t>1 else t))
|
from math import *
f=lambda:[*list(map(int,input().split()))]
n,k=f()
a=f()
def ok(x):
c=0
for i in a:
c+=ceil(i/x)
return c<=n+k
l,r=0,10**9+1
while r-l>0.1:
m=(l+r)/2
if ok(m): r=m
else: l=m
t=ceil(r)
print((t-ok(t-1) if t>1 else t))
| 17 | 16 | 283 | 258 |
f = lambda: [*list(map(int, input().split()))]
n, k = f()
a = f()
a = [i * 100 for i in a]
# Binary Search
def ok(x):
c = 0
for i in a:
c += 0 - -i // x
return c <= n + k
l, r = 0, 10**11 + 1
while r - l > 1:
m = l + r >> 1
if ok(m):
r = m
else:
l = m
t = 0 - -r // 100
print((t - ok(t - 1) if t > 1 else t))
|
from math import *
f = lambda: [*list(map(int, input().split()))]
n, k = f()
a = f()
def ok(x):
c = 0
for i in a:
c += ceil(i / x)
return c <= n + k
l, r = 0, 10**9 + 1
while r - l > 0.1:
m = (l + r) / 2
if ok(m):
r = m
else:
l = m
t = ceil(r)
print((t - ok(t - 1) if t > 1 else t))
| false | 5.882353 |
[
"+from math import *",
"+",
"-a = [i * 100 for i in a]",
"-# Binary Search",
"+",
"+",
"- c += 0 - -i // x",
"+ c += ceil(i / x)",
"-l, r = 0, 10**11 + 1",
"-while r - l > 1:",
"- m = l + r >> 1",
"+l, r = 0, 10**9 + 1",
"+while r - l > 0.1:",
"+ m = (l + r) / 2",
"-t = 0 - -r // 100",
"+t = ceil(r)"
] | false | 0.03814 | 0.069953 | 0.545232 |
[
"s070547953",
"s624291667"
] |
u761989513
|
p03244
|
python
|
s445494136
|
s224063520
| 133 | 74 | 19,040 | 15,972 |
Accepted
|
Accepted
| 44.36 |
import collections
n = int(eval(input()))
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(list(ac.items()), key=lambda x: x[1], reverse=True)
bc = sorted(list(bc.items()), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
if len(ac) == len(bc) and len(ac) == 1:
print((ac[0][1]))
exit()
i = 0
while ac[i][1] == bc[i][1]:
i += 1
if i == len(ac) - 1 or i == len(bc) - 1:
break
if ac[i][1] > bc[i][1]:
ac.remove(ac[i])
bc.remove(bc[0])
elif ac[i][1] < bc[i][1]:
ac.remove(ac[0])
bc.remove(bc[i])
else:
ac.remove(ac[0])
bc.remove(bc[1])
else:
ac.remove(ac[0])
bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
ans += ac[i][1]
for i in range(len(bc)):
ans += bc[i][1]
print(ans)
|
import collections
n = int(eval(input()))
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a).most_common(2)
bc = collections.Counter(b).most_common(2)
if ac[0][0] != bc[0][0]:
print((n - ac[0][1] - bc[0][1]))
else:
if len(ac) == 1:
print((n // 2))
else:
print((n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])))
| 37 | 15 | 911 | 379 |
import collections
n = int(eval(input()))
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(list(ac.items()), key=lambda x: x[1], reverse=True)
bc = sorted(list(bc.items()), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
if len(ac) == len(bc) and len(ac) == 1:
print((ac[0][1]))
exit()
i = 0
while ac[i][1] == bc[i][1]:
i += 1
if i == len(ac) - 1 or i == len(bc) - 1:
break
if ac[i][1] > bc[i][1]:
ac.remove(ac[i])
bc.remove(bc[0])
elif ac[i][1] < bc[i][1]:
ac.remove(ac[0])
bc.remove(bc[i])
else:
ac.remove(ac[0])
bc.remove(bc[1])
else:
ac.remove(ac[0])
bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
ans += ac[i][1]
for i in range(len(bc)):
ans += bc[i][1]
print(ans)
|
import collections
n = int(eval(input()))
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a).most_common(2)
bc = collections.Counter(b).most_common(2)
if ac[0][0] != bc[0][0]:
print((n - ac[0][1] - bc[0][1]))
else:
if len(ac) == 1:
print((n // 2))
else:
print((n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])))
| false | 59.459459 |
[
"-ac = collections.Counter(a)",
"-bc = collections.Counter(b)",
"-ac = sorted(list(ac.items()), key=lambda x: x[1], reverse=True)",
"-bc = sorted(list(bc.items()), key=lambda x: x[1], reverse=True)",
"-if ac[0][0] == bc[0][0]:",
"- if len(ac) == len(bc) and len(ac) == 1:",
"- print((ac[0][1]))",
"- exit()",
"- i = 0",
"- while ac[i][1] == bc[i][1]:",
"- i += 1",
"- if i == len(ac) - 1 or i == len(bc) - 1:",
"- break",
"- if ac[i][1] > bc[i][1]:",
"- ac.remove(ac[i])",
"- bc.remove(bc[0])",
"- elif ac[i][1] < bc[i][1]:",
"- ac.remove(ac[0])",
"- bc.remove(bc[i])",
"+ac = collections.Counter(a).most_common(2)",
"+bc = collections.Counter(b).most_common(2)",
"+if ac[0][0] != bc[0][0]:",
"+ print((n - ac[0][1] - bc[0][1]))",
"+else:",
"+ if len(ac) == 1:",
"+ print((n // 2))",
"- ac.remove(ac[0])",
"- bc.remove(bc[1])",
"-else:",
"- ac.remove(ac[0])",
"- bc.remove(bc[0])",
"-ans = 0",
"-for i in range(len(ac)):",
"- ans += ac[i][1]",
"-for i in range(len(bc)):",
"- ans += bc[i][1]",
"-print(ans)",
"+ print((n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])))"
] | false | 0.039217 | 0.047685 | 0.822415 |
[
"s445494136",
"s224063520"
] |
u852690916
|
p03966
|
python
|
s818105002
|
s471162391
| 198 | 166 | 38,768 | 38,384 |
Accepted
|
Accepted
| 16.16 |
N = int(eval(input()))
t = a = 1
for i in range(N):
T, A = list(map(int, input().split()))
tb = (t + T - 1) // T
ab = (a + A - 1) // A
b = max(tb, ab)
t = T * b
a = A * b
print((t+a))
|
import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
t, a = 1, 1
for _ in range(N):
T, A = list(map(int, input().split()))
nt = t + (T - (t % T) if t % T else 0)
na = a + (A - (a % A) if a % A else 0)
n = na // A if nt // T < na // A else nt // T
t, a = T * n, A * n
print((t + a))
if __name__ == '__main__':
main()
| 10 | 16 | 202 | 402 |
N = int(eval(input()))
t = a = 1
for i in range(N):
T, A = list(map(int, input().split()))
tb = (t + T - 1) // T
ab = (a + A - 1) // A
b = max(tb, ab)
t = T * b
a = A * b
print((t + a))
|
import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
t, a = 1, 1
for _ in range(N):
T, A = list(map(int, input().split()))
nt = t + (T - (t % T) if t % T else 0)
na = a + (A - (a % A) if a % A else 0)
n = na // A if nt // T < na // A else nt // T
t, a = T * n, A * n
print((t + a))
if __name__ == "__main__":
main()
| false | 37.5 |
[
"-N = int(eval(input()))",
"-t = a = 1",
"-for i in range(N):",
"- T, A = list(map(int, input().split()))",
"- tb = (t + T - 1) // T",
"- ab = (a + A - 1) // A",
"- b = max(tb, ab)",
"- t = T * b",
"- a = A * b",
"-print((t + a))",
"+import sys",
"+",
"+",
"+def main():",
"+ input = sys.stdin.readline",
"+ N = int(eval(input()))",
"+ t, a = 1, 1",
"+ for _ in range(N):",
"+ T, A = list(map(int, input().split()))",
"+ nt = t + (T - (t % T) if t % T else 0)",
"+ na = a + (A - (a % A) if a % A else 0)",
"+ n = na // A if nt // T < na // A else nt // T",
"+ t, a = T * n, A * n",
"+ print((t + a))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.13908 | 0.030409 | 4.573622 |
[
"s818105002",
"s471162391"
] |
u334712262
|
p03095
|
python
|
s736849410
|
s595991483
| 77 | 46 | 5,956 | 5,700 |
Accepted
|
Accepted
| 40.26 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
class Mod:
def __init__(self, m):
self.m = m
def add(self, a, b):
return (a + b ) % self.m
def sub(self, a, b):
return (a - b) % self.m
def mul(self, a, b):
return ((a % self.m) * (b % self.m)) % self.m
def div(self, a, b):
return self.mul(a, self.pow(b, self.m-2))
def pow(self, x, y):
if y == 0:
return 1
elif y == 1:
return x % self.m
elif y % 2 == 0:
return self.pow(x, y//2)**2 % self.m
else:
return self.pow(x, y//2)**2 * x % self.m
@mt
def slv(N, S):
CC = Counter()
for c in S:
CC[c] += 1
for c in CC:
CC[c] += 1
m = Mod(10**9+7)
return reduce(m.mul, CC.values()) - 1
def main():
N = read_int()
S = read_str()
print(slv(N, S))
if __name__ == '__main__':
main()
|
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
class Mod:
def __init__(self, m):
self.m = m
def add(self, a, b):
return (a + b ) % self.m
def sub(self, a, b):
return (a - b) % self.m
def mul(self, a, b):
return ((a % self.m) * (b % self.m)) % self.m
def div(self, a, b):
return self.mul(a, self.pow(b, self.m-2))
def pow(self, x, y):
if y == 0:
return 1
elif y == 1:
return x % self.m
elif y % 2 == 0:
return self.pow(x, y//2)**2 % self.m
else:
return self.pow(x, y//2)**2 * x % self.m
@mt
def slv(N, S):
CC = defaultdict(lambda: 1)
for c in S:
CC[c] += 1
m = Mod(10**9+7)
return reduce(m.mul, CC.values()) - 1
def main():
N = read_int()
S = read_str()
print(slv(N, S))
if __name__ == '__main__':
main()
| 106 | 103 | 1,993 | 1,966 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
class Mod:
def __init__(self, m):
self.m = m
def add(self, a, b):
return (a + b) % self.m
def sub(self, a, b):
return (a - b) % self.m
def mul(self, a, b):
return ((a % self.m) * (b % self.m)) % self.m
def div(self, a, b):
return self.mul(a, self.pow(b, self.m - 2))
def pow(self, x, y):
if y == 0:
return 1
elif y == 1:
return x % self.m
elif y % 2 == 0:
return self.pow(x, y // 2) ** 2 % self.m
else:
return self.pow(x, y // 2) ** 2 * x % self.m
@mt
def slv(N, S):
CC = Counter()
for c in S:
CC[c] += 1
for c in CC:
CC[c] += 1
m = Mod(10**9 + 7)
return reduce(m.mul, CC.values()) - 1
def main():
N = read_int()
S = read_str()
print(slv(N, S))
if __name__ == "__main__":
main()
|
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
class Mod:
def __init__(self, m):
self.m = m
def add(self, a, b):
return (a + b) % self.m
def sub(self, a, b):
return (a - b) % self.m
def mul(self, a, b):
return ((a % self.m) * (b % self.m)) % self.m
def div(self, a, b):
return self.mul(a, self.pow(b, self.m - 2))
def pow(self, x, y):
if y == 0:
return 1
elif y == 1:
return x % self.m
elif y % 2 == 0:
return self.pow(x, y // 2) ** 2 % self.m
else:
return self.pow(x, y // 2) ** 2 * x % self.m
@mt
def slv(N, S):
CC = defaultdict(lambda: 1)
for c in S:
CC[c] += 1
m = Mod(10**9 + 7)
return reduce(m.mul, CC.values()) - 1
def main():
N = read_int()
S = read_str()
print(slv(N, S))
if __name__ == "__main__":
main()
| false | 2.830189 |
[
"- CC = Counter()",
"+ CC = defaultdict(lambda: 1)",
"- CC[c] += 1",
"- for c in CC:"
] | false | 0.077763 | 0.033403 | 2.328039 |
[
"s736849410",
"s595991483"
] |
u144913062
|
p02589
|
python
|
s315440098
|
s809226284
| 2,326 | 1,398 | 552,728 | 436,516 |
Accepted
|
Accepted
| 39.9 |
import sys
input = sys.stdin.readline
base = 1000
mod = 10**23 + 117
N = int(eval(input()))
S = [input().rstrip()[::-1] for _ in range(N)]
S.sort(key=lambda s: -len(s))
cnt = {}
ans = 0
one = [0] * 26
for s in S:
n = len(s)
if n == 1:
ans += one[ord(s[0]) - ord('a')]
continue
hashes = [0] * (n - 1)
hashes[0] = ord(s[0])
for i in range(1, n - 1):
hashes[i] = (hashes[i-1] * base + ord(s[i])) % mod
if hashes[-1] in cnt:
ans += cnt[hashes[-1]][ord(s[-1]) - ord('a')]
found = [0] * 26
found[ord(s[-1]) - ord('a')] = 1
for i in range(n - 2, 0, -1):
found[ord(s[i]) - ord('a')] = 1
if hashes[i-1] not in cnt:
cnt[hashes[i-1]] = [0] * 26
for c in range(26):
cnt[hashes[i-1]][c] += found[c]
found[ord(s[0]) - ord('a')] = 1
for c in range(26):
one[c] += found[c]
print(ans)
|
import sys
input = sys.stdin.readline
base = 30
mod = 10**17 + 3
N = int(eval(input()))
S = [input().rstrip()[::-1] for _ in range(N)]
S.sort(key=lambda s: -len(s))
cnt = {}
ans = 0
one = [0] * 26
for s in S:
n = len(s)
if n == 1:
ans += one[ord(s[0]) - ord('a')]
continue
hashes = [0] * (n - 1)
hashes[0] = ord(s[0]) - ord('a') + 1
for i in range(1, n - 1):
hashes[i] = (hashes[i-1] * base + ord(s[i]) - ord('a') + 1) % mod
if hashes[-1] in cnt:
ans += cnt[hashes[-1]][ord(s[-1]) - ord('a')]
found = [0] * 26
found[ord(s[-1]) - ord('a')] = 1
for i in range(n - 2, 0, -1):
found[ord(s[i]) - ord('a')] = 1
if hashes[i-1] not in cnt:
cnt[hashes[i-1]] = [0] * 26
for c in range(26):
cnt[hashes[i-1]][c] += found[c]
found[ord(s[0]) - ord('a')] = 1
for c in range(26):
one[c] += found[c]
print(ans)
| 35 | 35 | 930 | 956 |
import sys
input = sys.stdin.readline
base = 1000
mod = 10**23 + 117
N = int(eval(input()))
S = [input().rstrip()[::-1] for _ in range(N)]
S.sort(key=lambda s: -len(s))
cnt = {}
ans = 0
one = [0] * 26
for s in S:
n = len(s)
if n == 1:
ans += one[ord(s[0]) - ord("a")]
continue
hashes = [0] * (n - 1)
hashes[0] = ord(s[0])
for i in range(1, n - 1):
hashes[i] = (hashes[i - 1] * base + ord(s[i])) % mod
if hashes[-1] in cnt:
ans += cnt[hashes[-1]][ord(s[-1]) - ord("a")]
found = [0] * 26
found[ord(s[-1]) - ord("a")] = 1
for i in range(n - 2, 0, -1):
found[ord(s[i]) - ord("a")] = 1
if hashes[i - 1] not in cnt:
cnt[hashes[i - 1]] = [0] * 26
for c in range(26):
cnt[hashes[i - 1]][c] += found[c]
found[ord(s[0]) - ord("a")] = 1
for c in range(26):
one[c] += found[c]
print(ans)
|
import sys
input = sys.stdin.readline
base = 30
mod = 10**17 + 3
N = int(eval(input()))
S = [input().rstrip()[::-1] for _ in range(N)]
S.sort(key=lambda s: -len(s))
cnt = {}
ans = 0
one = [0] * 26
for s in S:
n = len(s)
if n == 1:
ans += one[ord(s[0]) - ord("a")]
continue
hashes = [0] * (n - 1)
hashes[0] = ord(s[0]) - ord("a") + 1
for i in range(1, n - 1):
hashes[i] = (hashes[i - 1] * base + ord(s[i]) - ord("a") + 1) % mod
if hashes[-1] in cnt:
ans += cnt[hashes[-1]][ord(s[-1]) - ord("a")]
found = [0] * 26
found[ord(s[-1]) - ord("a")] = 1
for i in range(n - 2, 0, -1):
found[ord(s[i]) - ord("a")] = 1
if hashes[i - 1] not in cnt:
cnt[hashes[i - 1]] = [0] * 26
for c in range(26):
cnt[hashes[i - 1]][c] += found[c]
found[ord(s[0]) - ord("a")] = 1
for c in range(26):
one[c] += found[c]
print(ans)
| false | 0 |
[
"-base = 1000",
"-mod = 10**23 + 117",
"+base = 30",
"+mod = 10**17 + 3",
"- hashes[0] = ord(s[0])",
"+ hashes[0] = ord(s[0]) - ord(\"a\") + 1",
"- hashes[i] = (hashes[i - 1] * base + ord(s[i])) % mod",
"+ hashes[i] = (hashes[i - 1] * base + ord(s[i]) - ord(\"a\") + 1) % mod"
] | false | 0.076612 | 0.038598 | 1.984846 |
[
"s315440098",
"s809226284"
] |
u531599639
|
p02773
|
python
|
s638186617
|
s067936632
| 789 | 501 | 32,096 | 39,840 |
Accepted
|
Accepted
| 36.5 |
N = int(eval(input()))
count = {}
for i in range(N):
s = eval(input())
count.setdefault(s, 0)
count[s] += 1
p = max(count.values())
ans = []
for k in list(count.keys()):
if count[k] == p:
ans.append(k)
ans.sort()
for a in ans:
print(a)
|
from collections import Counter
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
s.sort()
d = Counter(s)
a = 0
for v in list(d.values()):
if v>a:
a = v
for k in list(d.keys()):
if d[k]==a:
print(k)
| 14 | 12 | 258 | 208 |
N = int(eval(input()))
count = {}
for i in range(N):
s = eval(input())
count.setdefault(s, 0)
count[s] += 1
p = max(count.values())
ans = []
for k in list(count.keys()):
if count[k] == p:
ans.append(k)
ans.sort()
for a in ans:
print(a)
|
from collections import Counter
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
s.sort()
d = Counter(s)
a = 0
for v in list(d.values()):
if v > a:
a = v
for k in list(d.keys()):
if d[k] == a:
print(k)
| false | 14.285714 |
[
"-N = int(eval(input()))",
"-count = {}",
"-for i in range(N):",
"- s = eval(input())",
"- count.setdefault(s, 0)",
"- count[s] += 1",
"-p = max(count.values())",
"-ans = []",
"-for k in list(count.keys()):",
"- if count[k] == p:",
"- ans.append(k)",
"-ans.sort()",
"-for a in ans:",
"- print(a)",
"+from collections import Counter",
"+",
"+n = int(eval(input()))",
"+s = [eval(input()) for _ in range(n)]",
"+s.sort()",
"+d = Counter(s)",
"+a = 0",
"+for v in list(d.values()):",
"+ if v > a:",
"+ a = v",
"+for k in list(d.keys()):",
"+ if d[k] == a:",
"+ print(k)"
] | false | 0.045777 | 0.045934 | 0.996585 |
[
"s638186617",
"s067936632"
] |
u186838327
|
p02947
|
python
|
s917215584
|
s022793805
| 1,989 | 1,020 | 119,944 | 90,460 |
Accepted
|
Accepted
| 48.72 |
n = int(eval(input()))
l = [str(sorted(str(eval(input())))) for _ in range(n)]
d = {}
for i in range(n):
s = l[i]
# print(s)
if s in d:
d[s] += 1
else:
d[s] = 1
ans = 0
for x in list(d.values()):
ans += x*(x-1)/2
print((int(ans)))
|
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n = int(eval(input()))
l = [str(sorted(str(eval(input())))) for _ in range(n)]
d = {}
for i in range(n):
s = l[i]
# print(s)
if s in d:
d[s] += 1
else:
d[s] = 1
ans = 0
for x in list(d.values()):
ans += x*(x-1)/2
print((int(ans)))
| 19 | 21 | 252 | 321 |
n = int(eval(input()))
l = [str(sorted(str(eval(input())))) for _ in range(n)]
d = {}
for i in range(n):
s = l[i]
# print(s)
if s in d:
d[s] += 1
else:
d[s] = 1
ans = 0
for x in list(d.values()):
ans += x * (x - 1) / 2
print((int(ans)))
|
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n = int(eval(input()))
l = [str(sorted(str(eval(input())))) for _ in range(n)]
d = {}
for i in range(n):
s = l[i]
# print(s)
if s in d:
d[s] += 1
else:
d[s] = 1
ans = 0
for x in list(d.values()):
ans += x * (x - 1) / 2
print((int(ans)))
| false | 9.52381 |
[
"+import sys",
"+",
"+sys.setrecursionlimit(10**9)",
"+input = sys.stdin.readline"
] | false | 0.006441 | 0.033257 | 0.193669 |
[
"s917215584",
"s022793805"
] |
u814265211
|
p03416
|
python
|
s432069919
|
s816383379
| 158 | 82 | 3,864 | 3,864 |
Accepted
|
Accepted
| 48.1 |
# 回文かどうかを調べる関数
def is_palindrome(s: str) -> bool:
return s[:len(s)//2] == "".join(list(reversed(s[-1*(len(s)//2):])))
a, b = [int(i) for i in input().split()]
print(([is_palindrome(str(n)) for n in range(a, b+1)].count(True)))
|
def is_palindrome(s: str) -> bool:
return s[:len(s)//2] == s[-1*(len(s)//2):][::-1]
a, b = [int(i) for i in input().split()]
print(([is_palindrome(str(n)) for n in range(a, b+1)].count(True)))
| 7 | 6 | 236 | 201 |
# 回文かどうかを調べる関数
def is_palindrome(s: str) -> bool:
return s[: len(s) // 2] == "".join(list(reversed(s[-1 * (len(s) // 2) :])))
a, b = [int(i) for i in input().split()]
print(([is_palindrome(str(n)) for n in range(a, b + 1)].count(True)))
|
def is_palindrome(s: str) -> bool:
return s[: len(s) // 2] == s[-1 * (len(s) // 2) :][::-1]
a, b = [int(i) for i in input().split()]
print(([is_palindrome(str(n)) for n in range(a, b + 1)].count(True)))
| false | 14.285714 |
[
"-# 回文かどうかを調べる関数",
"- return s[: len(s) // 2] == \"\".join(list(reversed(s[-1 * (len(s) // 2) :])))",
"+ return s[: len(s) // 2] == s[-1 * (len(s) // 2) :][::-1]"
] | false | 0.072342 | 0.048049 | 1.505603 |
[
"s432069919",
"s816383379"
] |
u150984829
|
p00109
|
python
|
s576079954
|
s255199840
| 40 | 20 | 6,612 | 5,604 |
Accepted
|
Accepted
| 50 |
import re
class c:
def __init__(self,value):self.x=value
def __str__(self):return str(self.x)
def __add__(self,value):return c(self.x+value.x)
def __sub__(self,value):return c(self.x-value.x)
def __mul__(self,value):return c(self.x*value.x)
def __truediv__(self,value):return c(int(self.x/value.x))
for i in[0]*int(eval(input())):print((eval(re.sub(r'(\d+)',r'c(\1)',input()[:-1]))))
|
r={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
for _ in[0]*int(eval(input())):
L=[];t=''
for e in input()[:-1]:
if e.isdigit():t+=e
else:
if t:L+=[t];t=''
L+=e
if t:L+=[t]
P,S=[],[]
for i in L:
if"("==i:S+=i
elif")"==i:
while"("!=S[-1]:P+=S.pop()
S.pop()
elif i in r:
while S and r[S[-1]]>=r[i]:P+=S.pop()
S+=i
else:P+=[i]
while S:P+=S.pop()
for x in P:
if x in'+-*/':t=S.pop();S+=[str(int(eval(S.pop()+x+t)))]
else:S+=[x]
print((*S))
| 9 | 24 | 390 | 485 |
import re
class c:
def __init__(self, value):
self.x = value
def __str__(self):
return str(self.x)
def __add__(self, value):
return c(self.x + value.x)
def __sub__(self, value):
return c(self.x - value.x)
def __mul__(self, value):
return c(self.x * value.x)
def __truediv__(self, value):
return c(int(self.x / value.x))
for i in [0] * int(eval(input())):
print((eval(re.sub(r"(\d+)", r"c(\1)", input()[:-1]))))
|
r = {"*": 2, "/": 2, "+": 1, "-": 1, "(": 0, ")": 0}
for _ in [0] * int(eval(input())):
L = []
t = ""
for e in input()[:-1]:
if e.isdigit():
t += e
else:
if t:
L += [t]
t = ""
L += e
if t:
L += [t]
P, S = [], []
for i in L:
if "(" == i:
S += i
elif ")" == i:
while "(" != S[-1]:
P += S.pop()
S.pop()
elif i in r:
while S and r[S[-1]] >= r[i]:
P += S.pop()
S += i
else:
P += [i]
while S:
P += S.pop()
for x in P:
if x in "+-*/":
t = S.pop()
S += [str(int(eval(S.pop() + x + t)))]
else:
S += [x]
print((*S))
| false | 62.5 |
[
"-import re",
"-",
"-",
"-class c:",
"- def __init__(self, value):",
"- self.x = value",
"-",
"- def __str__(self):",
"- return str(self.x)",
"-",
"- def __add__(self, value):",
"- return c(self.x + value.x)",
"-",
"- def __sub__(self, value):",
"- return c(self.x - value.x)",
"-",
"- def __mul__(self, value):",
"- return c(self.x * value.x)",
"-",
"- def __truediv__(self, value):",
"- return c(int(self.x / value.x))",
"-",
"-",
"-for i in [0] * int(eval(input())):",
"- print((eval(re.sub(r\"(\\d+)\", r\"c(\\1)\", input()[:-1]))))",
"+r = {\"*\": 2, \"/\": 2, \"+\": 1, \"-\": 1, \"(\": 0, \")\": 0}",
"+for _ in [0] * int(eval(input())):",
"+ L = []",
"+ t = \"\"",
"+ for e in input()[:-1]:",
"+ if e.isdigit():",
"+ t += e",
"+ else:",
"+ if t:",
"+ L += [t]",
"+ t = \"\"",
"+ L += e",
"+ if t:",
"+ L += [t]",
"+ P, S = [], []",
"+ for i in L:",
"+ if \"(\" == i:",
"+ S += i",
"+ elif \")\" == i:",
"+ while \"(\" != S[-1]:",
"+ P += S.pop()",
"+ S.pop()",
"+ elif i in r:",
"+ while S and r[S[-1]] >= r[i]:",
"+ P += S.pop()",
"+ S += i",
"+ else:",
"+ P += [i]",
"+ while S:",
"+ P += S.pop()",
"+ for x in P:",
"+ if x in \"+-*/\":",
"+ t = S.pop()",
"+ S += [str(int(eval(S.pop() + x + t)))]",
"+ else:",
"+ S += [x]",
"+ print((*S))"
] | false | 0.045997 | 0.041229 | 1.115651 |
[
"s576079954",
"s255199840"
] |
u366796457
|
p02699
|
python
|
s767127820
|
s640376775
| 24 | 20 | 9,172 | 9,128 |
Accepted
|
Accepted
| 16.67 |
#cording:utf-8
S,W=list(map(int,input().split()))
if S<=W:
print("unsafe")
else:
print("safe")
|
s,w=list(map(int,input().split()))
if s<=w:
print("unsafe")
else:
print("safe")
| 8 | 5 | 102 | 86 |
# cording:utf-8
S, W = list(map(int, input().split()))
if S <= W:
print("unsafe")
else:
print("safe")
|
s, w = list(map(int, input().split()))
if s <= w:
print("unsafe")
else:
print("safe")
| false | 37.5 |
[
"-# cording:utf-8",
"-S, W = list(map(int, input().split()))",
"-if S <= W:",
"+s, w = list(map(int, input().split()))",
"+if s <= w:"
] | false | 0.070471 | 0.065236 | 1.080234 |
[
"s767127820",
"s640376775"
] |
u127499732
|
p03504
|
python
|
s304497830
|
s142663126
| 262 | 240 | 39,352 | 38,336 |
Accepted
|
Accepted
| 8.4 |
def main():
from itertools import accumulate
n, c, *stc = list(map(int, open(0).read().split()))
table = [0] * (10 ** 5 + 2)
m = list(zip(stc[::3], stc[1::3], stc[2::3]))
m.sort(key=lambda a: (a[2], a[0], a[1]))
ch_ = 0
t_ = 0
for s, t, ch in m:
if ch != ch_:
ch_ = ch
t_ = 0
if t_ == s:
table[t_ + 1] += 1
else:
table[s] += 1
table[t + 1] -= 1
t_ = t
*x, = accumulate(table)
ans = max(x)
print(ans)
if __name__ == '__main__':
main()
|
def main():
from itertools import accumulate
n, c, *stc = list(map(int, open(0).read().split()))
table = [0] * (10 ** 5 + 2)
m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1]))
ch_ = 0
t_ = 0
for s, t, ch in m:
if ch != ch_:
ch_ = ch
t_ = 0
if t_ == s:
table[t_ + 1] += 1
else:
table[s] += 1
table[t + 1] -= 1
t_ = t
*x, = accumulate(table)
ans = max(x)
print(ans)
if __name__ == '__main__':
main()
| 29 | 28 | 598 | 580 |
def main():
from itertools import accumulate
n, c, *stc = list(map(int, open(0).read().split()))
table = [0] * (10**5 + 2)
m = list(zip(stc[::3], stc[1::3], stc[2::3]))
m.sort(key=lambda a: (a[2], a[0], a[1]))
ch_ = 0
t_ = 0
for s, t, ch in m:
if ch != ch_:
ch_ = ch
t_ = 0
if t_ == s:
table[t_ + 1] += 1
else:
table[s] += 1
table[t + 1] -= 1
t_ = t
(*x,) = accumulate(table)
ans = max(x)
print(ans)
if __name__ == "__main__":
main()
|
def main():
from itertools import accumulate
n, c, *stc = list(map(int, open(0).read().split()))
table = [0] * (10**5 + 2)
m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1]))
ch_ = 0
t_ = 0
for s, t, ch in m:
if ch != ch_:
ch_ = ch
t_ = 0
if t_ == s:
table[t_ + 1] += 1
else:
table[s] += 1
table[t + 1] -= 1
t_ = t
(*x,) = accumulate(table)
ans = max(x)
print(ans)
if __name__ == "__main__":
main()
| false | 3.448276 |
[
"- m = list(zip(stc[::3], stc[1::3], stc[2::3]))",
"- m.sort(key=lambda a: (a[2], a[0], a[1]))",
"+ m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1]))"
] | false | 0.054797 | 0.145268 | 0.377215 |
[
"s304497830",
"s142663126"
] |
u415905784
|
p03816
|
python
|
s101309920
|
s835835912
| 57 | 50 | 22,252 | 22,252 |
Accepted
|
Accepted
| 12.28 |
N = int(eval(input()))
A = list(map(int, input().split()))
m = {}
eat = 1
for a in A:
if a in m:
eat += 1
else:
m[a] = 1
print((N - 2 * (eat // 2)))
|
N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
d[a] = 1
print((len(d) - (0 if len(d) % 2 else 1)))
| 10 | 6 | 155 | 124 |
N = int(eval(input()))
A = list(map(int, input().split()))
m = {}
eat = 1
for a in A:
if a in m:
eat += 1
else:
m[a] = 1
print((N - 2 * (eat // 2)))
|
N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
d[a] = 1
print((len(d) - (0 if len(d) % 2 else 1)))
| false | 40 |
[
"-m = {}",
"-eat = 1",
"+d = {}",
"- if a in m:",
"- eat += 1",
"- else:",
"- m[a] = 1",
"-print((N - 2 * (eat // 2)))",
"+ d[a] = 1",
"+print((len(d) - (0 if len(d) % 2 else 1)))"
] | false | 0.079167 | 0.079973 | 0.989923 |
[
"s101309920",
"s835835912"
] |
u145950990
|
p02885
|
python
|
s373460524
|
s283647493
| 19 | 17 | 3,064 | 2,940 |
Accepted
|
Accepted
| 10.53 |
a,b=list(map(int, input().split()))
print((max(a-2*b,0)))
|
a,b = list(map(int,input().split()))
print((max(0,a-b*2)))
| 3 | 2 | 52 | 51 |
a, b = list(map(int, input().split()))
print((max(a - 2 * b, 0)))
|
a, b = list(map(int, input().split()))
print((max(0, a - b * 2)))
| false | 33.333333 |
[
"-print((max(a - 2 * b, 0)))",
"+print((max(0, a - b * 2)))"
] | false | 0.050377 | 0.068958 | 0.730549 |
[
"s373460524",
"s283647493"
] |
u284744415
|
p02899
|
python
|
s159022438
|
s036806989
| 402 | 190 | 24,248 | 24,248 |
Accepted
|
Accepted
| 52.74 |
n = int(input())
a = [(int(a), num) for a, num in zip(input().split(" "), list(range(1,n + 1)))]
a.sort()
m = len(a)
for i in range(m):
print(a[i][1],end="")
if(i + 1 < m):
print(" ",end="")
print()
|
n = int(eval(input()))
a = sorted([(int(a), num) for a, num in zip(input().split(" "), list(range(1,n + 1)))])
print((" ".join([str(x[1]) for x in a])))
| 9 | 3 | 222 | 151 |
n = int(input())
a = [(int(a), num) for a, num in zip(input().split(" "), list(range(1, n + 1)))]
a.sort()
m = len(a)
for i in range(m):
print(a[i][1], end="")
if i + 1 < m:
print(" ", end="")
print()
|
n = int(eval(input()))
a = sorted([(int(a), num) for a, num in zip(input().split(" "), list(range(1, n + 1)))])
print((" ".join([str(x[1]) for x in a])))
| false | 66.666667 |
[
"-n = int(input())",
"-a = [(int(a), num) for a, num in zip(input().split(\" \"), list(range(1, n + 1)))]",
"-a.sort()",
"-m = len(a)",
"-for i in range(m):",
"- print(a[i][1], end=\"\")",
"- if i + 1 < m:",
"- print(\" \", end=\"\")",
"-print()",
"+n = int(eval(input()))",
"+a = sorted([(int(a), num) for a, num in zip(input().split(\" \"), list(range(1, n + 1)))])",
"+print((\" \".join([str(x[1]) for x in a])))"
] | false | 0.043503 | 0.035868 | 1.21287 |
[
"s159022438",
"s036806989"
] |
u261103969
|
p02622
|
python
|
s830080976
|
s575996573
| 96 | 60 | 68,152 | 9,376 |
Accepted
|
Accepted
| 37.5 |
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
s = eval(input())
t = eval(input())
ans = 0
for ch1, ch2 in zip(s, t):
if ch1 != ch2:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
s = eval(input())
t = eval(input())
ans = 0
for char_s, char_t in zip(s, t):
if char_s != char_t:
ans += 1
print(ans)
| 22 | 9 | 321 | 127 |
import sys
readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)
def main():
s = eval(input())
t = eval(input())
ans = 0
for ch1, ch2 in zip(s, t):
if ch1 != ch2:
ans += 1
print(ans)
if __name__ == "__main__":
main()
|
s = eval(input())
t = eval(input())
ans = 0
for char_s, char_t in zip(s, t):
if char_s != char_t:
ans += 1
print(ans)
| false | 59.090909 |
[
"-import sys",
"-",
"-readline = sys.stdin.readline",
"-MOD = 10**9 + 7",
"-INF = float(\"INF\")",
"-sys.setrecursionlimit(10**5)",
"-",
"-",
"-def main():",
"- s = eval(input())",
"- t = eval(input())",
"- ans = 0",
"- for ch1, ch2 in zip(s, t):",
"- if ch1 != ch2:",
"- ans += 1",
"- print(ans)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+s = eval(input())",
"+t = eval(input())",
"+ans = 0",
"+for char_s, char_t in zip(s, t):",
"+ if char_s != char_t:",
"+ ans += 1",
"+print(ans)"
] | false | 0.039988 | 0.072847 | 0.548925 |
[
"s830080976",
"s575996573"
] |
u556594202
|
p03031
|
python
|
s956295063
|
s235625272
| 168 | 50 | 27,040 | 8,736 |
Accepted
|
Accepted
| 70.24 |
import numpy as np
N,M=list(map(int,input().split()))
ks=np.array([[int(i) for i in input().split()] for _ in range(M)])
p=list(map(int,input().split()))
ans=0
for i in range(2**N):
# swにスイッチのオンオフを記録
sw=[0]*N
for j in range(N):
if (i>>j)&1:
sw[j]=1
count=0
for denkyu_no in range(M):
if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
count +=1
if count==M:
ans+=1
print(ans)
|
n,m = list(map(int,input().split()))
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = list(map(int,input().split()))
ans=0
for i in range(2**n):
sw=[]
on=0
for j in range(n):
sw.append(i>>j & 1)
for k in range(m):
if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
on +=1
if on==m:
ans +=1
print(ans)
| 24 | 16 | 505 | 397 |
import numpy as np
N, M = list(map(int, input().split()))
ks = np.array([[int(i) for i in input().split()] for _ in range(M)])
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
# swにスイッチのオンオフを記録
sw = [0] * N
for j in range(N):
if (i >> j) & 1:
sw[j] = 1
count = 0
for denkyu_no in range(M):
if (
sum([sw[ks[denkyu_no][j + 1] - 1] for j in range(ks[denkyu_no][0])]) % 2
== p[denkyu_no]
):
count += 1
if count == M:
ans += 1
print(ans)
|
n, m = list(map(int, input().split()))
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
sw = []
on = 0
for j in range(n):
sw.append(i >> j & 1)
for k in range(m):
if (sum([sw[ks[k][j + 1] - 1] for j in range(ks[k][0])])) % 2 == p[k]:
on += 1
if on == m:
ans += 1
print(ans)
| false | 33.333333 |
[
"-import numpy as np",
"-",
"-N, M = list(map(int, input().split()))",
"-ks = np.array([[int(i) for i in input().split()] for _ in range(M)])",
"+n, m = list(map(int, input().split()))",
"+ks = [[int(i) for i in input().split()] for _ in range(m)]",
"-for i in range(2**N):",
"- # swにスイッチのオンオフを記録",
"- sw = [0] * N",
"- for j in range(N):",
"- if (i >> j) & 1:",
"- sw[j] = 1",
"- count = 0",
"- for denkyu_no in range(M):",
"- if (",
"- sum([sw[ks[denkyu_no][j + 1] - 1] for j in range(ks[denkyu_no][0])]) % 2",
"- == p[denkyu_no]",
"- ):",
"- count += 1",
"- if count == M:",
"+for i in range(2**n):",
"+ sw = []",
"+ on = 0",
"+ for j in range(n):",
"+ sw.append(i >> j & 1)",
"+ for k in range(m):",
"+ if (sum([sw[ks[k][j + 1] - 1] for j in range(ks[k][0])])) % 2 == p[k]:",
"+ on += 1",
"+ if on == m:"
] | false | 0.168534 | 0.035402 | 4.760519 |
[
"s956295063",
"s235625272"
] |
u175111751
|
p02413
|
python
|
s267904831
|
s324396883
| 30 | 20 | 7,632 | 7,624 |
Accepted
|
Accepted
| 33.33 |
r, c = list(map(int, input().split()))
a = [0]*(c+1)
for _ in range(r):
v = list(map(int, input().split()))
v.append(sum(v))
print((*v))
a = [x+y for x, y in zip(a, v)]
print((*a))
|
r, c = list(map(int, input().split()))
a = [0]*(c+1)
for _ in range(r):
v = list(map(int, input().split()))
s = 0
for i, e in enumerate(v):
s+=e
a[i]+=e
v.append(s)
print((*v))
a[-1]+=s
print((*a))
| 8 | 12 | 193 | 238 |
r, c = list(map(int, input().split()))
a = [0] * (c + 1)
for _ in range(r):
v = list(map(int, input().split()))
v.append(sum(v))
print((*v))
a = [x + y for x, y in zip(a, v)]
print((*a))
|
r, c = list(map(int, input().split()))
a = [0] * (c + 1)
for _ in range(r):
v = list(map(int, input().split()))
s = 0
for i, e in enumerate(v):
s += e
a[i] += e
v.append(s)
print((*v))
a[-1] += s
print((*a))
| false | 33.333333 |
[
"- v.append(sum(v))",
"+ s = 0",
"+ for i, e in enumerate(v):",
"+ s += e",
"+ a[i] += e",
"+ v.append(s)",
"- a = [x + y for x, y in zip(a, v)]",
"+ a[-1] += s"
] | false | 0.034578 | 0.040121 | 0.861841 |
[
"s267904831",
"s324396883"
] |
u427344224
|
p03164
|
python
|
s420472821
|
s400088823
| 471 | 369 | 97,020 | 50,080 |
Accepted
|
Accepted
| 21.66 |
N, W = list(map(int, input().split()))
goods = [list(map(int, input().split())) for i in range(N)]
v_sum = sum([i[1] for i in goods])
dp = [float("inf") for i in range(v_sum + 1)]
dp[0] = 0
for i in range(N):
for j in range(v_sum, -1, -1):
dp[j] = min(dp[j - goods[i][1]] + goods[i][0], dp[j])
for i in range(v_sum, -1, -1):
if dp[i] <= W:
print(i)
break
|
N, W = list(map(int, input().split()))
items = [list(map(int, input().split())) for _ in range(N)]
v_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [inf for _ in range(v_sum + 1)]
dp[0] = 0
for i in range(N):
for j in range(v_sum, -1, -1):
if dp[j] > dp[j - items[i][1]] + items[i][0]:
dp[j] = dp[j - items[i][1]] + items[i][0]
for i in range(v_sum, -1, -1):
if dp[i] <= W:
print(i)
exit()
| 13 | 18 | 394 | 465 |
N, W = list(map(int, input().split()))
goods = [list(map(int, input().split())) for i in range(N)]
v_sum = sum([i[1] for i in goods])
dp = [float("inf") for i in range(v_sum + 1)]
dp[0] = 0
for i in range(N):
for j in range(v_sum, -1, -1):
dp[j] = min(dp[j - goods[i][1]] + goods[i][0], dp[j])
for i in range(v_sum, -1, -1):
if dp[i] <= W:
print(i)
break
|
N, W = list(map(int, input().split()))
items = [list(map(int, input().split())) for _ in range(N)]
v_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [inf for _ in range(v_sum + 1)]
dp[0] = 0
for i in range(N):
for j in range(v_sum, -1, -1):
if dp[j] > dp[j - items[i][1]] + items[i][0]:
dp[j] = dp[j - items[i][1]] + items[i][0]
for i in range(v_sum, -1, -1):
if dp[i] <= W:
print(i)
exit()
| false | 27.777778 |
[
"-goods = [list(map(int, input().split())) for i in range(N)]",
"-v_sum = sum([i[1] for i in goods])",
"-dp = [float(\"inf\") for i in range(v_sum + 1)]",
"+items = [list(map(int, input().split())) for _ in range(N)]",
"+v_sum = sum([item[1] for item in items])",
"+inf = float(\"inf\")",
"+dp = [inf for _ in range(v_sum + 1)]",
"- dp[j] = min(dp[j - goods[i][1]] + goods[i][0], dp[j])",
"+ if dp[j] > dp[j - items[i][1]] + items[i][0]:",
"+ dp[j] = dp[j - items[i][1]] + items[i][0]",
"- break",
"+ exit()"
] | false | 0.037662 | 0.041211 | 0.913886 |
[
"s420472821",
"s400088823"
] |
u506132575
|
p00072
|
python
|
s932958058
|
s834554713
| 280 | 140 | 4,876 | 4,884 |
Accepted
|
Accepted
| 50 |
def solve(nu,mu,du):
E = []
vs = [False]*nu
vs[0] = True
while True:
min_dist,ind = float("inf"),float("inf")
for i in range(len(du)):
if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
E.append(min_dist)
vs[pf] = vs[pt] = True
du.pop(ind)
if all(vs):
break
for e in du:
if vs[e[0]] and vs[e[1]]:
du.remove(e)
print(sum(E)/100 - len(E))
while True:
n = eval(input())
if n == 0:
exit()
m = eval(input())
data = []
for i in range(m):
data.append( list(map(int,input().split(","))) )
solve(n,m,data)
|
def solve(nu,mu,du):
E = []
vs = [False]*nu
vs[0] = True
while True:
min_dist,ind = float("inf"),float("inf")
for i in range(len(du)):
if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
E.append(min_dist)
vs[pf] = vs[pt] = True
du.pop(ind)
if all(vs):
break
for i in range(len(du)):
try:
if vs[du[i][0]] and vs[du[i][1]]:
du.pop(i)
except:
pass
print(sum(E)/100 - len(E))
while True:
n = eval(input())
if n == 0:
exit()
m = eval(input())
data = []
for i in range(m):
data.append( list(map(int,input().split(","))) )
solve(n,m,data)
| 29 | 34 | 806 | 897 |
def solve(nu, mu, du):
E = []
vs = [False] * nu
vs[0] = True
while True:
min_dist, ind = float("inf"), float("inf")
for i in range(len(du)):
if (
(vs[du[i][0]] and not vs[du[i][1]])
or (not vs[du[i][0]] and vs[du[i][1]])
) and min_dist > du[i][2]:
min_dist, ind, pf, pt = du[i][2], i, du[i][0], du[i][1]
E.append(min_dist)
vs[pf] = vs[pt] = True
du.pop(ind)
if all(vs):
break
for e in du:
if vs[e[0]] and vs[e[1]]:
du.remove(e)
print(sum(E) / 100 - len(E))
while True:
n = eval(input())
if n == 0:
exit()
m = eval(input())
data = []
for i in range(m):
data.append(list(map(int, input().split(","))))
solve(n, m, data)
|
def solve(nu, mu, du):
E = []
vs = [False] * nu
vs[0] = True
while True:
min_dist, ind = float("inf"), float("inf")
for i in range(len(du)):
if (
(vs[du[i][0]] and not vs[du[i][1]])
or (not vs[du[i][0]] and vs[du[i][1]])
) and min_dist > du[i][2]:
min_dist, ind, pf, pt = du[i][2], i, du[i][0], du[i][1]
E.append(min_dist)
vs[pf] = vs[pt] = True
du.pop(ind)
if all(vs):
break
for i in range(len(du)):
try:
if vs[du[i][0]] and vs[du[i][1]]:
du.pop(i)
except:
pass
print(sum(E) / 100 - len(E))
while True:
n = eval(input())
if n == 0:
exit()
m = eval(input())
data = []
for i in range(m):
data.append(list(map(int, input().split(","))))
solve(n, m, data)
| false | 14.705882 |
[
"- for e in du:",
"- if vs[e[0]] and vs[e[1]]:",
"- du.remove(e)",
"+ for i in range(len(du)):",
"+ try:",
"+ if vs[du[i][0]] and vs[du[i][1]]:",
"+ du.pop(i)",
"+ except:",
"+ pass"
] | false | 0.037193 | 0.065653 | 0.566508 |
[
"s932958058",
"s834554713"
] |
u285891772
|
p03450
|
python
|
s401013309
|
s725805996
| 1,037 | 943 | 113,664 | 78,720 |
Accepted
|
Accepted
| 9.06 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
N, M = MAP()
LRD = [LIST() for _ in range(M)]
graph = [[] for _ in range(N)]
for L, R, D in LRD:
graph[L-1].append((R-1, D))
graph[R-1].append((L-1, -D))
check = [1]*N
i = 0
while 1:
while check[i] == 0:
i += 1
if i == N:
print("Yes")
exit()
check[i] = 0
dis = defaultdict(int)
dis[i] = 0
q = deque([i])
while q:
p = q.popleft()
for v, dist in graph[p]:
if check[v] == 1:
check[v] = 0
dis[v] = dis[p] + dist
q.append(v)
if check[v] == 0 and dis[v] != dis[p] + dist:
print("No")
exit()
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
N, M = MAP()
graph = defaultdict(list)
for _ in range(M):
L, R, D = MAP()
graph[L-1].append((R-1, D))
graph[R-1].append((L-1, -D))
num = [None]*N
for i in range(N):
if num[i] != None:
continue
q = deque([i])
num[i] = 0
while q:
n = q.popleft()
for node, weight in graph[n]:
if num[node] == None:
num[node] = num[n] + weight
q.append(node)
elif num[node] != num[n] + weight:
print("No")
exit()
else:
print("Yes")
| 55 | 51 | 1,567 | 1,480 |
import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
gcd,
)
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def TUPLE():
return tuple(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# mod = 998244353
from decimal import *
# import numpy as np
# decimal.getcontext().prec = 10
N, M = MAP()
LRD = [LIST() for _ in range(M)]
graph = [[] for _ in range(N)]
for L, R, D in LRD:
graph[L - 1].append((R - 1, D))
graph[R - 1].append((L - 1, -D))
check = [1] * N
i = 0
while 1:
while check[i] == 0:
i += 1
if i == N:
print("Yes")
exit()
check[i] = 0
dis = defaultdict(int)
dis[i] = 0
q = deque([i])
while q:
p = q.popleft()
for v, dist in graph[p]:
if check[v] == 1:
check[v] = 0
dis[v] = dis[p] + dist
q.append(v)
if check[v] == 0 and dis[v] != dis[p] + dist:
print("No")
exit()
|
import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
gcd,
)
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def TUPLE():
return tuple(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# mod = 998244353
from decimal import *
# import numpy as np
# decimal.getcontext().prec = 10
N, M = MAP()
graph = defaultdict(list)
for _ in range(M):
L, R, D = MAP()
graph[L - 1].append((R - 1, D))
graph[R - 1].append((L - 1, -D))
num = [None] * N
for i in range(N):
if num[i] != None:
continue
q = deque([i])
num[i] = 0
while q:
n = q.popleft()
for node, weight in graph[n]:
if num[node] == None:
num[node] = num[n] + weight
q.append(node)
elif num[node] != num[n] + weight:
print("No")
exit()
else:
print("Yes")
| false | 7.272727 |
[
"-LRD = [LIST() for _ in range(M)]",
"-graph = [[] for _ in range(N)]",
"-for L, R, D in LRD:",
"+graph = defaultdict(list)",
"+for _ in range(M):",
"+ L, R, D = MAP()",
"-check = [1] * N",
"-i = 0",
"-while 1:",
"- while check[i] == 0:",
"- i += 1",
"- if i == N:",
"- print(\"Yes\")",
"- exit()",
"- check[i] = 0",
"- dis = defaultdict(int)",
"- dis[i] = 0",
"+num = [None] * N",
"+for i in range(N):",
"+ if num[i] != None:",
"+ continue",
"+ num[i] = 0",
"- p = q.popleft()",
"- for v, dist in graph[p]:",
"- if check[v] == 1:",
"- check[v] = 0",
"- dis[v] = dis[p] + dist",
"- q.append(v)",
"- if check[v] == 0 and dis[v] != dis[p] + dist:",
"+ n = q.popleft()",
"+ for node, weight in graph[n]:",
"+ if num[node] == None:",
"+ num[node] = num[n] + weight",
"+ q.append(node)",
"+ elif num[node] != num[n] + weight:",
"+else:",
"+ print(\"Yes\")"
] | false | 0.046048 | 0.048748 | 0.944612 |
[
"s401013309",
"s725805996"
] |
u808373096
|
p03854
|
python
|
s151249203
|
s837066516
| 1,847 | 1,033 | 137,088 | 134,968 |
Accepted
|
Accepted
| 44.07 |
S = list(eval(input()))
while len(S) > 0:
if ''.join(S[-5:]) == 'dream' or ''.join(S[-5:]) == 'erase':
S = S[:-5]
elif ''.join(S[-6:]) == 'eraser':
S = S[:-6]
elif ''.join(S[-7:]) == 'dreamer':
S = S[:-7]
else:
print('NO')
quit()
print('YES')
|
S = eval(input())
while len(S) > 0:
if ''.join(S[-5:]) == 'dream' or ''.join(S[-5:]) == 'erase':
S = S[:-5]
elif ''.join(S[-6:]) == 'eraser':
S = S[:-6]
elif ''.join(S[-7:]) == 'dreamer':
S = S[:-7]
else:
print('NO')
quit()
print('YES')
| 12 | 12 | 303 | 297 |
S = list(eval(input()))
while len(S) > 0:
if "".join(S[-5:]) == "dream" or "".join(S[-5:]) == "erase":
S = S[:-5]
elif "".join(S[-6:]) == "eraser":
S = S[:-6]
elif "".join(S[-7:]) == "dreamer":
S = S[:-7]
else:
print("NO")
quit()
print("YES")
|
S = eval(input())
while len(S) > 0:
if "".join(S[-5:]) == "dream" or "".join(S[-5:]) == "erase":
S = S[:-5]
elif "".join(S[-6:]) == "eraser":
S = S[:-6]
elif "".join(S[-7:]) == "dreamer":
S = S[:-7]
else:
print("NO")
quit()
print("YES")
| false | 0 |
[
"-S = list(eval(input()))",
"+S = eval(input())"
] | false | 0.077104 | 0.086093 | 0.895589 |
[
"s151249203",
"s837066516"
] |
u850491413
|
p02889
|
python
|
s336735726
|
s543593848
| 1,023 | 687 | 19,940 | 21,476 |
Accepted
|
Accepted
| 32.84 |
from scipy.sparse import csr_matrix #pypyだとエラーになるので、pythonを使うこと
from scipy.sparse.csgraph import shortest_path, floyd_warshall
import numpy as np
import sys
def input():
return sys.stdin.readline().strip()
N, M, L = list(map(int, input().split()))
A = np.zeros(M)
B = np.zeros(M)
C = np.zeros(M)
for i in range(M):
Ai, Bi, Ci = list(map(int, input().split()))
A[i] = Ai - 1
B[i] = Bi - 1
C[i] = Ci
graph = csr_matrix((C, (A, B)), shape=(N, N))
#print(graph)
dist = floyd_warshall(graph, directed=False)
graph2 = np.full((N, N), np.inf)
graph2[dist <= L] = 1
graph2 = csr_matrix(graph2)
num = floyd_warshall(graph2, directed=False)
Q = int(eval(input()))
for q in range(Q):
s, t = list(map(int, input().split()))
if num[s - 1][t - 1] < 10000000:
print((int(num[s - 1][t - 1] - 1)))
else:
print((-1))
|
from scipy.sparse import csr_matrix #pypyだとエラーになるので、pythonを使うこと
from scipy.sparse.csgraph import shortest_path, floyd_warshall
import numpy as np
import sys
def input():
return sys.stdin.readline().strip()
N, M, L = list(map(int, input().split()))
A = np.zeros(M)
B = np.zeros(M)
C = np.zeros(M)
for i in range(M):
Ai, Bi, Ci = list(map(int, input().split()))
A[i] = Ai - 1
B[i] = Bi - 1
C[i] = Ci
graph = csr_matrix((C, (A, B)), shape=(N, N))
#print(graph)
dist = floyd_warshall(graph, directed=False)
graph2 = np.full((N, N), np.inf)
graph2[dist <= L] = 1
graph2 = csr_matrix(graph2)
num = floyd_warshall(graph2, directed=False)
num = num.tolist()
Q = int(eval(input()))
for q in range(Q):
s, t = list(map(int, input().split()))
if num[s - 1][t - 1] < 10000000:
print((int(num[s - 1][t - 1] - 1)))
else:
print((-1))
| 36 | 38 | 842 | 864 |
from scipy.sparse import csr_matrix # pypyだとエラーになるので、pythonを使うこと
from scipy.sparse.csgraph import shortest_path, floyd_warshall
import numpy as np
import sys
def input():
return sys.stdin.readline().strip()
N, M, L = list(map(int, input().split()))
A = np.zeros(M)
B = np.zeros(M)
C = np.zeros(M)
for i in range(M):
Ai, Bi, Ci = list(map(int, input().split()))
A[i] = Ai - 1
B[i] = Bi - 1
C[i] = Ci
graph = csr_matrix((C, (A, B)), shape=(N, N))
# print(graph)
dist = floyd_warshall(graph, directed=False)
graph2 = np.full((N, N), np.inf)
graph2[dist <= L] = 1
graph2 = csr_matrix(graph2)
num = floyd_warshall(graph2, directed=False)
Q = int(eval(input()))
for q in range(Q):
s, t = list(map(int, input().split()))
if num[s - 1][t - 1] < 10000000:
print((int(num[s - 1][t - 1] - 1)))
else:
print((-1))
|
from scipy.sparse import csr_matrix # pypyだとエラーになるので、pythonを使うこと
from scipy.sparse.csgraph import shortest_path, floyd_warshall
import numpy as np
import sys
def input():
return sys.stdin.readline().strip()
N, M, L = list(map(int, input().split()))
A = np.zeros(M)
B = np.zeros(M)
C = np.zeros(M)
for i in range(M):
Ai, Bi, Ci = list(map(int, input().split()))
A[i] = Ai - 1
B[i] = Bi - 1
C[i] = Ci
graph = csr_matrix((C, (A, B)), shape=(N, N))
# print(graph)
dist = floyd_warshall(graph, directed=False)
graph2 = np.full((N, N), np.inf)
graph2[dist <= L] = 1
graph2 = csr_matrix(graph2)
num = floyd_warshall(graph2, directed=False)
num = num.tolist()
Q = int(eval(input()))
for q in range(Q):
s, t = list(map(int, input().split()))
if num[s - 1][t - 1] < 10000000:
print((int(num[s - 1][t - 1] - 1)))
else:
print((-1))
| false | 5.263158 |
[
"+num = num.tolist()"
] | false | 0.52416 | 0.292026 | 1.794906 |
[
"s336735726",
"s543593848"
] |
u312025627
|
p03944
|
python
|
s857721328
|
s924389159
| 204 | 188 | 41,968 | 40,688 |
Accepted
|
Accepted
| 7.84 |
def main():
W, H, N = (int(i) for i in input().split())
seen = [[True]*W for _ in range(H)]
for i in range(N):
X, Y, a = (int(i) for i in input().split())
if a == 1:
for h in range(H):
for x in range(X):
seen[h][x] = False
elif a == 2:
for h in range(H):
for x in range(X, W):
seen[h][x] = False
elif a == 3:
for w in range(W):
for y in range(Y):
seen[y][w] = False
else:
for w in range(W):
for y in range(Y, H):
seen[y][w] = False
# print(*seen, sep="\n")
ans = 0
for h in range(H):
for w in range(W):
if seen[h][w]:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
def main():
import sys
input = sys.stdin.buffer.readline
W, H, N = (int(i) for i in input().split())
XYA = [[int(i) for i in input().split()] for j in range(N)]
seen = [[True]*W for _ in range(H)]
for x, y, a in XYA:
if a == 1:
for h in range(H):
for w in range(x):
seen[h][w] = False
elif a == 2:
for h in range(H):
for w in range(x, W):
seen[h][w] = False
elif a == 3:
for h in range(y):
for w in range(W):
seen[h][w] = False
elif a == 4:
for h in range(y, H):
for w in range(W):
seen[h][w] = False
ans = 0
for h in range(H):
for w in range(W):
if seen[h][w]:
ans += 1
print(ans)
if __name__ == '__main__':
main()
| 32 | 34 | 905 | 952 |
def main():
W, H, N = (int(i) for i in input().split())
seen = [[True] * W for _ in range(H)]
for i in range(N):
X, Y, a = (int(i) for i in input().split())
if a == 1:
for h in range(H):
for x in range(X):
seen[h][x] = False
elif a == 2:
for h in range(H):
for x in range(X, W):
seen[h][x] = False
elif a == 3:
for w in range(W):
for y in range(Y):
seen[y][w] = False
else:
for w in range(W):
for y in range(Y, H):
seen[y][w] = False
# print(*seen, sep="\n")
ans = 0
for h in range(H):
for w in range(W):
if seen[h][w]:
ans += 1
print(ans)
if __name__ == "__main__":
main()
|
def main():
import sys
input = sys.stdin.buffer.readline
W, H, N = (int(i) for i in input().split())
XYA = [[int(i) for i in input().split()] for j in range(N)]
seen = [[True] * W for _ in range(H)]
for x, y, a in XYA:
if a == 1:
for h in range(H):
for w in range(x):
seen[h][w] = False
elif a == 2:
for h in range(H):
for w in range(x, W):
seen[h][w] = False
elif a == 3:
for h in range(y):
for w in range(W):
seen[h][w] = False
elif a == 4:
for h in range(y, H):
for w in range(W):
seen[h][w] = False
ans = 0
for h in range(H):
for w in range(W):
if seen[h][w]:
ans += 1
print(ans)
if __name__ == "__main__":
main()
| false | 5.882353 |
[
"+ import sys",
"+",
"+ input = sys.stdin.buffer.readline",
"+ XYA = [[int(i) for i in input().split()] for j in range(N)]",
"- for i in range(N):",
"- X, Y, a = (int(i) for i in input().split())",
"+ for x, y, a in XYA:",
"- for x in range(X):",
"- seen[h][x] = False",
"+ for w in range(x):",
"+ seen[h][w] = False",
"- for x in range(X, W):",
"- seen[h][x] = False",
"+ for w in range(x, W):",
"+ seen[h][w] = False",
"- for w in range(W):",
"- for y in range(Y):",
"- seen[y][w] = False",
"- else:",
"- for w in range(W):",
"- for y in range(Y, H):",
"- seen[y][w] = False",
"- # print(*seen, sep=\"\\n\")",
"+ for h in range(y):",
"+ for w in range(W):",
"+ seen[h][w] = False",
"+ elif a == 4:",
"+ for h in range(y, H):",
"+ for w in range(W):",
"+ seen[h][w] = False"
] | false | 0.044688 | 0.146416 | 0.305214 |
[
"s857721328",
"s924389159"
] |
u021019433
|
p03038
|
python
|
s709434983
|
s818267393
| 758 | 630 | 21,548 | 21,548 |
Accepted
|
Accepted
| 16.89 |
import heapq
from itertools import repeat, starmap
from operator import mul
R = lambda: list(map(int, input().split()))
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
b, c = R()
i = b
while i and a[0][0] < c:
x, y = a[0]
if y > i:
heapq.heapreplace(a, (x, y - i))
i = 0
else:
heapq.heappop(a)
i -= y
heapq.heappush(a, (c, b - i))
print((sum(starmap(mul, a))))
|
import heapq
from itertools import repeat, starmap
from operator import mul
R = lambda: list(map(int, input().split()))
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
b, c = R()
i = b
while i and a[0][0] < c:
x, y = a[0]
if y > i:
heapq.heapreplace(a, (x, y - i))
i = 0
else:
heapq.heappop(a)
i -= y
if i < b:
heapq.heappush(a, (c, b - i))
print((sum(starmap(mul, a))))
| 21 | 22 | 491 | 510 |
import heapq
from itertools import repeat, starmap
from operator import mul
R = lambda: list(map(int, input().split()))
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
b, c = R()
i = b
while i and a[0][0] < c:
x, y = a[0]
if y > i:
heapq.heapreplace(a, (x, y - i))
i = 0
else:
heapq.heappop(a)
i -= y
heapq.heappush(a, (c, b - i))
print((sum(starmap(mul, a))))
|
import heapq
from itertools import repeat, starmap
from operator import mul
R = lambda: list(map(int, input().split()))
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
b, c = R()
i = b
while i and a[0][0] < c:
x, y = a[0]
if y > i:
heapq.heapreplace(a, (x, y - i))
i = 0
else:
heapq.heappop(a)
i -= y
if i < b:
heapq.heappush(a, (c, b - i))
print((sum(starmap(mul, a))))
| false | 4.545455 |
[
"- heapq.heappush(a, (c, b - i))",
"+ if i < b:",
"+ heapq.heappush(a, (c, b - i))"
] | false | 0.037783 | 0.037932 | 0.996065 |
[
"s709434983",
"s818267393"
] |
u463068683
|
p02606
|
python
|
s295832376
|
s125419274
| 30 | 23 | 9,160 | 9,136 |
Accepted
|
Accepted
| 23.33 |
l,r,d = list(map(int, input().split()))
ans = 0
while l <= r:
if l%d == 0:
ans += 1
l += 1
print(ans)
|
l,r,d = list(map(int, input().split()))
ans = r//d - (l-1)//d
print(ans)
| 8 | 3 | 111 | 68 |
l, r, d = list(map(int, input().split()))
ans = 0
while l <= r:
if l % d == 0:
ans += 1
l += 1
print(ans)
|
l, r, d = list(map(int, input().split()))
ans = r // d - (l - 1) // d
print(ans)
| false | 62.5 |
[
"-ans = 0",
"-while l <= r:",
"- if l % d == 0:",
"- ans += 1",
"- l += 1",
"+ans = r // d - (l - 1) // d"
] | false | 0.038886 | 0.110694 | 0.351293 |
[
"s295832376",
"s125419274"
] |
u945181840
|
p03201
|
python
|
s463145120
|
s856233297
| 1,508 | 653 | 33,712 | 33,968 |
Accepted
|
Accepted
| 56.7 |
import sys
from collections import Counter
read = sys.stdin.read
readline = sys.stdin.readline
N, *A = list(map(int, read().split()))
A.sort()
a = Counter(A)
answer = 0
# 可能な最大の2冪
limit = 1 << ((2 * 10 ** 9 + 1).bit_length() - 1)
while A:
n = A.pop()
if a[n] == 0:
continue
a[n] -= 1
s = limit
while n < s:
b = s - n
if a[b] > 0:
answer += 1
a[b] -= 1
break
s //= 2
print(answer)
|
import sys
from collections import Counter
read = sys.stdin.read
readline = sys.stdin.readline
N, *A = list(map(int, read().split()))
A.sort()
a = Counter(A)
answer = 0
while A:
n = A.pop()
if a[n] == 0:
continue
a[n] -= 1
# 実現可能な最大の2冪
s = 1 << (2 * n).bit_length()
while n < s:
b = s - n
if a[b] > 0:
answer += 1
a[b] -= 1
break
s //= 2
print(answer)
| 30 | 30 | 497 | 474 |
import sys
from collections import Counter
read = sys.stdin.read
readline = sys.stdin.readline
N, *A = list(map(int, read().split()))
A.sort()
a = Counter(A)
answer = 0
# 可能な最大の2冪
limit = 1 << ((2 * 10**9 + 1).bit_length() - 1)
while A:
n = A.pop()
if a[n] == 0:
continue
a[n] -= 1
s = limit
while n < s:
b = s - n
if a[b] > 0:
answer += 1
a[b] -= 1
break
s //= 2
print(answer)
|
import sys
from collections import Counter
read = sys.stdin.read
readline = sys.stdin.readline
N, *A = list(map(int, read().split()))
A.sort()
a = Counter(A)
answer = 0
while A:
n = A.pop()
if a[n] == 0:
continue
a[n] -= 1
# 実現可能な最大の2冪
s = 1 << (2 * n).bit_length()
while n < s:
b = s - n
if a[b] > 0:
answer += 1
a[b] -= 1
break
s //= 2
print(answer)
| false | 0 |
[
"-# 可能な最大の2冪",
"-limit = 1 << ((2 * 10**9 + 1).bit_length() - 1)",
"- s = limit",
"+ # 実現可能な最大の2冪",
"+ s = 1 << (2 * n).bit_length()"
] | false | 0.154103 | 0.006827 | 22.57102 |
[
"s463145120",
"s856233297"
] |
u912237403
|
p00159
|
python
|
s853550074
|
s994573117
| 30 | 20 | 4,576 | 4,252 |
Accepted
|
Accepted
| 33.33 |
import math
while 1:
n = eval(input())
if n==0: break
x = []
for _ in [0]*n:
i,h,w = list(map(int, input().split()))
x.append([i,abs(w/math.pow((h/100.0),2)-22)])
x = sorted(x, key = lambda a: (a[1], a[0]))
print(x[0][0])
|
while 1:
n = eval(input())
if n==0: break
a = 1e9
b = 1e9
for _ in [0]*n:
i,h,w = list(map(int, input().split()))
tmp = abs(w/(h/100.0)**2-22)
if a>=tmp: a,b = tmp,i
print(b)
| 10 | 10 | 241 | 198 |
import math
while 1:
n = eval(input())
if n == 0:
break
x = []
for _ in [0] * n:
i, h, w = list(map(int, input().split()))
x.append([i, abs(w / math.pow((h / 100.0), 2) - 22)])
x = sorted(x, key=lambda a: (a[1], a[0]))
print(x[0][0])
|
while 1:
n = eval(input())
if n == 0:
break
a = 1e9
b = 1e9
for _ in [0] * n:
i, h, w = list(map(int, input().split()))
tmp = abs(w / (h / 100.0) ** 2 - 22)
if a >= tmp:
a, b = tmp, i
print(b)
| false | 0 |
[
"-import math",
"-",
"- x = []",
"+ a = 1e9",
"+ b = 1e9",
"- x.append([i, abs(w / math.pow((h / 100.0), 2) - 22)])",
"- x = sorted(x, key=lambda a: (a[1], a[0]))",
"- print(x[0][0])",
"+ tmp = abs(w / (h / 100.0) ** 2 - 22)",
"+ if a >= tmp:",
"+ a, b = tmp, i",
"+ print(b)"
] | false | 0.114975 | 0.052283 | 2.199111 |
[
"s853550074",
"s994573117"
] |
u832152513
|
p03419
|
python
|
s807983708
|
s599204538
| 163 | 62 | 38,256 | 61,812 |
Accepted
|
Accepted
| 61.96 |
n, m = list(map(int, input().split()))
if 2 <= n:
n -= 2
if 2 <= m:
m -= 2
print((n * m))
|
n, m = list(map(int, input().split()))
print((abs((n-2) * (m-2))))
| 8 | 3 | 102 | 61 |
n, m = list(map(int, input().split()))
if 2 <= n:
n -= 2
if 2 <= m:
m -= 2
print((n * m))
|
n, m = list(map(int, input().split()))
print((abs((n - 2) * (m - 2))))
| false | 62.5 |
[
"-if 2 <= n:",
"- n -= 2",
"-if 2 <= m:",
"- m -= 2",
"-print((n * m))",
"+print((abs((n - 2) * (m - 2))))"
] | false | 0.044346 | 0.036578 | 1.212371 |
[
"s807983708",
"s599204538"
] |
u597374218
|
p03250
|
python
|
s765485041
|
s700566101
| 20 | 18 | 3,060 | 2,940 |
Accepted
|
Accepted
| 10 |
l=list(map(int,input().split()))
print((sum(l)+max(l)*9))
|
print((eval('+'.join(sorted(eval(input())))+'*10')))
| 2 | 1 | 56 | 44 |
l = list(map(int, input().split()))
print((sum(l) + max(l) * 9))
|
print((eval("+".join(sorted(eval(input()))) + "*10")))
| false | 50 |
[
"-l = list(map(int, input().split()))",
"-print((sum(l) + max(l) * 9))",
"+print((eval(\"+\".join(sorted(eval(input()))) + \"*10\")))"
] | false | 0.037865 | 0.036657 | 1.032972 |
[
"s765485041",
"s700566101"
] |
u391731808
|
p03722
|
python
|
s112280089
|
s050491808
| 905 | 790 | 4,468 | 4,440 |
Accepted
|
Accepted
| 12.71 |
N,M = list(map(int,input().split()))
ABC = [list(map(int,input().split())) for _ in [0]*M]
E = [{} for _ in [0]*N]
Eb = [{} for _ in [0]*N]
for a,b,c in ABC:
E[a-1][b-1] = -c
Eb[b-1][a-1] = -c
#0 -> N-1 経路上にない頂点を除く
V1 = [False]*N
V1[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
for j in E[i]:
if V1[j]:continue
qa(j)
V1[j]=True
V2 = [False]*N
V2[-1] = True
qa(N-1)
while q:
i = qp()
for j in Eb[i]:
if V2[j] or not V1[j]:continue
qa(j)
V2[j]=True
for i in range(N):
if V1[i] and V2[i]:continue
for j in Eb[i]:
E[j].pop(i)
INFTY = 10**18
d = [INFTY]*N
d[0] = 0
def update():
done = [False]*N
done[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
di = d[i]
for j,c in list(E[i].items()):
d[j] = min(d[j],d[i]+c)
if not done[j]:
qa(j)
done[j] = True
for _ in range(N-1):update()
dc = d[:]
update()
if dc!=d:
print("inf")
else:
print((-d[-1]))
|
def main():
N,M = list(map(int,input().split()))
ABC = [list(map(int,input().split())) for _ in [0]*M]
E = [{} for _ in [0]*N]
Eb = [{} for _ in [0]*N]
for a,b,c in ABC:
E[a-1][b-1] = -c
Eb[b-1][a-1] = -c
#0 -> N-1 経路上にない頂点を除く
V1 = [False]*N
V1[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
for j in E[i]:
if V1[j]:continue
qa(j)
V1[j]=True
V2 = [False]*N
V2[-1] = True
qa(N-1)
while q:
i = qp()
for j in Eb[i]:
if V2[j] or not V1[j]:continue
qa(j)
V2[j]=True
for i in range(N):
if V1[i] and V2[i]:continue
for j in Eb[i]:
E[j].pop(i)
INFTY = 10**18
d = [INFTY]*N
d[0] = 0
def update():
done = [False]*N
done[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
di = d[i]
for j,c in list(E[i].items()):
d[j] = min(d[j],d[i]+c)
if not done[j]:
qa(j)
done[j] = True
for _ in range(N-1):update()
dc = d[:]
update()
if dc!=d:
print("inf")
else:
print((-d[-1]))
main()
| 61 | 63 | 1,134 | 1,363 |
N, M = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in [0] * M]
E = [{} for _ in [0] * N]
Eb = [{} for _ in [0] * N]
for a, b, c in ABC:
E[a - 1][b - 1] = -c
Eb[b - 1][a - 1] = -c
# 0 -> N-1 経路上にない頂点を除く
V1 = [False] * N
V1[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
for j in E[i]:
if V1[j]:
continue
qa(j)
V1[j] = True
V2 = [False] * N
V2[-1] = True
qa(N - 1)
while q:
i = qp()
for j in Eb[i]:
if V2[j] or not V1[j]:
continue
qa(j)
V2[j] = True
for i in range(N):
if V1[i] and V2[i]:
continue
for j in Eb[i]:
E[j].pop(i)
INFTY = 10**18
d = [INFTY] * N
d[0] = 0
def update():
done = [False] * N
done[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
di = d[i]
for j, c in list(E[i].items()):
d[j] = min(d[j], d[i] + c)
if not done[j]:
qa(j)
done[j] = True
for _ in range(N - 1):
update()
dc = d[:]
update()
if dc != d:
print("inf")
else:
print((-d[-1]))
|
def main():
N, M = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in [0] * M]
E = [{} for _ in [0] * N]
Eb = [{} for _ in [0] * N]
for a, b, c in ABC:
E[a - 1][b - 1] = -c
Eb[b - 1][a - 1] = -c
# 0 -> N-1 経路上にない頂点を除く
V1 = [False] * N
V1[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
for j in E[i]:
if V1[j]:
continue
qa(j)
V1[j] = True
V2 = [False] * N
V2[-1] = True
qa(N - 1)
while q:
i = qp()
for j in Eb[i]:
if V2[j] or not V1[j]:
continue
qa(j)
V2[j] = True
for i in range(N):
if V1[i] and V2[i]:
continue
for j in Eb[i]:
E[j].pop(i)
INFTY = 10**18
d = [INFTY] * N
d[0] = 0
def update():
done = [False] * N
done[0] = True
q = [0]
qp = q.pop
qa = q.append
while q:
i = qp()
di = d[i]
for j, c in list(E[i].items()):
d[j] = min(d[j], d[i] + c)
if not done[j]:
qa(j)
done[j] = True
for _ in range(N - 1):
update()
dc = d[:]
update()
if dc != d:
print("inf")
else:
print((-d[-1]))
main()
| false | 3.174603 |
[
"-N, M = list(map(int, input().split()))",
"-ABC = [list(map(int, input().split())) for _ in [0] * M]",
"-E = [{} for _ in [0] * N]",
"-Eb = [{} for _ in [0] * N]",
"-for a, b, c in ABC:",
"- E[a - 1][b - 1] = -c",
"- Eb[b - 1][a - 1] = -c",
"-# 0 -> N-1 経路上にない頂点を除く",
"-V1 = [False] * N",
"-V1[0] = True",
"-q = [0]",
"-qp = q.pop",
"-qa = q.append",
"-while q:",
"- i = qp()",
"- for j in E[i]:",
"- if V1[j]:",
"- continue",
"- qa(j)",
"- V1[j] = True",
"-V2 = [False] * N",
"-V2[-1] = True",
"-qa(N - 1)",
"-while q:",
"- i = qp()",
"- for j in Eb[i]:",
"- if V2[j] or not V1[j]:",
"- continue",
"- qa(j)",
"- V2[j] = True",
"-for i in range(N):",
"- if V1[i] and V2[i]:",
"- continue",
"- for j in Eb[i]:",
"- E[j].pop(i)",
"-INFTY = 10**18",
"-d = [INFTY] * N",
"-d[0] = 0",
"-",
"-",
"-def update():",
"- done = [False] * N",
"- done[0] = True",
"+def main():",
"+ N, M = list(map(int, input().split()))",
"+ ABC = [list(map(int, input().split())) for _ in [0] * M]",
"+ E = [{} for _ in [0] * N]",
"+ Eb = [{} for _ in [0] * N]",
"+ for a, b, c in ABC:",
"+ E[a - 1][b - 1] = -c",
"+ Eb[b - 1][a - 1] = -c",
"+ # 0 -> N-1 経路上にない頂点を除く",
"+ V1 = [False] * N",
"+ V1[0] = True",
"- di = d[i]",
"- for j, c in list(E[i].items()):",
"- d[j] = min(d[j], d[i] + c)",
"- if not done[j]:",
"- qa(j)",
"- done[j] = True",
"+ for j in E[i]:",
"+ if V1[j]:",
"+ continue",
"+ qa(j)",
"+ V1[j] = True",
"+ V2 = [False] * N",
"+ V2[-1] = True",
"+ qa(N - 1)",
"+ while q:",
"+ i = qp()",
"+ for j in Eb[i]:",
"+ if V2[j] or not V1[j]:",
"+ continue",
"+ qa(j)",
"+ V2[j] = True",
"+ for i in range(N):",
"+ if V1[i] and V2[i]:",
"+ continue",
"+ for j in Eb[i]:",
"+ E[j].pop(i)",
"+ INFTY = 10**18",
"+ d = [INFTY] * N",
"+ d[0] = 0",
"+",
"+ def update():",
"+ done = [False] * N",
"+ done[0] = True",
"+ q = [0]",
"+ qp = q.pop",
"+ qa = q.append",
"+ while q:",
"+ i = qp()",
"+ di = d[i]",
"+ for j, c in list(E[i].items()):",
"+ d[j] = min(d[j], d[i] + c)",
"+ if not done[j]:",
"+ qa(j)",
"+ done[j] = True",
"+",
"+ for _ in range(N - 1):",
"+ update()",
"+ dc = d[:]",
"+ update()",
"+ if dc != d:",
"+ print(\"inf\")",
"+ else:",
"+ print((-d[-1]))",
"-for _ in range(N - 1):",
"- update()",
"-dc = d[:]",
"-update()",
"-if dc != d:",
"- print(\"inf\")",
"-else:",
"- print((-d[-1]))",
"+main()"
] | false | 0.045271 | 0.045191 | 1.001762 |
[
"s112280089",
"s050491808"
] |
u644907318
|
p03437
|
python
|
s870601452
|
s731618487
| 166 | 63 | 38,256 | 61,788 |
Accepted
|
Accepted
| 62.05 |
X,Y = list(map(int,input().split()))
flag = -1
if X!=Y:
for i in range(1,10**9//(X)+1):
if i*X%Y!=0:
flag = i*X
break
print(flag)
|
X,Y = list(map(int,input().split()))
if X%Y==0:
print((-1))
else:
print(X)
| 8 | 5 | 166 | 78 |
X, Y = list(map(int, input().split()))
flag = -1
if X != Y:
for i in range(1, 10**9 // (X) + 1):
if i * X % Y != 0:
flag = i * X
break
print(flag)
|
X, Y = list(map(int, input().split()))
if X % Y == 0:
print((-1))
else:
print(X)
| false | 37.5 |
[
"-flag = -1",
"-if X != Y:",
"- for i in range(1, 10**9 // (X) + 1):",
"- if i * X % Y != 0:",
"- flag = i * X",
"- break",
"-print(flag)",
"+if X % Y == 0:",
"+ print((-1))",
"+else:",
"+ print(X)"
] | false | 0.074864 | 0.036167 | 2.069955 |
[
"s870601452",
"s731618487"
] |
u476604182
|
p03291
|
python
|
s627512125
|
s822229067
| 155 | 125 | 3,188 | 3,188 |
Accepted
|
Accepted
| 19.35 |
S = eval(input())
INF = 10**9+7
dp = [0,0,0]
N = 1
for i in range(len(S)):
if S[i]=='A':
dp[0] += N
dp[0] %= INF
elif S[i]=='B':
dp[1] += dp[0]
dp[1] %= INF
elif S[i]=='C':
dp[2] += dp[1]
dp[2] %= INF
else:
a = dp[0]
b = dp[1]
dp[0] = N + dp[0]*3
dp[1] = a + dp[1]*3
dp[2] = b + dp[2]*3
dp[0] %= INF
dp[1] %= INF
dp[2] %= INF
N = (3*N)%INF
print((dp[2]%INF))
|
S = eval(input())
MOD = 10**9+7
A = 0
AB = 0
ABC = 0
cnt = 1
for c in S:
if c=='A':
A += cnt
A %= MOD
elif c=='B':
AB += A
AB %= MOD
elif c=='C':
ABC += AB
ABC %= MOD
else:
nA = 3*A+cnt
nAB = 3*AB+A
nABC = 3*ABC+AB
cnt *= 3
A,AB,ABC = nA%MOD,nAB%MOD,nABC%MOD
cnt %= MOD
print(ABC)
| 25 | 24 | 443 | 353 |
S = eval(input())
INF = 10**9 + 7
dp = [0, 0, 0]
N = 1
for i in range(len(S)):
if S[i] == "A":
dp[0] += N
dp[0] %= INF
elif S[i] == "B":
dp[1] += dp[0]
dp[1] %= INF
elif S[i] == "C":
dp[2] += dp[1]
dp[2] %= INF
else:
a = dp[0]
b = dp[1]
dp[0] = N + dp[0] * 3
dp[1] = a + dp[1] * 3
dp[2] = b + dp[2] * 3
dp[0] %= INF
dp[1] %= INF
dp[2] %= INF
N = (3 * N) % INF
print((dp[2] % INF))
|
S = eval(input())
MOD = 10**9 + 7
A = 0
AB = 0
ABC = 0
cnt = 1
for c in S:
if c == "A":
A += cnt
A %= MOD
elif c == "B":
AB += A
AB %= MOD
elif c == "C":
ABC += AB
ABC %= MOD
else:
nA = 3 * A + cnt
nAB = 3 * AB + A
nABC = 3 * ABC + AB
cnt *= 3
A, AB, ABC = nA % MOD, nAB % MOD, nABC % MOD
cnt %= MOD
print(ABC)
| false | 4 |
[
"-INF = 10**9 + 7",
"-dp = [0, 0, 0]",
"-N = 1",
"-for i in range(len(S)):",
"- if S[i] == \"A\":",
"- dp[0] += N",
"- dp[0] %= INF",
"- elif S[i] == \"B\":",
"- dp[1] += dp[0]",
"- dp[1] %= INF",
"- elif S[i] == \"C\":",
"- dp[2] += dp[1]",
"- dp[2] %= INF",
"+MOD = 10**9 + 7",
"+A = 0",
"+AB = 0",
"+ABC = 0",
"+cnt = 1",
"+for c in S:",
"+ if c == \"A\":",
"+ A += cnt",
"+ A %= MOD",
"+ elif c == \"B\":",
"+ AB += A",
"+ AB %= MOD",
"+ elif c == \"C\":",
"+ ABC += AB",
"+ ABC %= MOD",
"- a = dp[0]",
"- b = dp[1]",
"- dp[0] = N + dp[0] * 3",
"- dp[1] = a + dp[1] * 3",
"- dp[2] = b + dp[2] * 3",
"- dp[0] %= INF",
"- dp[1] %= INF",
"- dp[2] %= INF",
"- N = (3 * N) % INF",
"-print((dp[2] % INF))",
"+ nA = 3 * A + cnt",
"+ nAB = 3 * AB + A",
"+ nABC = 3 * ABC + AB",
"+ cnt *= 3",
"+ A, AB, ABC = nA % MOD, nAB % MOD, nABC % MOD",
"+ cnt %= MOD",
"+print(ABC)"
] | false | 0.036487 | 0.036523 | 0.999018 |
[
"s627512125",
"s822229067"
] |
u164727245
|
p02762
|
python
|
s022531441
|
s202350723
| 801 | 707 | 124,240 | 105,120 |
Accepted
|
Accepted
| 11.74 |
# coding: utf-8
from sys import setrecursionlimit
def dfs(node: int):
if checked[node]:
return
checked[node] = True
chain.add(node)
for n in friends[node]:
dfs(n)
def solve(*args: str) -> str:
setrecursionlimit(2 * 10 ** 9)
n, m, k = list(map(int, args[0].split()))
global friends
friends = {i: set() for i in range(n+1)}
blocked = {i: set() for i in range(n+1)}
for a, b in map(str.split, args[1:1+m]):
friends[int(a)].add(int(b))
friends[int(b)].add(int(a))
for c, d in map(str.split, args[1+m:1+m+k]):
blocked[int(c)].add(int(d))
blocked[int(d)].add(int(c))
global checked
checked = [False]*(n+1)
ret = [0]*(n+1)
for a in range(1, n+1):
if checked[a]:
continue
global chain
chain = set()
dfs(a)
count = len(chain) - 1
for i in chain:
ret[i] += count - len(chain & (friends[i] | blocked[i]))
return ' '.join(map(str, ret[1:]))
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
|
# coding: utf-8
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
friends = [set() for _ in range(n+1)]
blocked = [set() for _ in range(n+1)]
for a, b in map(str.split, args[1:1+m]):
friends[int(a)].add(int(b))
friends[int(b)].add(int(a))
for c, d in map(str.split, args[1+m:1+m+k]):
blocked[int(c)].add(int(d))
blocked[int(d)].add(int(c))
checked = set()
ret = [0]*(n+1)
for a in range(1, n+1):
if a in checked:
continue
chain = set()
stack = list(friends[a])
while stack:
b = stack.pop()
if b in checked:
continue
checked.add(b)
chain.add(b)
stack.extend(friends[b])
count = len(chain) - 1
for i in chain:
ret[i] += count - len(chain & (friends[i] | blocked[i]))
return ' '.join(map(str, ret[1:]))
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
| 50 | 45 | 1,146 | 1,066 |
# coding: utf-8
from sys import setrecursionlimit
def dfs(node: int):
if checked[node]:
return
checked[node] = True
chain.add(node)
for n in friends[node]:
dfs(n)
def solve(*args: str) -> str:
setrecursionlimit(2 * 10**9)
n, m, k = list(map(int, args[0].split()))
global friends
friends = {i: set() for i in range(n + 1)}
blocked = {i: set() for i in range(n + 1)}
for a, b in map(str.split, args[1 : 1 + m]):
friends[int(a)].add(int(b))
friends[int(b)].add(int(a))
for c, d in map(str.split, args[1 + m : 1 + m + k]):
blocked[int(c)].add(int(d))
blocked[int(d)].add(int(c))
global checked
checked = [False] * (n + 1)
ret = [0] * (n + 1)
for a in range(1, n + 1):
if checked[a]:
continue
global chain
chain = set()
dfs(a)
count = len(chain) - 1
for i in chain:
ret[i] += count - len(chain & (friends[i] | blocked[i]))
return " ".join(map(str, ret[1:]))
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
|
# coding: utf-8
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
friends = [set() for _ in range(n + 1)]
blocked = [set() for _ in range(n + 1)]
for a, b in map(str.split, args[1 : 1 + m]):
friends[int(a)].add(int(b))
friends[int(b)].add(int(a))
for c, d in map(str.split, args[1 + m : 1 + m + k]):
blocked[int(c)].add(int(d))
blocked[int(d)].add(int(c))
checked = set()
ret = [0] * (n + 1)
for a in range(1, n + 1):
if a in checked:
continue
chain = set()
stack = list(friends[a])
while stack:
b = stack.pop()
if b in checked:
continue
checked.add(b)
chain.add(b)
stack.extend(friends[b])
count = len(chain) - 1
for i in chain:
ret[i] += count - len(chain & (friends[i] | blocked[i]))
return " ".join(map(str, ret[1:]))
if __name__ == "__main__":
print((solve(*(open(0).read().splitlines()))))
| false | 10 |
[
"-from sys import setrecursionlimit",
"-",
"-",
"-def dfs(node: int):",
"- if checked[node]:",
"- return",
"- checked[node] = True",
"- chain.add(node)",
"- for n in friends[node]:",
"- dfs(n)",
"-",
"-",
"- setrecursionlimit(2 * 10**9)",
"- global friends",
"- friends = {i: set() for i in range(n + 1)}",
"- blocked = {i: set() for i in range(n + 1)}",
"+ friends = [set() for _ in range(n + 1)]",
"+ blocked = [set() for _ in range(n + 1)]",
"- global checked",
"- checked = [False] * (n + 1)",
"+ checked = set()",
"- if checked[a]:",
"+ if a in checked:",
"- global chain",
"- dfs(a)",
"+ stack = list(friends[a])",
"+ while stack:",
"+ b = stack.pop()",
"+ if b in checked:",
"+ continue",
"+ checked.add(b)",
"+ chain.add(b)",
"+ stack.extend(friends[b])"
] | false | 0.108572 | 0.036256 | 2.994611 |
[
"s022531441",
"s202350723"
] |
u803848678
|
p03838
|
python
|
s390540544
|
s920278861
| 21 | 19 | 3,064 | 3,188 |
Accepted
|
Accepted
| 9.52 |
x, y = list(map(int, input().split()))
if x*y == 0:
if x <= y:
print((abs(y-x)))
else:
print((abs(y-x)+1))
elif x*y < 0:
print((abs(x+y)+1))
else:
if x < y:
print((y-x))
else:
print((x-y+2))
|
x, y = list(map(int, input().split()))
xs = [x, -x]
ys = [y, -y]
ans = float("inf")
for i, x in enumerate(xs):
for j, y in enumerate(ys):
if x + abs(x-y) == y:
kouho = abs(x-y) + i + j
ans = min(ans, kouho)
print(ans)
| 13 | 10 | 244 | 262 |
x, y = list(map(int, input().split()))
if x * y == 0:
if x <= y:
print((abs(y - x)))
else:
print((abs(y - x) + 1))
elif x * y < 0:
print((abs(x + y) + 1))
else:
if x < y:
print((y - x))
else:
print((x - y + 2))
|
x, y = list(map(int, input().split()))
xs = [x, -x]
ys = [y, -y]
ans = float("inf")
for i, x in enumerate(xs):
for j, y in enumerate(ys):
if x + abs(x - y) == y:
kouho = abs(x - y) + i + j
ans = min(ans, kouho)
print(ans)
| false | 23.076923 |
[
"-if x * y == 0:",
"- if x <= y:",
"- print((abs(y - x)))",
"- else:",
"- print((abs(y - x) + 1))",
"-elif x * y < 0:",
"- print((abs(x + y) + 1))",
"-else:",
"- if x < y:",
"- print((y - x))",
"- else:",
"- print((x - y + 2))",
"+xs = [x, -x]",
"+ys = [y, -y]",
"+ans = float(\"inf\")",
"+for i, x in enumerate(xs):",
"+ for j, y in enumerate(ys):",
"+ if x + abs(x - y) == y:",
"+ kouho = abs(x - y) + i + j",
"+ ans = min(ans, kouho)",
"+print(ans)"
] | false | 0.039159 | 0.041993 | 0.932505 |
[
"s390540544",
"s920278861"
] |
u057109575
|
p03087
|
python
|
s077581205
|
s634804703
| 844 | 654 | 8,820 | 69,080 |
Accepted
|
Accepted
| 22.51 |
from itertools import accumulate
from operator import add
N, Q = list(map(int, input().split()))
S = eval(input())
idx_list = [1 if S[i:i + 2] == 'AC' else 0 for i in range(len(S) - 1)]
idx_list_cumsum = [0] + list(accumulate(idx_list, add))
for _ in range(Q):
l, r = list(map(int, input().split()))
print((idx_list_cumsum[r - 1] - idx_list_cumsum[l - 1]))
|
N, Q = list(map(int, input().split()))
S = eval(input())
X = [list(map(int, input().split())) for _ in range(Q)]
cnt = [0] * (N + 1)
for i in range(N - 1):
cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i]
for l, r in X:
print((cnt[r - 1] - cnt[l - 1]))
| 11 | 10 | 353 | 268 |
from itertools import accumulate
from operator import add
N, Q = list(map(int, input().split()))
S = eval(input())
idx_list = [1 if S[i : i + 2] == "AC" else 0 for i in range(len(S) - 1)]
idx_list_cumsum = [0] + list(accumulate(idx_list, add))
for _ in range(Q):
l, r = list(map(int, input().split()))
print((idx_list_cumsum[r - 1] - idx_list_cumsum[l - 1]))
|
N, Q = list(map(int, input().split()))
S = eval(input())
X = [list(map(int, input().split())) for _ in range(Q)]
cnt = [0] * (N + 1)
for i in range(N - 1):
cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i]
for l, r in X:
print((cnt[r - 1] - cnt[l - 1]))
| false | 9.090909 |
[
"-from itertools import accumulate",
"-from operator import add",
"-",
"-idx_list = [1 if S[i : i + 2] == \"AC\" else 0 for i in range(len(S) - 1)]",
"-idx_list_cumsum = [0] + list(accumulate(idx_list, add))",
"-for _ in range(Q):",
"- l, r = list(map(int, input().split()))",
"- print((idx_list_cumsum[r - 1] - idx_list_cumsum[l - 1]))",
"+X = [list(map(int, input().split())) for _ in range(Q)]",
"+cnt = [0] * (N + 1)",
"+for i in range(N - 1):",
"+ cnt[i + 1] = int(S[i] == \"A\" and S[i + 1] == \"C\") + cnt[i]",
"+for l, r in X:",
"+ print((cnt[r - 1] - cnt[l - 1]))"
] | false | 0.007809 | 0.109685 | 0.071195 |
[
"s077581205",
"s634804703"
] |
u796942881
|
p03043
|
python
|
s971812770
|
s794074649
| 20 | 17 | 3,188 | 3,060 |
Accepted
|
Accepted
| 15 |
import math
def main():
N, K = list(map(int, input().split()))
print(((max(0, N - K + 1) + sum(
max(0, N - (math.ceil(K * 0.5 ** i)) + 1) * 0.5 ** i
- max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5 ** i
for i in range(1, int(math.log2(K)) + 1 + 1))) / N))
return
main()
|
import math
def main():
N, K = list(map(int, input().split()))
print(((max(0, N - K + 1) + sum(
max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i
- max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i
for i in range(1, len(bin(K)) - 2 + 1 + 1))) / N))
return
main()
| 13 | 13 | 321 | 335 |
import math
def main():
N, K = list(map(int, input().split()))
print(
(
(
max(0, N - K + 1)
+ sum(
max(0, N - (math.ceil(K * 0.5**i)) + 1) * 0.5**i
- max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5**i
for i in range(1, int(math.log2(K)) + 1 + 1)
)
)
/ N
)
)
return
main()
|
import math
def main():
N, K = list(map(int, input().split()))
print(
(
(
max(0, N - K + 1)
+ sum(
max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i
- max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i
for i in range(1, len(bin(K)) - 2 + 1 + 1)
)
)
/ N
)
)
return
main()
| false | 0 |
[
"- max(0, N - (math.ceil(K * 0.5**i)) + 1) * 0.5**i",
"- - max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5**i",
"- for i in range(1, int(math.log2(K)) + 1 + 1)",
"+ max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i",
"+ - max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i",
"+ for i in range(1, len(bin(K)) - 2 + 1 + 1)"
] | false | 0.039328 | 0.039078 | 1.006409 |
[
"s971812770",
"s794074649"
] |
u811733736
|
p00168
|
python
|
s729789960
|
s281459645
| 40 | 30 | 7,688 | 7,768 |
Accepted
|
Accepted
| 25 |
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline
def solve(n):
dp = [[0] * (n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
for j in range(i, n+1):
t = 0
for k in range(1, min(j+1, 3+1)):
t += dp[i-1][j-k]
dp[i][j] = t
total = 0
for d in dp:
total += d[-1]
return total
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
result = solve(n)
print((ceil(result / 365 / 10)))
if __name__ == '__main__':
main(sys.argv[1:])
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline
dp = 0
def solve(n):
global dp
dp = [[0] * (n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
for j in range(i, n+1):
t = 0
for k in range(1, min(j+1, 3+1)):
t += dp[i-1][j-k]
dp[i][j] = t
total = 0
for d in dp:
total += d[-1]
return total
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
result = solve(n)
print((ceil(result / 365 / 10)))
if __name__ == '__main__':
main(sys.argv[1:])
| 41 | 42 | 763 | 784 |
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline
def solve(n):
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
for j in range(i, n + 1):
t = 0
for k in range(1, min(j + 1, 3 + 1)):
t += dp[i - 1][j - k]
dp[i][j] = t
total = 0
for d in dp:
total += d[-1]
return total
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
result = solve(n)
print((ceil(result / 365 / 10)))
if __name__ == "__main__":
main(sys.argv[1:])
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline
dp = 0
def solve(n):
global dp
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
for j in range(i, n + 1):
t = 0
for k in range(1, min(j + 1, 3 + 1)):
t += dp[i - 1][j - k]
dp[i][j] = t
total = 0
for d in dp:
total += d[-1]
return total
def main(args):
while True:
n = int(eval(input()))
if n == 0:
break
result = solve(n)
print((ceil(result / 365 / 10)))
if __name__ == "__main__":
main(sys.argv[1:])
| false | 2.380952 |
[
"+dp = 0",
"+ global dp"
] | false | 0.050135 | 0.046464 | 1.079013 |
[
"s729789960",
"s281459645"
] |
u462329577
|
p02767
|
python
|
s332245571
|
s511361327
| 172 | 21 | 39,152 | 3,060 |
Accepted
|
Accepted
| 87.79 |
#!/usr/bin/env python3
n = int(eval(input()))
x = list(map(int,input().split()))
ans = 10**6 #INF
for i in range(1,101):
ans = min(ans,sum([(k-i)**2 for k in x]))
#print(ans,sum([(k-i)**2 for k in x]))
print(ans)
|
#!/usr/bin/env python3
n = int(eval(input()))
x = list(map(int,input().split()))
ans = 10**6
for i in range(1,101):
k = 0
for j in range(n):
k += (x[j]-i) **2
ans = min(ans,k)
print(ans)
| 8 | 10 | 221 | 199 |
#!/usr/bin/env python3
n = int(eval(input()))
x = list(map(int, input().split()))
ans = 10**6 # INF
for i in range(1, 101):
ans = min(ans, sum([(k - i) ** 2 for k in x]))
# print(ans,sum([(k-i)**2 for k in x]))
print(ans)
|
#!/usr/bin/env python3
n = int(eval(input()))
x = list(map(int, input().split()))
ans = 10**6
for i in range(1, 101):
k = 0
for j in range(n):
k += (x[j] - i) ** 2
ans = min(ans, k)
print(ans)
| false | 20 |
[
"-ans = 10**6 # INF",
"+ans = 10**6",
"- ans = min(ans, sum([(k - i) ** 2 for k in x]))",
"- # print(ans,sum([(k-i)**2 for k in x]))",
"+ k = 0",
"+ for j in range(n):",
"+ k += (x[j] - i) ** 2",
"+ ans = min(ans, k)"
] | false | 0.077898 | 0.036802 | 2.116685 |
[
"s332245571",
"s511361327"
] |
u644907318
|
p02768
|
python
|
s878117642
|
s298744383
| 242 | 124 | 64,204 | 105,304 |
Accepted
|
Accepted
| 48.76 |
p = 10**9+7
def pow(x,m):
if m==0:
return 1
if m==1:
return x
if m%2==0:
return (pow(x,m//2)**2)%p
else:
return (x*(pow(x,(m-1)//2)**2)%p)%p
A = [1 for _ in range(200001)]
for i in range(2,200001):
A[i] = (i*A[i-1])%p
B = [1 for _ in range(200001)]
B[200000] = pow(A[200000],p-2)
for i in range(199999,1,-1):
B[i] = (B[i+1]*(i+1))%p
n,a,b = list(map(int,input().split()))
a1 = 1
for i in range(n,n-a,-1):
a1 = (a1*i)%p
a1 = (a1*B[a])%p
b1 = 1
for i in range(n,n-b,-1):
b1 = (b1*i)%p
b1 = (b1*B[b])%p
ans = (pow(2,n)-1-a1-b1)%p
print(ans)
|
p = 10**9+7
def pow(x,m):
if m==0:
return 1
if m==1:
return x
if m%2==0:
return (pow(x,m//2)**2)%p
else:
return (x*(pow(x,(m-1)//2)**2)%p)%p
n,a,b = list(map(int,input().split()))
A = [1 for _ in range(2*10**5+1)]
for i in range(2,2*10**5+1):
A[i] = (A[i-1]*i)%p
B = [1 for _ in range(2*10**5+1)]
B[2*10**5] = pow(A[2*10**5],p-2)
for i in range(2*10**5-1,1,-1):
B[i] = (B[i+1]*(i+1))%p
cnt = pow(2,n)-1
cnt1 = 1
for i in range(a):
cnt1 = (cnt1*(n-i))%p
cnt1 = (cnt1*B[a])%p
cnt2 = 1
for i in range(b):
cnt2 = (cnt2*(n-i))%p
cnt2 = (cnt2*B[b])%p
cnt = (cnt-cnt1-cnt2)%p
print(cnt)
| 29 | 29 | 628 | 665 |
p = 10**9 + 7
def pow(x, m):
if m == 0:
return 1
if m == 1:
return x
if m % 2 == 0:
return (pow(x, m // 2) ** 2) % p
else:
return (x * (pow(x, (m - 1) // 2) ** 2) % p) % p
A = [1 for _ in range(200001)]
for i in range(2, 200001):
A[i] = (i * A[i - 1]) % p
B = [1 for _ in range(200001)]
B[200000] = pow(A[200000], p - 2)
for i in range(199999, 1, -1):
B[i] = (B[i + 1] * (i + 1)) % p
n, a, b = list(map(int, input().split()))
a1 = 1
for i in range(n, n - a, -1):
a1 = (a1 * i) % p
a1 = (a1 * B[a]) % p
b1 = 1
for i in range(n, n - b, -1):
b1 = (b1 * i) % p
b1 = (b1 * B[b]) % p
ans = (pow(2, n) - 1 - a1 - b1) % p
print(ans)
|
p = 10**9 + 7
def pow(x, m):
if m == 0:
return 1
if m == 1:
return x
if m % 2 == 0:
return (pow(x, m // 2) ** 2) % p
else:
return (x * (pow(x, (m - 1) // 2) ** 2) % p) % p
n, a, b = list(map(int, input().split()))
A = [1 for _ in range(2 * 10**5 + 1)]
for i in range(2, 2 * 10**5 + 1):
A[i] = (A[i - 1] * i) % p
B = [1 for _ in range(2 * 10**5 + 1)]
B[2 * 10**5] = pow(A[2 * 10**5], p - 2)
for i in range(2 * 10**5 - 1, 1, -1):
B[i] = (B[i + 1] * (i + 1)) % p
cnt = pow(2, n) - 1
cnt1 = 1
for i in range(a):
cnt1 = (cnt1 * (n - i)) % p
cnt1 = (cnt1 * B[a]) % p
cnt2 = 1
for i in range(b):
cnt2 = (cnt2 * (n - i)) % p
cnt2 = (cnt2 * B[b]) % p
cnt = (cnt - cnt1 - cnt2) % p
print(cnt)
| false | 0 |
[
"-A = [1 for _ in range(200001)]",
"-for i in range(2, 200001):",
"- A[i] = (i * A[i - 1]) % p",
"-B = [1 for _ in range(200001)]",
"-B[200000] = pow(A[200000], p - 2)",
"-for i in range(199999, 1, -1):",
"+n, a, b = list(map(int, input().split()))",
"+A = [1 for _ in range(2 * 10**5 + 1)]",
"+for i in range(2, 2 * 10**5 + 1):",
"+ A[i] = (A[i - 1] * i) % p",
"+B = [1 for _ in range(2 * 10**5 + 1)]",
"+B[2 * 10**5] = pow(A[2 * 10**5], p - 2)",
"+for i in range(2 * 10**5 - 1, 1, -1):",
"-n, a, b = list(map(int, input().split()))",
"-a1 = 1",
"-for i in range(n, n - a, -1):",
"- a1 = (a1 * i) % p",
"-a1 = (a1 * B[a]) % p",
"-b1 = 1",
"-for i in range(n, n - b, -1):",
"- b1 = (b1 * i) % p",
"-b1 = (b1 * B[b]) % p",
"-ans = (pow(2, n) - 1 - a1 - b1) % p",
"-print(ans)",
"+cnt = pow(2, n) - 1",
"+cnt1 = 1",
"+for i in range(a):",
"+ cnt1 = (cnt1 * (n - i)) % p",
"+cnt1 = (cnt1 * B[a]) % p",
"+cnt2 = 1",
"+for i in range(b):",
"+ cnt2 = (cnt2 * (n - i)) % p",
"+cnt2 = (cnt2 * B[b]) % p",
"+cnt = (cnt - cnt1 - cnt2) % p",
"+print(cnt)"
] | false | 0.471506 | 0.31806 | 1.482442 |
[
"s878117642",
"s298744383"
] |
u617990214
|
p02400
|
python
|
s714987540
|
s481890568
| 60 | 50 | 10,128 | 10,124 |
Accepted
|
Accepted
| 16.67 |
from math import pi
from decimal import Decimal
r=Decimal(eval(input()))
p=Decimal(pi)
print((str(p*r**2)+" "+str(2*p*r)))
|
from math import pi
from decimal import Decimal
r=Decimal(str(eval(input())))
p=Decimal(str(pi))
print((str(p*r**2)+" "+str(2*p*r)))
| 5 | 5 | 118 | 128 |
from math import pi
from decimal import Decimal
r = Decimal(eval(input()))
p = Decimal(pi)
print((str(p * r**2) + " " + str(2 * p * r)))
|
from math import pi
from decimal import Decimal
r = Decimal(str(eval(input())))
p = Decimal(str(pi))
print((str(p * r**2) + " " + str(2 * p * r)))
| false | 0 |
[
"-r = Decimal(eval(input()))",
"-p = Decimal(pi)",
"+r = Decimal(str(eval(input())))",
"+p = Decimal(str(pi))"
] | false | 0.047823 | 0.042726 | 1.119312 |
[
"s714987540",
"s481890568"
] |
u392029857
|
p03478
|
python
|
s337799708
|
s431258838
| 36 | 30 | 4,196 | 3,064 |
Accepted
|
Accepted
| 16.67 |
N, A, B = list(map(int, input().split()))
number = list(range(A, N+1))
number_str = list(map(str, number))
arc = []
for item in number_str:
num = list(map(int, item))
s = sum(num)
if A <= s and s <= B:
arc.append(int(item))
print((sum(arc)))
|
N, A, B = list(map(int, input().split()))
numbers = list(range(A, N + 1))
somesums = 0
for i in numbers:
p = i
sums = 0
while p >= 1:
sums += p%10
p //= 10
if A <= sums <= B:
somesums += i
print(somesums)
| 10 | 12 | 256 | 243 |
N, A, B = list(map(int, input().split()))
number = list(range(A, N + 1))
number_str = list(map(str, number))
arc = []
for item in number_str:
num = list(map(int, item))
s = sum(num)
if A <= s and s <= B:
arc.append(int(item))
print((sum(arc)))
|
N, A, B = list(map(int, input().split()))
numbers = list(range(A, N + 1))
somesums = 0
for i in numbers:
p = i
sums = 0
while p >= 1:
sums += p % 10
p //= 10
if A <= sums <= B:
somesums += i
print(somesums)
| false | 16.666667 |
[
"-number = list(range(A, N + 1))",
"-number_str = list(map(str, number))",
"-arc = []",
"-for item in number_str:",
"- num = list(map(int, item))",
"- s = sum(num)",
"- if A <= s and s <= B:",
"- arc.append(int(item))",
"-print((sum(arc)))",
"+numbers = list(range(A, N + 1))",
"+somesums = 0",
"+for i in numbers:",
"+ p = i",
"+ sums = 0",
"+ while p >= 1:",
"+ sums += p % 10",
"+ p //= 10",
"+ if A <= sums <= B:",
"+ somesums += i",
"+print(somesums)"
] | false | 0.044958 | 0.042336 | 1.061933 |
[
"s337799708",
"s431258838"
] |
u362560965
|
p03485
|
python
|
s677536233
|
s554889354
| 19 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 10.53 |
a, b = list(map(int, input().split()))
ans = int((a+b)/2)
if (a+b) % 2 != 0:
ans += 1
print(ans)
|
import math
a, b = list(map(int, input().split()))
ans = math.ceil((a+b)/2)
print(ans)
| 8 | 7 | 104 | 89 |
a, b = list(map(int, input().split()))
ans = int((a + b) / 2)
if (a + b) % 2 != 0:
ans += 1
print(ans)
|
import math
a, b = list(map(int, input().split()))
ans = math.ceil((a + b) / 2)
print(ans)
| false | 12.5 |
[
"+import math",
"+",
"-ans = int((a + b) / 2)",
"-if (a + b) % 2 != 0:",
"- ans += 1",
"+ans = math.ceil((a + b) / 2)"
] | false | 0.080833 | 0.087873 | 0.919886 |
[
"s677536233",
"s554889354"
] |
u095266283
|
p02558
|
python
|
s905928627
|
s601453518
| 786 | 393 | 12,960 | 13,440 |
Accepted
|
Accepted
| 50 |
class DisjointSetUnion:
def __init__(self, n):
self.n = n
self.par = [-1] * n
self.rank = [0] * n
def root(self, x):
if self.par[x] == -1:
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def same(self, x, y):
return self.root(x) == self.root(y)
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return
if self.rank[x] < self.rank[y]:
x, y = y, x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
self.par[y] = x
return
if __name__ == '__main__':
n, q = list(map(int, input().split()))
dsu = DisjointSetUnion(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t:
print((int(dsu.same(u, v))))
else:
dsu.unite(u, v)
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
class DisjointSetUnion:
def __init__(self, n):
self.n = n
self.par = [-1] * n
self.rank = [0] * n
def root(self, x):
if self.par[x] == -1:
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def same(self, x, y):
return self.root(x) == self.root(y)
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return
if self.rank[x] < self.rank[y]:
x, y = y, x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
self.par[y] = x
return
if __name__ == '__main__':
n, q = list(map(int, readline().split()))
dsu = DisjointSetUnion(n)
for i in range(q):
t, u, v = list(map(int, readline().split()))
if t:
print((int(dsu.same(u, v))))
else:
dsu.unite(u, v)
| 39 | 47 | 953 | 1,087 |
class DisjointSetUnion:
def __init__(self, n):
self.n = n
self.par = [-1] * n
self.rank = [0] * n
def root(self, x):
if self.par[x] == -1:
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def same(self, x, y):
return self.root(x) == self.root(y)
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return
if self.rank[x] < self.rank[y]:
x, y = y, x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
self.par[y] = x
return
if __name__ == "__main__":
n, q = list(map(int, input().split()))
dsu = DisjointSetUnion(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t:
print((int(dsu.same(u, v))))
else:
dsu.unite(u, v)
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
class DisjointSetUnion:
def __init__(self, n):
self.n = n
self.par = [-1] * n
self.rank = [0] * n
def root(self, x):
if self.par[x] == -1:
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
def same(self, x, y):
return self.root(x) == self.root(y)
def unite(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return
if self.rank[x] < self.rank[y]:
x, y = y, x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
self.par[y] = x
return
if __name__ == "__main__":
n, q = list(map(int, readline().split()))
dsu = DisjointSetUnion(n)
for i in range(q):
t, u, v = list(map(int, readline().split()))
if t:
print((int(dsu.same(u, v))))
else:
dsu.unite(u, v)
| false | 17.021277 |
[
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+",
"+",
"- n, q = list(map(int, input().split()))",
"+ n, q = list(map(int, readline().split()))",
"- t, u, v = list(map(int, input().split()))",
"+ t, u, v = list(map(int, readline().split()))"
] | false | 0.062415 | 0.034946 | 1.786036 |
[
"s905928627",
"s601453518"
] |
u564589929
|
p02700
|
python
|
s679309428
|
s681716366
| 26 | 21 | 9,200 | 9,216 |
Accepted
|
Accepted
| 19.23 |
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
from math import ceil
def solve():
a, b, c, d = MI()
aoki = ceil(a / d)
taka = ceil(c / b)
# print(taka, aoki)
if taka > aoki:
print('No')
else: # taka <= aoki
print('Yes')
if __name__ == '__main__':
solve()
|
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
INF = float('inf')
def solve():
a, b, c, d = MI()
for i in range(1000000):
c -= b
if c <= 0:
print('Yes')
return
a -= d
if a <= 0:
print('No')
return
if __name__ == '__main__':
solve()
| 29 | 31 | 596 | 703 |
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
from math import ceil
def solve():
a, b, c, d = MI()
aoki = ceil(a / d)
taka = ceil(c / b)
# print(taka, aoki)
if taka > aoki:
print("No")
else: # taka <= aoki
print("Yes")
if __name__ == "__main__":
solve()
|
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def LI1():
return list(map(int1, input().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
INF = float("inf")
def solve():
a, b, c, d = MI()
for i in range(1000000):
c -= b
if c <= 0:
print("Yes")
return
a -= d
if a <= 0:
print("No")
return
if __name__ == "__main__":
solve()
| false | 6.451613 |
[
"-# import sys",
"-# sys.setrecursionlimit(10 ** 6)",
"+import sys",
"+",
"+sys.setrecursionlimit(10**6)",
"+# input = sys.stdin.readline ####",
"+def LI1():",
"+ return list(map(int1, input().split()))",
"+",
"+",
"-from math import ceil",
"+INF = float(\"inf\")",
"- aoki = ceil(a / d)",
"- taka = ceil(c / b)",
"- # print(taka, aoki)",
"- if taka > aoki:",
"- print(\"No\")",
"- else: # taka <= aoki",
"- print(\"Yes\")",
"+ for i in range(1000000):",
"+ c -= b",
"+ if c <= 0:",
"+ print(\"Yes\")",
"+ return",
"+ a -= d",
"+ if a <= 0:",
"+ print(\"No\")",
"+ return"
] | false | 0.080366 | 0.076645 | 1.048543 |
[
"s679309428",
"s681716366"
] |
u736443076
|
p02773
|
python
|
s348374326
|
s643205700
| 538 | 495 | 48,764 | 38,728 |
Accepted
|
Accepted
| 7.99 |
from collections import Counter
N = int(eval(input()))
S = []
for _ in range(N):
S.append(eval(input()))
counter = Counter(S)
sorted_S = list(sorted(set(S)))
maxcnt = max(counter.values())
for Si in sorted_S:
if counter[Si] == maxcnt:
print(Si)
|
from collections import Counter
N = int(eval(input()))
S = []
for _ in range(N):
S.append(eval(input()))
counter = Counter(S)
sorted_S = list(sorted(counter.keys()))
maxcnt = max(counter.values())
for Si in sorted_S:
if counter[Si] == maxcnt:
print(Si)
| 13 | 12 | 263 | 269 |
from collections import Counter
N = int(eval(input()))
S = []
for _ in range(N):
S.append(eval(input()))
counter = Counter(S)
sorted_S = list(sorted(set(S)))
maxcnt = max(counter.values())
for Si in sorted_S:
if counter[Si] == maxcnt:
print(Si)
|
from collections import Counter
N = int(eval(input()))
S = []
for _ in range(N):
S.append(eval(input()))
counter = Counter(S)
sorted_S = list(sorted(counter.keys()))
maxcnt = max(counter.values())
for Si in sorted_S:
if counter[Si] == maxcnt:
print(Si)
| false | 7.692308 |
[
"-sorted_S = list(sorted(set(S)))",
"+sorted_S = list(sorted(counter.keys()))"
] | false | 0.041418 | 0.125278 | 0.330609 |
[
"s348374326",
"s643205700"
] |
u352394527
|
p00441
|
python
|
s365837243
|
s243917227
| 15,620 | 12,870 | 6,964 | 6,964 |
Accepted
|
Accepted
| 17.61 |
def main():
while True:
n = int(eval(input()))
if not n:
break
ps = [list(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add((t[0],t[1]))
ans = 0
for i in range(n):
for j in range(n):
p1 = ps[i]
p2 = ps[j]
p1x = p1[0]
p1y = p1[1]
p2x = p2[0]
p2y = p2[1]
vx = p2x - p1x
vy = p2y - p1y
if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:
ans = max(ans, vx ** 2 + vy ** 2)
print(ans)
main()
|
def main():
while True:
n = int(eval(input()))
if not n:
break
ps = [list(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add((t[0],t[1]))
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
p2x = p2[0]
p2y = p2[1]
vx = p2x - p1x
vy = p2y - p1y
if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:
ans = max(ans, vx ** 2 + vy ** 2)
print(ans)
main()
| 30 | 30 | 598 | 592 |
def main():
while True:
n = int(eval(input()))
if not n:
break
ps = [list(map(int, input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add((t[0], t[1]))
ans = 0
for i in range(n):
for j in range(n):
p1 = ps[i]
p2 = ps[j]
p1x = p1[0]
p1y = p1[1]
p2x = p2[0]
p2y = p2[1]
vx = p2x - p1x
vy = p2y - p1y
if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:
ans = max(ans, vx**2 + vy**2)
print(ans)
main()
|
def main():
while True:
n = int(eval(input()))
if not n:
break
ps = [list(map(int, input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add((t[0], t[1]))
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
p2x = p2[0]
p2y = p2[1]
vx = p2x - p1x
vy = p2y - p1y
if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:
ans = max(ans, vx**2 + vy**2)
print(ans)
main()
| false | 0 |
[
"+ p1 = ps[i]",
"+ p1x = p1[0]",
"+ p1y = p1[1]",
"- p1 = ps[i]",
"- p1x = p1[0]",
"- p1y = p1[1]"
] | false | 0.037639 | 0.038931 | 0.966812 |
[
"s365837243",
"s243917227"
] |
u188827677
|
p03030
|
python
|
s217665103
|
s351078597
| 69 | 28 | 9,116 | 9,004 |
Accepted
|
Accepted
| 59.42 |
n = int(eval(input()))
city = []
nums = []
result = []
for i in range(n):
s,p = input().split()
p = int(p)
city.append(s)
nums.append(p)
result.append([s,p,i+1])
for i in sorted(set(city)):
for j in sorted(set(nums), reverse = True):
for k in result:
if k[0] == i and k[1] == j:
print((k[2]))
|
n = int(eval(input()))
l = []
d = {}
for i in range(n):
s,p = input().split()
if s not in l:
l.append(s)
d[s] = []
d[s].append([int(p), i+1])
for i in sorted(l):
for j in sorted(d[i], reverse=True):
print((j[1]))
| 17 | 13 | 332 | 237 |
n = int(eval(input()))
city = []
nums = []
result = []
for i in range(n):
s, p = input().split()
p = int(p)
city.append(s)
nums.append(p)
result.append([s, p, i + 1])
for i in sorted(set(city)):
for j in sorted(set(nums), reverse=True):
for k in result:
if k[0] == i and k[1] == j:
print((k[2]))
|
n = int(eval(input()))
l = []
d = {}
for i in range(n):
s, p = input().split()
if s not in l:
l.append(s)
d[s] = []
d[s].append([int(p), i + 1])
for i in sorted(l):
for j in sorted(d[i], reverse=True):
print((j[1]))
| false | 23.529412 |
[
"-city = []",
"-nums = []",
"-result = []",
"+l = []",
"+d = {}",
"- p = int(p)",
"- city.append(s)",
"- nums.append(p)",
"- result.append([s, p, i + 1])",
"-for i in sorted(set(city)):",
"- for j in sorted(set(nums), reverse=True):",
"- for k in result:",
"- if k[0] == i and k[1] == j:",
"- print((k[2]))",
"+ if s not in l:",
"+ l.append(s)",
"+ d[s] = []",
"+ d[s].append([int(p), i + 1])",
"+for i in sorted(l):",
"+ for j in sorted(d[i], reverse=True):",
"+ print((j[1]))"
] | false | 0.035863 | 0.03561 | 1.007105 |
[
"s217665103",
"s351078597"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.