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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u007270338 | p02288 | python | s269285753 | s772662499 | 840 | 710 | 64,208 | 63,844 | Accepted | Accepted | 15.48 | #coding:utf-8
H = int(eval(input()))
A = list(map(int,input().split()))
def maxHeapify(A,i):
l = 2 * i
r = 2 * i + 1
if l <= H and A[l-1] > A[i-1]:
largest = l
else:
largest = i
if r <= H and A[r-1] > A[largest-1]:
largest = r
if largest != i:
A[i-1], A[largest-1] = A[largest-1], A[i-1]
maxHeapify(A,largest)
def buildMaxHeap(A):
for i in range(H // 2, 0, -1):
maxHeapify(A,i)
buildMaxHeap(A)
A = " " + " ".join([str(num) for num in A])
print(A)
| #coding: utf-8
def maxHeapify(A, i):
l = 2 * i
r = 2 * i + 1
if l <= H and A[l] > A[i]:
largest = l
else:
largest = i
if r <= H and A[r] > A[largest]:
largest = r
if largest != i:
A[i], A[largest] = A[largest], A[i]
maxHeapify(A, largest)
def buildMaxHeap(A):
for i in range(H//2, 0, -1):
maxHeapify(A, i)
H = int(eval(input()))
A = [0] + list(map(int,input().split()))
buildMaxHeap(A)
A.pop(0)
print((" " + " ".join([str(num) for num in A])))
| 25 | 28 | 545 | 547 | # coding:utf-8
H = int(eval(input()))
A = list(map(int, input().split()))
def maxHeapify(A, i):
l = 2 * i
r = 2 * i + 1
if l <= H and A[l - 1] > A[i - 1]:
largest = l
else:
largest = i
if r <= H and A[r - 1] > A[largest - 1]:
largest = r
if largest != i:
A[i - 1], A[largest - 1] = A[largest - 1], A[i - 1]
maxHeapify(A, largest)
def buildMaxHeap(A):
for i in range(H // 2, 0, -1):
maxHeapify(A, i)
buildMaxHeap(A)
A = " " + " ".join([str(num) for num in A])
print(A)
| # coding: utf-8
def maxHeapify(A, i):
l = 2 * i
r = 2 * i + 1
if l <= H and A[l] > A[i]:
largest = l
else:
largest = i
if r <= H and A[r] > A[largest]:
largest = r
if largest != i:
A[i], A[largest] = A[largest], A[i]
maxHeapify(A, largest)
def buildMaxHeap(A):
for i in range(H // 2, 0, -1):
maxHeapify(A, i)
H = int(eval(input()))
A = [0] + list(map(int, input().split()))
buildMaxHeap(A)
A.pop(0)
print((" " + " ".join([str(num) for num in A])))
| false | 10.714286 | [
"-# coding:utf-8",
"-H = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-",
"-",
"+# coding: utf-8",
"- if l <= H and A[l - 1] > A[i - 1]:",
"+ if l <= H and A[l] > A[i]:",
"- if r <= H and A[r - 1] > A[largest - 1]:",
"+ if r <= H and A[r] > A[largest]:",
"- A[i - 1], A[largest - 1] = A[largest - 1], A[i - 1]",
"+ A[i], A[largest] = A[largest], A[i]",
"+H = int(eval(input()))",
"+A = [0] + list(map(int, input().split()))",
"-A = \" \" + \" \".join([str(num) for num in A])",
"-print(A)",
"+A.pop(0)",
"+print((\" \" + \" \".join([str(num) for num in A])))"
]
| false | 0.037868 | 0.104081 | 0.363835 | [
"s269285753",
"s772662499"
]
|
u677523557 | p03343 | python | s092682667 | s617793720 | 966 | 487 | 3,444 | 47,324 | Accepted | Accepted | 49.59 | import sys
input = sys.stdin.readline
import heapq as hp
def main():
N, K, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
NUM = sorted(list(set(A)))
ans = 10**10
for n in NUM:
Qs = []
q = []
for i in range(N):
if A[i] < n:
if q:
Qs.append(q)
q = []
continue
if not q:
q = [A[i]]
else:
hp.heappush(q, A[i])
if q:
Qs.append(q)
P = []
for q in Qs:
l = len(q)
if l < K: continue
for _ in range(min(Q, l-K+1)):
v = hp.heappop(q)
P.append(v)
if len(P) < Q:
break
P.sort()
ans = min(ans, P[Q-1]-P[0])
print(ans)
if __name__ == "__main__":
main() | import sys
input = sys.stdin.readline
import heapq as hp
N, K, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
Xs = sorted(list(set(A)))
ans = 10**14
for x in Xs:
Ps = []
tmp = []
for a in A:
if a >= x:
tmp.append(a)
else:
if len(tmp) >= K:
Ps.append(tmp)
tmp = []
if len(tmp) >= K:
Ps.append(tmp)
q = []
for P in Ps:
P.sort()
for i, p in enumerate(P):
q.append(p)
if len(P)-K-i == 0: break
if len(q) < Q:
break
q.sort()
ans = min(ans, q[Q-1]-x)
print(ans)
| 44 | 34 | 939 | 675 | import sys
input = sys.stdin.readline
import heapq as hp
def main():
N, K, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
NUM = sorted(list(set(A)))
ans = 10**10
for n in NUM:
Qs = []
q = []
for i in range(N):
if A[i] < n:
if q:
Qs.append(q)
q = []
continue
if not q:
q = [A[i]]
else:
hp.heappush(q, A[i])
if q:
Qs.append(q)
P = []
for q in Qs:
l = len(q)
if l < K:
continue
for _ in range(min(Q, l - K + 1)):
v = hp.heappop(q)
P.append(v)
if len(P) < Q:
break
P.sort()
ans = min(ans, P[Q - 1] - P[0])
print(ans)
if __name__ == "__main__":
main()
| import sys
input = sys.stdin.readline
import heapq as hp
N, K, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
Xs = sorted(list(set(A)))
ans = 10**14
for x in Xs:
Ps = []
tmp = []
for a in A:
if a >= x:
tmp.append(a)
else:
if len(tmp) >= K:
Ps.append(tmp)
tmp = []
if len(tmp) >= K:
Ps.append(tmp)
q = []
for P in Ps:
P.sort()
for i, p in enumerate(P):
q.append(p)
if len(P) - K - i == 0:
break
if len(q) < Q:
break
q.sort()
ans = min(ans, q[Q - 1] - x)
print(ans)
| false | 22.727273 | [
"-",
"-def main():",
"- N, K, Q = list(map(int, input().split()))",
"- A = list(map(int, input().split()))",
"- NUM = sorted(list(set(A)))",
"- ans = 10**10",
"- for n in NUM:",
"- Qs = []",
"- q = []",
"- for i in range(N):",
"- if A[i] < n:",
"- if q:",
"- Qs.append(q)",
"- q = []",
"- continue",
"- if not q:",
"- q = [A[i]]",
"- else:",
"- hp.heappush(q, A[i])",
"- if q:",
"- Qs.append(q)",
"- P = []",
"- for q in Qs:",
"- l = len(q)",
"- if l < K:",
"- continue",
"- for _ in range(min(Q, l - K + 1)):",
"- v = hp.heappop(q)",
"- P.append(v)",
"- if len(P) < Q:",
"- break",
"+N, K, Q = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+Xs = sorted(list(set(A)))",
"+ans = 10**14",
"+for x in Xs:",
"+ Ps = []",
"+ tmp = []",
"+ for a in A:",
"+ if a >= x:",
"+ tmp.append(a)",
"+ else:",
"+ if len(tmp) >= K:",
"+ Ps.append(tmp)",
"+ tmp = []",
"+ if len(tmp) >= K:",
"+ Ps.append(tmp)",
"+ q = []",
"+ for P in Ps:",
"- ans = min(ans, P[Q - 1] - P[0])",
"- print(ans)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+ for i, p in enumerate(P):",
"+ q.append(p)",
"+ if len(P) - K - i == 0:",
"+ break",
"+ if len(q) < Q:",
"+ break",
"+ q.sort()",
"+ ans = min(ans, q[Q - 1] - x)",
"+print(ans)"
]
| false | 0.041199 | 0.047683 | 0.864034 | [
"s092682667",
"s617793720"
]
|
u604774382 | p02257 | python | s682579101 | s482569189 | 820 | 340 | 4,540 | 6,676 | Accepted | Accepted | 58.54 | def isPrime( x ):
if 2 == x or 3 == x:
return True
if 0 == x&1:
return False
i = 3
while i*i <= x:
if 0 == x%i:
return False
i += 1
return True
n = int( input( ) )
nums = []
while 0 < n:
nums.append( int( input( ) ) )
n -= 1
cnt = 0
for num in nums:
if isPrime( num ):
cnt += 1
print( cnt ) | import math
def isPrime( x ):
if 2 == x or 3 == x:
return True
if 0 == x&1:
return False
i = 3
limit = math.sqrt( x )
while i <= limit:
if 0 == x%i:
return False
i += 2
return True
n = int( input( ) )
nums = []
i = 0
while i < n:
nums.append( int( input( ) ) )
i += 1
cnt = i = 0
for val in nums:
if isPrime( val ):
cnt += 1
print( cnt ) | 24 | 28 | 348 | 417 | def isPrime(x):
if 2 == x or 3 == x:
return True
if 0 == x & 1:
return False
i = 3
while i * i <= x:
if 0 == x % i:
return False
i += 1
return True
n = int(input())
nums = []
while 0 < n:
nums.append(int(input()))
n -= 1
cnt = 0
for num in nums:
if isPrime(num):
cnt += 1
print(cnt)
| import math
def isPrime(x):
if 2 == x or 3 == x:
return True
if 0 == x & 1:
return False
i = 3
limit = math.sqrt(x)
while i <= limit:
if 0 == x % i:
return False
i += 2
return True
n = int(input())
nums = []
i = 0
while i < n:
nums.append(int(input()))
i += 1
cnt = i = 0
for val in nums:
if isPrime(val):
cnt += 1
print(cnt)
| false | 14.285714 | [
"+import math",
"+",
"+",
"- while i * i <= x:",
"+ limit = math.sqrt(x)",
"+ while i <= limit:",
"- i += 1",
"+ i += 2",
"-while 0 < n:",
"+i = 0",
"+while i < n:",
"- n -= 1",
"-cnt = 0",
"-for num in nums:",
"- if isPrime(num):",
"+ i += 1",
"+cnt = i = 0",
"+for val in nums:",
"+ if isPrime(val):"
]
| false | 0.033433 | 0.034093 | 0.980661 | [
"s682579101",
"s482569189"
]
|
u528748570 | p03087 | python | s735138358 | s291734405 | 674 | 495 | 69,848 | 30,636 | Accepted | Accepted | 26.56 | N, Q = list(map(int, input().split()))
str = eval(input())
length = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N)]
for i in range(1, N):
if (str[i-1] == "A") and (str[i] == "C"):
ans[i] = ans[i-1] + 1
else:
ans[i] = ans[i-1]
for l1, l2 in length:
# print(ans)
print((ans[l2-1] - ans[l1-1]))
| N, Q = list(map(int, input().split()))
str = eval(input())
length = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N)]
for i in range(1, N):
if (str[i-1] == "A"):
if (str[i] == "C"):
ans[i] = ans[i-1] + 1
else:
ans[i] = ans[i-1]
else:
ans[i] = ans[i-1]
if i != N-1:
ans[i+1] = ans[i-1]
i += 1
for l1, l2 in length:
# print(ans)
print((ans[l2-1] - ans[l1-1]))
| 14 | 20 | 357 | 487 | N, Q = list(map(int, input().split()))
str = eval(input())
length = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N)]
for i in range(1, N):
if (str[i - 1] == "A") and (str[i] == "C"):
ans[i] = ans[i - 1] + 1
else:
ans[i] = ans[i - 1]
for l1, l2 in length:
# print(ans)
print((ans[l2 - 1] - ans[l1 - 1]))
| N, Q = list(map(int, input().split()))
str = eval(input())
length = [list(map(int, input().split())) for _ in range(Q)]
ans = [0 for _ in range(N)]
for i in range(1, N):
if str[i - 1] == "A":
if str[i] == "C":
ans[i] = ans[i - 1] + 1
else:
ans[i] = ans[i - 1]
else:
ans[i] = ans[i - 1]
if i != N - 1:
ans[i + 1] = ans[i - 1]
i += 1
for l1, l2 in length:
# print(ans)
print((ans[l2 - 1] - ans[l1 - 1]))
| false | 30 | [
"- if (str[i - 1] == \"A\") and (str[i] == \"C\"):",
"- ans[i] = ans[i - 1] + 1",
"+ if str[i - 1] == \"A\":",
"+ if str[i] == \"C\":",
"+ ans[i] = ans[i - 1] + 1",
"+ else:",
"+ ans[i] = ans[i - 1]",
"+ if i != N - 1:",
"+ ans[i + 1] = ans[i - 1]",
"+ i += 1"
]
| false | 0.037584 | 0.060849 | 0.617655 | [
"s735138358",
"s291734405"
]
|
u912237403 | p02400 | python | s589570231 | s844487373 | 20 | 10 | 4,252 | 4,248 | Accepted | Accepted | 50 | import sys
for line in sys.stdin:
PI = 3.14159265358979
a = float(line)
print('%f.8 %f.8' %(PI*a**2, 2*PI*a)) | a = float(input())
PI = 3.14159265358979
print('%.8f %.8f' %(PI*a**2, 2*PI*a)) | 5 | 3 | 124 | 83 | import sys
for line in sys.stdin:
PI = 3.14159265358979
a = float(line)
print("%f.8 %f.8" % (PI * a**2, 2 * PI * a))
| a = float(input())
PI = 3.14159265358979
print("%.8f %.8f" % (PI * a**2, 2 * PI * a))
| false | 40 | [
"-import sys",
"-",
"-for line in sys.stdin:",
"- PI = 3.14159265358979",
"- a = float(line)",
"- print(\"%f.8 %f.8\" % (PI * a**2, 2 * PI * a))",
"+a = float(input())",
"+PI = 3.14159265358979",
"+print(\"%.8f %.8f\" % (PI * a**2, 2 * PI * a))"
]
| false | 0.035187 | 0.035069 | 1.003387 | [
"s589570231",
"s844487373"
]
|
u838644735 | p02756 | python | s666037548 | s808615231 | 495 | 213 | 8,420 | 8,548 | Accepted | Accepted | 56.97 | from collections import deque
def main():
S = deque([s for s in eval(input())])
Q = int(eval(input()))
order = True
for i in range(Q):
query = input().split()
t = int(query[0])
if t == 1:
order = not order
else:
f = int(query[1])
c = query[2]
left = True
if f == 1:
if order:
left = True
else:
left = False
else:
if order:
left = False
else:
left = True
if left:
S.appendleft(c)
else:
S.append(c)
if not order:
S.reverse()
print((''.join(S)))
if __name__ == '__main__':
main()
| from collections import deque
from sys import stdin
def main():
S = deque([s for s in eval(input())])
Q = int(eval(input()))
order = True
for i in range(Q):
query = stdin.readline().split()
t = int(query[0])
if t == 1:
order = not order
else:
f = int(query[1])
c = query[2]
if not order:
f = 3 - f # 2, 1 -> 1, 2
left = True
if f == 1:
S.appendleft(c)
else:
S.append(c)
if not order:
S.reverse()
print((''.join(S)))
if __name__ == '__main__':
main()
| 34 | 28 | 837 | 666 | from collections import deque
def main():
S = deque([s for s in eval(input())])
Q = int(eval(input()))
order = True
for i in range(Q):
query = input().split()
t = int(query[0])
if t == 1:
order = not order
else:
f = int(query[1])
c = query[2]
left = True
if f == 1:
if order:
left = True
else:
left = False
else:
if order:
left = False
else:
left = True
if left:
S.appendleft(c)
else:
S.append(c)
if not order:
S.reverse()
print(("".join(S)))
if __name__ == "__main__":
main()
| from collections import deque
from sys import stdin
def main():
S = deque([s for s in eval(input())])
Q = int(eval(input()))
order = True
for i in range(Q):
query = stdin.readline().split()
t = int(query[0])
if t == 1:
order = not order
else:
f = int(query[1])
c = query[2]
if not order:
f = 3 - f # 2, 1 -> 1, 2
left = True
if f == 1:
S.appendleft(c)
else:
S.append(c)
if not order:
S.reverse()
print(("".join(S)))
if __name__ == "__main__":
main()
| false | 17.647059 | [
"+from sys import stdin",
"- query = input().split()",
"+ query = stdin.readline().split()",
"+ if not order:",
"+ f = 3 - f # 2, 1 -> 1, 2",
"- if order:",
"- left = True",
"- else:",
"- left = False",
"- else:",
"- if order:",
"- left = False",
"- else:",
"- left = True",
"- if left:"
]
| false | 0.037252 | 0.044705 | 0.833295 | [
"s666037548",
"s808615231"
]
|
u325282913 | p03147 | python | s958874215 | s734614343 | 51 | 21 | 3,060 | 3,064 | Accepted | Accepted | 58.82 | N = int(eval(input()))
array = list(map(int,input().split()))
ans = 0
while True:
if max(array) == 0:
break
flg = False
for i in range(N):
if array[i] == 0:
if flg:
break
continue
array[i] -= 1
flg = True
ans += 1
print(ans) | import itertools
N = int(eval(input()))
arr = list(map(int, input().split()))
ans = 0
while sum(arr) != 0:
tmp = [0]*N
tmp2 = 0
for i in range(N):
if arr[i] != 0:
tmp[i] = 1
arr[i] -= 1
gr = itertools.groupby(tmp)
for key, group in gr:
if key != 0:
tmp2 += 1
ans += tmp2
print(ans) | 16 | 17 | 321 | 367 | N = int(eval(input()))
array = list(map(int, input().split()))
ans = 0
while True:
if max(array) == 0:
break
flg = False
for i in range(N):
if array[i] == 0:
if flg:
break
continue
array[i] -= 1
flg = True
ans += 1
print(ans)
| import itertools
N = int(eval(input()))
arr = list(map(int, input().split()))
ans = 0
while sum(arr) != 0:
tmp = [0] * N
tmp2 = 0
for i in range(N):
if arr[i] != 0:
tmp[i] = 1
arr[i] -= 1
gr = itertools.groupby(tmp)
for key, group in gr:
if key != 0:
tmp2 += 1
ans += tmp2
print(ans)
| false | 5.882353 | [
"+import itertools",
"+",
"-array = list(map(int, input().split()))",
"+arr = list(map(int, input().split()))",
"-while True:",
"- if max(array) == 0:",
"- break",
"- flg = False",
"+while sum(arr) != 0:",
"+ tmp = [0] * N",
"+ tmp2 = 0",
"- if array[i] == 0:",
"- if flg:",
"- break",
"- continue",
"- array[i] -= 1",
"- flg = True",
"- ans += 1",
"+ if arr[i] != 0:",
"+ tmp[i] = 1",
"+ arr[i] -= 1",
"+ gr = itertools.groupby(tmp)",
"+ for key, group in gr:",
"+ if key != 0:",
"+ tmp2 += 1",
"+ ans += tmp2"
]
| false | 0.0885 | 0.098011 | 0.902963 | [
"s958874215",
"s734614343"
]
|
u072717685 | p02725 | python | s934424286 | s014922454 | 139 | 110 | 26,060 | 33,344 | Accepted | Accepted | 20.86 | import sys
input = sys.stdin.readline
def main():
k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
longest = a[0] + k - a[-1]
for i in range(n - 1):
longest = max(longest, a[i+1] - a[i])
print((k - longest))
if __name__ == '__main__':
main()
| import sys
read = sys.stdin.read
def main():
k, n = list(map(int, input().split()))
a = tuple(map(int, input().split()))
dis_max = (k - a[-1]) + a[0]
for i1 in range(1, n):
dis = a[i1] - a[i1-1]
dis_max = max(dis_max, dis)
print((k - dis_max))
if __name__ == '__main__':
main()
| 15 | 12 | 310 | 321 | import sys
input = sys.stdin.readline
def main():
k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
longest = a[0] + k - a[-1]
for i in range(n - 1):
longest = max(longest, a[i + 1] - a[i])
print((k - longest))
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
def main():
k, n = list(map(int, input().split()))
a = tuple(map(int, input().split()))
dis_max = (k - a[-1]) + a[0]
for i1 in range(1, n):
dis = a[i1] - a[i1 - 1]
dis_max = max(dis_max, dis)
print((k - dis_max))
if __name__ == "__main__":
main()
| false | 20 | [
"-input = sys.stdin.readline",
"+read = sys.stdin.read",
"- a = list(map(int, input().split()))",
"- longest = a[0] + k - a[-1]",
"- for i in range(n - 1):",
"- longest = max(longest, a[i + 1] - a[i])",
"- print((k - longest))",
"+ a = tuple(map(int, input().split()))",
"+ dis_max = (k - a[-1]) + a[0]",
"+ for i1 in range(1, n):",
"+ dis = a[i1] - a[i1 - 1]",
"+ dis_max = max(dis_max, dis)",
"+ print((k - dis_max))"
]
| false | 0.062041 | 0.036066 | 1.720224 | [
"s934424286",
"s014922454"
]
|
u633068244 | p00507 | python | s154632644 | s078756243 | 70 | 20 | 4,720 | 4,720 | Accepted | Accepted | 71.43 | a = list(map(str,sorted(eval(input()) for i in range(eval(input())))[:4]))
ans = []
for i in range(3):
for j in range(i+1,4):
ans.append(int(a[i]+a[j]))
ans.append(int(a[j]+a[i]))
print(sorted(ans)[2]) | a = list(map(str,sorted(int(input()) for i in range(eval(input())))[:4]))
ans = []
for i in range(3):
for j in range(i+1,4):
ans.append(int(a[i]+a[j]))
ans.append(int(a[j]+a[i]))
print(sorted(ans)[2]) | 7 | 7 | 193 | 202 | a = list(map(str, sorted(eval(input()) for i in range(eval(input())))[:4]))
ans = []
for i in range(3):
for j in range(i + 1, 4):
ans.append(int(a[i] + a[j]))
ans.append(int(a[j] + a[i]))
print(sorted(ans)[2])
| a = list(map(str, sorted(int(input()) for i in range(eval(input())))[:4]))
ans = []
for i in range(3):
for j in range(i + 1, 4):
ans.append(int(a[i] + a[j]))
ans.append(int(a[j] + a[i]))
print(sorted(ans)[2])
| false | 0 | [
"-a = list(map(str, sorted(eval(input()) for i in range(eval(input())))[:4]))",
"+a = list(map(str, sorted(int(input()) for i in range(eval(input())))[:4]))"
]
| false | 0.03938 | 0.03817 | 1.031684 | [
"s154632644",
"s078756243"
]
|
u260980560 | p01104 | python | s943061458 | s629499780 | 6,060 | 4,780 | 180,008 | 171,840 | Accepted | Accepted | 21.12 | while 1:
n, m = list(map(int, input().split()))
if n+m == 0:
break
B = [int(eval(input()),2) for i in range(n)]
C = {0: 0}
for b in B:
D = dict(C)
for k, v in list(D.items()):
C[k^b] = max(C.get(k^b, 0), v+1)
print((C[0])) | while 1:
n, m = list(map(int, input().split()))
if n+m == 0:
break
C = {0: 0}
for i in range(n):
b = int(eval(input()), 2)
for k, v in list(dict(C).items()):
if C.get(k^b, 0) < v+1:
C[k^b] = v+1
print((C[0])) | 11 | 11 | 272 | 270 | while 1:
n, m = list(map(int, input().split()))
if n + m == 0:
break
B = [int(eval(input()), 2) for i in range(n)]
C = {0: 0}
for b in B:
D = dict(C)
for k, v in list(D.items()):
C[k ^ b] = max(C.get(k ^ b, 0), v + 1)
print((C[0]))
| while 1:
n, m = list(map(int, input().split()))
if n + m == 0:
break
C = {0: 0}
for i in range(n):
b = int(eval(input()), 2)
for k, v in list(dict(C).items()):
if C.get(k ^ b, 0) < v + 1:
C[k ^ b] = v + 1
print((C[0]))
| false | 0 | [
"- B = [int(eval(input()), 2) for i in range(n)]",
"- for b in B:",
"- D = dict(C)",
"- for k, v in list(D.items()):",
"- C[k ^ b] = max(C.get(k ^ b, 0), v + 1)",
"+ for i in range(n):",
"+ b = int(eval(input()), 2)",
"+ for k, v in list(dict(C).items()):",
"+ if C.get(k ^ b, 0) < v + 1:",
"+ C[k ^ b] = v + 1"
]
| false | 0.040065 | 0.03987 | 1.004896 | [
"s943061458",
"s629499780"
]
|
u169138653 | p03576 | python | s743262098 | s454219049 | 1,444 | 58 | 48,732 | 5,148 | Accepted | Accepted | 95.98 | n,k=list(map(int,input().split()))
x,y,xy=[],[],[]
for _ in range(n):
a,b=list(map(int,input().split()))
x.append(a)
y.append(b)
xy.append((a,b))
x.sort()
y.sort()
ans=float('inf')
for i in range(n-1):
x1=x[i]
for j in range(i+1,n):
x2=x[j]
for l in range(n-1):
y1=y[l]
for m in range(l+1,n):
y2=y[m]
cnt=0
for o in range(n):
x3,y3=xy[o]
if x1<=x3<=x2 and y1<=y3<=y2:
cnt+=1
if cnt>=k:
ans=min(ans,(x2-x1)*(y2-y1))
print(ans) | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF
xy.sort()
for l in range(N-K+1): # 長方形に含まれる最も左の点
for r in range(l+K, N+1): # 長方形に含まれる最も右の点
y = sorted(xy[l:r], key = lambda x: x[1]) # lからrの中でのyのとりうる値をソート
for i in range(r-l-K+1):
sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1]) # 下からKこ選んだときの面積
ans = min(ans, sq)
print(ans)
| 26 | 29 | 544 | 1,053 | n, k = list(map(int, input().split()))
x, y, xy = [], [], []
for _ in range(n):
a, b = list(map(int, input().split()))
x.append(a)
y.append(b)
xy.append((a, b))
x.sort()
y.sort()
ans = float("inf")
for i in range(n - 1):
x1 = x[i]
for j in range(i + 1, n):
x2 = x[j]
for l in range(n - 1):
y1 = y[l]
for m in range(l + 1, n):
y2 = y[m]
cnt = 0
for o in range(n):
x3, y3 = xy[o]
if x1 <= x3 <= x2 and y1 <= y3 <= y2:
cnt += 1
if cnt >= k:
ans = min(ans, (x2 - x1) * (y2 - y1))
print(ans)
| import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
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()))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF
xy.sort()
for l in range(N - K + 1): # 長方形に含まれる最も左の点
for r in range(l + K, N + 1): # 長方形に含まれる最も右の点
y = sorted(xy[l:r], key=lambda x: x[1]) # lからrの中でのyのとりうる値をソート
for i in range(r - l - K + 1):
sq = (xy[r - 1][0] - xy[l][0]) * (
y[i + K - 1][1] - y[i][1]
) # 下からKこ選んだときの面積
ans = min(ans, sq)
print(ans)
| false | 10.344828 | [
"-n, k = list(map(int, input().split()))",
"-x, y, xy = [], [], []",
"-for _ in range(n):",
"- a, b = list(map(int, input().split()))",
"- x.append(a)",
"- y.append(b)",
"- xy.append((a, b))",
"-x.sort()",
"-y.sort()",
"-ans = float(\"inf\")",
"-for i in range(n - 1):",
"- x1 = x[i]",
"- for j in range(i + 1, n):",
"- x2 = x[j]",
"- for l in range(n - 1):",
"- y1 = y[l]",
"- for m in range(l + 1, n):",
"- y2 = y[m]",
"- cnt = 0",
"- for o in range(n):",
"- x3, y3 = xy[o]",
"- if x1 <= x3 <= x2 and y1 <= y3 <= y2:",
"- cnt += 1",
"- if cnt >= k:",
"- ans = min(ans, (x2 - x1) * (y2 - y1))",
"+import sys, re",
"+from collections import deque, defaultdict, Counter",
"+from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees",
"+from itertools import permutations, combinations, product, accumulate",
"+from operator import itemgetter, mul",
"+from copy import deepcopy",
"+from string import ascii_lowercase, ascii_uppercase, digits",
"+from fractions import gcd",
"+from bisect import bisect",
"+",
"+",
"+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()))",
"+",
"+",
"+sys.setrecursionlimit(10**9)",
"+INF = float(\"inf\")",
"+mod = 10**9 + 7",
"+N, K = MAP()",
"+xy = [LIST() for _ in range(N)]",
"+ans = INF",
"+xy.sort()",
"+for l in range(N - K + 1): # 長方形に含まれる最も左の点",
"+ for r in range(l + K, N + 1): # 長方形に含まれる最も右の点",
"+ y = sorted(xy[l:r], key=lambda x: x[1]) # lからrの中でのyのとりうる値をソート",
"+ for i in range(r - l - K + 1):",
"+ sq = (xy[r - 1][0] - xy[l][0]) * (",
"+ y[i + K - 1][1] - y[i][1]",
"+ ) # 下からKこ選んだときの面積",
"+ ans = min(ans, sq)"
]
| false | 0.044584 | 0.036698 | 1.214884 | [
"s743262098",
"s454219049"
]
|
u254871849 | p03645 | python | s882341724 | s581964983 | 1,541 | 344 | 196,560 | 33,132 | Accepted | Accepted | 77.68 | import sys
from collections import deque
l = deque(sys.stdin.readlines())
n, m = (int(x) for x in l[0].split())
l.popleft()
from_1, to_n = set(), set()
for a, b in deque((int(x) for x in l[i].split()) for i in range(m)):
if a == 1: from_1.add(b)
elif b == n: to_n.add(a)
print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE")) | import sys
l = sys.stdin.readlines()
n, m = (int(x) for x in l[0].split())
from_1, to_n = set(), set()
for a, b in ((int(x) for x in l[i].split()) for i in range(1, m+1)):
if a == 1: from_1.add(b)
elif b == n: to_n.add(a)
print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))
| 12 | 10 | 344 | 294 | import sys
from collections import deque
l = deque(sys.stdin.readlines())
n, m = (int(x) for x in l[0].split())
l.popleft()
from_1, to_n = set(), set()
for a, b in deque((int(x) for x in l[i].split()) for i in range(m)):
if a == 1:
from_1.add(b)
elif b == n:
to_n.add(a)
print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))
| import sys
l = sys.stdin.readlines()
n, m = (int(x) for x in l[0].split())
from_1, to_n = set(), set()
for a, b in ((int(x) for x in l[i].split()) for i in range(1, m + 1)):
if a == 1:
from_1.add(b)
elif b == n:
to_n.add(a)
print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))
| false | 16.666667 | [
"-from collections import deque",
"-l = deque(sys.stdin.readlines())",
"+l = sys.stdin.readlines()",
"-l.popleft()",
"-for a, b in deque((int(x) for x in l[i].split()) for i in range(m)):",
"+for a, b in ((int(x) for x in l[i].split()) for i in range(1, m + 1)):"
]
| false | 0.043306 | 0.076987 | 0.562508 | [
"s882341724",
"s581964983"
]
|
u759412327 | p03103 | python | s834517975 | s176729677 | 469 | 345 | 28,656 | 28,280 | Accepted | Accepted | 26.44 | N,M = list(map(int,input().split()))
D = sorted([list(map(int,input().split())) for n in range(N)])
mon = 0
num = 0
for n in range(N):
mon+=D[n][0]*D[n][1]
num+=D[n][1]
if M<=num:
print((mon-D[n][0]*(num-M)))
break | N,M = list(map(int,input().split()))
D = sorted([list(map(int,input().split())) for n in range(N)])
ans = 0
num = 0
for a,b in D:
num+=b
ans+=a*b
if M<=num:
ans-=a*(num-M)
break
print(ans) | 12 | 13 | 235 | 210 | N, M = list(map(int, input().split()))
D = sorted([list(map(int, input().split())) for n in range(N)])
mon = 0
num = 0
for n in range(N):
mon += D[n][0] * D[n][1]
num += D[n][1]
if M <= num:
print((mon - D[n][0] * (num - M)))
break
| N, M = list(map(int, input().split()))
D = sorted([list(map(int, input().split())) for n in range(N)])
ans = 0
num = 0
for a, b in D:
num += b
ans += a * b
if M <= num:
ans -= a * (num - M)
break
print(ans)
| false | 7.692308 | [
"-mon = 0",
"+ans = 0",
"-for n in range(N):",
"- mon += D[n][0] * D[n][1]",
"- num += D[n][1]",
"+for a, b in D:",
"+ num += b",
"+ ans += a * b",
"- print((mon - D[n][0] * (num - M)))",
"+ ans -= a * (num - M)",
"+print(ans)"
]
| false | 0.034992 | 0.037246 | 0.939492 | [
"s834517975",
"s176729677"
]
|
u490553751 | p03262 | python | s955404855 | s313347913 | 216 | 120 | 16,292 | 14,252 | Accepted | Accepted | 44.44 | import fractions
N,X = list(map(int,input().split()))
x = list(map(int,input().split()))
distance = []
for i in range(N) :
d = abs(x[i] - X)
distance.append(d)
s = 1000000001
if N == 1 :
s = distance[0]
else :
for i in range(0,N-1) :
s = min(fractions.gcd(distance[i],distance[i+1]),s)
print(s) | N,X = [int(i) for i in input().split()]
xa = [int(i) for i in input().split()]
from fractions import gcd
lia = [0]*N
for i in range(N):
lia[i] = abs(X-xa[i])
ans = lia[0]
for i in range(1,N):
ans = gcd(ans,lia[i])
print(ans) | 14 | 10 | 325 | 241 | import fractions
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
distance = []
for i in range(N):
d = abs(x[i] - X)
distance.append(d)
s = 1000000001
if N == 1:
s = distance[0]
else:
for i in range(0, N - 1):
s = min(fractions.gcd(distance[i], distance[i + 1]), s)
print(s)
| N, X = [int(i) for i in input().split()]
xa = [int(i) for i in input().split()]
from fractions import gcd
lia = [0] * N
for i in range(N):
lia[i] = abs(X - xa[i])
ans = lia[0]
for i in range(1, N):
ans = gcd(ans, lia[i])
print(ans)
| false | 28.571429 | [
"-import fractions",
"+N, X = [int(i) for i in input().split()]",
"+xa = [int(i) for i in input().split()]",
"+from fractions import gcd",
"-N, X = list(map(int, input().split()))",
"-x = list(map(int, input().split()))",
"-distance = []",
"+lia = [0] * N",
"- d = abs(x[i] - X)",
"- distance.append(d)",
"-s = 1000000001",
"-if N == 1:",
"- s = distance[0]",
"-else:",
"- for i in range(0, N - 1):",
"- s = min(fractions.gcd(distance[i], distance[i + 1]), s)",
"-print(s)",
"+ lia[i] = abs(X - xa[i])",
"+ans = lia[0]",
"+for i in range(1, N):",
"+ ans = gcd(ans, lia[i])",
"+print(ans)"
]
| false | 0.089927 | 0.139826 | 0.643132 | [
"s955404855",
"s313347913"
]
|
u226108478 | p02773 | python | s980642499 | s095931987 | 737 | 587 | 45,032 | 35,572 | Accepted | Accepted | 20.35 | # -*- coding: utf-8 -*-
def main():
from collections import Counter
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
c = sorted(list(Counter(s).items()), key=lambda x: x[1], reverse=True)
max_value = c[0][1]
ans = list()
for key, value in c:
if value == max_value:
ans.append(key)
for a in sorted(ans):
print(a)
if __name__ == '__main__':
main()
| # -*- coding: utf-8 -*-
def main():
from collections import Counter
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
c = Counter(s)
max_value = max(c.values())
ans = list()
for key, value in list(c.items()):
if value == max_value:
ans.append(key)
for a in sorted(ans):
print(a)
if __name__ == '__main__':
main()
| 22 | 22 | 432 | 398 | # -*- coding: utf-8 -*-
def main():
from collections import Counter
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
c = sorted(list(Counter(s).items()), key=lambda x: x[1], reverse=True)
max_value = c[0][1]
ans = list()
for key, value in c:
if value == max_value:
ans.append(key)
for a in sorted(ans):
print(a)
if __name__ == "__main__":
main()
| # -*- coding: utf-8 -*-
def main():
from collections import Counter
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
c = Counter(s)
max_value = max(c.values())
ans = list()
for key, value in list(c.items()):
if value == max_value:
ans.append(key)
for a in sorted(ans):
print(a)
if __name__ == "__main__":
main()
| false | 0 | [
"- c = sorted(list(Counter(s).items()), key=lambda x: x[1], reverse=True)",
"- max_value = c[0][1]",
"+ c = Counter(s)",
"+ max_value = max(c.values())",
"- for key, value in c:",
"+ for key, value in list(c.items()):"
]
| false | 0.038441 | 0.040322 | 0.953354 | [
"s980642499",
"s095931987"
]
|
u102461423 | p03045 | python | s852319370 | s584137442 | 858 | 315 | 67,416 | 43,892 | Accepted | Accepted | 63.29 | import sys
sys.setrecursionlimit(10**6)
# 連結成分
# UF tree
N,M = list(map(int,input().split()))
n_component = N
root = list(range(N+1))
depth = [0] * (N+1)
def find_root(x):
y = root[x]
if x == y:
return x
z = find_root(y)
root[x] = z
return z
def merge(x,y):
global n_component
xx = find_root(x)
yy = find_root(y)
if xx == yy:
return
n_component -= 1
if depth[xx] >= depth[yy]:
root[yy] = xx
depth[xx] += 1
else:
root[xx] = yy
depth[yy] += 1
for _ in range(M):
x,y,z = [int(x) for x in input().split()]
merge(x,y)
answer = n_component
print(answer)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
# X,Y に辺を貼る -> 連結成分ごとに1回
N,M = list(map(int,readline().split()))
m = list(map(int,read().split()))
XYZ = list(zip(m,m,m))
X,Y,Z = list(zip(*XYZ))
graph = csr_matrix(([1]*M,(X,Y)),(N+1,N+1))
Ncomp,_ = connected_components(graph,connection='weak')
answer = Ncomp - 1
print(answer) | 39 | 21 | 640 | 492 | import sys
sys.setrecursionlimit(10**6)
# 連結成分
# UF tree
N, M = list(map(int, input().split()))
n_component = N
root = list(range(N + 1))
depth = [0] * (N + 1)
def find_root(x):
y = root[x]
if x == y:
return x
z = find_root(y)
root[x] = z
return z
def merge(x, y):
global n_component
xx = find_root(x)
yy = find_root(y)
if xx == yy:
return
n_component -= 1
if depth[xx] >= depth[yy]:
root[yy] = xx
depth[xx] += 1
else:
root[xx] = yy
depth[yy] += 1
for _ in range(M):
x, y, z = [int(x) for x in input().split()]
merge(x, y)
answer = n_component
print(answer)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
# X,Y に辺を貼る -> 連結成分ごとに1回
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
XYZ = list(zip(m, m, m))
X, Y, Z = list(zip(*XYZ))
graph = csr_matrix(([1] * M, (X, Y)), (N + 1, N + 1))
Ncomp, _ = connected_components(graph, connection="weak")
answer = Ncomp - 1
print(answer)
| false | 46.153846 | [
"-sys.setrecursionlimit(10**6)",
"-# 連結成分",
"-# UF tree",
"-N, M = list(map(int, input().split()))",
"-n_component = N",
"-root = list(range(N + 1))",
"-depth = [0] * (N + 1)",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+from scipy.sparse import csr_matrix",
"+from scipy.sparse.csgraph import connected_components",
"-",
"-def find_root(x):",
"- y = root[x]",
"- if x == y:",
"- return x",
"- z = find_root(y)",
"- root[x] = z",
"- return z",
"-",
"-",
"-def merge(x, y):",
"- global n_component",
"- xx = find_root(x)",
"- yy = find_root(y)",
"- if xx == yy:",
"- return",
"- n_component -= 1",
"- if depth[xx] >= depth[yy]:",
"- root[yy] = xx",
"- depth[xx] += 1",
"- else:",
"- root[xx] = yy",
"- depth[yy] += 1",
"-",
"-",
"-for _ in range(M):",
"- x, y, z = [int(x) for x in input().split()]",
"- merge(x, y)",
"-answer = n_component",
"+# X,Y に辺を貼る -> 連結成分ごとに1回",
"+N, M = list(map(int, readline().split()))",
"+m = list(map(int, read().split()))",
"+XYZ = list(zip(m, m, m))",
"+X, Y, Z = list(zip(*XYZ))",
"+graph = csr_matrix(([1] * M, (X, Y)), (N + 1, N + 1))",
"+Ncomp, _ = connected_components(graph, connection=\"weak\")",
"+answer = Ncomp - 1"
]
| false | 0.064488 | 0.27596 | 0.233686 | [
"s852319370",
"s584137442"
]
|
u018679195 | p02789 | python | s136478981 | s757516283 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | from sys import stdin
def main():
n,m = list(map(int,stdin.readline().split()))
if(n==m):
print("Yes")
else:
print("No")
main()
| n, m = list(map(int, input().split()))
if m == n:
print("Yes")
else: print("No") | 10 | 4 | 161 | 81 | from sys import stdin
def main():
n, m = list(map(int, stdin.readline().split()))
if n == m:
print("Yes")
else:
print("No")
main()
| n, m = list(map(int, input().split()))
if m == n:
print("Yes")
else:
print("No")
| false | 60 | [
"-from sys import stdin",
"-",
"-",
"-def main():",
"- n, m = list(map(int, stdin.readline().split()))",
"- if n == m:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"-",
"-",
"-main()",
"+n, m = list(map(int, input().split()))",
"+if m == n:",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"
]
| false | 0.04122 | 0.047347 | 0.870608 | [
"s136478981",
"s757516283"
]
|
u200887663 | p03196 | python | s944512969 | s799616603 | 176 | 125 | 38,512 | 9,140 | Accepted | Accepted | 28.98 | #p=int(input())
n,p=list(map(int,input().split()))
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
#素因数分解した結果を2次元配列にして返す
def prime_factorize(n):
n_origin=n+0
primelist=[]
a=2
while a*a<=n_origin:
if n%a!=0:
a+=1
continue
ex=0
while n%a==0:
ex+=1
n=n//a
primelist.append([a,ex])
a+=1
if n!=1:
primelist.append([n,1])
return primelist
pfs=prime_factorize(p)
ans=1
for pf in pfs:
p=pf[0];ex=pf[1]
ans=ans*(p**(ex//n))
print(ans)
| #n=int(input())
n,p=list(map(int,input().split()))
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def prime_factorize(n):
n_origin=n+0
primelist=[]
a=2
while a*a<=n_origin:
if n%a!=0:
a+=1
continue
ex=0
while n%a==0:
ex+=1
n=n//a
primelist.append([a,ex])
a+=1
if n!=1:
primelist.append([n,1])
return primelist
primelist=prime_factorize(p)
ans=1
for p,e in primelist:
ans=ans*(p**(e//n))
print(ans) | 29 | 28 | 618 | 585 | # p=int(input())
n, p = list(map(int, input().split()))
# al=list(map(int,input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
# 素因数分解した結果を2次元配列にして返す
def prime_factorize(n):
n_origin = n + 0
primelist = []
a = 2
while a * a <= n_origin:
if n % a != 0:
a += 1
continue
ex = 0
while n % a == 0:
ex += 1
n = n // a
primelist.append([a, ex])
a += 1
if n != 1:
primelist.append([n, 1])
return primelist
pfs = prime_factorize(p)
ans = 1
for pf in pfs:
p = pf[0]
ex = pf[1]
ans = ans * (p ** (ex // n))
print(ans)
| # n=int(input())
n, p = list(map(int, input().split()))
# l=list(map(int,input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
def prime_factorize(n):
n_origin = n + 0
primelist = []
a = 2
while a * a <= n_origin:
if n % a != 0:
a += 1
continue
ex = 0
while n % a == 0:
ex += 1
n = n // a
primelist.append([a, ex])
a += 1
if n != 1:
primelist.append([n, 1])
return primelist
primelist = prime_factorize(p)
ans = 1
for p, e in primelist:
ans = ans * (p ** (e // n))
print(ans)
| false | 3.448276 | [
"-# p=int(input())",
"+# n=int(input())",
"-# al=list(map(int,input().split()))",
"+# l=list(map(int,input().split()))",
"-# 素因数分解した結果を2次元配列にして返す",
"-pfs = prime_factorize(p)",
"+primelist = prime_factorize(p)",
"-for pf in pfs:",
"- p = pf[0]",
"- ex = pf[1]",
"- ans = ans * (p ** (ex // n))",
"+for p, e in primelist:",
"+ ans = ans * (p ** (e // n))"
]
| false | 0.093338 | 0.079091 | 1.180129 | [
"s944512969",
"s799616603"
]
|
u554954744 | p03371 | python | s354130369 | s531811509 | 279 | 200 | 60,212 | 41,324 | Accepted | Accepted | 28.32 | import math
A, B, C, X, Y = list(map(int, input().split()))
cost = []
cost.append(A*X + B*Y)
for i in range(2*min(X,Y), 2*max(X,Y)+1):
cost.append(C*i + max(0, math.ceil(X-i/2)*A) + max(0, math.ceil(Y-i/2)*B))
print((min(cost))) | a, b, c, x, y = list(map(int, input().split()))
ans = float('inf')
for k in range(2*max(x, y)+1):
cost = c * k
need_x = max(0, x - k // 2)
need_y = max(0, y - k // 2)
cost += a * need_x + b * need_y
ans = min(ans, cost)
print(ans) | 11 | 10 | 238 | 254 | import math
A, B, C, X, Y = list(map(int, input().split()))
cost = []
cost.append(A * X + B * Y)
for i in range(2 * min(X, Y), 2 * max(X, Y) + 1):
cost.append(
C * i + max(0, math.ceil(X - i / 2) * A) + max(0, math.ceil(Y - i / 2) * B)
)
print((min(cost)))
| a, b, c, x, y = list(map(int, input().split()))
ans = float("inf")
for k in range(2 * max(x, y) + 1):
cost = c * k
need_x = max(0, x - k // 2)
need_y = max(0, y - k // 2)
cost += a * need_x + b * need_y
ans = min(ans, cost)
print(ans)
| false | 9.090909 | [
"-import math",
"-",
"-A, B, C, X, Y = list(map(int, input().split()))",
"-cost = []",
"-cost.append(A * X + B * Y)",
"-for i in range(2 * min(X, Y), 2 * max(X, Y) + 1):",
"- cost.append(",
"- C * i + max(0, math.ceil(X - i / 2) * A) + max(0, math.ceil(Y - i / 2) * B)",
"- )",
"-print((min(cost)))",
"+a, b, c, x, y = list(map(int, input().split()))",
"+ans = float(\"inf\")",
"+for k in range(2 * max(x, y) + 1):",
"+ cost = c * k",
"+ need_x = max(0, x - k // 2)",
"+ need_y = max(0, y - k // 2)",
"+ cost += a * need_x + b * need_y",
"+ ans = min(ans, cost)",
"+print(ans)"
]
| false | 0.03849 | 0.106961 | 0.359852 | [
"s354130369",
"s531811509"
]
|
u519939795 | p02887 | python | s967343397 | s368694771 | 47 | 42 | 3,956 | 3,316 | Accepted | Accepted | 10.64 | N = int(eval(input()))
S = eval(input())
slimes = []
for i in range(N):
if i == 0 or slimes[-1] != S[i]:
slimes.append(S[i])
print((len(slimes)))
| N=int(eval(input()))
S=eval(input())
ans = 1
for i in range(N-1):
if S[i] != S[i+1]:
ans +=1
print(ans)
| 10 | 7 | 156 | 110 | N = int(eval(input()))
S = eval(input())
slimes = []
for i in range(N):
if i == 0 or slimes[-1] != S[i]:
slimes.append(S[i])
print((len(slimes)))
| N = int(eval(input()))
S = eval(input())
ans = 1
for i in range(N - 1):
if S[i] != S[i + 1]:
ans += 1
print(ans)
| false | 30 | [
"-slimes = []",
"-for i in range(N):",
"- if i == 0 or slimes[-1] != S[i]:",
"- slimes.append(S[i])",
"-print((len(slimes)))",
"+ans = 1",
"+for i in range(N - 1):",
"+ if S[i] != S[i + 1]:",
"+ ans += 1",
"+print(ans)"
]
| false | 0.0406 | 0.096876 | 0.419094 | [
"s967343397",
"s368694771"
]
|
u298297089 | p02936 | python | s985792673 | s076470020 | 1,790 | 1,109 | 55,856 | 55,856 | Accepted | Accepted | 38.04 | # https://atcoder.jp/contests/abc138/tasks/abc138_d
def dfs(lst, start, ans):
queue = [start]
visited = [False] * len(ans)
visited[start] = True
while queue:
parent = queue.pop()
for child in lst[parent]:
if visited[child]:
continue
visited[child] = True
ans[child] += ans[parent]
queue.append(child)
print((*ans))
n,q = list(map(int, input().split()))
start = 0
tree = [[] for i in range(n)]
for i in range(n-1):
a,b = list(map(int, input().split()))
tree[a-1].append(b-1)
tree[b-1].append(a-1)
ans = [0]*n
for _ in range(q):
p, x = list(map(int,input().split()))
ans[p-1] += x
dfs(tree, start, ans)
| # https://atcoder.jp/contests/abc138/tasks/abc138_d
def dfs(lst, start, ans):
queue = [start]
visited = [False] * len(ans)
visited[start] = True
while queue:
parent = queue.pop()
for child in lst[parent]:
if visited[child]:
continue
visited[child] = True
ans[child] += ans[parent]
queue.append(child)
print((*ans))
import sys
input = sys.stdin.readline
n,q = list(map(int, input().split()))
start = 0
tree = [[] for i in range(n)]
for i in range(n-1):
a,b = list(map(int, input().split()))
tree[a-1].append(b-1)
tree[b-1].append(a-1)
ans = [0]*n
for _ in range(q):
p, x = list(map(int,input().split()))
ans[p-1] += x
dfs(tree, start, ans)
| 32 | 34 | 738 | 778 | # https://atcoder.jp/contests/abc138/tasks/abc138_d
def dfs(lst, start, ans):
queue = [start]
visited = [False] * len(ans)
visited[start] = True
while queue:
parent = queue.pop()
for child in lst[parent]:
if visited[child]:
continue
visited[child] = True
ans[child] += ans[parent]
queue.append(child)
print((*ans))
n, q = list(map(int, input().split()))
start = 0
tree = [[] for i in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
tree[a - 1].append(b - 1)
tree[b - 1].append(a - 1)
ans = [0] * n
for _ in range(q):
p, x = list(map(int, input().split()))
ans[p - 1] += x
dfs(tree, start, ans)
| # https://atcoder.jp/contests/abc138/tasks/abc138_d
def dfs(lst, start, ans):
queue = [start]
visited = [False] * len(ans)
visited[start] = True
while queue:
parent = queue.pop()
for child in lst[parent]:
if visited[child]:
continue
visited[child] = True
ans[child] += ans[parent]
queue.append(child)
print((*ans))
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
start = 0
tree = [[] for i in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
tree[a - 1].append(b - 1)
tree[b - 1].append(a - 1)
ans = [0] * n
for _ in range(q):
p, x = list(map(int, input().split()))
ans[p - 1] += x
dfs(tree, start, ans)
| false | 5.882353 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
]
| false | 0.036598 | 0.042669 | 0.857713 | [
"s985792673",
"s076470020"
]
|
u780962115 | p02804 | python | s171776109 | s958017714 | 452 | 156 | 108,104 | 97,796 | Accepted | Accepted | 65.49 | def find_power(n,mod):
# 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである)
powlist=[0]*(n+1)
powlist[0]=1
powlist[1]=1
for i in range(2,n+1):
powlist[i]=powlist[i-1]*i%(mod)
return powlist
def find_inv_power(n):
#0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
powlist=find_power(n,10**9+7)
check=powlist[-1]
first=1
uselist=[0]*(n+1)
secondlist=[0]*30
secondlist[0]=check
secondlist[1]=check**2
for i in range(28):
secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
a=format(10**9+5,"b")
for j in range(30):
if a[29-j]=="1":
first=(first*secondlist[j])%(10**9+7)
uselist[n]=first
for i in range(n,0,-1):
uselist[i-1]=(uselist[i]*i)%(10**9+7)
return uselist
def combi(a,b,n,r,mod):
if n<r:
return 0
elif n>=r:
return (a[n]*b[r]*b[n-r])%(mod)
aa=find_power(10**5,10**9+7)
bb=find_inv_power(10**5)
mod=10**9+7
n,k=list(map(int,input().split()))
lists=list(map(int,input().split()))
import collections
L=collections.Counter(lists)
L=dict(L)
uselist=[]
for a,v in list(L.items()):
uselist.append((a,v))
uselist=sorted(uselist,key=lambda x:x[0])
maxlist=[(0,0)]
counter=0
for some in uselist:
counter+=some[1]
maxlist.append((some[0],counter))
MAX=0
for j in range(1,len(maxlist)):
MAX+=(combi(aa,bb,maxlist[j][1],k,mod)-combi(aa,bb,maxlist[j-1][1],k,mod))*maxlist[j][0]
MAX=MAX%mod
uselist=uselist[::-1]
maxlist=[(0,0)]
counter=0
for some in uselist:
counter+=some[1]
maxlist.append((some[0],counter))
MIN=0
for j in range(1,len(maxlist)):
MIN+=(combi(aa,bb,maxlist[j][1],k,mod)-combi(aa,bb,maxlist[j-1][1],k,mod))*maxlist[j][0]
MIN=MIN%mod
print(((MAX-MIN)%mod))
| class Combi():
def __init__(self, N, mod):
self.power = [1 for _ in range(N+1)]
self.rev = [1 for _ in range(N+1)]
self.mod = mod
for i in range(2, N+1):
self.power[i] = (self.power[i-1]*i) % self.mod
self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
for j in range(N, 0, -1):
self.rev[j-1] = (self.rev[j]*j) % self.mod
def com(self, K, R):
if K < R:
return 0
else:
return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod
def pom(self, K, R):
if K < R:
return 0
else:
return (self.power[K])*(self.rev[K-R]) % self.mod
def main():
mod = 10**9+7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
c = Combi(N, mod)
res = 0
for i, v in enumerate(A):
res += c.com(i, K-1)*v
res -= c.com(N-1-i, K-1)*v
res %= mod
print(res)
return
if __name__ == "__main__":
main() | 77 | 41 | 1,801 | 1,075 | def find_power(n, mod):
# 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである)
powlist = [0] * (n + 1)
powlist[0] = 1
powlist[1] = 1
for i in range(2, n + 1):
powlist[i] = powlist[i - 1] * i % (mod)
return powlist
def find_inv_power(n):
# 0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
powlist = find_power(n, 10**9 + 7)
check = powlist[-1]
first = 1
uselist = [0] * (n + 1)
secondlist = [0] * 30
secondlist[0] = check
secondlist[1] = check**2
for i in range(28):
secondlist[i + 2] = (secondlist[i + 1] ** 2) % (10**9 + 7)
a = format(10**9 + 5, "b")
for j in range(30):
if a[29 - j] == "1":
first = (first * secondlist[j]) % (10**9 + 7)
uselist[n] = first
for i in range(n, 0, -1):
uselist[i - 1] = (uselist[i] * i) % (10**9 + 7)
return uselist
def combi(a, b, n, r, mod):
if n < r:
return 0
elif n >= r:
return (a[n] * b[r] * b[n - r]) % (mod)
aa = find_power(10**5, 10**9 + 7)
bb = find_inv_power(10**5)
mod = 10**9 + 7
n, k = list(map(int, input().split()))
lists = list(map(int, input().split()))
import collections
L = collections.Counter(lists)
L = dict(L)
uselist = []
for a, v in list(L.items()):
uselist.append((a, v))
uselist = sorted(uselist, key=lambda x: x[0])
maxlist = [(0, 0)]
counter = 0
for some in uselist:
counter += some[1]
maxlist.append((some[0], counter))
MAX = 0
for j in range(1, len(maxlist)):
MAX += (
combi(aa, bb, maxlist[j][1], k, mod) - combi(aa, bb, maxlist[j - 1][1], k, mod)
) * maxlist[j][0]
MAX = MAX % mod
uselist = uselist[::-1]
maxlist = [(0, 0)]
counter = 0
for some in uselist:
counter += some[1]
maxlist.append((some[0], counter))
MIN = 0
for j in range(1, len(maxlist)):
MIN += (
combi(aa, bb, maxlist[j][1], k, mod) - combi(aa, bb, maxlist[j - 1][1], k, mod)
) * maxlist[j][0]
MIN = MIN % mod
print(((MAX - MIN) % mod))
| class Combi:
def __init__(self, N, mod):
self.power = [1 for _ in range(N + 1)]
self.rev = [1 for _ in range(N + 1)]
self.mod = mod
for i in range(2, N + 1):
self.power[i] = (self.power[i - 1] * i) % self.mod
self.rev[N] = pow(self.power[N], self.mod - 2, self.mod)
for j in range(N, 0, -1):
self.rev[j - 1] = (self.rev[j] * j) % self.mod
def com(self, K, R):
if K < R:
return 0
else:
return ((self.power[K]) * (self.rev[K - R]) * (self.rev[R])) % self.mod
def pom(self, K, R):
if K < R:
return 0
else:
return (self.power[K]) * (self.rev[K - R]) % self.mod
def main():
mod = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
c = Combi(N, mod)
res = 0
for i, v in enumerate(A):
res += c.com(i, K - 1) * v
res -= c.com(N - 1 - i, K - 1) * v
res %= mod
print(res)
return
if __name__ == "__main__":
main()
| false | 46.753247 | [
"-def find_power(n, mod):",
"- # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである)",
"- powlist = [0] * (n + 1)",
"- powlist[0] = 1",
"- powlist[1] = 1",
"- for i in range(2, n + 1):",
"- powlist[i] = powlist[i - 1] * i % (mod)",
"- return powlist",
"+class Combi:",
"+ def __init__(self, N, mod):",
"+ self.power = [1 for _ in range(N + 1)]",
"+ self.rev = [1 for _ in range(N + 1)]",
"+ self.mod = mod",
"+ for i in range(2, N + 1):",
"+ self.power[i] = (self.power[i - 1] * i) % self.mod",
"+ self.rev[N] = pow(self.power[N], self.mod - 2, self.mod)",
"+ for j in range(N, 0, -1):",
"+ self.rev[j - 1] = (self.rev[j] * j) % self.mod",
"+",
"+ def com(self, K, R):",
"+ if K < R:",
"+ return 0",
"+ else:",
"+ return ((self.power[K]) * (self.rev[K - R]) * (self.rev[R])) % self.mod",
"+",
"+ def pom(self, K, R):",
"+ if K < R:",
"+ return 0",
"+ else:",
"+ return (self.power[K]) * (self.rev[K - R]) % self.mod",
"-def find_inv_power(n):",
"- # 0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数",
"- powlist = find_power(n, 10**9 + 7)",
"- check = powlist[-1]",
"- first = 1",
"- uselist = [0] * (n + 1)",
"- secondlist = [0] * 30",
"- secondlist[0] = check",
"- secondlist[1] = check**2",
"- for i in range(28):",
"- secondlist[i + 2] = (secondlist[i + 1] ** 2) % (10**9 + 7)",
"- a = format(10**9 + 5, \"b\")",
"- for j in range(30):",
"- if a[29 - j] == \"1\":",
"- first = (first * secondlist[j]) % (10**9 + 7)",
"- uselist[n] = first",
"- for i in range(n, 0, -1):",
"- uselist[i - 1] = (uselist[i] * i) % (10**9 + 7)",
"- return uselist",
"+def main():",
"+ mod = 10**9 + 7",
"+ N, K = list(map(int, input().split()))",
"+ A = list(map(int, input().split()))",
"+ A.sort()",
"+ c = Combi(N, mod)",
"+ res = 0",
"+ for i, v in enumerate(A):",
"+ res += c.com(i, K - 1) * v",
"+ res -= c.com(N - 1 - i, K - 1) * v",
"+ res %= mod",
"+ print(res)",
"+ return",
"-def combi(a, b, n, r, mod):",
"- if n < r:",
"- return 0",
"- elif n >= r:",
"- return (a[n] * b[r] * b[n - r]) % (mod)",
"-",
"-",
"-aa = find_power(10**5, 10**9 + 7)",
"-bb = find_inv_power(10**5)",
"-mod = 10**9 + 7",
"-n, k = list(map(int, input().split()))",
"-lists = list(map(int, input().split()))",
"-import collections",
"-",
"-L = collections.Counter(lists)",
"-L = dict(L)",
"-uselist = []",
"-for a, v in list(L.items()):",
"- uselist.append((a, v))",
"-uselist = sorted(uselist, key=lambda x: x[0])",
"-maxlist = [(0, 0)]",
"-counter = 0",
"-for some in uselist:",
"- counter += some[1]",
"- maxlist.append((some[0], counter))",
"-MAX = 0",
"-for j in range(1, len(maxlist)):",
"- MAX += (",
"- combi(aa, bb, maxlist[j][1], k, mod) - combi(aa, bb, maxlist[j - 1][1], k, mod)",
"- ) * maxlist[j][0]",
"- MAX = MAX % mod",
"-uselist = uselist[::-1]",
"-maxlist = [(0, 0)]",
"-counter = 0",
"-for some in uselist:",
"- counter += some[1]",
"- maxlist.append((some[0], counter))",
"-MIN = 0",
"-for j in range(1, len(maxlist)):",
"- MIN += (",
"- combi(aa, bb, maxlist[j][1], k, mod) - combi(aa, bb, maxlist[j - 1][1], k, mod)",
"- ) * maxlist[j][0]",
"- MIN = MIN % mod",
"-print(((MAX - MIN) % mod))",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.125426 | 0.036712 | 3.416433 | [
"s171776109",
"s958017714"
]
|
u062147869 | p03330 | python | s385801326 | s056448151 | 390 | 355 | 45,148 | 47,452 | Accepted | Accepted | 8.97 | N,C = list(map(int,input().split()))
D=[[int(i) for i in input().split()] for j in range(C)]
co=[[int(i) for i in input().split()] for j in range(N)]
A=[[0]*C for i in range(3)]#iに変えた時の違和感
for i in range(N):
for j in range(N):
t = (i+j)%3
for s in range(C):
A[t][s]+=D[co[j][i]-1][s]
ans =10**13
for x in range(C):
for y in range(C):
if x==y:
continue
for z in range(C):
if x==z or y==z:
continue
ans=min(ans,A[0][x]+A[1][y]+A[2][z])
print(ans) | from collections import defaultdict
N,C=list(map(int,input().split()))
D=[[int(i) for i in input().split()] for j in range(C)]
M=[[int(i) for i in input().split()] for j in range(N)]
ans=10**9
L=[defaultdict(int) for i in range(3)]
for i in range(N):
for j in range(N):
L[(i+j)%3][M[i][j]-1]+=1
#print(L)
for i in range(C):
for j in range(C):
for k in range(C):
if i==j or j==k or k==i:
continue
num=0
for color,number in list(L[0].items()):
#num+=D[i][color]*number
num += D[color][i] * number
#print(num)
for color,number in list(L[1].items()):
#num+=D[j][color]*number
#print(num)
num += D[color][j] * number
for color,number in list(L[2].items()):
#num+=D[k][color]*number
#print(num)
num += D[color ][k] * number
ans=min(ans,num)
#print(ans,i,j,k)
#for color,number in L[0].items():
#print(color,number)
print(ans)
| 19 | 37 | 560 | 1,108 | N, C = list(map(int, input().split()))
D = [[int(i) for i in input().split()] for j in range(C)]
co = [[int(i) for i in input().split()] for j in range(N)]
A = [[0] * C for i in range(3)] # iに変えた時の違和感
for i in range(N):
for j in range(N):
t = (i + j) % 3
for s in range(C):
A[t][s] += D[co[j][i] - 1][s]
ans = 10**13
for x in range(C):
for y in range(C):
if x == y:
continue
for z in range(C):
if x == z or y == z:
continue
ans = min(ans, A[0][x] + A[1][y] + A[2][z])
print(ans)
| from collections import defaultdict
N, C = list(map(int, input().split()))
D = [[int(i) for i in input().split()] for j in range(C)]
M = [[int(i) for i in input().split()] for j in range(N)]
ans = 10**9
L = [defaultdict(int) for i in range(3)]
for i in range(N):
for j in range(N):
L[(i + j) % 3][M[i][j] - 1] += 1
# print(L)
for i in range(C):
for j in range(C):
for k in range(C):
if i == j or j == k or k == i:
continue
num = 0
for color, number in list(L[0].items()):
# num+=D[i][color]*number
num += D[color][i] * number
# print(num)
for color, number in list(L[1].items()):
# num+=D[j][color]*number
# print(num)
num += D[color][j] * number
for color, number in list(L[2].items()):
# num+=D[k][color]*number
# print(num)
num += D[color][k] * number
ans = min(ans, num)
# print(ans,i,j,k)
# for color,number in L[0].items():
# print(color,number)
print(ans)
| false | 48.648649 | [
"+from collections import defaultdict",
"+",
"-co = [[int(i) for i in input().split()] for j in range(N)]",
"-A = [[0] * C for i in range(3)] # iに変えた時の違和感",
"+M = [[int(i) for i in input().split()] for j in range(N)]",
"+ans = 10**9",
"+L = [defaultdict(int) for i in range(3)]",
"- t = (i + j) % 3",
"- for s in range(C):",
"- A[t][s] += D[co[j][i] - 1][s]",
"-ans = 10**13",
"-for x in range(C):",
"- for y in range(C):",
"- if x == y:",
"- continue",
"- for z in range(C):",
"- if x == z or y == z:",
"+ L[(i + j) % 3][M[i][j] - 1] += 1",
"+# print(L)",
"+for i in range(C):",
"+ for j in range(C):",
"+ for k in range(C):",
"+ if i == j or j == k or k == i:",
"- ans = min(ans, A[0][x] + A[1][y] + A[2][z])",
"+ num = 0",
"+ for color, number in list(L[0].items()):",
"+ # num+=D[i][color]*number",
"+ num += D[color][i] * number",
"+ # print(num)",
"+ for color, number in list(L[1].items()):",
"+ # num+=D[j][color]*number",
"+ # print(num)",
"+ num += D[color][j] * number",
"+ for color, number in list(L[2].items()):",
"+ # num+=D[k][color]*number",
"+ # print(num)",
"+ num += D[color][k] * number",
"+ ans = min(ans, num)",
"+ # print(ans,i,j,k)",
"+# for color,number in L[0].items():",
"+# print(color,number)"
]
| false | 0.037306 | 0.036843 | 1.012589 | [
"s385801326",
"s056448151"
]
|
u597374218 | p03210 | python | s535937473 | s428082539 | 29 | 24 | 9,080 | 9,096 | Accepted | Accepted | 17.24 | X = eval(input())
if X in "753":
print("YES")
else:
print("NO") | X = eval(input())
print(("YES" if X in "753" else "NO")) | 5 | 2 | 69 | 49 | X = eval(input())
if X in "753":
print("YES")
else:
print("NO")
| X = eval(input())
print(("YES" if X in "753" else "NO"))
| false | 60 | [
"-if X in \"753\":",
"- print(\"YES\")",
"-else:",
"- print(\"NO\")",
"+print((\"YES\" if X in \"753\" else \"NO\"))"
]
| false | 0.077423 | 0.082357 | 0.940088 | [
"s535937473",
"s428082539"
]
|
u074220993 | p03434 | python | s530168839 | s590496373 | 31 | 28 | 9,068 | 8,976 | Accepted | Accepted | 9.68 | N = int(eval(input()))
A = [int(x) for x in input().split()]
A.sort()
a, b, turn = 0, 0, 1
while len(A) != 0:
if turn & 1:
a += A.pop()
else:
b += A.pop()
turn += 1
print((a-b)) | with open(0) as f:
N, *A = list(map(int, f.read().split()))
A.sort(reverse=True)
Alice = sum(A[::2])
Bob = sum(A[1::2])
print((Alice - Bob)) | 11 | 6 | 207 | 141 | N = int(eval(input()))
A = [int(x) for x in input().split()]
A.sort()
a, b, turn = 0, 0, 1
while len(A) != 0:
if turn & 1:
a += A.pop()
else:
b += A.pop()
turn += 1
print((a - b))
| with open(0) as f:
N, *A = list(map(int, f.read().split()))
A.sort(reverse=True)
Alice = sum(A[::2])
Bob = sum(A[1::2])
print((Alice - Bob))
| false | 45.454545 | [
"-N = int(eval(input()))",
"-A = [int(x) for x in input().split()]",
"-A.sort()",
"-a, b, turn = 0, 0, 1",
"-while len(A) != 0:",
"- if turn & 1:",
"- a += A.pop()",
"- else:",
"- b += A.pop()",
"- turn += 1",
"-print((a - b))",
"+with open(0) as f:",
"+ N, *A = list(map(int, f.read().split()))",
"+A.sort(reverse=True)",
"+Alice = sum(A[::2])",
"+Bob = sum(A[1::2])",
"+print((Alice - Bob))"
]
| false | 0.037756 | 0.037329 | 1.011441 | [
"s530168839",
"s590496373"
]
|
u765237551 | p03702 | python | s189790119 | s836003230 | 1,362 | 797 | 55,896 | 54,616 | Accepted | Accepted | 41.48 | import math
n, a, b = list(map(int, input().split()))
hs = list(map(int, (eval(input()) for _ in range(n))))
m = sum(hs) // (a + (n-1)*b) - 10
M = sum(math.ceil(h/a) for h in hs)
def killable(p, hs, a, b):
x = sum(max(0, math.ceil((h-p*b) / (a-b))) for h in hs)
return x <= p
while(m+1 < M):
c = (m+M) // 2
if killable(c, hs, a, b):
M = c
else:
m = c
print(M) | import math
n, a, b = list(map(int, input().split()))
hs = list(map(int, (eval(input()) for _ in range(n))))
m = sum(hs) // (a + (n-1)*b) - 1
#M = sum(math.ceil(h/a) for h in hs)
M = max(hs) // b + 1
def killable(p, hs, a, b):
x = sum(max(0, math.ceil((h-p*b) / (a-b))) for h in hs)
return x <= p
while(m+1 < M):
c = (m+M) // 2
if killable(c, hs, a, b):
M = c
else:
m = c
print(M) | 19 | 20 | 405 | 427 | import math
n, a, b = list(map(int, input().split()))
hs = list(map(int, (eval(input()) for _ in range(n))))
m = sum(hs) // (a + (n - 1) * b) - 10
M = sum(math.ceil(h / a) for h in hs)
def killable(p, hs, a, b):
x = sum(max(0, math.ceil((h - p * b) / (a - b))) for h in hs)
return x <= p
while m + 1 < M:
c = (m + M) // 2
if killable(c, hs, a, b):
M = c
else:
m = c
print(M)
| import math
n, a, b = list(map(int, input().split()))
hs = list(map(int, (eval(input()) for _ in range(n))))
m = sum(hs) // (a + (n - 1) * b) - 1
# M = sum(math.ceil(h/a) for h in hs)
M = max(hs) // b + 1
def killable(p, hs, a, b):
x = sum(max(0, math.ceil((h - p * b) / (a - b))) for h in hs)
return x <= p
while m + 1 < M:
c = (m + M) // 2
if killable(c, hs, a, b):
M = c
else:
m = c
print(M)
| false | 5 | [
"-m = sum(hs) // (a + (n - 1) * b) - 10",
"-M = sum(math.ceil(h / a) for h in hs)",
"+m = sum(hs) // (a + (n - 1) * b) - 1",
"+# M = sum(math.ceil(h/a) for h in hs)",
"+M = max(hs) // b + 1"
]
| false | 0.067538 | 0.04824 | 1.400038 | [
"s189790119",
"s836003230"
]
|
u840310460 | p03493 | python | s621953614 | s788037568 | 168 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.88 | aaa = list(eval(input()))
bag = []
if aaa[0] == "1":
bag.append(1)
if aaa[1] == "1":
bag.append(1)
if aaa[2] == "1":
bag.append(1)
print((len(bag))) | num = eval(input())
count = [1 for i in range(len(num)) if num[i] =="1"]
print((len(count))) | 9 | 3 | 160 | 86 | aaa = list(eval(input()))
bag = []
if aaa[0] == "1":
bag.append(1)
if aaa[1] == "1":
bag.append(1)
if aaa[2] == "1":
bag.append(1)
print((len(bag)))
| num = eval(input())
count = [1 for i in range(len(num)) if num[i] == "1"]
print((len(count)))
| false | 66.666667 | [
"-aaa = list(eval(input()))",
"-bag = []",
"-if aaa[0] == \"1\":",
"- bag.append(1)",
"-if aaa[1] == \"1\":",
"- bag.append(1)",
"-if aaa[2] == \"1\":",
"- bag.append(1)",
"-print((len(bag)))",
"+num = eval(input())",
"+count = [1 for i in range(len(num)) if num[i] == \"1\"]",
"+print((len(count)))"
]
| false | 0.113091 | 0.077026 | 1.468217 | [
"s621953614",
"s788037568"
]
|
u086503932 | p02631 | python | s760040595 | s865101756 | 216 | 151 | 43,728 | 31,584 | Accepted | Accepted | 30.09 | #!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
def main():
N = int(eval(input()))
a = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(N):
L[i+1] = L[i]^a[i]
R[N-i-1] = R[N-i]^a[N-i-1]
ans = [None]*N
for i in range(N):
ans[i] = L[i]^R[i+1]
print((*ans))
# print(L,R)
if __name__ == "__main__":
main()
| N = int(eval(input()))
A = list(map(int, input().split()))
res = 0
for i in range(N):
res ^= A[i]
ans = [a ^ res for a in A]
print((*ans)) | 22 | 7 | 490 | 140 | #!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
def main():
N = int(eval(input()))
a = list(map(int, input().split()))
L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
L[i + 1] = L[i] ^ a[i]
R[N - i - 1] = R[N - i] ^ a[N - i - 1]
ans = [None] * N
for i in range(N):
ans[i] = L[i] ^ R[i + 1]
print((*ans))
# print(L,R)
if __name__ == "__main__":
main()
| N = int(eval(input()))
A = list(map(int, input().split()))
res = 0
for i in range(N):
res ^= A[i]
ans = [a ^ res for a in A]
print((*ans))
| false | 68.181818 | [
"-#!/usr/bin/env python3",
"-from collections import deque, Counter",
"-from heapq import heappop, heappush",
"-from bisect import bisect_right",
"-",
"-",
"-def main():",
"- N = int(eval(input()))",
"- a = list(map(int, input().split()))",
"- L = [0] * (N + 1)",
"- R = [0] * (N + 1)",
"- for i in range(N):",
"- L[i + 1] = L[i] ^ a[i]",
"- R[N - i - 1] = R[N - i] ^ a[N - i - 1]",
"- ans = [None] * N",
"- for i in range(N):",
"- ans[i] = L[i] ^ R[i + 1]",
"- print((*ans))",
"- # print(L,R)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+N = int(eval(input()))",
"+A = list(map(int, input().split()))",
"+res = 0",
"+for i in range(N):",
"+ res ^= A[i]",
"+ans = [a ^ res for a in A]",
"+print((*ans))"
]
| false | 0.037088 | 0.037923 | 0.977986 | [
"s760040595",
"s865101756"
]
|
u869154953 | p03563 | python | s096533132 | s201863817 | 33 | 23 | 9,148 | 9,084 | Accepted | Accepted | 30.3 | R=int(eval(input()))
G=int(eval(input()))
X=2*G-R
print(X)
| R=int(eval(input()))
G=int(eval(input()))
print(((2*G)-R)) | 7 | 4 | 56 | 48 | R = int(eval(input()))
G = int(eval(input()))
X = 2 * G - R
print(X)
| R = int(eval(input()))
G = int(eval(input()))
print(((2 * G) - R))
| false | 42.857143 | [
"-X = 2 * G - R",
"-print(X)",
"+print(((2 * G) - R))"
]
| false | 0.072257 | 0.081588 | 0.885635 | [
"s096533132",
"s201863817"
]
|
u411203878 | p02756 | python | s558539003 | s297330511 | 840 | 354 | 99,348 | 134,152 | Accepted | Accepted | 57.86 | s = eval(input())
s = list(s)
q=int(eval(input()))
front=[]
back=[]
hantei = True
for _ in range(q):
t = input().split()
if t[0] == '1':
hantei = not hantei
else:
if hantei:
if t[1] == '1':
front.append(t[2])
else:
back.append(t[2])
else:
if t[1] == '2':
front.append(t[2])
else:
back.append(t[2])
if hantei:
front.reverse()
ans = front + s + back
else:
back.reverse()
s.reverse()
ans = back + s + front
print((''.join(map(str,ans)))) | S = list(eval(input()))
N = int(eval(input()))
normalFlag = True
front = []
back = []
for _ in range(N):
q = list(map(str,input().split()))
if q[0] == '1':
normalFlag = not normalFlag
else:
if q[1] == '1':
if normalFlag:
front.append(q[2])
else:
back.append(q[2])
else:
if normalFlag:
back.append(q[2])
else:
front.append(q[2])
if normalFlag:
front.reverse()
ans = front+S+back
else:
back.reverse()
S.reverse()
ans = back+S+front
print((''.join(map(str,ans)))) | 31 | 29 | 622 | 643 | s = eval(input())
s = list(s)
q = int(eval(input()))
front = []
back = []
hantei = True
for _ in range(q):
t = input().split()
if t[0] == "1":
hantei = not hantei
else:
if hantei:
if t[1] == "1":
front.append(t[2])
else:
back.append(t[2])
else:
if t[1] == "2":
front.append(t[2])
else:
back.append(t[2])
if hantei:
front.reverse()
ans = front + s + back
else:
back.reverse()
s.reverse()
ans = back + s + front
print(("".join(map(str, ans))))
| S = list(eval(input()))
N = int(eval(input()))
normalFlag = True
front = []
back = []
for _ in range(N):
q = list(map(str, input().split()))
if q[0] == "1":
normalFlag = not normalFlag
else:
if q[1] == "1":
if normalFlag:
front.append(q[2])
else:
back.append(q[2])
else:
if normalFlag:
back.append(q[2])
else:
front.append(q[2])
if normalFlag:
front.reverse()
ans = front + S + back
else:
back.reverse()
S.reverse()
ans = back + S + front
print(("".join(map(str, ans))))
| false | 6.451613 | [
"-s = eval(input())",
"-s = list(s)",
"-q = int(eval(input()))",
"+S = list(eval(input()))",
"+N = int(eval(input()))",
"+normalFlag = True",
"-hantei = True",
"-for _ in range(q):",
"- t = input().split()",
"- if t[0] == \"1\":",
"- hantei = not hantei",
"+for _ in range(N):",
"+ q = list(map(str, input().split()))",
"+ if q[0] == \"1\":",
"+ normalFlag = not normalFlag",
"- if hantei:",
"- if t[1] == \"1\":",
"- front.append(t[2])",
"+ if q[1] == \"1\":",
"+ if normalFlag:",
"+ front.append(q[2])",
"- back.append(t[2])",
"+ back.append(q[2])",
"- if t[1] == \"2\":",
"- front.append(t[2])",
"+ if normalFlag:",
"+ back.append(q[2])",
"- back.append(t[2])",
"-if hantei:",
"+ front.append(q[2])",
"+if normalFlag:",
"- ans = front + s + back",
"+ ans = front + S + back",
"- s.reverse()",
"- ans = back + s + front",
"+ S.reverse()",
"+ ans = back + S + front"
]
| false | 0.04898 | 0.049365 | 0.992208 | [
"s558539003",
"s297330511"
]
|
u902577051 | p03074 | python | s047421841 | s293837191 | 150 | 125 | 4,768 | 8,608 | Accepted | Accepted | 16.67 | # -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
if s[i] == target:
count += 1
else:
target = 1 - target
rle.append(count)
count = 1
rle.append(count)
if target == 0:
rle.append(0)
offset = 2 * k + 1
res = 0
# two pointers
left = 0
right = 0
cand = 0
for i in range(0, len(rle), 2):
next_left = i
next_right = min(i + offset, len(rle))
while(next_left > left):
cand -= rle[left]
left += 1
while(next_right > right):
cand += rle[right]
right += 1
res = max(res, cand)
print(res) | # -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
if s[i] == target:
count += 1
else:
target = 1 - target
rle.append(count)
count = 1
rle.append(count)
if target == 0:
rle.append(0)
offset = 2 * k + 1
res = 0
# cumsum
rle_cumsum = [0]
for i in range(len(rle)):
rle_cumsum.append(rle_cumsum[i] + rle[i])
for i in range(0, len(rle), 2):
left = i
right = min(i + offset, len(rle))
cand = rle_cumsum[right] - rle_cumsum[left]
res = max(res, cand)
print(res) | 41 | 36 | 731 | 669 | # -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
if s[i] == target:
count += 1
else:
target = 1 - target
rle.append(count)
count = 1
rle.append(count)
if target == 0:
rle.append(0)
offset = 2 * k + 1
res = 0
# two pointers
left = 0
right = 0
cand = 0
for i in range(0, len(rle), 2):
next_left = i
next_right = min(i + offset, len(rle))
while next_left > left:
cand -= rle[left]
left += 1
while next_right > right:
cand += rle[right]
right += 1
res = max(res, cand)
print(res)
| # -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
if s[i] == target:
count += 1
else:
target = 1 - target
rle.append(count)
count = 1
rle.append(count)
if target == 0:
rle.append(0)
offset = 2 * k + 1
res = 0
# cumsum
rle_cumsum = [0]
for i in range(len(rle)):
rle_cumsum.append(rle_cumsum[i] + rle[i])
for i in range(0, len(rle), 2):
left = i
right = min(i + offset, len(rle))
cand = rle_cumsum[right] - rle_cumsum[left]
res = max(res, cand)
print(res)
| false | 12.195122 | [
"-# two pointers",
"-left = 0",
"-right = 0",
"-cand = 0",
"+# cumsum",
"+rle_cumsum = [0]",
"+for i in range(len(rle)):",
"+ rle_cumsum.append(rle_cumsum[i] + rle[i])",
"- next_left = i",
"- next_right = min(i + offset, len(rle))",
"- while next_left > left:",
"- cand -= rle[left]",
"- left += 1",
"- while next_right > right:",
"- cand += rle[right]",
"- right += 1",
"+ left = i",
"+ right = min(i + offset, len(rle))",
"+ cand = rle_cumsum[right] - rle_cumsum[left]"
]
| false | 0.045741 | 0.045073 | 1.014818 | [
"s047421841",
"s293837191"
]
|
u130900604 | p02819 | python | s950217400 | s083463198 | 213 | 30 | 2,940 | 2,940 | Accepted | Accepted | 85.92 | #探索範囲増やすとどのくらい時間が伸びるのか
x=int(eval(input()))
def is_prime(p):
cnt=0
for i in range(2,p):
if p%i==0:
cnt+=1
if cnt==0:
return True
#2からp-1までみて、cntが0ならpは素数
else:
return False
#print(*[(x,is_prime(x)) for x in range(1,10+1)])
num=x
while True:
if is_prime(num):
ans=num
break
num+=1
print(ans)
| x=int(eval(input()))
mod=10**7+9
for i in range(x,mod):
if not any(i%j==0 for j in range(2,i+1-1)):
ans=i
break
print(ans) | 23 | 9 | 355 | 140 | # 探索範囲増やすとどのくらい時間が伸びるのか
x = int(eval(input()))
def is_prime(p):
cnt = 0
for i in range(2, p):
if p % i == 0:
cnt += 1
if cnt == 0:
return True
# 2からp-1までみて、cntが0ならpは素数
else:
return False
# print(*[(x,is_prime(x)) for x in range(1,10+1)])
num = x
while True:
if is_prime(num):
ans = num
break
num += 1
print(ans)
| x = int(eval(input()))
mod = 10**7 + 9
for i in range(x, mod):
if not any(i % j == 0 for j in range(2, i + 1 - 1)):
ans = i
break
print(ans)
| false | 60.869565 | [
"-# 探索範囲増やすとどのくらい時間が伸びるのか",
"-",
"-",
"-def is_prime(p):",
"- cnt = 0",
"- for i in range(2, p):",
"- if p % i == 0:",
"- cnt += 1",
"- if cnt == 0:",
"- return True",
"- # 2からp-1までみて、cntが0ならpは素数",
"- else:",
"- return False",
"-",
"-",
"-# print(*[(x,is_prime(x)) for x in range(1,10+1)])",
"-num = x",
"-while True:",
"- if is_prime(num):",
"- ans = num",
"+mod = 10**7 + 9",
"+for i in range(x, mod):",
"+ if not any(i % j == 0 for j in range(2, i + 1 - 1)):",
"+ ans = i",
"- num += 1"
]
| false | 0.059679 | 0.034624 | 1.723617 | [
"s950217400",
"s083463198"
]
|
u535803878 | p02702 | python | s315274035 | s176305765 | 127 | 94 | 12,668 | 73,220 | Accepted | Accepted | 25.98 | import sys
input = lambda : sys.stdin.readline().rstrip()
import collections
s = [int(c) for c in eval(input())]
tmp = 1
mod = 0
count = collections.defaultdict(int)
for i,num in enumerate(s[::-1]):
mod = (tmp * num + mod) % 2019
count[mod] += 1
tmp *= 10
tmp %= 2019
count[0] += 1
print((sum((item*(item-1)//2 for item in list(count.values()))))) | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
s = eval(input())
n = len(s)
a = [None]*n
c = 0
v = 1
for i in range(n-1, -1, -1):
c = (c + v*int(s[i])) % 2019
a[i] = c
v *= 10
v %= 2019
from collections import Counter
cc = Counter(a)
ans = 0
for k,v in list(cc.items()):
ans += v*(v-1)//2
ans += cc[0]
print(ans) | 15 | 23 | 364 | 438 | import sys
input = lambda: sys.stdin.readline().rstrip()
import collections
s = [int(c) for c in eval(input())]
tmp = 1
mod = 0
count = collections.defaultdict(int)
for i, num in enumerate(s[::-1]):
mod = (tmp * num + mod) % 2019
count[mod] += 1
tmp *= 10
tmp %= 2019
count[0] += 1
print((sum((item * (item - 1) // 2 for item in list(count.values())))))
| import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
s = eval(input())
n = len(s)
a = [None] * n
c = 0
v = 1
for i in range(n - 1, -1, -1):
c = (c + v * int(s[i])) % 2019
a[i] = c
v *= 10
v %= 2019
from collections import Counter
cc = Counter(a)
ans = 0
for k, v in list(cc.items()):
ans += v * (v - 1) // 2
ans += cc[0]
print(ans)
| false | 34.782609 | [
"-import collections",
"+sys.setrecursionlimit(max(1000, 10**9))",
"+write = lambda x: sys.stdout.write(x + \"\\n\")",
"+s = eval(input())",
"+n = len(s)",
"+a = [None] * n",
"+c = 0",
"+v = 1",
"+for i in range(n - 1, -1, -1):",
"+ c = (c + v * int(s[i])) % 2019",
"+ a[i] = c",
"+ v *= 10",
"+ v %= 2019",
"+from collections import Counter",
"-s = [int(c) for c in eval(input())]",
"-tmp = 1",
"-mod = 0",
"-count = collections.defaultdict(int)",
"-for i, num in enumerate(s[::-1]):",
"- mod = (tmp * num + mod) % 2019",
"- count[mod] += 1",
"- tmp *= 10",
"- tmp %= 2019",
"-count[0] += 1",
"-print((sum((item * (item - 1) // 2 for item in list(count.values())))))",
"+cc = Counter(a)",
"+ans = 0",
"+for k, v in list(cc.items()):",
"+ ans += v * (v - 1) // 2",
"+ans += cc[0]",
"+print(ans)"
]
| false | 0.044732 | 0.045495 | 0.983223 | [
"s315274035",
"s176305765"
]
|
u678167152 | p03799 | python | s205068101 | s379268042 | 184 | 64 | 38,256 | 61,224 | Accepted | Accepted | 65.22 | def solve():
N, M = list(map(int, input().split()))
if M<2*N:
return M//2
return N+(M-2*N)//4
print((solve())) | def solve():
N, M = list(map(int, input().split()))
if M<=2*N:
ans = M//2
else:
ans = N+(M-2*N)//4
return ans
print((solve())) | 6 | 8 | 127 | 141 | def solve():
N, M = list(map(int, input().split()))
if M < 2 * N:
return M // 2
return N + (M - 2 * N) // 4
print((solve()))
| def solve():
N, M = list(map(int, input().split()))
if M <= 2 * N:
ans = M // 2
else:
ans = N + (M - 2 * N) // 4
return ans
print((solve()))
| false | 25 | [
"- if M < 2 * N:",
"- return M // 2",
"- return N + (M - 2 * N) // 4",
"+ if M <= 2 * N:",
"+ ans = M // 2",
"+ else:",
"+ ans = N + (M - 2 * N) // 4",
"+ return ans"
]
| false | 0.046135 | 0.045933 | 1.004385 | [
"s205068101",
"s379268042"
]
|
u644778646 | p03363 | python | s510402690 | s557137628 | 319 | 216 | 110,288 | 41,128 | Accepted | Accepted | 32.29 | from collections import defaultdict
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
r = [0]
d = defaultdict(int)
d[0] = 1
ans = 0
for i in range(n):
r.append(r[i] + a[i])
ans += d[r[i+1]]
d[r[i+1]] += 1
print(ans)
if __name__ == '__main__':
main() | from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
ruiseki = [0]
d = defaultdict(int)
d[0] = 1
for i in range(n):
ruiseki.append(ruiseki[i] + a[i])
ans += d[ruiseki[i+1]]
d[ruiseki[i + 1]] += 1
print(ans)
if __name__ == '__main__':
main()
| 19 | 29 | 346 | 613 | from collections import defaultdict
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
r = [0]
d = defaultdict(int)
d[0] = 1
ans = 0
for i in range(n):
r.append(r[i] + a[i])
ans += d[r[i + 1]]
d[r[i + 1]] += 1
print(ans)
if __name__ == "__main__":
main()
| from fractions import gcd
from datetime import date, timedelta
from heapq import *
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
ruiseki = [0]
d = defaultdict(int)
d[0] = 1
for i in range(n):
ruiseki.append(ruiseki[i] + a[i])
ans += d[ruiseki[i + 1]]
d[ruiseki[i + 1]] += 1
print(ans)
if __name__ == "__main__":
main()
| false | 34.482759 | [
"-from collections import defaultdict",
"+from fractions import gcd",
"+from datetime import date, timedelta",
"+from heapq import *",
"+import math",
"+from collections import defaultdict, Counter, deque",
"+import sys",
"+from bisect import *",
"+import itertools",
"+import copy",
"+",
"+sys.setrecursionlimit(10**7)",
"+MOD = 10**9 + 7",
"- r = [0]",
"+ ans = 0",
"+ ruiseki = [0]",
"- ans = 0",
"- r.append(r[i] + a[i])",
"- ans += d[r[i + 1]]",
"- d[r[i + 1]] += 1",
"+ ruiseki.append(ruiseki[i] + a[i])",
"+ ans += d[ruiseki[i + 1]]",
"+ d[ruiseki[i + 1]] += 1"
]
| false | 0.033816 | 0.035876 | 0.942595 | [
"s510402690",
"s557137628"
]
|
u018679195 | p02785 | python | s170778772 | s847756888 | 174 | 158 | 27,276 | 26,024 | Accepted | Accepted | 9.2 | from math import ceil
from sys import stdin
n,k = list(map(int,stdin.readline().split()))
h = sorted(list(map(int,stdin.readline().split())))
ans = 0
for i in range(0,len(h)-k): ans += h[i]
print(ans) | special_moves = input().split(" ")
_, special_moves = int(special_moves [0]), int(special_moves [1])
health= input().split(" ")
health= [int(h) for h in health]
health.sort(reverse=True)
print((sum(health[special_moves:]))) | 7 | 8 | 200 | 230 | from math import ceil
from sys import stdin
n, k = list(map(int, stdin.readline().split()))
h = sorted(list(map(int, stdin.readline().split())))
ans = 0
for i in range(0, len(h) - k):
ans += h[i]
print(ans)
| special_moves = input().split(" ")
_, special_moves = int(special_moves[0]), int(special_moves[1])
health = input().split(" ")
health = [int(h) for h in health]
health.sort(reverse=True)
print((sum(health[special_moves:])))
| false | 12.5 | [
"-from math import ceil",
"-from sys import stdin",
"-",
"-n, k = list(map(int, stdin.readline().split()))",
"-h = sorted(list(map(int, stdin.readline().split())))",
"-ans = 0",
"-for i in range(0, len(h) - k):",
"- ans += h[i]",
"-print(ans)",
"+special_moves = input().split(\" \")",
"+_, special_moves = int(special_moves[0]), int(special_moves[1])",
"+health = input().split(\" \")",
"+health = [int(h) for h in health]",
"+health.sort(reverse=True)",
"+print((sum(health[special_moves:])))"
]
| false | 0.081645 | 0.044326 | 1.84194 | [
"s170778772",
"s847756888"
]
|
u201234972 | p03776 | python | s204340160 | s709150663 | 54 | 21 | 5,848 | 3,316 | Accepted | Accepted | 61.11 | # -*- coding: utf-8 -*-
from statistics import mean
from math import factorial as fact
n,a,b = list(map(int, input().split()))
v = sorted([int(x) for x in input().split()], reverse=True)
sel = v[:a]
print((mean(sel)))
vn = v.count(sel[-1])
na = sel.count(sel[-1])
nb = min(b-a, vn-na)
# print(na,nb,vn,len(sel),sel[-1])
if na!=len(sel):
print((fact(vn)//(fact(na)*fact(vn-na))))
elif nb==0:
print((1))
else:
ret = 0
for bi in range(na,na+nb+1):
ret += fact(vn)//(fact(bi)*fact(vn-bi))
print(ret)
| from math import factorial
from collections import Counter
def combination(a,b):
if a < b:
a, b = b, a
comb = 1
for i in range(b):
comb *= a-i
comb //= factorial(b)
return comb
N, A, B = list(map( int, input().split()))
V = list( map( int, input().split()))
V.sort(reverse = True)
print(( sum(V[:A])/A))
S = list( set(V))
S.sort(reverse = True)
CV = Counter(V)
ans = 0
K = CV[S[0]]
if A <= K:
for i in range(A, min(K, B)+1):
ans += combination(K, i)
else:
cnt = A
for x in S:
if cnt <= CV[x]:
ans += combination(CV[x],cnt)
break
else:
cnt -= CV[x]
print(ans) | 23 | 32 | 537 | 690 | # -*- coding: utf-8 -*-
from statistics import mean
from math import factorial as fact
n, a, b = list(map(int, input().split()))
v = sorted([int(x) for x in input().split()], reverse=True)
sel = v[:a]
print((mean(sel)))
vn = v.count(sel[-1])
na = sel.count(sel[-1])
nb = min(b - a, vn - na)
# print(na,nb,vn,len(sel),sel[-1])
if na != len(sel):
print((fact(vn) // (fact(na) * fact(vn - na))))
elif nb == 0:
print((1))
else:
ret = 0
for bi in range(na, na + nb + 1):
ret += fact(vn) // (fact(bi) * fact(vn - bi))
print(ret)
| from math import factorial
from collections import Counter
def combination(a, b):
if a < b:
a, b = b, a
comb = 1
for i in range(b):
comb *= a - i
comb //= factorial(b)
return comb
N, A, B = list(map(int, input().split()))
V = list(map(int, input().split()))
V.sort(reverse=True)
print((sum(V[:A]) / A))
S = list(set(V))
S.sort(reverse=True)
CV = Counter(V)
ans = 0
K = CV[S[0]]
if A <= K:
for i in range(A, min(K, B) + 1):
ans += combination(K, i)
else:
cnt = A
for x in S:
if cnt <= CV[x]:
ans += combination(CV[x], cnt)
break
else:
cnt -= CV[x]
print(ans)
| false | 28.125 | [
"-# -*- coding: utf-8 -*-",
"-from statistics import mean",
"-from math import factorial as fact",
"+from math import factorial",
"+from collections import Counter",
"-n, a, b = list(map(int, input().split()))",
"-v = sorted([int(x) for x in input().split()], reverse=True)",
"-sel = v[:a]",
"-print((mean(sel)))",
"-vn = v.count(sel[-1])",
"-na = sel.count(sel[-1])",
"-nb = min(b - a, vn - na)",
"-# print(na,nb,vn,len(sel),sel[-1])",
"-if na != len(sel):",
"- print((fact(vn) // (fact(na) * fact(vn - na))))",
"-elif nb == 0:",
"- print((1))",
"+",
"+def combination(a, b):",
"+ if a < b:",
"+ a, b = b, a",
"+ comb = 1",
"+ for i in range(b):",
"+ comb *= a - i",
"+ comb //= factorial(b)",
"+ return comb",
"+",
"+",
"+N, A, B = list(map(int, input().split()))",
"+V = list(map(int, input().split()))",
"+V.sort(reverse=True)",
"+print((sum(V[:A]) / A))",
"+S = list(set(V))",
"+S.sort(reverse=True)",
"+CV = Counter(V)",
"+ans = 0",
"+K = CV[S[0]]",
"+if A <= K:",
"+ for i in range(A, min(K, B) + 1):",
"+ ans += combination(K, i)",
"- ret = 0",
"- for bi in range(na, na + nb + 1):",
"- ret += fact(vn) // (fact(bi) * fact(vn - bi))",
"- print(ret)",
"+ cnt = A",
"+ for x in S:",
"+ if cnt <= CV[x]:",
"+ ans += combination(CV[x], cnt)",
"+ break",
"+ else:",
"+ cnt -= CV[x]",
"+print(ans)"
]
| false | 0.056071 | 0.122017 | 0.459535 | [
"s204340160",
"s709150663"
]
|
u999750647 | p02612 | python | s979764618 | s413376200 | 30 | 26 | 9,164 | 8,904 | Accepted | Accepted | 13.33 | import sys
n = int((eval(input())))
if n%1000 == 0:
print((0))
else:
while n > 1000:
n -= 1000
print((1000-n)) | import sys
n = int((eval(input())))
if n%1000 == 0:
print((0))
else:
for i in range(10):
if n < 1000:
print((1000-n))
sys.exit()
else:
n -= 1000
| 8 | 11 | 127 | 205 | import sys
n = int((eval(input())))
if n % 1000 == 0:
print((0))
else:
while n > 1000:
n -= 1000
print((1000 - n))
| import sys
n = int((eval(input())))
if n % 1000 == 0:
print((0))
else:
for i in range(10):
if n < 1000:
print((1000 - n))
sys.exit()
else:
n -= 1000
| false | 27.272727 | [
"- while n > 1000:",
"- n -= 1000",
"- print((1000 - n))",
"+ for i in range(10):",
"+ if n < 1000:",
"+ print((1000 - n))",
"+ sys.exit()",
"+ else:",
"+ n -= 1000"
]
| false | 0.035976 | 0.041378 | 0.869462 | [
"s979764618",
"s413376200"
]
|
u014333473 | p03860 | python | s227349413 | s608723144 | 28 | 24 | 9,044 | 9,072 | Accepted | Accepted | 14.29 | s=input().split();print((''.join([i[0] for i in s]))) | print(f'A{input()[8]}C') | 1 | 1 | 51 | 24 | s = input().split()
print(("".join([i[0] for i in s])))
| print(f"A{input()[8]}C")
| false | 0 | [
"-s = input().split()",
"-print((\"\".join([i[0] for i in s])))",
"+print(f\"A{input()[8]}C\")"
]
| false | 0.137617 | 0.008182 | 16.819868 | [
"s227349413",
"s608723144"
]
|
u077291787 | p03221 | python | s133578130 | s629766417 | 622 | 483 | 46,120 | 40,524 | Accepted | Accepted | 22.35 | # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
P = [[] for _ in range(N + 1)] # prefectures
for num in range(M):
pref, year = map(int, input().split())
P[pref] += [(year, num)]
ans = []
P = [sorted(p) for p in P] # sort by year
for pref_idx, pref in enumerate(P):
for city_idx, (_, num) in enumerate(pref, 1):
x = "{:06}{:06}".format(pref_idx, city_idx)
ans += [(num, x)]
print(*[i[1] for i in sorted(ans)], sep="\n") # sort by input order
if __name__ == "__main__":
main()
| # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = tuple(map(int, input().split()))
P = [[] for _ in range(N + 1)] # prefectures
for num in range(M): # classify cities by prefectures
pref, year = tuple(map(int, input().split()))
P[pref] += [(year, num)]
ans = [""] * M
P = [sorted(p) for p in P] # sort by year
for pref_idx, pref in enumerate(P):
for city_idx, (_, num) in enumerate(pref, 1):
x = "{:06}{:06}".format(pref_idx, city_idx)
ans[num] = x
print(*ans, sep="\n")
if __name__ == "__main__":
main()
| 20 | 20 | 628 | 630 | # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = map(int, input().split())
P = [[] for _ in range(N + 1)] # prefectures
for num in range(M):
pref, year = map(int, input().split())
P[pref] += [(year, num)]
ans = []
P = [sorted(p) for p in P] # sort by year
for pref_idx, pref in enumerate(P):
for city_idx, (_, num) in enumerate(pref, 1):
x = "{:06}{:06}".format(pref_idx, city_idx)
ans += [(num, x)]
print(*[i[1] for i in sorted(ans)], sep="\n") # sort by input order
if __name__ == "__main__":
main()
| # ABC113C - ID
import sys
input = sys.stdin.readline
def main():
N, M = tuple(map(int, input().split()))
P = [[] for _ in range(N + 1)] # prefectures
for num in range(M): # classify cities by prefectures
pref, year = tuple(map(int, input().split()))
P[pref] += [(year, num)]
ans = [""] * M
P = [sorted(p) for p in P] # sort by year
for pref_idx, pref in enumerate(P):
for city_idx, (_, num) in enumerate(pref, 1):
x = "{:06}{:06}".format(pref_idx, city_idx)
ans[num] = x
print(*ans, sep="\n")
if __name__ == "__main__":
main()
| false | 0 | [
"- N, M = map(int, input().split())",
"+ N, M = tuple(map(int, input().split()))",
"- for num in range(M):",
"- pref, year = map(int, input().split())",
"+ for num in range(M): # classify cities by prefectures",
"+ pref, year = tuple(map(int, input().split()))",
"- ans = []",
"+ ans = [\"\"] * M",
"- ans += [(num, x)]",
"- print(*[i[1] for i in sorted(ans)], sep=\"\\n\") # sort by input order",
"+ ans[num] = x",
"+ print(*ans, sep=\"\\n\")"
]
| false | 0.040927 | 0.036387 | 1.12476 | [
"s133578130",
"s629766417"
]
|
u621935300 | p02803 | python | s828459579 | s408762349 | 245 | 214 | 34,152 | 34,280 | Accepted | Accepted | 12.65 | # -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
H,W=list(map(int, sys.stdin.readline().split()))
S=[ sys.stdin.readline().strip() for _ in range(H) ]
D=[(1,0),(-1,0),(0,1),(0,-1)]
def bfs(start):
Visit={}
q=deque()
q.append(start)
L=defaultdict(lambda: float("inf"))
L[start]=0
while q:
fro_x,fro_y=q.popleft()
for dx,dy in D:
to_x=fro_x+dx
to_y=fro_y+dy
alt=L[(fro_x,fro_y)]+1
if 0<=to_x<H and 0<=to_y<W:
if S[to_x][to_y]=="." and alt<L[(to_x,to_y)]:
L[(to_x,to_y)]=alt
q.append((to_x,to_y))
return max(L.values())
ans=0
for h in range(H):
for w in range(W):
if S[h][w]==".":
ans=max(ans,bfs((h,w)))
print(ans)
| # -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
H,W=list(map(int, sys.stdin.readline().split()))
S=[ sys.stdin.readline().strip() for _ in range(H) ]
D=[(1,0),(-1,0),(0,1),(0,-1)]
def bfs(start):
Visit={}
q=deque()
q.append(start)
Visit[start]=1
L=defaultdict(lambda: float("inf")) #距離
L[start]=0
while q:
fro_x,fro_y=q.popleft()
for dx,dy in D:
to_x=fro_x+dx
to_y=fro_y+dy
if 0<=to_x<H and 0<=to_y<W:
if S[to_x][to_y]=="." and (to_x,to_y) not in Visit:
Visit[to_x,to_y]=1
L[(to_x,to_y)]=min(L[(to_x,to_y)],L[(fro_x,fro_y)]+1)
q.append((to_x,to_y))
if len(list(L.values()))==0:
return 0
else:
return max(L.values())
ans=0
for h in range(H):
for w in range(W):
if S[h][w]==".":
ans=max(ans,bfs((h,w)))
print(ans) | 35 | 40 | 875 | 1,009 | # -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
H, W = list(map(int, sys.stdin.readline().split()))
S = [sys.stdin.readline().strip() for _ in range(H)]
D = [(1, 0), (-1, 0), (0, 1), (0, -1)]
def bfs(start):
Visit = {}
q = deque()
q.append(start)
L = defaultdict(lambda: float("inf"))
L[start] = 0
while q:
fro_x, fro_y = q.popleft()
for dx, dy in D:
to_x = fro_x + dx
to_y = fro_y + dy
alt = L[(fro_x, fro_y)] + 1
if 0 <= to_x < H and 0 <= to_y < W:
if S[to_x][to_y] == "." and alt < L[(to_x, to_y)]:
L[(to_x, to_y)] = alt
q.append((to_x, to_y))
return max(L.values())
ans = 0
for h in range(H):
for w in range(W):
if S[h][w] == ".":
ans = max(ans, bfs((h, w)))
print(ans)
| # -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
H, W = list(map(int, sys.stdin.readline().split()))
S = [sys.stdin.readline().strip() for _ in range(H)]
D = [(1, 0), (-1, 0), (0, 1), (0, -1)]
def bfs(start):
Visit = {}
q = deque()
q.append(start)
Visit[start] = 1
L = defaultdict(lambda: float("inf")) # 距離
L[start] = 0
while q:
fro_x, fro_y = q.popleft()
for dx, dy in D:
to_x = fro_x + dx
to_y = fro_y + dy
if 0 <= to_x < H and 0 <= to_y < W:
if S[to_x][to_y] == "." and (to_x, to_y) not in Visit:
Visit[to_x, to_y] = 1
L[(to_x, to_y)] = min(L[(to_x, to_y)], L[(fro_x, fro_y)] + 1)
q.append((to_x, to_y))
if len(list(L.values())) == 0:
return 0
else:
return max(L.values())
ans = 0
for h in range(H):
for w in range(W):
if S[h][w] == ".":
ans = max(ans, bfs((h, w)))
print(ans)
| false | 12.5 | [
"- L = defaultdict(lambda: float(\"inf\"))",
"+ Visit[start] = 1",
"+ L = defaultdict(lambda: float(\"inf\")) # 距離",
"- alt = L[(fro_x, fro_y)] + 1",
"- if S[to_x][to_y] == \".\" and alt < L[(to_x, to_y)]:",
"- L[(to_x, to_y)] = alt",
"+ if S[to_x][to_y] == \".\" and (to_x, to_y) not in Visit:",
"+ Visit[to_x, to_y] = 1",
"+ L[(to_x, to_y)] = min(L[(to_x, to_y)], L[(fro_x, fro_y)] + 1)",
"- return max(L.values())",
"+ if len(list(L.values())) == 0:",
"+ return 0",
"+ else:",
"+ return max(L.values())"
]
| false | 0.155365 | 0.109385 | 1.420348 | [
"s828459579",
"s408762349"
]
|
u033178473 | p02613 | python | s178248088 | s022380002 | 163 | 80 | 74,772 | 73,508 | Accepted | Accepted | 50.92 | n = int(eval(input()))
a = [0]*4
for i in range(n):
s = eval(input())
if s == "AC":
a[0] += 1
elif s == "WA":
a[1] += 1
elif s == "TLE":
a[2] += 1
else:
a[3] += 1
print(("AC x",a[0]))
print(("WA x",a[1]))
print(("TLE x",a[2]))
print(("RE x",a[3])) | from sys import stdin
input = stdin.readline
n = int(eval(input()))
a = [0]*4
for i in range(n):
s = input().strip()
if s == "AC":
a[0] += 1
elif s == "WA":
a[1] += 1
elif s == "TLE":
a[2] += 1
else:
a[3] += 1
print(("AC x",a[0]))
print(("WA x",a[1]))
print(("TLE x",a[2]))
print(("RE x",a[3])) | 18 | 20 | 306 | 361 | n = int(eval(input()))
a = [0] * 4
for i in range(n):
s = eval(input())
if s == "AC":
a[0] += 1
elif s == "WA":
a[1] += 1
elif s == "TLE":
a[2] += 1
else:
a[3] += 1
print(("AC x", a[0]))
print(("WA x", a[1]))
print(("TLE x", a[2]))
print(("RE x", a[3]))
| from sys import stdin
input = stdin.readline
n = int(eval(input()))
a = [0] * 4
for i in range(n):
s = input().strip()
if s == "AC":
a[0] += 1
elif s == "WA":
a[1] += 1
elif s == "TLE":
a[2] += 1
else:
a[3] += 1
print(("AC x", a[0]))
print(("WA x", a[1]))
print(("TLE x", a[2]))
print(("RE x", a[3]))
| false | 10 | [
"+from sys import stdin",
"+",
"+input = stdin.readline",
"- s = eval(input())",
"+ s = input().strip()"
]
| false | 0.123022 | 0.205947 | 0.597349 | [
"s178248088",
"s022380002"
]
|
u374802266 | p02790 | python | s992201777 | s887413433 | 174 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.23 | a,b=input().split()
e=[str(a*int(b)),str(b*int(a))]
e.sort()
print((e[0]))
| a=sorted(list(map(int,input().split())))
print((str(a[0])*a[1])) | 4 | 2 | 76 | 63 | a, b = input().split()
e = [str(a * int(b)), str(b * int(a))]
e.sort()
print((e[0]))
| a = sorted(list(map(int, input().split())))
print((str(a[0]) * a[1]))
| false | 50 | [
"-a, b = input().split()",
"-e = [str(a * int(b)), str(b * int(a))]",
"-e.sort()",
"-print((e[0]))",
"+a = sorted(list(map(int, input().split())))",
"+print((str(a[0]) * a[1]))"
]
| false | 0.041845 | 0.045982 | 0.910027 | [
"s992201777",
"s887413433"
]
|
u197300773 | p02901 | python | s898643246 | s814851772 | 1,227 | 769 | 3,188 | 3,188 | Accepted | Accepted | 37.33 | def main():
N,M=list(map(int,input().split()))
L=2**N
dp=[10**7 for i in range(L)]
dp[0]=0
for i in range(M):
a, _ = list(map(int, input().split()))
key=sum([2**(int(i)-1) for i in input().split()])
for j in range(L):
q=j|key
dp[q]=min(dp[j]+a,dp[q])
ans=dp[L-1]
print((ans if ans<10**7 else -1))
if __name__ == '__main__':
main() | def main():
n, m = list(map(int, input().split()))
p = 2**n
inf = 10**7
dp = [inf]*p
dp[0] = 0
for _ in range(m):
a, _ = list(map(int, input().split()))
c = sum([1<<(int(i)-1) for i in input().split()])
for s in range(p):
t = s|c
new = dp[s] + a
if dp[t] > new:
dp[t] = new
ans = dp[-1]
if ans == inf:
ans = -1
print(ans)
if __name__ == '__main__':
main()
| 20 | 21 | 428 | 505 | def main():
N, M = list(map(int, input().split()))
L = 2**N
dp = [10**7 for i in range(L)]
dp[0] = 0
for i in range(M):
a, _ = list(map(int, input().split()))
key = sum([2 ** (int(i) - 1) for i in input().split()])
for j in range(L):
q = j | key
dp[q] = min(dp[j] + a, dp[q])
ans = dp[L - 1]
print((ans if ans < 10**7 else -1))
if __name__ == "__main__":
main()
| def main():
n, m = list(map(int, input().split()))
p = 2**n
inf = 10**7
dp = [inf] * p
dp[0] = 0
for _ in range(m):
a, _ = list(map(int, input().split()))
c = sum([1 << (int(i) - 1) for i in input().split()])
for s in range(p):
t = s | c
new = dp[s] + a
if dp[t] > new:
dp[t] = new
ans = dp[-1]
if ans == inf:
ans = -1
print(ans)
if __name__ == "__main__":
main()
| false | 4.761905 | [
"- N, M = list(map(int, input().split()))",
"- L = 2**N",
"- dp = [10**7 for i in range(L)]",
"+ n, m = list(map(int, input().split()))",
"+ p = 2**n",
"+ inf = 10**7",
"+ dp = [inf] * p",
"- for i in range(M):",
"+ for _ in range(m):",
"- key = sum([2 ** (int(i) - 1) for i in input().split()])",
"- for j in range(L):",
"- q = j | key",
"- dp[q] = min(dp[j] + a, dp[q])",
"- ans = dp[L - 1]",
"- print((ans if ans < 10**7 else -1))",
"+ c = sum([1 << (int(i) - 1) for i in input().split()])",
"+ for s in range(p):",
"+ t = s | c",
"+ new = dp[s] + a",
"+ if dp[t] > new:",
"+ dp[t] = new",
"+ ans = dp[-1]",
"+ if ans == inf:",
"+ ans = -1",
"+ print(ans)"
]
| false | 0.188799 | 0.058002 | 3.255018 | [
"s898643246",
"s814851772"
]
|
u633068244 | p00501 | python | s971990874 | s101767354 | 70 | 60 | 4,232 | 4,232 | Accepted | Accepted | 14.29 | n=eval(input())
a=input()
count=0
for r in range(n):
b=input()
lb=len(b)
flag=0
for s in range(lb):
for i in range(lb-(s+1)*(len(a)-1)):
if b[i:i+(s+1)*len(a):s+1]==a:
count+=1
flag=1
break
if flag==1:break
print(count)
| n=eval(input())
a=input()
la=len(a)
count=0
for r in range(n):
b=input()
lb=len(b)
flag=0
for skip in range(lb):
for ini in range(lb-(skip+1)*(la-1)):
if b[ini:ini+(skip+1)*la:skip+1]==a:
count+=1
flag=1
break
if flag==1:break
print(count)
| 16 | 17 | 260 | 281 | n = eval(input())
a = input()
count = 0
for r in range(n):
b = input()
lb = len(b)
flag = 0
for s in range(lb):
for i in range(lb - (s + 1) * (len(a) - 1)):
if b[i : i + (s + 1) * len(a) : s + 1] == a:
count += 1
flag = 1
break
if flag == 1:
break
print(count)
| n = eval(input())
a = input()
la = len(a)
count = 0
for r in range(n):
b = input()
lb = len(b)
flag = 0
for skip in range(lb):
for ini in range(lb - (skip + 1) * (la - 1)):
if b[ini : ini + (skip + 1) * la : skip + 1] == a:
count += 1
flag = 1
break
if flag == 1:
break
print(count)
| false | 5.882353 | [
"+la = len(a)",
"- for s in range(lb):",
"- for i in range(lb - (s + 1) * (len(a) - 1)):",
"- if b[i : i + (s + 1) * len(a) : s + 1] == a:",
"+ for skip in range(lb):",
"+ for ini in range(lb - (skip + 1) * (la - 1)):",
"+ if b[ini : ini + (skip + 1) * la : skip + 1] == a:"
]
| false | 0.140652 | 0.045255 | 3.107954 | [
"s971990874",
"s101767354"
]
|
u674588203 | p02623 | python | s123979363 | s908731923 | 317 | 291 | 42,524 | 40,828 | Accepted | Accepted | 8.2 | from sys import stdin
import bisect
sysin=stdin.readline
N,M,K=[int(x) for x in sysin().rstrip().split()]
a=[int(x) for x in sysin().rstrip().split()]
b=[int(x) for x in sysin().rstrip().split()]
# N,M=3,4
# K=240
# a=[60, 90, 120]
# b=[80, 150, 80, 150]
ans=0
accum_a=[0]
for i in a:
_a=accum_a[-1]+i
if _a>K:
break
else:
accum_a.append(_a)
accum_a.append(K)
accum_b=[0]
for i in b:
accum_b.append(accum_b[-1]+i)
ans=0
for j in range (len(accum_a)-1):
Kb=K-accum_a[j]
bookB=bisect.bisect_right(accum_b,Kb)-1
if j+bookB>ans:
ans=j+bookB
else:
pass
print(ans) | import bisect
N,M,K=list(map(int,input().split()))
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
totaltame_a=[0]
for a in list_a:
temp_a=totaltame_a[-1]+a
if temp_a>K:
break
else:
totaltame_a.append(temp_a)
totaltime_b=[0]
for b in list_b:
totaltime_b.append(totaltime_b[-1]+b)
ans=0
for i in range (len(totaltame_a)):
Kb=K-totaltame_a[i]
j=bisect.bisect_right(totaltime_b,Kb)-1
if i+j>ans:
ans=i+j
else:
pass
print(ans) | 40 | 31 | 670 | 546 | from sys import stdin
import bisect
sysin = stdin.readline
N, M, K = [int(x) for x in sysin().rstrip().split()]
a = [int(x) for x in sysin().rstrip().split()]
b = [int(x) for x in sysin().rstrip().split()]
# N,M=3,4
# K=240
# a=[60, 90, 120]
# b=[80, 150, 80, 150]
ans = 0
accum_a = [0]
for i in a:
_a = accum_a[-1] + i
if _a > K:
break
else:
accum_a.append(_a)
accum_a.append(K)
accum_b = [0]
for i in b:
accum_b.append(accum_b[-1] + i)
ans = 0
for j in range(len(accum_a) - 1):
Kb = K - accum_a[j]
bookB = bisect.bisect_right(accum_b, Kb) - 1
if j + bookB > ans:
ans = j + bookB
else:
pass
print(ans)
| import bisect
N, M, K = list(map(int, input().split()))
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
totaltame_a = [0]
for a in list_a:
temp_a = totaltame_a[-1] + a
if temp_a > K:
break
else:
totaltame_a.append(temp_a)
totaltime_b = [0]
for b in list_b:
totaltime_b.append(totaltime_b[-1] + b)
ans = 0
for i in range(len(totaltame_a)):
Kb = K - totaltame_a[i]
j = bisect.bisect_right(totaltime_b, Kb) - 1
if i + j > ans:
ans = i + j
else:
pass
print(ans)
| false | 22.5 | [
"-from sys import stdin",
"-sysin = stdin.readline",
"-N, M, K = [int(x) for x in sysin().rstrip().split()]",
"-a = [int(x) for x in sysin().rstrip().split()]",
"-b = [int(x) for x in sysin().rstrip().split()]",
"-# N,M=3,4",
"-# K=240",
"-# a=[60, 90, 120]",
"-# b=[80, 150, 80, 150]",
"-ans = 0",
"-accum_a = [0]",
"-for i in a:",
"- _a = accum_a[-1] + i",
"- if _a > K:",
"+N, M, K = list(map(int, input().split()))",
"+list_a = list(map(int, input().split()))",
"+list_b = list(map(int, input().split()))",
"+totaltame_a = [0]",
"+for a in list_a:",
"+ temp_a = totaltame_a[-1] + a",
"+ if temp_a > K:",
"- accum_a.append(_a)",
"-accum_a.append(K)",
"-accum_b = [0]",
"-for i in b:",
"- accum_b.append(accum_b[-1] + i)",
"+ totaltame_a.append(temp_a)",
"+totaltime_b = [0]",
"+for b in list_b:",
"+ totaltime_b.append(totaltime_b[-1] + b)",
"-for j in range(len(accum_a) - 1):",
"- Kb = K - accum_a[j]",
"- bookB = bisect.bisect_right(accum_b, Kb) - 1",
"- if j + bookB > ans:",
"- ans = j + bookB",
"+for i in range(len(totaltame_a)):",
"+ Kb = K - totaltame_a[i]",
"+ j = bisect.bisect_right(totaltime_b, Kb) - 1",
"+ if i + j > ans:",
"+ ans = i + j"
]
| false | 0.110071 | 0.049005 | 2.24612 | [
"s123979363",
"s908731923"
]
|
u368796742 | p03651 | python | s984437568 | s865526332 | 80 | 65 | 20,276 | 20,172 | Accepted | Accepted | 18.75 | import math
n,k = list(map(int,input().split()))
l = sorted(list(map(int,input().split())))
if l[-1] < k:
print("IMPOSSIBLE")
exit()
if k in l:
print("POSSIBLE")
exit()
x = l[0]
for i in l[1:]:
x = math.gcd(x,i)
if x == 1:
print("POSSIBLE")
else:
for i in l:
if (k-i)%x == 0:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| import math
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
if max(l) < k:
print("IMPOSSIBLE")
exit()
x = l[0]
for i in l:
x = math.gcd(x,i)
if x == 1:
print("POSSIBLE")
else:
for i in l:
if (k-i)%x == 0:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| 24 | 20 | 406 | 346 | import math
n, k = list(map(int, input().split()))
l = sorted(list(map(int, input().split())))
if l[-1] < k:
print("IMPOSSIBLE")
exit()
if k in l:
print("POSSIBLE")
exit()
x = l[0]
for i in l[1:]:
x = math.gcd(x, i)
if x == 1:
print("POSSIBLE")
else:
for i in l:
if (k - i) % x == 0:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| import math
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
if max(l) < k:
print("IMPOSSIBLE")
exit()
x = l[0]
for i in l:
x = math.gcd(x, i)
if x == 1:
print("POSSIBLE")
else:
for i in l:
if (k - i) % x == 0:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| false | 16.666667 | [
"-l = sorted(list(map(int, input().split())))",
"-if l[-1] < k:",
"+l = list(map(int, input().split()))",
"+if max(l) < k:",
"-if k in l:",
"- print(\"POSSIBLE\")",
"- exit()",
"-for i in l[1:]:",
"+for i in l:"
]
| false | 0.042198 | 0.034872 | 1.210064 | [
"s984437568",
"s865526332"
]
|
u347640436 | p02939 | python | s010519219 | s641642984 | 81 | 48 | 3,500 | 8,296 | Accepted | Accepted | 40.74 | s = eval(input())
t = ''
k = 0
prev = ''
for i in range(len(s)):
t += s[i]
if prev != t:
k += 1
prev = t
t = ''
print(k)
| def divide_string(s):
result = []
prev, t = '', ''
for i in range(len(s)):
t += s[i]
if prev != t:
result.append(t)
prev, t = t, ''
if t != '':
if len(result) == 1 or len(result[-2]) == 1:
result[-1] = result[-1] + t
else:
result[-2] = result[-2] + t
return result
S = eval(input())
print((len(divide_string(S))))
| 11 | 19 | 141 | 427 | s = eval(input())
t = ""
k = 0
prev = ""
for i in range(len(s)):
t += s[i]
if prev != t:
k += 1
prev = t
t = ""
print(k)
| def divide_string(s):
result = []
prev, t = "", ""
for i in range(len(s)):
t += s[i]
if prev != t:
result.append(t)
prev, t = t, ""
if t != "":
if len(result) == 1 or len(result[-2]) == 1:
result[-1] = result[-1] + t
else:
result[-2] = result[-2] + t
return result
S = eval(input())
print((len(divide_string(S))))
| false | 42.105263 | [
"-s = eval(input())",
"-t = \"\"",
"-k = 0",
"-prev = \"\"",
"-for i in range(len(s)):",
"- t += s[i]",
"- if prev != t:",
"- k += 1",
"- prev = t",
"- t = \"\"",
"-print(k)",
"+def divide_string(s):",
"+ result = []",
"+ prev, t = \"\", \"\"",
"+ for i in range(len(s)):",
"+ t += s[i]",
"+ if prev != t:",
"+ result.append(t)",
"+ prev, t = t, \"\"",
"+ if t != \"\":",
"+ if len(result) == 1 or len(result[-2]) == 1:",
"+ result[-1] = result[-1] + t",
"+ else:",
"+ result[-2] = result[-2] + t",
"+ return result",
"+",
"+",
"+S = eval(input())",
"+print((len(divide_string(S))))"
]
| false | 0.0386 | 0.038075 | 1.013799 | [
"s010519219",
"s641642984"
]
|
u325227960 | p03108 | python | s481587555 | s965123972 | 950 | 683 | 97,624 | 96,476 | Accepted | Accepted | 28.11 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
for j in range(2):
A[i][j] -= 1
U = UnionFind(n)
ans = n * (n-1) // 2
ANS = []
for i in range(m-1, -1, -1):
ANS.append(ans)
a = A[i][0]
b = A[i][1]
ua = U.find(a)
ub = U.find(b)
if ua != ub:
ans -= U.parents[ua] * U.parents[ub]
U.union(ua, ub)
for i in range(len(ANS)-1, -1, -1):
print((ANS[i])) | import sys
input = sys.stdin.readline
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def size(self, x):
if self.parents[x] < 0:
return -self.parents[x]
else:
self.parents[x] = self.size(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
for j in range(2):
A[i][j] -= 1
U = UnionFind(n)
ans = n * (n-1) // 2
ANS = []
for i in range(m-1, -1, -1):
ANS.append(ans)
a = A[i][0]
b = A[i][1]
ua = U.find(a)
ub = U.find(b)
if ua != ub:
ans -= U.size(ua) * U.size(ub)
U.union(ua, ub)
for i in range(len(ANS)-1, -1, -1):
print((ANS[i])) | 47 | 57 | 1,047 | 1,288 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
for j in range(2):
A[i][j] -= 1
U = UnionFind(n)
ans = n * (n - 1) // 2
ANS = []
for i in range(m - 1, -1, -1):
ANS.append(ans)
a = A[i][0]
b = A[i][1]
ua = U.find(a)
ub = U.find(b)
if ua != ub:
ans -= U.parents[ua] * U.parents[ub]
U.union(ua, ub)
for i in range(len(ANS) - 1, -1, -1):
print((ANS[i]))
| import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def size(self, x):
if self.parents[x] < 0:
return -self.parents[x]
else:
self.parents[x] = self.size(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
for j in range(2):
A[i][j] -= 1
U = UnionFind(n)
ans = n * (n - 1) // 2
ANS = []
for i in range(m - 1, -1, -1):
ANS.append(ans)
a = A[i][0]
b = A[i][1]
ua = U.find(a)
ub = U.find(b)
if ua != ub:
ans -= U.size(ua) * U.size(ub)
U.union(ua, ub)
for i in range(len(ANS) - 1, -1, -1):
print((ANS[i]))
| false | 17.54386 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+",
"+ return self.parents[x]",
"+",
"+ def size(self, x):",
"+ if self.parents[x] < 0:",
"+ return -self.parents[x]",
"+ else:",
"+ self.parents[x] = self.size(self.parents[x])",
"- ans -= U.parents[ua] * U.parents[ub]",
"+ ans -= U.size(ua) * U.size(ub)"
]
| false | 0.083144 | 0.113448 | 0.732884 | [
"s481587555",
"s965123972"
]
|
u803848678 | p03182 | python | s277573172 | s866119890 | 1,853 | 1,652 | 126,796 | 107,468 | Accepted | Accepted | 10.85 | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class RAQ_RMQ:
def __init__(self, n, F=min, e=float("inf")):
self.n = n
self.n0 = 2**(n-1).bit_length()
self.e = e
self.F = F
self.lazy = [0]*(2*self.n0)
self.data = [e]*(2*self.n0)
def construct(self, a):
for i, x in enumerate(a):
self.data[i+self.n0] = x
for i in range(self.n0-1, 0, -1):
self.data[i] = self.F(self.data[2*i], self.data[2*i+1])
def bottomup(self, i):
i += self.n0
k = i//(i & -i)
c = k.bit_length()
for j in range(c-1):
k >>= 1
self.data[k] = self.F(self.data[2*k], self.data[2*k+1]) + self.lazy[k]
def topdown(self, i):
i += self.n0
k = i//(i & -i)
c = k.bit_length()
for j in range(c-1):
idx = k >> (c - j - 1)
ax = self.lazy[idx]
if not ax:
continue
self.lazy[idx] = 0
self.data[2*idx] += ax
self.data[2*idx+1] += ax
self.lazy[2*idx] += ax
self.lazy[2*idx+1] += ax
def query(self, l, r):
self.topdown(l)
self.topdown(r)
L = l+self.n0
R = r+self.n0
s = self.e
while L < R:
if R & 1:
R -= 1
s = self.F(s, self.data[R])
if L & 1:
s = self.F(s, self.data[L])
L += 1
L >>= 1
R >>= 1
return s
def add(self, l, r, x):
L = l+self.n0
R = r+self.n0
while L < R :
if R & 1:
R -= 1
self.data[R] += x
self.lazy[R] += x
if L & 1:
self.data[L] += x
self.lazy[L] += x
L += 1
L >>= 1
R >>= 1
self.bottomup(l)
self.bottomup(r)
n,m = list(map(int, input().split()))
memo = [[] for i in range(n+2)]
for i in range(m):
l,r,a = list(map(int, input().split()))
memo[l].append((l,a))
memo[r+1].append((l,-a))
seg = RAQ_RMQ(n+2, F=max, e=-float("inf"))
seg.construct([0]*(n+2))
for i in range(1, n+2):
for j, a in memo[i]:
seg.add(0, j, a)
tmp = seg.query(0, i)
seg.add(i, i+1, tmp)
ans = seg.query(0, n+1)
print(ans) | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class RAQ_RMQ:
def __init__(self, n, a=None, F=min, e=float("inf")):
self.n = n
self.n0 = 2**(n-1).bit_length()
self.e = e
self.F = F
self.lazy = [0]*(2*self.n0)
if a is None:
self.data = [e]*(2*self.n0)
else:
self.data = [0]*(2*self.n0)
self.construct(a)
def construct(self, a):
for i, x in enumerate(a):
self.data[i+self.n0] = x
for i in range(self.n0-1, 0, -1):
self.data[i] = self.F(self.data[2*i], self.data[2*i+1])
def bottomup(self, i):
i += self.n0
k = i//(i & -i)
c = k.bit_length()
for j in range(c-1):
k >>= 1
self.data[k] = self.F(self.data[2*k], self.data[2*k+1]) + self.lazy[k]
def topdown(self, i):
i += self.n0
k = i//(i & -i)
c = k.bit_length()
for j in range(c-1):
idx = k >> (c - j - 1)
ax = self.lazy[idx]
if not ax:
continue
self.lazy[idx] = 0
self.data[2*idx] += ax
self.data[2*idx+1] += ax
self.lazy[2*idx] += ax
self.lazy[2*idx+1] += ax
def query(self, l, r):
self.topdown(l)
self.topdown(r)
L = l+self.n0
R = r+self.n0
s = self.e
while L < R:
if R & 1:
R -= 1
s = self.F(s, self.data[R])
if L & 1:
s = self.F(s, self.data[L])
L += 1
L >>= 1
R >>= 1
return s
def add(self, l, r, x):
L = l+self.n0
R = r+self.n0
while L < R :
if R & 1:
R -= 1
self.data[R] += x
self.lazy[R] += x
if L & 1:
self.data[L] += x
self.lazy[L] += x
L += 1
L >>= 1
R >>= 1
self.bottomup(l)
self.bottomup(r)
n,m = list(map(int, input().split()))
memo = [[] for i in range(n+2)]
for i in range(m):
l,r,a = list(map(int, input().split()))
memo[l].append((l,a))
memo[r+1].append((l,-a))
seg = RAQ_RMQ(n+2, a=[0]*(n+2), F=max, e=-float("inf"))
for i in range(1, n+2):
for j, a in memo[i]:
seg.add(0, j, a)
tmp = seg.query(0, i)
seg.add(i, i+1, tmp)
ans = seg.query(0, n+1)
print(ans) | 95 | 101 | 2,479 | 2,594 | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class RAQ_RMQ:
def __init__(self, n, F=min, e=float("inf")):
self.n = n
self.n0 = 2 ** (n - 1).bit_length()
self.e = e
self.F = F
self.lazy = [0] * (2 * self.n0)
self.data = [e] * (2 * self.n0)
def construct(self, a):
for i, x in enumerate(a):
self.data[i + self.n0] = x
for i in range(self.n0 - 1, 0, -1):
self.data[i] = self.F(self.data[2 * i], self.data[2 * i + 1])
def bottomup(self, i):
i += self.n0
k = i // (i & -i)
c = k.bit_length()
for j in range(c - 1):
k >>= 1
self.data[k] = self.F(self.data[2 * k], self.data[2 * k + 1]) + self.lazy[k]
def topdown(self, i):
i += self.n0
k = i // (i & -i)
c = k.bit_length()
for j in range(c - 1):
idx = k >> (c - j - 1)
ax = self.lazy[idx]
if not ax:
continue
self.lazy[idx] = 0
self.data[2 * idx] += ax
self.data[2 * idx + 1] += ax
self.lazy[2 * idx] += ax
self.lazy[2 * idx + 1] += ax
def query(self, l, r):
self.topdown(l)
self.topdown(r)
L = l + self.n0
R = r + self.n0
s = self.e
while L < R:
if R & 1:
R -= 1
s = self.F(s, self.data[R])
if L & 1:
s = self.F(s, self.data[L])
L += 1
L >>= 1
R >>= 1
return s
def add(self, l, r, x):
L = l + self.n0
R = r + self.n0
while L < R:
if R & 1:
R -= 1
self.data[R] += x
self.lazy[R] += x
if L & 1:
self.data[L] += x
self.lazy[L] += x
L += 1
L >>= 1
R >>= 1
self.bottomup(l)
self.bottomup(r)
n, m = list(map(int, input().split()))
memo = [[] for i in range(n + 2)]
for i in range(m):
l, r, a = list(map(int, input().split()))
memo[l].append((l, a))
memo[r + 1].append((l, -a))
seg = RAQ_RMQ(n + 2, F=max, e=-float("inf"))
seg.construct([0] * (n + 2))
for i in range(1, n + 2):
for j, a in memo[i]:
seg.add(0, j, a)
tmp = seg.query(0, i)
seg.add(i, i + 1, tmp)
ans = seg.query(0, n + 1)
print(ans)
| import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class RAQ_RMQ:
def __init__(self, n, a=None, F=min, e=float("inf")):
self.n = n
self.n0 = 2 ** (n - 1).bit_length()
self.e = e
self.F = F
self.lazy = [0] * (2 * self.n0)
if a is None:
self.data = [e] * (2 * self.n0)
else:
self.data = [0] * (2 * self.n0)
self.construct(a)
def construct(self, a):
for i, x in enumerate(a):
self.data[i + self.n0] = x
for i in range(self.n0 - 1, 0, -1):
self.data[i] = self.F(self.data[2 * i], self.data[2 * i + 1])
def bottomup(self, i):
i += self.n0
k = i // (i & -i)
c = k.bit_length()
for j in range(c - 1):
k >>= 1
self.data[k] = self.F(self.data[2 * k], self.data[2 * k + 1]) + self.lazy[k]
def topdown(self, i):
i += self.n0
k = i // (i & -i)
c = k.bit_length()
for j in range(c - 1):
idx = k >> (c - j - 1)
ax = self.lazy[idx]
if not ax:
continue
self.lazy[idx] = 0
self.data[2 * idx] += ax
self.data[2 * idx + 1] += ax
self.lazy[2 * idx] += ax
self.lazy[2 * idx + 1] += ax
def query(self, l, r):
self.topdown(l)
self.topdown(r)
L = l + self.n0
R = r + self.n0
s = self.e
while L < R:
if R & 1:
R -= 1
s = self.F(s, self.data[R])
if L & 1:
s = self.F(s, self.data[L])
L += 1
L >>= 1
R >>= 1
return s
def add(self, l, r, x):
L = l + self.n0
R = r + self.n0
while L < R:
if R & 1:
R -= 1
self.data[R] += x
self.lazy[R] += x
if L & 1:
self.data[L] += x
self.lazy[L] += x
L += 1
L >>= 1
R >>= 1
self.bottomup(l)
self.bottomup(r)
n, m = list(map(int, input().split()))
memo = [[] for i in range(n + 2)]
for i in range(m):
l, r, a = list(map(int, input().split()))
memo[l].append((l, a))
memo[r + 1].append((l, -a))
seg = RAQ_RMQ(n + 2, a=[0] * (n + 2), F=max, e=-float("inf"))
for i in range(1, n + 2):
for j, a in memo[i]:
seg.add(0, j, a)
tmp = seg.query(0, i)
seg.add(i, i + 1, tmp)
ans = seg.query(0, n + 1)
print(ans)
| false | 5.940594 | [
"- def __init__(self, n, F=min, e=float(\"inf\")):",
"+ def __init__(self, n, a=None, F=min, e=float(\"inf\")):",
"- self.data = [e] * (2 * self.n0)",
"+ if a is None:",
"+ self.data = [e] * (2 * self.n0)",
"+ else:",
"+ self.data = [0] * (2 * self.n0)",
"+ self.construct(a)",
"-seg = RAQ_RMQ(n + 2, F=max, e=-float(\"inf\"))",
"-seg.construct([0] * (n + 2))",
"+seg = RAQ_RMQ(n + 2, a=[0] * (n + 2), F=max, e=-float(\"inf\"))"
]
| false | 0.11659 | 0.03976 | 2.932363 | [
"s277573172",
"s866119890"
]
|
u600402037 | p02972 | python | s164552735 | s855155124 | 1,532 | 240 | 21,864 | 11,696 | Accepted | Accepted | 84.33 | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = np.array([0] + lr())
for i in range(N//2, 0, -1):
a = A[i]
result = A[i::i].sum()
if result % 2 != a:
A[i] = 1 - a
B = np.where(A == 1)[0]
print((len(B)))
print((*B))
| import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = [0] + lr()
# 後ろから決める、愚直にやって計算時間はNlogN
for i in range(N, 0, -1):
result = sum(A[i::i]) % 2
if A[i] != result:
A[i] = 1 - A[i]
print((sum(A)))
print((*[i for i, x in enumerate(A) if x]))
| 18 | 16 | 354 | 347 | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = np.array([0] + lr())
for i in range(N // 2, 0, -1):
a = A[i]
result = A[i::i].sum()
if result % 2 != a:
A[i] = 1 - a
B = np.where(A == 1)[0]
print((len(B)))
print((*B))
| import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = [0] + lr()
# 後ろから決める、愚直にやって計算時間はNlogN
for i in range(N, 0, -1):
result = sum(A[i::i]) % 2
if A[i] != result:
A[i] = 1 - A[i]
print((sum(A)))
print((*[i for i, x in enumerate(A) if x]))
| false | 11.111111 | [
"-import numpy as np",
"-A = np.array([0] + lr())",
"-for i in range(N // 2, 0, -1):",
"- a = A[i]",
"- result = A[i::i].sum()",
"- if result % 2 != a:",
"- A[i] = 1 - a",
"-B = np.where(A == 1)[0]",
"-print((len(B)))",
"-print((*B))",
"+A = [0] + lr()",
"+# 後ろから決める、愚直にやって計算時間はNlogN",
"+for i in range(N, 0, -1):",
"+ result = sum(A[i::i]) % 2",
"+ if A[i] != result:",
"+ A[i] = 1 - A[i]",
"+print((sum(A)))",
"+print((*[i for i, x in enumerate(A) if x]))"
]
| false | 0.242505 | 0.045885 | 5.285119 | [
"s164552735",
"s855155124"
]
|
u909643606 | p03048 | python | s764138741 | s444021031 | 1,545 | 18 | 2,940 | 3,064 | Accepted | Accepted | 98.83 |
r, g, b, n = [int(i) for i in input().split()]
ans = 0
for i in range(n//b + 1):
for j in range((n-i*b)//g + 1):
if (n - i*b - g*j) % r == 0:
ans += 1
print(ans) | def trans(n, dp, color):
for i in range(n-color+1):
dp[i+color] += dp[i]
return dp
def main():
r, g, b, n = [int(i) for i in input().split()]
dp = [0 for i in range(n+1)]
dp[0] = 1
dp = trans(n, dp, r)
dp = trans(n, dp, g)
dp = trans(n, dp, b)
print((dp[-1]))
main() | 11 | 15 | 199 | 324 | r, g, b, n = [int(i) for i in input().split()]
ans = 0
for i in range(n // b + 1):
for j in range((n - i * b) // g + 1):
if (n - i * b - g * j) % r == 0:
ans += 1
print(ans)
| def trans(n, dp, color):
for i in range(n - color + 1):
dp[i + color] += dp[i]
return dp
def main():
r, g, b, n = [int(i) for i in input().split()]
dp = [0 for i in range(n + 1)]
dp[0] = 1
dp = trans(n, dp, r)
dp = trans(n, dp, g)
dp = trans(n, dp, b)
print((dp[-1]))
main()
| false | 26.666667 | [
"-r, g, b, n = [int(i) for i in input().split()]",
"-ans = 0",
"-for i in range(n // b + 1):",
"- for j in range((n - i * b) // g + 1):",
"- if (n - i * b - g * j) % r == 0:",
"- ans += 1",
"-print(ans)",
"+def trans(n, dp, color):",
"+ for i in range(n - color + 1):",
"+ dp[i + color] += dp[i]",
"+ return dp",
"+",
"+",
"+def main():",
"+ r, g, b, n = [int(i) for i in input().split()]",
"+ dp = [0 for i in range(n + 1)]",
"+ dp[0] = 1",
"+ dp = trans(n, dp, r)",
"+ dp = trans(n, dp, g)",
"+ dp = trans(n, dp, b)",
"+ print((dp[-1]))",
"+",
"+",
"+main()"
]
| false | 0.141302 | 0.040485 | 3.490249 | [
"s764138741",
"s444021031"
]
|
u644907318 | p03559 | python | s155083683 | s692554133 | 538 | 225 | 112,996 | 107,628 | Accepted | Accepted | 58.18 | from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
F = [0 for _ in range(N+1)]
for i in range(N-1,-1,-1):
b = B[i]
indC = bisect_right(C,b)
if i<N-1:
indC1 = bisect_right(C,B[i+1])
else:
indC1 = N
F[i] = F[i+1]+indC1-indC
G = [0 for _ in range(N+1)]
for i in range(N-1,-1,-1):
G[i] = G[i+1]+F[i]
cnt = 0
for i in range(N):
a = A[i]
indB = bisect_right(B,a)
cnt += G[indB]
print(cnt) | from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
B1 = []
for i in range(N):
ind = bisect_right(C,B[i])
B1.append(ind)
B2 = [0 for _ in range(N+1)]
for i in range(N-1,-1,-1):
B2[i] = B2[i+1]+N-B1[i]
cnt = 0
for i in range(N):
ind = bisect_right(B,A[i])
cnt += B2[ind]
print(cnt) | 23 | 17 | 583 | 442 | from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
F = [0 for _ in range(N + 1)]
for i in range(N - 1, -1, -1):
b = B[i]
indC = bisect_right(C, b)
if i < N - 1:
indC1 = bisect_right(C, B[i + 1])
else:
indC1 = N
F[i] = F[i + 1] + indC1 - indC
G = [0 for _ in range(N + 1)]
for i in range(N - 1, -1, -1):
G[i] = G[i + 1] + F[i]
cnt = 0
for i in range(N):
a = A[i]
indB = bisect_right(B, a)
cnt += G[indB]
print(cnt)
| from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
B1 = []
for i in range(N):
ind = bisect_right(C, B[i])
B1.append(ind)
B2 = [0 for _ in range(N + 1)]
for i in range(N - 1, -1, -1):
B2[i] = B2[i + 1] + N - B1[i]
cnt = 0
for i in range(N):
ind = bisect_right(B, A[i])
cnt += B2[ind]
print(cnt)
| false | 26.086957 | [
"-F = [0 for _ in range(N + 1)]",
"+B1 = []",
"+for i in range(N):",
"+ ind = bisect_right(C, B[i])",
"+ B1.append(ind)",
"+B2 = [0 for _ in range(N + 1)]",
"- b = B[i]",
"- indC = bisect_right(C, b)",
"- if i < N - 1:",
"- indC1 = bisect_right(C, B[i + 1])",
"- else:",
"- indC1 = N",
"- F[i] = F[i + 1] + indC1 - indC",
"-G = [0 for _ in range(N + 1)]",
"-for i in range(N - 1, -1, -1):",
"- G[i] = G[i + 1] + F[i]",
"+ B2[i] = B2[i + 1] + N - B1[i]",
"- a = A[i]",
"- indB = bisect_right(B, a)",
"- cnt += G[indB]",
"+ ind = bisect_right(B, A[i])",
"+ cnt += B2[ind]"
]
| false | 0.036785 | 0.047125 | 0.780593 | [
"s155083683",
"s692554133"
]
|
u141610915 | p03039 | python | s482412940 | s489938116 | 1,933 | 214 | 74,588 | 54,644 | Accepted | Accepted | 88.93 | from math import factorial as f
N, M, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
def combi(n, r):
return f(n) // (f(n - r) * f(r)) % mod
res = 0
c = combi(N * M - 2, K - 2)
for i in range(1, N):
res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod
res %= mod
for i in range(1, M):
res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod
res %= mod
print((res % mod))
| import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
class Factorial:
def __init__(self, n, mod):
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[: : -1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(N * M, mod)
t = f.combi(N * M - 2, K - 2)
res = 0
for d in range(1, M):
x = N ** 2 % mod * (M - d) % mod
res += x * d % mod
res %= mod
#print(x)
for d in range(1, N):
y = M ** 2 % mod * (N - d) % mod
res += y * d % mod
res %= mod
#print(res, t)
print((res * t % mod)) | 19 | 35 | 402 | 884 | from math import factorial as f
N, M, K = list(map(int, input().split()))
mod = 10**9 + 7
def combi(n, r):
return f(n) // (f(n - r) * f(r)) % mod
res = 0
c = combi(N * M - 2, K - 2)
for i in range(1, N):
res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod
res %= mod
for i in range(1, M):
res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod
res %= mod
print((res % mod))
| import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
mod = 10**9 + 7
class Factorial:
def __init__(self, n, mod):
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[::-1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(N * M, mod)
t = f.combi(N * M - 2, K - 2)
res = 0
for d in range(1, M):
x = N**2 % mod * (M - d) % mod
res += x * d % mod
res %= mod
# print(x)
for d in range(1, N):
y = M**2 % mod * (N - d) % mod
res += y * d % mod
res %= mod
# print(res, t)
print((res * t % mod))
| false | 45.714286 | [
"-from math import factorial as f",
"+import sys",
"+input = sys.stdin.readline",
"-def combi(n, r):",
"- return f(n) // (f(n - r) * f(r)) % mod",
"+class Factorial:",
"+ def __init__(self, n, mod):",
"+ self.f = [1]",
"+ for i in range(1, n + 1):",
"+ self.f.append(self.f[-1] * i % mod)",
"+ self.i = [pow(self.f[-1], mod - 2, mod)]",
"+ for i in range(1, n + 1)[::-1]:",
"+ self.i.append(self.i[-1] * i % mod)",
"+ self.i.reverse()",
"+",
"+ def factorial(self, i):",
"+ return self.f[i]",
"+",
"+ def ifactorial(self, i):",
"+ return self.i[i]",
"+",
"+ def combi(self, n, k):",
"+ return self.f[n] * self.i[n - k] % mod * self.i[k] % mod",
"+f = Factorial(N * M, mod)",
"+t = f.combi(N * M - 2, K - 2)",
"-c = combi(N * M - 2, K - 2)",
"-for i in range(1, N):",
"- res += ((N - i + 1) * (N - i) // 2) * c * M * M % mod",
"+for d in range(1, M):",
"+ x = N**2 % mod * (M - d) % mod",
"+ res += x * d % mod",
"-for i in range(1, M):",
"- res += ((M - i + 1) * (M - i) // 2) * c * N * N % mod",
"+ # print(x)",
"+for d in range(1, N):",
"+ y = M**2 % mod * (N - d) % mod",
"+ res += y * d % mod",
"-print((res % mod))",
"+# print(res, t)",
"+print((res * t % mod))"
]
| false | 0.040728 | 0.037932 | 1.073718 | [
"s482412940",
"s489938116"
]
|
u597374218 | p02725 | python | s950455447 | s739483263 | 112 | 101 | 25,840 | 26,444 | Accepted | Accepted | 9.82 | K,N=list(map(int,input().split()))
A=list(map(int,input().split()))
A+=[A[0]+K]
print((min(K-(A[i+1]-A[i]) for i in range(N)))) | K,N=list(map(int,input().split()))
A=list(map(int,input().split()))
A+=[A[0]+K]
print((K-max(A[i+1]-A[i] for i in range(N)))) | 4 | 4 | 122 | 120 | K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A += [A[0] + K]
print((min(K - (A[i + 1] - A[i]) for i in range(N))))
| K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A += [A[0] + K]
print((K - max(A[i + 1] - A[i] for i in range(N))))
| false | 0 | [
"-print((min(K - (A[i + 1] - A[i]) for i in range(N))))",
"+print((K - max(A[i + 1] - A[i] for i in range(N))))"
]
| false | 0.035384 | 0.0409 | 0.865139 | [
"s950455447",
"s739483263"
]
|
u366959492 | p03281 | python | s585466962 | s783087740 | 206 | 169 | 38,896 | 38,384 | Accepted | Accepted | 17.96 | n=int(eval(input()))
x=0
for j in range(1,n+1):
if j%2==0:
continue
m=0
for i in range(1,j+1):
if j%i==0:
m+=1
if m==8:
x+=1
print(x)
| def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
n=int(eval(input()))
if n<105:
print((0))
exit()
ans=1
for i in range(106,n+1):
if i%2==0:
continue
l=make_divisors(i)
if len(l)==8:
ans+=1
print(ans)
| 12 | 22 | 191 | 439 | n = int(eval(input()))
x = 0
for j in range(1, n + 1):
if j % 2 == 0:
continue
m = 0
for i in range(1, j + 1):
if j % i == 0:
m += 1
if m == 8:
x += 1
print(x)
| def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
divisors.sort()
return divisors
n = int(eval(input()))
if n < 105:
print((0))
exit()
ans = 1
for i in range(106, n + 1):
if i % 2 == 0:
continue
l = make_divisors(i)
if len(l) == 8:
ans += 1
print(ans)
| false | 45.454545 | [
"+def make_divisors(n):",
"+ divisors = []",
"+ for i in range(1, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ divisors.append(i)",
"+ if i != n // i:",
"+ divisors.append(n // i)",
"+ divisors.sort()",
"+ return divisors",
"+",
"+",
"-x = 0",
"-for j in range(1, n + 1):",
"- if j % 2 == 0:",
"+if n < 105:",
"+ print((0))",
"+ exit()",
"+ans = 1",
"+for i in range(106, n + 1):",
"+ if i % 2 == 0:",
"- m = 0",
"- for i in range(1, j + 1):",
"- if j % i == 0:",
"- m += 1",
"- if m == 8:",
"- x += 1",
"-print(x)",
"+ l = make_divisors(i)",
"+ if len(l) == 8:",
"+ ans += 1",
"+print(ans)"
]
| false | 0.040234 | 0.101183 | 0.397633 | [
"s585466962",
"s783087740"
]
|
u301387419 | p02887 | python | s325472729 | s202092907 | 767 | 43 | 3,388 | 3,316 | Accepted | Accepted | 94.39 | N = int(eval(input()))
s = eval(input())
temp = s[0]
i = 1
while i < len(s):
if s[i] == temp:
s = s[:i] + s[i+1:]
else:
temp = s[i]
i += 1
print((len(s)))
| N = int(eval(input()))
s = eval(input())
cnt = 1
for i in range(1,N):
if s[i] != s[i-1]:
cnt += 1
print(cnt)
| 13 | 7 | 175 | 109 | N = int(eval(input()))
s = eval(input())
temp = s[0]
i = 1
while i < len(s):
if s[i] == temp:
s = s[:i] + s[i + 1 :]
else:
temp = s[i]
i += 1
print((len(s)))
| N = int(eval(input()))
s = eval(input())
cnt = 1
for i in range(1, N):
if s[i] != s[i - 1]:
cnt += 1
print(cnt)
| false | 46.153846 | [
"-temp = s[0]",
"-i = 1",
"-while i < len(s):",
"- if s[i] == temp:",
"- s = s[:i] + s[i + 1 :]",
"- else:",
"- temp = s[i]",
"- i += 1",
"-print((len(s)))",
"+cnt = 1",
"+for i in range(1, N):",
"+ if s[i] != s[i - 1]:",
"+ cnt += 1",
"+print(cnt)"
]
| false | 0.109075 | 0.035219 | 3.09703 | [
"s325472729",
"s202092907"
]
|
u210827208 | p03363 | python | s240866502 | s591586436 | 240 | 153 | 41,448 | 39,296 | Accepted | Accepted | 36.25 | from _collections import defaultdict
n=int(eval(input()))
A=list(map(int,input().split()))
X=[A[0]]
for i in range(1,n):
X.append(X[-1]+A[i])
Y=defaultdict(int)
for x in X:
Y[x]+=1
ans=0
for y in list(Y.values()):
ans+=(y-1)*y//2
print((ans+Y[0])) | from collections import Counter
from itertools import accumulate
n=int(eval(input()))
A=accumulate(list(map(int,input().split())))
Y=Counter(A)
ans=0
for y in list(Y.values()):
ans+=(y-1)*y//2
print((ans+Y[0])) | 14 | 9 | 259 | 208 | from _collections import defaultdict
n = int(eval(input()))
A = list(map(int, input().split()))
X = [A[0]]
for i in range(1, n):
X.append(X[-1] + A[i])
Y = defaultdict(int)
for x in X:
Y[x] += 1
ans = 0
for y in list(Y.values()):
ans += (y - 1) * y // 2
print((ans + Y[0]))
| from collections import Counter
from itertools import accumulate
n = int(eval(input()))
A = accumulate(list(map(int, input().split())))
Y = Counter(A)
ans = 0
for y in list(Y.values()):
ans += (y - 1) * y // 2
print((ans + Y[0]))
| false | 35.714286 | [
"-from _collections import defaultdict",
"+from collections import Counter",
"+from itertools import accumulate",
"-A = list(map(int, input().split()))",
"-X = [A[0]]",
"-for i in range(1, n):",
"- X.append(X[-1] + A[i])",
"-Y = defaultdict(int)",
"-for x in X:",
"- Y[x] += 1",
"+A = accumulate(list(map(int, input().split())))",
"+Y = Counter(A)"
]
| false | 0.034432 | 0.090953 | 0.378566 | [
"s240866502",
"s591586436"
]
|
u057109575 | p02787 | python | s337251204 | s419457085 | 559 | 474 | 120,540 | 152,268 | Accepted | Accepted | 15.21 | H, N = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
dp = [[10 ** 9] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i, (a, b) in enumerate(X):
for j in range(H + 1):
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
dp[i + 1][min(j + a, H)] = min(dp[i + 1][min(j + a, H)], dp[i + 1][j] + b)
print((dp[-1][-1]))
| H, N = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
inf = 10 ** 9 + 7
dp = [[inf] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
for j in range(H + 1):
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
dp[i + 1][min(j + X[i][0], H)] = min(dp[i + 1][min(j + X[i][0], H)],
dp[i][j] + X[i][1],
dp[i + 1][j] + X[i][1])
print((dp[-1][-1]))
| 12 | 15 | 375 | 516 | H, N = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
dp = [[10**9] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i, (a, b) in enumerate(X):
for j in range(H + 1):
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
dp[i + 1][min(j + a, H)] = min(dp[i + 1][min(j + a, H)], dp[i + 1][j] + b)
print((dp[-1][-1]))
| H, N = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
inf = 10**9 + 7
dp = [[inf] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
for j in range(H + 1):
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
dp[i + 1][min(j + X[i][0], H)] = min(
dp[i + 1][min(j + X[i][0], H)], dp[i][j] + X[i][1], dp[i + 1][j] + X[i][1]
)
print((dp[-1][-1]))
| false | 20 | [
"-dp = [[10**9] * (H + 1) for _ in range(N + 1)]",
"+inf = 10**9 + 7",
"+dp = [[inf] * (H + 1) for _ in range(N + 1)]",
"-for i, (a, b) in enumerate(X):",
"+for i in range(N):",
"- dp[i + 1][min(j + a, H)] = min(dp[i + 1][min(j + a, H)], dp[i + 1][j] + b)",
"+ dp[i + 1][min(j + X[i][0], H)] = min(",
"+ dp[i + 1][min(j + X[i][0], H)], dp[i][j] + X[i][1], dp[i + 1][j] + X[i][1]",
"+ )"
]
| false | 0.177755 | 0.425157 | 0.418092 | [
"s337251204",
"s419457085"
]
|
u759726213 | p03478 | python | s374356182 | s037922983 | 34 | 28 | 3,296 | 2,940 | Accepted | Accepted | 17.65 | n, a, b = list(map(int, input().split()))
ans = []
for i in range(1,n+1):
num = 0
for j in str(i):
num += int(j)
if a <= num <= b:
ans.append(i)
print((sum(ans))) | n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1,n+1):
# i = 10
n1 = i
n2 = 0
while n1 != 0:
n2 += n1%10
n1 = n1//10
if a <= n2 <= b:
ans += i
print(ans)
| 10 | 14 | 192 | 225 | n, a, b = list(map(int, input().split()))
ans = []
for i in range(1, n + 1):
num = 0
for j in str(i):
num += int(j)
if a <= num <= b:
ans.append(i)
print((sum(ans)))
| n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
# i = 10
n1 = i
n2 = 0
while n1 != 0:
n2 += n1 % 10
n1 = n1 // 10
if a <= n2 <= b:
ans += i
print(ans)
| false | 28.571429 | [
"-ans = []",
"+ans = 0",
"- num = 0",
"- for j in str(i):",
"- num += int(j)",
"- if a <= num <= b:",
"- ans.append(i)",
"-print((sum(ans)))",
"+ # i = 10",
"+ n1 = i",
"+ n2 = 0",
"+ while n1 != 0:",
"+ n2 += n1 % 10",
"+ n1 = n1 // 10",
"+ if a <= n2 <= b:",
"+ ans += i",
"+print(ans)"
]
| false | 0.082454 | 0.068232 | 1.208439 | [
"s374356182",
"s037922983"
]
|
u094191970 | p02641 | python | s060127723 | s983808921 | 22 | 20 | 9,144 | 9,184 | Accepted | Accepted | 9.09 | nii=lambda:list(map(int,input().split()))
lnii=lambda:list(map(int,input().split()))
x,n=nii()
p=lnii()
dist=1000
ans=[]
aa=[]
for i in range(-10,110):
if i not in p:
ans.append(abs(x-i))
aa.append(i)
min_inx=ans.index(min(ans))
print((aa[min_inx])) | nii=lambda:list(map(int,input().split()))
lnii=lambda:list(map(int,input().split()))
x,n=nii()
p=lnii()
dist=1000
ans=1000
for i in range(101,-1,-1):
if i not in p:
t_dist=abs(x-i)
if t_dist<=dist:
dist=t_dist
ans=i
print(ans) | 15 | 15 | 267 | 258 | nii = lambda: list(map(int, input().split()))
lnii = lambda: list(map(int, input().split()))
x, n = nii()
p = lnii()
dist = 1000
ans = []
aa = []
for i in range(-10, 110):
if i not in p:
ans.append(abs(x - i))
aa.append(i)
min_inx = ans.index(min(ans))
print((aa[min_inx]))
| nii = lambda: list(map(int, input().split()))
lnii = lambda: list(map(int, input().split()))
x, n = nii()
p = lnii()
dist = 1000
ans = 1000
for i in range(101, -1, -1):
if i not in p:
t_dist = abs(x - i)
if t_dist <= dist:
dist = t_dist
ans = i
print(ans)
| false | 0 | [
"-ans = []",
"-aa = []",
"-for i in range(-10, 110):",
"+ans = 1000",
"+for i in range(101, -1, -1):",
"- ans.append(abs(x - i))",
"- aa.append(i)",
"-min_inx = ans.index(min(ans))",
"-print((aa[min_inx]))",
"+ t_dist = abs(x - i)",
"+ if t_dist <= dist:",
"+ dist = t_dist",
"+ ans = i",
"+print(ans)"
]
| false | 0.040714 | 0.035154 | 1.158173 | [
"s060127723",
"s983808921"
]
|
u075012704 | p03476 | python | s643411413 | s957253470 | 1,087 | 844 | 53,460 | 8,648 | Accepted | Accepted | 22.36 | from itertools import accumulate
# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
for i in range(x + x, len(s), x):
s[i] = False
def eratosthenes(n):
s = [True] * n
for x in range(2, int(n ** 0.5) + 1):
if s[x]: mark(s, x)
return [i for i in range(0, n) if s[i] and i > 1]
Prime = set(eratosthenes(10**5 + 1))
Target = [0] * (10**5 + 1)
for n in range(1, 10**5 + 1):
if n in Prime and (n + 1) / 2 in Prime:
Target[n] = 1
Target = list(accumulate(Target))
Q = int(eval(input()))
for q in range(Q):
l, r = list(map(int, input().split()))
print((Target[r] - Target[l - 1]))
| from itertools import accumulate
# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
for i in range(x + x, len(s), x):
s[i] = False
def eratosthenes(n):
s = [True] * n
for x in range(2, int(n ** 0.5) + 1):
if s[x]: mark(s, x)
return [i for i in range(0, n) if s[i] and i > 1]
E = eratosthenes(10 ** 5 + 1)
P = [0] * (10 ** 5 + 1)
for e in E:
P[e] = 1
like2017 = [0] * (10 ** 5 + 1)
for n in range(10 ** 5 + 1):
if ((n + 1) / 2).is_integer():
if P[n] and P[(n + 1) // 2]:
like2017[n] = 1
like2017 = list(accumulate(like2017))
Q = int(eval(input()))
for i in range(Q):
l, r = list(map(int, input().split()))
print((like2017[r] - like2017[l - 1]))
| 27 | 32 | 635 | 728 | from itertools import accumulate
# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
for i in range(x + x, len(s), x):
s[i] = False
def eratosthenes(n):
s = [True] * n
for x in range(2, int(n**0.5) + 1):
if s[x]:
mark(s, x)
return [i for i in range(0, n) if s[i] and i > 1]
Prime = set(eratosthenes(10**5 + 1))
Target = [0] * (10**5 + 1)
for n in range(1, 10**5 + 1):
if n in Prime and (n + 1) / 2 in Prime:
Target[n] = 1
Target = list(accumulate(Target))
Q = int(eval(input()))
for q in range(Q):
l, r = list(map(int, input().split()))
print((Target[r] - Target[l - 1]))
| from itertools import accumulate
# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
for i in range(x + x, len(s), x):
s[i] = False
def eratosthenes(n):
s = [True] * n
for x in range(2, int(n**0.5) + 1):
if s[x]:
mark(s, x)
return [i for i in range(0, n) if s[i] and i > 1]
E = eratosthenes(10**5 + 1)
P = [0] * (10**5 + 1)
for e in E:
P[e] = 1
like2017 = [0] * (10**5 + 1)
for n in range(10**5 + 1):
if ((n + 1) / 2).is_integer():
if P[n] and P[(n + 1) // 2]:
like2017[n] = 1
like2017 = list(accumulate(like2017))
Q = int(eval(input()))
for i in range(Q):
l, r = list(map(int, input().split()))
print((like2017[r] - like2017[l - 1]))
| false | 15.625 | [
"-Prime = set(eratosthenes(10**5 + 1))",
"-Target = [0] * (10**5 + 1)",
"-for n in range(1, 10**5 + 1):",
"- if n in Prime and (n + 1) / 2 in Prime:",
"- Target[n] = 1",
"-Target = list(accumulate(Target))",
"+E = eratosthenes(10**5 + 1)",
"+P = [0] * (10**5 + 1)",
"+for e in E:",
"+ P[e] = 1",
"+like2017 = [0] * (10**5 + 1)",
"+for n in range(10**5 + 1):",
"+ if ((n + 1) / 2).is_integer():",
"+ if P[n] and P[(n + 1) // 2]:",
"+ like2017[n] = 1",
"+like2017 = list(accumulate(like2017))",
"-for q in range(Q):",
"+for i in range(Q):",
"- print((Target[r] - Target[l - 1]))",
"+ print((like2017[r] - like2017[l - 1]))"
]
| false | 0.110259 | 0.136853 | 0.805679 | [
"s643411413",
"s957253470"
]
|
u513519822 | p02713 | python | s950715522 | s720047946 | 1,590 | 488 | 9,184 | 67,876 | Accepted | Accepted | 69.31 | import math
K = int(eval(input()))
sumval = 0
for a in range(1, K+1):
for b in range(1, K+1):
f = math.gcd(a,b)
for c in range(1, K+1):
g = math.gcd(f,c)
sumval += g
print(sumval) | import math
K = int(eval(input()))
sumval = 0
for a in range(1, K+1):
for b in range(1, K+1):
for c in range(1, K+1):
f = math.gcd(a,b)
g = math.gcd(f,c)
sumval += g
print(sumval) | 10 | 10 | 226 | 230 | import math
K = int(eval(input()))
sumval = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
f = math.gcd(a, b)
for c in range(1, K + 1):
g = math.gcd(f, c)
sumval += g
print(sumval)
| import math
K = int(eval(input()))
sumval = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
for c in range(1, K + 1):
f = math.gcd(a, b)
g = math.gcd(f, c)
sumval += g
print(sumval)
| false | 0 | [
"- f = math.gcd(a, b)",
"+ f = math.gcd(a, b)"
]
| false | 0.168702 | 0.080107 | 2.10596 | [
"s950715522",
"s720047946"
]
|
u033606236 | p03712 | python | s790709799 | s875159623 | 21 | 18 | 3,064 | 3,060 | Accepted | Accepted | 14.29 | y,x = list(map(int,input().split()))
str = [["#" for i in range(x+2)]for i in range(y+2)]
a = [0 for i in range(y)]
for i in range(y):
a[i] = eval(input())
for i in range(1,y+1):
for z in range(1,x+1):
check = a[i-1]
str[i][z] = a[i-1][z-1]
for i in range(y+2):
print(("".join(str[i]))) | h, w = map(int,input().split())
s = ["#"+input()+"#" for _ in range(h)]
s = ["#"*(w+2)]+s+["#"*(w+2)]
print(*s,sep="\n")
| 12 | 4 | 312 | 123 | y, x = list(map(int, input().split()))
str = [["#" for i in range(x + 2)] for i in range(y + 2)]
a = [0 for i in range(y)]
for i in range(y):
a[i] = eval(input())
for i in range(1, y + 1):
for z in range(1, x + 1):
check = a[i - 1]
str[i][z] = a[i - 1][z - 1]
for i in range(y + 2):
print(("".join(str[i])))
| h, w = map(int, input().split())
s = ["#" + input() + "#" for _ in range(h)]
s = ["#" * (w + 2)] + s + ["#" * (w + 2)]
print(*s, sep="\n")
| false | 66.666667 | [
"-y, x = list(map(int, input().split()))",
"-str = [[\"#\" for i in range(x + 2)] for i in range(y + 2)]",
"-a = [0 for i in range(y)]",
"-for i in range(y):",
"- a[i] = eval(input())",
"-for i in range(1, y + 1):",
"- for z in range(1, x + 1):",
"- check = a[i - 1]",
"- str[i][z] = a[i - 1][z - 1]",
"-for i in range(y + 2):",
"- print((\"\".join(str[i])))",
"+h, w = map(int, input().split())",
"+s = [\"#\" + input() + \"#\" for _ in range(h)]",
"+s = [\"#\" * (w + 2)] + s + [\"#\" * (w + 2)]",
"+print(*s, sep=\"\\n\")"
]
| false | 0.035951 | 0.036373 | 0.988404 | [
"s790709799",
"s875159623"
]
|
u864197622 | p02888 | python | s994306752 | s713686791 | 1,098 | 21 | 3,188 | 3,316 | Accepted | Accepted | 98.09 | N = int(eval(input()))
A = sorted([int(a) for a in input().split()])
X = [0] * 1001
for a in A:
X[a] += 1
for i in range(1, 1001):
X[i] += X[i-1]
ans = 0
for i in range(N):
for j in range(i+1, N):
ans += X[min(A[i]+A[j]-1, 1000)] - (j+1)
print(ans) | k = 31
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(1001)]]
N = int(eval(input()))
A = [int(a) for a in input().split()]
C = [0] * 1001
for a in A:
C[a] += 1
B = li(st(nu(C) ** 2))
for a in A:
if a <= 500: B[2*a] -= 1
for i in range(1001):
B[i] //= 2
for i in range(1, 1001):
C[i] += C[i-1]
ans = N*(N-1)*(N-2)//6
for i in range(1, 1001):
ans -= (N-C[i-1]) * B[i]
print(ans)
| 13 | 22 | 275 | 561 | N = int(eval(input()))
A = sorted([int(a) for a in input().split()])
X = [0] * 1001
for a in A:
X[a] += 1
for i in range(1, 1001):
X[i] += X[i - 1]
ans = 0
for i in range(N):
for j in range(i + 1, N):
ans += X[min(A[i] + A[j] - 1, 1000)] - (j + 1)
print(ans)
| k = 31
K = 1 << k
nu = lambda L: int("".join([bin(K + a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [
int(a, 2) if len(a) else 0
for a in [s[-(i + 1) * k - 1 : -i * k - 1] for i in range(1001)]
]
N = int(eval(input()))
A = [int(a) for a in input().split()]
C = [0] * 1001
for a in A:
C[a] += 1
B = li(st(nu(C) ** 2))
for a in A:
if a <= 500:
B[2 * a] -= 1
for i in range(1001):
B[i] //= 2
for i in range(1, 1001):
C[i] += C[i - 1]
ans = N * (N - 1) * (N - 2) // 6
for i in range(1, 1001):
ans -= (N - C[i - 1]) * B[i]
print(ans)
| false | 40.909091 | [
"+k = 31",
"+K = 1 << k",
"+nu = lambda L: int(\"\".join([bin(K + a)[-k:] for a in L[::-1]]), 2)",
"+st = lambda n: bin(n)[2:] + \"0\"",
"+li = lambda s: [",
"+ int(a, 2) if len(a) else 0",
"+ for a in [s[-(i + 1) * k - 1 : -i * k - 1] for i in range(1001)]",
"+]",
"-A = sorted([int(a) for a in input().split()])",
"-X = [0] * 1001",
"+A = [int(a) for a in input().split()]",
"+C = [0] * 1001",
"- X[a] += 1",
"+ C[a] += 1",
"+B = li(st(nu(C) ** 2))",
"+for a in A:",
"+ if a <= 500:",
"+ B[2 * a] -= 1",
"+for i in range(1001):",
"+ B[i] //= 2",
"- X[i] += X[i - 1]",
"-ans = 0",
"-for i in range(N):",
"- for j in range(i + 1, N):",
"- ans += X[min(A[i] + A[j] - 1, 1000)] - (j + 1)",
"+ C[i] += C[i - 1]",
"+ans = N * (N - 1) * (N - 2) // 6",
"+for i in range(1, 1001):",
"+ ans -= (N - C[i - 1]) * B[i]"
]
| false | 0.049274 | 0.047294 | 1.041862 | [
"s994306752",
"s713686791"
]
|
u160414758 | p03645 | python | s321369680 | s585792495 | 361 | 290 | 22,140 | 18,936 | Accepted | Accepted | 19.67 | from sys import stdin
input = stdin.readline
N,M = list(map(int,(input().split())))
ans = "IMPOSSIBLE"
seta,setb = set(),set()
af,bf = [False]*M,[False]*M
for m in range(M):
a,b = list(map(int,(input().split())))
if a-1 == 0:
af[m] = True
seta.add(b-1)
if b-1 == N-1:
bf[m] = True
setb.add(a-1)
if af[m] and bf[m]:
ans = "POSSIBLE"
break
for a in seta:
if ans == "POSSIBLE":
break
if a in setb:
ans = "POSSIBLE"
break
print(ans) | from sys import stdin
input = stdin.readline
N,M = list(map(int,(input().split())))
ans = "IMPOSSIBLE"
seta,setb = set(),set()
for m in range(M):
a,b = list(map(int,(input().split())))
if a == 1:
seta.add(b)
if b == N:
setb.add(a)
if seta & setb:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| 30 | 20 | 551 | 347 | from sys import stdin
input = stdin.readline
N, M = list(map(int, (input().split())))
ans = "IMPOSSIBLE"
seta, setb = set(), set()
af, bf = [False] * M, [False] * M
for m in range(M):
a, b = list(map(int, (input().split())))
if a - 1 == 0:
af[m] = True
seta.add(b - 1)
if b - 1 == N - 1:
bf[m] = True
setb.add(a - 1)
if af[m] and bf[m]:
ans = "POSSIBLE"
break
for a in seta:
if ans == "POSSIBLE":
break
if a in setb:
ans = "POSSIBLE"
break
print(ans)
| from sys import stdin
input = stdin.readline
N, M = list(map(int, (input().split())))
ans = "IMPOSSIBLE"
seta, setb = set(), set()
for m in range(M):
a, b = list(map(int, (input().split())))
if a == 1:
seta.add(b)
if b == N:
setb.add(a)
if seta & setb:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false | 33.333333 | [
"-af, bf = [False] * M, [False] * M",
"- if a - 1 == 0:",
"- af[m] = True",
"- seta.add(b - 1)",
"- if b - 1 == N - 1:",
"- bf[m] = True",
"- setb.add(a - 1)",
"- if af[m] and bf[m]:",
"- ans = \"POSSIBLE\"",
"- break",
"-for a in seta:",
"- if ans == \"POSSIBLE\":",
"- break",
"- if a in setb:",
"- ans = \"POSSIBLE\"",
"- break",
"-print(ans)",
"+ if a == 1:",
"+ seta.add(b)",
"+ if b == N:",
"+ setb.add(a)",
"+if seta & setb:",
"+ print(\"POSSIBLE\")",
"+else:",
"+ print(\"IMPOSSIBLE\")"
]
| false | 0.080567 | 0.078511 | 1.026196 | [
"s321369680",
"s585792495"
]
|
u312025627 | p02713 | python | s675653267 | s126014189 | 524 | 185 | 67,764 | 69,852 | Accepted | Accepted | 64.69 | def main():
K = int(eval(input()))
from math import gcd
ans = 0
for a in range(1, K+1):
for b in range(1, K+1):
for c in range(1, K+1):
d = gcd(a, b)
ans += gcd(c, d)
print(ans)
if __name__ == '__main__':
main()
| def main():
K = int(eval(input()))
from math import gcd
ans = 0
for i in range(1, K+1):
for j in range(1, K+1):
g = gcd(i, j)
for k in range(1, K+1):
ans += gcd(g, k)
print(ans)
if __name__ == '__main__':
main()
| 14 | 14 | 297 | 293 | def main():
K = int(eval(input()))
from math import gcd
ans = 0
for a in range(1, K + 1):
for b in range(1, K + 1):
for c in range(1, K + 1):
d = gcd(a, b)
ans += gcd(c, d)
print(ans)
if __name__ == "__main__":
main()
| def main():
K = int(eval(input()))
from math import gcd
ans = 0
for i in range(1, K + 1):
for j in range(1, K + 1):
g = gcd(i, j)
for k in range(1, K + 1):
ans += gcd(g, k)
print(ans)
if __name__ == "__main__":
main()
| false | 0 | [
"- for a in range(1, K + 1):",
"- for b in range(1, K + 1):",
"- for c in range(1, K + 1):",
"- d = gcd(a, b)",
"- ans += gcd(c, d)",
"+ for i in range(1, K + 1):",
"+ for j in range(1, K + 1):",
"+ g = gcd(i, j)",
"+ for k in range(1, K + 1):",
"+ ans += gcd(g, k)"
]
| false | 0.079864 | 0.119588 | 0.667824 | [
"s675653267",
"s126014189"
]
|
u133936772 | p02767 | python | s721466971 | s629851833 | 183 | 17 | 5,784 | 2,940 | Accepted | Accepted | 90.71 | n=int(eval(input()))
l=list(map(int,input().split()))
import statistics as st
m=round(st.mean(l))
print((sum((m-i)**2 for i in l))) | n=int(eval(input()))
l=list(map(int,input().split()))
m=round(sum(l)/n)
print((sum((m-i)**2 for i in l))) | 5 | 4 | 127 | 100 | n = int(eval(input()))
l = list(map(int, input().split()))
import statistics as st
m = round(st.mean(l))
print((sum((m - i) ** 2 for i in l)))
| n = int(eval(input()))
l = list(map(int, input().split()))
m = round(sum(l) / n)
print((sum((m - i) ** 2 for i in l)))
| false | 20 | [
"-import statistics as st",
"-",
"-m = round(st.mean(l))",
"+m = round(sum(l) / n)"
]
| false | 0.107867 | 0.035004 | 3.081564 | [
"s721466971",
"s629851833"
]
|
u811841526 | p02258 | python | s482224699 | s361084288 | 520 | 480 | 7,664 | 5,612 | Accepted | Accepted | 7.69 | #!/usr/bin/env python3
# coding: utf-8
# ?§£??¬??????????????????????????¨????????¨??¬??¬????????§??????
# input & calc
n = int(eval(input()))
max_diff = -20**9
minv = 20**9
for i in range(n):
r = int(eval(input()))
max_diff = max(max_diff, r - minv)
minv = min(minv, r)
# output
print(max_diff) | n = int(eval(input()))
max_diff = -10**10
current_min = int(eval(input()))
for _ in range(n-1):
current = int(eval(input()))
diff = current - current_min
if diff > max_diff:
max_diff = diff
if current < current_min:
current_min = current
print(max_diff)
| 15 | 14 | 311 | 284 | #!/usr/bin/env python3
# coding: utf-8
# ?§£??¬??????????????????????????¨????????¨??¬??¬????????§??????
# input & calc
n = int(eval(input()))
max_diff = -(20**9)
minv = 20**9
for i in range(n):
r = int(eval(input()))
max_diff = max(max_diff, r - minv)
minv = min(minv, r)
# output
print(max_diff)
| n = int(eval(input()))
max_diff = -(10**10)
current_min = int(eval(input()))
for _ in range(n - 1):
current = int(eval(input()))
diff = current - current_min
if diff > max_diff:
max_diff = diff
if current < current_min:
current_min = current
print(max_diff)
| false | 6.666667 | [
"-#!/usr/bin/env python3",
"-# coding: utf-8",
"-# ?§£??¬??????????????????????????¨????????¨??¬??¬????????§??????",
"-# input & calc",
"-max_diff = -(20**9)",
"-minv = 20**9",
"-for i in range(n):",
"- r = int(eval(input()))",
"- max_diff = max(max_diff, r - minv)",
"- minv = min(minv, r)",
"-# output",
"+max_diff = -(10**10)",
"+current_min = int(eval(input()))",
"+for _ in range(n - 1):",
"+ current = int(eval(input()))",
"+ diff = current - current_min",
"+ if diff > max_diff:",
"+ max_diff = diff",
"+ if current < current_min:",
"+ current_min = current"
]
| false | 0.048508 | 0.046139 | 1.051356 | [
"s482224699",
"s361084288"
]
|
u453055089 | p03964 | python | s535921436 | s235477617 | 90 | 76 | 73,472 | 73,096 | Accepted | Accepted | 15.56 | n = int(eval(input()))
x, y = 1, 1
for _ in range(n):
t, a = list(map(int, input().split()))
if x <= t and y <= a:
x = t
y = a
elif x <= t and y > a:
if y % a == 0:
i = y // a
else:
i = y // a + 1
y = i*a
x = i*t
elif x > t and y <= a:
if x % t == 0:
i = x // t
else:
i = x // t + 1
x = i*t
y = i*a
elif x > t and y > a:
if x % t == 0:
i_x = x // t
else:
i_x = x // t + 1
if y % a == 0:
i_y = y // a
else:
i_y = y // a + 1
bigger = max(i_x, i_y)
x = bigger*t
y = bigger*a
print((x+y)) | n = int(eval(input()))
x, y = 1, 1
for _ in range(n):
t, a = list(map(int, input().split()))
if x <= t and y <= a:
x = t
y = a
else:
if x % t == 0:
i_x = x // t
else:
i_x = x // t + 1
if y % a == 0:
i_y = y // a
else:
i_y = y // a + 1
bigger = max(i_x, i_y)
x = bigger*t
y = bigger*a
print((x+y)) | 35 | 21 | 757 | 435 | n = int(eval(input()))
x, y = 1, 1
for _ in range(n):
t, a = list(map(int, input().split()))
if x <= t and y <= a:
x = t
y = a
elif x <= t and y > a:
if y % a == 0:
i = y // a
else:
i = y // a + 1
y = i * a
x = i * t
elif x > t and y <= a:
if x % t == 0:
i = x // t
else:
i = x // t + 1
x = i * t
y = i * a
elif x > t and y > a:
if x % t == 0:
i_x = x // t
else:
i_x = x // t + 1
if y % a == 0:
i_y = y // a
else:
i_y = y // a + 1
bigger = max(i_x, i_y)
x = bigger * t
y = bigger * a
print((x + y))
| n = int(eval(input()))
x, y = 1, 1
for _ in range(n):
t, a = list(map(int, input().split()))
if x <= t and y <= a:
x = t
y = a
else:
if x % t == 0:
i_x = x // t
else:
i_x = x // t + 1
if y % a == 0:
i_y = y // a
else:
i_y = y // a + 1
bigger = max(i_x, i_y)
x = bigger * t
y = bigger * a
print((x + y))
| false | 40 | [
"- elif x <= t and y > a:",
"- if y % a == 0:",
"- i = y // a",
"- else:",
"- i = y // a + 1",
"- y = i * a",
"- x = i * t",
"- elif x > t and y <= a:",
"- if x % t == 0:",
"- i = x // t",
"- else:",
"- i = x // t + 1",
"- x = i * t",
"- y = i * a",
"- elif x > t and y > a:",
"+ else:"
]
| false | 0.039089 | 0.177231 | 0.220555 | [
"s535921436",
"s235477617"
]
|
u905203728 | p03426 | python | s347508470 | s309287374 | 758 | 603 | 87,260 | 47,716 | Accepted | Accepted | 20.45 | h,w,d=list(map(int,input().split()))
box=[list(map(int,input().split())) for i in range(h)]
adress={}
for i in range(h):
for j in range(w):
adress[box[i][j]]=[i,j]
q=int(eval(input()))
order=[list(map(int,input().split())) for i in range(q)]
S=[0]*(h*w+1)
for k in range(d+1,h*w+1):
x,y=adress[k]
i,j=adress[k-d]
S[k]=S[k-d]+abs(x-i)+abs(y-j)
for x,y in order:
print((S[y]-S[x])) | h,w,d=list(map(int,input().split()))
box=list(list(map(int,input().split())) for i in range(h))
q=int(eval(input()))
order=[list(map(int,input().split())) for i in range(q)]
S=[0]*(h*w+1)
add={}
for i in range(h):
for j in range(w):
add[box[i][j]]=[i,j]
for k in range(d+1,h*w+1):
x,y=add[k]
i,j=add[k-d]
S[k]=S[k-d]+abs(x-i)+abs(y-j)
for s,g in order:
print((S[g]-S[s])) | 15 | 19 | 407 | 407 | h, w, d = list(map(int, input().split()))
box = [list(map(int, input().split())) for i in range(h)]
adress = {}
for i in range(h):
for j in range(w):
adress[box[i][j]] = [i, j]
q = int(eval(input()))
order = [list(map(int, input().split())) for i in range(q)]
S = [0] * (h * w + 1)
for k in range(d + 1, h * w + 1):
x, y = adress[k]
i, j = adress[k - d]
S[k] = S[k - d] + abs(x - i) + abs(y - j)
for x, y in order:
print((S[y] - S[x]))
| h, w, d = list(map(int, input().split()))
box = list(list(map(int, input().split())) for i in range(h))
q = int(eval(input()))
order = [list(map(int, input().split())) for i in range(q)]
S = [0] * (h * w + 1)
add = {}
for i in range(h):
for j in range(w):
add[box[i][j]] = [i, j]
for k in range(d + 1, h * w + 1):
x, y = add[k]
i, j = add[k - d]
S[k] = S[k - d] + abs(x - i) + abs(y - j)
for s, g in order:
print((S[g] - S[s]))
| false | 21.052632 | [
"-box = [list(map(int, input().split())) for i in range(h)]",
"-adress = {}",
"-for i in range(h):",
"- for j in range(w):",
"- adress[box[i][j]] = [i, j]",
"+box = list(list(map(int, input().split())) for i in range(h))",
"+add = {}",
"+for i in range(h):",
"+ for j in range(w):",
"+ add[box[i][j]] = [i, j]",
"- x, y = adress[k]",
"- i, j = adress[k - d]",
"+ x, y = add[k]",
"+ i, j = add[k - d]",
"-for x, y in order:",
"- print((S[y] - S[x]))",
"+for s, g in order:",
"+ print((S[g] - S[s]))"
]
| false | 0.06269 | 0.070683 | 0.886916 | [
"s347508470",
"s309287374"
]
|
u620084012 | p03592 | python | s851750808 | s678593895 | 293 | 193 | 2,940 | 38,768 | Accepted | Accepted | 34.13 | N, M, K = list(map(int, input().split()))
for k in range(N+1):
for l in range(M+1):
if l*(N-k)+k*(M-l)==K:
print("Yes")
exit(0)
print("No") | N, M, K = list(map(int,input().split()))
for k in range(N+1):
for l in range(M+1):
if k*l + (M-l)*(N-k) == K:
print("Yes")
exit(0)
print("No")
| 8 | 8 | 177 | 181 | N, M, K = list(map(int, input().split()))
for k in range(N + 1):
for l in range(M + 1):
if l * (N - k) + k * (M - l) == K:
print("Yes")
exit(0)
print("No")
| N, M, K = list(map(int, input().split()))
for k in range(N + 1):
for l in range(M + 1):
if k * l + (M - l) * (N - k) == K:
print("Yes")
exit(0)
print("No")
| false | 0 | [
"- if l * (N - k) + k * (M - l) == K:",
"+ if k * l + (M - l) * (N - k) == K:"
]
| false | 0.033728 | 0.034853 | 0.967713 | [
"s851750808",
"s678593895"
]
|
u528470578 | p03086 | python | s273908027 | s321345200 | 183 | 68 | 38,256 | 61,764 | Accepted | Accepted | 62.84 | # ABC122 B-ATCoder
S = eval(input())
ans = 0
l, r = 0, 0
ls = len(S)
for i in range(ls):
if S[i] in "ATGC":
r += 1
else:
r += 1
l = r
ans = max(ans, r-l)
print(ans) | S = eval(input())
tf = []
for s in S:
if s in "ACGT":
tf.append(True)
else:
tf.append(False)
ans = 0
temp = 0
for res in tf:
if res:
temp += 1
else:
temp = 0
ans = max(ans, temp)
print(ans) | 15 | 17 | 210 | 252 | # ABC122 B-ATCoder
S = eval(input())
ans = 0
l, r = 0, 0
ls = len(S)
for i in range(ls):
if S[i] in "ATGC":
r += 1
else:
r += 1
l = r
ans = max(ans, r - l)
print(ans)
| S = eval(input())
tf = []
for s in S:
if s in "ACGT":
tf.append(True)
else:
tf.append(False)
ans = 0
temp = 0
for res in tf:
if res:
temp += 1
else:
temp = 0
ans = max(ans, temp)
print(ans)
| false | 11.764706 | [
"-# ABC122 B-ATCoder",
"+tf = []",
"+for s in S:",
"+ if s in \"ACGT\":",
"+ tf.append(True)",
"+ else:",
"+ tf.append(False)",
"-l, r = 0, 0",
"-ls = len(S)",
"-for i in range(ls):",
"- if S[i] in \"ATGC\":",
"- r += 1",
"+temp = 0",
"+for res in tf:",
"+ if res:",
"+ temp += 1",
"- r += 1",
"- l = r",
"- ans = max(ans, r - l)",
"+ temp = 0",
"+ ans = max(ans, temp)"
]
| false | 0.043648 | 0.044659 | 0.977358 | [
"s273908027",
"s321345200"
]
|
u335599768 | p02573 | python | s396400958 | s639893282 | 753 | 677 | 35,884 | 16,340 | Accepted | Accepted | 10.09 | import sys
sys.setrecursionlimit(10 ** 9)
n, m = list(map(int, input().split()))
root = [-1] * n
def r(x):
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(x, y):
x = r(x)
y = r(y)
if x == y:
return
root[x] += root[y]
root[y] = x
def size(x):
x = r(x)
return -root[x]
for i in range(m):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
unite(x,y)
max_size = 0
for i in range(n):
max_size = max(size(i), max_size)
print(max_size) | import sys
sys.setrecursionlimit(10 ** 9)
N, M = list(map(int, input().split()))
root = [-1] * N
def parent(x):
if root[x] < 0:
return x
root[x] = parent(root[x])
return root[x]
def union(x, y):
x_parent = parent(x)
y_parent = parent(y)
if x_parent == y_parent:
return
root[x_parent] += root[y_parent]
root[y_parent] = x
def size(x):
return -root[x]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
union(a, b)
max_size = 0
for i in range(N):
max_size = max(size(i), max_size)
print(max_size) | 41 | 38 | 596 | 627 | import sys
sys.setrecursionlimit(10**9)
n, m = list(map(int, input().split()))
root = [-1] * n
def r(x):
if root[x] < 0:
return x
else:
root[x] = r(root[x])
return root[x]
def unite(x, y):
x = r(x)
y = r(y)
if x == y:
return
root[x] += root[y]
root[y] = x
def size(x):
x = r(x)
return -root[x]
for i in range(m):
x, y = list(map(int, input().split()))
x -= 1
y -= 1
unite(x, y)
max_size = 0
for i in range(n):
max_size = max(size(i), max_size)
print(max_size)
| import sys
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
root = [-1] * N
def parent(x):
if root[x] < 0:
return x
root[x] = parent(root[x])
return root[x]
def union(x, y):
x_parent = parent(x)
y_parent = parent(y)
if x_parent == y_parent:
return
root[x_parent] += root[y_parent]
root[y_parent] = x
def size(x):
return -root[x]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
union(a, b)
max_size = 0
for i in range(N):
max_size = max(size(i), max_size)
print(max_size)
| false | 7.317073 | [
"-n, m = list(map(int, input().split()))",
"-root = [-1] * n",
"+N, M = list(map(int, input().split()))",
"+root = [-1] * N",
"-def r(x):",
"+def parent(x):",
"- else:",
"- root[x] = r(root[x])",
"- return root[x]",
"+ root[x] = parent(root[x])",
"+ return root[x]",
"-def unite(x, y):",
"- x = r(x)",
"- y = r(y)",
"- if x == y:",
"+def union(x, y):",
"+ x_parent = parent(x)",
"+ y_parent = parent(y)",
"+ if x_parent == y_parent:",
"- root[x] += root[y]",
"- root[y] = x",
"+ root[x_parent] += root[y_parent]",
"+ root[y_parent] = x",
"- x = r(x)",
"-for i in range(m):",
"- x, y = list(map(int, input().split()))",
"- x -= 1",
"- y -= 1",
"- unite(x, y)",
"+for i in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ a -= 1",
"+ b -= 1",
"+ union(a, b)",
"-for i in range(n):",
"+for i in range(N):"
]
| false | 0.042552 | 0.070149 | 0.606593 | [
"s396400958",
"s639893282"
]
|
u329565519 | p02946 | python | s463631873 | s445788469 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | K, X = list(map(int, input().split()))
low = X - K
hight = X + K
a = set()
for x in range(low + 1, hight, 1):
a.add(x)
a = sorted(a)
a = [str(x) for x in a]
print((' '.join(a)))
| K, X = list(map(int, input().split()))
low = X - K
hight = X + K
a = []
for x in range(low + 1, hight, 1):
a.append(str(x))
print((' '.join(a)))
| 11 | 9 | 186 | 151 | K, X = list(map(int, input().split()))
low = X - K
hight = X + K
a = set()
for x in range(low + 1, hight, 1):
a.add(x)
a = sorted(a)
a = [str(x) for x in a]
print((" ".join(a)))
| K, X = list(map(int, input().split()))
low = X - K
hight = X + K
a = []
for x in range(low + 1, hight, 1):
a.append(str(x))
print((" ".join(a)))
| false | 18.181818 | [
"-a = set()",
"+a = []",
"- a.add(x)",
"-a = sorted(a)",
"-a = [str(x) for x in a]",
"+ a.append(str(x))"
]
| false | 0.101393 | 0.113897 | 0.890221 | [
"s463631873",
"s445788469"
]
|
u572002343 | p03325 | python | s351151781 | s313004410 | 88 | 79 | 4,148 | 4,148 | Accepted | Accepted | 10.23 | def calc(numbers):
count = 0
for num in numbers:
while(num % 2 == 0):
num /= 2
count += 1
return count
if __name__ == "__main__":
_ = eval(input())
numbers = list(map(int, input().split()))
print((calc(numbers)))
| N = int(eval(input()))
numbers = list(map(int, input().split()))
count = 0
for n in numbers:
while(n % 2 == 0):
n //= 2
count +=1
print(count)
| 15 | 11 | 279 | 160 | def calc(numbers):
count = 0
for num in numbers:
while num % 2 == 0:
num /= 2
count += 1
return count
if __name__ == "__main__":
_ = eval(input())
numbers = list(map(int, input().split()))
print((calc(numbers)))
| N = int(eval(input()))
numbers = list(map(int, input().split()))
count = 0
for n in numbers:
while n % 2 == 0:
n //= 2
count += 1
print(count)
| false | 26.666667 | [
"-def calc(numbers):",
"- count = 0",
"- for num in numbers:",
"- while num % 2 == 0:",
"- num /= 2",
"- count += 1",
"- return count",
"-",
"-",
"-if __name__ == \"__main__\":",
"- _ = eval(input())",
"- numbers = list(map(int, input().split()))",
"- print((calc(numbers)))",
"+N = int(eval(input()))",
"+numbers = list(map(int, input().split()))",
"+count = 0",
"+for n in numbers:",
"+ while n % 2 == 0:",
"+ n //= 2",
"+ count += 1",
"+print(count)"
]
| false | 0.045704 | 0.045284 | 1.009265 | [
"s351151781",
"s313004410"
]
|
u573754721 | p02756 | python | s086694432 | s214146787 | 1,970 | 444 | 4,384 | 4,476 | Accepted | Accepted | 77.46 | S=eval(input())
q=int(eval(input()))
RV=0
A="A"
for i in range(q):
IN=eval(input())
if IN=="1":
RV+=1
else:
t,f,c=IN.split()
if RV%2==0:
if f=="1":
A=c+A
else:
A=A+c
else:
if f=="1":
A=A+c
else:
A=c+A
if RV%2==0:
for i in range(len(A)):
if A[i]=="A":
print((A[:i]+S+A[i+1:]))
else:
A=A[::-1]
for i in range(len(A)):
if A[i]=="A":
print((A[:i]+S[::-1]+A[i+1:])) | S=eval(input())
q=int(eval(input()))
rev=False
pre=''
for i in range(q):
inp=eval(input())
if inp[0]=="1":
rev=not rev
else:
t,f,c=inp.split()
if (f=='1' and rev) or (f=='2' and not rev):
S+=c
else:
pre+=c
if not rev:
print((pre[::-1]+S))
else:
print((S[::-1]+pre)) | 29 | 18 | 589 | 336 | S = eval(input())
q = int(eval(input()))
RV = 0
A = "A"
for i in range(q):
IN = eval(input())
if IN == "1":
RV += 1
else:
t, f, c = IN.split()
if RV % 2 == 0:
if f == "1":
A = c + A
else:
A = A + c
else:
if f == "1":
A = A + c
else:
A = c + A
if RV % 2 == 0:
for i in range(len(A)):
if A[i] == "A":
print((A[:i] + S + A[i + 1 :]))
else:
A = A[::-1]
for i in range(len(A)):
if A[i] == "A":
print((A[:i] + S[::-1] + A[i + 1 :]))
| S = eval(input())
q = int(eval(input()))
rev = False
pre = ""
for i in range(q):
inp = eval(input())
if inp[0] == "1":
rev = not rev
else:
t, f, c = inp.split()
if (f == "1" and rev) or (f == "2" and not rev):
S += c
else:
pre += c
if not rev:
print((pre[::-1] + S))
else:
print((S[::-1] + pre))
| false | 37.931034 | [
"-RV = 0",
"-A = \"A\"",
"+rev = False",
"+pre = \"\"",
"- IN = eval(input())",
"- if IN == \"1\":",
"- RV += 1",
"+ inp = eval(input())",
"+ if inp[0] == \"1\":",
"+ rev = not rev",
"- t, f, c = IN.split()",
"- if RV % 2 == 0:",
"- if f == \"1\":",
"- A = c + A",
"- else:",
"- A = A + c",
"+ t, f, c = inp.split()",
"+ if (f == \"1\" and rev) or (f == \"2\" and not rev):",
"+ S += c",
"- if f == \"1\":",
"- A = A + c",
"- else:",
"- A = c + A",
"-if RV % 2 == 0:",
"- for i in range(len(A)):",
"- if A[i] == \"A\":",
"- print((A[:i] + S + A[i + 1 :]))",
"+ pre += c",
"+if not rev:",
"+ print((pre[::-1] + S))",
"- A = A[::-1]",
"- for i in range(len(A)):",
"- if A[i] == \"A\":",
"- print((A[:i] + S[::-1] + A[i + 1 :]))",
"+ print((S[::-1] + pre))"
]
| false | 0.045797 | 0.037942 | 1.207049 | [
"s086694432",
"s214146787"
]
|
u754022296 | p03008 | python | s107748268 | s192420123 | 820 | 484 | 261,796 | 260,252 | Accepted | Accepted | 40.98 | import sys
input = sys.stdin.readline
n = int(eval(input()))
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
dp = list(range(n+1))
for a, b in zip(A, B):
for i in range(n+1):
if i-a >= 0:
dp[i] = max(dp[i], dp[i-a]+b)
return max(dp)
m = f(n)
A, B = B, A
ans = f(m)
print(ans) | import sys
input = sys.stdin.readline
n = int(eval(input()))
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
dp = list(range(n+1))
for a, b in zip(A, B):
if b <= a:
continue
for i in range(n+1):
if i-a >= 0:
dp[i] = max(dp[i], dp[i-a]+b)
return max(dp)
m = f(n)
A, B = B, A
ans = f(m)
print(ans) | 17 | 19 | 346 | 378 | import sys
input = sys.stdin.readline
n = int(eval(input()))
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
dp = list(range(n + 1))
for a, b in zip(A, B):
for i in range(n + 1):
if i - a >= 0:
dp[i] = max(dp[i], dp[i - a] + b)
return max(dp)
m = f(n)
A, B = B, A
ans = f(m)
print(ans)
| import sys
input = sys.stdin.readline
n = int(eval(input()))
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
def f(n):
dp = list(range(n + 1))
for a, b in zip(A, B):
if b <= a:
continue
for i in range(n + 1):
if i - a >= 0:
dp[i] = max(dp[i], dp[i - a] + b)
return max(dp)
m = f(n)
A, B = B, A
ans = f(m)
print(ans)
| false | 10.526316 | [
"+ if b <= a:",
"+ continue"
]
| false | 0.039543 | 0.039477 | 1.001662 | [
"s107748268",
"s192420123"
]
|
u941753895 | p03197 | python | s268415933 | s203863255 | 101 | 91 | 9,568 | 5,076 | Accepted | Accepted | 9.9 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
def main():
n=I()
l=[I() for _ in range(n)]
for x in l:
if x%2==1:
return 'first'
return 'second'
# main()
print((main()))
| import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
def main():
# 最後に食べたら勝ち
# 1を引けば勝ち
# 奇数調整をする
# 相手に全て偶数を与えるよう調整する
# all偶数だと負け
n=I()
f=False
for _ in range(n):
if I()%2==1:
f=True
if f:
return 'first'
return 'second'
# main()
print((main()))
| 25 | 31 | 654 | 649 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
def main():
n = I()
l = [I() for _ in range(n)]
for x in l:
if x % 2 == 1:
return "first"
return "second"
# main()
print((main()))
| import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
def main():
# 最後に食べたら勝ち
# 1を引けば勝ち
# 奇数調整をする
# 相手に全て偶数を与えるよう調整する
# all偶数だと負け
n = I()
f = False
for _ in range(n):
if I() % 2 == 1:
f = True
if f:
return "first"
return "second"
# main()
print((main()))
| false | 19.354839 | [
"-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy",
"+import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy",
"-",
"-",
"-def LI_():",
"- return [int(x) - 1 for x in sys.stdin.readline().split()]",
"+ # 最後に食べたら勝ち",
"+ # 1を引けば勝ち",
"+ # 奇数調整をする",
"+ # 相手に全て偶数を与えるよう調整する",
"+ # all偶数だと負け",
"- l = [I() for _ in range(n)]",
"- for x in l:",
"- if x % 2 == 1:",
"- return \"first\"",
"+ f = False",
"+ for _ in range(n):",
"+ if I() % 2 == 1:",
"+ f = True",
"+ if f:",
"+ return \"first\""
]
| false | 0.046265 | 0.041807 | 1.106645 | [
"s268415933",
"s203863255"
]
|
u790710233 | p03212 | python | s386568211 | s726915755 | 71 | 53 | 3,060 | 4,504 | Accepted | Accepted | 25.35 | N = int(eval(input()))
def dfs(x):
if int('0'+x) > N:
return 0
retval = 1 if len(set(x)) == 3 else 0
for c in '753':
retval += dfs(x + c)
return retval
print((dfs(''))) | n = int(eval(input()))
like_753 = []
def dfs(x):
if n < x:
return 0
else:
like_753.append(x)
dfs(10*x+3)
dfs(10*x+5)
dfs(10*x+7)
dfs(3)
dfs(5)
dfs(7)
ls_753 = [x for x in like_753 if len(set(str(x))) == 3]
print((len(ls_753)))
| 13 | 20 | 208 | 291 | N = int(eval(input()))
def dfs(x):
if int("0" + x) > N:
return 0
retval = 1 if len(set(x)) == 3 else 0
for c in "753":
retval += dfs(x + c)
return retval
print((dfs("")))
| n = int(eval(input()))
like_753 = []
def dfs(x):
if n < x:
return 0
else:
like_753.append(x)
dfs(10 * x + 3)
dfs(10 * x + 5)
dfs(10 * x + 7)
dfs(3)
dfs(5)
dfs(7)
ls_753 = [x for x in like_753 if len(set(str(x))) == 3]
print((len(ls_753)))
| false | 35 | [
"-N = int(eval(input()))",
"+n = int(eval(input()))",
"+like_753 = []",
"- if int(\"0\" + x) > N:",
"+ if n < x:",
"- retval = 1 if len(set(x)) == 3 else 0",
"- for c in \"753\":",
"- retval += dfs(x + c)",
"- return retval",
"+ else:",
"+ like_753.append(x)",
"+ dfs(10 * x + 3)",
"+ dfs(10 * x + 5)",
"+ dfs(10 * x + 7)",
"-print((dfs(\"\")))",
"+dfs(3)",
"+dfs(5)",
"+dfs(7)",
"+ls_753 = [x for x in like_753 if len(set(str(x))) == 3]",
"+print((len(ls_753)))"
]
| false | 0.044164 | 0.051293 | 0.861007 | [
"s386568211",
"s726915755"
]
|
u080364835 | p03611 | python | s135055957 | s229896930 | 118 | 80 | 13,964 | 20,720 | Accepted | Accepted | 32.2 | n = int(eval(input()))
al = list(map(int, input().split()))
num = [0] * (10**5+1)
for a in al:
num[a] += 1
ans = 0
for i in range(10**5+2):
x_cnt = sum(num[i-1:i+2])
ans = max(ans, x_cnt)
print(ans) | n = int(eval(input()))
al = list(map(int, input().split()))
ans = [0]*(10**5+2)
for a in al:
ans[a] += 1
ans[a-1] += 1
ans[a+1] += 1
print((max(ans))) | 14 | 11 | 221 | 167 | n = int(eval(input()))
al = list(map(int, input().split()))
num = [0] * (10**5 + 1)
for a in al:
num[a] += 1
ans = 0
for i in range(10**5 + 2):
x_cnt = sum(num[i - 1 : i + 2])
ans = max(ans, x_cnt)
print(ans)
| n = int(eval(input()))
al = list(map(int, input().split()))
ans = [0] * (10**5 + 2)
for a in al:
ans[a] += 1
ans[a - 1] += 1
ans[a + 1] += 1
print((max(ans)))
| false | 21.428571 | [
"-num = [0] * (10**5 + 1)",
"+ans = [0] * (10**5 + 2)",
"- num[a] += 1",
"-ans = 0",
"-for i in range(10**5 + 2):",
"- x_cnt = sum(num[i - 1 : i + 2])",
"- ans = max(ans, x_cnt)",
"-print(ans)",
"+ ans[a] += 1",
"+ ans[a - 1] += 1",
"+ ans[a + 1] += 1",
"+print((max(ans)))"
]
| false | 0.006792 | 0.058732 | 0.115649 | [
"s135055957",
"s229896930"
]
|
u362771726 | p02773 | python | s890369495 | s372723650 | 1,084 | 974 | 105,824 | 108,496 | Accepted | Accepted | 10.15 | from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
dic = Counter(S)
tmp = max(dic.values())
ans = [key for key, value in dic.items() if value == tmp]
# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
for key in sorted(ans):
print(key, end="")
print("")
| from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
dic = Counter(S)
tmp = max(dic.values()) # ここ重要!
ans = [key for key, value in dic.items() if value == tmp]
# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
"""
for key in sorted(ans):
print(key, end="")
print("")
"""
ans.sort()
print(*ans, sep="\n")
# print(*ans, sep="\n") かっこいい書き方
| 14 | 23 | 308 | 402 | from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
dic = Counter(S)
tmp = max(dic.values())
ans = [key for key, value in dic.items() if value == tmp]
# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
for key in sorted(ans):
print(key, end="")
print("")
| from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
dic = Counter(S)
tmp = max(dic.values()) # ここ重要!
ans = [key for key, value in dic.items() if value == tmp]
# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
"""
for key in sorted(ans):
print(key, end="")
print("")
"""
ans.sort()
print(*ans, sep="\n")
# print(*ans, sep="\n") かっこいい書き方
| false | 39.130435 | [
"-tmp = max(dic.values())",
"+tmp = max(dic.values()) # ここ重要!",
"+\"\"\"",
"+\"\"\"",
"+ans.sort()",
"+print(*ans, sep=\"\\n\")",
"+# print(*ans, sep=\"\\n\") かっこいい書き方"
]
| false | 0.042918 | 0.065996 | 0.650305 | [
"s890369495",
"s372723650"
]
|
u747602774 | p02835 | python | s327983766 | s901029331 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | A = list(map(int,input().split()))
if sum(A) >= 22:
print('bust')
else:
print('win') | s = input().split()
sum_s = int(s[0]) + int(s[1]) + int(s[2])
if sum_s >= 22:
print('bust')
else:
print('win') | 5 | 7 | 96 | 125 | A = list(map(int, input().split()))
if sum(A) >= 22:
print("bust")
else:
print("win")
| s = input().split()
sum_s = int(s[0]) + int(s[1]) + int(s[2])
if sum_s >= 22:
print("bust")
else:
print("win")
| false | 28.571429 | [
"-A = list(map(int, input().split()))",
"-if sum(A) >= 22:",
"+s = input().split()",
"+sum_s = int(s[0]) + int(s[1]) + int(s[2])",
"+if sum_s >= 22:"
]
| false | 0.106006 | 0.040058 | 2.646338 | [
"s327983766",
"s901029331"
]
|
u391875425 | p03387 | python | s850976406 | s488545136 | 19 | 17 | 2,940 | 3,064 | Accepted | Accepted | 10.53 | a = sorted(list(map(int,input().split())))
d = 3*a[2] - sum(a)
if d%2 == 0:
print((int(d/2)))
else:
print((int((3*(a[2]+1) - sum(a))/2)))
| no = list(map(int, input().split()))
no.sort()
a = no[0]
b = no[1]
c = no[2]
cnt = 0
if a == b:
print((int(c-a)))
elif a%2 != b%2 and a%2 == c%2:
print((int(1+(c-b)+(b+1-a)/2)))
elif a%2 != b%2 and a%2 != c%2:
print((int(1+(c-b)/2+(c+1-a)/2)))
elif a%2 == b%2 and b%2 == c%2:
print((int((c-b)/2+(c-a)/2)))
elif a%2 == b%2 and b%2 != c%2:
print((int(c-b+(c-(a+c-b))/2))) | 6 | 16 | 147 | 395 | a = sorted(list(map(int, input().split())))
d = 3 * a[2] - sum(a)
if d % 2 == 0:
print((int(d / 2)))
else:
print((int((3 * (a[2] + 1) - sum(a)) / 2)))
| no = list(map(int, input().split()))
no.sort()
a = no[0]
b = no[1]
c = no[2]
cnt = 0
if a == b:
print((int(c - a)))
elif a % 2 != b % 2 and a % 2 == c % 2:
print((int(1 + (c - b) + (b + 1 - a) / 2)))
elif a % 2 != b % 2 and a % 2 != c % 2:
print((int(1 + (c - b) / 2 + (c + 1 - a) / 2)))
elif a % 2 == b % 2 and b % 2 == c % 2:
print((int((c - b) / 2 + (c - a) / 2)))
elif a % 2 == b % 2 and b % 2 != c % 2:
print((int(c - b + (c - (a + c - b)) / 2)))
| false | 62.5 | [
"-a = sorted(list(map(int, input().split())))",
"-d = 3 * a[2] - sum(a)",
"-if d % 2 == 0:",
"- print((int(d / 2)))",
"-else:",
"- print((int((3 * (a[2] + 1) - sum(a)) / 2)))",
"+no = list(map(int, input().split()))",
"+no.sort()",
"+a = no[0]",
"+b = no[1]",
"+c = no[2]",
"+cnt = 0",
"+if a == b:",
"+ print((int(c - a)))",
"+elif a % 2 != b % 2 and a % 2 == c % 2:",
"+ print((int(1 + (c - b) + (b + 1 - a) / 2)))",
"+elif a % 2 != b % 2 and a % 2 != c % 2:",
"+ print((int(1 + (c - b) / 2 + (c + 1 - a) / 2)))",
"+elif a % 2 == b % 2 and b % 2 == c % 2:",
"+ print((int((c - b) / 2 + (c - a) / 2)))",
"+elif a % 2 == b % 2 and b % 2 != c % 2:",
"+ print((int(c - b + (c - (a + c - b)) / 2)))"
]
| false | 0.047216 | 0.007294 | 6.473024 | [
"s850976406",
"s488545136"
]
|
u301624971 | p02732 | python | s190899108 | s922059996 | 437 | 297 | 30,892 | 25,892 | Accepted | Accepted | 32.04 | from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
d=Counter(A)
dic={}
total=0
for item in list(d.items()):
counter=item[1]
s1=(counter - 1)*(counter - 2)/2 #1個少ない
s2=(counter)*(counter - 1)/2
dic[item[0]]=int(s1 - s2)
total+=int(s2)
for a in A:
print((total + dic[a]))
| import collections
def myAnswer(N:int,A:list)-> None:
dic = collections.Counter(A)
total =0
for value in list(dic.values()):
total += value * (value -1) //2
for a in A:
print((total - (dic[a]-1)))
def modelAnswer():
return
def main():
N = int(eval(input()))
A = list(map(int,input().split()))
myAnswer(N,A[:])
if __name__ == '__main__':
main() | 15 | 18 | 334 | 387 | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
d = Counter(A)
dic = {}
total = 0
for item in list(d.items()):
counter = item[1]
s1 = (counter - 1) * (counter - 2) / 2 # 1個少ない
s2 = (counter) * (counter - 1) / 2
dic[item[0]] = int(s1 - s2)
total += int(s2)
for a in A:
print((total + dic[a]))
| import collections
def myAnswer(N: int, A: list) -> None:
dic = collections.Counter(A)
total = 0
for value in list(dic.values()):
total += value * (value - 1) // 2
for a in A:
print((total - (dic[a] - 1)))
def modelAnswer():
return
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
myAnswer(N, A[:])
if __name__ == "__main__":
main()
| false | 16.666667 | [
"-from collections import Counter",
"+import collections",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-d = Counter(A)",
"-dic = {}",
"-total = 0",
"-for item in list(d.items()):",
"- counter = item[1]",
"- s1 = (counter - 1) * (counter - 2) / 2 # 1個少ない",
"- s2 = (counter) * (counter - 1) / 2",
"- dic[item[0]] = int(s1 - s2)",
"- total += int(s2)",
"-for a in A:",
"- print((total + dic[a]))",
"+",
"+def myAnswer(N: int, A: list) -> None:",
"+ dic = collections.Counter(A)",
"+ total = 0",
"+ for value in list(dic.values()):",
"+ total += value * (value - 1) // 2",
"+ for a in A:",
"+ print((total - (dic[a] - 1)))",
"+",
"+",
"+def modelAnswer():",
"+ return",
"+",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ myAnswer(N, A[:])",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.033491 | 0.038804 | 0.863087 | [
"s190899108",
"s922059996"
]
|
u820180033 | p02796 | python | s856098298 | s389129179 | 407 | 167 | 18,284 | 27,568 | Accepted | Accepted | 58.97 | from operator import itemgetter
N = int(eval(input()))
arms = []
finishtime = float('-inf')
for i in range(N):
x,l = list(map(int,input().split()))
arms.append((x-l,x+l))
arms.sort(key=itemgetter(1))
cnt=0
for L,R in arms:
if finishtime<=L:
cnt+=1
finishtime = R
print(cnt) | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter
# 区間スケジューリング
N = int(readline())
m = list(map(int,read().split()))
XL = list(zip(m,m))
LR = [(x-l,x+l) for x,l in XL]
LR.sort(key = itemgetter(1))
INF = 10 ** 18
prev_R = -INF
cnt = 0
for L,R in LR:
if prev_R > L:
continue
cnt += 1
prev_R = R
print(cnt)
| 14 | 26 | 302 | 441 | from operator import itemgetter
N = int(eval(input()))
arms = []
finishtime = float("-inf")
for i in range(N):
x, l = list(map(int, input().split()))
arms.append((x - l, x + l))
arms.sort(key=itemgetter(1))
cnt = 0
for L, R in arms:
if finishtime <= L:
cnt += 1
finishtime = R
print(cnt)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter
# 区間スケジューリング
N = int(readline())
m = list(map(int, read().split()))
XL = list(zip(m, m))
LR = [(x - l, x + l) for x, l in XL]
LR.sort(key=itemgetter(1))
INF = 10**18
prev_R = -INF
cnt = 0
for L, R in LR:
if prev_R > L:
continue
cnt += 1
prev_R = R
print(cnt)
| false | 46.153846 | [
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"-N = int(eval(input()))",
"-arms = []",
"-finishtime = float(\"-inf\")",
"-for i in range(N):",
"- x, l = list(map(int, input().split()))",
"- arms.append((x - l, x + l))",
"-arms.sort(key=itemgetter(1))",
"+# 区間スケジューリング",
"+N = int(readline())",
"+m = list(map(int, read().split()))",
"+XL = list(zip(m, m))",
"+LR = [(x - l, x + l) for x, l in XL]",
"+LR.sort(key=itemgetter(1))",
"+INF = 10**18",
"+prev_R = -INF",
"-for L, R in arms:",
"- if finishtime <= L:",
"- cnt += 1",
"- finishtime = R",
"+for L, R in LR:",
"+ if prev_R > L:",
"+ continue",
"+ cnt += 1",
"+ prev_R = R"
]
| false | 0.047604 | 0.038189 | 1.246537 | [
"s856098298",
"s389129179"
]
|
u535171899 | p02725 | python | s478025214 | s414128919 | 137 | 112 | 26,420 | 26,436 | Accepted | Accepted | 18.25 | inputs = [int(i) for i in input().split()]
K,N = inputs[0],inputs[1]
input_lines = [int(i) for i in input().split()]
max_range = input_lines[0]+(K-input_lines[-1])
for i in range(N):
if i!=N-1:
torange = input_lines[i+1]-input_lines[i]
if torange>max_range:
max_range = torange
print((K-max_range))
| k,n = list(map(int,input().split()))
a_inputs = [int(a) for a in input().split()]
longest = a_inputs[0]+(k-a_inputs[-1])
for i in range(n-1):
if a_inputs[i+1]-a_inputs[i]>longest:
longest = a_inputs[i+1]-a_inputs[i]
print((k-longest)) | 12 | 9 | 342 | 248 | inputs = [int(i) for i in input().split()]
K, N = inputs[0], inputs[1]
input_lines = [int(i) for i in input().split()]
max_range = input_lines[0] + (K - input_lines[-1])
for i in range(N):
if i != N - 1:
torange = input_lines[i + 1] - input_lines[i]
if torange > max_range:
max_range = torange
print((K - max_range))
| k, n = list(map(int, input().split()))
a_inputs = [int(a) for a in input().split()]
longest = a_inputs[0] + (k - a_inputs[-1])
for i in range(n - 1):
if a_inputs[i + 1] - a_inputs[i] > longest:
longest = a_inputs[i + 1] - a_inputs[i]
print((k - longest))
| false | 25 | [
"-inputs = [int(i) for i in input().split()]",
"-K, N = inputs[0], inputs[1]",
"-input_lines = [int(i) for i in input().split()]",
"-max_range = input_lines[0] + (K - input_lines[-1])",
"-for i in range(N):",
"- if i != N - 1:",
"- torange = input_lines[i + 1] - input_lines[i]",
"- if torange > max_range:",
"- max_range = torange",
"-print((K - max_range))",
"+k, n = list(map(int, input().split()))",
"+a_inputs = [int(a) for a in input().split()]",
"+longest = a_inputs[0] + (k - a_inputs[-1])",
"+for i in range(n - 1):",
"+ if a_inputs[i + 1] - a_inputs[i] > longest:",
"+ longest = a_inputs[i + 1] - a_inputs[i]",
"+print((k - longest))"
]
| false | 0.036094 | 0.038348 | 0.941213 | [
"s478025214",
"s414128919"
]
|
u219180252 | p03164 | python | s661619452 | s771612667 | 1,973 | 1,002 | 318,832 | 307,912 | Accepted | Accepted | 49.21 | N, W = list(map(int, input().split()))
w_v = [list(map(int, input().split())) for _ in range(N)]
V = max(w_v, key=lambda x: x[1])[1] * N
# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ
dp = [[float('inf') for _ in range(V+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
w, v = w_v[i]
for j in range(V+1):
if j - v >= 0:
dp[i+1][j] = min(dp[i][j-v]+w, dp[i][j])
else:
#dp[i+1][j] = min(dp[i][j], dp[i+1][j])
dp[i+1][j] = dp[i][j]
r = 0
for v in range(V+1):
if dp[N][v] <= W:
r = v
print(r) | n, W = list(map(int, input().split()))
data = []
for _ in range(n):
w, v = list(map(int, input().split()))
data.append((w, v))
V = sum([v for _, v in data])
dp = [[float("inf")] * (V + 1) for i in range(n + 1)]
dp[0][0]= 0
for i in range(1, n+1):
w, v = data[i-1]
for j in range(V + 1):
if j - v >= 0:
dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])
else:
dp[i][j] = dp[i - 1][j]
print((max([i for i, x in enumerate(dp[-1]) if x != "inf" and x <= W])))
| 22 | 19 | 577 | 539 | N, W = list(map(int, input().split()))
w_v = [list(map(int, input().split())) for _ in range(N)]
V = max(w_v, key=lambda x: x[1])[1] * N
# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ
dp = [[float("inf") for _ in range(V + 1)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
w, v = w_v[i]
for j in range(V + 1):
if j - v >= 0:
dp[i + 1][j] = min(dp[i][j - v] + w, dp[i][j])
else:
# dp[i+1][j] = min(dp[i][j], dp[i+1][j])
dp[i + 1][j] = dp[i][j]
r = 0
for v in range(V + 1):
if dp[N][v] <= W:
r = v
print(r)
| n, W = list(map(int, input().split()))
data = []
for _ in range(n):
w, v = list(map(int, input().split()))
data.append((w, v))
V = sum([v for _, v in data])
dp = [[float("inf")] * (V + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
w, v = data[i - 1]
for j in range(V + 1):
if j - v >= 0:
dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])
else:
dp[i][j] = dp[i - 1][j]
print((max([i for i, x in enumerate(dp[-1]) if x != "inf" and x <= W])))
| false | 13.636364 | [
"-N, W = list(map(int, input().split()))",
"-w_v = [list(map(int, input().split())) for _ in range(N)]",
"-V = max(w_v, key=lambda x: x[1])[1] * N",
"-# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ",
"-dp = [[float(\"inf\") for _ in range(V + 1)] for _ in range(N + 1)]",
"+n, W = list(map(int, input().split()))",
"+data = []",
"+for _ in range(n):",
"+ w, v = list(map(int, input().split()))",
"+ data.append((w, v))",
"+V = sum([v for _, v in data])",
"+dp = [[float(\"inf\")] * (V + 1) for i in range(n + 1)]",
"-for i in range(N):",
"- w, v = w_v[i]",
"+for i in range(1, n + 1):",
"+ w, v = data[i - 1]",
"- dp[i + 1][j] = min(dp[i][j - v] + w, dp[i][j])",
"+ dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])",
"- # dp[i+1][j] = min(dp[i][j], dp[i+1][j])",
"- dp[i + 1][j] = dp[i][j]",
"-r = 0",
"-for v in range(V + 1):",
"- if dp[N][v] <= W:",
"- r = v",
"-print(r)",
"+ dp[i][j] = dp[i - 1][j]",
"+print((max([i for i, x in enumerate(dp[-1]) if x != \"inf\" and x <= W])))"
]
| false | 0.148534 | 0.039299 | 3.779605 | [
"s661619452",
"s771612667"
]
|
u784022244 | p03831 | python | s542796080 | s558073181 | 222 | 84 | 62,704 | 14,252 | Accepted | Accepted | 62.16 | N,A,B=list(map(int, input().split()))
X=list(map(int, input().split()))
ans=0
for i in range(N-1):
l=X[i+1]-X[i]
ans+=min(l*A,B)
print(ans) | N,A,B=list(map(int, input().split()))
X=list(map(int, input().split()))
now=X[0]
ans=0
for i in range(1,N):
nex=X[i]
if (nex-now)*A>B:
ans+=B
else:
ans+=(nex-now)*A
now=nex
print(ans) | 7 | 12 | 147 | 220 | N, A, B = list(map(int, input().split()))
X = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
l = X[i + 1] - X[i]
ans += min(l * A, B)
print(ans)
| N, A, B = list(map(int, input().split()))
X = list(map(int, input().split()))
now = X[0]
ans = 0
for i in range(1, N):
nex = X[i]
if (nex - now) * A > B:
ans += B
else:
ans += (nex - now) * A
now = nex
print(ans)
| false | 41.666667 | [
"+now = X[0]",
"-for i in range(N - 1):",
"- l = X[i + 1] - X[i]",
"- ans += min(l * A, B)",
"+for i in range(1, N):",
"+ nex = X[i]",
"+ if (nex - now) * A > B:",
"+ ans += B",
"+ else:",
"+ ans += (nex - now) * A",
"+ now = nex"
]
| false | 0.146572 | 0.039765 | 3.685974 | [
"s542796080",
"s558073181"
]
|
u905203728 | p03044 | python | s990553501 | s060136517 | 633 | 555 | 97,372 | 87,132 | Accepted | Accepted | 12.32 | from collections import deque
import sys
input=sys.stdin.readline
def BFS():
color=["white" for _ in range(n)]
D=[0]*n
M=[[] for _ in range(n)]
for u,v,w in UVW:
M[u-1].append([v-1,w])
M[v-1].append([u-1,w])
D[0]=1
color[0]="gray"
queue=deque([0])
while len(queue)>0:
u=queue.popleft()
for i,j in M[u]:
if color[i]=="white":
if j%2==0:D[i]=D[u]
elif j%2==1:D[i]=-D[u]
color[i]="gray"
queue.append(i)
color[u]="black"
return D
n=int(eval(input()))
UVW=[list(map(int,input().split())) for _ in range(n-1)]
for i in BFS():
if i==-1:print((0))
else:print(i) | from collections import deque
import sys
input=sys.stdin.readline
def BFS():
color=["white" for _ in range(n)]
D=[0]*n
M=[[] for _ in range(n)]
for u,v,w in UVW:
M[u-1].append((v-1,w))
M[v-1].append((u-1,w))
D[0]=1
color[0]="gray"
queue=deque([0])
while len(queue)>0:
u=queue.popleft()
for i,j in M[u]:
if color[i]=="white":
if j%2==0:D[i]=D[u]
elif j%2==1:D[i]=-D[u]
color[i]="gray"
queue.append(i)
color[u]="black"
return D
n=int(eval(input()))
UVW=[list(map(int,input().split())) for _ in range(n-1)]
for i in BFS():
if i==-1:print((0))
else:print(i) | 36 | 36 | 748 | 748 | from collections import deque
import sys
input = sys.stdin.readline
def BFS():
color = ["white" for _ in range(n)]
D = [0] * n
M = [[] for _ in range(n)]
for u, v, w in UVW:
M[u - 1].append([v - 1, w])
M[v - 1].append([u - 1, w])
D[0] = 1
color[0] = "gray"
queue = deque([0])
while len(queue) > 0:
u = queue.popleft()
for i, j in M[u]:
if color[i] == "white":
if j % 2 == 0:
D[i] = D[u]
elif j % 2 == 1:
D[i] = -D[u]
color[i] = "gray"
queue.append(i)
color[u] = "black"
return D
n = int(eval(input()))
UVW = [list(map(int, input().split())) for _ in range(n - 1)]
for i in BFS():
if i == -1:
print((0))
else:
print(i)
| from collections import deque
import sys
input = sys.stdin.readline
def BFS():
color = ["white" for _ in range(n)]
D = [0] * n
M = [[] for _ in range(n)]
for u, v, w in UVW:
M[u - 1].append((v - 1, w))
M[v - 1].append((u - 1, w))
D[0] = 1
color[0] = "gray"
queue = deque([0])
while len(queue) > 0:
u = queue.popleft()
for i, j in M[u]:
if color[i] == "white":
if j % 2 == 0:
D[i] = D[u]
elif j % 2 == 1:
D[i] = -D[u]
color[i] = "gray"
queue.append(i)
color[u] = "black"
return D
n = int(eval(input()))
UVW = [list(map(int, input().split())) for _ in range(n - 1)]
for i in BFS():
if i == -1:
print((0))
else:
print(i)
| false | 0 | [
"- M[u - 1].append([v - 1, w])",
"- M[v - 1].append([u - 1, w])",
"+ M[u - 1].append((v - 1, w))",
"+ M[v - 1].append((u - 1, w))"
]
| false | 0.064352 | 0.040625 | 1.58402 | [
"s990553501",
"s060136517"
]
|
u374146618 | p02772 | python | s097222073 | s280779282 | 273 | 148 | 20,144 | 12,444 | Accepted | Accepted | 45.79 | import numpy as np
n = int(eval(input()))
a = np.array([int(x) for x in input().split()])
aa = a[a%2 == 0]
aaa = aa[(aa%3 == 0) | (aa%5 == 0)]
if len(aa) == len(aaa):
print("APPROVED")
else:
print("DENIED") | import numpy as np
n = int(eval(input()))
a = np.array([int(x) for x in input().split()])
aa = a[a%2 == 0]
if np.all((aa%3 == 0) | (aa%5 == 0)):
print("APPROVED")
else:
print("DENIED") | 12 | 10 | 222 | 197 | import numpy as np
n = int(eval(input()))
a = np.array([int(x) for x in input().split()])
aa = a[a % 2 == 0]
aaa = aa[(aa % 3 == 0) | (aa % 5 == 0)]
if len(aa) == len(aaa):
print("APPROVED")
else:
print("DENIED")
| import numpy as np
n = int(eval(input()))
a = np.array([int(x) for x in input().split()])
aa = a[a % 2 == 0]
if np.all((aa % 3 == 0) | (aa % 5 == 0)):
print("APPROVED")
else:
print("DENIED")
| false | 16.666667 | [
"-aaa = aa[(aa % 3 == 0) | (aa % 5 == 0)]",
"-if len(aa) == len(aaa):",
"+if np.all((aa % 3 == 0) | (aa % 5 == 0)):"
]
| false | 0.182437 | 0.183092 | 0.996427 | [
"s097222073",
"s280779282"
]
|
u629540524 | p02819 | python | s484226447 | s588497389 | 41 | 29 | 8,908 | 9,304 | Accepted | Accepted | 29.27 | x = int(eval(input()))
n = 2
while n<x:
if x%n == 0:
x+=1
n=2
else:
n+=1
print(x) | x = int(eval(input()))
for y in range(x,2*x):
for i in range(2, int(y**.5)+1):
if y%i ==0:
break
else:
print(y)
break | 9 | 8 | 115 | 162 | x = int(eval(input()))
n = 2
while n < x:
if x % n == 0:
x += 1
n = 2
else:
n += 1
print(x)
| x = int(eval(input()))
for y in range(x, 2 * x):
for i in range(2, int(y**0.5) + 1):
if y % i == 0:
break
else:
print(y)
break
| false | 11.111111 | [
"-n = 2",
"-while n < x:",
"- if x % n == 0:",
"- x += 1",
"- n = 2",
"+for y in range(x, 2 * x):",
"+ for i in range(2, int(y**0.5) + 1):",
"+ if y % i == 0:",
"+ break",
"- n += 1",
"-print(x)",
"+ print(y)",
"+ break"
]
| false | 0.040727 | 0.036957 | 1.101996 | [
"s484226447",
"s588497389"
]
|
u046187684 | p02959 | python | s165694449 | s088118072 | 152 | 137 | 28,052 | 18,624 | Accepted | Accepted | 9.87 | def solve(string):
n, *ab = list(map(int, string.split()))
a, b = ab[:n + 1], ab[n + 1:]
_sum = sum(a)
for i, _b in enumerate(b[::-1]):
diff = min(a[n - i], _b)
_b -= diff
a[n - i] -= diff
a[n - i - 1] = max(0, a[n - i - 1] - _b)
return str(_sum - sum(a))
if __name__ == '__main__':
n = int(eval(input()))
print((solve('{}\n'.format(n) + '\n'.join([eval(input()) for _ in range(2)]))))
| N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
pow = 0
ans = 0
for a, b in zip(A, B):
ans += a if pow >= a else pow
a = 0 if pow >= a else a - pow
ans += a if a <= b else b
pow = b - a if b >= a else 0
ans += A[N] if pow >= A[N] else pow
print(ans)
| 15 | 12 | 442 | 322 | def solve(string):
n, *ab = list(map(int, string.split()))
a, b = ab[: n + 1], ab[n + 1 :]
_sum = sum(a)
for i, _b in enumerate(b[::-1]):
diff = min(a[n - i], _b)
_b -= diff
a[n - i] -= diff
a[n - i - 1] = max(0, a[n - i - 1] - _b)
return str(_sum - sum(a))
if __name__ == "__main__":
n = int(eval(input()))
print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(2)]))))
| N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
pow = 0
ans = 0
for a, b in zip(A, B):
ans += a if pow >= a else pow
a = 0 if pow >= a else a - pow
ans += a if a <= b else b
pow = b - a if b >= a else 0
ans += A[N] if pow >= A[N] else pow
print(ans)
| false | 20 | [
"-def solve(string):",
"- n, *ab = list(map(int, string.split()))",
"- a, b = ab[: n + 1], ab[n + 1 :]",
"- _sum = sum(a)",
"- for i, _b in enumerate(b[::-1]):",
"- diff = min(a[n - i], _b)",
"- _b -= diff",
"- a[n - i] -= diff",
"- a[n - i - 1] = max(0, a[n - i - 1] - _b)",
"- return str(_sum - sum(a))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- n = int(eval(input()))",
"- print((solve(\"{}\\n\".format(n) + \"\\n\".join([eval(input()) for _ in range(2)]))))",
"+N = int(eval(input()))",
"+A = [int(a) for a in input().split()]",
"+B = [int(b) for b in input().split()]",
"+pow = 0",
"+ans = 0",
"+for a, b in zip(A, B):",
"+ ans += a if pow >= a else pow",
"+ a = 0 if pow >= a else a - pow",
"+ ans += a if a <= b else b",
"+ pow = b - a if b >= a else 0",
"+ans += A[N] if pow >= A[N] else pow",
"+print(ans)"
]
| false | 0.098023 | 0.042258 | 2.319642 | [
"s165694449",
"s088118072"
]
|
u774160580 | p03549 | python | s510715323 | s756449074 | 174 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.23 | N, M = list(map(int, input().split()))
print(((M * 1900 + (N - M) * 100) * pow(2, M))) | N, M = list(map(int, input().split()))
print(((1800 * M + 100 * N) * 2 ** M))
| 2 | 2 | 85 | 71 | N, M = list(map(int, input().split()))
print(((M * 1900 + (N - M) * 100) * pow(2, M)))
| N, M = list(map(int, input().split()))
print(((1800 * M + 100 * N) * 2**M))
| false | 0 | [
"-print(((M * 1900 + (N - M) * 100) * pow(2, M)))",
"+print(((1800 * M + 100 * N) * 2**M))"
]
| false | 0.041444 | 0.042262 | 0.98063 | [
"s510715323",
"s756449074"
]
|
u189056821 | p03160 | python | s067306251 | s611939107 | 436 | 126 | 22,700 | 13,980 | Accepted | Accepted | 71.1 | import numpy as np
n = int(eval(input()))
h = np.array(list(map(int, input().split())))
dp = np.full_like(h, np.inf)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, len(h)):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[(len(h) - 1)])) | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1])) | 13 | 11 | 296 | 233 | import numpy as np
n = int(eval(input()))
h = np.array(list(map(int, input().split())))
dp = np.full_like(h, np.inf)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, len(h)):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[(len(h) - 1)]))
| n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))
| false | 15.384615 | [
"-import numpy as np",
"-",
"-h = np.array(list(map(int, input().split())))",
"-dp = np.full_like(h, np.inf)",
"+h = list(map(int, input().split()))",
"+dp = [0] * n",
"-for i in range(2, len(h)):",
"+for i in range(2, n):",
"-print((dp[(len(h) - 1)]))",
"+print((dp[-1]))"
]
| false | 0.265854 | 0.036617 | 7.260457 | [
"s067306251",
"s611939107"
]
|
u905329882 | p02803 | python | s414319255 | s730118099 | 601 | 433 | 27,432 | 27,292 | Accepted | Accepted | 27.95 | import sys
sys.setrecursionlimit(3000)
import numpy as np
h,w = list(map(int,input().split()))
s = []
for i in range(h):
s.append(list(eval(input())))
from collections import deque
def bfs(i,j,dist):
seen[i][j] = dist
lis = [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]
for place in lis:
if place[0]<0 or place[0]>=h or place[1]<0 or place[1]>=w:
continue
if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]]=="#":
continue
if [place[0],place[1],dist+1] in que:
continue
que.append([place[0],place[1],dist+1])
if len(que):
new = que.popleft()
bfs(new[0],new[1],new[2])
else:
return
mx = 0
for i in range(h):
for j in range(w):
if s[i][j]=="#":
continue
seen = [[-1 for _ in range(w)]for _ in range(h)]
que = deque()
bfs(i,j,0)
ast = np.array(seen)
tmp = np.amax(ast)
mx = max(mx,tmp)
#print(seen)
#print(*seen,sep="\n")
print(mx)
| import sys
sys.setrecursionlimit(3000)
import numpy as np
h,w = list(map(int,input().split()))
s = []
for i in range(h):
s.append(list(eval(input())))
from collections import deque
def bfs(i,j,dist):
lis = [[i-1,j],[i,j-1],[i+1,j],[i,j+1]]
for place in lis:
if place[0]<0 or place[0]>=h or place[1]<0 or place[1]>=w:
continue
if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]]=="#":
continue
seen[place[0]][place[1]] = dist+1
que.append([place[0],place[1],dist+1])
if len(que):
new = que.popleft()
bfs(new[0],new[1],new[2])
else:
return
mx = 0
for i in range(h):
for j in range(w):
if s[i][j]=="#":
continue
seen = [[-1 for _ in range(w)]for _ in range(h)]
que = deque()
seen[i][j] = 0
bfs(i,j,0)
ast = np.array(seen)
tmp = np.amax(ast)
mx = max(mx,tmp)
#print(seen)
#print(*seen,sep="\n")
print(mx)
| 45 | 44 | 1,072 | 1,047 | import sys
sys.setrecursionlimit(3000)
import numpy as np
h, w = list(map(int, input().split()))
s = []
for i in range(h):
s.append(list(eval(input())))
from collections import deque
def bfs(i, j, dist):
seen[i][j] = dist
lis = [[i - 1, j], [i, j - 1], [i + 1, j], [i, j + 1]]
for place in lis:
if place[0] < 0 or place[0] >= h or place[1] < 0 or place[1] >= w:
continue
if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]] == "#":
continue
if [place[0], place[1], dist + 1] in que:
continue
que.append([place[0], place[1], dist + 1])
if len(que):
new = que.popleft()
bfs(new[0], new[1], new[2])
else:
return
mx = 0
for i in range(h):
for j in range(w):
if s[i][j] == "#":
continue
seen = [[-1 for _ in range(w)] for _ in range(h)]
que = deque()
bfs(i, j, 0)
ast = np.array(seen)
tmp = np.amax(ast)
mx = max(mx, tmp)
# print(seen)
# print(*seen,sep="\n")
print(mx)
| import sys
sys.setrecursionlimit(3000)
import numpy as np
h, w = list(map(int, input().split()))
s = []
for i in range(h):
s.append(list(eval(input())))
from collections import deque
def bfs(i, j, dist):
lis = [[i - 1, j], [i, j - 1], [i + 1, j], [i, j + 1]]
for place in lis:
if place[0] < 0 or place[0] >= h or place[1] < 0 or place[1] >= w:
continue
if seen[place[0]][place[1]] != -1 or s[place[0]][place[1]] == "#":
continue
seen[place[0]][place[1]] = dist + 1
que.append([place[0], place[1], dist + 1])
if len(que):
new = que.popleft()
bfs(new[0], new[1], new[2])
else:
return
mx = 0
for i in range(h):
for j in range(w):
if s[i][j] == "#":
continue
seen = [[-1 for _ in range(w)] for _ in range(h)]
que = deque()
seen[i][j] = 0
bfs(i, j, 0)
ast = np.array(seen)
tmp = np.amax(ast)
mx = max(mx, tmp)
# print(seen)
# print(*seen,sep="\n")
print(mx)
| false | 2.222222 | [
"- seen[i][j] = dist",
"- if [place[0], place[1], dist + 1] in que:",
"- continue",
"+ seen[place[0]][place[1]] = dist + 1",
"+ seen[i][j] = 0"
]
| false | 0.250295 | 0.558343 | 0.448281 | [
"s414319255",
"s730118099"
]
|
u994988729 | p03168 | python | s235705693 | s290631716 | 1,550 | 1,029 | 22,404 | 22,404 | Accepted | Accepted | 33.61 | import numpy as np
N = int(eval(input()))
P = np.array(input().split(), dtype=float)
dp = np.zeros(N + 1, dtype=float)
dp[0] = 1 - P[0]
dp[1] = P[0]
for i in range(N - 1):
newDP = dp * (1 - P[i + 1])
newDP[1:] += dp[:-1] * P[i + 1]
dp = newDP.copy()
n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)
| import numpy as np
N = int(eval(input()))
P = np.array(input().split(), dtype=float)
dp = np.zeros(N + 1, dtype=float)
dp[0] = 1
for p in P:
newDP = dp * (1-p)
newDP[1:] += dp[:-1] * p
dp = newDP
n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)
| 16 | 15 | 321 | 266 | import numpy as np
N = int(eval(input()))
P = np.array(input().split(), dtype=float)
dp = np.zeros(N + 1, dtype=float)
dp[0] = 1 - P[0]
dp[1] = P[0]
for i in range(N - 1):
newDP = dp * (1 - P[i + 1])
newDP[1:] += dp[:-1] * P[i + 1]
dp = newDP.copy()
n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)
| import numpy as np
N = int(eval(input()))
P = np.array(input().split(), dtype=float)
dp = np.zeros(N + 1, dtype=float)
dp[0] = 1
for p in P:
newDP = dp * (1 - p)
newDP[1:] += dp[:-1] * p
dp = newDP
n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)
| false | 6.25 | [
"-dp[0] = 1 - P[0]",
"-dp[1] = P[0]",
"-for i in range(N - 1):",
"- newDP = dp * (1 - P[i + 1])",
"- newDP[1:] += dp[:-1] * P[i + 1]",
"- dp = newDP.copy()",
"+dp[0] = 1",
"+for p in P:",
"+ newDP = dp * (1 - p)",
"+ newDP[1:] += dp[:-1] * p",
"+ dp = newDP"
]
| false | 0.21332 | 0.521692 | 0.4089 | [
"s235705693",
"s290631716"
]
|
u332385682 | p03806 | python | s170772492 | s952826853 | 213 | 183 | 40,560 | 5,752 | Accepted | Accepted | 14.08 |
def solve():
N, Ma, Mb = list(map(int, input().split()))
a, b, c = [], [], []
for i in range(N):
ai, bi, ci = list(map(int, input().split()))
a.append(ai)
b.append(bi)
c.append(ci)
alim = sum(a)
blim = sum(b)
inf = 40 * 100 + 1
dp = [[inf]*(blim + 1) for i in range(alim + 1)]
dp[0][0] = 0
for i in range(N):
for u in range(alim, a[i] - 1, -1):
for v in range(blim, b[i] - 1, -1):
dp[u][v] = min(dp[u][v], dp[u - a[i]][v - b[i]] + c[i])
ans = inf
for u in range(1, alim + 1):
for v in range(1, blim + 1):
if u * Mb == v * Ma:
ans = min(ans, dp[u][v])
if ans < inf:
print(ans)
else:
print((-1))
if __name__ == '__main__':
solve() |
def solve():
N, Ma, Mb = list(map(int, input().split()))
a, b, c = [], [], []
for i in range(N):
ai, bi, ci = list(map(int, input().split()))
a.append(ai)
b.append(bi)
c.append(ci)
nvals = 99 * N * 2 + 1
inf = 40 * 100 + 1
dp = [[inf] * nvals for i in range(N)]
for i in range(N):
v = Mb * a[i] - Ma * b[i]
if i == 0:
dp[i][v] = c[i]
continue
for j in range(-99 * N, 99 * N + 1):
if -99 * N <= j - v <= 99 * N:
dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + c[i])
dp[i][v] = min(dp[i][v], c[i])
ans = dp[N - 1][0]
if ans < inf:
print(ans)
else:
print((-1))
if __name__ == '__main__':
solve() | 37 | 37 | 835 | 800 | def solve():
N, Ma, Mb = list(map(int, input().split()))
a, b, c = [], [], []
for i in range(N):
ai, bi, ci = list(map(int, input().split()))
a.append(ai)
b.append(bi)
c.append(ci)
alim = sum(a)
blim = sum(b)
inf = 40 * 100 + 1
dp = [[inf] * (blim + 1) for i in range(alim + 1)]
dp[0][0] = 0
for i in range(N):
for u in range(alim, a[i] - 1, -1):
for v in range(blim, b[i] - 1, -1):
dp[u][v] = min(dp[u][v], dp[u - a[i]][v - b[i]] + c[i])
ans = inf
for u in range(1, alim + 1):
for v in range(1, blim + 1):
if u * Mb == v * Ma:
ans = min(ans, dp[u][v])
if ans < inf:
print(ans)
else:
print((-1))
if __name__ == "__main__":
solve()
| def solve():
N, Ma, Mb = list(map(int, input().split()))
a, b, c = [], [], []
for i in range(N):
ai, bi, ci = list(map(int, input().split()))
a.append(ai)
b.append(bi)
c.append(ci)
nvals = 99 * N * 2 + 1
inf = 40 * 100 + 1
dp = [[inf] * nvals for i in range(N)]
for i in range(N):
v = Mb * a[i] - Ma * b[i]
if i == 0:
dp[i][v] = c[i]
continue
for j in range(-99 * N, 99 * N + 1):
if -99 * N <= j - v <= 99 * N:
dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + c[i])
dp[i][v] = min(dp[i][v], c[i])
ans = dp[N - 1][0]
if ans < inf:
print(ans)
else:
print((-1))
if __name__ == "__main__":
solve()
| false | 0 | [
"- alim = sum(a)",
"- blim = sum(b)",
"+ nvals = 99 * N * 2 + 1",
"- dp = [[inf] * (blim + 1) for i in range(alim + 1)]",
"- dp[0][0] = 0",
"+ dp = [[inf] * nvals for i in range(N)]",
"- for u in range(alim, a[i] - 1, -1):",
"- for v in range(blim, b[i] - 1, -1):",
"- dp[u][v] = min(dp[u][v], dp[u - a[i]][v - b[i]] + c[i])",
"- ans = inf",
"- for u in range(1, alim + 1):",
"- for v in range(1, blim + 1):",
"- if u * Mb == v * Ma:",
"- ans = min(ans, dp[u][v])",
"+ v = Mb * a[i] - Ma * b[i]",
"+ if i == 0:",
"+ dp[i][v] = c[i]",
"+ continue",
"+ for j in range(-99 * N, 99 * N + 1):",
"+ if -99 * N <= j - v <= 99 * N:",
"+ dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + c[i])",
"+ dp[i][v] = min(dp[i][v], c[i])",
"+ ans = dp[N - 1][0]"
]
| false | 0.034775 | 0.04935 | 0.704646 | [
"s170772492",
"s952826853"
]
|
u977389981 | p03409 | python | s470083743 | s402392951 | 27 | 20 | 3,064 | 3,064 | Accepted | Accepted | 25.93 | N = int(eval(input()))
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)],
key=lambda x: x[1],
reverse=True)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])
for i in range(N):
for j in range(len(AB)):
if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
del AB[j]
break
print((N - len(AB))) | N = int(eval(input()))
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)],
key=lambda x: x[1],
reverse=True)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])
count = 0
for i in range(N):
for j in range(len(AB)):
if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
del AB[j]
count += 1
break
print(count) | 12 | 14 | 384 | 413 | N = int(eval(input()))
AB = sorted(
[[int(_) for _ in input().split()] for _ in range(N)],
key=lambda x: x[1],
reverse=True,
)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])
for i in range(N):
for j in range(len(AB)):
if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
del AB[j]
break
print((N - len(AB)))
| N = int(eval(input()))
AB = sorted(
[[int(_) for _ in input().split()] for _ in range(N)],
key=lambda x: x[1],
reverse=True,
)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])
count = 0
for i in range(N):
for j in range(len(AB)):
if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
del AB[j]
count += 1
break
print(count)
| false | 14.285714 | [
"+count = 0",
"+ count += 1",
"-print((N - len(AB)))",
"+print(count)"
]
| false | 0.04181 | 0.105888 | 0.394853 | [
"s470083743",
"s402392951"
]
|
u785989355 | p03222 | python | s890140570 | s060421684 | 20 | 18 | 3,064 | 3,064 | Accepted | Accepted | 10 | H,W,K = list(map(int,input().split()))
amida = [0 for i in range(8)]
amida[0]=1
amida[1]=2
amida[2]=3
amida[3]=5
amida[4]=8
amida[5]=13
amida[6]=21
amida[7]=34
def amida_num(k,l):
return amida[max(k,0)]*amida[max(l,0)]
dp=[[0 for i in range(W)] for j in range(H+1)]
dp[0][0] = 1
if W!=1:
for i in range(1,H+1):
for j in range(W):
if j==0:
dp[i][j]=dp[i-1][j+1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
elif j==W-1:
dp[i][j]=dp[i-1][j-1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
else:
dp[i][j]=dp[i-1][j-1]*amida_num(j-2,W-j-2) + dp[i-1][j]*amida_num(j-1,W-j-2) + dp[i-1][j+1]*amida_num(j-1,W-j-3)
print((dp[H][K-1]%(10**9+7)))
else:
print((1)) | H,W,K=list(map(int,input().split()))
r = 10**9 + 7
dp=[[0 for i in range(W)] for j in range(H+1)]
dp[0][0]=1
num = [1,1,2,3,5,8,13,21]
if W!=1:
for i in range(H):
for j in range(W):
if j==0:
dp[i+1][j]=(num[W-1]*dp[i][j]+num[W-2]*dp[i][j+1])%r
elif j==W-1:
dp[i+1][j]=(num[W-1]*dp[i][j]+num[W-2]*dp[i][j-1])%r
else:
dp[i+1][j]=(num[j]*num[W-j-1]*dp[i][j]+num[j-1]*num[W-j-1]*dp[i][j-1]+num[j]*num[W-j-2]*dp[i][j+1])%r
print((dp[H][K-1]))
else:
print((1))
| 33 | 22 | 807 | 581 | H, W, K = list(map(int, input().split()))
amida = [0 for i in range(8)]
amida[0] = 1
amida[1] = 2
amida[2] = 3
amida[3] = 5
amida[4] = 8
amida[5] = 13
amida[6] = 21
amida[7] = 34
def amida_num(k, l):
return amida[max(k, 0)] * amida[max(l, 0)]
dp = [[0 for i in range(W)] for j in range(H + 1)]
dp[0][0] = 1
if W != 1:
for i in range(1, H + 1):
for j in range(W):
if j == 0:
dp[i][j] = dp[i - 1][j + 1] * amida_num(0, W - 3) + dp[i - 1][
j
] * amida_num(0, W - 2)
elif j == W - 1:
dp[i][j] = dp[i - 1][j - 1] * amida_num(0, W - 3) + dp[i - 1][
j
] * amida_num(0, W - 2)
else:
dp[i][j] = (
dp[i - 1][j - 1] * amida_num(j - 2, W - j - 2)
+ dp[i - 1][j] * amida_num(j - 1, W - j - 2)
+ dp[i - 1][j + 1] * amida_num(j - 1, W - j - 3)
)
print((dp[H][K - 1] % (10**9 + 7)))
else:
print((1))
| H, W, K = list(map(int, input().split()))
r = 10**9 + 7
dp = [[0 for i in range(W)] for j in range(H + 1)]
dp[0][0] = 1
num = [1, 1, 2, 3, 5, 8, 13, 21]
if W != 1:
for i in range(H):
for j in range(W):
if j == 0:
dp[i + 1][j] = (num[W - 1] * dp[i][j] + num[W - 2] * dp[i][j + 1]) % r
elif j == W - 1:
dp[i + 1][j] = (num[W - 1] * dp[i][j] + num[W - 2] * dp[i][j - 1]) % r
else:
dp[i + 1][j] = (
num[j] * num[W - j - 1] * dp[i][j]
+ num[j - 1] * num[W - j - 1] * dp[i][j - 1]
+ num[j] * num[W - j - 2] * dp[i][j + 1]
) % r
print((dp[H][K - 1]))
else:
print((1))
| false | 33.333333 | [
"-amida = [0 for i in range(8)]",
"-amida[0] = 1",
"-amida[1] = 2",
"-amida[2] = 3",
"-amida[3] = 5",
"-amida[4] = 8",
"-amida[5] = 13",
"-amida[6] = 21",
"-amida[7] = 34",
"-",
"-",
"-def amida_num(k, l):",
"- return amida[max(k, 0)] * amida[max(l, 0)]",
"-",
"-",
"+r = 10**9 + 7",
"+num = [1, 1, 2, 3, 5, 8, 13, 21]",
"- for i in range(1, H + 1):",
"+ for i in range(H):",
"- dp[i][j] = dp[i - 1][j + 1] * amida_num(0, W - 3) + dp[i - 1][",
"- j",
"- ] * amida_num(0, W - 2)",
"+ dp[i + 1][j] = (num[W - 1] * dp[i][j] + num[W - 2] * dp[i][j + 1]) % r",
"- dp[i][j] = dp[i - 1][j - 1] * amida_num(0, W - 3) + dp[i - 1][",
"- j",
"- ] * amida_num(0, W - 2)",
"+ dp[i + 1][j] = (num[W - 1] * dp[i][j] + num[W - 2] * dp[i][j - 1]) % r",
"- dp[i][j] = (",
"- dp[i - 1][j - 1] * amida_num(j - 2, W - j - 2)",
"- + dp[i - 1][j] * amida_num(j - 1, W - j - 2)",
"- + dp[i - 1][j + 1] * amida_num(j - 1, W - j - 3)",
"- )",
"- print((dp[H][K - 1] % (10**9 + 7)))",
"+ dp[i + 1][j] = (",
"+ num[j] * num[W - j - 1] * dp[i][j]",
"+ + num[j - 1] * num[W - j - 1] * dp[i][j - 1]",
"+ + num[j] * num[W - j - 2] * dp[i][j + 1]",
"+ ) % r",
"+ print((dp[H][K - 1]))"
]
| false | 0.046413 | 0.046121 | 1.006324 | [
"s890140570",
"s060421684"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.