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
sequence | 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
sequence |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u203843959 | p02732 | python | s220043573 | s741548377 | 416 | 329 | 35,576 | 25,004 | Accepted | Accepted | 20.91 | N=int(eval(input()))
alist=list(map(int,input().split()))
#print(alist)
dic_a={}
for a in alist:
if not a in dic_a:
dic_a[a]=1
else:
dic_a[a]+=1
all_pair=0
for val in list(dic_a.values()):
all_pair+=val*(val-1)//2
#print(dic_a,all_pair)
dic_answer={}
for a in alist:
if a in dic_answer:
print((dic_answer[a]))
continue
now=dic_a[a]
kill=now*(now-1)//2-(now-1)*(now-2)//2
answer=all_pair-kill
print(answer)
dic_answer[a]=answer | N=int(eval(input()))
alist=list(map(int,input().split()))
#print(alist)
dic_a={}
for a in alist:
if not a in dic_a:
dic_a[a]=1
else:
dic_a[a]+=1
all_pair=0
for val in list(dic_a.values()):
all_pair+=val*(val-1)//2
#print(dic_a,all_pair)
for a in alist:
answer=all_pair-dic_a[a]+1
print(answer) | 28 | 19 | 488 | 324 | N = int(eval(input()))
alist = list(map(int, input().split()))
# print(alist)
dic_a = {}
for a in alist:
if not a in dic_a:
dic_a[a] = 1
else:
dic_a[a] += 1
all_pair = 0
for val in list(dic_a.values()):
all_pair += val * (val - 1) // 2
# print(dic_a,all_pair)
dic_answer = {}
for a in alist:
if a in dic_answer:
print((dic_answer[a]))
continue
now = dic_a[a]
kill = now * (now - 1) // 2 - (now - 1) * (now - 2) // 2
answer = all_pair - kill
print(answer)
dic_answer[a] = answer
| N = int(eval(input()))
alist = list(map(int, input().split()))
# print(alist)
dic_a = {}
for a in alist:
if not a in dic_a:
dic_a[a] = 1
else:
dic_a[a] += 1
all_pair = 0
for val in list(dic_a.values()):
all_pair += val * (val - 1) // 2
# print(dic_a,all_pair)
for a in alist:
answer = all_pair - dic_a[a] + 1
print(answer)
| false | 32.142857 | [
"-dic_answer = {}",
"- if a in dic_answer:",
"- print((dic_answer[a]))",
"- continue",
"- now = dic_a[a]",
"- kill = now * (now - 1) // 2 - (now - 1) * (now - 2) // 2",
"- answer = all_pair - kill",
"+ answer = all_pair - dic_a[a] + 1",
"- dic_answer[a] = answer"
] | false | 0.117805 | 0.037682 | 3.126267 | [
"s220043573",
"s741548377"
] |
u007018214 | p02792 | python | s579050702 | s573289749 | 198 | 164 | 3,060 | 3,060 | Accepted | Accepted | 17.17 | n = int(eval(input()));l=[0 for _ in range(100)]
for i in range(1,n+1):
l[int(str(i)[0]+str(i)[-1])]+=1
print((sum([l[i*10+j]*l[j*10+i]for i in range(10) for j in range(10)]))) | l=[0 for _ in range(100)];r=list(range(10))
for i in range(1,int(eval(input()))+1):
s=str(i);l[int(s[0]+s[-1])]+=1
print((sum([l[i*10+j]*l[j*10+i]for i in r for j in r]))) | 4 | 4 | 175 | 164 | n = int(eval(input()))
l = [0 for _ in range(100)]
for i in range(1, n + 1):
l[int(str(i)[0] + str(i)[-1])] += 1
print((sum([l[i * 10 + j] * l[j * 10 + i] for i in range(10) for j in range(10)])))
| l = [0 for _ in range(100)]
r = list(range(10))
for i in range(1, int(eval(input())) + 1):
s = str(i)
l[int(s[0] + s[-1])] += 1
print((sum([l[i * 10 + j] * l[j * 10 + i] for i in r for j in r])))
| false | 0 | [
"-n = int(eval(input()))",
"-for i in range(1, n + 1):",
"- l[int(str(i)[0] + str(i)[-1])] += 1",
"-print((sum([l[i * 10 + j] * l[j * 10 + i] for i in range(10) for j in range(10)])))",
"+r = list(range(10))",
"+for i in range(1, int(eval(input())) + 1):",
"+ s = str(i)",
"+ l[int(s[0] + s[-1])] += 1",
"+print((sum([l[i * 10 + j] * l[j * 10 + i] for i in r for j in r])))"
] | false | 0.052764 | 0.064718 | 0.815286 | [
"s579050702",
"s573289749"
] |
u578953945 | p03212 | python | s089358259 | s252332832 | 78 | 66 | 3,064 | 3,060 | Accepted | Accepted | 15.38 | N=int(eval(input()))
ans = 0
def dfs(s, sum):
global ans
sum = sum + s
if int(sum) > N:
return False
sum = str(int(sum))
if sum.count("3") >= 1 and sum.count("5") >= 1 and sum.count("7") >= 1:
ans += 1
if dfs("3", sum):
return True
if dfs("5", sum):
return True
if dfs("7", sum):
return True
dfs("0" ,'')
print(ans)
| N=int(eval(input()))
ans = 0
def dfs(s, target):
global ans
target = target + s
if int(target) > N:
return False
if target.count("3") >= 1 and target.count("5") >= 1 and target.count("7") >= 1:
ans += 1
if dfs("3", target):
return True
if dfs("5", target):
return True
if dfs("7", target):
return True
dfs("0" ,'')
print(ans)
| 29 | 27 | 396 | 401 | N = int(eval(input()))
ans = 0
def dfs(s, sum):
global ans
sum = sum + s
if int(sum) > N:
return False
sum = str(int(sum))
if sum.count("3") >= 1 and sum.count("5") >= 1 and sum.count("7") >= 1:
ans += 1
if dfs("3", sum):
return True
if dfs("5", sum):
return True
if dfs("7", sum):
return True
dfs("0", "")
print(ans)
| N = int(eval(input()))
ans = 0
def dfs(s, target):
global ans
target = target + s
if int(target) > N:
return False
if target.count("3") >= 1 and target.count("5") >= 1 and target.count("7") >= 1:
ans += 1
if dfs("3", target):
return True
if dfs("5", target):
return True
if dfs("7", target):
return True
dfs("0", "")
print(ans)
| false | 6.896552 | [
"-def dfs(s, sum):",
"+def dfs(s, target):",
"- sum = sum + s",
"- if int(sum) > N:",
"+ target = target + s",
"+ if int(target) > N:",
"- sum = str(int(sum))",
"- if sum.count(\"3\") >= 1 and sum.count(\"5\") >= 1 and sum.count(\"7\") >= 1:",
"+ if target.count(\"3\") >= 1 and target.count(\"5\") >= 1 and target.count(\"7\") >= 1:",
"- if dfs(\"3\", sum):",
"+ if dfs(\"3\", target):",
"- if dfs(\"5\", sum):",
"+ if dfs(\"5\", target):",
"- if dfs(\"7\", sum):",
"+ if dfs(\"7\", target):"
] | false | 0.057921 | 0.046232 | 1.252851 | [
"s089358259",
"s252332832"
] |
u279546122 | p02361 | python | s584613971 | s653206052 | 3,130 | 2,200 | 123,348 | 102,404 | Accepted | Accepted | 29.71 | from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
def sp(G,R,V):
d = {}
q = [(0, R)]
heapify(q)
#seen = set()
while q:
(cost, v) = heappop(q)
if v not in d:
#seen.add(v)
d[v] = cost
for (next, c) in list(G[v].items()):
heappush(q, (cost + c, next))
return d
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin
.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if k not in d:
print("INF")
else:
print((d[k])) | from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
#import time
def sp(G,R,V):
d = {}
INF = float('inf')
for i in range(V):
d[i] = INF
q = [(0, R)]
d[R] = 0
heapify(q)
while q:
(cost, v) = heappop(q)
for (next, c) in list(G[v].items()):
if d[next] > d[v] + c:
d[next] = d[v] + c
heappush(q, (d[next], next))
return d
#start = time.clock()
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin
.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if d[k] == float('inf'):
print("INF")
else:
print((d[k]))
#print('Computation time : {}'.format(time.clock()-start)) | 29 | 36 | 705 | 875 | from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
def sp(G, R, V):
d = {}
q = [(0, R)]
heapify(q)
# seen = set()
while q:
(cost, v) = heappop(q)
if v not in d:
# seen.add(v)
d[v] = cost
for (next, c) in list(G[v].items()):
heappush(q, (cost + c, next))
return d
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if k not in d:
print("INF")
else:
print((d[k]))
| from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
# import time
def sp(G, R, V):
d = {}
INF = float("inf")
for i in range(V):
d[i] = INF
q = [(0, R)]
d[R] = 0
heapify(q)
while q:
(cost, v) = heappop(q)
for (next, c) in list(G[v].items()):
if d[next] > d[v] + c:
d[next] = d[v] + c
heappush(q, (d[next], next))
return d
# start = time.clock()
V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
s, t, w = [int(x) for x in stdin.readline().split()]
G[s][t] = w
d = sp(G, R, V)
for k in range(V):
if d[k] == float("inf"):
print("INF")
else:
print((d[k]))
# print('Computation time : {}'.format(time.clock()-start))
| false | 19.444444 | [
"-",
"+# import time",
"+ INF = float(\"inf\")",
"+ for i in range(V):",
"+ d[i] = INF",
"+ d[R] = 0",
"- # seen = set()",
"- if v not in d:",
"- # seen.add(v)",
"- d[v] = cost",
"- for (next, c) in list(G[v].items()):",
"- heappush(q, (cost + c, next))",
"+ for (next, c) in list(G[v].items()):",
"+ if d[next] > d[v] + c:",
"+ d[next] = d[v] + c",
"+ heappush(q, (d[next], next))",
"+# start = time.clock()",
"- if k not in d:",
"+ if d[k] == float(\"inf\"):",
"+# print('Computation time : {}'.format(time.clock()-start))"
] | false | 0.037064 | 0.104953 | 0.353147 | [
"s584613971",
"s653206052"
] |
u256678932 | p02398 | python | s716065979 | s118776583 | 30 | 20 | 8,284 | 5,596 | Accepted | Accepted | 33.33 | from operator import add
from functools import reduce
def divisor_generator(a, b, c):
for i in range(a, b+1):
yield (1 if c%i == 0 else 0)
a, b, c = list(map(int, input().split(' ')))
print((reduce(add, divisor_generator(a, b, c)))) | a, b, c = list(map(int, input().split()))
cnt = 0
for n in range(a, b+1):
if c % n == 0:
cnt += 1
print(cnt)
| 10 | 8 | 248 | 124 | from operator import add
from functools import reduce
def divisor_generator(a, b, c):
for i in range(a, b + 1):
yield (1 if c % i == 0 else 0)
a, b, c = list(map(int, input().split(" ")))
print((reduce(add, divisor_generator(a, b, c))))
| a, b, c = list(map(int, input().split()))
cnt = 0
for n in range(a, b + 1):
if c % n == 0:
cnt += 1
print(cnt)
| false | 20 | [
"-from operator import add",
"-from functools import reduce",
"-",
"-",
"-def divisor_generator(a, b, c):",
"- for i in range(a, b + 1):",
"- yield (1 if c % i == 0 else 0)",
"-",
"-",
"-a, b, c = list(map(int, input().split(\" \")))",
"-print((reduce(add, divisor_generator(a, b, c))))",
"+a, b, c = list(map(int, input().split()))",
"+cnt = 0",
"+for n in range(a, b + 1):",
"+ if c % n == 0:",
"+ cnt += 1",
"+print(cnt)"
] | false | 0.042241 | 0.042664 | 0.9901 | [
"s716065979",
"s118776583"
] |
u170650966 | p03456 | python | s669458564 | s059464330 | 34 | 17 | 2,940 | 3,060 | Accepted | Accepted | 50 | a,b = input().split()
t = int(a+b)
flag = False
for i in range(t//2 + 1):
if i**2 == t:
flag = True
break
if flag: print("Yes")
else: print("No")
| a,b = input().split()
t = int(a+b)
print(("Yes" if t == int(t**0.5)**2 else "No"))
| 9 | 3 | 174 | 83 | a, b = input().split()
t = int(a + b)
flag = False
for i in range(t // 2 + 1):
if i**2 == t:
flag = True
break
if flag:
print("Yes")
else:
print("No")
| a, b = input().split()
t = int(a + b)
print(("Yes" if t == int(t**0.5) ** 2 else "No"))
| false | 66.666667 | [
"-flag = False",
"-for i in range(t // 2 + 1):",
"- if i**2 == t:",
"- flag = True",
"- break",
"-if flag:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+print((\"Yes\" if t == int(t**0.5) ** 2 else \"No\"))"
] | false | 0.059461 | 0.039042 | 1.52301 | [
"s669458564",
"s059464330"
] |
u564902833 | p03295 | python | s116485300 | s721740101 | 588 | 500 | 58,084 | 58,088 | Accepted | Accepted | 14.97 | from functools import reduce
from operator import itemgetter
N, M = list(map(int, input().split()))
a, b = list(zip(*(list(map(int, input().split())) for _ in range(M))))
ts = sorted(zip(a, b), key=itemgetter(1))
ans = reduce(
lambda acc, t: acc if t[0] < acc[1] else (acc[0] + 1, t[1]),
ts,
(0, 0)
)[0]
print(ans)
| from functools import reduce
from operator import itemgetter
N, M = list(map(int, input().split()))
a, b = (
list(zip(*(list(map(int, input().split())) for _ in range(M)))) if M else
((), ())
)
# bについてソートし、橋を取り除く必要があれば可能な限り東の橋を取り除く
ans, _ = reduce(
lambda acc, q: (
(acc[0] + 1, q[1]) if q[0] >= acc[1] else
acc
),
sorted(zip(a, b), key=itemgetter(1)),
(0, 0)
)
print(ans)
| 12 | 20 | 321 | 417 | from functools import reduce
from operator import itemgetter
N, M = list(map(int, input().split()))
a, b = list(zip(*(list(map(int, input().split())) for _ in range(M))))
ts = sorted(zip(a, b), key=itemgetter(1))
ans = reduce(lambda acc, t: acc if t[0] < acc[1] else (acc[0] + 1, t[1]), ts, (0, 0))[0]
print(ans)
| from functools import reduce
from operator import itemgetter
N, M = list(map(int, input().split()))
a, b = (
list(zip(*(list(map(int, input().split())) for _ in range(M)))) if M else ((), ())
)
# bについてソートし、橋を取り除く必要があれば可能な限り東の橋を取り除く
ans, _ = reduce(
lambda acc, q: ((acc[0] + 1, q[1]) if q[0] >= acc[1] else acc),
sorted(zip(a, b), key=itemgetter(1)),
(0, 0),
)
print(ans)
| false | 40 | [
"-a, b = list(zip(*(list(map(int, input().split())) for _ in range(M))))",
"-ts = sorted(zip(a, b), key=itemgetter(1))",
"-ans = reduce(lambda acc, t: acc if t[0] < acc[1] else (acc[0] + 1, t[1]), ts, (0, 0))[0]",
"+a, b = (",
"+ list(zip(*(list(map(int, input().split())) for _ in range(M)))) if M else ((), ())",
"+)",
"+# bについてソートし、橋を取り除く必要があれば可能な限り東の橋を取り除く",
"+ans, _ = reduce(",
"+ lambda acc, q: ((acc[0] + 1, q[1]) if q[0] >= acc[1] else acc),",
"+ sorted(zip(a, b), key=itemgetter(1)),",
"+ (0, 0),",
"+)"
] | false | 0.043765 | 0.043704 | 1.001397 | [
"s116485300",
"s721740101"
] |
u352394527 | p00474 | python | s983404211 | s657091044 | 280 | 250 | 5,620 | 5,620 | Accepted | Accepted | 10.71 | def solve():
n, l = list(map(int,input().split()))
ans = 0
pre = 0
up_acc = 0
down_acc = 0
for i in range(n):
length = int(eval(input()))
time = l - length
if length > pre:
up_acc += time
if down_acc > ans:
ans = down_acc
down_acc = time
else:
down_acc += time
if up_acc > ans:
ans = up_acc
up_acc = time
pre = length
else:
ans = max(ans, up_acc, down_acc)
print(ans)
solve()
| def solve():
n, l = list(map(int,input().split()))
ans = 0
pre = 0
prepre = 0
acc = 0
for i in range(n):
length = int(eval(input()))
time = l - length
if length > pre and pre >= prepre:
acc += time
elif length < pre and pre <= prepre:
acc += time
else:
if ans < acc:
ans = acc
acc = time + (l - pre)
prepre = pre
pre = length
else:
ans = max(ans, acc)
print(ans)
solve()
| 24 | 23 | 479 | 461 | def solve():
n, l = list(map(int, input().split()))
ans = 0
pre = 0
up_acc = 0
down_acc = 0
for i in range(n):
length = int(eval(input()))
time = l - length
if length > pre:
up_acc += time
if down_acc > ans:
ans = down_acc
down_acc = time
else:
down_acc += time
if up_acc > ans:
ans = up_acc
up_acc = time
pre = length
else:
ans = max(ans, up_acc, down_acc)
print(ans)
solve()
| def solve():
n, l = list(map(int, input().split()))
ans = 0
pre = 0
prepre = 0
acc = 0
for i in range(n):
length = int(eval(input()))
time = l - length
if length > pre and pre >= prepre:
acc += time
elif length < pre and pre <= prepre:
acc += time
else:
if ans < acc:
ans = acc
acc = time + (l - pre)
prepre = pre
pre = length
else:
ans = max(ans, acc)
print(ans)
solve()
| false | 4.166667 | [
"- up_acc = 0",
"- down_acc = 0",
"+ prepre = 0",
"+ acc = 0",
"- if length > pre:",
"- up_acc += time",
"- if down_acc > ans:",
"- ans = down_acc",
"- down_acc = time",
"+ if length > pre and pre >= prepre:",
"+ acc += time",
"+ elif length < pre and pre <= prepre:",
"+ acc += time",
"- down_acc += time",
"- if up_acc > ans:",
"- ans = up_acc",
"- up_acc = time",
"+ if ans < acc:",
"+ ans = acc",
"+ acc = time + (l - pre)",
"+ prepre = pre",
"- ans = max(ans, up_acc, down_acc)",
"+ ans = max(ans, acc)"
] | false | 0.044294 | 0.043529 | 1.017578 | [
"s983404211",
"s657091044"
] |
u478266845 | p03220 | python | s158862701 | s621870399 | 154 | 29 | 14,476 | 9,208 | Accepted | Accepted | 81.17 | import numpy as np
N = int(eval(input()))
T, A = [int(i) for i in input().split()]
H = np.array([int(i) for i in input().split()])
temp = T - 0.006*H
temp_def = temp-A
temp_target = min(abs(temp_def))
ans = int(np.where(abs(temp_def) == temp_target)[0]) +1
print(ans) | n = int(eval(input()))
t,a = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
cand = float('inf')
ans = 1
for i in range(n):
temp = abs(a - (t - 0.006*h[i]))
if cand > temp:
cand = temp
ans = i+1
print(ans) | 18 | 15 | 287 | 274 | import numpy as np
N = int(eval(input()))
T, A = [int(i) for i in input().split()]
H = np.array([int(i) for i in input().split()])
temp = T - 0.006 * H
temp_def = temp - A
temp_target = min(abs(temp_def))
ans = int(np.where(abs(temp_def) == temp_target)[0]) + 1
print(ans)
| n = int(eval(input()))
t, a = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
cand = float("inf")
ans = 1
for i in range(n):
temp = abs(a - (t - 0.006 * h[i]))
if cand > temp:
cand = temp
ans = i + 1
print(ans)
| false | 16.666667 | [
"-import numpy as np",
"-",
"-N = int(eval(input()))",
"-T, A = [int(i) for i in input().split()]",
"-H = np.array([int(i) for i in input().split()])",
"-temp = T - 0.006 * H",
"-temp_def = temp - A",
"-temp_target = min(abs(temp_def))",
"-ans = int(np.where(abs(temp_def) == temp_target)[0]) + 1",
"+n = int(eval(input()))",
"+t, a = [int(i) for i in input().split()]",
"+h = [int(i) for i in input().split()]",
"+cand = float(\"inf\")",
"+ans = 1",
"+for i in range(n):",
"+ temp = abs(a - (t - 0.006 * h[i]))",
"+ if cand > temp:",
"+ cand = temp",
"+ ans = i + 1"
] | false | 0.231622 | 0.046402 | 4.991666 | [
"s158862701",
"s621870399"
] |
u236823931 | p02754 | python | s395689735 | s096793848 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | if __name__ == '__main__':
(n, a, b) = list(map(int, input().split()))
ans = (n//(a+b)) * a
m = min(n%(a+b), a)
print((ans+m)) | if __name__ == '__main__':
(n, a, b) = tuple(map(int, input().split()))
ans = n // (a + b) * a
ans += min(n % (a + b), a)
print(ans) | 5 | 5 | 138 | 152 | if __name__ == "__main__":
(n, a, b) = list(map(int, input().split()))
ans = (n // (a + b)) * a
m = min(n % (a + b), a)
print((ans + m))
| if __name__ == "__main__":
(n, a, b) = tuple(map(int, input().split()))
ans = n // (a + b) * a
ans += min(n % (a + b), a)
print(ans)
| false | 0 | [
"- (n, a, b) = list(map(int, input().split()))",
"- ans = (n // (a + b)) * a",
"- m = min(n % (a + b), a)",
"- print((ans + m))",
"+ (n, a, b) = tuple(map(int, input().split()))",
"+ ans = n // (a + b) * a",
"+ ans += min(n % (a + b), a)",
"+ print(ans)"
] | false | 0.090368 | 0.045014 | 2.007535 | [
"s395689735",
"s096793848"
] |
u091051505 | p03125 | python | s886138550 | s442443746 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | a, b = list(map(int, input().split()))
if ((b%a) == 0):
print((a + b))
else:
print((b - a)) | a, b = list(map(int, input().split()))
if b % a == 0:
print((a+b))
else:
print((b-a)) | 5 | 5 | 93 | 87 | a, b = list(map(int, input().split()))
if (b % a) == 0:
print((a + b))
else:
print((b - a))
| a, b = list(map(int, input().split()))
if b % a == 0:
print((a + b))
else:
print((b - a))
| false | 0 | [
"-if (b % a) == 0:",
"+if b % a == 0:"
] | false | 0.04142 | 0.042241 | 0.98055 | [
"s886138550",
"s442443746"
] |
u729133443 | p03463 | python | s893445233 | s806089950 | 170 | 17 | 38,256 | 3,064 | Accepted | Accepted | 90 | print(('ABloircyes'[eval(input()[2:].replace(' ','-'))%2::2])) | print(('ABloircyes'[sum(map(int,input().split()[1:]))%2::2])) | 1 | 1 | 60 | 59 | print(("ABloircyes"[eval(input()[2:].replace(" ", "-")) % 2 :: 2]))
| print(("ABloircyes"[sum(map(int, input().split()[1:])) % 2 :: 2]))
| false | 0 | [
"-print((\"ABloircyes\"[eval(input()[2:].replace(\" \", \"-\")) % 2 :: 2]))",
"+print((\"ABloircyes\"[sum(map(int, input().split()[1:])) % 2 :: 2]))"
] | false | 0.162791 | 0.043608 | 3.733021 | [
"s893445233",
"s806089950"
] |
u644907318 | p03108 | python | s228163349 | s138824971 | 1,080 | 426 | 109,396 | 124,092 | Accepted | Accepted | 60.56 | def find(x):
if x != T[x][0]:
while x!=T[x][0]:
x = T[x][0]
return x
def union(x,y):
rt0 = find(x)
rt1 = find(y)
if T[rt0][1]>T[rt1][1]:
T[rt1][0] = rt0
elif T[rt0][1]==T[rt1][1]:
T[rt1][0] = rt0
T[rt0][1] += 1
else:
T[rt0][0] = rt1
N,M = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(M)]
T = {i:[i,0] for i in range(1,N+1)}
C = {i:1 for i in range(1,N+1)}
cnt = 0
a = (N*(N-1))//2
B = []
for j in range(M-1,-1,-1):
B.append(a-cnt)
x,y = A[j]
if find(x)!=find(y):
k1 = C[find(x)]
k2 = C[find(y)]
cnt = cnt-((k1*(k1-1))//2+(k2*(k2-1))//2)
union(x,y)
k3 = k1+k2
C[find(x)] = k3
cnt += (k3*(k3-1))//2
for j in range(M-1,-1,-1):
print((B[j])) | def find(x):
while x!=T[x][0]:
x = T[x][0]
return x
def union(x,y):
rt1 = find(x)
rt2 = find(y)
if T[rt1][1]>=T[rt2][1]:
T[rt2][0] = rt1
T[rt1][1] += T[rt2][1]
else:
T[rt1][0] = rt2
T[rt2][1] += T[rt1][1]
N,M = list(map(int,input().split()))
E = [list(map(int,input().split())) for _ in range(M)]
T = {i:[i,1] for i in range(1,N+1)}
RT = {i:1 for i in range(1,N+1)}
cnt = 0
ans = (N*(N-1))//2
A = []
A.append(ans)
for i in range(M-1,-1,-1):
a,b = E[i]
rt1 = find(a)
rt2 = find(b)
if rt1==rt2:
A.append(ans)
else:
x = T[rt1][1]
y = T[rt2][1]
ans += (x*(x-1))//2+(y*(y-1))//2
union(a,b)
rt = find(a)
z = T[rt][1]
ans -= (z*(z-1))//2
A.append(ans)
A = A[::-1]
for i in range(1,M+1):
print((A[i])) | 36 | 39 | 854 | 883 | def find(x):
if x != T[x][0]:
while x != T[x][0]:
x = T[x][0]
return x
def union(x, y):
rt0 = find(x)
rt1 = find(y)
if T[rt0][1] > T[rt1][1]:
T[rt1][0] = rt0
elif T[rt0][1] == T[rt1][1]:
T[rt1][0] = rt0
T[rt0][1] += 1
else:
T[rt0][0] = rt1
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(M)]
T = {i: [i, 0] for i in range(1, N + 1)}
C = {i: 1 for i in range(1, N + 1)}
cnt = 0
a = (N * (N - 1)) // 2
B = []
for j in range(M - 1, -1, -1):
B.append(a - cnt)
x, y = A[j]
if find(x) != find(y):
k1 = C[find(x)]
k2 = C[find(y)]
cnt = cnt - ((k1 * (k1 - 1)) // 2 + (k2 * (k2 - 1)) // 2)
union(x, y)
k3 = k1 + k2
C[find(x)] = k3
cnt += (k3 * (k3 - 1)) // 2
for j in range(M - 1, -1, -1):
print((B[j]))
| def find(x):
while x != T[x][0]:
x = T[x][0]
return x
def union(x, y):
rt1 = find(x)
rt2 = find(y)
if T[rt1][1] >= T[rt2][1]:
T[rt2][0] = rt1
T[rt1][1] += T[rt2][1]
else:
T[rt1][0] = rt2
T[rt2][1] += T[rt1][1]
N, M = list(map(int, input().split()))
E = [list(map(int, input().split())) for _ in range(M)]
T = {i: [i, 1] for i in range(1, N + 1)}
RT = {i: 1 for i in range(1, N + 1)}
cnt = 0
ans = (N * (N - 1)) // 2
A = []
A.append(ans)
for i in range(M - 1, -1, -1):
a, b = E[i]
rt1 = find(a)
rt2 = find(b)
if rt1 == rt2:
A.append(ans)
else:
x = T[rt1][1]
y = T[rt2][1]
ans += (x * (x - 1)) // 2 + (y * (y - 1)) // 2
union(a, b)
rt = find(a)
z = T[rt][1]
ans -= (z * (z - 1)) // 2
A.append(ans)
A = A[::-1]
for i in range(1, M + 1):
print((A[i]))
| false | 7.692308 | [
"- if x != T[x][0]:",
"- while x != T[x][0]:",
"- x = T[x][0]",
"+ while x != T[x][0]:",
"+ x = T[x][0]",
"- rt0 = find(x)",
"- rt1 = find(y)",
"- if T[rt0][1] > T[rt1][1]:",
"- T[rt1][0] = rt0",
"- elif T[rt0][1] == T[rt1][1]:",
"- T[rt1][0] = rt0",
"- T[rt0][1] += 1",
"+ rt1 = find(x)",
"+ rt2 = find(y)",
"+ if T[rt1][1] >= T[rt2][1]:",
"+ T[rt2][0] = rt1",
"+ T[rt1][1] += T[rt2][1]",
"- T[rt0][0] = rt1",
"+ T[rt1][0] = rt2",
"+ T[rt2][1] += T[rt1][1]",
"-A = [list(map(int, input().split())) for _ in range(M)]",
"-T = {i: [i, 0] for i in range(1, N + 1)}",
"-C = {i: 1 for i in range(1, N + 1)}",
"+E = [list(map(int, input().split())) for _ in range(M)]",
"+T = {i: [i, 1] for i in range(1, N + 1)}",
"+RT = {i: 1 for i in range(1, N + 1)}",
"-a = (N * (N - 1)) // 2",
"-B = []",
"-for j in range(M - 1, -1, -1):",
"- B.append(a - cnt)",
"- x, y = A[j]",
"- if find(x) != find(y):",
"- k1 = C[find(x)]",
"- k2 = C[find(y)]",
"- cnt = cnt - ((k1 * (k1 - 1)) // 2 + (k2 * (k2 - 1)) // 2)",
"- union(x, y)",
"- k3 = k1 + k2",
"- C[find(x)] = k3",
"- cnt += (k3 * (k3 - 1)) // 2",
"-for j in range(M - 1, -1, -1):",
"- print((B[j]))",
"+ans = (N * (N - 1)) // 2",
"+A = []",
"+A.append(ans)",
"+for i in range(M - 1, -1, -1):",
"+ a, b = E[i]",
"+ rt1 = find(a)",
"+ rt2 = find(b)",
"+ if rt1 == rt2:",
"+ A.append(ans)",
"+ else:",
"+ x = T[rt1][1]",
"+ y = T[rt2][1]",
"+ ans += (x * (x - 1)) // 2 + (y * (y - 1)) // 2",
"+ union(a, b)",
"+ rt = find(a)",
"+ z = T[rt][1]",
"+ ans -= (z * (z - 1)) // 2",
"+ A.append(ans)",
"+A = A[::-1]",
"+for i in range(1, M + 1):",
"+ print((A[i]))"
] | false | 0.037747 | 0.038383 | 0.983431 | [
"s228163349",
"s138824971"
] |
u102461423 | p03641 | python | s152153996 | s342318240 | 1,671 | 1,214 | 108,752 | 108,108 | Accepted | Accepted | 27.35 | import sys
input = sys.stdin.readline
import numpy as np
from heapq import heappush, heappop
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int32)
a_to_i = {a:i for i,a in enumerate(A)}
# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく
U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
L = 1 << (i-1)
sp.append(np.minimum(sp[-1][:-L], sp[-1][L:]))
def RMQ(x,y):
# x番目から偶数番目だけ見て[x,y]での最小値を返す
d = y - x
if d <= 1:
return A[x]
n = d.bit_length()
return min(sp[n-1][x], sp[n-1][y+2-(1<<(n-1))])
def F(x,y):
# 辞書式で最小の2つ組をとる
# そのあと、今後調べないといけない区間の一覧を返す
x1 = RMQ(x,y-1)
i1 = a_to_i[x1]
x2 = RMQ(i1+1,y)
i2 = a_to_i[x2]
task = ((x,y) for x,y in ((x,i1-1), (i1+1,i2-1), (i2+1,y)) if y > x)
return x1,x2,task
q = [(None,None,((0,N-1),))]
answer = []
while q:
x,y,task = heappop(q)
answer.append(x)
answer.append(y)
for left,right in task:
heappush(q,F(left,right))
print((' '.join(map(str,answer[2:])))) | import sys
input = sys.stdin.readline
from heapq import heappush, heappop
N = int(eval(input()))
A = [int(x) for x in input().split()]
a_to_i = {a:i for i,a in enumerate(A)}
# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく
U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
L = 1 << (i-1)
sp.append([x if x < y else y for x,y in zip(sp[-1][:-L], sp[-1][L:])])
def RMQ(x,y):
# x番目から偶数番目だけ見て[x,y]での最小値を返す
d = y - x
if d <= 1:
return A[x]
n = d.bit_length()
return min(sp[n-1][x], sp[n-1][y+2-(1<<(n-1))])
def F(x,y):
# 辞書式で最小の2つ組をとる
# そのあと、今後調べないといけない区間の一覧を返す
x1 = RMQ(x,y-1)
i1 = a_to_i[x1]
x2 = RMQ(i1+1,y)
i2 = a_to_i[x2]
task = ((x,y) for x,y in ((x,i1-1), (i1+1,i2-1), (i2+1,y)) if y > x)
return x1,x2,task
q = [(None,None,((0,N-1),))]
answer = []
while q:
x,y,task = heappop(q)
answer.append(x)
answer.append(y)
for left,right in task:
heappush(q,F(left,right))
print((' '.join(map(str,answer[2:])))) | 46 | 45 | 1,052 | 1,048 | import sys
input = sys.stdin.readline
import numpy as np
from heapq import heappush, heappop
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int32)
a_to_i = {a: i for i, a in enumerate(A)}
# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく
U = len(A).bit_length()
sp = [None, A]
for i in range(2, U):
L = 1 << (i - 1)
sp.append(np.minimum(sp[-1][:-L], sp[-1][L:]))
def RMQ(x, y):
# x番目から偶数番目だけ見て[x,y]での最小値を返す
d = y - x
if d <= 1:
return A[x]
n = d.bit_length()
return min(sp[n - 1][x], sp[n - 1][y + 2 - (1 << (n - 1))])
def F(x, y):
# 辞書式で最小の2つ組をとる
# そのあと、今後調べないといけない区間の一覧を返す
x1 = RMQ(x, y - 1)
i1 = a_to_i[x1]
x2 = RMQ(i1 + 1, y)
i2 = a_to_i[x2]
task = ((x, y) for x, y in ((x, i1 - 1), (i1 + 1, i2 - 1), (i2 + 1, y)) if y > x)
return x1, x2, task
q = [(None, None, ((0, N - 1),))]
answer = []
while q:
x, y, task = heappop(q)
answer.append(x)
answer.append(y)
for left, right in task:
heappush(q, F(left, right))
print((" ".join(map(str, answer[2:]))))
| import sys
input = sys.stdin.readline
from heapq import heappush, heappop
N = int(eval(input()))
A = [int(x) for x in input().split()]
a_to_i = {a: i for i, a in enumerate(A)}
# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく
U = len(A).bit_length()
sp = [None, A]
for i in range(2, U):
L = 1 << (i - 1)
sp.append([x if x < y else y for x, y in zip(sp[-1][:-L], sp[-1][L:])])
def RMQ(x, y):
# x番目から偶数番目だけ見て[x,y]での最小値を返す
d = y - x
if d <= 1:
return A[x]
n = d.bit_length()
return min(sp[n - 1][x], sp[n - 1][y + 2 - (1 << (n - 1))])
def F(x, y):
# 辞書式で最小の2つ組をとる
# そのあと、今後調べないといけない区間の一覧を返す
x1 = RMQ(x, y - 1)
i1 = a_to_i[x1]
x2 = RMQ(i1 + 1, y)
i2 = a_to_i[x2]
task = ((x, y) for x, y in ((x, i1 - 1), (i1 + 1, i2 - 1), (i2 + 1, y)) if y > x)
return x1, x2, task
q = [(None, None, ((0, N - 1),))]
answer = []
while q:
x, y, task = heappop(q)
answer.append(x)
answer.append(y)
for left, right in task:
heappush(q, F(left, right))
print((" ".join(map(str, answer[2:]))))
| false | 2.173913 | [
"-import numpy as np",
"-A = np.array(input().split(), dtype=np.int32)",
"+A = [int(x) for x in input().split()]",
"- sp.append(np.minimum(sp[-1][:-L], sp[-1][L:]))",
"+ sp.append([x if x < y else y for x, y in zip(sp[-1][:-L], sp[-1][L:])])"
] | false | 0.177049 | 0.041069 | 4.311047 | [
"s152153996",
"s342318240"
] |
u752802582 | p02613 | python | s589614470 | s301061323 | 183 | 164 | 83,160 | 74,904 | Accepted | Accepted | 10.38 | from collections import Counter
n = int(eval(input()))
verdict = list()
while n:
n -= 1
verdict.append(eval(input()))
dictOBJ = dict()
dictOBJ = { 'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0}
for elm in verdict:
dictOBJ[elm] += 1
print(('AC x', dictOBJ['AC']))
print(('WA x', dictOBJ['WA']))
print(('TLE x', dictOBJ['TLE']))
print(('RE x',dictOBJ['RE']))
| """
atcoder : 173B
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""
ans = {
"AC": 0,
"WA": 0,
"TLE": 0,
"RE":0
}
n = int(eval(input()))
for _ in range(n):
ans[eval(input())] += 1
print(f"AC x {ans['AC']}")
print(f"WA x {ans['WA']}")
print(f"TLE x {ans['TLE']}")
print(f"RE x {ans['RE']}") | 17 | 21 | 362 | 329 | from collections import Counter
n = int(eval(input()))
verdict = list()
while n:
n -= 1
verdict.append(eval(input()))
dictOBJ = dict()
dictOBJ = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for elm in verdict:
dictOBJ[elm] += 1
print(("AC x", dictOBJ["AC"]))
print(("WA x", dictOBJ["WA"]))
print(("TLE x", dictOBJ["TLE"]))
print(("RE x", dictOBJ["RE"]))
| """
atcoder : 173B
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
n = int(eval(input()))
for _ in range(n):
ans[eval(input())] += 1
print(f"AC x {ans['AC']}")
print(f"WA x {ans['WA']}")
print(f"TLE x {ans['TLE']}")
print(f"RE x {ans['RE']}")
| false | 19.047619 | [
"-from collections import Counter",
"-",
"+\"\"\"",
"+atcoder : 173B",
"+auther : Jay Saha",
"+handel : ponder2000",
"+date : 15/07/2020",
"+\"\"\"",
"+ans = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\": 0}",
"-verdict = list()",
"-while n:",
"- n -= 1",
"- verdict.append(eval(input()))",
"-dictOBJ = dict()",
"-dictOBJ = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\": 0}",
"-for elm in verdict:",
"- dictOBJ[elm] += 1",
"-print((\"AC x\", dictOBJ[\"AC\"]))",
"-print((\"WA x\", dictOBJ[\"WA\"]))",
"-print((\"TLE x\", dictOBJ[\"TLE\"]))",
"-print((\"RE x\", dictOBJ[\"RE\"]))",
"+for _ in range(n):",
"+ ans[eval(input())] += 1",
"+print(f\"AC x {ans['AC']}\")",
"+print(f\"WA x {ans['WA']}\")",
"+print(f\"TLE x {ans['TLE']}\")",
"+print(f\"RE x {ans['RE']}\")"
] | false | 0.085598 | 0.050975 | 1.679222 | [
"s589614470",
"s301061323"
] |
u347600233 | p02717 | python | s036637569 | s835014637 | 30 | 27 | 9,120 | 9,004 | Accepted | Accepted | 10 | x, y, z = list(map(int, input().split()))
x, y = y, x
x, z = z, x
print((x, y, z)) | x, y, z = list(map(int, input().split()))
print((z, x, y)) | 4 | 2 | 77 | 51 | x, y, z = list(map(int, input().split()))
x, y = y, x
x, z = z, x
print((x, y, z))
| x, y, z = list(map(int, input().split()))
print((z, x, y))
| false | 50 | [
"-x, y = y, x",
"-x, z = z, x",
"-print((x, y, z))",
"+print((z, x, y))"
] | false | 0.03733 | 0.040996 | 0.910578 | [
"s036637569",
"s835014637"
] |
u191874006 | p02844 | python | s608384799 | s303933048 | 1,246 | 403 | 46,044 | 42,588 | Accepted | Accepted | 67.66 | #!/usr/bin/env python3
#三井住友信託銀行プログラミングコンテスト2019 D
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def C(n,r):
return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
n = I()
s = eval(input())
t = list(map(int,list(s)))
ans = 0
for i in range(10):
for j in range(n):
if i == t[j]:
tmp = j
break
else:
continue
for j in range(100):
if len(str(j)) == 2:
x,y = list(str(j))
else:
x,y = '0',str(j)
flg = False
for k in range(tmp+1,n):
if flg and y == str(t[k]):
ans += 1
break
if x == str(t[k]):
flg = True
print(ans) | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
n = I()
s = eval(input())
ans = 0
for l in range(10):
for i in range(n):
if int(s[i]) == l:
break
else:
continue
for r in range(10):
for j in range(i+1,n):
if int(s[j]) == r:
break
else:
continue
num = [True]*10
for k in range(j+1,n):
if num[int(s[k])]:
ans += 1
num[int(s[k])] = False
print(ans) | 47 | 40 | 1,214 | 1,026 | #!/usr/bin/env python3
# 三井住友信託銀行プログラミングコンテスト2019 D
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float("inf")
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def C(n, r):
return math.factorial(n) // math.factorial(n - r) // math.factorial(r)
n = I()
s = eval(input())
t = list(map(int, list(s)))
ans = 0
for i in range(10):
for j in range(n):
if i == t[j]:
tmp = j
break
else:
continue
for j in range(100):
if len(str(j)) == 2:
x, y = list(str(j))
else:
x, y = "0", str(j)
flg = False
for k in range(tmp + 1, n):
if flg and y == str(t[k]):
ans += 1
break
if x == str(t[k]):
flg = True
print(ans)
| #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float("inf")
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
n = I()
s = eval(input())
ans = 0
for l in range(10):
for i in range(n):
if int(s[i]) == l:
break
else:
continue
for r in range(10):
for j in range(i + 1, n):
if int(s[j]) == r:
break
else:
continue
num = [True] * 10
for k in range(j + 1, n):
if num[int(s[k])]:
ans += 1
num[int(s[k])] = False
print(ans)
| false | 14.893617 | [
"-# 三井住友信託銀行プログラミングコンテスト2019 D",
"-sys.setrecursionlimit(1000000)",
"+sys.setrecursionlimit(2147483647)",
"-def C(n, r):",
"- return math.factorial(n) // math.factorial(n - r) // math.factorial(r)",
"-",
"-",
"-t = list(map(int, list(s)))",
"-for i in range(10):",
"- for j in range(n):",
"- if i == t[j]:",
"- tmp = j",
"+for l in range(10):",
"+ for i in range(n):",
"+ if int(s[i]) == l:",
"- for j in range(100):",
"- if len(str(j)) == 2:",
"- x, y = list(str(j))",
"+ for r in range(10):",
"+ for j in range(i + 1, n):",
"+ if int(s[j]) == r:",
"+ break",
"- x, y = \"0\", str(j)",
"- flg = False",
"- for k in range(tmp + 1, n):",
"- if flg and y == str(t[k]):",
"+ continue",
"+ num = [True] * 10",
"+ for k in range(j + 1, n):",
"+ if num[int(s[k])]:",
"- break",
"- if x == str(t[k]):",
"- flg = True",
"+ num[int(s[k])] = False"
] | false | 0.172303 | 0.037588 | 4.584033 | [
"s608384799",
"s303933048"
] |
u729939940 | p02577 | python | s937761035 | s603659052 | 217 | 37 | 9,312 | 9,256 | Accepted | Accepted | 82.95 | N=int(eval(input()))
if N%9==0:
print('Yes')
else:
print('No') | N = eval(input())
cnt = 0
for i in range(10):
cnt += i * N.count(str(i))
print(("Yes" if cnt % 9 == 0 else "No")) | 5 | 5 | 64 | 111 | N = int(eval(input()))
if N % 9 == 0:
print("Yes")
else:
print("No")
| N = eval(input())
cnt = 0
for i in range(10):
cnt += i * N.count(str(i))
print(("Yes" if cnt % 9 == 0 else "No"))
| false | 0 | [
"-N = int(eval(input()))",
"-if N % 9 == 0:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+N = eval(input())",
"+cnt = 0",
"+for i in range(10):",
"+ cnt += i * N.count(str(i))",
"+print((\"Yes\" if cnt % 9 == 0 else \"No\"))"
] | false | 0.043333 | 0.037623 | 1.151762 | [
"s937761035",
"s603659052"
] |
u644907318 | p02754 | python | s953231436 | s354504829 | 174 | 73 | 38,748 | 61,876 | Accepted | Accepted | 58.05 | N,A,B = list(map(int,input().split()))
n = N//(A+B)
m = N%(A+B)
k = min(m,A)
print((n*A+k)) | N,A,B = list(map(int,input().split()))
a = N//(A+B)
b = N%(A+B)
if b>A:
print((a*A+A))
else:
print((a*A+b)) | 5 | 7 | 87 | 111 | N, A, B = list(map(int, input().split()))
n = N // (A + B)
m = N % (A + B)
k = min(m, A)
print((n * A + k))
| N, A, B = list(map(int, input().split()))
a = N // (A + B)
b = N % (A + B)
if b > A:
print((a * A + A))
else:
print((a * A + b))
| false | 28.571429 | [
"-n = N // (A + B)",
"-m = N % (A + B)",
"-k = min(m, A)",
"-print((n * A + k))",
"+a = N // (A + B)",
"+b = N % (A + B)",
"+if b > A:",
"+ print((a * A + A))",
"+else:",
"+ print((a * A + b))"
] | false | 0.036042 | 0.035764 | 1.007771 | [
"s953231436",
"s354504829"
] |
u888092736 | p02756 | python | s593392321 | s958232528 | 1,851 | 231 | 9,828 | 8,676 | Accepted | Accepted | 87.52 | from collections import deque
import sys
input = lambda: sys.stdin.readline().rstrip()
s = deque(list(eval(input())))
q = int(eval(input()))
rev_cnt = 0
for i in range(q):
query = input().split()
if query[0] == '2':
if (query[1] == '1' and rev_cnt % 2 == 0) or ((query[1] == '2' and rev_cnt % 2 == 1)):
s.appendleft(query[2])
else:
s.append(query[2])
else:
rev_cnt += 1
if rev_cnt % 2 == 1:
print((''.join([s[len(s) - i - 1] for i in range(len(s))])))
else:
print((''.join([c for c in s])))
| from collections import deque
import sys
input = lambda: sys.stdin.readline().rstrip()
s = deque(list(eval(input())))
q = int(eval(input()))
is_reverse = False
for i in range(q):
query = input().split()
if query[0] == '2':
if (query[1] == '1' and not is_reverse) or (query[1] == '2' and is_reverse):
s.appendleft(query[2])
else:
s.append(query[2])
else:
is_reverse = not is_reverse
result = ''.join(s)
if is_reverse:
print((result[::-1]))
else:
print(result)
| 23 | 24 | 569 | 540 | from collections import deque
import sys
input = lambda: sys.stdin.readline().rstrip()
s = deque(list(eval(input())))
q = int(eval(input()))
rev_cnt = 0
for i in range(q):
query = input().split()
if query[0] == "2":
if (query[1] == "1" and rev_cnt % 2 == 0) or (
(query[1] == "2" and rev_cnt % 2 == 1)
):
s.appendleft(query[2])
else:
s.append(query[2])
else:
rev_cnt += 1
if rev_cnt % 2 == 1:
print(("".join([s[len(s) - i - 1] for i in range(len(s))])))
else:
print(("".join([c for c in s])))
| from collections import deque
import sys
input = lambda: sys.stdin.readline().rstrip()
s = deque(list(eval(input())))
q = int(eval(input()))
is_reverse = False
for i in range(q):
query = input().split()
if query[0] == "2":
if (query[1] == "1" and not is_reverse) or (query[1] == "2" and is_reverse):
s.appendleft(query[2])
else:
s.append(query[2])
else:
is_reverse = not is_reverse
result = "".join(s)
if is_reverse:
print((result[::-1]))
else:
print(result)
| false | 4.166667 | [
"-rev_cnt = 0",
"+is_reverse = False",
"- if (query[1] == \"1\" and rev_cnt % 2 == 0) or (",
"- (query[1] == \"2\" and rev_cnt % 2 == 1)",
"- ):",
"+ if (query[1] == \"1\" and not is_reverse) or (query[1] == \"2\" and is_reverse):",
"- rev_cnt += 1",
"-if rev_cnt % 2 == 1:",
"- print((\"\".join([s[len(s) - i - 1] for i in range(len(s))])))",
"+ is_reverse = not is_reverse",
"+result = \"\".join(s)",
"+if is_reverse:",
"+ print((result[::-1]))",
"- print((\"\".join([c for c in s])))",
"+ print(result)"
] | false | 0.044171 | 0.045156 | 0.978194 | [
"s593392321",
"s958232528"
] |
u759412327 | p03556 | python | s039595564 | s854228297 | 61 | 18 | 2,940 | 3,060 | Accepted | Accepted | 70.49 | import math
a = int(eval(input()))
for i in range(a):
if a-i==math.floor(math.sqrt(a-i))**2:
print((a-i))
break | N = int(eval(input()))
print((int(N**.5)**2))
| 7 | 2 | 120 | 39 | import math
a = int(eval(input()))
for i in range(a):
if a - i == math.floor(math.sqrt(a - i)) ** 2:
print((a - i))
break
| N = int(eval(input()))
print((int(N**0.5) ** 2))
| false | 71.428571 | [
"-import math",
"-",
"-a = int(eval(input()))",
"-for i in range(a):",
"- if a - i == math.floor(math.sqrt(a - i)) ** 2:",
"- print((a - i))",
"- break",
"+N = int(eval(input()))",
"+print((int(N**0.5) ** 2))"
] | false | 0.041179 | 0.03641 | 1.130978 | [
"s039595564",
"s854228297"
] |
u089830331 | p02241 | python | s200573586 | s496292938 | 510 | 30 | 8,016 | 7,908 | Accepted | Accepted | 94.12 | def solv(G):
new_V = [0]
new_E = []
while len(new_V) < len(G):
u, e = select_min(G, new_V)
new_V.append(u)
new_E.append(e)
return sum(new_E)
def select_min(G, V):
min_u = -1
min_e = float('inf')
for v in V:
for u, e in enumerate(G[v]):
if (e < 0) or (u in V): continue
if e < min_e:
min_u = u
min_e = e
return min_u, min_e
n = int(eval(input()))
G = [list(map(int, input().split())) for _ in range(n)]
print((solv(G))) | def solv(G):
n = len(G)
V = {0:0}
new_V = []
cost = 0
while len(new_V) < n:
u, e = min(list(V.items()), key=lambda x:x[1])
V.pop(u)
new_V.append(u)
cost += e
for v, e in enumerate(G[u]):
if e < 0 or v == u or v in new_V: continue
V[v] = min(V[v], e) if v in V else e
return cost
n = int(eval(input()))
G = [list(map(int, input().split())) for _ in range(n)]
print((solv(G))) | 25 | 20 | 498 | 426 | def solv(G):
new_V = [0]
new_E = []
while len(new_V) < len(G):
u, e = select_min(G, new_V)
new_V.append(u)
new_E.append(e)
return sum(new_E)
def select_min(G, V):
min_u = -1
min_e = float("inf")
for v in V:
for u, e in enumerate(G[v]):
if (e < 0) or (u in V):
continue
if e < min_e:
min_u = u
min_e = e
return min_u, min_e
n = int(eval(input()))
G = [list(map(int, input().split())) for _ in range(n)]
print((solv(G)))
| def solv(G):
n = len(G)
V = {0: 0}
new_V = []
cost = 0
while len(new_V) < n:
u, e = min(list(V.items()), key=lambda x: x[1])
V.pop(u)
new_V.append(u)
cost += e
for v, e in enumerate(G[u]):
if e < 0 or v == u or v in new_V:
continue
V[v] = min(V[v], e) if v in V else e
return cost
n = int(eval(input()))
G = [list(map(int, input().split())) for _ in range(n)]
print((solv(G)))
| false | 20 | [
"- new_V = [0]",
"- new_E = []",
"- while len(new_V) < len(G):",
"- u, e = select_min(G, new_V)",
"+ n = len(G)",
"+ V = {0: 0}",
"+ new_V = []",
"+ cost = 0",
"+ while len(new_V) < n:",
"+ u, e = min(list(V.items()), key=lambda x: x[1])",
"+ V.pop(u)",
"- new_E.append(e)",
"- return sum(new_E)",
"-",
"-",
"-def select_min(G, V):",
"- min_u = -1",
"- min_e = float(\"inf\")",
"- for v in V:",
"- for u, e in enumerate(G[v]):",
"- if (e < 0) or (u in V):",
"+ cost += e",
"+ for v, e in enumerate(G[u]):",
"+ if e < 0 or v == u or v in new_V:",
"- if e < min_e:",
"- min_u = u",
"- min_e = e",
"- return min_u, min_e",
"+ V[v] = min(V[v], e) if v in V else e",
"+ return cost"
] | false | 0.094512 | 0.037576 | 2.515203 | [
"s200573586",
"s496292938"
] |
u595289165 | p03160 | python | s095627960 | s083769238 | 516 | 122 | 17,200 | 13,924 | Accepted | Accepted | 76.36 | N = int(eval(input()))
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros(N+1, dtype=int)
dp[2] = abs(h[0]-h[1])
for i in range(2, N):
dp[i+1] = min(
dp[i] + abs(h[i-1]-h[i]),
dp[i-1] + abs(h[i-2]-h[i])
)
print((dp[N]))
| n = int(eval(input()))
h = [0] + list(map(int, input().split()))
inf = 10**5
dp = [inf]*(n+1)
dp[1] = 0
dp[2] = abs(h[1] - h[2])
for i in range(3, n+1):
dp[i] = min(
dp[i-1] + abs(h[i-1] - h[i]),
dp[i-2] + abs(h[i-2] - h[i])
)
print((dp[n])) | 11 | 13 | 264 | 270 | N = int(eval(input()))
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros(N + 1, dtype=int)
dp[2] = abs(h[0] - h[1])
for i in range(2, N):
dp[i + 1] = min(dp[i] + abs(h[i - 1] - h[i]), dp[i - 1] + abs(h[i - 2] - h[i]))
print((dp[N]))
| n = int(eval(input()))
h = [0] + list(map(int, input().split()))
inf = 10**5
dp = [inf] * (n + 1)
dp[1] = 0
dp[2] = abs(h[1] - h[2])
for i in range(3, n + 1):
dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
print((dp[n]))
| false | 15.384615 | [
"-N = int(eval(input()))",
"-h = list(map(int, input().split()))",
"-import numpy as np",
"-",
"-dp = np.zeros(N + 1, dtype=int)",
"-dp[2] = abs(h[0] - h[1])",
"-for i in range(2, N):",
"- dp[i + 1] = min(dp[i] + abs(h[i - 1] - h[i]), dp[i - 1] + abs(h[i - 2] - h[i]))",
"-print((dp[N]))",
"+n = int(eval(input()))",
"+h = [0] + list(map(int, input().split()))",
"+inf = 10**5",
"+dp = [inf] * (n + 1)",
"+dp[1] = 0",
"+dp[2] = abs(h[1] - h[2])",
"+for i in range(3, n + 1):",
"+ dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))",
"+print((dp[n]))"
] | false | 0.221053 | 0.046235 | 4.781021 | [
"s095627960",
"s083769238"
] |
u981931040 | p03645 | python | s029915767 | s852984808 | 825 | 453 | 38,320 | 17,236 | Accepted | Accepted | 45.09 | N , M = list(map(int,input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
a , b = list(map(int,input().split()))
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
for node0 in graph[0]:
for node1 in graph[node0]:
if node1 == N - 1:
print("POSSIBLE")
exit()
print("IMPOSSIBLE") | import bisect
N, M = list(map(int, input().split()))
start_to_middle = []
middle_to_end = []
for i in range(M):
a, b = list(map(int, input().split()))
if a == 1:
start_to_middle.append(b)
elif b == N:
middle_to_end.append(a)
if not len(start_to_middle) or not len(middle_to_end):
print('IMPOSSIBLE')
exit()
middle_to_end.sort()
for middle in start_to_middle:
idx = bisect.bisect_left(middle_to_end, middle)
if idx < len(middle_to_end) and middle_to_end[idx] == middle:
print('POSSIBLE')
exit()
print('IMPOSSIBLE')
| 13 | 21 | 344 | 583 | N, M = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
for node0 in graph[0]:
for node1 in graph[node0]:
if node1 == N - 1:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| import bisect
N, M = list(map(int, input().split()))
start_to_middle = []
middle_to_end = []
for i in range(M):
a, b = list(map(int, input().split()))
if a == 1:
start_to_middle.append(b)
elif b == N:
middle_to_end.append(a)
if not len(start_to_middle) or not len(middle_to_end):
print("IMPOSSIBLE")
exit()
middle_to_end.sort()
for middle in start_to_middle:
idx = bisect.bisect_left(middle_to_end, middle)
if idx < len(middle_to_end) and middle_to_end[idx] == middle:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| false | 38.095238 | [
"+import bisect",
"+",
"-graph = [[] for _ in range(N)]",
"-for _ in range(M):",
"+start_to_middle = []",
"+middle_to_end = []",
"+for i in range(M):",
"- graph[a - 1].append(b - 1)",
"- graph[b - 1].append(a - 1)",
"-for node0 in graph[0]:",
"- for node1 in graph[node0]:",
"- if node1 == N - 1:",
"- print(\"POSSIBLE\")",
"- exit()",
"+ if a == 1:",
"+ start_to_middle.append(b)",
"+ elif b == N:",
"+ middle_to_end.append(a)",
"+if not len(start_to_middle) or not len(middle_to_end):",
"+ print(\"IMPOSSIBLE\")",
"+ exit()",
"+middle_to_end.sort()",
"+for middle in start_to_middle:",
"+ idx = bisect.bisect_left(middle_to_end, middle)",
"+ if idx < len(middle_to_end) and middle_to_end[idx] == middle:",
"+ print(\"POSSIBLE\")",
"+ exit()"
] | false | 0.08559 | 0.167379 | 0.511351 | [
"s029915767",
"s852984808"
] |
u879870653 | p02983 | python | s583406131 | s596977636 | 960 | 764 | 3,060 | 2,940 | Accepted | Accepted | 20.42 | L,R = list(map(int,input().split()))
flg = 1
for i in range(10**6+1) :
if 2019*i < L :
continue
if 2019*i <= R :
ans = 0
flg = 0
break
else :
break
if flg :
ans = float("inf")
for i in range(L,R) :
for j in range(i+1,R+1) :
calc = (i*j) % 2019
ans = min(ans,calc)
print(ans)
| L,R = list(map(int,input().split()))
if R-L >= 2018 :
ans = 0
else :
ans = float("inf")
for i in range(L,R) :
for j in range(i+1,R+1) :
ans = min(ans, (i*j)%2019)
print(ans) | 21 | 9 | 396 | 207 | L, R = list(map(int, input().split()))
flg = 1
for i in range(10**6 + 1):
if 2019 * i < L:
continue
if 2019 * i <= R:
ans = 0
flg = 0
break
else:
break
if flg:
ans = float("inf")
for i in range(L, R):
for j in range(i + 1, R + 1):
calc = (i * j) % 2019
ans = min(ans, calc)
print(ans)
| L, R = list(map(int, input().split()))
if R - L >= 2018:
ans = 0
else:
ans = float("inf")
for i in range(L, R):
for j in range(i + 1, R + 1):
ans = min(ans, (i * j) % 2019)
print(ans)
| false | 57.142857 | [
"-flg = 1",
"-for i in range(10**6 + 1):",
"- if 2019 * i < L:",
"- continue",
"- if 2019 * i <= R:",
"- ans = 0",
"- flg = 0",
"- break",
"- else:",
"- break",
"-if flg:",
"+if R - L >= 2018:",
"+ ans = 0",
"+else:",
"- calc = (i * j) % 2019",
"- ans = min(ans, calc)",
"+ ans = min(ans, (i * j) % 2019)"
] | false | 0.038145 | 0.051675 | 0.738173 | [
"s583406131",
"s596977636"
] |
u692453235 | p02793 | python | s238978792 | s272123882 | 1,544 | 206 | 74,284 | 77,364 | Accepted | Accepted | 86.66 | import math
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9+7
def lcm(x, y):
return (x // math.gcd(x, y)) * y
LCM = A[0]
for i in range(N-1):
LCM = lcm(LCM, A[i+1])
#LCM %= mod
ans = 0
for a in A:
ans += LCM * pow(a, mod-2, mod) % mod
ans %= mod
print(ans) | import math
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9+7
primes = [0]*(10**6+1)
def prime_fac(n):
temp = n
Flag = True
for i in range(2, int(math.sqrt(n)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
primes[i] = max(primes[i], cnt)
Flag = False
if temp != 1:
primes[temp] = max(primes[temp], 1)
if Flag:
primes[n] = max(primes[n], 1)
for a in A:
prime_fac(a)
LCM = 1
for p, i in enumerate(primes):
if i:
LCM *= pow(p, i, mod)
LCM %= mod
ans = 0
for a in A:
ans += LCM * pow(a, mod-2, mod) % mod
ans %= mod
print(ans) | 22 | 40 | 309 | 691 | import math
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
def lcm(x, y):
return (x // math.gcd(x, y)) * y
LCM = A[0]
for i in range(N - 1):
LCM = lcm(LCM, A[i + 1])
# LCM %= mod
ans = 0
for a in A:
ans += LCM * pow(a, mod - 2, mod) % mod
ans %= mod
print(ans)
| import math
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
primes = [0] * (10**6 + 1)
def prime_fac(n):
temp = n
Flag = True
for i in range(2, int(math.sqrt(n)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
primes[i] = max(primes[i], cnt)
Flag = False
if temp != 1:
primes[temp] = max(primes[temp], 1)
if Flag:
primes[n] = max(primes[n], 1)
for a in A:
prime_fac(a)
LCM = 1
for p, i in enumerate(primes):
if i:
LCM *= pow(p, i, mod)
LCM %= mod
ans = 0
for a in A:
ans += LCM * pow(a, mod - 2, mod) % mod
ans %= mod
print(ans)
| false | 45 | [
"+primes = [0] * (10**6 + 1)",
"-def lcm(x, y):",
"- return (x // math.gcd(x, y)) * y",
"+def prime_fac(n):",
"+ temp = n",
"+ Flag = True",
"+ for i in range(2, int(math.sqrt(n)) + 1):",
"+ if temp % i == 0:",
"+ cnt = 0",
"+ while temp % i == 0:",
"+ cnt += 1",
"+ temp //= i",
"+ primes[i] = max(primes[i], cnt)",
"+ Flag = False",
"+ if temp != 1:",
"+ primes[temp] = max(primes[temp], 1)",
"+ if Flag:",
"+ primes[n] = max(primes[n], 1)",
"-LCM = A[0]",
"-for i in range(N - 1):",
"- LCM = lcm(LCM, A[i + 1])",
"-# LCM %= mod",
"+for a in A:",
"+ prime_fac(a)",
"+LCM = 1",
"+for p, i in enumerate(primes):",
"+ if i:",
"+ LCM *= pow(p, i, mod)",
"+ LCM %= mod"
] | false | 0.190955 | 0.453699 | 0.420884 | [
"s238978792",
"s272123882"
] |
u746419473 | p02819 | python | s708012993 | s919838653 | 19 | 17 | 3,064 | 2,940 | Accepted | Accepted | 10.53 | import math
x = int(eval(input()))
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
i = x
while not is_prime(i):
i += 1
print(i)
| import math
x = int(eval(input()))
def is_prime(n: int) -> bool:
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
while True:
if is_prime(x):
break
x += 1
print(x)
| 18 | 18 | 256 | 285 | import math
x = int(eval(input()))
def is_prime(n):
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
i = x
while not is_prime(i):
i += 1
print(i)
| import math
x = int(eval(input()))
def is_prime(n: int) -> bool:
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
while True:
if is_prime(x):
break
x += 1
print(x)
| false | 0 | [
"-def is_prime(n):",
"+def is_prime(n: int) -> bool:",
"-i = x",
"-while not is_prime(i):",
"- i += 1",
"-print(i)",
"+while True:",
"+ if is_prime(x):",
"+ break",
"+ x += 1",
"+print(x)"
] | false | 0.047301 | 0.045134 | 1.048033 | [
"s708012993",
"s919838653"
] |
u708255304 | p02928 | python | s195665726 | s211884800 | 1,379 | 1,046 | 3,188 | 3,188 | Accepted | Accepted | 24.15 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 1000000007
# K = 2のときの初期値が必要
B = A * 2
syokiti_A = 0
syokiti_B = 0
for i in range(N):
for j in range(i, N):
if A[i] > A[j]:
syokiti_A += 1
for i in range(N):
for j in range(N):
if i == j:
continue
if A[i] > A[j]:
syokiti_B += 1
ans = (syokiti_A * K) % mod + (syokiti_B * K * (K-1) // 2) % mod
print((int(ans) % mod))
| N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
p = 0
q = 0
ans = 0
for i in range(N):
for j in range(i, N):
if A[i] > A[j]:
p += 1
for i in range(N):
for j in range(N):
if A[i] > A[j]:
q += 1
ans = (p * K) % 1000000007 + (q * K * (K-1) // 2) % 1000000007
print((ans % 1000000007))
| 24 | 20 | 486 | 373 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 1000000007
# K = 2のときの初期値が必要
B = A * 2
syokiti_A = 0
syokiti_B = 0
for i in range(N):
for j in range(i, N):
if A[i] > A[j]:
syokiti_A += 1
for i in range(N):
for j in range(N):
if i == j:
continue
if A[i] > A[j]:
syokiti_B += 1
ans = (syokiti_A * K) % mod + (syokiti_B * K * (K - 1) // 2) % mod
print((int(ans) % mod))
| N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
p = 0
q = 0
ans = 0
for i in range(N):
for j in range(i, N):
if A[i] > A[j]:
p += 1
for i in range(N):
for j in range(N):
if A[i] > A[j]:
q += 1
ans = (p * K) % 1000000007 + (q * K * (K - 1) // 2) % 1000000007
print((ans % 1000000007))
| false | 16.666667 | [
"-mod = 1000000007",
"-# K = 2のときの初期値が必要",
"-B = A * 2",
"-syokiti_A = 0",
"-syokiti_B = 0",
"+p = 0",
"+q = 0",
"+ans = 0",
"- syokiti_A += 1",
"+ p += 1",
"- if i == j:",
"- continue",
"- syokiti_B += 1",
"-ans = (syokiti_A * K) % mod + (syokiti_B * K * (K - 1) // 2) % mod",
"-print((int(ans) % mod))",
"+ q += 1",
"+ans = (p * K) % 1000000007 + (q * K * (K - 1) // 2) % 1000000007",
"+print((ans % 1000000007))"
] | false | 0.036195 | 0.036085 | 1.00306 | [
"s195665726",
"s211884800"
] |
u814986259 | p03282 | python | s747365169 | s065047535 | 162 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.51 | S=list(map(int,list(eval(input()))))
K=int(eval(input()))
if S[0]==1:
if K==1:
print((1))
else:
for i in range(1,len(S)):
if S[i] != 1:
print((S[i]))
exit(0)
if i == K-1:
print((1))
exit(0)
else:
print((S[0])) | S = eval(input())
K = int(eval(input()))
for x in S:
x = int(x)
if x != 1:
print(x)
break
else:
if K == 1:
print(x)
break
else:
K -= 1
| 16 | 13 | 263 | 215 | S = list(map(int, list(eval(input()))))
K = int(eval(input()))
if S[0] == 1:
if K == 1:
print((1))
else:
for i in range(1, len(S)):
if S[i] != 1:
print((S[i]))
exit(0)
if i == K - 1:
print((1))
exit(0)
else:
print((S[0]))
| S = eval(input())
K = int(eval(input()))
for x in S:
x = int(x)
if x != 1:
print(x)
break
else:
if K == 1:
print(x)
break
else:
K -= 1
| false | 18.75 | [
"-S = list(map(int, list(eval(input()))))",
"+S = eval(input())",
"-if S[0] == 1:",
"- if K == 1:",
"- print((1))",
"+for x in S:",
"+ x = int(x)",
"+ if x != 1:",
"+ print(x)",
"+ break",
"- for i in range(1, len(S)):",
"- if S[i] != 1:",
"- print((S[i]))",
"- exit(0)",
"- if i == K - 1:",
"- print((1))",
"- exit(0)",
"-else:",
"- print((S[0]))",
"+ if K == 1:",
"+ print(x)",
"+ break",
"+ else:",
"+ K -= 1"
] | false | 0.042554 | 0.039439 | 1.079001 | [
"s747365169",
"s065047535"
] |
u761989513 | p03807 | python | s849348442 | s397116227 | 58 | 53 | 14,108 | 14,112 | Accepted | Accepted | 8.62 | n = int(eval(input()))
a = list(map(int, input().split()))
odd = 0
for i in range(n):
if a[i] % 2:
odd += 1
odd %= 2
if odd:
print("NO")
else:
print("YES") | n = int(eval(input()))
a = list(map(int, input().split()))
odd = 0
for i in a:
if i % 2:
odd += 1
if odd % 2:
print("NO")
else:
print("YES") | 11 | 10 | 179 | 163 | n = int(eval(input()))
a = list(map(int, input().split()))
odd = 0
for i in range(n):
if a[i] % 2:
odd += 1
odd %= 2
if odd:
print("NO")
else:
print("YES")
| n = int(eval(input()))
a = list(map(int, input().split()))
odd = 0
for i in a:
if i % 2:
odd += 1
if odd % 2:
print("NO")
else:
print("YES")
| false | 9.090909 | [
"-for i in range(n):",
"- if a[i] % 2:",
"+for i in a:",
"+ if i % 2:",
"-odd %= 2",
"-if odd:",
"+if odd % 2:"
] | false | 0.0468 | 0.038888 | 1.20344 | [
"s849348442",
"s397116227"
] |
u102461423 | p03164 | python | s027749132 | s159006188 | 214 | 130 | 14,920 | 28,268 | Accepted | Accepted | 39.25 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N,W = list(map(int,readline().split()))
m = list(map(int,read().split()))
WV = list(zip(m,m))
# 価値 -> 最小重さ
INF = 10**18
dp = np.full(10**5+10,INF,np.int64)
dp[0] = 0
for w,v in WV:
np.minimum(dp[v:], dp[:-v].copy()+w, out=dp[v:])
answer = np.where(dp<=W)[0][-1]
print(answer) | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, lim = list(map(int, readline().split()))
WV = np.array(read().split(), np.int64)
W = WV[::2]
V = WV[1::2]
# value sum -> min weight
INF = 10**18
dp = np.full(V.sum() + 1, INF, np.int64)
dp[0] = 0
for w, v in zip(W, V):
np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])
answer = np.where(dp <= lim)[0].max()
print(answer) | 21 | 22 | 421 | 476 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N, W = list(map(int, readline().split()))
m = list(map(int, read().split()))
WV = list(zip(m, m))
# 価値 -> 最小重さ
INF = 10**18
dp = np.full(10**5 + 10, INF, np.int64)
dp[0] = 0
for w, v in WV:
np.minimum(dp[v:], dp[:-v].copy() + w, out=dp[v:])
answer = np.where(dp <= W)[0][-1]
print(answer)
| import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, lim = list(map(int, readline().split()))
WV = np.array(read().split(), np.int64)
W = WV[::2]
V = WV[1::2]
# value sum -> min weight
INF = 10**18
dp = np.full(V.sum() + 1, INF, np.int64)
dp[0] = 0
for w, v in zip(W, V):
np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])
answer = np.where(dp <= lim)[0].max()
print(answer)
| false | 4.545455 | [
"+import numpy as np",
"-import numpy as np",
"-",
"-N, W = list(map(int, readline().split()))",
"-m = list(map(int, read().split()))",
"-WV = list(zip(m, m))",
"-# 価値 -> 最小重さ",
"+N, lim = list(map(int, readline().split()))",
"+WV = np.array(read().split(), np.int64)",
"+W = WV[::2]",
"+V = WV[1::2]",
"+# value sum -> min weight",
"-dp = np.full(10**5 + 10, INF, np.int64)",
"+dp = np.full(V.sum() + 1, INF, np.int64)",
"-for w, v in WV:",
"- np.minimum(dp[v:], dp[:-v].copy() + w, out=dp[v:])",
"-answer = np.where(dp <= W)[0][-1]",
"+for w, v in zip(W, V):",
"+ np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])",
"+answer = np.where(dp <= lim)[0].max()"
] | false | 0.282418 | 0.220884 | 1.27858 | [
"s027749132",
"s159006188"
] |
u312025627 | p03854 | python | s469718237 | s170881440 | 182 | 76 | 40,688 | 3,192 | Accepted | Accepted | 58.24 | def main():
S = input()[::-1]
tar = {'maerd', 'remaerd', 'esare', 'resare'}
i = 0
while i < len(S):
if S[i] == 'm':
if S[i:i+5] == 'maerd':
i += 5
else:
return print("NO")
elif S[i] == 'e':
if S[i:i+5] == 'esare':
i += 5
else:
return print("NO")
elif S[i] == 'r':
if S[i:i+6] == 'resare':
i += 6
elif S[i:i+7] == 'remaerd':
i += 7
else:
return print("NO")
else:
return print("NO")
print("YES")
if __name__ == '__main__':
main()
| def main():
S = input()
S = S[::-1]
ans = ["maerd", "remaerd", "esare", "resare"]
while S:
for a in ans:
if S[:5] in ans:
S = S.replace(S[:5], "", 1)
break
elif S[:6] in ans:
S = S.replace(S[:6], "", 1)
break
elif S[:7] in ans:
S = S.replace(S[:7], "", 1)
break
else:
return print("NO")
else:
return print("YES")
if __name__ == '__main__':
main()
| 27 | 23 | 717 | 563 | def main():
S = input()[::-1]
tar = {"maerd", "remaerd", "esare", "resare"}
i = 0
while i < len(S):
if S[i] == "m":
if S[i : i + 5] == "maerd":
i += 5
else:
return print("NO")
elif S[i] == "e":
if S[i : i + 5] == "esare":
i += 5
else:
return print("NO")
elif S[i] == "r":
if S[i : i + 6] == "resare":
i += 6
elif S[i : i + 7] == "remaerd":
i += 7
else:
return print("NO")
else:
return print("NO")
print("YES")
if __name__ == "__main__":
main()
| def main():
S = input()
S = S[::-1]
ans = ["maerd", "remaerd", "esare", "resare"]
while S:
for a in ans:
if S[:5] in ans:
S = S.replace(S[:5], "", 1)
break
elif S[:6] in ans:
S = S.replace(S[:6], "", 1)
break
elif S[:7] in ans:
S = S.replace(S[:7], "", 1)
break
else:
return print("NO")
else:
return print("YES")
if __name__ == "__main__":
main()
| false | 14.814815 | [
"- S = input()[::-1]",
"- tar = {\"maerd\", \"remaerd\", \"esare\", \"resare\"}",
"- i = 0",
"- while i < len(S):",
"- if S[i] == \"m\":",
"- if S[i : i + 5] == \"maerd\":",
"- i += 5",
"- else:",
"- return print(\"NO\")",
"- elif S[i] == \"e\":",
"- if S[i : i + 5] == \"esare\":",
"- i += 5",
"- else:",
"- return print(\"NO\")",
"- elif S[i] == \"r\":",
"- if S[i : i + 6] == \"resare\":",
"- i += 6",
"- elif S[i : i + 7] == \"remaerd\":",
"- i += 7",
"- else:",
"- return print(\"NO\")",
"+ S = input()",
"+ S = S[::-1]",
"+ ans = [\"maerd\", \"remaerd\", \"esare\", \"resare\"]",
"+ while S:",
"+ for a in ans:",
"+ if S[:5] in ans:",
"+ S = S.replace(S[:5], \"\", 1)",
"+ break",
"+ elif S[:6] in ans:",
"+ S = S.replace(S[:6], \"\", 1)",
"+ break",
"+ elif S[:7] in ans:",
"+ S = S.replace(S[:7], \"\", 1)",
"+ break",
"- print(\"YES\")",
"+ else:",
"+ return print(\"YES\")"
] | false | 0.057866 | 0.036692 | 1.577084 | [
"s469718237",
"s170881440"
] |
u076917070 | p03013 | python | s932761454 | s191858667 | 493 | 455 | 460,020 | 460,020 | Accepted | Accepted | 7.71 | import sys
input=sys.stdin.readline
n,m = list(map(int, input().split()))
a = {}
for i in range(m):
a[int(eval(input()))] = 0
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2,n+1):
if i in a:
dp[i] = 0
else:
dp[i] = dp[i-1] + dp[i-2]
print((dp[n]%(10**9+7)))
| import sys
input=sys.stdin.readline
n,m = list(map(int, input().split()))
a = set()
for i in range(m):
a.add(int(eval(input())))
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2,n+1):
if i in a:
dp[i] = 0
else:
dp[i] = dp[i-1] + dp[i-2]
print((dp[n]%(10**9+7)))
| 18 | 18 | 313 | 316 | import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
a = {}
for i in range(m):
a[int(eval(input()))] = 0
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2, n + 1):
if i in a:
dp[i] = 0
else:
dp[i] = dp[i - 1] + dp[i - 2]
print((dp[n] % (10**9 + 7)))
| import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
a = set()
for i in range(m):
a.add(int(eval(input())))
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2, n + 1):
if i in a:
dp[i] = 0
else:
dp[i] = dp[i - 1] + dp[i - 2]
print((dp[n] % (10**9 + 7)))
| false | 0 | [
"-a = {}",
"+a = set()",
"- a[int(eval(input()))] = 0",
"+ a.add(int(eval(input())))"
] | false | 0.06555 | 0.037791 | 1.734532 | [
"s932761454",
"s191858667"
] |
u375616706 | p03675 | python | s007129674 | s092958814 | 315 | 122 | 119,252 | 31,172 | Accepted | Accepted | 61.27 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = []
if N % 2 == 0:
l1 = A[0::2]
l2 = A[1::2]
l2 = l2[::-1]
ans = l2+l1
else:
l1 = A[0::2]
l2 = A[1::2]
l1 = l1[::-1]
ans = l1+l2
print((" ".join(list(map(str, ans)))))
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = []
l1 = A[0::2]
l2 = A[1::2]
if N % 2 == 0:
l2 = l2[::-1]
ans = l2+l1
else:
l1 = l1[::-1]
ans = l1+l2
print((" ".join(list(map(str, ans)))))
| 16 | 15 | 273 | 231 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = []
if N % 2 == 0:
l1 = A[0::2]
l2 = A[1::2]
l2 = l2[::-1]
ans = l2 + l1
else:
l1 = A[0::2]
l2 = A[1::2]
l1 = l1[::-1]
ans = l1 + l2
print((" ".join(list(map(str, ans)))))
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = []
l1 = A[0::2]
l2 = A[1::2]
if N % 2 == 0:
l2 = l2[::-1]
ans = l2 + l1
else:
l1 = l1[::-1]
ans = l1 + l2
print((" ".join(list(map(str, ans)))))
| false | 6.25 | [
"+l1 = A[0::2]",
"+l2 = A[1::2]",
"- l1 = A[0::2]",
"- l2 = A[1::2]",
"- l1 = A[0::2]",
"- l2 = A[1::2]"
] | false | 0.036294 | 0.036398 | 0.997151 | [
"s007129674",
"s092958814"
] |
u148551245 | p03399 | python | s678095878 | s571029856 | 176 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.34 | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
print(((a if a <= b else b) + (c if c <= d else d))) | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
ans = min(a, b) + min(c, d)
print(ans) | 6 | 6 | 124 | 111 | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
print(((a if a <= b else b) + (c if c <= d else d)))
| a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
ans = min(a, b) + min(c, d)
print(ans)
| false | 0 | [
"-print(((a if a <= b else b) + (c if c <= d else d)))",
"+ans = min(a, b) + min(c, d)",
"+print(ans)"
] | false | 0.047631 | 0.042776 | 1.113495 | [
"s678095878",
"s571029856"
] |
u685263709 | p03078 | python | s003251705 | s225572037 | 992 | 405 | 140,420 | 88,732 | Accepted | Accepted | 59.17 | X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sumsofAandB = sorted([a+b for a in A for b in B], reverse=True)[:K]
sumsofAll = sorted([ab+c for ab in sumsofAandB for c in C], reverse=True)
for i in range(K):
print((sumsofAll[i])) | from heapq import heappush, heappop
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
h = []
maxv = A[0] + B[0] + C[0]
def inv(v):
return maxv - v
pushed = [[[] for _ in range(Y)] for _ in range(X)]
heappush(h, (0, 0, 0, 0))
for _ in range(K):
invv, i, j, k = heappop(h)
print((inv(invv)))
if i + 1 < X and k not in pushed[i + 1][j]:
heappush(h, (inv(A[i + 1] + B[j] + C[k]), i + 1, j, k))
pushed[i + 1][j].append(k)
if j + 1 < Y and k not in pushed[i][j + 1]:
heappush(h, (inv(A[i] + B[j + 1] + C[k]), i, j + 1, k))
pushed[i][j + 1].append(k)
if k + 1 < Z and k + 1 not in pushed[i][j]:
heappush(h, (inv(A[i] + B[j] + C[k + 1]), i, j, k + 1))
pushed[i][j].append(k + 1) | 9 | 32 | 340 | 937 | X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sumsofAandB = sorted([a + b for a in A for b in B], reverse=True)[:K]
sumsofAll = sorted([ab + c for ab in sumsofAandB for c in C], reverse=True)
for i in range(K):
print((sumsofAll[i]))
| from heapq import heappush, heappop
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
h = []
maxv = A[0] + B[0] + C[0]
def inv(v):
return maxv - v
pushed = [[[] for _ in range(Y)] for _ in range(X)]
heappush(h, (0, 0, 0, 0))
for _ in range(K):
invv, i, j, k = heappop(h)
print((inv(invv)))
if i + 1 < X and k not in pushed[i + 1][j]:
heappush(h, (inv(A[i + 1] + B[j] + C[k]), i + 1, j, k))
pushed[i + 1][j].append(k)
if j + 1 < Y and k not in pushed[i][j + 1]:
heappush(h, (inv(A[i] + B[j + 1] + C[k]), i, j + 1, k))
pushed[i][j + 1].append(k)
if k + 1 < Z and k + 1 not in pushed[i][j]:
heappush(h, (inv(A[i] + B[j] + C[k + 1]), i, j, k + 1))
pushed[i][j].append(k + 1)
| false | 71.875 | [
"+from heapq import heappush, heappop",
"+",
"-sumsofAandB = sorted([a + b for a in A for b in B], reverse=True)[:K]",
"-sumsofAll = sorted([ab + c for ab in sumsofAandB for c in C], reverse=True)",
"-for i in range(K):",
"- print((sumsofAll[i]))",
"+A.sort(reverse=True)",
"+B.sort(reverse=True)",
"+C.sort(reverse=True)",
"+h = []",
"+maxv = A[0] + B[0] + C[0]",
"+",
"+",
"+def inv(v):",
"+ return maxv - v",
"+",
"+",
"+pushed = [[[] for _ in range(Y)] for _ in range(X)]",
"+heappush(h, (0, 0, 0, 0))",
"+for _ in range(K):",
"+ invv, i, j, k = heappop(h)",
"+ print((inv(invv)))",
"+ if i + 1 < X and k not in pushed[i + 1][j]:",
"+ heappush(h, (inv(A[i + 1] + B[j] + C[k]), i + 1, j, k))",
"+ pushed[i + 1][j].append(k)",
"+ if j + 1 < Y and k not in pushed[i][j + 1]:",
"+ heappush(h, (inv(A[i] + B[j + 1] + C[k]), i, j + 1, k))",
"+ pushed[i][j + 1].append(k)",
"+ if k + 1 < Z and k + 1 not in pushed[i][j]:",
"+ heappush(h, (inv(A[i] + B[j] + C[k + 1]), i, j, k + 1))",
"+ pushed[i][j].append(k + 1)"
] | false | 0.073562 | 0.037967 | 1.937538 | [
"s003251705",
"s225572037"
] |
u993622994 | p03835 | python | s694243442 | s070201181 | 1,802 | 1,220 | 2,940 | 2,940 | Accepted | Accepted | 32.3 | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s - x - y
if 0 > z or z > k:
continue
else:
count += 1
print(count) | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
if 0 <= s-x-y <= k:
count += 1
print(count) | 12 | 9 | 221 | 162 | k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 > z or z > k:
continue
else:
count += 1
print(count)
| k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
if 0 <= s - x - y <= k:
count += 1
print(count)
| false | 25 | [
"- z = s - x - y",
"- if 0 > z or z > k:",
"- continue",
"- else:",
"+ if 0 <= s - x - y <= k:"
] | false | 0.091158 | 0.03745 | 2.43415 | [
"s694243442",
"s070201181"
] |
u954858867 | p02412 | python | s008518836 | s457428846 | 670 | 290 | 6,452 | 6,392 | Accepted | Accepted | 56.72 | ret = []
while True:
n, x = list(map(int, input().split()))
num_arr = [i for i in range(1, n+1)]
if (n, x) == (0, 0):
break
cnt = 0
for i in range(len(num_arr)):
for j in range(i + 1, len(num_arr)):
k_flg = False
for k in range(j + 1, len(num_arr)):
work = num_arr[i] + num_arr[j] + num_arr[k]
if x == work:
cnt += 1
k_flg = True
break
ret += [cnt]
for i in ret:
print(i) | ret = []
while True:
n, x = list(map(int, input().split()))
num_arr = [i for i in range(1, n+1)]
if (n, x) == (0, 0):
break
cnt = 0
for i in range(n, 0, -1):
if x - i <= 2:
continue
#print "i : %d" % i
for j in range(i -1, 0, -1):
if x-i-j <= 0:
continue
#print "j : %d" % j
for k in range(j - 1, 0 , -1):
if x-i-j-k < 0:
continue
if x -i-j-k == 0:
cnt += 1
#print "k : %d" % k
break
ret += [cnt]
for i in ret:
print(i) | 20 | 26 | 533 | 647 | ret = []
while True:
n, x = list(map(int, input().split()))
num_arr = [i for i in range(1, n + 1)]
if (n, x) == (0, 0):
break
cnt = 0
for i in range(len(num_arr)):
for j in range(i + 1, len(num_arr)):
k_flg = False
for k in range(j + 1, len(num_arr)):
work = num_arr[i] + num_arr[j] + num_arr[k]
if x == work:
cnt += 1
k_flg = True
break
ret += [cnt]
for i in ret:
print(i)
| ret = []
while True:
n, x = list(map(int, input().split()))
num_arr = [i for i in range(1, n + 1)]
if (n, x) == (0, 0):
break
cnt = 0
for i in range(n, 0, -1):
if x - i <= 2:
continue
# print "i : %d" % i
for j in range(i - 1, 0, -1):
if x - i - j <= 0:
continue
# print "j : %d" % j
for k in range(j - 1, 0, -1):
if x - i - j - k < 0:
continue
if x - i - j - k == 0:
cnt += 1
# print "k : %d" % k
break
ret += [cnt]
for i in ret:
print(i)
| false | 23.076923 | [
"- for i in range(len(num_arr)):",
"- for j in range(i + 1, len(num_arr)):",
"- k_flg = False",
"- for k in range(j + 1, len(num_arr)):",
"- work = num_arr[i] + num_arr[j] + num_arr[k]",
"- if x == work:",
"+ for i in range(n, 0, -1):",
"+ if x - i <= 2:",
"+ continue",
"+ # print \"i : %d\" % i",
"+ for j in range(i - 1, 0, -1):",
"+ if x - i - j <= 0:",
"+ continue",
"+ # print \"j : %d\" % j",
"+ for k in range(j - 1, 0, -1):",
"+ if x - i - j - k < 0:",
"+ continue",
"+ if x - i - j - k == 0:",
"- k_flg = True",
"+ # print \"k : %d\" % k"
] | false | 0.075646 | 0.163171 | 0.463597 | [
"s008518836",
"s457428846"
] |
u223133214 | p03137 | python | s098827855 | s243342545 | 112 | 100 | 13,960 | 20,460 | Accepted | Accepted | 10.71 | n,m=list(map(int,input().split()))
x_s=list(map(int,input().split()))
if n >= m:
print((0))
exit()
x_s.sort()
sa=[]
for i in range(m-1):
sa.append(x_s[i+1]-x_s[i])
sa.sort()
print((sum(sa)-sum(sa[m-n:m])))
| n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
if n >= m:
print((0))
exit()
sa = []
for i in range(1, m):
sa.append(abs(X[i] - X[i - 1]))
sa.sort(reverse=True)
# print(sa)
# print((max(X) - min(X)))
print(((max(X) - min(X)) - sum(sa[:n-1])))
| 13 | 17 | 222 | 301 | n, m = list(map(int, input().split()))
x_s = list(map(int, input().split()))
if n >= m:
print((0))
exit()
x_s.sort()
sa = []
for i in range(m - 1):
sa.append(x_s[i + 1] - x_s[i])
sa.sort()
print((sum(sa) - sum(sa[m - n : m])))
| n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
if n >= m:
print((0))
exit()
sa = []
for i in range(1, m):
sa.append(abs(X[i] - X[i - 1]))
sa.sort(reverse=True)
# print(sa)
# print((max(X) - min(X)))
print(((max(X) - min(X)) - sum(sa[: n - 1])))
| false | 23.529412 | [
"-x_s = list(map(int, input().split()))",
"+X = list(map(int, input().split()))",
"+X.sort()",
"-x_s.sort()",
"-for i in range(m - 1):",
"- sa.append(x_s[i + 1] - x_s[i])",
"-sa.sort()",
"-print((sum(sa) - sum(sa[m - n : m])))",
"+for i in range(1, m):",
"+ sa.append(abs(X[i] - X[i - 1]))",
"+sa.sort(reverse=True)",
"+# print(sa)",
"+# print((max(X) - min(X)))",
"+print(((max(X) - min(X)) - sum(sa[: n - 1])))"
] | false | 0.081454 | 0.043459 | 1.874266 | [
"s098827855",
"s243342545"
] |
u350248178 | p02642 | python | s325367539 | s140034278 | 573 | 394 | 115,220 | 50,528 | Accepted | Accepted | 31.24 | import numpy as np
n=int(eval(input()))
a=[int(j)for j in input().split()]+[10**7]
l=np.zeros(max(a)+1)
a.sort()
r=0
for i,j in zip(a,a[1:]):
if l[i]==0:
l[::i]=1
if i!=j:
r+=1
print(r) | import numpy as np
n,*a=list(map(int,open(0).read().split()))
l=np.zeros(max(a)+1)
a.sort()
a+=[10**7]
r=0
for i,j in zip(a,a[1:]):
if l[i]==0:
l[::i]=1
if i!=j:
r+=1
print(r) | 12 | 12 | 222 | 212 | import numpy as np
n = int(eval(input()))
a = [int(j) for j in input().split()] + [10**7]
l = np.zeros(max(a) + 1)
a.sort()
r = 0
for i, j in zip(a, a[1:]):
if l[i] == 0:
l[::i] = 1
if i != j:
r += 1
print(r)
| import numpy as np
n, *a = list(map(int, open(0).read().split()))
l = np.zeros(max(a) + 1)
a.sort()
a += [10**7]
r = 0
for i, j in zip(a, a[1:]):
if l[i] == 0:
l[::i] = 1
if i != j:
r += 1
print(r)
| false | 0 | [
"-n = int(eval(input()))",
"-a = [int(j) for j in input().split()] + [10**7]",
"+n, *a = list(map(int, open(0).read().split()))",
"+a += [10**7]"
] | false | 0.913955 | 0.311827 | 2.930969 | [
"s325367539",
"s140034278"
] |
u023846178 | p02389 | python | s064044034 | s616166510 | 20 | 10 | 4,192 | 4,192 | Accepted | Accepted | 50 | n = [int(i) for i in input().split()]
print(n[0]*n[1], 2*(n[0]+n[1])) | n = list(map(int, input().split()))
print(n[0] * n[1], 2 * (n[0] + n[1])) | 2 | 2 | 73 | 71 | n = [int(i) for i in input().split()]
print(n[0] * n[1], 2 * (n[0] + n[1]))
| n = list(map(int, input().split()))
print(n[0] * n[1], 2 * (n[0] + n[1]))
| false | 0 | [
"-n = [int(i) for i in input().split()]",
"+n = list(map(int, input().split()))"
] | false | 0.048413 | 0.049038 | 0.987245 | [
"s064044034",
"s616166510"
] |
u325282913 | p03476 | python | s228833449 | s982446981 | 1,092 | 836 | 4,980 | 4,980 | Accepted | Accepted | 23.44 | import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
Q = int(eval(input()))
ans = [0] * (10**5+1)
prime = [0] * (10**5+1)
for i in range(1,10**5+1):
if is_prime(i):
prime[i] = 1
if prime[(i+1)//2] == 1:
ans[i] = ans[i-1] + 1
continue
ans[i] = ans[i-1]
disp_ans = 0
for i in range(Q):
l, r = list(map(int, input().split()))
print((ans[r]-ans[l-1])) | def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return is_prime
Q = int(eval(input()))
ans = [0] * (10**5+1)
prime = primes(10**5)
for i in range(1,10**5+1):
if prime[i] == 1 and prime[(i+1)//2] == 1:
ans[i] = ans[i-1] + 1
continue
ans[i] = ans[i-1]
for i in range(Q):
l, r = list(map(int, input().split()))
print((ans[r]-ans[l-1])) | 21 | 21 | 523 | 583 | import math
def is_prime(n):
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
Q = int(eval(input()))
ans = [0] * (10**5 + 1)
prime = [0] * (10**5 + 1)
for i in range(1, 10**5 + 1):
if is_prime(i):
prime[i] = 1
if prime[(i + 1) // 2] == 1:
ans[i] = ans[i - 1] + 1
continue
ans[i] = ans[i - 1]
disp_ans = 0
for i in range(Q):
l, r = list(map(int, input().split()))
print((ans[r] - ans[l - 1]))
| def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return is_prime
Q = int(eval(input()))
ans = [0] * (10**5 + 1)
prime = primes(10**5)
for i in range(1, 10**5 + 1):
if prime[i] == 1 and prime[(i + 1) // 2] == 1:
ans[i] = ans[i - 1] + 1
continue
ans[i] = ans[i - 1]
for i in range(Q):
l, r = list(map(int, input().split()))
print((ans[r] - ans[l - 1]))
| false | 0 | [
"-import math",
"-",
"-",
"-def is_prime(n):",
"- if n == 1:",
"- return False",
"- for k in range(2, int(math.sqrt(n)) + 1):",
"- if n % k == 0:",
"- return False",
"- return True",
"+def primes(n):",
"+ is_prime = [True] * (n + 1)",
"+ is_prime[0] = False",
"+ is_prime[1] = False",
"+ for i in range(2, int(n**0.5) + 1):",
"+ if not is_prime[i]:",
"+ continue",
"+ for j in range(i * 2, n + 1, i):",
"+ is_prime[j] = False",
"+ return is_prime",
"-prime = [0] * (10**5 + 1)",
"+prime = primes(10**5)",
"- if is_prime(i):",
"- prime[i] = 1",
"- if prime[(i + 1) // 2] == 1:",
"- ans[i] = ans[i - 1] + 1",
"- continue",
"+ if prime[i] == 1 and prime[(i + 1) // 2] == 1:",
"+ ans[i] = ans[i - 1] + 1",
"+ continue",
"-disp_ans = 0"
] | false | 0.584947 | 0.132478 | 4.41543 | [
"s228833449",
"s982446981"
] |
u597374218 | p03399 | python | s915191996 | s138471246 | 21 | 17 | 3,316 | 2,940 | Accepted | Accepted | 19.05 | f=lambda:min(int(eval(input())),int(eval(input())))
print((f()+f())) | A, B, C, D = [int(eval(input())) for _ in range(4)]
print((min(A, B)+min(C, D))) | 2 | 2 | 55 | 73 | f = lambda: min(int(eval(input())), int(eval(input())))
print((f() + f()))
| A, B, C, D = [int(eval(input())) for _ in range(4)]
print((min(A, B) + min(C, D)))
| false | 0 | [
"-f = lambda: min(int(eval(input())), int(eval(input())))",
"-print((f() + f()))",
"+A, B, C, D = [int(eval(input())) for _ in range(4)]",
"+print((min(A, B) + min(C, D)))"
] | false | 0.047834 | 0.037991 | 1.259083 | [
"s915191996",
"s138471246"
] |
u498487134 | p02882 | python | s212082976 | s910053461 | 172 | 70 | 38,512 | 62,488 | Accepted | Accepted | 59.3 | import math
a,b,x = list(map(int,input().split()))
h=x/(a*a)
if h>(b/2):
c=(b-h)*2
ans = math.atan2(c,a)
else:
d=2*a*h/b
ans=math.atan2(b,d)
print((math.degrees(ans))) | import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
import math
mod=10**9+7
a,b,x3=MI()
x=x3/(a**2) #引数勘違いしてた
if (a*b)//2 >= a*x :
y=(2*a*x)/b
th=math.atan2(b,y)
else:
rem=a*(b-x)
z=rem*2/a
th=math.atan2(z,a)
print((th/math.pi * 180))
main()
| 12 | 27 | 188 | 493 | import math
a, b, x = list(map(int, input().split()))
h = x / (a * a)
if h > (b / 2):
c = (b - h) * 2
ans = math.atan2(c, a)
else:
d = 2 * a * h / b
ans = math.atan2(b, d)
print((math.degrees(ans)))
| import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
import math
mod = 10**9 + 7
a, b, x3 = MI()
x = x3 / (a**2) # 引数勘違いしてた
if (a * b) // 2 >= a * x:
y = (2 * a * x) / b
th = math.atan2(b, y)
else:
rem = a * (b - x)
z = rem * 2 / a
th = math.atan2(z, a)
print((th / math.pi * 180))
main()
| false | 55.555556 | [
"-import math",
"+import sys",
"-a, b, x = list(map(int, input().split()))",
"-h = x / (a * a)",
"-if h > (b / 2):",
"- c = (b - h) * 2",
"- ans = math.atan2(c, a)",
"-else:",
"- d = 2 * a * h / b",
"- ans = math.atan2(b, d)",
"-print((math.degrees(ans)))",
"+input = sys.stdin.readline",
"+",
"+",
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def main():",
"+ import math",
"+",
"+ mod = 10**9 + 7",
"+ a, b, x3 = MI()",
"+ x = x3 / (a**2) # 引数勘違いしてた",
"+ if (a * b) // 2 >= a * x:",
"+ y = (2 * a * x) / b",
"+ th = math.atan2(b, y)",
"+ else:",
"+ rem = a * (b - x)",
"+ z = rem * 2 / a",
"+ th = math.atan2(z, a)",
"+ print((th / math.pi * 180))",
"+",
"+",
"+main()"
] | false | 0.034123 | 0.035877 | 0.951128 | [
"s212082976",
"s910053461"
] |
u363407238 | p02971 | python | s235598875 | s507973921 | 334 | 241 | 12,532 | 25,036 | Accepted | Accepted | 27.84 | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
max_i = 0
max_num = 0
sec_num = 0
for i in range(n):
if a[i] > max_num:
max_num = a[i]
max_i = i
a.sort(reverse=True)
for i in range(n):
if i != max_i:
print(max_num)
else:
print((a[1]))
| # import sys
# input = sys.stdin.readline
# n = int(input())
# a = [int(input()) for _ in range(n)]
#
# max_i = 0
# max_num = 0
# for i in range(n):
# if a[i] > max_num:
# max_num = a[i]
# max_i = i
#
# a.sort(reverse=True)
#
# for i in range(n):
# if i != max_i:
# print(max_num)
# else:
# print(a[1])
n,*a=list(map(int,open(0).read().split()))
ma=max(a)
# 最大値のインデックスを取得
ma_index=a.index(ma)
for i in range(n):
if i==ma_index:
# 最大値を除いた配列の最大値を出力
print((max(a[:i]+a[i+1:])))
else:
print(ma) | 20 | 30 | 343 | 588 | import sys
input = sys.stdin.readline
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
max_i = 0
max_num = 0
sec_num = 0
for i in range(n):
if a[i] > max_num:
max_num = a[i]
max_i = i
a.sort(reverse=True)
for i in range(n):
if i != max_i:
print(max_num)
else:
print((a[1]))
| # import sys
# input = sys.stdin.readline
# n = int(input())
# a = [int(input()) for _ in range(n)]
#
# max_i = 0
# max_num = 0
# for i in range(n):
# if a[i] > max_num:
# max_num = a[i]
# max_i = i
#
# a.sort(reverse=True)
#
# for i in range(n):
# if i != max_i:
# print(max_num)
# else:
# print(a[1])
n, *a = list(map(int, open(0).read().split()))
ma = max(a)
# 最大値のインデックスを取得
ma_index = a.index(ma)
for i in range(n):
if i == ma_index:
# 最大値を除いた配列の最大値を出力
print((max(a[:i] + a[i + 1 :])))
else:
print(ma)
| false | 33.333333 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-n = int(eval(input()))",
"-a = [int(eval(input())) for _ in range(n)]",
"-max_i = 0",
"-max_num = 0",
"-sec_num = 0",
"+# import sys",
"+# input = sys.stdin.readline",
"+# n = int(input())",
"+# a = [int(input()) for _ in range(n)]",
"+#",
"+# max_i = 0",
"+# max_num = 0",
"+# for i in range(n):",
"+# if a[i] > max_num:",
"+# max_num = a[i]",
"+# max_i = i",
"+#",
"+# a.sort(reverse=True)",
"+#",
"+# for i in range(n):",
"+# if i != max_i:",
"+# print(max_num)",
"+# else:",
"+# print(a[1])",
"+n, *a = list(map(int, open(0).read().split()))",
"+ma = max(a)",
"+# 最大値のインデックスを取得",
"+ma_index = a.index(ma)",
"- if a[i] > max_num:",
"- max_num = a[i]",
"- max_i = i",
"-a.sort(reverse=True)",
"-for i in range(n):",
"- if i != max_i:",
"- print(max_num)",
"+ if i == ma_index:",
"+ # 最大値を除いた配列の最大値を出力",
"+ print((max(a[:i] + a[i + 1 :])))",
"- print((a[1]))",
"+ print(ma)"
] | false | 0.104303 | 0.201968 | 0.516434 | [
"s235598875",
"s507973921"
] |
u233588813 | p02936 | python | s607408238 | s598198313 | 1,610 | 1,345 | 79,540 | 105,236 | Accepted | Accepted | 16.46 | from collections import deque
import sys
def main():
a,b=list(map(int,sys.stdin.readline().split()))
e=[[]for i in range(a)]
for i in range(a-1):
c1,c2=list(map(int,sys.stdin.readline().split()))
e[c1-1].append(c2-1)
e[c2-1].append(c1-1)
g=[[]for i in range(a)]
f=deque()
f.append((0,-1))
ans=[0 for _ in range(a)]
for i in range(b):
ten,p=list(map(int,input().split()))
ans[ten-1]+=p
i=0
while len(f)!=0:
i,fr=f.popleft()
for j in e[i]:
if j==fr:
continue
else:
ans[j]+=ans[i]
f.append([j,i])
print((*ans))
if __name__ == '__main__':
main()
| from collections import deque
import sys
def main():
a,b=list(map(int,sys.stdin.readline().split()))
e=[[]for i in range(a)]
for i in range(a-1):
c1,c2=list(map(int,sys.stdin.readline().split()))
e[c1-1].append(c2-1)
e[c2-1].append(c1-1)
g=[[]for i in range(a)]
f=deque()
f.append((0,-1))
ans=[0 for _ in range(a)]
for i in range(b):
ten,p=list(map(int,input().split()))
ans[ten-1]+=p
i=0
while len(f)!=0:
i,fr=f.popleft()
for j in e[i]:
if j==fr:
continue
else:
ans[j]+=ans[i]
f.append((j,i))
print((*ans))
if __name__ == '__main__':
main()
| 35 | 35 | 664 | 664 | from collections import deque
import sys
def main():
a, b = list(map(int, sys.stdin.readline().split()))
e = [[] for i in range(a)]
for i in range(a - 1):
c1, c2 = list(map(int, sys.stdin.readline().split()))
e[c1 - 1].append(c2 - 1)
e[c2 - 1].append(c1 - 1)
g = [[] for i in range(a)]
f = deque()
f.append((0, -1))
ans = [0 for _ in range(a)]
for i in range(b):
ten, p = list(map(int, input().split()))
ans[ten - 1] += p
i = 0
while len(f) != 0:
i, fr = f.popleft()
for j in e[i]:
if j == fr:
continue
else:
ans[j] += ans[i]
f.append([j, i])
print((*ans))
if __name__ == "__main__":
main()
| from collections import deque
import sys
def main():
a, b = list(map(int, sys.stdin.readline().split()))
e = [[] for i in range(a)]
for i in range(a - 1):
c1, c2 = list(map(int, sys.stdin.readline().split()))
e[c1 - 1].append(c2 - 1)
e[c2 - 1].append(c1 - 1)
g = [[] for i in range(a)]
f = deque()
f.append((0, -1))
ans = [0 for _ in range(a)]
for i in range(b):
ten, p = list(map(int, input().split()))
ans[ten - 1] += p
i = 0
while len(f) != 0:
i, fr = f.popleft()
for j in e[i]:
if j == fr:
continue
else:
ans[j] += ans[i]
f.append((j, i))
print((*ans))
if __name__ == "__main__":
main()
| false | 0 | [
"- f.append([j, i])",
"+ f.append((j, i))"
] | false | 0.048297 | 0.039567 | 1.22063 | [
"s607408238",
"s598198313"
] |
u900848560 | p02933 | python | s999989185 | s173153802 | 172 | 17 | 38,256 | 2,940 | Accepted | Accepted | 90.12 | a=eval(input())
b=eval(input())
if int(a)>=3200:
print(b)
else:
print("red") | a=eval(input())
b=eval(input())
if int(a)>=3200:
print(b)
elif int(a)<3200:
print("red")
| 6 | 6 | 72 | 87 | a = eval(input())
b = eval(input())
if int(a) >= 3200:
print(b)
else:
print("red")
| a = eval(input())
b = eval(input())
if int(a) >= 3200:
print(b)
elif int(a) < 3200:
print("red")
| false | 0 | [
"-else:",
"+elif int(a) < 3200:"
] | false | 0.036825 | 0.036229 | 1.016455 | [
"s999989185",
"s173153802"
] |
u576432509 | p03862 | python | s076173059 | s319759334 | 133 | 80 | 14,152 | 14,540 | Accepted | Accepted | 39.85 |
n,x=list(map(int,input().split()))
a=list(map(int,input().split()))
cdy=0
for i in range(n-1):
ai=a[i]
aip=a[i+1]
if a[i]>x:
a[i]=x
cdy=cdy+ai-x
ai=a[i]
if a[i]+a[i+1]>x:
a[i+1]=x-a[i]
cdy=cdy+ai+aip-x
print(cdy)
| n,x=list(map(int,input().split()))
a=list(map(int,input().split()))
asum=sum(a)
if a[0]>x:
a[0]=x
for i in range(n-1):
if a[i]+a[i+1]>x:
a[i+1]=x-a[i]
asum=asum-sum(a)
print(asum) | 18 | 13 | 295 | 216 | n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
cdy = 0
for i in range(n - 1):
ai = a[i]
aip = a[i + 1]
if a[i] > x:
a[i] = x
cdy = cdy + ai - x
ai = a[i]
if a[i] + a[i + 1] > x:
a[i + 1] = x - a[i]
cdy = cdy + ai + aip - x
print(cdy)
| n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
asum = sum(a)
if a[0] > x:
a[0] = x
for i in range(n - 1):
if a[i] + a[i + 1] > x:
a[i + 1] = x - a[i]
asum = asum - sum(a)
print(asum)
| false | 27.777778 | [
"-cdy = 0",
"+asum = sum(a)",
"+if a[0] > x:",
"+ a[0] = x",
"- ai = a[i]",
"- aip = a[i + 1]",
"- if a[i] > x:",
"- a[i] = x",
"- cdy = cdy + ai - x",
"- ai = a[i]",
"- cdy = cdy + ai + aip - x",
"-print(cdy)",
"+asum = asum - sum(a)",
"+print(asum)"
] | false | 0.13662 | 0.037597 | 3.633852 | [
"s076173059",
"s319759334"
] |
u703950586 | p03739 | python | s911235927 | s366083006 | 321 | 241 | 61,928 | 61,288 | Accepted | Accepted | 24.92 | import sys,queue,math,copy,itertools,bisect,collections,heapq
def main():
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
n = NI()
bit = [0] * (n+1)
def add(i,x):
while i <= n:
bit[i] += x
i += i & -i
def query(i):
x = 0
while i > 0:
x += bit[i]
i -= i & -i
return x
for i,a in enumerate(LI()):
add(i+1,int(a))
ans = INF
b = [bit,copy.copy(bit)]
for s in (1,-1):
bit = b[(s+1)//2]
cnt = 0
x = s
for i in range(1,n+1):
z = query(i)
if z * x <= 0:
add(i,x-z)
cnt += abs(x-z)
x = -x
ans = min(ans,cnt)
print(ans)
if __name__ == '__main__':
main() | import sys,queue,math,copy,itertools,bisect,collections,heapq
def main():
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
n = NI()
a = LI()
ans = INF
for s in (1,-1):
acc = 0
cnt = 0
x = s
for i in range(n):
acc += a[i]
if acc * x <= 0:
cnt += abs(x-acc)
acc = x
x = -x
ans = min(ans,cnt)
print(ans)
if __name__ == '__main__':
main() | 46 | 28 | 964 | 627 | import sys, queue, math, copy, itertools, bisect, collections, heapq
def main():
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
NI = lambda: int(sys.stdin.readline())
n = NI()
bit = [0] * (n + 1)
def add(i, x):
while i <= n:
bit[i] += x
i += i & -i
def query(i):
x = 0
while i > 0:
x += bit[i]
i -= i & -i
return x
for i, a in enumerate(LI()):
add(i + 1, int(a))
ans = INF
b = [bit, copy.copy(bit)]
for s in (1, -1):
bit = b[(s + 1) // 2]
cnt = 0
x = s
for i in range(1, n + 1):
z = query(i)
if z * x <= 0:
add(i, x - z)
cnt += abs(x - z)
x = -x
ans = min(ans, cnt)
print(ans)
if __name__ == "__main__":
main()
| import sys, queue, math, copy, itertools, bisect, collections, heapq
def main():
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
NI = lambda: int(sys.stdin.readline())
n = NI()
a = LI()
ans = INF
for s in (1, -1):
acc = 0
cnt = 0
x = s
for i in range(n):
acc += a[i]
if acc * x <= 0:
cnt += abs(x - acc)
acc = x
x = -x
ans = min(ans, cnt)
print(ans)
if __name__ == "__main__":
main()
| false | 39.130435 | [
"- bit = [0] * (n + 1)",
"-",
"- def add(i, x):",
"- while i <= n:",
"- bit[i] += x",
"- i += i & -i",
"-",
"- def query(i):",
"- x = 0",
"- while i > 0:",
"- x += bit[i]",
"- i -= i & -i",
"- return x",
"-",
"- for i, a in enumerate(LI()):",
"- add(i + 1, int(a))",
"+ a = LI()",
"- b = [bit, copy.copy(bit)]",
"- bit = b[(s + 1) // 2]",
"+ acc = 0",
"- for i in range(1, n + 1):",
"- z = query(i)",
"- if z * x <= 0:",
"- add(i, x - z)",
"- cnt += abs(x - z)",
"+ for i in range(n):",
"+ acc += a[i]",
"+ if acc * x <= 0:",
"+ cnt += abs(x - acc)",
"+ acc = x"
] | false | 0.077174 | 0.046638 | 1.65475 | [
"s911235927",
"s366083006"
] |
u684120680 | p03290 | python | s273378498 | s396541335 | 165 | 28 | 3,064 | 3,064 | Accepted | Accepted | 83.03 | d, g = [int(i) for i in input().split()]
score = 0
p = []
c = []
for i in range(d):
p_tmp, c_tmp = [int(i) for i in input().split()]
p.append(p_tmp)
c.append(c_tmp)
num = []
for i in range(2**d):
num_tmp = 0
score = 0
not_comp = []
for j in range(d):
if i >> j & 1:
score += p[j] * 100 * (j+1) + c[j]
num_tmp += p[j]
else:
not_comp.append(j)
for j in not_comp[::-1]:
for k in range(p[j]-1):
if score < g:
score += 100 * (j+1)
num_tmp += 1
else:
break
else:
continue
break
if score >= g:
num.append(num_tmp)
ans = min(num)
print(ans)
| d, g = [int(i) for i in input().split()]
score = 0
p = []
c = []
for i in range(d):
p_tmp, c_tmp = [int(i) for i in input().split()]
p.append(p_tmp)
c.append(c_tmp)
num = []
for i in range(2**d):
num_tmp = 0
score = 0
not_comp = []
for j in range(d):
if i >> j & 1:
score += p[j] * 100 * (j+1) + c[j]
num_tmp += p[j]
else:
not_comp.append(j)
for j in not_comp[::-1]:
if score < g:
num_j = min(p[j]-1, (g-score-1)//(100*(j+1))+1)
score += num_j * 100*(j+1)
num_tmp += num_j
if score >= g:
num.append(num_tmp)
ans = min(num)
print(ans)
| 37 | 32 | 777 | 709 | d, g = [int(i) for i in input().split()]
score = 0
p = []
c = []
for i in range(d):
p_tmp, c_tmp = [int(i) for i in input().split()]
p.append(p_tmp)
c.append(c_tmp)
num = []
for i in range(2**d):
num_tmp = 0
score = 0
not_comp = []
for j in range(d):
if i >> j & 1:
score += p[j] * 100 * (j + 1) + c[j]
num_tmp += p[j]
else:
not_comp.append(j)
for j in not_comp[::-1]:
for k in range(p[j] - 1):
if score < g:
score += 100 * (j + 1)
num_tmp += 1
else:
break
else:
continue
break
if score >= g:
num.append(num_tmp)
ans = min(num)
print(ans)
| d, g = [int(i) for i in input().split()]
score = 0
p = []
c = []
for i in range(d):
p_tmp, c_tmp = [int(i) for i in input().split()]
p.append(p_tmp)
c.append(c_tmp)
num = []
for i in range(2**d):
num_tmp = 0
score = 0
not_comp = []
for j in range(d):
if i >> j & 1:
score += p[j] * 100 * (j + 1) + c[j]
num_tmp += p[j]
else:
not_comp.append(j)
for j in not_comp[::-1]:
if score < g:
num_j = min(p[j] - 1, (g - score - 1) // (100 * (j + 1)) + 1)
score += num_j * 100 * (j + 1)
num_tmp += num_j
if score >= g:
num.append(num_tmp)
ans = min(num)
print(ans)
| false | 13.513514 | [
"- for k in range(p[j] - 1):",
"- if score < g:",
"- score += 100 * (j + 1)",
"- num_tmp += 1",
"- else:",
"- break",
"- else:",
"- continue",
"- break",
"+ if score < g:",
"+ num_j = min(p[j] - 1, (g - score - 1) // (100 * (j + 1)) + 1)",
"+ score += num_j * 100 * (j + 1)",
"+ num_tmp += num_j"
] | false | 0.03814 | 0.036556 | 1.043318 | [
"s273378498",
"s396541335"
] |
u826929627 | p02720 | python | s910110588 | s397219621 | 939 | 382 | 42,992 | 5,892 | Accepted | Accepted | 59.32 | K = int(eval(input()))
d = [1,2,3,4,5,6,7,8,9]
if K <= 9:
print(K)
exit()
cnt = 9
while cnt < K:
_ = d.pop(0)
matsubi = _%10
if matsubi == 0:
d.append(_*10+matsubi)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_*10+matsubi+1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
elif matsubi == 9:
d.append(_*10+matsubi-1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_*10+matsubi)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
else:
d.append(_*10+matsubi-1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_*10+matsubi)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_*10+matsubi+1)
cnt += 1
if cnt == K:
print((d[-1]))
exit() | K = int(eval(input()))
d = [1,2,3,4,5,6,7,8,9]
if K <= 9:
print(K)
exit()
cnt = 9
while cnt < K:
_ = d.pop(0)
matsubi = _%10
if matsubi == 0:
d.append(_*10+matsubi)
d.append(_*10+matsubi+1)
cnt += 2
elif matsubi == 9:
d.append(_*10+matsubi-1)
d.append(_*10+matsubi)
cnt += 2
else:
d.append(_*10+matsubi-1)
d.append(_*10+matsubi)
d.append(_*10+matsubi+1)
cnt += 3
ans = -1*(cnt - K + 1)
print((d[ans])) | 54 | 30 | 871 | 490 | K = int(eval(input()))
d = [1, 2, 3, 4, 5, 6, 7, 8, 9]
if K <= 9:
print(K)
exit()
cnt = 9
while cnt < K:
_ = d.pop(0)
matsubi = _ % 10
if matsubi == 0:
d.append(_ * 10 + matsubi)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_ * 10 + matsubi + 1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
elif matsubi == 9:
d.append(_ * 10 + matsubi - 1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_ * 10 + matsubi)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
else:
d.append(_ * 10 + matsubi - 1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_ * 10 + matsubi)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
d.append(_ * 10 + matsubi + 1)
cnt += 1
if cnt == K:
print((d[-1]))
exit()
| K = int(eval(input()))
d = [1, 2, 3, 4, 5, 6, 7, 8, 9]
if K <= 9:
print(K)
exit()
cnt = 9
while cnt < K:
_ = d.pop(0)
matsubi = _ % 10
if matsubi == 0:
d.append(_ * 10 + matsubi)
d.append(_ * 10 + matsubi + 1)
cnt += 2
elif matsubi == 9:
d.append(_ * 10 + matsubi - 1)
d.append(_ * 10 + matsubi)
cnt += 2
else:
d.append(_ * 10 + matsubi - 1)
d.append(_ * 10 + matsubi)
d.append(_ * 10 + matsubi + 1)
cnt += 3
ans = -1 * (cnt - K + 1)
print((d[ans]))
| false | 44.444444 | [
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"+ cnt += 2",
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"+ cnt += 2",
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"- cnt += 1",
"- if cnt == K:",
"- print((d[-1]))",
"- exit()",
"+ cnt += 3",
"+ans = -1 * (cnt - K + 1)",
"+print((d[ans]))"
] | false | 0.08258 | 0.187926 | 0.439431 | [
"s910110588",
"s397219621"
] |
u661764795 | p02614 | python | s871443001 | s159382516 | 155 | 80 | 27,024 | 73,896 | Accepted | Accepted | 48.39 | import numpy as np
H, W, K = input().split(' ')
H = int(H)
W = int(W)
K = int(K)
c = [list(str(eval(input()))) for i in range(H)]
cnp = np.array(c)
countAll = np.count_nonzero(cnp == '#')
countH = []
countW = []
for i in range(H):
countH.append(np.count_nonzero(cnp[i] == '#'))
for i in range(W):
countW.append(np.count_nonzero(cnp[:, i] == '#'))
ans = 0
for i in range(2 ** H - 1):
for j in range(2 ** W - 1):
tmp = countAll
tmp2 = []
choiceH = format(i, '0' + str(H) + 'b')
for m in range(len(choiceH)):
if int(choiceH[m]):
tmp -= countH[m]
tmp2.append(m)
choiceW = format(j, '0' + str(W) + 'b')
for n in range(len(choiceW)):
if int(choiceW[n]):
tmp -= countW[n]
for o in range(len(tmp2)):
if cnp[tmp2[o], n] == '#':
tmp += 1
if tmp == K:
ans += 1
print(ans) | import itertools
H, W, K = list(map(int, input().split()))
c = [list(str(eval(input()))) for i in range(H)]
ans = 0
for i in itertools.product(list(range(2)), repeat=H+W):
cnt = 0
for j in itertools.product(list(range(H)), list(range(W))):
if i[j[0]]:
continue
if i[H+j[1]]:
continue
if c[j[0]][j[1]] == '#':
cnt += 1
if cnt == K:
ans += 1
print(ans) | 38 | 19 | 1,007 | 421 | import numpy as np
H, W, K = input().split(" ")
H = int(H)
W = int(W)
K = int(K)
c = [list(str(eval(input()))) for i in range(H)]
cnp = np.array(c)
countAll = np.count_nonzero(cnp == "#")
countH = []
countW = []
for i in range(H):
countH.append(np.count_nonzero(cnp[i] == "#"))
for i in range(W):
countW.append(np.count_nonzero(cnp[:, i] == "#"))
ans = 0
for i in range(2**H - 1):
for j in range(2**W - 1):
tmp = countAll
tmp2 = []
choiceH = format(i, "0" + str(H) + "b")
for m in range(len(choiceH)):
if int(choiceH[m]):
tmp -= countH[m]
tmp2.append(m)
choiceW = format(j, "0" + str(W) + "b")
for n in range(len(choiceW)):
if int(choiceW[n]):
tmp -= countW[n]
for o in range(len(tmp2)):
if cnp[tmp2[o], n] == "#":
tmp += 1
if tmp == K:
ans += 1
print(ans)
| import itertools
H, W, K = list(map(int, input().split()))
c = [list(str(eval(input()))) for i in range(H)]
ans = 0
for i in itertools.product(list(range(2)), repeat=H + W):
cnt = 0
for j in itertools.product(list(range(H)), list(range(W))):
if i[j[0]]:
continue
if i[H + j[1]]:
continue
if c[j[0]][j[1]] == "#":
cnt += 1
if cnt == K:
ans += 1
print(ans)
| false | 50 | [
"-import numpy as np",
"+import itertools",
"-H, W, K = input().split(\" \")",
"-H = int(H)",
"-W = int(W)",
"-K = int(K)",
"+H, W, K = list(map(int, input().split()))",
"-cnp = np.array(c)",
"-countAll = np.count_nonzero(cnp == \"#\")",
"-countH = []",
"-countW = []",
"-for i in range(H):",
"- countH.append(np.count_nonzero(cnp[i] == \"#\"))",
"-for i in range(W):",
"- countW.append(np.count_nonzero(cnp[:, i] == \"#\"))",
"-for i in range(2**H - 1):",
"- for j in range(2**W - 1):",
"- tmp = countAll",
"- tmp2 = []",
"- choiceH = format(i, \"0\" + str(H) + \"b\")",
"- for m in range(len(choiceH)):",
"- if int(choiceH[m]):",
"- tmp -= countH[m]",
"- tmp2.append(m)",
"- choiceW = format(j, \"0\" + str(W) + \"b\")",
"- for n in range(len(choiceW)):",
"- if int(choiceW[n]):",
"- tmp -= countW[n]",
"- for o in range(len(tmp2)):",
"- if cnp[tmp2[o], n] == \"#\":",
"- tmp += 1",
"- if tmp == K:",
"- ans += 1",
"+for i in itertools.product(list(range(2)), repeat=H + W):",
"+ cnt = 0",
"+ for j in itertools.product(list(range(H)), list(range(W))):",
"+ if i[j[0]]:",
"+ continue",
"+ if i[H + j[1]]:",
"+ continue",
"+ if c[j[0]][j[1]] == \"#\":",
"+ cnt += 1",
"+ if cnt == K:",
"+ ans += 1"
] | false | 0.184924 | 0.084625 | 2.185231 | [
"s871443001",
"s159382516"
] |
u721316601 | p03339 | python | s601151687 | s958421024 | 239 | 195 | 3,828 | 15,644 | Accepted | Accepted | 18.41 | N = int(eval(input()))
S = eval(input())
min_count = N
left = {'W':0, 'E':0}
w = S.count('W')
right = {'W':w, 'E':N-w}
for i in range(N):
base = S[i]
right[base] -= 1
min_count = min(left['W']+right['E'], min_count)
left[base] += 1
print(min_count) | from collections import deque
N = int(eval(input()))
S = eval(input())
count = deque()
left = {'W':0, 'E':0}
w = S.count('W')
right = {'W':w, 'E':N-w}
for i in range(N):
base = S[i]
right[base] -= 1
count.append(left['W']+right['E'])
left[base] += 1
print((min(count))) | 15 | 17 | 269 | 291 | N = int(eval(input()))
S = eval(input())
min_count = N
left = {"W": 0, "E": 0}
w = S.count("W")
right = {"W": w, "E": N - w}
for i in range(N):
base = S[i]
right[base] -= 1
min_count = min(left["W"] + right["E"], min_count)
left[base] += 1
print(min_count)
| from collections import deque
N = int(eval(input()))
S = eval(input())
count = deque()
left = {"W": 0, "E": 0}
w = S.count("W")
right = {"W": w, "E": N - w}
for i in range(N):
base = S[i]
right[base] -= 1
count.append(left["W"] + right["E"])
left[base] += 1
print((min(count)))
| false | 11.764706 | [
"+from collections import deque",
"+",
"-min_count = N",
"+count = deque()",
"- min_count = min(left[\"W\"] + right[\"E\"], min_count)",
"+ count.append(left[\"W\"] + right[\"E\"])",
"-print(min_count)",
"+print((min(count)))"
] | false | 0.110154 | 0.119617 | 0.920892 | [
"s601151687",
"s958421024"
] |
u579699847 | p03160 | python | s755613008 | s028441985 | 260 | 237 | 56,264 | 52,208 | Accepted | Accepted | 8.85 | import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
h = [None]+LI()
dp = [float('INF')]*(N+1) #1_indexed
dp[1] = 0
for i,j in itertools.product(list(range(1,N+1)),[1,2]):
if i+j>=N+1:
continue
dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print((dp[-1]))
| import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i in range(N):
if i-1>=0:
dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
if i-2>=0:
dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print((dp[-1])) | 12 | 13 | 372 | 369 | import itertools, sys
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N = I()
h = [None] + LI()
dp = [float("INF")] * (N + 1) # 1_indexed
dp[1] = 0
for i, j in itertools.product(list(range(1, N + 1)), [1, 2]):
if i + j >= N + 1:
continue
dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print((dp[-1]))
| import itertools, sys
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N = I()
h = LI()
dp = [float("INF")] * N
dp[0] = 0
for i in range(N):
if i - 1 >= 0:
dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i - 2 >= 0:
dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))
| false | 7.692308 | [
"-h = [None] + LI()",
"-dp = [float(\"INF\")] * (N + 1) # 1_indexed",
"-dp[1] = 0",
"-for i, j in itertools.product(list(range(1, N + 1)), [1, 2]):",
"- if i + j >= N + 1:",
"- continue",
"- dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))",
"+h = LI()",
"+dp = [float(\"INF\")] * N",
"+dp[0] = 0",
"+for i in range(N):",
"+ if i - 1 >= 0:",
"+ dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))",
"+ if i - 2 >= 0:",
"+ dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))"
] | false | 0.055234 | 0.054356 | 1.016154 | [
"s755613008",
"s028441985"
] |
u225388820 | p02571 | python | s206505390 | s775813991 | 95 | 37 | 67,228 | 9,104 | Accepted | Accepted | 61.05 | s, t = eval(input()), eval(input())
def d(s, t):
cnt = 0
for i in range(len(s)):
if s[i] != t[i]:
cnt += 1
return cnt
n = len(s)
m = len(t)
ans = 1000000
for i in range(n - m + 1):
ans = min(ans, d(s[i:i + m], t))
print(ans)
| def d(s, t):
cnt = 0
for i in range(len(s)):
if s[i] != t[i]:
cnt += 1
return cnt
s, t = eval(input()), eval(input())
n = len(s)
m = len(t)
ans = 1000000
print((min(d(s[i:i + m], t) for i in range(n - m + 1))))
| 17 | 13 | 269 | 243 | s, t = eval(input()), eval(input())
def d(s, t):
cnt = 0
for i in range(len(s)):
if s[i] != t[i]:
cnt += 1
return cnt
n = len(s)
m = len(t)
ans = 1000000
for i in range(n - m + 1):
ans = min(ans, d(s[i : i + m], t))
print(ans)
| def d(s, t):
cnt = 0
for i in range(len(s)):
if s[i] != t[i]:
cnt += 1
return cnt
s, t = eval(input()), eval(input())
n = len(s)
m = len(t)
ans = 1000000
print((min(d(s[i : i + m], t) for i in range(n - m + 1))))
| false | 23.529412 | [
"-s, t = eval(input()), eval(input())",
"-",
"-",
"+s, t = eval(input()), eval(input())",
"-for i in range(n - m + 1):",
"- ans = min(ans, d(s[i : i + m], t))",
"-print(ans)",
"+print((min(d(s[i : i + m], t) for i in range(n - m + 1))))"
] | false | 0.036641 | 0.036745 | 0.997184 | [
"s206505390",
"s775813991"
] |
u591503175 | p02843 | python | s166855476 | s177361183 | 52 | 17 | 16,904 | 3,060 | Accepted | Accepted | 67.31 | import itertools as it
num = int(eval(input()))
item_number = num//100
if item_number>= 20:
item_number = 20
res_list = []
candi_list = list(it.combinations_with_replacement([100, 101, 102, 103, 104, 105], item_number))
candi_ans_list = [sum(item) for item in candi_list]
if num >= 2000:
print((1))
else:
if num in candi_ans_list:
print((1))
else:
print((0))
| import itertools as it
num = int(eval(input()))
item_number = num//100
temp_val = num%100
times = temp_val //15
temp_val = temp_val % 15
if temp_val <= 5:
temp_val = 1
elif temp_val <= 10:
temp_val = 2
else:
temp_val =3
need_item_number = 3*times + temp_val
# print(item_number)
# print(times)
# print(need_item_number)
if item_number >= need_item_number:
print((1))
else:
print((0)) | 21 | 27 | 405 | 426 | import itertools as it
num = int(eval(input()))
item_number = num // 100
if item_number >= 20:
item_number = 20
res_list = []
candi_list = list(
it.combinations_with_replacement([100, 101, 102, 103, 104, 105], item_number)
)
candi_ans_list = [sum(item) for item in candi_list]
if num >= 2000:
print((1))
else:
if num in candi_ans_list:
print((1))
else:
print((0))
| import itertools as it
num = int(eval(input()))
item_number = num // 100
temp_val = num % 100
times = temp_val // 15
temp_val = temp_val % 15
if temp_val <= 5:
temp_val = 1
elif temp_val <= 10:
temp_val = 2
else:
temp_val = 3
need_item_number = 3 * times + temp_val
# print(item_number)
# print(times)
# print(need_item_number)
if item_number >= need_item_number:
print((1))
else:
print((0))
| false | 22.222222 | [
"-if item_number >= 20:",
"- item_number = 20",
"-res_list = []",
"-candi_list = list(",
"- it.combinations_with_replacement([100, 101, 102, 103, 104, 105], item_number)",
"-)",
"-candi_ans_list = [sum(item) for item in candi_list]",
"-if num >= 2000:",
"+temp_val = num % 100",
"+times = temp_val // 15",
"+temp_val = temp_val % 15",
"+if temp_val <= 5:",
"+ temp_val = 1",
"+elif temp_val <= 10:",
"+ temp_val = 2",
"+else:",
"+ temp_val = 3",
"+need_item_number = 3 * times + temp_val",
"+# print(item_number)",
"+# print(times)",
"+# print(need_item_number)",
"+if item_number >= need_item_number:",
"- if num in candi_ans_list:",
"- print((1))",
"- else:",
"- print((0))",
"+ print((0))"
] | false | 0.048232 | 0.078872 | 0.611517 | [
"s166855476",
"s177361183"
] |
u186838327 | p02603 | python | s524503529 | s748443438 | 62 | 26 | 61,956 | 9,092 | Accepted | Accepted | 58.06 | def main():
n = int(eval(input()))
A = list(map(int, input().split()))
INF = 19**18
X = []
Y = []
A = [INF] + A
for i in range(1, n):
if len(X) == len(Y):
if A[i-1] >= A[i] and A[i] < A[i+1]:
X.append(i)
if len(X) > len(Y):
if A[i-1] <= A[i] and A[i] > A[i+1]:
Y.append(i)
else:
if len(X) > len(Y):
Y.append(i+1)
#print(X)
#print(Y)
cur = 1000
for i, j in zip(X, Y):
q, cur = divmod(cur, A[i])
cur += q*A[j]
print(cur)
if __name__ == '__main__':
main()
| n = int(eval(input()))
A = list(map(int, input().split()))
x = 1000
for i in range(n-1):
if A[i] < A[i+1]:
q, x = divmod(x, A[i])
x += q*A[i+1]
print(x) | 32 | 9 | 649 | 175 | def main():
n = int(eval(input()))
A = list(map(int, input().split()))
INF = 19**18
X = []
Y = []
A = [INF] + A
for i in range(1, n):
if len(X) == len(Y):
if A[i - 1] >= A[i] and A[i] < A[i + 1]:
X.append(i)
if len(X) > len(Y):
if A[i - 1] <= A[i] and A[i] > A[i + 1]:
Y.append(i)
else:
if len(X) > len(Y):
Y.append(i + 1)
# print(X)
# print(Y)
cur = 1000
for i, j in zip(X, Y):
q, cur = divmod(cur, A[i])
cur += q * A[j]
print(cur)
if __name__ == "__main__":
main()
| n = int(eval(input()))
A = list(map(int, input().split()))
x = 1000
for i in range(n - 1):
if A[i] < A[i + 1]:
q, x = divmod(x, A[i])
x += q * A[i + 1]
print(x)
| false | 71.875 | [
"-def main():",
"- n = int(eval(input()))",
"- A = list(map(int, input().split()))",
"- INF = 19**18",
"- X = []",
"- Y = []",
"- A = [INF] + A",
"- for i in range(1, n):",
"- if len(X) == len(Y):",
"- if A[i - 1] >= A[i] and A[i] < A[i + 1]:",
"- X.append(i)",
"- if len(X) > len(Y):",
"- if A[i - 1] <= A[i] and A[i] > A[i + 1]:",
"- Y.append(i)",
"- else:",
"- if len(X) > len(Y):",
"- Y.append(i + 1)",
"- # print(X)",
"- # print(Y)",
"- cur = 1000",
"- for i, j in zip(X, Y):",
"- q, cur = divmod(cur, A[i])",
"- cur += q * A[j]",
"- print(cur)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+n = int(eval(input()))",
"+A = list(map(int, input().split()))",
"+x = 1000",
"+for i in range(n - 1):",
"+ if A[i] < A[i + 1]:",
"+ q, x = divmod(x, A[i])",
"+ x += q * A[i + 1]",
"+print(x)"
] | false | 0.066313 | 0.06072 | 1.092114 | [
"s524503529",
"s748443438"
] |
u736546944 | p02659 | python | s689696229 | s005383811 | 189 | 65 | 77,588 | 61,728 | Accepted | Accepted | 65.61 | import math
from decimal import Decimal
a, b = list(map(str, input().split()))
a = Decimal(a)
b = Decimal(b)
ans = a*b
print((math.floor(ans))) | a, b = list(map(str, input().split()))
a = int(a)
b = int(b.replace(".", ""))
ans = a*b
if ans <= 99:
print((0))
else:
print((str(ans)[:-2])) | 7 | 8 | 141 | 142 | import math
from decimal import Decimal
a, b = list(map(str, input().split()))
a = Decimal(a)
b = Decimal(b)
ans = a * b
print((math.floor(ans)))
| a, b = list(map(str, input().split()))
a = int(a)
b = int(b.replace(".", ""))
ans = a * b
if ans <= 99:
print((0))
else:
print((str(ans)[:-2]))
| false | 12.5 | [
"-import math",
"-from decimal import Decimal",
"-",
"-a = Decimal(a)",
"-b = Decimal(b)",
"+a = int(a)",
"+b = int(b.replace(\".\", \"\"))",
"-print((math.floor(ans)))",
"+if ans <= 99:",
"+ print((0))",
"+else:",
"+ print((str(ans)[:-2]))"
] | false | 0.044775 | 0.057868 | 0.773742 | [
"s689696229",
"s005383811"
] |
u418149936 | p02731 | python | s408783420 | s022943923 | 25 | 23 | 9,104 | 9,184 | Accepted | Accepted | 8 | L = int(eval(input()))
print(((L/3)**3)) | print(((int(eval(input())) / 3) ** 3)) | 2 | 1 | 33 | 30 | L = int(eval(input()))
print(((L / 3) ** 3))
| print(((int(eval(input())) / 3) ** 3))
| false | 50 | [
"-L = int(eval(input()))",
"-print(((L / 3) ** 3))",
"+print(((int(eval(input())) / 3) ** 3))"
] | false | 0.039226 | 0.046854 | 0.837194 | [
"s408783420",
"s022943923"
] |
u221149873 | p02726 | python | s460823436 | s219102496 | 1,909 | 1,197 | 3,444 | 3,444 | Accepted | Accepted | 37.3 | n,x,y = list(map(int,input().split()))
dists = [0]*(n)
for i in range(1,n+1):
for j in range(1,i):
dists[min(abs(i-j),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y))]+=1
for i in range(1,len(dists)):
print((dists[i])) | n,x,y = list(map(int,input().split()))
dists = [0]*(n)
for i in range(1,n+1):
for j in range(1,i):
dists[min(i-j,abs(j-x)+1+abs(i-y))]+=1
for i in range(1,len(dists)):
print((dists[i])) | 8 | 8 | 230 | 205 | n, x, y = list(map(int, input().split()))
dists = [0] * (n)
for i in range(1, n + 1):
for j in range(1, i):
dists[
min(abs(i - j), abs(i - x) + 1 + abs(j - y), abs(j - x) + 1 + abs(i - y))
] += 1
for i in range(1, len(dists)):
print((dists[i]))
| n, x, y = list(map(int, input().split()))
dists = [0] * (n)
for i in range(1, n + 1):
for j in range(1, i):
dists[min(i - j, abs(j - x) + 1 + abs(i - y))] += 1
for i in range(1, len(dists)):
print((dists[i]))
| false | 0 | [
"- dists[",
"- min(abs(i - j), abs(i - x) + 1 + abs(j - y), abs(j - x) + 1 + abs(i - y))",
"- ] += 1",
"+ dists[min(i - j, abs(j - x) + 1 + abs(i - y))] += 1"
] | false | 0.006609 | 0.075572 | 0.087458 | [
"s460823436",
"s219102496"
] |
u628070051 | p02784 | python | s952003046 | s729511310 | 65 | 51 | 20,504 | 20,460 | Accepted | Accepted | 21.54 | H, N = list(map(int, input().split()))
A = list(map(int, input().split()))
def answer(H: int, N: int, A: list) -> str:
damage = 0
for i in range(0, N):
damage += int(A[i])
i += 1
if damage < H:
return 'No'
else:
return 'Yes'
print((answer(H, N, A)))
| H, N = list(map(int,input().split()))
A = list(map(int,input().split()))
if H <= sum(A):
print("Yes")
else:
print("No") | 15 | 7 | 307 | 128 | H, N = list(map(int, input().split()))
A = list(map(int, input().split()))
def answer(H: int, N: int, A: list) -> str:
damage = 0
for i in range(0, N):
damage += int(A[i])
i += 1
if damage < H:
return "No"
else:
return "Yes"
print((answer(H, N, A)))
| H, N = list(map(int, input().split()))
A = list(map(int, input().split()))
if H <= sum(A):
print("Yes")
else:
print("No")
| false | 53.333333 | [
"-",
"-",
"-def answer(H: int, N: int, A: list) -> str:",
"- damage = 0",
"- for i in range(0, N):",
"- damage += int(A[i])",
"- i += 1",
"- if damage < H:",
"- return \"No\"",
"- else:",
"- return \"Yes\"",
"-",
"-",
"-print((answer(H, N, A)))",
"+if H <= sum(A):",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"
] | false | 0.036013 | 0.047521 | 0.75782 | [
"s952003046",
"s729511310"
] |
u143492911 | p03945 | python | s358439149 | s559968752 | 49 | 43 | 3,956 | 3,956 | Accepted | Accepted | 12.24 | s=list(eval(input()))
sl=len(s)
cnt=0
for i in range(sl-1):
if s[i]=="W":
if s[i+1]=="B":
cnt+=1
elif s[i]=="B":
if s[i+1]=="W":
cnt+=1
print(cnt) | s=list(eval(input()))
sl=len(s)
cnt=0
for i in range(1,sl):
if s[i]!=s[i-1]:
cnt+=1
print(cnt)
| 11 | 8 | 198 | 116 | s = list(eval(input()))
sl = len(s)
cnt = 0
for i in range(sl - 1):
if s[i] == "W":
if s[i + 1] == "B":
cnt += 1
elif s[i] == "B":
if s[i + 1] == "W":
cnt += 1
print(cnt)
| s = list(eval(input()))
sl = len(s)
cnt = 0
for i in range(1, sl):
if s[i] != s[i - 1]:
cnt += 1
print(cnt)
| false | 27.272727 | [
"-for i in range(sl - 1):",
"- if s[i] == \"W\":",
"- if s[i + 1] == \"B\":",
"- cnt += 1",
"- elif s[i] == \"B\":",
"- if s[i + 1] == \"W\":",
"- cnt += 1",
"+for i in range(1, sl):",
"+ if s[i] != s[i - 1]:",
"+ cnt += 1"
] | false | 0.044527 | 0.03832 | 1.161979 | [
"s358439149",
"s559968752"
] |
u874320250 | p02678 | python | s699660269 | s647034379 | 1,976 | 393 | 180,612 | 126,832 | Accepted | Accepted | 80.11 | import sys, heapq, math
input = sys.stdin.readline
N, M = list(map(int, input().split()))
path = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
path[a-1].add(b-1)
path[b-1].add(a-1)
h = [(0, 0, 0)] # 距離, id, 直前のid
heapq.heapify(h)
cost = [[math.inf, -1]]*N
while len(h) != 0:
d, idx, pre_idx = heapq.heappop(h)
if cost[idx][0] <= d:
continue
cost[idx] = [d, pre_idx]
for next_idx in path[idx]:
if cost[next_idx] == math.inf:
continue
heapq.heappush(h, (d+1, next_idx, idx))
if max(cost)[0] == math.inf:
print('No')
sys.exit()
print('Yes')
for d, pre_idx in cost[1:]:
print((pre_idx+1))
| import sys, math
input = sys.stdin.readline
N, M = list(map(int, input().split()))
path = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
path[a-1].add(b-1)
path[b-1].add(a-1)
cost = [[math.inf, -1]]*N
cost[0] = [0, 0]
pre = [0]
for d in range(N):
next = []
for i in pre:
for j in path[i]:
if cost[j][0] != math.inf:
continue
cost[j] = [d, i]
next.append(j)
pre = next
if len(next)==0:
break
if max(cost)[0] == math.inf:
print('No')
sys.exit()
print('Yes')
for d, pre_idx in cost[1:]:
print((pre_idx+1))
| 33 | 34 | 724 | 673 | import sys, heapq, math
input = sys.stdin.readline
N, M = list(map(int, input().split()))
path = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
path[a - 1].add(b - 1)
path[b - 1].add(a - 1)
h = [(0, 0, 0)] # 距離, id, 直前のid
heapq.heapify(h)
cost = [[math.inf, -1]] * N
while len(h) != 0:
d, idx, pre_idx = heapq.heappop(h)
if cost[idx][0] <= d:
continue
cost[idx] = [d, pre_idx]
for next_idx in path[idx]:
if cost[next_idx] == math.inf:
continue
heapq.heappush(h, (d + 1, next_idx, idx))
if max(cost)[0] == math.inf:
print("No")
sys.exit()
print("Yes")
for d, pre_idx in cost[1:]:
print((pre_idx + 1))
| import sys, math
input = sys.stdin.readline
N, M = list(map(int, input().split()))
path = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
path[a - 1].add(b - 1)
path[b - 1].add(a - 1)
cost = [[math.inf, -1]] * N
cost[0] = [0, 0]
pre = [0]
for d in range(N):
next = []
for i in pre:
for j in path[i]:
if cost[j][0] != math.inf:
continue
cost[j] = [d, i]
next.append(j)
pre = next
if len(next) == 0:
break
if max(cost)[0] == math.inf:
print("No")
sys.exit()
print("Yes")
for d, pre_idx in cost[1:]:
print((pre_idx + 1))
| false | 2.941176 | [
"-import sys, heapq, math",
"+import sys, math",
"-h = [(0, 0, 0)] # 距離, id, 直前のid",
"-heapq.heapify(h)",
"-while len(h) != 0:",
"- d, idx, pre_idx = heapq.heappop(h)",
"- if cost[idx][0] <= d:",
"- continue",
"- cost[idx] = [d, pre_idx]",
"- for next_idx in path[idx]:",
"- if cost[next_idx] == math.inf:",
"- continue",
"- heapq.heappush(h, (d + 1, next_idx, idx))",
"+cost[0] = [0, 0]",
"+pre = [0]",
"+for d in range(N):",
"+ next = []",
"+ for i in pre:",
"+ for j in path[i]:",
"+ if cost[j][0] != math.inf:",
"+ continue",
"+ cost[j] = [d, i]",
"+ next.append(j)",
"+ pre = next",
"+ if len(next) == 0:",
"+ break"
] | false | 0.064289 | 0.035787 | 1.79641 | [
"s699660269",
"s647034379"
] |
u699296734 | p03606 | python | s259030566 | s259227904 | 56 | 26 | 9,436 | 9,036 | Accepted | Accepted | 53.57 | n = int(eval(input()))
# seat = [0] * 10 ** 6
seat = [0] * 10 ** 5
for i in range(n):
l, r = list(map(int, input().split()))
for j in range(l, r + 1):
seat[j - 1] = 1
res = 0
# for i in range(10 ** 6):
for i in range(10 ** 5):
if seat[i] == 1:
res += 1
print(res)
| n = int(eval(input()))
res = 0
for i in range(n):
r, l = list(map(int, input().split()))
res += l - r + 1
print(res)
| 14 | 6 | 294 | 118 | n = int(eval(input()))
# seat = [0] * 10 ** 6
seat = [0] * 10**5
for i in range(n):
l, r = list(map(int, input().split()))
for j in range(l, r + 1):
seat[j - 1] = 1
res = 0
# for i in range(10 ** 6):
for i in range(10**5):
if seat[i] == 1:
res += 1
print(res)
| n = int(eval(input()))
res = 0
for i in range(n):
r, l = list(map(int, input().split()))
res += l - r + 1
print(res)
| false | 57.142857 | [
"-# seat = [0] * 10 ** 6",
"-seat = [0] * 10**5",
"+res = 0",
"- l, r = list(map(int, input().split()))",
"- for j in range(l, r + 1):",
"- seat[j - 1] = 1",
"-res = 0",
"-# for i in range(10 ** 6):",
"-for i in range(10**5):",
"- if seat[i] == 1:",
"- res += 1",
"+ r, l = list(map(int, input().split()))",
"+ res += l - r + 1"
] | false | 0.067178 | 0.044939 | 1.494881 | [
"s259030566",
"s259227904"
] |
u721316601 | p03722 | python | s236302867 | s552100224 | 1,870 | 25 | 3,312 | 3,388 | Accepted | Accepted | 98.66 | def main():
INF = float('inf')
N, M = list(map(int, input().split()))
dist = [0] + [INF] * (N-1)
abc = []
for i in range(M):
a, b, c = list(map(int, input().split()))
abc.append((a, b, -c))
for i in range(N-1):
for a, b, c in abc:
if dist[a-1] == INF:
continue
dist[b-1] = min(dist[b-1], dist[a-1]+c)
ans = dist[-1]
negative = [False] * N
for i in range(N):
for a, b, c in abc:
if dist[a-1] == INF:
continue
elif dist[b-1] > dist[a-1]+c:
dist[b-1] = dist[a-1]+c
negative[b-1] = True
if negative[a-1]:
negative[b-1] = True
if negative[-1]:
print('inf')
else:
print((-ans))
if __name__ == '__main__':
main()
| def main():
INF = float('inf')
N, M = list(map(int, input().split()))
dist = [0] + [INF] * (N-1)
abc = []
for i in range(M):
a, b, c = list(map(int, input().split()))
abc.append((a-1, b-1, -c))
for a, b, c in abc:
dist[b] = min(dist[b], dist[a]+c)
ans = dist[-1]
for a, b, c in abc:
dist[b] = min(dist[b], dist[a]+c)
if ans != dist[-1]:
print('inf')
else:
print((-ans))
if __name__ == '__main__':
main() | 37 | 25 | 914 | 551 | def main():
INF = float("inf")
N, M = list(map(int, input().split()))
dist = [0] + [INF] * (N - 1)
abc = []
for i in range(M):
a, b, c = list(map(int, input().split()))
abc.append((a, b, -c))
for i in range(N - 1):
for a, b, c in abc:
if dist[a - 1] == INF:
continue
dist[b - 1] = min(dist[b - 1], dist[a - 1] + c)
ans = dist[-1]
negative = [False] * N
for i in range(N):
for a, b, c in abc:
if dist[a - 1] == INF:
continue
elif dist[b - 1] > dist[a - 1] + c:
dist[b - 1] = dist[a - 1] + c
negative[b - 1] = True
if negative[a - 1]:
negative[b - 1] = True
if negative[-1]:
print("inf")
else:
print((-ans))
if __name__ == "__main__":
main()
| def main():
INF = float("inf")
N, M = list(map(int, input().split()))
dist = [0] + [INF] * (N - 1)
abc = []
for i in range(M):
a, b, c = list(map(int, input().split()))
abc.append((a - 1, b - 1, -c))
for a, b, c in abc:
dist[b] = min(dist[b], dist[a] + c)
ans = dist[-1]
for a, b, c in abc:
dist[b] = min(dist[b], dist[a] + c)
if ans != dist[-1]:
print("inf")
else:
print((-ans))
if __name__ == "__main__":
main()
| false | 32.432432 | [
"- abc.append((a, b, -c))",
"- for i in range(N - 1):",
"- for a, b, c in abc:",
"- if dist[a - 1] == INF:",
"- continue",
"- dist[b - 1] = min(dist[b - 1], dist[a - 1] + c)",
"+ abc.append((a - 1, b - 1, -c))",
"+ for a, b, c in abc:",
"+ dist[b] = min(dist[b], dist[a] + c)",
"- negative = [False] * N",
"- for i in range(N):",
"- for a, b, c in abc:",
"- if dist[a - 1] == INF:",
"- continue",
"- elif dist[b - 1] > dist[a - 1] + c:",
"- dist[b - 1] = dist[a - 1] + c",
"- negative[b - 1] = True",
"- if negative[a - 1]:",
"- negative[b - 1] = True",
"- if negative[-1]:",
"+ for a, b, c in abc:",
"+ dist[b] = min(dist[b], dist[a] + c)",
"+ if ans != dist[-1]:"
] | false | 0.041029 | 0.040945 | 1.00206 | [
"s236302867",
"s552100224"
] |
u018679195 | p03795 | python | s701587396 | s162997782 | 18 | 10 | 2,940 | 2,568 | Accepted | Accepted | 44.44 | n = int(eval(input()))
x = 800*n
y = (n // 15) * 200
print((x-y)) | x = int(input())
print((x*800 - (x/15) * 200))
"""code length ...... """ | 7 | 4 | 66 | 78 | n = int(eval(input()))
x = 800 * n
y = (n // 15) * 200
print((x - y))
| x = int(input())
print((x * 800 - (x / 15) * 200))
"""code length ...... """
| false | 42.857143 | [
"-n = int(eval(input()))",
"-x = 800 * n",
"-y = (n // 15) * 200",
"-print((x - y))",
"+x = int(input())",
"+print((x * 800 - (x / 15) * 200))",
"+\"\"\"code length ...... \"\"\""
] | false | 0.122363 | 0.040912 | 2.990876 | [
"s701587396",
"s162997782"
] |
u691018832 | p02936 | python | s160526737 | s101627864 | 1,297 | 1,154 | 72,080 | 56,024 | Accepted | Accepted | 11.03 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict, deque
n, q = list(map(int, readline().split()))
graph = defaultdict(list)
for i in range(n - 1):
u, v = list(map(int, readline().split()))
graph[u - 1].append(v - 1)
graph[v - 1].append(u - 1)
v = [0] * n
for i in range(q):
p, x = list(map(int, readline().split()))
v[p - 1] += x
def dfs(s):
check = [False] * n
stack = deque([s])
while stack:
now = stack.pop()
check[now] = True
for next in graph[now]:
if check[next]:
continue
v[next] += v[now]
stack.appendleft(next)
dfs(0)
print((*v))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
from collections import deque
n, q = list(map(int, readline().split()))
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, readline().split()))
graph[a].append(b)
graph[b].append(a)
cnt = [0] * (n + 1)
for i in range(q):
p, x = list(map(int, readline().split()))
cnt[p] += x
def dfs(s):
check = [False] * (n + 1)
stack = deque([s])
while stack:
now = stack.pop()
check[now] = True
for nxt in graph[now]:
if check[nxt]:
continue
stack.appendleft(nxt)
cnt[nxt] += cnt[now]
dfs(1)
print((*cnt[1:]))
| 35 | 35 | 801 | 799 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from collections import defaultdict, deque
n, q = list(map(int, readline().split()))
graph = defaultdict(list)
for i in range(n - 1):
u, v = list(map(int, readline().split()))
graph[u - 1].append(v - 1)
graph[v - 1].append(u - 1)
v = [0] * n
for i in range(q):
p, x = list(map(int, readline().split()))
v[p - 1] += x
def dfs(s):
check = [False] * n
stack = deque([s])
while stack:
now = stack.pop()
check[now] = True
for next in graph[now]:
if check[next]:
continue
v[next] += v[now]
stack.appendleft(next)
dfs(0)
print((*v))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
from collections import deque
n, q = list(map(int, readline().split()))
graph = [[] for _ in range(n + 1)]
for i in range(n - 1):
a, b = list(map(int, readline().split()))
graph[a].append(b)
graph[b].append(a)
cnt = [0] * (n + 1)
for i in range(q):
p, x = list(map(int, readline().split()))
cnt[p] += x
def dfs(s):
check = [False] * (n + 1)
stack = deque([s])
while stack:
now = stack.pop()
check[now] = True
for nxt in graph[now]:
if check[nxt]:
continue
stack.appendleft(nxt)
cnt[nxt] += cnt[now]
dfs(1)
print((*cnt[1:]))
| false | 0 | [
"-from collections import defaultdict, deque",
"+from collections import deque",
"-graph = defaultdict(list)",
"+graph = [[] for _ in range(n + 1)]",
"- u, v = list(map(int, readline().split()))",
"- graph[u - 1].append(v - 1)",
"- graph[v - 1].append(u - 1)",
"-v = [0] * n",
"+ a, b = list(map(int, readline().split()))",
"+ graph[a].append(b)",
"+ graph[b].append(a)",
"+cnt = [0] * (n + 1)",
"- v[p - 1] += x",
"+ cnt[p] += x",
"- check = [False] * n",
"+ check = [False] * (n + 1)",
"- for next in graph[now]:",
"- if check[next]:",
"+ for nxt in graph[now]:",
"+ if check[nxt]:",
"- v[next] += v[now]",
"- stack.appendleft(next)",
"+ stack.appendleft(nxt)",
"+ cnt[nxt] += cnt[now]",
"-dfs(0)",
"-print((*v))",
"+dfs(1)",
"+print((*cnt[1:]))"
] | false | 0.047975 | 0.046456 | 1.032695 | [
"s160526737",
"s101627864"
] |
u561231954 | p03325 | python | s964937916 | s130887138 | 65 | 56 | 4,148 | 10,112 | Accepted | Accepted | 13.85 | n=int(eval(input()))
num=list(map(int,input().split()))
cnt=0
def cnt_2(n):
cnt=0
while n>1:
if n%2==0:
n//=2
cnt+=1
else:
break
return cnt
for i in num:
cnt+=cnt_2(i)
print(cnt) | import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
def main():
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for a in A:
while a%2 == 0:
ans += 1
a >>= 1
print(ans)
if __name__ == '__main__':
main() | 16 | 16 | 226 | 309 | n = int(eval(input()))
num = list(map(int, input().split()))
cnt = 0
def cnt_2(n):
cnt = 0
while n > 1:
if n % 2 == 0:
n //= 2
cnt += 1
else:
break
return cnt
for i in num:
cnt += cnt_2(i)
print(cnt)
| import sys
sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for a in A:
while a % 2 == 0:
ans += 1
a >>= 1
print(ans)
if __name__ == "__main__":
main()
| false | 0 | [
"-n = int(eval(input()))",
"-num = list(map(int, input().split()))",
"-cnt = 0",
"+import sys",
"+",
"+sys.setrecursionlimit(10000000)",
"+MOD = 10**9 + 7",
"+INF = 10**15",
"-def cnt_2(n):",
"- cnt = 0",
"- while n > 1:",
"- if n % 2 == 0:",
"- n //= 2",
"- cnt += 1",
"- else:",
"- break",
"- return cnt",
"+def main():",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ ans = 0",
"+ for a in A:",
"+ while a % 2 == 0:",
"+ ans += 1",
"+ a >>= 1",
"+ print(ans)",
"-for i in num:",
"- cnt += cnt_2(i)",
"-print(cnt)",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.083456 | 0.037648 | 2.216742 | [
"s964937916",
"s130887138"
] |
u814986259 | p02996 | python | s037924959 | s461197588 | 1,344 | 841 | 55,192 | 31,824 | Accepted | Accepted | 37.43 | N = int(eval(input()))
AB = [[0]*2 for i in range(N)]
for i in range(N):
AB[i] = list(map(int, input().split()))
AB = sorted(AB, key=lambda x: x[1])
time = 0
for i in range(N):
time += AB[i][0]
if time > AB[i][1]:
print("No")
exit(0)
print("Yes")
| N = int(eval(input()))
AB = [tuple(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[1])
t = 0
for a, b in AB:
t += a
if t <= b:
continue
else:
print("No")
exit(0)
print("Yes")
| 16 | 14 | 288 | 242 | N = int(eval(input()))
AB = [[0] * 2 for i in range(N)]
for i in range(N):
AB[i] = list(map(int, input().split()))
AB = sorted(AB, key=lambda x: x[1])
time = 0
for i in range(N):
time += AB[i][0]
if time > AB[i][1]:
print("No")
exit(0)
print("Yes")
| N = int(eval(input()))
AB = [tuple(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[1])
t = 0
for a, b in AB:
t += a
if t <= b:
continue
else:
print("No")
exit(0)
print("Yes")
| false | 12.5 | [
"-AB = [[0] * 2 for i in range(N)]",
"-for i in range(N):",
"- AB[i] = list(map(int, input().split()))",
"-AB = sorted(AB, key=lambda x: x[1])",
"-time = 0",
"-for i in range(N):",
"- time += AB[i][0]",
"- if time > AB[i][1]:",
"+AB = [tuple(map(int, input().split())) for i in range(N)]",
"+AB.sort(key=lambda x: x[1])",
"+t = 0",
"+for a, b in AB:",
"+ t += a",
"+ if t <= b:",
"+ continue",
"+ else:"
] | false | 0.06539 | 0.042889 | 1.524616 | [
"s037924959",
"s461197588"
] |
u198336369 | p03331 | python | s860984579 | s616254712 | 395 | 223 | 9,652 | 9,208 | Accepted | Accepted | 43.54 | n = int(eval(input()))
absum = []
for a in range(1,n):
b = n-a
asum = 0
bsum = 0
alen = len(str(a))
blen = len(str(b))
for j in range(alen):
a0 = (a//(10**j)) % 10
asum = asum + a0
for k in range(blen):
b0 = (b//(10**k)) % 10
bsum = bsum + b0
absum.append(asum+bsum)
print((min(absum))) | n = int(eval(input()))
absum = []
for a in range(1,n//2+1):
b = n-a
asum = 0
bsum = 0
alen = len(str(a))
blen = len(str(b))
for j in range(alen):
a0 = (a//(10**j)) % 10
asum = asum + a0
for k in range(blen):
b0 = (b//(10**k)) % 10
bsum = bsum + b0
absum.append(asum+bsum)
print((min(absum))) | 16 | 16 | 361 | 364 | n = int(eval(input()))
absum = []
for a in range(1, n):
b = n - a
asum = 0
bsum = 0
alen = len(str(a))
blen = len(str(b))
for j in range(alen):
a0 = (a // (10**j)) % 10
asum = asum + a0
for k in range(blen):
b0 = (b // (10**k)) % 10
bsum = bsum + b0
absum.append(asum + bsum)
print((min(absum)))
| n = int(eval(input()))
absum = []
for a in range(1, n // 2 + 1):
b = n - a
asum = 0
bsum = 0
alen = len(str(a))
blen = len(str(b))
for j in range(alen):
a0 = (a // (10**j)) % 10
asum = asum + a0
for k in range(blen):
b0 = (b // (10**k)) % 10
bsum = bsum + b0
absum.append(asum + bsum)
print((min(absum)))
| false | 0 | [
"-for a in range(1, n):",
"+for a in range(1, n // 2 + 1):"
] | false | 0.395133 | 0.349224 | 1.13146 | [
"s860984579",
"s616254712"
] |
u681444474 | p03273 | python | s601400799 | s000829390 | 40 | 26 | 5,216 | 3,188 | Accepted | Accepted | 35 | # coding: utf-8
import fractions
#N = int(input())
h, w = list(map(int,input().split()))
h_list = []
w_list = []
F = []
for i in range(h):
l = list(eval(input()))
F.append(l)
if list(set(l)) == ['.']:
w_list.append(i)
for i in range(w):
cnt = 0
for j in range(h):
if F[j][i] == '.':
cnt += 1
else:
break
if cnt == h:
h_list.append(i)
A = []
#print(h_list,w_list)#ここまでOK
for i in range(h):
if i not in w_list:
l = []
for j in range(w):
if j not in h_list:
#print(F[i][j])
l.append(F[i][j])
A.append(l)
for i in range(len(A)):
print((''.join(A[i]))) | # coding: utf-8
h, w = list(map(int,input().split()))
A = []
for i in range(h):
l = list(eval(input()))
if list(set(l)) == ['.']:
h -= 1
else:
A.append(l)
#for a in A:
#print(a)
Ans = []
for i in range(w):
cnt = 0
for j in range(h):
if A[j][i] == '.':
cnt += 1
if cnt == h:
Ans.append(i)
for i in Ans:
for j in range(h):
A[j][i] = ''
for a in A:
print((''.join(a))) | 37 | 28 | 745 | 470 | # coding: utf-8
import fractions
# N = int(input())
h, w = list(map(int, input().split()))
h_list = []
w_list = []
F = []
for i in range(h):
l = list(eval(input()))
F.append(l)
if list(set(l)) == ["."]:
w_list.append(i)
for i in range(w):
cnt = 0
for j in range(h):
if F[j][i] == ".":
cnt += 1
else:
break
if cnt == h:
h_list.append(i)
A = []
# print(h_list,w_list)#ここまでOK
for i in range(h):
if i not in w_list:
l = []
for j in range(w):
if j not in h_list:
# print(F[i][j])
l.append(F[i][j])
A.append(l)
for i in range(len(A)):
print(("".join(A[i])))
| # coding: utf-8
h, w = list(map(int, input().split()))
A = []
for i in range(h):
l = list(eval(input()))
if list(set(l)) == ["."]:
h -= 1
else:
A.append(l)
# for a in A:
# print(a)
Ans = []
for i in range(w):
cnt = 0
for j in range(h):
if A[j][i] == ".":
cnt += 1
if cnt == h:
Ans.append(i)
for i in Ans:
for j in range(h):
A[j][i] = ""
for a in A:
print(("".join(a)))
| false | 24.324324 | [
"-import fractions",
"-",
"-# N = int(input())",
"-h_list = []",
"-w_list = []",
"-F = []",
"+A = []",
"- F.append(l)",
"- w_list.append(i)",
"+ h -= 1",
"+ else:",
"+ A.append(l)",
"+# for a in A:",
"+# print(a)",
"+Ans = []",
"- if F[j][i] == \".\":",
"+ if A[j][i] == \".\":",
"- else:",
"- break",
"- h_list.append(i)",
"-A = []",
"-# print(h_list,w_list)#ここまでOK",
"-for i in range(h):",
"- if i not in w_list:",
"- l = []",
"- for j in range(w):",
"- if j not in h_list:",
"- # print(F[i][j])",
"- l.append(F[i][j])",
"- A.append(l)",
"-for i in range(len(A)):",
"- print((\"\".join(A[i])))",
"+ Ans.append(i)",
"+for i in Ans:",
"+ for j in range(h):",
"+ A[j][i] = \"\"",
"+for a in A:",
"+ print((\"\".join(a)))"
] | false | 0.037368 | 0.04571 | 0.8175 | [
"s601400799",
"s000829390"
] |
u638795007 | p04033 | python | s130047415 | s095449914 | 166 | 58 | 38,256 | 5,864 | Accepted | Accepted | 65.06 | def examA():
a, b = LI()
if a>0:
ans = "Positive"
print(ans)
return
if b>=0:
ans = "Zero"
else:
judge = b-a
if judge%2==1:
ans = "Positive"
else:
ans = "Negative"
print(ans)
return
import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')
if __name__ == '__main__':
examA()
| def examA():
a, b = LI()
if b<a:
a,b = b,a
if a<=0 and 0<=b:
print("Zero")
elif 0<a:
print("Positive")
else:
judge = b-a+1
if judge%2==0:
print("Positive")
else:
print("Negative")
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]
sys.setrecursionlimit(10**6)
if __name__ == '__main__':
examA()
"""
""" | 30 | 65 | 784 | 1,254 | def examA():
a, b = LI()
if a > 0:
ans = "Positive"
print(ans)
return
if b >= 0:
ans = "Zero"
else:
judge = b - a
if judge % 2 == 1:
ans = "Positive"
else:
ans = "Negative"
print(ans)
return
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float("inf")
if __name__ == "__main__":
examA()
| def examA():
a, b = LI()
if b < a:
a, b = b, a
if a <= 0 and 0 <= b:
print("Zero")
elif 0 < a:
print("Positive")
else:
judge = b - a + 1
if judge % 2 == 0:
print("Positive")
else:
print("Negative")
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
import sys, bisect, itertools, heapq, math, random
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10 ** (-12)
alphabet = [chr(ord("a") + i) for i in range(26)]
sys.setrecursionlimit(10**6)
if __name__ == "__main__":
examA()
"""
"""
| false | 53.846154 | [
"- if a > 0:",
"- ans = \"Positive\"",
"- print(ans)",
"- return",
"- if b >= 0:",
"- ans = \"Zero\"",
"+ if b < a:",
"+ a, b = b, a",
"+ if a <= 0 and 0 <= b:",
"+ print(\"Zero\")",
"+ elif 0 < a:",
"+ print(\"Positive\")",
"- judge = b - a",
"- if judge % 2 == 1:",
"- ans = \"Positive\"",
"+ judge = b - a + 1",
"+ if judge % 2 == 0:",
"+ print(\"Positive\")",
"- ans = \"Negative\"",
"+ print(\"Negative\")",
"+ return",
"+",
"+",
"+def examB():",
"+ ans = 0",
"-import sys, copy, bisect, itertools, heapq, math",
"+def examC():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examD():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examE():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+def examF():",
"+ ans = 0",
"+ print(ans)",
"+ return",
"+",
"+",
"+import sys, bisect, itertools, heapq, math, random",
"+from copy import deepcopy",
"+global mod, mod2, inf, alphabet, _ep",
"-inf = float(\"inf\")",
"+mod2 = 998244353",
"+inf = 10**18",
"+_ep = 10 ** (-12)",
"+alphabet = [chr(ord(\"a\") + i) for i in range(26)]",
"+sys.setrecursionlimit(10**6)",
"+\"\"\"",
"+\"\"\""
] | false | 0.046464 | 0.064692 | 0.718244 | [
"s130047415",
"s095449914"
] |
u073852194 | p03911 | python | s356555883 | s135017454 | 531 | 248 | 48,900 | 87,780 | Accepted | Accepted | 53.3 | N,M = list(map(int,input().split()))
K = []
L = []
for _ in range(N):
k,*l = list(map(int,input().split()))
K.append(k)
L.append(l)
graph = [[] for _ in range(N+M)]
for i in range(N):
for l in L[i]:
graph[i].append(N+l-1)
graph[N+l-1].append(i)
visited = [0 for _ in range(N+M)]
visited[0] = 1
stack = [0]
while stack:
node = stack.pop()
for adj in graph[node]:
if not visited[adj]:
visited[adj] = 1
stack.append(adj)
print(('YES' if all(visited[:N]) else 'NO')) | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n)]
self.size = [1 for _ in range(n)]
def find(self, x):
root = x
while self.parents[root] != root:
root = self.parents[root]
return root
def unite(self, x, y):
xroot = self.find(x)
yroot = self.find(y)
if xroot == yroot: return
if self.size[xroot] <= self.size[yroot]:
self.parents[xroot] = yroot
self.size[yroot] += self.size[xroot]
else:
self.parents[yroot] = xroot
self.size[xroot] += self.size[yroot]
N, M = list(map(int, input().split()))
uf = UnionFind(M)
L = []
for _ in range(N):
k, *l = list(map(int, input().split()))
for i in range(1, k):
uf.unite(l[0] - 1, l[i] - 1)
L.append(l[0] - 1)
if len(set([uf.find(L[i]) for i in range(N)])) == 1:
print('YES')
else:
print('NO') | 26 | 38 | 565 | 987 | N, M = list(map(int, input().split()))
K = []
L = []
for _ in range(N):
k, *l = list(map(int, input().split()))
K.append(k)
L.append(l)
graph = [[] for _ in range(N + M)]
for i in range(N):
for l in L[i]:
graph[i].append(N + l - 1)
graph[N + l - 1].append(i)
visited = [0 for _ in range(N + M)]
visited[0] = 1
stack = [0]
while stack:
node = stack.pop()
for adj in graph[node]:
if not visited[adj]:
visited[adj] = 1
stack.append(adj)
print(("YES" if all(visited[:N]) else "NO"))
| class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n)]
self.size = [1 for _ in range(n)]
def find(self, x):
root = x
while self.parents[root] != root:
root = self.parents[root]
return root
def unite(self, x, y):
xroot = self.find(x)
yroot = self.find(y)
if xroot == yroot:
return
if self.size[xroot] <= self.size[yroot]:
self.parents[xroot] = yroot
self.size[yroot] += self.size[xroot]
else:
self.parents[yroot] = xroot
self.size[xroot] += self.size[yroot]
N, M = list(map(int, input().split()))
uf = UnionFind(M)
L = []
for _ in range(N):
k, *l = list(map(int, input().split()))
for i in range(1, k):
uf.unite(l[0] - 1, l[i] - 1)
L.append(l[0] - 1)
if len(set([uf.find(L[i]) for i in range(N)])) == 1:
print("YES")
else:
print("NO")
| false | 31.578947 | [
"+class UnionFind:",
"+ def __init__(self, n):",
"+ self.n = n",
"+ self.parents = [i for i in range(n)]",
"+ self.size = [1 for _ in range(n)]",
"+",
"+ def find(self, x):",
"+ root = x",
"+ while self.parents[root] != root:",
"+ root = self.parents[root]",
"+ return root",
"+",
"+ def unite(self, x, y):",
"+ xroot = self.find(x)",
"+ yroot = self.find(y)",
"+ if xroot == yroot:",
"+ return",
"+ if self.size[xroot] <= self.size[yroot]:",
"+ self.parents[xroot] = yroot",
"+ self.size[yroot] += self.size[xroot]",
"+ else:",
"+ self.parents[yroot] = xroot",
"+ self.size[xroot] += self.size[yroot]",
"+",
"+",
"-K = []",
"+uf = UnionFind(M)",
"- K.append(k)",
"- L.append(l)",
"-graph = [[] for _ in range(N + M)]",
"-for i in range(N):",
"- for l in L[i]:",
"- graph[i].append(N + l - 1)",
"- graph[N + l - 1].append(i)",
"-visited = [0 for _ in range(N + M)]",
"-visited[0] = 1",
"-stack = [0]",
"-while stack:",
"- node = stack.pop()",
"- for adj in graph[node]:",
"- if not visited[adj]:",
"- visited[adj] = 1",
"- stack.append(adj)",
"-print((\"YES\" if all(visited[:N]) else \"NO\"))",
"+ for i in range(1, k):",
"+ uf.unite(l[0] - 1, l[i] - 1)",
"+ L.append(l[0] - 1)",
"+if len(set([uf.find(L[i]) for i in range(N)])) == 1:",
"+ print(\"YES\")",
"+else:",
"+ print(\"NO\")"
] | false | 0.048938 | 0.049788 | 0.982936 | [
"s356555883",
"s135017454"
] |
u604774382 | p02396 | python | s754320070 | s005835572 | 70 | 40 | 6,724 | 4,192 | Accepted | Accepted | 42.86 | import sys
i=0
while True:
num=int( sys.stdin.readline() )
i+=1
if num == 0:
break
else:
print(( "Case {}: {}".format( i, num ) )) | import sys
i=1
while True:
x = int( sys.stdin.readline() )
if 0 != x:
print(( "Case {}: {}".format( i, x) ))
else:
break
i += 1 | 10 | 10 | 146 | 143 | import sys
i = 0
while True:
num = int(sys.stdin.readline())
i += 1
if num == 0:
break
else:
print(("Case {}: {}".format(i, num)))
| import sys
i = 1
while True:
x = int(sys.stdin.readline())
if 0 != x:
print(("Case {}: {}".format(i, x)))
else:
break
i += 1
| false | 0 | [
"-i = 0",
"+i = 1",
"- num = int(sys.stdin.readline())",
"+ x = int(sys.stdin.readline())",
"+ if 0 != x:",
"+ print((\"Case {}: {}\".format(i, x)))",
"+ else:",
"+ break",
"- if num == 0:",
"- break",
"- else:",
"- print((\"Case {}: {}\".format(i, num)))"
] | false | 0.037183 | 0.035209 | 1.056069 | [
"s754320070",
"s005835572"
] |
u740284863 | p03681 | python | s058067047 | s394032084 | 702 | 402 | 5,172 | 4,748 | Accepted | Accepted | 42.74 | import math
n = sorted(list(map(int,input().split())))
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = math.factorial(n[1]) **2 * 2
else:
ans = math.factorial(n[1]) * math.factorial(n[0])
print((ans % (10**9 + 7) ))
| import math
n = sorted(list(map(int,input().split())))
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = math.factorial(n[1]) **2 * 2
else:
ans = n[1] * math.factorial(n[0])**2
print((ans % (10**9 + 7) )) | 10 | 9 | 246 | 230 | import math
n = sorted(list(map(int, input().split())))
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = math.factorial(n[1]) ** 2 * 2
else:
ans = math.factorial(n[1]) * math.factorial(n[0])
print((ans % (10**9 + 7)))
| import math
n = sorted(list(map(int, input().split())))
if n[1] - n[0] >= 2:
ans = 0
elif n[1] - n[0] == 0:
ans = math.factorial(n[1]) ** 2 * 2
else:
ans = n[1] * math.factorial(n[0]) ** 2
print((ans % (10**9 + 7)))
| false | 10 | [
"- ans = math.factorial(n[1]) * math.factorial(n[0])",
"+ ans = n[1] * math.factorial(n[0]) ** 2"
] | false | 0.084425 | 0.04503 | 1.874866 | [
"s058067047",
"s394032084"
] |
u736729525 | p02947 | python | s081508910 | s138429419 | 511 | 376 | 19,012 | 18,220 | Accepted | Accepted | 26.42 | N = int(eval(input()))
S = [0] * N
from collections import Counter
counter = Counter()
for i in range(N):
k = "".join(sorted(input().strip()))
counter[k] += 1
# 4
answer = 0
for k, c in list(counter.items()):
f = 1
if c == 1:
continue
answer += (c * (c-1)) // 2
print(answer)
| from collections import Counter
def main():
N = int(eval(input()))
counter = Counter()
for i in range(N):
k = "".join(sorted(input().strip()))
counter[k] += 1
answer = 0
for k, c in list(counter.items()):
answer += (c * (c-1)) // 2
print(answer)
def main2():
N = int(eval(input()))
counter = Counter("".join(sorted(input().strip())) for i in range(N))
print((sum((c * (c-1)) // 2 for c in list(counter.values()))))
def main3():
print((sum((c * (c-1)) // 2 for c in list(Counter("".join(sorted(input().strip())) for i in range(int(eval(input())))).values()))))
main3()
| 17 | 23 | 310 | 619 | N = int(eval(input()))
S = [0] * N
from collections import Counter
counter = Counter()
for i in range(N):
k = "".join(sorted(input().strip()))
counter[k] += 1
# 4
answer = 0
for k, c in list(counter.items()):
f = 1
if c == 1:
continue
answer += (c * (c - 1)) // 2
print(answer)
| from collections import Counter
def main():
N = int(eval(input()))
counter = Counter()
for i in range(N):
k = "".join(sorted(input().strip()))
counter[k] += 1
answer = 0
for k, c in list(counter.items()):
answer += (c * (c - 1)) // 2
print(answer)
def main2():
N = int(eval(input()))
counter = Counter("".join(sorted(input().strip())) for i in range(N))
print((sum((c * (c - 1)) // 2 for c in list(counter.values()))))
def main3():
print(
(
sum(
(c * (c - 1)) // 2
for c in list(
Counter(
"".join(sorted(input().strip()))
for i in range(int(eval(input())))
).values()
)
)
)
)
main3()
| false | 26.086957 | [
"-N = int(eval(input()))",
"-S = [0] * N",
"-counter = Counter()",
"-for i in range(N):",
"- k = \"\".join(sorted(input().strip()))",
"- counter[k] += 1",
"-# 4",
"-answer = 0",
"-for k, c in list(counter.items()):",
"- f = 1",
"- if c == 1:",
"- continue",
"- answer += (c * (c - 1)) // 2",
"-print(answer)",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ counter = Counter()",
"+ for i in range(N):",
"+ k = \"\".join(sorted(input().strip()))",
"+ counter[k] += 1",
"+ answer = 0",
"+ for k, c in list(counter.items()):",
"+ answer += (c * (c - 1)) // 2",
"+ print(answer)",
"+",
"+",
"+def main2():",
"+ N = int(eval(input()))",
"+ counter = Counter(\"\".join(sorted(input().strip())) for i in range(N))",
"+ print((sum((c * (c - 1)) // 2 for c in list(counter.values()))))",
"+",
"+",
"+def main3():",
"+ print(",
"+ (",
"+ sum(",
"+ (c * (c - 1)) // 2",
"+ for c in list(",
"+ Counter(",
"+ \"\".join(sorted(input().strip()))",
"+ for i in range(int(eval(input())))",
"+ ).values()",
"+ )",
"+ )",
"+ )",
"+ )",
"+",
"+",
"+main3()"
] | false | 0.041039 | 0.044724 | 0.917603 | [
"s081508910",
"s138429419"
] |
u340781749 | p03677 | python | s408060027 | s812508637 | 1,379 | 276 | 20,192 | 24,152 | Accepted | Accepted | 79.99 | from collections import defaultdict
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
counter = defaultdict(list)
bit = Bit(m + 1)
ans_1 = 0
for a, b in zip(aa, aa[1:]):
counter[b].append(a)
bit.add(a + 1, 1)
bit.add(b, -1)
if a > b:
bit.add(1, 1)
ans_1 += b
else:
ans_1 += b - a
ans_prev = ans_1
ans_min = ans_1
for x in range(2, m + 1):
ans_x = ans_prev
px = x - 1
if px in counter:
ans_x += sum((px - a) % m - 1 for a in counter[px])
ans_x -= bit.sum(px)
ans_min = min(ans_min, ans_x)
ans_prev = ans_x
print(ans_min)
| from collections import defaultdict
from itertools import accumulate
n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
counter = defaultdict(list)
cum = [0] * (m + 2)
ans_1 = 0
for a, b in zip(aa, aa[1:]):
counter[b].append(a)
cum[a + 1] += 1
cum[b] += -1
if a > b:
cum[1] += 1
ans_1 += b
else:
ans_1 += b - a
cum = list(accumulate(cum))
ans_prev = ans_1
ans_min = ans_1
for x in range(2, m + 1):
ans_x = ans_prev
px = x - 1
if px in counter:
ans_x += sum((px - a) % m - 1 for a in counter[px])
ans_x -= cum[px]
ans_min = min(ans_min, ans_x)
ans_prev = ans_x
print(ans_min)
| 48 | 32 | 1,002 | 705 | from collections import defaultdict
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
counter = defaultdict(list)
bit = Bit(m + 1)
ans_1 = 0
for a, b in zip(aa, aa[1:]):
counter[b].append(a)
bit.add(a + 1, 1)
bit.add(b, -1)
if a > b:
bit.add(1, 1)
ans_1 += b
else:
ans_1 += b - a
ans_prev = ans_1
ans_min = ans_1
for x in range(2, m + 1):
ans_x = ans_prev
px = x - 1
if px in counter:
ans_x += sum((px - a) % m - 1 for a in counter[px])
ans_x -= bit.sum(px)
ans_min = min(ans_min, ans_x)
ans_prev = ans_x
print(ans_min)
| from collections import defaultdict
from itertools import accumulate
n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
counter = defaultdict(list)
cum = [0] * (m + 2)
ans_1 = 0
for a, b in zip(aa, aa[1:]):
counter[b].append(a)
cum[a + 1] += 1
cum[b] += -1
if a > b:
cum[1] += 1
ans_1 += b
else:
ans_1 += b - a
cum = list(accumulate(cum))
ans_prev = ans_1
ans_min = ans_1
for x in range(2, m + 1):
ans_x = ans_prev
px = x - 1
if px in counter:
ans_x += sum((px - a) % m - 1 for a in counter[px])
ans_x -= cum[px]
ans_min = min(ans_min, ans_x)
ans_prev = ans_x
print(ans_min)
| false | 33.333333 | [
"-",
"-",
"-class Bit:",
"- def __init__(self, n):",
"- self.size = n",
"- self.tree = [0] * (n + 1)",
"-",
"- def sum(self, i):",
"- s = 0",
"- while i > 0:",
"- s += self.tree[i]",
"- i -= i & -i",
"- return s",
"-",
"- def add(self, i, x):",
"- while i <= self.size:",
"- self.tree[i] += x",
"- i += i & -i",
"-",
"+from itertools import accumulate",
"-bit = Bit(m + 1)",
"+cum = [0] * (m + 2)",
"- bit.add(a + 1, 1)",
"- bit.add(b, -1)",
"+ cum[a + 1] += 1",
"+ cum[b] += -1",
"- bit.add(1, 1)",
"+ cum[1] += 1",
"+cum = list(accumulate(cum))",
"- ans_x -= bit.sum(px)",
"+ ans_x -= cum[px]"
] | false | 0.038614 | 0.034778 | 1.110302 | [
"s408060027",
"s812508637"
] |
u201234972 | p03487 | python | s852833821 | s535813259 | 100 | 78 | 18,676 | 22,324 | Accepted | Accepted | 22 | from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
CA = Counter(A)
ans = 0
for x in CA:
if CA[x] >= x:
ans += CA[x] - x
else:
ans += CA[x]
print(ans) | from collections import defaultdict
def main():
N = int( eval(input()))
A = list( map( int, input().split()))
d = defaultdict( int)
for a in A:
d[a] += 1
ans = 0
for key, value in list(d.items()):
if key > value:
ans += value
elif key < value:
ans += value - key
print(ans)
if __name__ == '__main__':
main()
| 11 | 16 | 216 | 391 | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
CA = Counter(A)
ans = 0
for x in CA:
if CA[x] >= x:
ans += CA[x] - x
else:
ans += CA[x]
print(ans)
| from collections import defaultdict
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(int)
for a in A:
d[a] += 1
ans = 0
for key, value in list(d.items()):
if key > value:
ans += value
elif key < value:
ans += value - key
print(ans)
if __name__ == "__main__":
main()
| false | 31.25 | [
"-from collections import Counter",
"+from collections import defaultdict",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-CA = Counter(A)",
"-ans = 0",
"-for x in CA:",
"- if CA[x] >= x:",
"- ans += CA[x] - x",
"- else:",
"- ans += CA[x]",
"-print(ans)",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ d = defaultdict(int)",
"+ for a in A:",
"+ d[a] += 1",
"+ ans = 0",
"+ for key, value in list(d.items()):",
"+ if key > value:",
"+ ans += value",
"+ elif key < value:",
"+ ans += value - key",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.089964 | 0.047049 | 1.912143 | [
"s852833821",
"s535813259"
] |
u228223940 | p02912 | python | s886434984 | s595950533 | 810 | 176 | 14,164 | 14,536 | Accepted | Accepted | 78.27 | import bisect
import math
n,m = list(map(int,input().split()))
a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans=[math.ceil(-a[0]/2)]
num = 0
now = 1
if n == 1:
print((a[0] // 2**m))
exit()
for i in range(m-1):
#print(ans[0],a[now],now,ans)
if now >= n:
tmp = math.ceil(ans[0] / 2)
idx = bisect.bisect_right(ans,tmp)
#print(ans,idx,tmp)
ans.insert(idx,tmp)
del ans[0]
continue
if ans[0] <= -a[now]:
tmp = math.ceil(ans[0] / 2)
idx = bisect.bisect_right(ans,tmp)
#print(ans,idx,tmp)
ans.insert(idx,tmp)
del ans[0]
else:
ans.append(math.ceil(-a[now]/2))
now += 1
#print(ans,ans,ans,ans)
if len(ans) == len(a):
print((-sum(ans)))
exit()
print((-sum(ans)+sum(a[len(ans):])))
exit()
for i in range(1,n):
if num >= m:
break
if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
ans.append(-a[i]//2)
num+=1
else:
pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える
print(ans)
print((-sum(ans)))
exit()
a = [-a]
print(a)
exit()
tmp = a[0] // 2
del a[0]
idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print((a,idx))
exit()
if a[0] >= a[1]:
a[0] = a[0] // 2
else:
a[1] = a[1] // 2
print(a) | import heapq
import math
n,m = list(map(int,input().split()))
a = [int(i) for i in input().split()]
a = [-1*num for num in a]
heapq.heapify(a)
for i in range(m):
#1番高い商品の値段を求める
maximum = heapq.heappop(a)
#割引券により、半額にする
add = math.trunc(maximum/2)
#それをheapqにプッシュする
heapq.heappush(a,add)
#-1をかけることを忘れずに!
print((-1 * sum(a))) | 75 | 20 | 1,396 | 361 | import bisect
import math
n, m = list(map(int, input().split()))
a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = [math.ceil(-a[0] / 2)]
num = 0
now = 1
if n == 1:
print((a[0] // 2**m))
exit()
for i in range(m - 1):
# print(ans[0],a[now],now,ans)
if now >= n:
tmp = math.ceil(ans[0] / 2)
idx = bisect.bisect_right(ans, tmp)
# print(ans,idx,tmp)
ans.insert(idx, tmp)
del ans[0]
continue
if ans[0] <= -a[now]:
tmp = math.ceil(ans[0] / 2)
idx = bisect.bisect_right(ans, tmp)
# print(ans,idx,tmp)
ans.insert(idx, tmp)
del ans[0]
else:
ans.append(math.ceil(-a[now] / 2))
now += 1
# print(ans,ans,ans,ans)
if len(ans) == len(a):
print((-sum(ans)))
exit()
print((-sum(ans) + sum(a[len(ans) :])))
exit()
for i in range(1, n):
if num >= m:
break
if -a[i] >= ans[-1]: # i番目の要素がansの最小値以下であればansに付け加える
ans.append(-a[i] // 2)
num += 1
else:
pos = bisect.bisect_right(ans, -a[i]) # i番目の要素以下の値で、最も大きい値の位置を求める
ans[pos] = -a[i] # その位置の値をi番目の要素と置き換える
print(ans)
print((-sum(ans)))
exit()
a = [-a]
print(a)
exit()
tmp = a[0] // 2
del a[0]
idx = bisect.bisect_right(a, tmp)
a.insert(idx, tmp)
print((a, idx))
exit()
if a[0] >= a[1]:
a[0] = a[0] // 2
else:
a[1] = a[1] // 2
print(a)
| import heapq
import math
n, m = list(map(int, input().split()))
a = [int(i) for i in input().split()]
a = [-1 * num for num in a]
heapq.heapify(a)
for i in range(m):
# 1番高い商品の値段を求める
maximum = heapq.heappop(a)
# 割引券により、半額にする
add = math.trunc(maximum / 2)
# それをheapqにプッシュする
heapq.heappush(a, add)
# -1をかけることを忘れずに!
print((-1 * sum(a)))
| false | 73.333333 | [
"-import bisect",
"+import heapq",
"-a.sort(reverse=True)",
"-ans = [math.ceil(-a[0] / 2)]",
"-num = 0",
"-now = 1",
"-if n == 1:",
"- print((a[0] // 2**m))",
"- exit()",
"-for i in range(m - 1):",
"- # print(ans[0],a[now],now,ans)",
"- if now >= n:",
"- tmp = math.ceil(ans[0] / 2)",
"- idx = bisect.bisect_right(ans, tmp)",
"- # print(ans,idx,tmp)",
"- ans.insert(idx, tmp)",
"- del ans[0]",
"- continue",
"- if ans[0] <= -a[now]:",
"- tmp = math.ceil(ans[0] / 2)",
"- idx = bisect.bisect_right(ans, tmp)",
"- # print(ans,idx,tmp)",
"- ans.insert(idx, tmp)",
"- del ans[0]",
"- else:",
"- ans.append(math.ceil(-a[now] / 2))",
"- now += 1",
"-# print(ans,ans,ans,ans)",
"-if len(ans) == len(a):",
"- print((-sum(ans)))",
"- exit()",
"-print((-sum(ans) + sum(a[len(ans) :])))",
"-exit()",
"-for i in range(1, n):",
"- if num >= m:",
"- break",
"- if -a[i] >= ans[-1]: # i番目の要素がansの最小値以下であればansに付け加える",
"- ans.append(-a[i] // 2)",
"- num += 1",
"- else:",
"- pos = bisect.bisect_right(ans, -a[i]) # i番目の要素以下の値で、最も大きい値の位置を求める",
"- ans[pos] = -a[i] # その位置の値をi番目の要素と置き換える",
"-print(ans)",
"-print((-sum(ans)))",
"-exit()",
"-a = [-a]",
"-print(a)",
"-exit()",
"-tmp = a[0] // 2",
"-del a[0]",
"-idx = bisect.bisect_right(a, tmp)",
"-a.insert(idx, tmp)",
"-print((a, idx))",
"-exit()",
"-if a[0] >= a[1]:",
"- a[0] = a[0] // 2",
"-else:",
"- a[1] = a[1] // 2",
"-print(a)",
"+a = [-1 * num for num in a]",
"+heapq.heapify(a)",
"+for i in range(m):",
"+ # 1番高い商品の値段を求める",
"+ maximum = heapq.heappop(a)",
"+ # 割引券により、半額にする",
"+ add = math.trunc(maximum / 2)",
"+ # それをheapqにプッシュする",
"+ heapq.heappush(a, add)",
"+# -1をかけることを忘れずに!",
"+print((-1 * sum(a)))"
] | false | 0.037611 | 0.218599 | 0.172055 | [
"s886434984",
"s595950533"
] |
u729133443 | p03835 | python | s994220224 | s770627532 | 1,961 | 19 | 2,940 | 2,940 | Accepted | Accepted | 99.03 | k,s=list(map(int,input().split()));k+=1;print((sum(k>s-I//k-I%k>=0for I in range(k*k)))) | k,s=list(map(int,input().split()));print((sum(max(0,min(2*k+i-s+1,s-i+1))for i in range(k+1)))) | 1 | 1 | 80 | 87 | k, s = list(map(int, input().split()))
k += 1
print((sum(k > s - I // k - I % k >= 0 for I in range(k * k))))
| k, s = list(map(int, input().split()))
print((sum(max(0, min(2 * k + i - s + 1, s - i + 1)) for i in range(k + 1))))
| false | 0 | [
"-k += 1",
"-print((sum(k > s - I // k - I % k >= 0 for I in range(k * k))))",
"+print((sum(max(0, min(2 * k + i - s + 1, s - i + 1)) for i in range(k + 1))))"
] | false | 0.051796 | 0.051472 | 1.00629 | [
"s994220224",
"s770627532"
] |
u186838327 | p02861 | python | s536575140 | s606160280 | 406 | 199 | 3,188 | 45,556 | Accepted | Accepted | 50.99 | n = int(eval(input()))
L = []
for i in range(n):
x, y = list(map(int, input().split()))
L.append([x, y])
import itertools
import math
ans = 0
for i in itertools.permutations(list(range(n))):
for j in range(n-1):
ans += math.sqrt((L[i[j+1]][0]-L[i[j]][0])**2+(L[i[j+1]][1]-L[i[j]][1])**2)
for i in range(1,n+1):
ans /= i
print(ans)
| n = int(eval(input()))
X = []
Y = []
for i in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
import math
import itertools
ans = 0
for p in list(itertools.permutations(list(range(n)))):
for i in range(len(p)):
if i == len(p)-1:
continue
ans += math.sqrt((X[p[i]]-X[p[i+1]])**2+(Y[p[i]]-Y[p[i+1]])**2)
ans /= math.factorial(n)
print(ans) | 16 | 19 | 354 | 407 | n = int(eval(input()))
L = []
for i in range(n):
x, y = list(map(int, input().split()))
L.append([x, y])
import itertools
import math
ans = 0
for i in itertools.permutations(list(range(n))):
for j in range(n - 1):
ans += math.sqrt(
(L[i[j + 1]][0] - L[i[j]][0]) ** 2 + (L[i[j + 1]][1] - L[i[j]][1]) ** 2
)
for i in range(1, n + 1):
ans /= i
print(ans)
| n = int(eval(input()))
X = []
Y = []
for i in range(n):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
import math
import itertools
ans = 0
for p in list(itertools.permutations(list(range(n)))):
for i in range(len(p)):
if i == len(p) - 1:
continue
ans += math.sqrt((X[p[i]] - X[p[i + 1]]) ** 2 + (Y[p[i]] - Y[p[i + 1]]) ** 2)
ans /= math.factorial(n)
print(ans)
| false | 15.789474 | [
"-L = []",
"+X = []",
"+Y = []",
"- L.append([x, y])",
"+ X.append(x)",
"+ Y.append(y)",
"+import math",
"-import math",
"-for i in itertools.permutations(list(range(n))):",
"- for j in range(n - 1):",
"- ans += math.sqrt(",
"- (L[i[j + 1]][0] - L[i[j]][0]) ** 2 + (L[i[j + 1]][1] - L[i[j]][1]) ** 2",
"- )",
"-for i in range(1, n + 1):",
"- ans /= i",
"+for p in list(itertools.permutations(list(range(n)))):",
"+ for i in range(len(p)):",
"+ if i == len(p) - 1:",
"+ continue",
"+ ans += math.sqrt((X[p[i]] - X[p[i + 1]]) ** 2 + (Y[p[i]] - Y[p[i + 1]]) ** 2)",
"+ans /= math.factorial(n)"
] | false | 0.039501 | 0.046397 | 0.851355 | [
"s536575140",
"s606160280"
] |
u620084012 | p03018 | python | s699743395 | s271861832 | 187 | 74 | 41,968 | 73,624 | Accepted | Accepted | 60.43 | s = eval(input())
s = s.replace("BC","D")
ans = 0
a = 0
for k in range(len(s)):
if s[k] == "A":
a += 1
elif s[k] == "D":
ans += a
else:
a = 0
print(ans)
| s = input().replace("BC","D")
ans = 0
c = 0
for e in s:
if e == "A":
c += 1
elif e == "D":
ans += c
else:
c = 0
print(ans)
| 12 | 11 | 194 | 169 | s = eval(input())
s = s.replace("BC", "D")
ans = 0
a = 0
for k in range(len(s)):
if s[k] == "A":
a += 1
elif s[k] == "D":
ans += a
else:
a = 0
print(ans)
| s = input().replace("BC", "D")
ans = 0
c = 0
for e in s:
if e == "A":
c += 1
elif e == "D":
ans += c
else:
c = 0
print(ans)
| false | 8.333333 | [
"-s = eval(input())",
"-s = s.replace(\"BC\", \"D\")",
"+s = input().replace(\"BC\", \"D\")",
"-a = 0",
"-for k in range(len(s)):",
"- if s[k] == \"A\":",
"- a += 1",
"- elif s[k] == \"D\":",
"- ans += a",
"+c = 0",
"+for e in s:",
"+ if e == \"A\":",
"+ c += 1",
"+ elif e == \"D\":",
"+ ans += c",
"- a = 0",
"+ c = 0"
] | false | 0.043388 | 0.03754 | 1.155793 | [
"s699743395",
"s271861832"
] |
u352394527 | p00486 | python | s988738636 | s558273012 | 660 | 610 | 25,176 | 25,180 | Accepted | Accepted | 7.58 | from bisect import bisect_left as bl
INF = 10 ** 20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int,input().split()))
appx(x)
appy(y)
sorted_xlst = sorted(xlst)
sorted_ylst = sorted(ylst)
accx = accy = 0
cum_sum_xlst = []
cum_sum_ylst = []
appx = cum_sum_xlst.append
appy = cum_sum_ylst.append
for i in range(n):
accx += sorted_xlst[i]
accy += sorted_ylst[i]
appx(accx)
appy(accy)
if n % 2:
clx = crx = sorted_xlst[n // 2]
cly = cry = sorted_ylst[n // 2]
else:
clx = sorted_xlst[n // 2 - 1]
crx = sorted_xlst[n // 2]
cly = sorted_ylst[n // 2 - 1]
cry = sorted_ylst[n // 2]
ans = ansx = ansy = INF
for i in range(n):
xi = xlst[i]
yi = ylst[i]
if xi <= clx:
cx = crx
else:
cx = clx
if yi <= cly:
cy = cry
else:
cy = cly
px = bl(sorted_xlst, cx)
py = bl(sorted_ylst, cy)
dx = xi - cx
if dx < 0:
dx = -dx
if px:
csx = cum_sum_xlst[px - 1]
xlen = (accx - csx * 2 - cx * (n - px * 2)) * 2 - dx
else:
xlen = (accx - cx * n) * 2 - dx
dy = yi - cy
if dy < 0:
dy = -dy
if py:
csy = cum_sum_ylst[py - 1]
ylen = (accy - csy * 2 - cy * (n - py * 2)) * 2 - dy
else:
ylen = (accy - cy * n) * 2 - dy
tlen = xlen + ylen
if ans > tlen:
ans = tlen
ansx = cx
ansy = cy
elif ans == tlen:
if ansx > cx:
ansx = cx
ansy = cy
elif ansx == cx:
if ansy > cy:
ansy = cy
print(ans)
print((ansx, ansy))
main()
| from bisect import bisect_left as bl
INF = 10 ** 20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int,input().split()))
appx(x)
appy(y)
sorted_xlst = sorted(xlst)
sorted_ylst = sorted(ylst)
accx = accy = 0
cum_sum_xlst = []
cum_sum_ylst = []
appx = cum_sum_xlst.append
appy = cum_sum_ylst.append
for i in range(n):
accx += sorted_xlst[i]
accy += sorted_ylst[i]
appx(accx)
appy(accy)
if n % 2:
clx = crx = sorted_xlst[n // 2]
cly = cry = sorted_ylst[n // 2]
else:
clx = sorted_xlst[n // 2 - 1]
crx = sorted_xlst[n // 2]
cly = sorted_ylst[n // 2 - 1]
cry = sorted_ylst[n // 2]
plx = bl(sorted_xlst, clx)
prx = bl(sorted_xlst, crx)
ply = bl(sorted_ylst, cly)
pry = bl(sorted_ylst, cry)
ans = ansx = ansy = INF
for i in range(n):
xi = xlst[i]
yi = ylst[i]
if xi <= clx:
cx = crx
px = prx
else:
cx = clx
px = plx
if yi <= cly:
cy = cry
py = pry
else:
cy = cly
py = ply
dx = xi - cx
if dx < 0:
dx = -dx
if px:
csx = cum_sum_xlst[px - 1]
xlen = (accx - csx * 2 - cx * (n - px * 2)) * 2 - dx
else:
xlen = (accx - cx * n) * 2 - dx
dy = yi - cy
if dy < 0:
dy = -dy
if py:
csy = cum_sum_ylst[py - 1]
ylen = (accy - csy * 2 - cy * (n - py * 2)) * 2 - dy
else:
ylen = (accy - cy * n) * 2 - dy
tlen = xlen + ylen
if ans > tlen:
ans = tlen
ansx = cx
ansy = cy
elif ans == tlen:
if ansx > cx:
ansx = cx
ansy = cy
elif ansx == cx:
if ansy > cy:
ansy = cy
print(ans)
print((ansx, ansy))
main()
| 97 | 103 | 1,829 | 1,953 | from bisect import bisect_left as bl
INF = 10**20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int, input().split()))
appx(x)
appy(y)
sorted_xlst = sorted(xlst)
sorted_ylst = sorted(ylst)
accx = accy = 0
cum_sum_xlst = []
cum_sum_ylst = []
appx = cum_sum_xlst.append
appy = cum_sum_ylst.append
for i in range(n):
accx += sorted_xlst[i]
accy += sorted_ylst[i]
appx(accx)
appy(accy)
if n % 2:
clx = crx = sorted_xlst[n // 2]
cly = cry = sorted_ylst[n // 2]
else:
clx = sorted_xlst[n // 2 - 1]
crx = sorted_xlst[n // 2]
cly = sorted_ylst[n // 2 - 1]
cry = sorted_ylst[n // 2]
ans = ansx = ansy = INF
for i in range(n):
xi = xlst[i]
yi = ylst[i]
if xi <= clx:
cx = crx
else:
cx = clx
if yi <= cly:
cy = cry
else:
cy = cly
px = bl(sorted_xlst, cx)
py = bl(sorted_ylst, cy)
dx = xi - cx
if dx < 0:
dx = -dx
if px:
csx = cum_sum_xlst[px - 1]
xlen = (accx - csx * 2 - cx * (n - px * 2)) * 2 - dx
else:
xlen = (accx - cx * n) * 2 - dx
dy = yi - cy
if dy < 0:
dy = -dy
if py:
csy = cum_sum_ylst[py - 1]
ylen = (accy - csy * 2 - cy * (n - py * 2)) * 2 - dy
else:
ylen = (accy - cy * n) * 2 - dy
tlen = xlen + ylen
if ans > tlen:
ans = tlen
ansx = cx
ansy = cy
elif ans == tlen:
if ansx > cx:
ansx = cx
ansy = cy
elif ansx == cx:
if ansy > cy:
ansy = cy
print(ans)
print((ansx, ansy))
main()
| from bisect import bisect_left as bl
INF = 10**20
def main():
w, h = list(map(int, input().split()))
n = int(eval(input()))
xlst = []
ylst = []
appx = xlst.append
appy = ylst.append
for i in range(n):
x, y = list(map(int, input().split()))
appx(x)
appy(y)
sorted_xlst = sorted(xlst)
sorted_ylst = sorted(ylst)
accx = accy = 0
cum_sum_xlst = []
cum_sum_ylst = []
appx = cum_sum_xlst.append
appy = cum_sum_ylst.append
for i in range(n):
accx += sorted_xlst[i]
accy += sorted_ylst[i]
appx(accx)
appy(accy)
if n % 2:
clx = crx = sorted_xlst[n // 2]
cly = cry = sorted_ylst[n // 2]
else:
clx = sorted_xlst[n // 2 - 1]
crx = sorted_xlst[n // 2]
cly = sorted_ylst[n // 2 - 1]
cry = sorted_ylst[n // 2]
plx = bl(sorted_xlst, clx)
prx = bl(sorted_xlst, crx)
ply = bl(sorted_ylst, cly)
pry = bl(sorted_ylst, cry)
ans = ansx = ansy = INF
for i in range(n):
xi = xlst[i]
yi = ylst[i]
if xi <= clx:
cx = crx
px = prx
else:
cx = clx
px = plx
if yi <= cly:
cy = cry
py = pry
else:
cy = cly
py = ply
dx = xi - cx
if dx < 0:
dx = -dx
if px:
csx = cum_sum_xlst[px - 1]
xlen = (accx - csx * 2 - cx * (n - px * 2)) * 2 - dx
else:
xlen = (accx - cx * n) * 2 - dx
dy = yi - cy
if dy < 0:
dy = -dy
if py:
csy = cum_sum_ylst[py - 1]
ylen = (accy - csy * 2 - cy * (n - py * 2)) * 2 - dy
else:
ylen = (accy - cy * n) * 2 - dy
tlen = xlen + ylen
if ans > tlen:
ans = tlen
ansx = cx
ansy = cy
elif ans == tlen:
if ansx > cx:
ansx = cx
ansy = cy
elif ansx == cx:
if ansy > cy:
ansy = cy
print(ans)
print((ansx, ansy))
main()
| false | 5.825243 | [
"+ plx = bl(sorted_xlst, clx)",
"+ prx = bl(sorted_xlst, crx)",
"+ ply = bl(sorted_ylst, cly)",
"+ pry = bl(sorted_ylst, cry)",
"+ px = prx",
"+ px = plx",
"+ py = pry",
"- px = bl(sorted_xlst, cx)",
"- py = bl(sorted_ylst, cy)",
"+ py = ply"
] | false | 0.049797 | 0.049416 | 1.007713 | [
"s988738636",
"s558273012"
] |
u072717685 | p02791 | python | s982293496 | s754131802 | 90 | 71 | 17,780 | 24,432 | Accepted | Accepted | 21.11 | N = int(eval(input()))
P = list(map(int,input().split()))
r = 0
x = 200001
for num in P:
if x >= num:
r += 1
x = num
print(r) | def main():
n = int(eval(input()))
p = list(map(int, input().split()))
num = float('inf')
r = 0
for pe in p:
if num >= pe:
r += 1
num = pe
print(r)
if __name__ == '__main__':
main()
| 10 | 15 | 133 | 247 | N = int(eval(input()))
P = list(map(int, input().split()))
r = 0
x = 200001
for num in P:
if x >= num:
r += 1
x = num
print(r)
| def main():
n = int(eval(input()))
p = list(map(int, input().split()))
num = float("inf")
r = 0
for pe in p:
if num >= pe:
r += 1
num = pe
print(r)
if __name__ == "__main__":
main()
| false | 33.333333 | [
"-N = int(eval(input()))",
"-P = list(map(int, input().split()))",
"-r = 0",
"-x = 200001",
"-for num in P:",
"- if x >= num:",
"- r += 1",
"- x = num",
"-print(r)",
"+def main():",
"+ n = int(eval(input()))",
"+ p = list(map(int, input().split()))",
"+ num = float(\"inf\")",
"+ r = 0",
"+ for pe in p:",
"+ if num >= pe:",
"+ r += 1",
"+ num = pe",
"+ print(r)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.048208 | 0.046317 | 1.040824 | [
"s982293496",
"s754131802"
] |
u077291787 | p03013 | python | s463981108 | s374862313 | 156 | 67 | 18,336 | 18,336 | Accepted | Accepted | 57.05 | n, m = list(map(int, input().split()))
s = set(map(int, [eval(input()) for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
if i in s:
a, b = b, 0
else:
a, b = b, (a + b) % MOD
print(b) | import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
s = set(map(int, [eval(input()) for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
if i in s:
a, b = b, 0
else:
a, b = b, (a + b) % MOD
print(b) | 11 | 14 | 273 | 315 | n, m = list(map(int, input().split()))
s = set(map(int, [eval(input()) for _ in range(m)]))
MOD = 10**9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
if i in s:
a, b = b, 0
else:
a, b = b, (a + b) % MOD
print(b)
| import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
s = set(map(int, [eval(input()) for _ in range(m)]))
MOD = 10**9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
if i in s:
a, b = b, 0
else:
a, b = b, (a + b) % MOD
print(b)
| false | 21.428571 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.085532 | 0.04629 | 1.847748 | [
"s463981108",
"s374862313"
] |
u983154415 | p02630 | python | s388172075 | s550210579 | 437 | 182 | 89,964 | 96,096 | Accepted | Accepted | 58.35 | v=[0 for i in range(100001)]
n=int(eval(input()))
ar=list(map(int,input().split()))
s=0
for i in ar:
s+=i
v[i]+=1
q=int(eval(input()))
for i in range(q):
a,b=list(map(int,input().split()))
s-=a*v[a]
s+=b*v[a]
v[b]+=v[a]
v[a]=0
print(s)
| import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd
from math import log,ceil
def main():
v=[0 for i in range(100001)]
n=int(eval(input()))
ar=list(map(int,input().split()))
s=0
for i in ar:
s+=i
v[i]+=1
q=int(eval(input()))
for i in range(q):
a,b=list(map(int,input().split()))
s-=a*v[a]
s+=b*v[a]
v[b]+=v[a]
v[a]=0
print(s)
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main()
| 15 | 68 | 264 | 2,194 | v = [0 for i in range(100001)]
n = int(eval(input()))
ar = list(map(int, input().split()))
s = 0
for i in ar:
s += i
v[i] += 1
q = int(eval(input()))
for i in range(q):
a, b = list(map(int, input().split()))
s -= a * v[a]
s += b * v[a]
v[b] += v[a]
v[a] = 0
print(s)
| import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd
from math import log, ceil
def main():
v = [0 for i in range(100001)]
n = int(eval(input()))
ar = list(map(int, input().split()))
s = 0
for i in ar:
s += i
v[i] += 1
q = int(eval(input()))
for i in range(q):
a, b = list(map(int, input().split()))
s -= a * v[a]
s += b * v[a]
v[b] += v[a]
v[a] = 0
print(s)
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main()
| false | 77.941176 | [
"-v = [0 for i in range(100001)]",
"-n = int(eval(input()))",
"-ar = list(map(int, input().split()))",
"-s = 0",
"-for i in ar:",
"- s += i",
"- v[i] += 1",
"-q = int(eval(input()))",
"-for i in range(q):",
"- a, b = list(map(int, input().split()))",
"- s -= a * v[a]",
"- s += b * v[a]",
"- v[b] += v[a]",
"- v[a] = 0",
"- print(s)",
"+import os",
"+import sys",
"+from io import BytesIO, IOBase",
"+from collections import defaultdict as dd",
"+from math import log, ceil",
"+",
"+",
"+def main():",
"+ v = [0 for i in range(100001)]",
"+ n = int(eval(input()))",
"+ ar = list(map(int, input().split()))",
"+ s = 0",
"+ for i in ar:",
"+ s += i",
"+ v[i] += 1",
"+ q = int(eval(input()))",
"+ for i in range(q):",
"+ a, b = list(map(int, input().split()))",
"+ s -= a * v[a]",
"+ s += b * v[a]",
"+ v[b] += v[a]",
"+ v[a] = 0",
"+ print(s)",
"+",
"+",
"+BUFSIZE = 8192",
"+",
"+",
"+class FastIO(IOBase):",
"+ newlines = 0",
"+",
"+ def __init__(self, file):",
"+ self._fd = file.fileno()",
"+ self.buffer = BytesIO()",
"+ self.writable = \"x\" in file.mode or \"r\" not in file.mode",
"+ self.write = self.buffer.write if self.writable else None",
"+",
"+ def read(self):",
"+ while True:",
"+ b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))",
"+ if not b:",
"+ break",
"+ ptr = self.buffer.tell()",
"+ self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)",
"+ self.newlines = 0",
"+ return self.buffer.read()",
"+",
"+ def readline(self):",
"+ while self.newlines == 0:",
"+ b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))",
"+ self.newlines = b.count(b\"\\n\") + (not b)",
"+ ptr = self.buffer.tell()",
"+ self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)",
"+ self.newlines -= 1",
"+ return self.buffer.readline()",
"+",
"+ def flush(self):",
"+ if self.writable:",
"+ os.write(self._fd, self.buffer.getvalue())",
"+ self.buffer.truncate(0), self.buffer.seek(0)",
"+",
"+",
"+class IOWrapper(IOBase):",
"+ def __init__(self, file):",
"+ self.buffer = FastIO(file)",
"+ self.flush = self.buffer.flush",
"+ self.writable = self.buffer.writable",
"+ self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))",
"+ self.read = lambda: self.buffer.read().decode(\"ascii\")",
"+ self.readline = lambda: self.buffer.readline().decode(\"ascii\")",
"+",
"+",
"+sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)",
"+input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.05403 | 0.054865 | 0.98478 | [
"s388172075",
"s550210579"
] |
u049191820 | p02681 | python | s199823298 | s360300525 | 23 | 19 | 9,016 | 8,964 | Accepted | Accepted | 17.39 | a=eval(input())
b=eval(input())
if a==b[:-1] and len(b)==len(a)+1: print('Yes')
else: print('No') | a=eval(input())
b=eval(input())
if a==b[:-1]: print('Yes')
else : print('No') | 4 | 4 | 88 | 68 | a = eval(input())
b = eval(input())
if a == b[:-1] and len(b) == len(a) + 1:
print("Yes")
else:
print("No")
| a = eval(input())
b = eval(input())
if a == b[:-1]:
print("Yes")
else:
print("No")
| false | 0 | [
"-if a == b[:-1] and len(b) == len(a) + 1:",
"+if a == b[:-1]:"
] | false | 0.040835 | 0.04045 | 1.009502 | [
"s199823298",
"s360300525"
] |
u474925961 | p02888 | python | s008862181 | s122129807 | 1,985 | 1,500 | 3,316 | 3,188 | Accepted | Accepted | 24.43 | #3本目を選ぶ時に2本目と同じ長さのものを選べることに注意する
import bisect
n=int(eval(input()))
l=sorted(list(map(int,input().split())))
cnt=0
for i in range(0,n-2):
for j in range(i+1,n-1):
p=bisect.bisect_right(l,l[i]+l[j]-1)
cnt+=max(p-j-1,0)
print(cnt)
| import bisect
n=int(eval(input()))
l=sorted(list(map(int,input().split())))
cnt=0
for i in range(0,n-2):
for j in range(i+1,n-1):
p=bisect.bisect_right(l,l[i]+l[j]-1)
cnt+=p-j-1
print(cnt)
| 11 | 10 | 253 | 213 | # 3本目を選ぶ時に2本目と同じ長さのものを選べることに注意する
import bisect
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(0, n - 2):
for j in range(i + 1, n - 1):
p = bisect.bisect_right(l, l[i] + l[j] - 1)
cnt += max(p - j - 1, 0)
print(cnt)
| import bisect
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(0, n - 2):
for j in range(i + 1, n - 1):
p = bisect.bisect_right(l, l[i] + l[j] - 1)
cnt += p - j - 1
print(cnt)
| false | 9.090909 | [
"-# 3本目を選ぶ時に2本目と同じ長さのものを選べることに注意する",
"- cnt += max(p - j - 1, 0)",
"+ cnt += p - j - 1"
] | false | 0.048156 | 0.046483 | 1.036 | [
"s008862181",
"s122129807"
] |
u088553842 | p04043 | python | s154260247 | s100237347 | 30 | 23 | 8,988 | 9,040 | Accepted | Accepted | 23.33 | s=eval(input());print(('YNEOS'[s.count('5')!=2or s.count('7')!=1::2])) | s=eval(input());z=s.count;print(('YNEOS'[z('5')!=2or z('7')!=1::2])) | 1 | 1 | 62 | 60 | s = eval(input())
print(("YNEOS"[s.count("5") != 2 or s.count("7") != 1 :: 2]))
| s = eval(input())
z = s.count
print(("YNEOS"[z("5") != 2 or z("7") != 1 :: 2]))
| false | 0 | [
"-print((\"YNEOS\"[s.count(\"5\") != 2 or s.count(\"7\") != 1 :: 2]))",
"+z = s.count",
"+print((\"YNEOS\"[z(\"5\") != 2 or z(\"7\") != 1 :: 2]))"
] | false | 0.037273 | 0.036335 | 1.025835 | [
"s154260247",
"s100237347"
] |
u153665391 | p02277 | python | s330667112 | s531878246 | 1,300 | 1,180 | 19,228 | 19,252 | Accepted | Accepted | 9.23 | import copy
def partition(p, r):
i = p
for j in range(p, r):
if A[r][1] >= A[j][1]:
A[i], A[j] = A[j], A[i]
i += 1
A[r], A[i] = A[i], A[r]
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q-1)
quick_sort(q+1, r)
def is_stable():
for i in range(N-1):
if A[i][1] == A[i+1][1]:
small_idx, large_idx = 0, 0
for j in range(N):
if A[i] == orig_list[j]:
small_idx = j
elif A[i+1] == orig_list[j]:
large_idx = j
if small_idx > large_idx:
return False
return True
N = int(eval(input()))
A = []
for _ in range(N):
suit, num = input().split()
num = int(num)
A.append([suit, num])
orig_list = copy.copy(A)
quick_sort(0, N-1)
is_stable = is_stable()
if is_stable:
print("Stable")
else:
print("Not stable")
for card in A:
print(("%s %d" % (card[0], card[1])))
| import copy
def partition(p, r):
i = p
for j in range(p, r):
if A[r][1] >= A[j][1]:
A[i], A[j] = A[j], A[i]
i += 1
A[r], A[i] = A[i], A[r]
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q-1)
quick_sort(q+1, r)
def is_stable():
for i in range(N-1):
if A[i][1] == A[i+1][1]:
small_idx, large_idx = 0, 0
cnt = 0
for j in range(N):
if A[i] == orig_list[j]:
small_idx = j
cnt += 1
elif A[i+1] == orig_list[j]:
large_idx = j
cnt += 1
if cnt == 2:
break
if small_idx > large_idx:
return False
return True
N = int(eval(input()))
A = []
for _ in range(N):
suit, num = input().split()
num = int(num)
A.append([suit, num])
orig_list = copy.copy(A)
quick_sort(0, N-1)
is_stable = is_stable()
if is_stable:
print("Stable")
else:
print("Not stable")
for card in A:
print(("%s %d" % (card[0], card[1])))
| 49 | 54 | 1,060 | 1,198 | import copy
def partition(p, r):
i = p
for j in range(p, r):
if A[r][1] >= A[j][1]:
A[i], A[j] = A[j], A[i]
i += 1
A[r], A[i] = A[i], A[r]
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q - 1)
quick_sort(q + 1, r)
def is_stable():
for i in range(N - 1):
if A[i][1] == A[i + 1][1]:
small_idx, large_idx = 0, 0
for j in range(N):
if A[i] == orig_list[j]:
small_idx = j
elif A[i + 1] == orig_list[j]:
large_idx = j
if small_idx > large_idx:
return False
return True
N = int(eval(input()))
A = []
for _ in range(N):
suit, num = input().split()
num = int(num)
A.append([suit, num])
orig_list = copy.copy(A)
quick_sort(0, N - 1)
is_stable = is_stable()
if is_stable:
print("Stable")
else:
print("Not stable")
for card in A:
print(("%s %d" % (card[0], card[1])))
| import copy
def partition(p, r):
i = p
for j in range(p, r):
if A[r][1] >= A[j][1]:
A[i], A[j] = A[j], A[i]
i += 1
A[r], A[i] = A[i], A[r]
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q - 1)
quick_sort(q + 1, r)
def is_stable():
for i in range(N - 1):
if A[i][1] == A[i + 1][1]:
small_idx, large_idx = 0, 0
cnt = 0
for j in range(N):
if A[i] == orig_list[j]:
small_idx = j
cnt += 1
elif A[i + 1] == orig_list[j]:
large_idx = j
cnt += 1
if cnt == 2:
break
if small_idx > large_idx:
return False
return True
N = int(eval(input()))
A = []
for _ in range(N):
suit, num = input().split()
num = int(num)
A.append([suit, num])
orig_list = copy.copy(A)
quick_sort(0, N - 1)
is_stable = is_stable()
if is_stable:
print("Stable")
else:
print("Not stable")
for card in A:
print(("%s %d" % (card[0], card[1])))
| false | 9.259259 | [
"+ cnt = 0",
"+ cnt += 1",
"+ cnt += 1",
"+ if cnt == 2:",
"+ break"
] | false | 0.04101 | 0.04351 | 0.942559 | [
"s330667112",
"s531878246"
] |
u750990077 | p02688 | python | s849051871 | s501940461 | 30 | 27 | 9,184 | 9,080 | Accepted | Accepted | 10 | def main():
n, k = list(map(int, input().split()))
sunukes = set()
for _ in range(k):
eval(input())
sunukes |= set(list(map(int, input().split())))
print((n-len(sunukes)))
if __name__ == "__main__":
main() | def main():
n, k = list(map(int, input().split()))
a = set()
for i in range(k):
eval(input())
a |= set(list(map(int, input().split())))
print((n-len(a)))
if __name__ == "__main__":
main() | 10 | 10 | 237 | 219 | def main():
n, k = list(map(int, input().split()))
sunukes = set()
for _ in range(k):
eval(input())
sunukes |= set(list(map(int, input().split())))
print((n - len(sunukes)))
if __name__ == "__main__":
main()
| def main():
n, k = list(map(int, input().split()))
a = set()
for i in range(k):
eval(input())
a |= set(list(map(int, input().split())))
print((n - len(a)))
if __name__ == "__main__":
main()
| false | 0 | [
"- sunukes = set()",
"- for _ in range(k):",
"+ a = set()",
"+ for i in range(k):",
"- sunukes |= set(list(map(int, input().split())))",
"- print((n - len(sunukes)))",
"+ a |= set(list(map(int, input().split())))",
"+ print((n - len(a)))"
] | false | 0.040276 | 0.042547 | 0.946618 | [
"s849051871",
"s501940461"
] |
u631914718 | p03287 | python | s278936251 | s496354007 | 230 | 102 | 24,808 | 16,100 | Accepted | Accepted | 55.65 | import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft
import numpy as np
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return eval(input())
def count_lr_old(n, m, a):
count = 0
for l in range(n):
for r in range(l, n):
if not sum(a[l:r+1]) % m:
count += 1
return count
def count_lr(n, m, a):
b_acm = 0
mod_m_counts = {}
for ai in a:
b_acm = (b_acm + ai) % m
mod_m_counts.setdefault(b_acm, 0)
mod_m_counts[b_acm] += 1
# print(mod_m_counts)
# print('len a:', len(a))
count = 0
all_ = 0
for k, v in list(mod_m_counts.items()):
all_ += v
count += v * (v - 1) // 2
if k == 0:
count += v
# print('all_', all_)
return count
if __name__ == "__main__":
n, m = LI()
a = LI()
print((count_lr(n, m, a)))
| n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b_acm = 0
mod_m_counts = {}
for ai in a:
b_acm = (b_acm + ai) % m
mod_m_counts.setdefault(b_acm, 0)
mod_m_counts[b_acm] += 1
count = 0
for k, v in list(mod_m_counts.items()):
count += v * (v - 1) // 2
if k == 0:
count += v
print(count)
| 52 | 17 | 1,290 | 340 | import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft
import numpy as np
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 LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def S():
return eval(input())
def count_lr_old(n, m, a):
count = 0
for l in range(n):
for r in range(l, n):
if not sum(a[l : r + 1]) % m:
count += 1
return count
def count_lr(n, m, a):
b_acm = 0
mod_m_counts = {}
for ai in a:
b_acm = (b_acm + ai) % m
mod_m_counts.setdefault(b_acm, 0)
mod_m_counts[b_acm] += 1
# print(mod_m_counts)
# print('len a:', len(a))
count = 0
all_ = 0
for k, v in list(mod_m_counts.items()):
all_ += v
count += v * (v - 1) // 2
if k == 0:
count += v
# print('all_', all_)
return count
if __name__ == "__main__":
n, m = LI()
a = LI()
print((count_lr(n, m, a)))
| n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b_acm = 0
mod_m_counts = {}
for ai in a:
b_acm = (b_acm + ai) % m
mod_m_counts.setdefault(b_acm, 0)
mod_m_counts[b_acm] += 1
count = 0
for k, v in list(mod_m_counts.items()):
count += v * (v - 1) // 2
if k == 0:
count += v
print(count)
| false | 67.307692 | [
"-import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy",
"-import itertools as it",
"-import collections as cl",
"-import functools as ft",
"-import numpy as np",
"-",
"-",
"-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 LF():",
"- return [float(x) for x in sys.stdin.readline().split()]",
"-",
"-",
"-def LS():",
"- return sys.stdin.readline().split()",
"-",
"-",
"-def I():",
"- return int(sys.stdin.readline())",
"-",
"-",
"-def F():",
"- return float(sys.stdin.readline())",
"-",
"-",
"-def S():",
"- return eval(input())",
"-",
"-",
"-def count_lr_old(n, m, a):",
"- count = 0",
"- for l in range(n):",
"- for r in range(l, n):",
"- if not sum(a[l : r + 1]) % m:",
"- count += 1",
"- return count",
"-",
"-",
"-def count_lr(n, m, a):",
"- b_acm = 0",
"- mod_m_counts = {}",
"- for ai in a:",
"- b_acm = (b_acm + ai) % m",
"- mod_m_counts.setdefault(b_acm, 0)",
"- mod_m_counts[b_acm] += 1",
"- # print(mod_m_counts)",
"- # print('len a:', len(a))",
"- count = 0",
"- all_ = 0",
"- for k, v in list(mod_m_counts.items()):",
"- all_ += v",
"- count += v * (v - 1) // 2",
"- if k == 0:",
"- count += v",
"- # print('all_', all_)",
"- return count",
"-",
"-",
"-if __name__ == \"__main__\":",
"- n, m = LI()",
"- a = LI()",
"- print((count_lr(n, m, a)))",
"+n, m = list(map(int, input().split()))",
"+a = list(map(int, input().split()))",
"+b_acm = 0",
"+mod_m_counts = {}",
"+for ai in a:",
"+ b_acm = (b_acm + ai) % m",
"+ mod_m_counts.setdefault(b_acm, 0)",
"+ mod_m_counts[b_acm] += 1",
"+count = 0",
"+for k, v in list(mod_m_counts.items()):",
"+ count += v * (v - 1) // 2",
"+ if k == 0:",
"+ count += v",
"+print(count)"
] | false | 0.066095 | 0.045433 | 1.45479 | [
"s278936251",
"s496354007"
] |
u716530146 | p02892 | python | s353118358 | s600512321 | 439 | 284 | 28,452 | 19,488 | Accepted | Accepted | 35.31 | #!/usr/bin/env python3
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from collections import deque
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
def solve():
n=int(eval(input()))
data=[list(map(int,list(eval(input())))) for i in range(n)]
fordfs=[[] for i in range(n)]
for i in range(n):
for j in range(n):
if data[i][j]==1:
fordfs[i].append(j)
def dfs():
V=[-1]*n
V[0]=0
que=deque()
que.append(0)
while que:
now=que.popleft()
nowv=V[now]
for ne in fordfs[now]:
if nowv==V[ne]:
print((-1))
exit()
elif V[ne]==-1:
V[ne]=(nowv+1)%2
que.append(ne)
dfs()
# print(data)
G=csgraph_from_dense(data)
d = floyd_warshall(G)
d.tolist()
M=0
for i in d:
M=max(M,max(i))
M=int(M)
print((M+1))
return
def main():
solve()
return
if __name__ == '__main__':
main()
| from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from collections import deque
import sys
def input(): return sys.stdin.readline()[:-1]
n = int(eval(input()))
data = [list(map(int, list(eval(input())))) for i in range(n)]
fordfs = [[] for i in range(n)]
for i in range(n):
for j in range(n):
if data[i][j] == 1:
fordfs[i].append(j)
def bfs():
V = [-1]*n
V[0] = 0
que = deque()
que.append(0)
while que:
now = que.popleft()
nowv = V[now]
for ne in fordfs[now]:
if nowv == V[ne]:
print((-1))
exit()
elif V[ne] == -1:
V[ne] = (nowv+1) % 2
que.append(ne)
bfs()
# print(data)
G = csgraph_from_dense(data)
d = floyd_warshall(G)
d.tolist()
M = 0
for i in d:
M = max(M, max(i))
M = int(M)
print((M+1))
| 51 | 41 | 1,153 | 901 | #!/usr/bin/env python3
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from collections import deque
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
def solve():
n = int(eval(input()))
data = [list(map(int, list(eval(input())))) for i in range(n)]
fordfs = [[] for i in range(n)]
for i in range(n):
for j in range(n):
if data[i][j] == 1:
fordfs[i].append(j)
def dfs():
V = [-1] * n
V[0] = 0
que = deque()
que.append(0)
while que:
now = que.popleft()
nowv = V[now]
for ne in fordfs[now]:
if nowv == V[ne]:
print((-1))
exit()
elif V[ne] == -1:
V[ne] = (nowv + 1) % 2
que.append(ne)
dfs()
# print(data)
G = csgraph_from_dense(data)
d = floyd_warshall(G)
d.tolist()
M = 0
for i in d:
M = max(M, max(i))
M = int(M)
print((M + 1))
return
def main():
solve()
return
if __name__ == "__main__":
main()
| from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from collections import deque
import sys
def input():
return sys.stdin.readline()[:-1]
n = int(eval(input()))
data = [list(map(int, list(eval(input())))) for i in range(n)]
fordfs = [[] for i in range(n)]
for i in range(n):
for j in range(n):
if data[i][j] == 1:
fordfs[i].append(j)
def bfs():
V = [-1] * n
V[0] = 0
que = deque()
que.append(0)
while que:
now = que.popleft()
nowv = V[now]
for ne in fordfs[now]:
if nowv == V[ne]:
print((-1))
exit()
elif V[ne] == -1:
V[ne] = (nowv + 1) % 2
que.append(ne)
bfs()
# print(data)
G = csgraph_from_dense(data)
d = floyd_warshall(G)
d.tolist()
M = 0
for i in d:
M = max(M, max(i))
M = int(M)
print((M + 1))
| false | 19.607843 | [
"-#!/usr/bin/env python3",
"-input = lambda: sys.stdin.readline()[:-1]",
"-sys.setrecursionlimit(10**8)",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"-def solve():",
"- n = int(eval(input()))",
"- data = [list(map(int, list(eval(input())))) for i in range(n)]",
"- fordfs = [[] for i in range(n)]",
"- for i in range(n):",
"- for j in range(n):",
"- if data[i][j] == 1:",
"- fordfs[i].append(j)",
"-",
"- def dfs():",
"- V = [-1] * n",
"- V[0] = 0",
"- que = deque()",
"- que.append(0)",
"- while que:",
"- now = que.popleft()",
"- nowv = V[now]",
"- for ne in fordfs[now]:",
"- if nowv == V[ne]:",
"- print((-1))",
"- exit()",
"- elif V[ne] == -1:",
"- V[ne] = (nowv + 1) % 2",
"- que.append(ne)",
"-",
"- dfs()",
"- # print(data)",
"- G = csgraph_from_dense(data)",
"- d = floyd_warshall(G)",
"- d.tolist()",
"- M = 0",
"- for i in d:",
"- M = max(M, max(i))",
"- M = int(M)",
"- print((M + 1))",
"- return",
"+n = int(eval(input()))",
"+data = [list(map(int, list(eval(input())))) for i in range(n)]",
"+fordfs = [[] for i in range(n)]",
"+for i in range(n):",
"+ for j in range(n):",
"+ if data[i][j] == 1:",
"+ fordfs[i].append(j)",
"-def main():",
"- solve()",
"- return",
"+def bfs():",
"+ V = [-1] * n",
"+ V[0] = 0",
"+ que = deque()",
"+ que.append(0)",
"+ while que:",
"+ now = que.popleft()",
"+ nowv = V[now]",
"+ for ne in fordfs[now]:",
"+ if nowv == V[ne]:",
"+ print((-1))",
"+ exit()",
"+ elif V[ne] == -1:",
"+ V[ne] = (nowv + 1) % 2",
"+ que.append(ne)",
"-if __name__ == \"__main__\":",
"- main()",
"+bfs()",
"+# print(data)",
"+G = csgraph_from_dense(data)",
"+d = floyd_warshall(G)",
"+d.tolist()",
"+M = 0",
"+for i in d:",
"+ M = max(M, max(i))",
"+M = int(M)",
"+print((M + 1))"
] | false | 0.236552 | 0.241469 | 0.979637 | [
"s353118358",
"s600512321"
] |
u636683284 | p03544 | python | s372836374 | s857970562 | 186 | 69 | 38,384 | 61,748 | Accepted | Accepted | 62.9 | N = int(eval(input()))
l = [2,1]
i = 2
while len(l)<N+1:
l.append(l[i-1]+l[i-2])
i+=1
print((l[N])) | n = int(eval(input()))
l = [0]*100
l[0] = 2
l[1] = 1
for i in range(2,100):
l[i] = l[i-1] + l[i-2]
print((l[n])) | 7 | 7 | 101 | 114 | N = int(eval(input()))
l = [2, 1]
i = 2
while len(l) < N + 1:
l.append(l[i - 1] + l[i - 2])
i += 1
print((l[N]))
| n = int(eval(input()))
l = [0] * 100
l[0] = 2
l[1] = 1
for i in range(2, 100):
l[i] = l[i - 1] + l[i - 2]
print((l[n]))
| false | 0 | [
"-N = int(eval(input()))",
"-l = [2, 1]",
"-i = 2",
"-while len(l) < N + 1:",
"- l.append(l[i - 1] + l[i - 2])",
"- i += 1",
"-print((l[N]))",
"+n = int(eval(input()))",
"+l = [0] * 100",
"+l[0] = 2",
"+l[1] = 1",
"+for i in range(2, 100):",
"+ l[i] = l[i - 1] + l[i - 2]",
"+print((l[n]))"
] | false | 0.03584 | 0.035829 | 1.00031 | [
"s372836374",
"s857970562"
] |
u212831449 | p03805 | python | s771414855 | s662630844 | 42 | 33 | 3,064 | 9,212 | Accepted | Accepted | 21.43 | import itertools
n,m = list(map(int,input().split()))#頂点の数、辺の数
graph = [[False for i in range(n)] for j in range(n)]
for i in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
graph[a][b] = True
graph[b][a] = True
ans = 0
for i in itertools.permutations(list(range(n))):
if i[0] != 0:
continue
visited = [0]*n
visited[0] += 1
for j in range(n):
if j == n-1:
if 0 not in visited:
ans += 1
break
if graph[i[j]][i[j+1]] == True:
visited[i[j+1]] += 1
print(ans)
| import itertools
n,m = list(map(int,input().split()))
path = [[] for i in range(n+1)]
for i in range(m):
a,b = list(map(int,input().split()))
path[a].append(b)
path[b].append(a)
ans = 0
l = [i for i in range(2,n+1)]
for v in itertools.permutations(l,n-1):
flag = True
if v[0] not in path[1]:
flag = False
continue
for k in range(1,n-1):
if v[k] not in path[v[k-1]]:
flag = False
continue
if flag:
ans += 1
print(ans)
| 29 | 24 | 617 | 515 | import itertools
n, m = list(map(int, input().split())) # 頂点の数、辺の数
graph = [[False for i in range(n)] for j in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
graph[a][b] = True
graph[b][a] = True
ans = 0
for i in itertools.permutations(list(range(n))):
if i[0] != 0:
continue
visited = [0] * n
visited[0] += 1
for j in range(n):
if j == n - 1:
if 0 not in visited:
ans += 1
break
if graph[i[j]][i[j + 1]] == True:
visited[i[j + 1]] += 1
print(ans)
| import itertools
n, m = list(map(int, input().split()))
path = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
path[a].append(b)
path[b].append(a)
ans = 0
l = [i for i in range(2, n + 1)]
for v in itertools.permutations(l, n - 1):
flag = True
if v[0] not in path[1]:
flag = False
continue
for k in range(1, n - 1):
if v[k] not in path[v[k - 1]]:
flag = False
continue
if flag:
ans += 1
print(ans)
| false | 17.241379 | [
"-n, m = list(map(int, input().split())) # 頂点の数、辺の数",
"-graph = [[False for i in range(n)] for j in range(n)]",
"+n, m = list(map(int, input().split()))",
"+path = [[] for i in range(n + 1)]",
"- a -= 1",
"- b -= 1",
"- graph[a][b] = True",
"- graph[b][a] = True",
"+ path[a].append(b)",
"+ path[b].append(a)",
"-for i in itertools.permutations(list(range(n))):",
"- if i[0] != 0:",
"+l = [i for i in range(2, n + 1)]",
"+for v in itertools.permutations(l, n - 1):",
"+ flag = True",
"+ if v[0] not in path[1]:",
"+ flag = False",
"- visited = [0] * n",
"- visited[0] += 1",
"- for j in range(n):",
"- if j == n - 1:",
"- if 0 not in visited:",
"- ans += 1",
"- break",
"- if graph[i[j]][i[j + 1]] == True:",
"- visited[i[j + 1]] += 1",
"+ for k in range(1, n - 1):",
"+ if v[k] not in path[v[k - 1]]:",
"+ flag = False",
"+ continue",
"+ if flag:",
"+ ans += 1"
] | false | 0.056204 | 0.0516 | 1.089216 | [
"s771414855",
"s662630844"
] |
u644778646 | p03061 | python | s507360877 | s412760008 | 396 | 358 | 89,832 | 94,816 | Accepted | Accepted | 9.6 | N = int(eval(input()))
A = list(map(int,input().split()))
l = []
r = []
import fractions as fr
l.append(0)
l.append(A[0])
for i in range(1,N-1):
l.append(fr.gcd(l[i],A[i]))
r.append(0)
r.append(A[-1])
for i in range(1,N-1):
r.append(fr.gcd(r[i],A[-i-1]))
ans = 0
for i in range(N):
ans = max(ans, fr.gcd(l[i],r[-i-1]))
print(ans)
| import fractions as fr
N = int(eval(input()))
A = list(map(int,input().split()))
l = [0,A[0]]
r = [0,A[-1]]
for i in range(1,N-1):
l.append(fr.gcd(l[i],A[i]))
r.append(fr.gcd(r[i],A[-i-1]))
ans = 0
for i in range(N):
ans = max(ans, fr.gcd(l[i],r[-i-1]))
print(ans)
| 19 | 15 | 356 | 288 | N = int(eval(input()))
A = list(map(int, input().split()))
l = []
r = []
import fractions as fr
l.append(0)
l.append(A[0])
for i in range(1, N - 1):
l.append(fr.gcd(l[i], A[i]))
r.append(0)
r.append(A[-1])
for i in range(1, N - 1):
r.append(fr.gcd(r[i], A[-i - 1]))
ans = 0
for i in range(N):
ans = max(ans, fr.gcd(l[i], r[-i - 1]))
print(ans)
| import fractions as fr
N = int(eval(input()))
A = list(map(int, input().split()))
l = [0, A[0]]
r = [0, A[-1]]
for i in range(1, N - 1):
l.append(fr.gcd(l[i], A[i]))
r.append(fr.gcd(r[i], A[-i - 1]))
ans = 0
for i in range(N):
ans = max(ans, fr.gcd(l[i], r[-i - 1]))
print(ans)
| false | 21.052632 | [
"+import fractions as fr",
"+",
"-l = []",
"-r = []",
"-import fractions as fr",
"-",
"-l.append(0)",
"-l.append(A[0])",
"+l = [0, A[0]]",
"+r = [0, A[-1]]",
"-r.append(0)",
"-r.append(A[-1])",
"-for i in range(1, N - 1):"
] | false | 0.044089 | 0.045466 | 0.969727 | [
"s507360877",
"s412760008"
] |
u875541136 | p02780 | python | s584388656 | s608370063 | 229 | 176 | 25,060 | 25,060 | Accepted | Accepted | 23.14 | N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
def expect(p):
return (1+p)/2
tmp = sum([expect(p) for p in P[:K]])
maxV = tmp
for i in range(N-K):
tmp -= expect(P[i])
tmp += expect(P[i+K])
maxV = max(maxV, tmp)
print(maxV) | N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [(1+p)/2 for p in P]
tmp = sum(P[:K])
maxV = tmp
for i in range(N-K):
tmp += P[i+K] - P[i]
maxV = max(maxV, tmp)
print(maxV) | 13 | 12 | 267 | 215 | N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
def expect(p):
return (1 + p) / 2
tmp = sum([expect(p) for p in P[:K]])
maxV = tmp
for i in range(N - K):
tmp -= expect(P[i])
tmp += expect(P[i + K])
maxV = max(maxV, tmp)
print(maxV)
| N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [(1 + p) / 2 for p in P]
tmp = sum(P[:K])
maxV = tmp
for i in range(N - K):
tmp += P[i + K] - P[i]
maxV = max(maxV, tmp)
print(maxV)
| false | 7.692308 | [
"-",
"-",
"-def expect(p):",
"- return (1 + p) / 2",
"-",
"-",
"-tmp = sum([expect(p) for p in P[:K]])",
"+P = [(1 + p) / 2 for p in P]",
"+tmp = sum(P[:K])",
"- tmp -= expect(P[i])",
"- tmp += expect(P[i + K])",
"+ tmp += P[i + K] - P[i]"
] | false | 0.03768 | 0.038448 | 0.980033 | [
"s584388656",
"s608370063"
] |
u828455902 | p02400 | python | s150255532 | s096422296 | 20 | 10 | 4,220 | 4,220 | Accepted | Accepted | 50 | r=eval(input());p=3.1415926535897;print("%.9f"%(p*r*r),r*2*p) | r=eval(input());p=3.141592653589;print("%.9f"%(p*r*r),r*2*p) | 1 | 1 | 54 | 53 | r = eval(input())
p = 3.1415926535897
print("%.9f" % (p * r * r), r * 2 * p)
| r = eval(input())
p = 3.141592653589
print("%.9f" % (p * r * r), r * 2 * p)
| false | 0 | [
"-p = 3.1415926535897",
"+p = 3.141592653589"
] | false | 0.035338 | 0.043531 | 0.811801 | [
"s150255532",
"s096422296"
] |
u304292701 | p02946 | python | s624778809 | s928275688 | 149 | 17 | 12,504 | 3,060 | Accepted | Accepted | 88.59 | import numpy as np
k,x = map(int,input().split())
result = np.arange(x-k+1,x+k,1,dtype = 'int')
for i in range(len(result)):
print(result[i],end = " ")
| k,x = list(map(int,input().split()))
for i in range(x-k+1,x+k):
print(i)
| 7 | 4 | 164 | 72 | import numpy as np
k, x = map(int, input().split())
result = np.arange(x - k + 1, x + k, 1, dtype="int")
for i in range(len(result)):
print(result[i], end=" ")
| k, x = list(map(int, input().split()))
for i in range(x - k + 1, x + k):
print(i)
| false | 42.857143 | [
"-import numpy as np",
"-",
"-k, x = map(int, input().split())",
"-result = np.arange(x - k + 1, x + k, 1, dtype=\"int\")",
"-for i in range(len(result)):",
"- print(result[i], end=\" \")",
"+k, x = list(map(int, input().split()))",
"+for i in range(x - k + 1, x + k):",
"+ print(i)"
] | false | 0.237835 | 0.082334 | 2.888648 | [
"s624778809",
"s928275688"
] |
u506858457 | p02936 | python | s012661269 | s762059575 | 1,441 | 1,236 | 283,024 | 56,588 | Accepted | Accepted | 14.23 | import sys
sys.setrecursionlimit(10**6)
def MI(): return list(map(int, input().split()))
N,Q=MI()
Edge=[[] for _ in range(N)]
Point=[0]*(N)
for _ in range(N-1):
a,b=MI()
Edge[a-1].append(b-1)
Edge[b-1].append(a-1)
for _ in range(Q):
p,x=MI()
Point[p-1]+=x
#print(p,Point[p-1])
def dfs(now,pre=-1):
for nxt in Edge[now]:
if nxt==pre:
continue
Point[nxt]+=Point[now]
#print(*Point)
dfs(nxt,now)
dfs(0)
print((*Point)) | import collections
def MI(): return list(map(int, input().split()))
N,Q=MI()
Edge=[[] for _ in range(N)]
Point=[0]*(N)
for _ in range(N-1):
a,b=MI()
Edge[a-1].append(b-1)
Edge[b-1].append(a-1)
for _ in range(Q):
p,x=MI()
Point[p-1]+=x
check=[0]*N
que=collections.deque()
que.append(0)
while que:
v=que.pop()
check[v]=1
for u in Edge[v]:
if check[u]==1:
continue
Point[u]+=Point[v]
que.append(u)
'''
def dfs(now,pre=-1):
for nxt in Edge[now]:
if nxt==pre:
continue
Point[nxt]+=Point[now]
#print(*Point)
dfs(nxt,now)
dfs(0)
'''
print((*Point)) | 26 | 34 | 473 | 630 | import sys
sys.setrecursionlimit(10**6)
def MI():
return list(map(int, input().split()))
N, Q = MI()
Edge = [[] for _ in range(N)]
Point = [0] * (N)
for _ in range(N - 1):
a, b = MI()
Edge[a - 1].append(b - 1)
Edge[b - 1].append(a - 1)
for _ in range(Q):
p, x = MI()
Point[p - 1] += x
# print(p,Point[p-1])
def dfs(now, pre=-1):
for nxt in Edge[now]:
if nxt == pre:
continue
Point[nxt] += Point[now]
# print(*Point)
dfs(nxt, now)
dfs(0)
print((*Point))
| import collections
def MI():
return list(map(int, input().split()))
N, Q = MI()
Edge = [[] for _ in range(N)]
Point = [0] * (N)
for _ in range(N - 1):
a, b = MI()
Edge[a - 1].append(b - 1)
Edge[b - 1].append(a - 1)
for _ in range(Q):
p, x = MI()
Point[p - 1] += x
check = [0] * N
que = collections.deque()
que.append(0)
while que:
v = que.pop()
check[v] = 1
for u in Edge[v]:
if check[u] == 1:
continue
Point[u] += Point[v]
que.append(u)
"""
def dfs(now,pre=-1):
for nxt in Edge[now]:
if nxt==pre:
continue
Point[nxt]+=Point[now]
#print(*Point)
dfs(nxt,now)
dfs(0)
"""
print((*Point))
| false | 23.529412 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"+import collections",
"- # print(p,Point[p-1])",
"-",
"-",
"-def dfs(now, pre=-1):",
"- for nxt in Edge[now]:",
"- if nxt == pre:",
"+check = [0] * N",
"+que = collections.deque()",
"+que.append(0)",
"+while que:",
"+ v = que.pop()",
"+ check[v] = 1",
"+ for u in Edge[v]:",
"+ if check[u] == 1:",
"- Point[nxt] += Point[now]",
"- # print(*Point)",
"- dfs(nxt, now)",
"-",
"-",
"+ Point[u] += Point[v]",
"+ que.append(u)",
"+\"\"\"",
"+def dfs(now,pre=-1):",
"+ for nxt in Edge[now]:",
"+ if nxt==pre:",
"+ continue",
"+ Point[nxt]+=Point[now]",
"+ #print(*Point)",
"+ dfs(nxt,now)",
"+\"\"\""
] | false | 0.047693 | 0.044223 | 1.078474 | [
"s012661269",
"s762059575"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.