user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
list
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
list
u145950990
p03031
python
s641551802
s593081536
219
28
42,096
3,064
Accepted
Accepted
87.21
n,m = list(map(int,input().split())) S = [list(map(int,input().split()))[1:] for i in range(m)] P = list(map(int,input().split())) ans = 0 #bit全探索 for bit in range(1<<n): on = [] ok = True #全部の電球が光る for i in range(n): if (bit & (1<<i)): on.append(i+1) for i in range(m): ...
n,m = list(map(int,input().split())) d = [] for i in range(m): d.append(list(map(int,input().split()))) p = list(map(int,input().split())) ans = 0 def search(x): global ans cnt = 0 for i in range(m): c = 0 for j in d[i][1:]: if x[j-1]==1: c += 1...
19
24
457
487
n, m = list(map(int, input().split())) S = [list(map(int, input().split()))[1:] for i in range(m)] P = list(map(int, input().split())) ans = 0 # bit全探索 for bit in range(1 << n): on = [] ok = True # 全部の電球が光る for i in range(n): if bit & (1 << i): on.append(i + 1) for i in range(m): ...
n, m = list(map(int, input().split())) d = [] for i in range(m): d.append(list(map(int, input().split()))) p = list(map(int, input().split())) ans = 0 def search(x): global ans cnt = 0 for i in range(m): c = 0 for j in d[i][1:]: if x[j - 1] == 1: c += 1 ...
false
20.833333
[ "-S = [list(map(int, input().split()))[1:] for i in range(m)]", "-P = list(map(int, input().split()))", "+d = []", "+for i in range(m):", "+ d.append(list(map(int, input().split())))", "+p = list(map(int, input().split()))", "-# bit全探索", "-for bit in range(1 << n):", "- on = []", "- ok = ...
false
0.035325
0.041324
0.854839
[ "s641551802", "s593081536" ]
u652569315
p02861
python
s469215441
s872162497
590
17
3,064
3,064
Accepted
Accepted
97.12
def main(): import sys input = sys.stdin.readline import math import itertools n=int(eval(input())) xy=[list(map(int,input().split())) for _ in [0]*n] l=''.join([str(i) for i in range(n)]) sum=0 for i in itertools.permutations(l): i=''.join(list(i)) for j in range(n-1): a,b...
def main(): import sys input = sys.stdin.readline n=int(eval(input())) xy=[list(map(int,input().split())) for _ in [0]*n] ans=0 for i in range(n): xi,yi=xy[i][0],xy[i][1] for j in range(n): xj,yj=xy[j][0],xy[j][1] ans+=pow(pow(xi-xj,2)+pow(yi-yj,2),0.5) print((ans/n)) if __...
18
14
486
345
def main(): import sys input = sys.stdin.readline import math import itertools n = int(eval(input())) xy = [list(map(int, input().split())) for _ in [0] * n] l = "".join([str(i) for i in range(n)]) sum = 0 for i in itertools.permutations(l): i = "".join(list(i)) for...
def main(): import sys input = sys.stdin.readline n = int(eval(input())) xy = [list(map(int, input().split())) for _ in [0] * n] ans = 0 for i in range(n): xi, yi = xy[i][0], xy[i][1] for j in range(n): xj, yj = xy[j][0], xy[j][1] ans += pow(pow(xi - xj, ...
false
22.222222
[ "- import math", "- import itertools", "-", "- l = \"\".join([str(i) for i in range(n)])", "- sum = 0", "- for i in itertools.permutations(l):", "- i = \"\".join(list(i))", "- for j in range(n - 1):", "- a, b = int(i[j + 1]), int(i[j])", "- sum +=...
false
0.044745
0.037945
1.179216
[ "s469215441", "s872162497" ]
u673361376
p03565
python
s772943644
s776815661
174
17
38,256
3,060
Accepted
Accepted
90.23
def is_matched(i, inputS, T): for s,t in zip(inputS, T): if s == '?': continue if s != t: return False return True S, T = eval(input()), eval(input()) lenS, lenT = len(S), len(T) matched_i = None for i in range(lenS-lenT+1): if is_matched(i, S[i:i+lenT], T): matched_i = i if matched_i is ...
S = eval(input()) T = eval(input()) lenS = len(S) lenT = len(T) for i in range(lenS - lenT, -1, -1): flag = True for ii in range(lenT): if S[i+ii] == '?' or S[i+ii] == T[ii]: continue else: flag = False break if flag == True: print((...
14
17
429
392
def is_matched(i, inputS, T): for s, t in zip(inputS, T): if s == "?": continue if s != t: return False return True S, T = eval(input()), eval(input()) lenS, lenT = len(S), len(T) matched_i = None for i in range(lenS - lenT + 1): if is_matched(i, S[i : i + lenT], T)...
S = eval(input()) T = eval(input()) lenS = len(S) lenT = len(T) for i in range(lenS - lenT, -1, -1): flag = True for ii in range(lenT): if S[i + ii] == "?" or S[i + ii] == T[ii]: continue else: flag = False break if flag == True: print(((S[:i] + T ...
false
17.647059
[ "-def is_matched(i, inputS, T):", "- for s, t in zip(inputS, T):", "- if s == \"?\":", "+S = eval(input())", "+T = eval(input())", "+lenS = len(S)", "+lenT = len(T)", "+for i in range(lenS - lenT, -1, -1):", "+ flag = True", "+ for ii in range(lenT):", "+ if S[i + ii] == \...
false
0.095901
0.035892
2.671924
[ "s772943644", "s776815661" ]
u418149936
p02629
python
s506063162
s657780193
31
26
9,100
9,160
Accepted
Accepted
16.13
N = int(eval(input())) - 1 rst = '' for i in range(1, 15): if N >= 26 ** i: N -= 26 ** i continue for j in range(i): rst += chr(ord('a') + N % 26) N //= 26 print((rst[::-1])) break
N = int(eval(input())) - 1 rst = '' for i in range(1, 16): if N >= 26 ** i: N -= 26 ** i continue for j in range(i): rst += chr(ord('a') + N % 26) N //= 26 print((rst[::-1])) break
12
11
232
230
N = int(eval(input())) - 1 rst = "" for i in range(1, 15): if N >= 26**i: N -= 26**i continue for j in range(i): rst += chr(ord("a") + N % 26) N //= 26 print((rst[::-1])) break
N = int(eval(input())) - 1 rst = "" for i in range(1, 16): if N >= 26**i: N -= 26**i continue for j in range(i): rst += chr(ord("a") + N % 26) N //= 26 print((rst[::-1])) break
false
8.333333
[ "-for i in range(1, 15):", "+for i in range(1, 16):" ]
false
0.040496
0.037196
1.088724
[ "s506063162", "s657780193" ]
u334712262
p02734
python
s992182460
s468460613
549
433
62,440
42,000
Accepted
Accepted
21.13
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import sys input = sys.stdin.buffer.readline def read_int_n(): return list(map(int, input().split())) def slv(N, S, A): M = 998244353 ans = 0 dp = [0] * (S+1) for a in A: dp[0] += 1 ndp = [0] * (S+1) for j in range(S+1): ...
109
38
2,035
666
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import sys input = sys.stdin.buffer.readline def read_int_n(): return list(map(int, input().split())) def slv(N, S, A): M = 998244353 ans = 0 dp = [0] * (S + 1) for a in A: dp[0] += 1 ndp = [0] * (S + 1) for j in range(S + 1): ndp[j] +...
false
65.137615
[ "-import bisect", "-import heapq", "-import math", "-import random", "-from collections import Counter, defaultdict, deque", "-from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal", "-from functools import lru_cache, reduce", "-from itertools import combinations, combinations_with_replacement, pr...
false
0.104508
0.081767
1.278116
[ "s992182460", "s468460613" ]
u581187895
p03012
python
s261173644
s129379600
19
17
3,064
2,940
Accepted
Accepted
10.53
n = int(eval(input())) arr = list(map(int, input().split())) dic = {} for i in range(1,n+1): S1 = sum(arr[:i]) S2 = sum(arr[i:]) dic[i] = abs(S1-S2) ans = sorted(list(dic.items()), key=lambda x:x[1]) print((ans[0][1]))
N = int(eval(input())) A = list(map(int, input().split())) ans = 1<<60 for t in range(1, N): L = sum(A[:t]) R = sum(A[t:]) ans = min(ans, abs(L-R)) print(ans)
12
12
238
183
n = int(eval(input())) arr = list(map(int, input().split())) dic = {} for i in range(1, n + 1): S1 = sum(arr[:i]) S2 = sum(arr[i:]) dic[i] = abs(S1 - S2) ans = sorted(list(dic.items()), key=lambda x: x[1]) print((ans[0][1]))
N = int(eval(input())) A = list(map(int, input().split())) ans = 1 << 60 for t in range(1, N): L = sum(A[:t]) R = sum(A[t:]) ans = min(ans, abs(L - R)) print(ans)
false
0
[ "-n = int(eval(input()))", "-arr = list(map(int, input().split()))", "-dic = {}", "-for i in range(1, n + 1):", "- S1 = sum(arr[:i])", "- S2 = sum(arr[i:])", "- dic[i] = abs(S1 - S2)", "-ans = sorted(list(dic.items()), key=lambda x: x[1])", "-print((ans[0][1]))", "+N = int(eval(input()))"...
false
0.048904
0.066693
0.733271
[ "s261173644", "s129379600" ]
u143509139
p02996
python
s244349640
s545681561
1,298
986
90,072
53,716
Accepted
Accepted
24.04
n = int(eval(input())) ar = [list(map(int, input().split())) for _ in range(n)] ar.sort(key=lambda x: x[1]) t = 0 for a, b in ar: t += a if b < t: print('No') exit(0) print('Yes')
n = int(eval(input())) l = [None] * n for i in range(n): l[i] = list(map(int, input().split())) l.sort(key=lambda x:x[1]) t = 0 for a, b in l: t += a if t > b: print('No') exit(0) print('Yes')
10
12
206
211
n = int(eval(input())) ar = [list(map(int, input().split())) for _ in range(n)] ar.sort(key=lambda x: x[1]) t = 0 for a, b in ar: t += a if b < t: print("No") exit(0) print("Yes")
n = int(eval(input())) l = [None] * n for i in range(n): l[i] = list(map(int, input().split())) l.sort(key=lambda x: x[1]) t = 0 for a, b in l: t += a if t > b: print("No") exit(0) print("Yes")
false
16.666667
[ "-ar = [list(map(int, input().split())) for _ in range(n)]", "-ar.sort(key=lambda x: x[1])", "+l = [None] * n", "+for i in range(n):", "+ l[i] = list(map(int, input().split()))", "+l.sort(key=lambda x: x[1])", "-for a, b in ar:", "+for a, b in l:", "- if b < t:", "+ if t > b:" ]
false
0.039628
0.035245
1.124343
[ "s244349640", "s545681561" ]
u419877586
p02972
python
s429273059
s190191773
388
277
14,132
80,232
Accepted
Accepted
28.61
n=int(eval(input())) A=[0]+list(map(int, input().split())) B=[0]*(n+1) B[n//2+1:]=A[n//2+1:] for i in range(n//2, 0, -1): B[i]=(sum([B[j] for j in range(2*i, n+1, i)])+A[i])&1 res=[] for i in range(n+1): if B[i]==1: res.append(i) print((len(res))) if res: print((*res))
N=int(eval(input())) a=list(map(int, input().split())) a.insert(0, 0) b=[0 for _ in range(N+1)] for i in range(N, 0, -1): s=0 for j in range(i, N+1, i): s=s^b[j] b[i]=s^a[i] ans=[] for i in range(1, N+1): if b[i]==1: ans.append(i) print((len(ans))) if len(ans): print((...
14
16
287
336
n = int(eval(input())) A = [0] + list(map(int, input().split())) B = [0] * (n + 1) B[n // 2 + 1 :] = A[n // 2 + 1 :] for i in range(n // 2, 0, -1): B[i] = (sum([B[j] for j in range(2 * i, n + 1, i)]) + A[i]) & 1 res = [] for i in range(n + 1): if B[i] == 1: res.append(i) print((len(res))) if res: pr...
N = int(eval(input())) a = list(map(int, input().split())) a.insert(0, 0) b = [0 for _ in range(N + 1)] for i in range(N, 0, -1): s = 0 for j in range(i, N + 1, i): s = s ^ b[j] b[i] = s ^ a[i] ans = [] for i in range(1, N + 1): if b[i] == 1: ans.append(i) print((len(ans))) if len(ans): ...
false
12.5
[ "-n = int(eval(input()))", "-A = [0] + list(map(int, input().split()))", "-B = [0] * (n + 1)", "-B[n // 2 + 1 :] = A[n // 2 + 1 :]", "-for i in range(n // 2, 0, -1):", "- B[i] = (sum([B[j] for j in range(2 * i, n + 1, i)]) + A[i]) & 1", "-res = []", "-for i in range(n + 1):", "- if B[i] == 1:"...
false
0.037936
0.037633
1.008064
[ "s429273059", "s190191773" ]
u285681431
p03044
python
s965628433
s867653631
521
354
47,704
95,244
Accepted
Accepted
32.05
from collections import deque n = int(eval(input())) g = [[] for _ in range(n)] # 0indexに直している for i in range(n - 1): u, v, w = list(map(int, input().split())) g[u - 1].append((v - 1, w)) g[v - 1].append((u - 1, w)) """ ex. 3 1 2 2 2 3 1 の場合、g = [[(1, 2)], [(0, 2), (2, 1)], [(1, 1)]] """...
from collections import deque n = int(eval(input())) g = [[] for _ in range(n)] # 0indexに直している for i in range(n - 1): u, v, w = list(map(int, input().split())) g[u - 1].append((v - 1, w)) g[v - 1].append((u - 1, w)) """ 根から各頂点への距離をd_iとする 2頂点u,vについて、その最小共通祖先をwとすると uとvの距離=d_u+d_v-2d_w 第3項は常に...
54
45
957
883
from collections import deque n = int(eval(input())) g = [[] for _ in range(n)] # 0indexに直している for i in range(n - 1): u, v, w = list(map(int, input().split())) g[u - 1].append((v - 1, w)) g[v - 1].append((u - 1, w)) """ ex. 3 1 2 2 2 3 1 の場合、g = [[(1, 2)], [(0, 2), (2, 1)], [(1, 1)]] """ # print(g) """ 根から...
from collections import deque n = int(eval(input())) g = [[] for _ in range(n)] # 0indexに直している for i in range(n - 1): u, v, w = list(map(int, input().split())) g[u - 1].append((v - 1, w)) g[v - 1].append((u - 1, w)) """ 根から各頂点への距離をd_iとする 2頂点u,vについて、その最小共通祖先をwとすると uとvの距離=d_u+d_v-2d_w 第3項は常に偶数 d_uとd_vの偶奇が等しけ...
false
16.666667
[ "-ex.", "-3", "-1 2 2", "-2 3 1", "-の場合、g = [[(1, 2)], [(0, 2), (2, 1)], [(1, 1)]]", "-\"\"\"", "-# print(g)", "-\"\"\"", "-u,vという2頂点について、その最小共通祖先をwとすると", "+2頂点u,vについて、その最小共通祖先をwとすると", "-# 各頂点について、根からの距離", "-# 頂点0を根とする(別にどれを選んでも良い)", "-ds = [-1] * n", "-ds[0] = 0", "-# BFS(幅優先探索)", "+...
false
0.127002
0.110165
1.152831
[ "s965628433", "s867653631" ]
u840310460
p03220
python
s761038901
s064306284
166
18
38,384
3,060
Accepted
Accepted
89.16
N = int(eval(input())) T, A = [int(i) for i in input().split()] H =[int(i) for i in input().split()] HH=[abs(A-(T-h*0.006))for h in H] print((int(HH.index(min(HH))+1)))
N = int(eval(input())) T, A = list(map(int,input().split())) H = [int(i) for i in input().split()] place = [T-i*0.006 for i in H ] best = [abs(A-place[i]) for i in range(N)] print((best.index(min(best))+1))
7
7
173
199
N = int(eval(input())) T, A = [int(i) for i in input().split()] H = [int(i) for i in input().split()] HH = [abs(A - (T - h * 0.006)) for h in H] print((int(HH.index(min(HH)) + 1)))
N = int(eval(input())) T, A = list(map(int, input().split())) H = [int(i) for i in input().split()] place = [T - i * 0.006 for i in H] best = [abs(A - place[i]) for i in range(N)] print((best.index(min(best)) + 1))
false
0
[ "-T, A = [int(i) for i in input().split()]", "+T, A = list(map(int, input().split()))", "-HH = [abs(A - (T - h * 0.006)) for h in H]", "-print((int(HH.index(min(HH)) + 1)))", "+place = [T - i * 0.006 for i in H]", "+best = [abs(A - place[i]) for i in range(N)]", "+print((best.index(min(best)) + 1))" ]
false
0.038237
0.038744
0.98692
[ "s761038901", "s064306284" ]
u968166680
p02845
python
s539171818
s427843719
76
63
14,044
13,956
Accepted
Accepted
17.11
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): MOD = 1000000007 N, *A = list(map(int, read().split())) ans = 1 C = [0, 0, 0] for a in A: try: ans = (ans *...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): MOD = 1000000007 N, *A = list(map(int, read().split())) ans = 1 C = [0] * (N + 1) C[0] = 3 for a in A: ans = ans * ...
29
27
509
441
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): MOD = 1000000007 N, *A = list(map(int, read().split())) ans = 1 C = [0, 0, 0] for a in A: try: ans = (ans * C.count(a)) % MOD ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): MOD = 1000000007 N, *A = list(map(int, read().split())) ans = 1 C = [0] * (N + 1) C[0] = 3 for a in A: ans = ans * C[a] % MOD C...
false
6.896552
[ "- C = [0, 0, 0]", "+ C = [0] * (N + 1)", "+ C[0] = 3", "- try:", "- ans = (ans * C.count(a)) % MOD", "- C[C.index(a)] += 1", "- except ValueError:", "- print((0))", "- return", "+ ans = ans * C[a] % MOD", "+ C[a] -...
false
0.076664
0.082796
0.925942
[ "s539171818", "s427843719" ]
u411203878
p03945
python
s202292072
s323801532
178
69
49,476
69,204
Accepted
Accepted
61.24
s=eval(input()) s = list(s) count = 0 for i in range(len(s)-1): if s[i] != s[i+1]: count += 1 print(count)
S = list(eval(input())) ans = 0 for i in range(len(S)-1): if S[i] != S[i+1]: ans += 1 print(ans)
11
7
130
109
s = eval(input()) s = list(s) count = 0 for i in range(len(s) - 1): if s[i] != s[i + 1]: count += 1 print(count)
S = list(eval(input())) ans = 0 for i in range(len(S) - 1): if S[i] != S[i + 1]: ans += 1 print(ans)
false
36.363636
[ "-s = eval(input())", "-s = list(s)", "-count = 0", "-for i in range(len(s) - 1):", "- if s[i] != s[i + 1]:", "- count += 1", "-print(count)", "+S = list(eval(input()))", "+ans = 0", "+for i in range(len(S) - 1):", "+ if S[i] != S[i + 1]:", "+ ans += 1", "+print(ans)" ]
false
0.06152
0.077325
0.795604
[ "s202292072", "s323801532" ]
u391589398
p03775
python
s226130648
s776120917
479
44
169,532
9,424
Accepted
Accepted
90.81
n = int(eval(input())) factors = [] while n%2 == 0: factors.append(2) n //=2 for f in range(3, int(n**0.5)+ 1, 2): while n%f == 0: factors.append(f) n //= f if n != 1: factors.append(n) nf = len(factors) fab = 11 sset = set() als = 2**nf for i in range(als): if ...
n = int(eval(input())) ans = 11 for a in range(1, int(n**0.5)+1): if n%a != 0: continue b = n//a ans = min(ans, max(len(str(a)), len(str(b)))) print(ans)
32
10
571
179
n = int(eval(input())) factors = [] while n % 2 == 0: factors.append(2) n //= 2 for f in range(3, int(n**0.5) + 1, 2): while n % f == 0: factors.append(f) n //= f if n != 1: factors.append(n) nf = len(factors) fab = 11 sset = set() als = 2**nf for i in range(als): if als ^ i in sset:...
n = int(eval(input())) ans = 11 for a in range(1, int(n**0.5) + 1): if n % a != 0: continue b = n // a ans = min(ans, max(len(str(a)), len(str(b)))) print(ans)
false
68.75
[ "-factors = []", "-while n % 2 == 0:", "- factors.append(2)", "- n //= 2", "-for f in range(3, int(n**0.5) + 1, 2):", "- while n % f == 0:", "- factors.append(f)", "- n //= f", "-if n != 1:", "- factors.append(n)", "-nf = len(factors)", "-fab = 11", "-sset = set()",...
false
0.073854
0.040078
1.842744
[ "s226130648", "s776120917" ]
u219417113
p02973
python
s229893217
s485440977
589
428
7,284
44,252
Accepted
Accepted
27.33
import bisect from collections import deque N = int(eval(input())) ans = deque() for _ in range(N): a = int(eval(input())) ind = bisect.bisect_left(ans, a) if ind == 0: ans.appendleft(a) else: ans[ind-1] = a print((len(ans)))
import sys input = sys.stdin.readline from bisect import bisect_left from collections import deque def main(): N = int(eval(input())) counter = deque([]) for _ in range(N): a = int(eval(input())) ind = bisect_left(counter, a) if ind == 0: counter.appendleft(a...
13
20
257
425
import bisect from collections import deque N = int(eval(input())) ans = deque() for _ in range(N): a = int(eval(input())) ind = bisect.bisect_left(ans, a) if ind == 0: ans.appendleft(a) else: ans[ind - 1] = a print((len(ans)))
import sys input = sys.stdin.readline from bisect import bisect_left from collections import deque def main(): N = int(eval(input())) counter = deque([]) for _ in range(N): a = int(eval(input())) ind = bisect_left(counter, a) if ind == 0: counter.appendleft(a) ...
false
35
[ "-import bisect", "+import sys", "+", "+input = sys.stdin.readline", "+from bisect import bisect_left", "-N = int(eval(input()))", "-ans = deque()", "-for _ in range(N):", "- a = int(eval(input()))", "- ind = bisect.bisect_left(ans, a)", "- if ind == 0:", "- ans.appendleft(a)",...
false
0.044025
0.037154
1.184935
[ "s229893217", "s485440977" ]
u562935282
p03287
python
s299233141
s025330074
117
105
16,300
16,172
Accepted
Accepted
10.26
n, m = list(map(int, input().split())) a = list(map(int, input().split())) s = [0]#s[i]はaからi個取った累積和 for i in range(len(a)): s.append((s[i] + a[i]) % m) ans = 0 d = dict() for i in range(len(s)): t = d.get(s[i], 0) ans += t d[s[i]] = t + 1 print(ans)
def iin(): return int(eval(input())) def nl(): return list(map(int, input().split())) n, m = nl() a = nl() csum = [0] for x in a: csum.append((csum[-1] + x) % m) d = dict() ans = 0 for x in csum: t = d.get(x, 0) ans += t d[x] = t + 1 print(ans)
14
18
274
279
n, m = list(map(int, input().split())) a = list(map(int, input().split())) s = [0] # s[i]はaからi個取った累積和 for i in range(len(a)): s.append((s[i] + a[i]) % m) ans = 0 d = dict() for i in range(len(s)): t = d.get(s[i], 0) ans += t d[s[i]] = t + 1 print(ans)
def iin(): return int(eval(input())) def nl(): return list(map(int, input().split())) n, m = nl() a = nl() csum = [0] for x in a: csum.append((csum[-1] + x) % m) d = dict() ans = 0 for x in csum: t = d.get(x, 0) ans += t d[x] = t + 1 print(ans)
false
22.222222
[ "-n, m = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-s = [0] # s[i]はaからi個取った累積和", "-for i in range(len(a)):", "- s.append((s[i] + a[i]) % m)", "+def iin():", "+ return int(eval(input()))", "+", "+", "+def nl():", "+ return list(map(int, input().split()))...
false
0.036598
0.038424
0.952466
[ "s299233141", "s025330074" ]
u395202850
p03419
python
s741072233
s269984622
31
28
9,412
9,236
Accepted
Accepted
9.68
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, m = list(map(int, readline().rstrip().split())) if n == 1 or m == 1: print((abs(abs(n - m) - 1))) return print((abs((m - 2) * (n - 2)))) if __name__ == '__main__': mai...
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, m = list(map(int, readline().rstrip().split())) print((abs((m - 2) * (n - 2)))) if __name__ == '__main__': main()
17
14
314
236
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, m = list(map(int, readline().rstrip().split())) if n == 1 or m == 1: print((abs(abs(n - m) - 1))) return print((abs((m - 2) * (n - 2)))) if __name__ == "__main__": main()
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, m = list(map(int, readline().rstrip().split())) print((abs((m - 2) * (n - 2)))) if __name__ == "__main__": main()
false
17.647059
[ "- if n == 1 or m == 1:", "- print((abs(abs(n - m) - 1)))", "- return" ]
false
0.086724
0.035858
2.418539
[ "s741072233", "s269984622" ]
u086503932
p02912
python
s037272806
s992254273
166
128
14,300
20,436
Accepted
Accepted
22.89
import sys import heapq from bisect import insort_right input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) A = [-a for a in A] heapq.heapify(A) for i in range(M): tmp = heapq.heappop(A) heapq.heappush(A,int(tmp/2)) print((sum([-a for a in A])))
from heapq import heapify,heappush,heappop N, M = list(map(int, input().split())) A = list([-int(x) for x in input().split()]) heapify(A) for i in range(M): tmp = heappop(A) heappush(A,-((-tmp)//2)) A = list(A) print((-sum(A)))
13
10
306
239
import sys import heapq from bisect import insort_right input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) A = [-a for a in A] heapq.heapify(A) for i in range(M): tmp = heapq.heappop(A) heapq.heappush(A, int(tmp / 2)) print((sum([-a for a in A])))
from heapq import heapify, heappush, heappop N, M = list(map(int, input().split())) A = list([-int(x) for x in input().split()]) heapify(A) for i in range(M): tmp = heappop(A) heappush(A, -((-tmp) // 2)) A = list(A) print((-sum(A)))
false
23.076923
[ "-import sys", "-import heapq", "-from bisect import insort_right", "+from heapq import heapify, heappush, heappop", "-input = sys.stdin.readline", "-A = list(map(int, input().split()))", "-A = [-a for a in A]", "-heapq.heapify(A)", "+A = list([-int(x) for x in input().split()])", "+heapify(A)", ...
false
0.042748
0.07777
0.549663
[ "s037272806", "s992254273" ]
u814781830
p02973
python
s876272335
s982577215
791
188
86,020
85,556
Accepted
Accepted
76.23
from bisect import bisect_left N = int(eval(input())) A = [int(eval(input())) for i in range(N)] X = [A[0]] for i in range(1, N): if X[0] >= A[i]: X.insert(0, A[i]) else: idx = bisect_left(X, A[i]) X[idx-1] = A[i] print((len(X)))
from bisect import bisect_right N = int(eval(input())) A = [int(eval(input())) for i in range(N)] A.reverse() X = [A[0]] for i in range(1, N): if X[-1] <= A[i]: X.append(A[i]) else: idx = bisect_right(X, A[i]) X[idx] = A[i] print((len(X)))
13
14
262
273
from bisect import bisect_left N = int(eval(input())) A = [int(eval(input())) for i in range(N)] X = [A[0]] for i in range(1, N): if X[0] >= A[i]: X.insert(0, A[i]) else: idx = bisect_left(X, A[i]) X[idx - 1] = A[i] print((len(X)))
from bisect import bisect_right N = int(eval(input())) A = [int(eval(input())) for i in range(N)] A.reverse() X = [A[0]] for i in range(1, N): if X[-1] <= A[i]: X.append(A[i]) else: idx = bisect_right(X, A[i]) X[idx] = A[i] print((len(X)))
false
7.142857
[ "-from bisect import bisect_left", "+from bisect import bisect_right", "+A.reverse()", "- if X[0] >= A[i]:", "- X.insert(0, A[i])", "+ if X[-1] <= A[i]:", "+ X.append(A[i])", "- idx = bisect_left(X, A[i])", "- X[idx - 1] = A[i]", "+ idx = bisect_right(X, A[...
false
0.08821
0.226165
0.390025
[ "s876272335", "s982577215" ]
u309120194
p02729
python
s051911576
s671979899
35
28
9,108
9,156
Accepted
Accepted
20
N, M = list(map(int, input().split())) if N <= 1: a = 0 else: a = N*(N-1) // 2 if M <= 1: b = 0 else: b = M*(M-1) // 2 print((a+b))
N, M = list(map(int, input().split())) # 下の式はN=0,1(M=0,1)の場合も成り立つ a = N*(N-1) // 2 b = M*(M-1) // 2 print((a+b))
9
7
136
114
N, M = list(map(int, input().split())) if N <= 1: a = 0 else: a = N * (N - 1) // 2 if M <= 1: b = 0 else: b = M * (M - 1) // 2 print((a + b))
N, M = list(map(int, input().split())) # 下の式はN=0,1(M=0,1)の場合も成り立つ a = N * (N - 1) // 2 b = M * (M - 1) // 2 print((a + b))
false
22.222222
[ "-if N <= 1:", "- a = 0", "-else:", "- a = N * (N - 1) // 2", "-if M <= 1:", "- b = 0", "-else:", "- b = M * (M - 1) // 2", "+# 下の式はN=0,1(M=0,1)の場合も成り立つ", "+a = N * (N - 1) // 2", "+b = M * (M - 1) // 2" ]
false
0.080832
0.043369
1.863809
[ "s051911576", "s671979899" ]
u606045429
p02850
python
s457861654
s780367922
251
222
25,900
25,900
Accepted
Accepted
11.55
from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) A, B = AB[::2], AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(A, B): E[a].append(b) Q = deque([1]) C = [0] * (N + 1) while Q: v = Q.popleft() c = 0 ...
""" challenge case in: 3 1 3 2 3 out: 1 1 1 """ from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) B = AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): E[a] += b, Q = deque([1]) C = [0] * (N + 1) while Q: v = Q.p...
25
39
488
460
from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) A, B = AB[::2], AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(A, B): E[a].append(b) Q = deque([1]) C = [0] * (N + 1) while Q: v = Q.popleft() c = 0 for u in E...
""" challenge case in: 3 1 3 2 3 out: 1 1 1 """ from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) B = AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): E[a] += (b,) Q = deque([1]) C = [0] * (N + 1) while Q: v =...
false
35.897436
[ "+\"\"\"", "+challenge case", "+in:", "+3", "+1 3", "+2 3", "+out:", "+1", "+1", "+1", "+\"\"\"", "- A, B = AB[::2], AB[1::2]", "+ B = AB[1::2]", "- for a, b in zip(A, B):", "- E[a].append(b)", "+ for a, b in zip(*[iter(AB)] * 2):", "+ E[a] += (b,)", "- ...
false
0.042633
0.038671
1.102458
[ "s457861654", "s780367922" ]
u440566786
p02868
python
s036687968
s984077078
624
500
78,624
86,792
Accepted
Accepted
19.87
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): n,m=list(map(int,input().split())) E=[[] for _ in range(n)] for i in range(1,n): E[i].append((i-1,0)) for _ in range(m): l,r,c=list(map(int,inpu...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() class SegmentTree(object): def __init__(self, A, dot, unit): n = 1 << (len(A) - 1).bit_length() tree = [unit] * (2 * n) for i, v in enumerate(A): ...
31
66
771
1,769
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, m = list(map(int, input().split())) E = [[] for _ in range(n)] for i in range(1, n): E[i].append((i - 1, 0)) for _ in range(m): l, r, c = lis...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() class SegmentTree(object): def __init__(self, A, dot, unit): n = 1 << (len(A) - 1).bit_length() tree = [unit] * (2 * n) for i, v in enumerate(A): ...
false
53.030303
[ "+INF = 1 << 60", "+MOD = 10**9 + 7 # 998244353", "-INF = float(\"inf\")", "-MOD = 10**9 + 7", "+", "+", "+class SegmentTree(object):", "+ def __init__(self, A, dot, unit):", "+ n = 1 << (len(A) - 1).bit_length()", "+ tree = [unit] * (2 * n)", "+ for i, v in enumerate(A)...
false
0.04376
0.038885
1.12536
[ "s036687968", "s984077078" ]
u339199690
p02854
python
s288016652
s659214788
237
176
26,216
25,748
Accepted
Accepted
25.74
import sys N = int(eval(input())) A = list(map(int, sys.stdin.readline().rsplit())) S = [0] * (N + 1) s = sum(A) for i in range(N): S[i + 1] += S[i] + A[i] mini = 10 ** 18 for i in range(1, N + 1): mini = min(mini, abs(S[N] - 2 * S[i])) print(mini)
import sys, itertools N = int(eval(input())) A = list(map(int, sys.stdin.readline().rsplit())) S = list(itertools.accumulate(A)) mini = 10 ** 18 for i in range(N): mini = min(mini, abs(S[N - 1] - 2 * S[i])) print(mini)
15
12
269
232
import sys N = int(eval(input())) A = list(map(int, sys.stdin.readline().rsplit())) S = [0] * (N + 1) s = sum(A) for i in range(N): S[i + 1] += S[i] + A[i] mini = 10**18 for i in range(1, N + 1): mini = min(mini, abs(S[N] - 2 * S[i])) print(mini)
import sys, itertools N = int(eval(input())) A = list(map(int, sys.stdin.readline().rsplit())) S = list(itertools.accumulate(A)) mini = 10**18 for i in range(N): mini = min(mini, abs(S[N - 1] - 2 * S[i])) print(mini)
false
20
[ "-import sys", "+import sys, itertools", "-S = [0] * (N + 1)", "-s = sum(A)", "+S = list(itertools.accumulate(A))", "+mini = 10**18", "- S[i + 1] += S[i] + A[i]", "-mini = 10**18", "-for i in range(1, N + 1):", "- mini = min(mini, abs(S[N] - 2 * S[i]))", "+ mini = min(mini, abs(S[N - 1]...
false
0.063374
0.034888
1.816492
[ "s288016652", "s659214788" ]
u761529120
p03290
python
s155662995
s030678080
185
91
40,432
9,412
Accepted
Accepted
50.81
def main(): D, G = list(map(int, input().split())) p = [0] * D c = [0] * D for i in range(D): p[i], c[i] = list(map(int, input().split())) ans = float('inf') for i in range(1 << D): cnt = 0 score = 0 tmp = 0 for j in range(D): i...
from collections import defaultdict def main(): D, G = list(map(int, input().split())) problem = [] for _ in range(D): p, c = list(map(int, input().split())) problem.append([p,c]) ans = float('inf') for i in range(2**D): all_solve = [] others = [] ...
34
48
757
1,262
def main(): D, G = list(map(int, input().split())) p = [0] * D c = [0] * D for i in range(D): p[i], c[i] = list(map(int, input().split())) ans = float("inf") for i in range(1 << D): cnt = 0 score = 0 tmp = 0 for j in range(D): if (i >> j) & 1: ...
from collections import defaultdict def main(): D, G = list(map(int, input().split())) problem = [] for _ in range(D): p, c = list(map(int, input().split())) problem.append([p, c]) ans = float("inf") for i in range(2**D): all_solve = [] others = [] score = 0...
false
29.166667
[ "+from collections import defaultdict", "+", "+", "- p = [0] * D", "- c = [0] * D", "- for i in range(D):", "- p[i], c[i] = list(map(int, input().split()))", "+ problem = []", "+ for _ in range(D):", "+ p, c = list(map(int, input().split()))", "+ problem.appen...
false
0.045388
0.093542
0.485218
[ "s155662995", "s030678080" ]
u525065967
p02616
python
s157726770
s784341201
279
229
32,396
34,852
Accepted
Accepted
17.92
def solve(): P.sort(reverse = True) M.sort() P.append(-1) M.append(1) # add endpoint p, m = [], [] while len(p) + len(m) < k: if P[len(p)] < -M[len(m)]: m.append(M[len(m)]) else: p.append(P[len(p)]) if len(m)%2 == 0: return p + m exis...
from logging import * basicConfig(level=DEBUG, format='%(levelname)s: %(message)s') disable(CRITICAL) def solve(): P.sort(reverse = True) M.sort() debug('k {} n {}'.format(k,n)) debug('P {}'.format(P)) debug('M {}'.format(M)) can_positive = False if len(P) > 0: if k < n:...
44
44
1,177
1,259
def solve(): P.sort(reverse=True) M.sort() P.append(-1) M.append(1) # add endpoint p, m = [], [] while len(p) + len(m) < k: if P[len(p)] < -M[len(m)]: m.append(M[len(m)]) else: p.append(P[len(p)]) if len(m) % 2 == 0: return p + m exist_p =...
from logging import * basicConfig(level=DEBUG, format="%(levelname)s: %(message)s") disable(CRITICAL) def solve(): P.sort(reverse=True) M.sort() debug("k {} n {}".format(k, n)) debug("P {}".format(P)) debug("M {}".format(M)) can_positive = False if len(P) > 0: if k < n: ...
false
0
[ "+from logging import *", "+", "+basicConfig(level=DEBUG, format=\"%(levelname)s: %(message)s\")", "+disable(CRITICAL)", "+", "+", "- P.append(-1)", "- M.append(1) # add endpoint", "- p, m = [], []", "- while len(p) + len(m) < k:", "- if P[len(p)] < -M[len(m)]:", "- ...
false
0.041216
0.047899
0.860479
[ "s157726770", "s784341201" ]
u968166680
p02551
python
s482759712
s154721394
295
159
130,116
118,476
Accepted
Accepted
46.1
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) MOD = 1000000007 def main(): N, Q, *queries = list(map(int, read().split())) queries = [(q, x) for q, x in zip(*[iter(queries)] * 2)] N -= 2 # N: 処理する区間の長さ ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, Q, *query = list(map(int, read().split())) N -= 2 row = [N] * N col = [N] * N R = C = N ans = N * N ...
85
43
1,761
872
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) MOD = 1000000007 def main(): N, Q, *queries = list(map(int, read().split())) queries = [(q, x) for q, x in zip(*[iter(queries)] * 2)] N -= 2 # N: 処理する区間の長さ N0 = 2 ** (N - 1)...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, Q, *query = list(map(int, read().split())) N -= 2 row = [N] * N col = [N] * N R = C = N ans = N * N for q, x in zip(*[i...
false
49.411765
[ "+INF = 1 << 60", "- N, Q, *queries = list(map(int, read().split()))", "- queries = [(q, x) for q, x in zip(*[iter(queries)] * 2)]", "+ N, Q, *query = list(map(int, read().split()))", "- # N: 処理する区間の長さ", "- N0 = 2 ** (N - 1).bit_length()", "- data1 = [None] * (2 * N0)", "- data2 =...
false
0.045217
0.048704
0.928421
[ "s482759712", "s154721394" ]
u077291787
p02947
python
s085222597
s545911498
226
195
18,184
26,752
Accepted
Accepted
13.72
# ABC137C - Green Bin import sys input = sys.stdin.readline from collections import Counter def main(): N = int(eval(input())) A = Counter("".join(sorted(eval(input()))) for _ in range(N)) ans = sum(i * (i - 1) // 2 for i in list(A.values())) print(ans) if __name__ == "__main__": ...
# ABC137C - Green Bin from collections import Counter def main(): _, *S = open(0).read().split() cnt = list(Counter("".join(sorted(s)) for s in S).values()) ans = sum(i * (i - 1) // 2 for i in cnt) print(ans) if __name__ == "__main__": main()
16
13
309
272
# ABC137C - Green Bin import sys input = sys.stdin.readline from collections import Counter def main(): N = int(eval(input())) A = Counter("".join(sorted(eval(input()))) for _ in range(N)) ans = sum(i * (i - 1) // 2 for i in list(A.values())) print(ans) if __name__ == "__main__": main()
# ABC137C - Green Bin from collections import Counter def main(): _, *S = open(0).read().split() cnt = list(Counter("".join(sorted(s)) for s in S).values()) ans = sum(i * (i - 1) // 2 for i in cnt) print(ans) if __name__ == "__main__": main()
false
18.75
[ "-import sys", "-", "-input = sys.stdin.readline", "- N = int(eval(input()))", "- A = Counter(\"\".join(sorted(eval(input()))) for _ in range(N))", "- ans = sum(i * (i - 1) // 2 for i in list(A.values()))", "+ _, *S = open(0).read().split()", "+ cnt = list(Counter(\"\".join(sorted(s)) f...
false
0.038571
0.043405
0.888633
[ "s085222597", "s545911498" ]
u263830634
p02868
python
s605862799
s782608975
1,967
1,454
123,100
100,332
Accepted
Accepted
26.08
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) lst = [tuple(map(int, input().split())) for _ in range(M)] lst.sort(key = lambda x: x[1]) lst.sort(key = lambda x: x[0]) #セグメント木 #次の2つの処理をO(log N)で実施...
INF = 10 ** 18 N, M = list(map(int, input().split())) G = [[] for _ in range(N + 1)] for _ in range(M): L, R, C = list(map(int, input().split())) G[L].append([C, R]) G[R].append([C, L]) for i in range(1, N): G[i + 1].append([0, i]) d = [INF] * (N + 1) def dijkstra(s): import hea...
89
35
2,182
744
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) lst = [tuple(map(int, input().split())) for _ in range(M)] lst.sort(key=lambda x: x[1]) lst.sort(key=lambda x: x[0]) # セグメント木 # 次の2つの処理をO(log N)で実施することができる # s, ...
INF = 10**18 N, M = list(map(int, input().split())) G = [[] for _ in range(N + 1)] for _ in range(M): L, R, C = list(map(int, input().split())) G[L].append([C, R]) G[R].append([C, L]) for i in range(1, N): G[i + 1].append([0, i]) d = [INF] * (N + 1) def dijkstra(s): import heapq d[s] = 0 ...
false
60.674157
[ "-def main():", "- import sys", "-", "- input = sys.stdin.readline", "- sys.setrecursionlimit(10**9)", "- N, M = list(map(int, input().split()))", "- lst = [tuple(map(int, input().split())) for _ in range(M)]", "- lst.sort(key=lambda x: x[1])", "- lst.sort(key=lambda x: x[0])", ...
false
0.090921
0.046801
1.942713
[ "s605862799", "s782608975" ]
u545368057
p02754
python
s760636175
s805932423
42
17
2,940
2,940
Accepted
Accepted
59.52
n,a,b = list(map(int, input().split())) x = n // (a+b) amari = n % (a+b) if amari <= a: print((x*a+amari)) else: print((x*a+a))
n,a,b = list(map(int, input().split())) s = n//(a+b) rest = n%(a+b) print((s*a+min(a,rest)))
7
4
131
87
n, a, b = list(map(int, input().split())) x = n // (a + b) amari = n % (a + b) if amari <= a: print((x * a + amari)) else: print((x * a + a))
n, a, b = list(map(int, input().split())) s = n // (a + b) rest = n % (a + b) print((s * a + min(a, rest)))
false
42.857143
[ "-x = n // (a + b)", "-amari = n % (a + b)", "-if amari <= a:", "- print((x * a + amari))", "-else:", "- print((x * a + a))", "+s = n // (a + b)", "+rest = n % (a + b)", "+print((s * a + min(a, rest)))" ]
false
0.032686
0.13763
0.237494
[ "s760636175", "s805932423" ]
u075012704
p03043
python
s837555188
s877908230
185
46
39,664
9,172
Accepted
Accepted
75.14
N, K = list(map(int, input().split())) def calc(x): cnt = 1 while x < K: cnt += 1 x *= 2 return cnt - 1 ans = 0 for i in range(1, N + 1): ans += (1 / N) * (1 / (2 ** calc(i))) print(ans)
from math import log2, ceil N, K = list(map(int, input().split())) ans = 0 j = 1.0 for x in range(N, 0, -1): if x >= K: ans += 1.0 * (1 / N) else: while x * j < K: j *= 2.0 ans += (1.0 / j) * (1 / N) print(ans)
16
13
232
262
N, K = list(map(int, input().split())) def calc(x): cnt = 1 while x < K: cnt += 1 x *= 2 return cnt - 1 ans = 0 for i in range(1, N + 1): ans += (1 / N) * (1 / (2 ** calc(i))) print(ans)
from math import log2, ceil N, K = list(map(int, input().split())) ans = 0 j = 1.0 for x in range(N, 0, -1): if x >= K: ans += 1.0 * (1 / N) else: while x * j < K: j *= 2.0 ans += (1.0 / j) * (1 / N) print(ans)
false
18.75
[ "+from math import log2, ceil", "+", "-", "-", "-def calc(x):", "- cnt = 1", "- while x < K:", "- cnt += 1", "- x *= 2", "- return cnt - 1", "-", "-", "-for i in range(1, N + 1):", "- ans += (1 / N) * (1 / (2 ** calc(i)))", "+j = 1.0", "+for x in range(N, 0, -...
false
0.100411
0.045412
2.211135
[ "s837555188", "s877908230" ]
u905582793
p02973
python
s144041763
s404681066
538
281
56,024
49,628
Accepted
Accepted
47.77
import bisect n = int(eval(input())) a = [int(eval(input())) for i in range(n)] ans = 0 color = [a[n-1]] for i in range(n-2,-1,-1): if a[i]>=color[-1]: color.append(a[i]) else: x = bisect.bisect_right(color,a[i]) color[x] = a[i] print((len(color)))
import sys import bisect input = sys.stdin.readline n = int(eval(input())) a = [int(eval(input())) for i in range(n)] ans = 0 color = [a[n-1]] for i in range(n-2,-1,-1): if a[i]>=color[-1]: color.append(a[i]) else: x = bisect.bisect_right(color,a[i]) color[x] = a[i] print((l...
12
14
277
317
import bisect n = int(eval(input())) a = [int(eval(input())) for i in range(n)] ans = 0 color = [a[n - 1]] for i in range(n - 2, -1, -1): if a[i] >= color[-1]: color.append(a[i]) else: x = bisect.bisect_right(color, a[i]) color[x] = a[i] print((len(color)))
import sys import bisect input = sys.stdin.readline n = int(eval(input())) a = [int(eval(input())) for i in range(n)] ans = 0 color = [a[n - 1]] for i in range(n - 2, -1, -1): if a[i] >= color[-1]: color.append(a[i]) else: x = bisect.bisect_right(color, a[i]) color[x] = a[i] print((len(...
false
14.285714
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.042285
0.036251
1.166452
[ "s144041763", "s404681066" ]
u353895424
p03371
python
s566339953
s308848496
171
18
38,384
3,064
Accepted
Accepted
89.47
a, b, c, x, y = list(map(int, input().split())) if a+b <= 2*c: print((a*x + b*y)) elif a+b > 2*c: if x == y: print((c * 2*x)) elif x < y: print((min(c*2*x + b*(y-x), c*2*y))) else: print((min(c*2*y + a*(x-y), c*2*x)))
a, b, c, x, y = list(map(int, input().split())) if a+b < 2*c: ans = a*x + b*y else: if x < y: ans = 2*c * x + b*(y-x) elif y < x: ans = 2*c * y + a*(x-y) else: ans = 2*c*x ans = min(ans, 2*c*max(x,y)) print(ans)
11
14
294
264
a, b, c, x, y = list(map(int, input().split())) if a + b <= 2 * c: print((a * x + b * y)) elif a + b > 2 * c: if x == y: print((c * 2 * x)) elif x < y: print((min(c * 2 * x + b * (y - x), c * 2 * y))) else: print((min(c * 2 * y + a * (x - y), c * 2 * x)))
a, b, c, x, y = list(map(int, input().split())) if a + b < 2 * c: ans = a * x + b * y else: if x < y: ans = 2 * c * x + b * (y - x) elif y < x: ans = 2 * c * y + a * (x - y) else: ans = 2 * c * x ans = min(ans, 2 * c * max(x, y)) print(ans)
false
21.428571
[ "-if a + b <= 2 * c:", "- print((a * x + b * y))", "-elif a + b > 2 * c:", "- if x == y:", "- print((c * 2 * x))", "- elif x < y:", "- print((min(c * 2 * x + b * (y - x), c * 2 * y)))", "+if a + b < 2 * c:", "+ ans = a * x + b * y", "+else:", "+ if x < y:", "+ ...
false
0.125334
0.007246
17.295864
[ "s566339953", "s308848496" ]
u133936772
p02911
python
s777549557
s059466593
1,793
267
7,676
6,584
Accepted
Accepted
85.11
n, k, q = list(map(int, input().split())) l = [int(eval(input()))-1 for _ in range(q)] l.sort() for i in range(n): cnt = 0 if l and l[0] == i: while l and l[0] == i: l.pop(0) cnt += 1 print((('No','Yes')[k > q - cnt]))
n, k, q = list(map(int, input().split())) l = [k-q]*n for _ in range(q): a = int(eval(input()))-1 l[a] += 1 for i in l: print(('Yes' if i>0 else 'No'))
11
8
237
151
n, k, q = list(map(int, input().split())) l = [int(eval(input())) - 1 for _ in range(q)] l.sort() for i in range(n): cnt = 0 if l and l[0] == i: while l and l[0] == i: l.pop(0) cnt += 1 print((("No", "Yes")[k > q - cnt]))
n, k, q = list(map(int, input().split())) l = [k - q] * n for _ in range(q): a = int(eval(input())) - 1 l[a] += 1 for i in l: print(("Yes" if i > 0 else "No"))
false
27.272727
[ "-l = [int(eval(input())) - 1 for _ in range(q)]", "-l.sort()", "-for i in range(n):", "- cnt = 0", "- if l and l[0] == i:", "- while l and l[0] == i:", "- l.pop(0)", "- cnt += 1", "- print(((\"No\", \"Yes\")[k > q - cnt]))", "+l = [k - q] * n", "+for _ in r...
false
0.087448
0.045392
1.92652
[ "s777549557", "s059466593" ]
u145231176
p03281
python
s154194941
s111950172
189
168
38,256
38,384
Accepted
Accepted
11.11
n = int(eval(input())) dp = [1]*(n + 1) ans = 0 # エラストテネスの箒 for i in range(2, n + 1): div = 1 while i * div <= n: dp[i * div] += 1 div += 1 # dp[1]から1個飛ばしで表示 print((dp[1::2].count(8)))
n = int(eval(input())) cnt = 0 lista = [0] * (n + 1) # 奇数のみ for i in range(1, n + 1, 2): # 3 * 1, 3 * 3, 3 * 5... for j in range(i, n + 1, 2 * i): lista[j] += 1 for i in range(n + 1): if lista[i] == 8: cnt += 1 print(cnt)
11
12
210
255
n = int(eval(input())) dp = [1] * (n + 1) ans = 0 # エラストテネスの箒 for i in range(2, n + 1): div = 1 while i * div <= n: dp[i * div] += 1 div += 1 # dp[1]から1個飛ばしで表示 print((dp[1::2].count(8)))
n = int(eval(input())) cnt = 0 lista = [0] * (n + 1) # 奇数のみ for i in range(1, n + 1, 2): # 3 * 1, 3 * 3, 3 * 5... for j in range(i, n + 1, 2 * i): lista[j] += 1 for i in range(n + 1): if lista[i] == 8: cnt += 1 print(cnt)
false
8.333333
[ "-dp = [1] * (n + 1)", "-ans = 0", "-# エラストテネスの箒", "-for i in range(2, n + 1):", "- div = 1", "- while i * div <= n:", "- dp[i * div] += 1", "- div += 1", "-# dp[1]から1個飛ばしで表示", "-print((dp[1::2].count(8)))", "+cnt = 0", "+lista = [0] * (n + 1)", "+# 奇数のみ", "+for i in ra...
false
0.044341
0.103944
0.426588
[ "s154194941", "s111950172" ]
u088061627
p02628
python
s466157449
s180937026
84
31
62,204
9,252
Accepted
Accepted
63.1
N, K = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() ans = 0 for i in range(K): ans += p[i] print(ans)
N, K = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() print((sum(p[: K])))
8
5
140
101
N, K = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() ans = 0 for i in range(K): ans += p[i] print(ans)
N, K = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() print((sum(p[:K])))
false
37.5
[ "-ans = 0", "-for i in range(K):", "- ans += p[i]", "-print(ans)", "+print((sum(p[:K])))" ]
false
0.036114
0.075658
0.477335
[ "s466157449", "s180937026" ]
u546285759
p00093
python
s967188320
s431462595
60
40
9,216
9,052
Accepted
Accepted
33.33
import calendar as C j=0 while 1: a,b=list(map(int, input().split())) if a==0:break if j:print() j=1 if sum([1 for i in range(a,b+1) if C.isleap(i)])==0: print("NA") else: for i in range(a,b+1): if C.isleap(i):print(i)
from calendar import isleap flag = False while True: a, b = list(map(int, input().split())) if a == 0: break if flag: print() flag = True ans = [i for i in range(a, b+1) if isleap(i)] print(("\n".join(map(str, ans)) if len(ans) else "NA"))
12
12
275
283
import calendar as C j = 0 while 1: a, b = list(map(int, input().split())) if a == 0: break if j: print() j = 1 if sum([1 for i in range(a, b + 1) if C.isleap(i)]) == 0: print("NA") else: for i in range(a, b + 1): if C.isleap(i): print...
from calendar import isleap flag = False while True: a, b = list(map(int, input().split())) if a == 0: break if flag: print() flag = True ans = [i for i in range(a, b + 1) if isleap(i)] print(("\n".join(map(str, ans)) if len(ans) else "NA"))
false
0
[ "-import calendar as C", "+from calendar import isleap", "-j = 0", "-while 1:", "+flag = False", "+while True:", "- if j:", "+ if flag:", "- j = 1", "- if sum([1 for i in range(a, b + 1) if C.isleap(i)]) == 0:", "- print(\"NA\")", "- else:", "- for i in range(a, ...
false
0.066195
0.065497
1.010661
[ "s967188320", "s431462595" ]
u072053884
p02412
python
s923056694
s061671743
530
380
7,644
7,564
Accepted
Accepted
28.3
while True: n, x = list(map(int, input().split())) if n == x == 0: break cnt = 0 for i in range(1, n - 1): for j in range(i + 1, n): for k in range(j + 1, n + 1): if (i + j + k) == x: cnt += 1 print(cnt)
while True: n, x = list(map(int, input().split())) if n == x == 0: break cnt = 0 for i in range(1, min(n - 1, int(x / 3))): for j in range(i + 1, n): for k in range(j + 1, n + 1): if (i + j + k) == x: cnt += 1 print(cnt)
11
11
291
308
while True: n, x = list(map(int, input().split())) if n == x == 0: break cnt = 0 for i in range(1, n - 1): for j in range(i + 1, n): for k in range(j + 1, n + 1): if (i + j + k) == x: cnt += 1 print(cnt)
while True: n, x = list(map(int, input().split())) if n == x == 0: break cnt = 0 for i in range(1, min(n - 1, int(x / 3))): for j in range(i + 1, n): for k in range(j + 1, n + 1): if (i + j + k) == x: cnt += 1 print(cnt)
false
0
[ "- for i in range(1, n - 1):", "+ for i in range(1, min(n - 1, int(x / 3))):" ]
false
0.044355
0.044441
0.998059
[ "s923056694", "s061671743" ]
u492910842
p02748
python
s926889670
s337577106
244
216
89,040
97,516
Accepted
Accepted
11.48
a,b,m = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) count = min(a)+min(b) for i in range(m): x,y,c = list(map(int,input().split())) if count > a[x-1]+b[y-1]-c: count = a[x-1]+b[y-1]-c print(count)
a,b,m=list(map(int,input().split())) a=list(map(int,input().split())) b=list(map(int,input().split())) ans=10**6 for i in range(m): x,y,c=list(map(int,input().split())) ans=min(ans,a[x-1]+b[y-1]-c) print((min(ans,min(a)+min(b))))
10
8
263
226
a, b, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) count = min(a) + min(b) for i in range(m): x, y, c = list(map(int, input().split())) if count > a[x - 1] + b[y - 1] - c: count = a[x - 1] + b[y - 1] - c print(count)
a, b, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**6 for i in range(m): x, y, c = list(map(int, input().split())) ans = min(ans, a[x - 1] + b[y - 1] - c) print((min(ans, min(a) + min(b))))
false
20
[ "-count = min(a) + min(b)", "+ans = 10**6", "- if count > a[x - 1] + b[y - 1] - c:", "- count = a[x - 1] + b[y - 1] - c", "-print(count)", "+ ans = min(ans, a[x - 1] + b[y - 1] - c)", "+print((min(ans, min(a) + min(b))))" ]
false
0.036189
0.076193
0.474967
[ "s926889670", "s337577106" ]
u413021823
p03557
python
s202761880
s729020870
467
236
92,968
29,376
Accepted
Accepted
49.46
# https://atcoder.jp/contests/abc077/tasks/arc084_a import sys from bisect import bisect_left, bisect_right def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LS(): return list(...
import sys import bisect def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() A = LI() B = LI() C = LI() A.sort() B.sort...
30
23
554
467
# https://atcoder.jp/contests/abc077/tasks/arc084_a import sys from bisect import bisect_left, bisect_right def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LS(): return lis...
import sys import bisect def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() A = LI() B = LI() C = LI() A.sor...
false
23.333333
[ "-# https://atcoder.jp/contests/abc077/tasks/arc084_a", "-from bisect import bisect_left, bisect_right", "-", "-", "-def S():", "- return sys.stdin.readline().rstrip()", "+import bisect", "+", "+", "+def S():", "+ return sys.stdin.readline().rstrip()", "- ok_a = bisect_left(A, b)", ...
false
0.040665
0.039794
1.021874
[ "s202761880", "s729020870" ]
u645250356
p03162
python
s138602858
s368190827
1,017
492
41,820
95,448
Accepted
Accepted
51.62
n = int(eval(input())) h = [] for i in range(n): a,b,c = list(map(int,input().split())) h.append((a,b,c)) dp = [[0 for i in range(3)] for i in range(n)] for i in range(3): dp[0][i] = h[0][i] for i in range(n-1): for j in range(3): #now for k in range(3): #pre if j != k: ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 mod2 = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.rea...
15
23
396
749
n = int(eval(input())) h = [] for i in range(n): a, b, c = list(map(int, input().split())) h.append((a, b, c)) dp = [[0 for i in range(3)] for i in range(n)] for i in range(3): dp[0][i] = h[0][i] for i in range(n - 1): for j in range(3): # now for k in range(3): # pre if j != k: ...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 mod2 = 998244353 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(in...
false
34.782609
[ "-n = int(eval(input()))", "-h = []", "-for i in range(n):", "- a, b, c = list(map(int, input().split()))", "- h.append((a, b, c))", "-dp = [[0 for i in range(3)] for i in range(n)]", "+from collections import Counter, defaultdict, deque", "+from heapq import heappop, heappush, heapify", "+imp...
false
0.037653
0.114236
0.329606
[ "s138602858", "s368190827" ]
u945181840
p03599
python
s877244930
s018223851
88
23
3,064
3,064
Accepted
Accepted
73.86
A, B, C, D, E, F = list(map(int, input().split())) water = set([]) for i in range(1, F // (100 * A) + 1): water1 = i * 100 * A for j in range((F - water1) // (100 * B) + 1): water2 = j * 100 * B water.add(water1 + water2) ans = [100 * A, 0] c = 0 for i in water: max_sugar = m...
A, B, C, D, E, F = list(map(int, input().split())) water = set([]) for i in range(1, F // (100 * A) + 1): water1 = i * 100 * A for j in range((F - water1) // (100 * B) + 1): water2 = j * 100 * B water.add(water1 + water2) ans = [100 * A, 0] c = 0 for i in water: max_sugar = m...
24
29
658
779
A, B, C, D, E, F = list(map(int, input().split())) water = set([]) for i in range(1, F // (100 * A) + 1): water1 = i * 100 * A for j in range((F - water1) // (100 * B) + 1): water2 = j * 100 * B water.add(water1 + water2) ans = [100 * A, 0] c = 0 for i in water: max_sugar = min(i // 100 * E,...
A, B, C, D, E, F = list(map(int, input().split())) water = set([]) for i in range(1, F // (100 * A) + 1): water1 = i * 100 * A for j in range((F - water1) // (100 * B) + 1): water2 = j * 100 * B water.add(water1 + water2) ans = [100 * A, 0] c = 0 for i in water: max_sugar = min(i // 100 * E,...
false
17.241379
[ "- for j in range(max_sugar // C + 1):", "+ for j in reversed(list(range(max_sugar // C + 1))):", "+ if max_sugar == sugar:", "+ break", "+ else:", "+ continue", "+ break" ]
false
0.100788
0.037305
2.701731
[ "s877244930", "s018223851" ]
u968166680
p02761
python
s437150301
s689230791
78
65
63,392
61,964
Accepted
Accepted
16.67
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, *SC = list(map(int, read().split())) ans = -1 for i in range(1000): n = str(i) if len(n) != N: ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, *SC = list(map(int, read().split())) A = [-1] * N for s, c in zip(*[iter(SC)] * 2): s -= 1 if A[s...
34
43
639
767
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, *SC = list(map(int, read().split())) ans = -1 for i in range(1000): n = str(i) if len(n) != N: continue ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, *SC = list(map(int, read().split())) A = [-1] * N for s, c in zip(*[iter(SC)] * 2): s -= 1 if A[s] != -1 and A[s] !=...
false
20.930233
[ "- ans = -1", "- for i in range(1000):", "- n = str(i)", "- if len(n) != N:", "- continue", "- ok = True", "- for s, c in zip(*[iter(SC)] * 2):", "- s -= 1", "- if s >= N or n[s] != str(c):", "- ok = False", "- ...
false
0.041792
0.03968
1.053222
[ "s437150301", "s689230791" ]
u701063973
p02612
python
s888328459
s135401413
31
28
9,104
9,072
Accepted
Accepted
9.68
cash = int(eval(input())) n = 0 paid = 0 while paid < cash: paid = 1000 * n n += 1 print((paid - cash))
cash = int(eval(input())) paid = (1000 - cash % 1000) % 1000 print(paid)
9
4
112
70
cash = int(eval(input())) n = 0 paid = 0 while paid < cash: paid = 1000 * n n += 1 print((paid - cash))
cash = int(eval(input())) paid = (1000 - cash % 1000) % 1000 print(paid)
false
55.555556
[ "-n = 0", "-paid = 0", "-while paid < cash:", "- paid = 1000 * n", "- n += 1", "-print((paid - cash))", "+paid = (1000 - cash % 1000) % 1000", "+print(paid)" ]
false
0.111566
0.048069
2.320955
[ "s888328459", "s135401413" ]
u875291233
p03055
python
s807956623
s324035024
1,771
860
267,828
57,140
Accepted
Accepted
51.44
# coding: utf-8 # Your code here! def diameter(g): def dfs(v,p): # v からの最長点と距離を求める m = 0 i = v for c in g[v]: if c == p: continue mc,ic = dfs(c,v) mc += 1 #重みつきのときは+1でなく +cost(v,c) if m < mc: m = mc ...
# coding: utf-8 # Your code here! from collections import deque def diameter(g): def bfs(start): # v からの最長点と距離を求める q = deque([(0,start,-1)]) while q: d,v,p = q.popleft() for c in g[v]: if c == p: continue q.append((d+1,c,v)) #重みつきのと...
51
49
929
932
# coding: utf-8 # Your code here! def diameter(g): def dfs(v, p): # v からの最長点と距離を求める m = 0 i = v for c in g[v]: if c == p: continue mc, ic = dfs(c, v) mc += 1 # 重みつきのときは+1でなく +cost(v,c) if m < mc: m = mc ...
# coding: utf-8 # Your code here! from collections import deque def diameter(g): def bfs(start): # v からの最長点と距離を求める q = deque([(0, start, -1)]) while q: d, v, p = q.popleft() for c in g[v]: if c == p: continue q.append((d ...
false
3.921569
[ "+from collections import deque", "+", "+", "- def dfs(v, p): # v からの最長点と距離を求める", "- m = 0", "- i = v", "- for c in g[v]:", "- if c == p:", "- continue", "- mc, ic = dfs(c, v)", "- mc += 1 # 重みつきのときは+1でなく +cost(v,c)", "-...
false
0.045111
0.115841
0.389421
[ "s807956623", "s324035024" ]
u191874006
p03074
python
s578112421
s794605140
98
84
8,512
81,632
Accepted
Accepted
14.29
#!/usr/bin/env python3 #ABC124 D from itertools import accumulate import bisect n,k = list(map(int,input().split())) s = list(map(int,list(eval(input())))) #0→1 または 1→0 の切り替わるときに連続する数を入れるlist L = [0] if s[0] == 1 else [0,0] cnt = 1 for i in range(1,n): if s[i-1] != s[i]: L += [cnt] cnt =...
#!/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...
23
45
514
1,009
#!/usr/bin/env python3 # ABC124 D from itertools import accumulate import bisect n, k = list(map(int, input().split())) s = list(map(int, list(eval(input())))) # 0→1 または 1→0 の切り替わるときに連続する数を入れるlist L = [0] if s[0] == 1 else [0, 0] cnt = 1 for i in range(1, n): if s[i - 1] != s[i]: L += [cnt] cnt = 0...
#!/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 collectio...
false
48.888889
[ "-# ABC124 D", "+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", "-import bisect", "+from collec...
false
0.047652
0.048894
0.974596
[ "s578112421", "s794605140" ]
u241159583
p03854
python
s199021513
s268316827
72
29
9,340
9,068
Accepted
Accepted
59.72
s = eval(input()) n = len(s) ans = "" i = 0 for _ in range(n): if i > n or ans == s: break if s[i:i+5] == "erase": i += 5 ans += "erase" if s[i:i+1] == "r": i += 1 ans += "r" elif s[i:i+5] == "dream": i += 5 ans += "dream" ...
s = eval(input()) s = s.replace("dream", "D") s = s.replace("erase", "E") s = s.replace("Der", "D") s = s.replace("Er", "E") s = list(set(s)) ok = True for i in range(len(s)): if s[i] not in ["D","E"]: ok = False print(("YES" if ok else "NO"))
21
12
461
259
s = eval(input()) n = len(s) ans = "" i = 0 for _ in range(n): if i > n or ans == s: break if s[i : i + 5] == "erase": i += 5 ans += "erase" if s[i : i + 1] == "r": i += 1 ans += "r" elif s[i : i + 5] == "dream": i += 5 ans += "dream" ...
s = eval(input()) s = s.replace("dream", "D") s = s.replace("erase", "E") s = s.replace("Der", "D") s = s.replace("Er", "E") s = list(set(s)) ok = True for i in range(len(s)): if s[i] not in ["D", "E"]: ok = False print(("YES" if ok else "NO"))
false
42.857143
[ "-n = len(s)", "-ans = \"\"", "-i = 0", "-for _ in range(n):", "- if i > n or ans == s:", "- break", "- if s[i : i + 5] == \"erase\":", "- i += 5", "- ans += \"erase\"", "- if s[i : i + 1] == \"r\":", "- i += 1", "- ans += \"r\"", "- ...
false
0.124719
0.04165
2.994485
[ "s199021513", "s268316827" ]
u588829932
p03026
python
s889558136
s322907522
68
58
7,112
15,092
Accepted
Accepted
14.71
*D, = open(0) n = int(D[0]) edge = [[] for _ in range(n+1)] v_val = [0 for _ in range(n+1)] dist = {} for i in range(1, n): a, b = list(map(int, D[i].split())) edge[a].append(b) edge[b].append(a) c = list(map(int, D[n].split())) c = sorted(c, reverse=True) # 木の端を求める def findLeaf(e...
*D, = open(0) n = int(D[0]) edge = [[] for _ in range(n+1)] v_val = [0 for _ in range(n+1)] dist = {} for i in range(1, n): a, b = list(map(int, D[i].split())) edge[a].append(b) edge[b].append(a) c = list(map(int, D[n].split())) c = sorted(c, reverse=True) start = None for i in range(1,l...
124
47
2,729
937
(*D,) = open(0) n = int(D[0]) edge = [[] for _ in range(n + 1)] v_val = [0 for _ in range(n + 1)] dist = {} for i in range(1, n): a, b = list(map(int, D[i].split())) edge[a].append(b) edge[b].append(a) c = list(map(int, D[n].split())) c = sorted(c, reverse=True) # 木の端を求める def findLeaf(edge, start=1): vi...
(*D,) = open(0) n = int(D[0]) edge = [[] for _ in range(n + 1)] v_val = [0 for _ in range(n + 1)] dist = {} for i in range(1, n): a, b = list(map(int, D[i].split())) edge[a].append(b) edge[b].append(a) c = list(map(int, D[n].split())) c = sorted(c, reverse=True) start = None for i in range(1, len(edge)): ...
false
62.096774
[ "-# 木の端を求める", "-def findLeaf(edge, start=1):", "- visited = [False for _ in range(len(edge))]", "- next_v = edge[start]", "- visited[start] = True", "- count = 0", "- while len(next_v) > 0:", "- new_v = []", "- for it in next_v:", "- # print(it)", ...
false
0.050735
0.050209
1.010463
[ "s889558136", "s322907522" ]
u895445743
p02813
python
s147572092
s989269976
177
88
39,024
79,964
Accepted
Accepted
50.28
from itertools import permutations N=int(eval(input())) P=tuple(map(int,input().split())) Q=tuple(map(int,input().split())) for i,p in enumerate(permutations(list(range(1,N+1)))): if p==P: a=i if p==Q: b=i print((abs(a-b)))
from itertools import permutations N = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) ls = [i for i in range(1, N+1)] a = 0 b = 0 for i, name in enumerate(list(permutations(ls, N))): name = list(name) if name == P: a = i if name == Q: ...
11
19
244
346
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) for i, p in enumerate(permutations(list(range(1, N + 1)))): if p == P: a = i if p == Q: b = i print((abs(a - b)))
from itertools import permutations N = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) ls = [i for i in range(1, N + 1)] a = 0 b = 0 for i, name in enumerate(list(permutations(ls, N))): name = list(name) if name == P: a = i if name == Q: b = i prin...
false
42.105263
[ "-P = tuple(map(int, input().split()))", "-Q = tuple(map(int, input().split()))", "-for i, p in enumerate(permutations(list(range(1, N + 1)))):", "- if p == P:", "+P = list(map(int, input().split()))", "+Q = list(map(int, input().split()))", "+ls = [i for i in range(1, N + 1)]", "+a = 0", "+b = 0...
false
0.042989
0.044326
0.969824
[ "s147572092", "s989269976" ]
u977389981
p03011
python
s694268930
s462863730
170
17
38,384
2,940
Accepted
Accepted
90
P, Q, R = list(map(int, input().split())) print((sum([P, Q, R]) - max([P, Q, R])))
P, Q, R = list(map(int, input().split())) print(((P + Q + R) - max(P, Q, R)))
2
2
75
70
P, Q, R = list(map(int, input().split())) print((sum([P, Q, R]) - max([P, Q, R])))
P, Q, R = list(map(int, input().split())) print(((P + Q + R) - max(P, Q, R)))
false
0
[ "-print((sum([P, Q, R]) - max([P, Q, R])))", "+print(((P + Q + R) - max(P, Q, R)))" ]
false
0.031705
0.034425
0.921004
[ "s694268930", "s462863730" ]
u185249212
p02843
python
s738023035
s279665920
308
171
66,156
38,384
Accepted
Accepted
44.48
# import numpy as np # import numpypy as np import sys input = sys.stdin.readline def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) return import math import string import fractions from fractions import Fraction from fractions import gcd def lcm(n,m): return int(n*m/...
import sys input = sys.stdin.readline def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) return # import math # import string # import fractions # from fractions import Fraction # from fractions import gcd # def lcm(n,m): # return int(n*m/gcd(n,m)) # import re # im...
121
151
2,467
2,808
# import numpy as np # import numpypy as np import sys input = sys.stdin.readline def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) return import math import string import fractions from fractions import Fraction from fractions import gcd def lcm(n, m): return int(n * m / gcd(n, m)...
import sys input = sys.stdin.readline def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) return # import math # import string # import fractions # from fractions import Fraction # from fractions import gcd # def lcm(n,m): # return int(n*m/gcd(n,m)) # import re # import array # import ...
false
19.86755
[ "-# import numpy as np", "-# import numpypy as np", "-import math", "-import string", "-import fractions", "-from fractions import Fraction", "-from fractions import gcd", "-", "-", "-def lcm(n, m):", "- return int(n * m / gcd(n, m))", "-", "-", "-import re", "-import array", "-impo...
false
0.060992
0.040685
1.499138
[ "s738023035", "s279665920" ]
u645250356
p02947
python
s857543709
s472797138
427
368
17,192
19,844
Accepted
Accepted
13.82
import sys,math,itertools def r(x): sum = 0 for i in range(1,x+1): sum += i return sum N = int(eval(input())) s = [] ans = [0] * N for i in range(N): tmp = eval(input()) li_tmp = list(tmp) s_tmp = sorted(li_tmp) st = "".join(s_tmp) s.append(st) data = {} a = s...
import sys,math,collections N = int(eval(input())) s = [] ans = 0 for i in range(N): li_tmp = list(eval(input())) li_tmp.sort() st = "".join(li_tmp) s.append(st) cnt = collections.Counter(s) for i in list(cnt.values()): if i != 1: ans += i*(i-1)//2 print(ans)
31
14
574
282
import sys, math, itertools def r(x): sum = 0 for i in range(1, x + 1): sum += i return sum N = int(eval(input())) s = [] ans = [0] * N for i in range(N): tmp = eval(input()) li_tmp = list(tmp) s_tmp = sorted(li_tmp) st = "".join(s_tmp) s.append(st) data = {} a = set() a.add(...
import sys, math, collections N = int(eval(input())) s = [] ans = 0 for i in range(N): li_tmp = list(eval(input())) li_tmp.sort() st = "".join(li_tmp) s.append(st) cnt = collections.Counter(s) for i in list(cnt.values()): if i != 1: ans += i * (i - 1) // 2 print(ans)
false
54.83871
[ "-import sys, math, itertools", "-", "-", "-def r(x):", "- sum = 0", "- for i in range(1, x + 1):", "- sum += i", "- return sum", "-", "+import sys, math, collections", "-ans = [0] * N", "+ans = 0", "- tmp = eval(input())", "- li_tmp = list(tmp)", "- s_tmp = sort...
false
0.086473
0.039836
2.170722
[ "s857543709", "s472797138" ]
u987164499
p02936
python
s323094957
s669875271
1,971
1,696
312,848
268,432
Accepted
Accepted
13.95
from sys import stdin import sys from itertools import groupby sys.setrecursionlimit(10**6) n,q = [int(x) for x in stdin.readline().rstrip().split()] li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)] lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)] kazu = [[...
import sys sys.setrecursionlimit(10 ** 6) import sys def input(): return sys.stdin.readline()[:-1] N , Q = list(map(int,input().split())) graph = [[] for _ in range(N)] point = [0] * N for _ in range(N - 1): a , b = list(map(int,input().split())) graph[a - 1].append(b - 1) graph[b - 1].append...
25
31
720
770
from sys import stdin import sys from itertools import groupby sys.setrecursionlimit(10**6) n, q = [int(x) for x in stdin.readline().rstrip().split()] li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n - 1)] lin = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)] kazu = [[] fo...
import sys sys.setrecursionlimit(10**6) import sys def input(): return sys.stdin.readline()[:-1] N, Q = list(map(int, input().split())) graph = [[] for _ in range(N)] point = [0] * N for _ in range(N - 1): a, b = list(map(int, input().split())) graph[a - 1].append(b - 1) graph[b - 1].append(a - 1) ...
false
19.354839
[ "-from sys import stdin", "-from itertools import groupby", "-n, q = [int(x) for x in stdin.readline().rstrip().split()]", "-li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n - 1)]", "-lin = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]", "-kazu = [[] for _ i...
false
0.042171
0.03723
1.132738
[ "s323094957", "s669875271" ]
u062147869
p03306
python
s916015915
s419939241
933
805
63,564
85,720
Accepted
Accepted
13.72
from collections import deque import sys N,M=list(map(int,input().split())) table=[[] for i in range(N)] ans=[] for i in range(M): a,b,c=list(map(int,input().split())) table[a-1].append((b-1,c)) table[b-1].append((a-1,c)) ans.append((a-1,b-1,c)) h=deque() inf=-10**13 h.append(0) flag=True ...
import sys from collections import deque N,M=list(map(int,input().split())) table=[[] for i in range(N)] for i in range(M): u,v,s=list(map(int,input().split())) table[u-1].append((v-1,s)) table[v-1].append((u-1,s)) L=[0]*N T=[1]*N#checker visit=[False]*N h=deque() h.append([0,1]) visit[0]=True ...
61
71
1,416
1,384
from collections import deque import sys N, M = list(map(int, input().split())) table = [[] for i in range(N)] ans = [] for i in range(M): a, b, c = list(map(int, input().split())) table[a - 1].append((b - 1, c)) table[b - 1].append((a - 1, c)) ans.append((a - 1, b - 1, c)) h = deque() inf = -(10**13) ...
import sys from collections import deque N, M = list(map(int, input().split())) table = [[] for i in range(N)] for i in range(M): u, v, s = list(map(int, input().split())) table[u - 1].append((v - 1, s)) table[v - 1].append((u - 1, s)) L = [0] * N T = [1] * N # checker visit = [False] * N h = deque() h.ap...
false
14.084507
[ "+import sys", "-import sys", "-ans = []", "- a, b, c = list(map(int, input().split()))", "- table[a - 1].append((b - 1, c))", "- table[b - 1].append((a - 1, c))", "- ans.append((a - 1, b - 1, c))", "+ u, v, s = list(map(int, input().split()))", "+ table[u - 1].append((v - 1, s))",...
false
0.090766
0.036941
2.45707
[ "s916015915", "s419939241" ]
u294385082
p02773
python
s129803729
s216465652
822
634
45,908
32,984
Accepted
Accepted
22.87
#10e5程度ならソートしてもTLEならないらしい? n = int(eval(input())) dic = {} lis = [] lis2 = [] for i in range(n): moji = eval(input()) if moji not in dic: dic[moji] = 0 dic[moji] += 1 for i in sorted(list(dic.items()), key=lambda x:x[1]): lis.append(i) lis.reverse() for j in lis: if lis[0][1] =...
#参考 def resolve(): n=int(eval(input())) dic={} for _ in range(n): s=eval(input()) if not s in list(dic.keys()): dic[s]=0 else: dic[s]+=1 m=max(dic.values()) ans=[] for each in list(dic.keys()): if dic[each]==m: ans...
26
18
413
372
# 10e5程度ならソートしてもTLEならないらしい? n = int(eval(input())) dic = {} lis = [] lis2 = [] for i in range(n): moji = eval(input()) if moji not in dic: dic[moji] = 0 dic[moji] += 1 for i in sorted(list(dic.items()), key=lambda x: x[1]): lis.append(i) lis.reverse() for j in lis: if lis[0][1] == j[1]: ...
# 参考 def resolve(): n = int(eval(input())) dic = {} for _ in range(n): s = eval(input()) if not s in list(dic.keys()): dic[s] = 0 else: dic[s] += 1 m = max(dic.values()) ans = [] for each in list(dic.keys()): if dic[each] == m: ...
false
30.769231
[ "-# 10e5程度ならソートしてもTLEならないらしい?", "-n = int(eval(input()))", "-dic = {}", "-lis = []", "-lis2 = []", "-for i in range(n):", "- moji = eval(input())", "- if moji not in dic:", "- dic[moji] = 0", "- dic[moji] += 1", "-for i in sorted(list(dic.items()), key=lambda x: x[1]):", "- ...
false
0.048665
0.048715
0.998962
[ "s129803729", "s216465652" ]
u004423772
p02629
python
s681067092
s768822065
94
86
68,772
71,856
Accepted
Accepted
8.51
import sys input = sys.stdin.readline import string import sys import math ALPHABET = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] result = [] def alphabet_decimal(v): quotient = math.floor(v / len(ALPHABET)) surplus = v % len(ALPHABET) ...
import sys input = sys.stdin.readline import string def main(): def f(n): if n == -1:return a, b = divmod(n, 26) ans.append(string.ascii_lowercase[b]) f(a-1) N = int(eval(input())) ans = [] f(N-1) print(("".join(ans[::-1]))) if __name__ == "__main__": ...
26
16
773
322
import sys input = sys.stdin.readline import string import sys import math ALPHABET = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "...
import sys input = sys.stdin.readline import string def main(): def f(n): if n == -1: return a, b = divmod(n, 26) ans.append(string.ascii_lowercase[b]) f(a - 1) N = int(eval(input())) ans = [] f(N - 1) print(("".join(ans[::-1]))) if __name__ == "__ma...
false
38.461538
[ "-import sys", "-import math", "-", "-ALPHABET = [", "- \"A\",", "- \"B\",", "- \"C\",", "- \"D\",", "- \"E\",", "- \"F\",", "- \"G\",", "- \"H\",", "- \"I\",", "- \"J\",", "- \"K\",", "- \"L\",", "- \"M\",", "- \"N\",", "- \"O\",", ...
false
0.037333
0.040369
0.924783
[ "s681067092", "s768822065" ]
u327532412
p02861
python
s293227940
s923993797
495
334
8,052
18,792
Accepted
Accepted
32.53
from itertools import permutations N = int(eval(input())) comb = list(permutations([i for i in range(0, N)], N)) xy = [] for _ in range(N): x, y = list(map(int, input().split())) xy.append([x, y]) ans = 0 for c in comb: for i in range(0, N-1): x = ((xy[c[i]][0] - xy[c[i+1]][0]) ** 2) ...
from itertools import permutations N = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(N)] ans = 0 li = list(permutations(list(range(N)))) l = len(list(permutations(list(range(N))))) for i in li: for j in range(N-1): x1, x2 = xy[i[j]][0], xy[i[j+1]][0] y1, y2 = xy[i[...
14
12
405
394
from itertools import permutations N = int(eval(input())) comb = list(permutations([i for i in range(0, N)], N)) xy = [] for _ in range(N): x, y = list(map(int, input().split())) xy.append([x, y]) ans = 0 for c in comb: for i in range(0, N - 1): x = (xy[c[i]][0] - xy[c[i + 1]][0]) ** 2 y = ...
from itertools import permutations N = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(N)] ans = 0 li = list(permutations(list(range(N)))) l = len(list(permutations(list(range(N))))) for i in li: for j in range(N - 1): x1, x2 = xy[i[j]][0], xy[i[j + 1]][0] y1, y2 = xy[i[j]][...
false
14.285714
[ "-comb = list(permutations([i for i in range(0, N)], N))", "-xy = []", "-for _ in range(N):", "- x, y = list(map(int, input().split()))", "- xy.append([x, y])", "+xy = [list(map(int, input().split())) for _ in range(N)]", "-for c in comb:", "- for i in range(0, N - 1):", "- x = (xy[c...
false
0.053339
0.057794
0.922906
[ "s293227940", "s923993797" ]
u879870653
p03290
python
s618389580
s742615716
30
27
3,064
3,064
Accepted
Accepted
10
D,G = list(map(int,input().split())) P = [] C = [] for i in range(D) : p,c = list(map(int,input().split())) P.append(p) C.append(c) ans = float("inf") for i in range(1 << D) : # 2**D ct = 0 #cost score = 0 for j in range(D) : if (i >> j) & 1 : #bit全探索 score += C[...
D,G = list(map(int,input().split())) L = [list(map(int,input().split())) for i in range(D)] ans = float("inf") for bit in range(2 ** D) : score = 0 AC = 0 for k in range(D) : if bit & (1 << k) : p,c = L[k] score += c AC += p score += p*(k+...
27
32
694
799
D, G = list(map(int, input().split())) P = [] C = [] for i in range(D): p, c = list(map(int, input().split())) P.append(p) C.append(c) ans = float("inf") for i in range(1 << D): # 2**D ct = 0 # cost score = 0 for j in range(D): if (i >> j) & 1: # bit全探索 score += C[j] # bo...
D, G = list(map(int, input().split())) L = [list(map(int, input().split())) for i in range(D)] ans = float("inf") for bit in range(2**D): score = 0 AC = 0 for k in range(D): if bit & (1 << k): p, c = L[k] score += c AC += p score += p * (k + 1) * 100 ...
false
15.625
[ "-P = []", "-C = []", "-for i in range(D):", "- p, c = list(map(int, input().split()))", "- P.append(p)", "- C.append(c)", "+L = [list(map(int, input().split())) for i in range(D)]", "-for i in range(1 << D): # 2**D", "- ct = 0 # cost", "+for bit in range(2**D):", "- for j in ra...
false
0.260897
0.048518
5.377297
[ "s618389580", "s742615716" ]
u753386263
p03160
python
s864804345
s312637451
244
101
52,208
84,852
Accepted
Accepted
58.61
N=int(eval(input())) h=list(map(int, input().split())) dp=[0]*N for i in range(N): if i==0: dp[i]=0 elif i==1: dp[i]=abs(h[i]-h[i-1]) else: dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) print((dp[-1]))
N=int(eval(input())) h=list(map(int, input().split())) dp=[10000000000000]*(N+2) #初期状態 dp[0]=0 #配るDP for i in range(N): try: dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i])) except IndexError: pass try: dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i])) except IndexError: ...
11
16
240
337
N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N for i in range(N): if i == 0: dp[i] = 0 elif i == 1: dp[i] = abs(h[i] - h[i - 1]) else: dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[-1]))
N = int(eval(input())) h = list(map(int, input().split())) dp = [10000000000000] * (N + 2) # 初期状態 dp[0] = 0 # 配るDP for i in range(N): try: dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) except IndexError: pass try: dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) ...
false
31.25
[ "-dp = [0] * N", "+dp = [10000000000000] * (N + 2)", "+# 初期状態", "+dp[0] = 0", "+# 配るDP", "- if i == 0:", "- dp[i] = 0", "- elif i == 1:", "- dp[i] = abs(h[i] - h[i - 1])", "- else:", "- dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))"...
false
0.108957
0.081933
1.329827
[ "s864804345", "s312637451" ]
u875291233
p03722
python
s527412493
s794127565
1,337
1,062
3,316
3,316
Accepted
Accepted
20.57
# coding: utf-8 # Your code here! def Bellman_Ford(g,start): n = len(g) dist = [float("inf")]*n dist[start] = 0 a0 = float("inf") negative = [False]*n for i in range((2*n)): updated = False for v in range(n): for to, cost in g[v]: if ...
# coding: utf-8 # Your code here! def Bellman_Ford(g,start): n = len(g) dist = [float("inf")]*n dist[start] = 0 a0 = float("inf") for i in range(n<<1): updated = False for v in range(n): for to, cost in g[v]: if dist[to] <= dist[v] +...
41
39
1,025
918
# coding: utf-8 # Your code here! def Bellman_Ford(g, start): n = len(g) dist = [float("inf")] * n dist[start] = 0 a0 = float("inf") negative = [False] * n for i in range((2 * n)): updated = False for v in range(n): for to, cost in g[v]: if negative[v]...
# coding: utf-8 # Your code here! def Bellman_Ford(g, start): n = len(g) dist = [float("inf")] * n dist[start] = 0 a0 = float("inf") for i in range(n << 1): updated = False for v in range(n): for to, cost in g[v]: if dist[to] <= dist[v] + cost: ...
false
4.878049
[ "- negative = [False] * n", "- for i in range((2 * n)):", "+ for i in range(n << 1):", "- if negative[v]:", "- negative[to] = True", "- if i >= n:", "- negative[to] = True", "- if negative[-1]:", "+ if i <= n:", ...
false
0.037066
0.03636
1.019421
[ "s527412493", "s794127565" ]
u255280439
p03400
python
s496851968
s264240459
51
43
5,140
4,892
Accepted
Accepted
15.69
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = { id(v): k for k, v in list(inspect.currentframe().f_back.f_locals.items()) } print(('...
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = { id(v): k for k, v in list(inspect.currentframe().f_back.f_locals.items()) } print(...
49
176
793
3,173
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = {id(v): k for k, v in list(inspect.currentframe().f_back.f_locals.items())} print((", ".join(names.get(id(arg), "???") + " = ...
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = {id(v): k for k, v in list(inspect.currentframe().f_back.f_locals.items())} print((", ".join(names.get(id(arg), "???") + " ...
false
72.159091
[ "-sys.setrecursionlimit(10000)", "+sys.setrecursionlimit(1000000)", "+", "+", "+def gcd(n, m):", "+ if n % m == 0:", "+ return m", "+ else:", "+ return gcd(m, n % m)", "+", "+", "+def gcd_list(L):", "+ v = L[0]", "+ for i in range(1, len(L)):", "+ v = gcd...
false
0.087608
0.104223
0.840585
[ "s496851968", "s264240459" ]
u620868411
p03805
python
s020056389
s794875925
26
23
3,064
3,064
Accepted
Accepted
11.54
# -*- coding: utf-8 -*- line = input().split(" ") n = int(line[0]) m = int(line[1]) edge = [[] for _ in range(n+1)] for _ in range(m): line = input().split(" ") a = int(line[0]) b = int(line[1]) edge[a].append(b) edge[b].append(a) visited = [False for _ in range(n+1)] visited[0...
# -*- coding: utf-8 -*- n,m = list(map(int, input().split())) edge = [[] for _ in range(n+1)] for _ in range(m): a,b = list(map(int, input().split())) a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) visited = [False for _ in range(n)] def dfs(v): if all(visited): return 1...
37
24
689
515
# -*- coding: utf-8 -*- line = input().split(" ") n = int(line[0]) m = int(line[1]) edge = [[] for _ in range(n + 1)] for _ in range(m): line = input().split(" ") a = int(line[0]) b = int(line[1]) edge[a].append(b) edge[b].append(a) visited = [False for _ in range(n + 1)] visited[0] = True # dummy ...
# -*- coding: utf-8 -*- n, m = list(map(int, input().split())) edge = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) visited = [False for _ in range(n)] def dfs(v): if all(visited): return 1 res...
false
35.135135
[ "-line = input().split(\" \")", "-n = int(line[0])", "-m = int(line[1])", "+n, m = list(map(int, input().split()))", "- line = input().split(\" \")", "- a = int(line[0])", "- b = int(line[1])", "+ a, b = list(map(int, input().split()))", "+ a -= 1", "+ b -= 1", "-visited = [Fal...
false
0.043379
0.043783
0.990763
[ "s020056389", "s794875925" ]
u537782349
p03423
python
s240781893
s725109722
19
17
3,060
2,940
Accepted
Accepted
10.53
a = int(eval(input())) print((a // 3))
print((int(eval(input())) // 3))
2
1
32
25
a = int(eval(input())) print((a // 3))
print((int(eval(input())) // 3))
false
50
[ "-a = int(eval(input()))", "-print((a // 3))", "+print((int(eval(input())) // 3))" ]
false
0.047524
0.046296
1.026538
[ "s240781893", "s725109722" ]
u562016607
p03634
python
s765375715
s334799117
1,567
991
60,788
62,456
Accepted
Accepted
36.76
import queue N=int(eval(input())) G=[dict() for i in range(N)] for i in range(N-1): a,b,c=list(map(int,input().split())) G[a-1][b-1]=c G[b-1][a-1]=c Q,K=list(map(int,input().split()));K-=1 x=[0 for i in range(Q)] y=[0 for i in range(Q)] for i in range(Q): x[i],y[i]=list(map(int,input().split(...
import queue N=int(eval(input())) G=[dict() for i in range(N)] for i in range(N-1): a,b,c=list(map(int,input().split())) G[a-1][b-1]=c G[b-1][a-1]=c Q,K=list(map(int,input().split()));K-=1 x=[0 for i in range(Q)] y=[0 for i in range(Q)] for i in range(Q): x[i],y[i]=list(map(int,input().split(...
27
28
604
604
import queue N = int(eval(input())) G = [dict() for i in range(N)] for i in range(N - 1): a, b, c = list(map(int, input().split())) G[a - 1][b - 1] = c G[b - 1][a - 1] = c Q, K = list(map(int, input().split())) K -= 1 x = [0 for i in range(Q)] y = [0 for i in range(Q)] for i in range(Q): x[i], y[i] = l...
import queue N = int(eval(input())) G = [dict() for i in range(N)] for i in range(N - 1): a, b, c = list(map(int, input().split())) G[a - 1][b - 1] = c G[b - 1][a - 1] = c Q, K = list(map(int, input().split())) K -= 1 x = [0 for i in range(Q)] y = [0 for i in range(Q)] for i in range(Q): x[i], y[i] = l...
false
3.571429
[ "-q = queue.Queue()", "-q.put(K)", "+q = []", "+q.append(K)", "-while not (q.empty()):", "- r = q.get()", "+while len(q) > 0:", "+ r = q[-1]", "+ q.pop()", "- q.put(p)", "+ q.append(p)" ]
false
0.120669
0.119567
1.009213
[ "s765375715", "s334799117" ]
u724844363
p03775
python
s899246944
s707411115
39
27
3,060
3,188
Accepted
Accepted
30.77
n = int(eval(input())) jud = [] for i in range(1, int(n**0.5) + 1): x = n // i if x * i == n: jud.append(len(str(x))) print((min(jud)))
def yaku(n): yalu_l = [] for j in range(1, int(n ** 0.5) + 1): if n % j == 0: yalu_l.append([n // j, j]) else: continue return yalu_l ans = 10 ** 9 n = int(eval(input())) for i in yaku(n): p = len(str(i[0])) q = len(str(i[1])) ans = mi...
7
20
149
345
n = int(eval(input())) jud = [] for i in range(1, int(n**0.5) + 1): x = n // i if x * i == n: jud.append(len(str(x))) print((min(jud)))
def yaku(n): yalu_l = [] for j in range(1, int(n**0.5) + 1): if n % j == 0: yalu_l.append([n // j, j]) else: continue return yalu_l ans = 10**9 n = int(eval(input())) for i in yaku(n): p = len(str(i[0])) q = len(str(i[1])) ans = min(max(p, q), ans) print...
false
65
[ "+def yaku(n):", "+ yalu_l = []", "+ for j in range(1, int(n**0.5) + 1):", "+ if n % j == 0:", "+ yalu_l.append([n // j, j])", "+ else:", "+ continue", "+ return yalu_l", "+", "+", "+ans = 10**9", "-jud = []", "-for i in range(1, int(n**0.5) + 1):...
false
0.04232
0.038172
1.108667
[ "s899246944", "s707411115" ]
u648881683
p03283
python
s763355919
s370491882
1,007
874
58,332
60,460
Accepted
Accepted
13.21
import sys input = lambda: sys.stdin.readline().rstrip() def resolve(): N, M, Q = list(map(int, input().split())) L = [0]*M R = [0]*M p = [0]*Q q = [0]*Q for i in range(M): L[i], R[i] = list(map(int, input().split())) for i in range(Q): p[i], q[i] = list(map(int...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = 10**20 def I(): return int(eval(input())) def F(): return float(eval(input())) def S(): return eval(input()) def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] def ...
31
37
785
1,037
import sys input = lambda: sys.stdin.readline().rstrip() def resolve(): N, M, Q = list(map(int, input().split())) L = [0] * M R = [0] * M p = [0] * Q q = [0] * Q for i in range(M): L[i], R[i] = list(map(int, input().split())) for i in range(Q): p[i], q[i] = list(map(int, i...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = 10**20 def I(): return int(eval(input())) def F(): return float(eval(input())) def S(): return eval(input()) def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x) - 1 for x i...
false
16.216216
[ "+sys.setrecursionlimit(10**7)", "+INF = 10**20", "+", "+", "+def I():", "+ return int(eval(input()))", "+", "+", "+def F():", "+ return float(eval(input()))", "+", "+", "+def S():", "+ return eval(input())", "+", "+", "+def LI():", "+ return [int(x) for x in input().sp...
false
0.04221
0.033396
1.263919
[ "s763355919", "s370491882" ]
u790710233
p03161
python
s128627540
s727560199
507
435
53,344
55,264
Accepted
Accepted
14.2
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [0]*n dp[1] = abs(h[1]-h[0]) for i in range(2, n): dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, k)+1)) print((dp[-1]))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) INF = float('inf') dp = [INF]*n dp[0] = 0 for i in range(n): for j in range(1, k+1): if n <= i+j: continue dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i])) print((dp[-1]))
7
12
218
280
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [0] * n dp[1] = abs(h[1] - h[0]) for i in range(2, n): dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)) print((dp[-1]))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) INF = float("inf") dp = [INF] * n dp[0] = 0 for i in range(n): for j in range(1, k + 1): if n <= i + j: continue dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) print((dp[-1]))
false
41.666667
[ "-dp = [0] * n", "-dp[1] = abs(h[1] - h[0])", "-for i in range(2, n):", "- dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1))", "+INF = float(\"inf\")", "+dp = [INF] * n", "+dp[0] = 0", "+for i in range(n):", "+ for j in range(1, k + 1):", "+ if n <= i + j:...
false
0.037121
0.035555
1.044025
[ "s128627540", "s727560199" ]
u777283665
p02832
python
s541811343
s970307541
122
90
26,268
24,744
Accepted
Accepted
26.23
n = int(eval(input())) a = list(map(int, input().split())) start = 1 i = 0 while i < n: if a[i] == start: start += 1 i += 1 else: i += 1 start -= 1 if start == 0: print((-1)) else: print((n-start))
n = int(eval(input())) A = list(map(int, input().split())) v = 1 for a in A: if a == v: v += 1 print((-1 if v==1 else n-v+1))
18
9
247
139
n = int(eval(input())) a = list(map(int, input().split())) start = 1 i = 0 while i < n: if a[i] == start: start += 1 i += 1 else: i += 1 start -= 1 if start == 0: print((-1)) else: print((n - start))
n = int(eval(input())) A = list(map(int, input().split())) v = 1 for a in A: if a == v: v += 1 print((-1 if v == 1 else n - v + 1))
false
50
[ "-a = list(map(int, input().split()))", "-start = 1", "-i = 0", "-while i < n:", "- if a[i] == start:", "- start += 1", "- i += 1", "- else:", "- i += 1", "-start -= 1", "-if start == 0:", "- print((-1))", "-else:", "- print((n - start))", "+A = list(map(...
false
0.033815
0.035001
0.966097
[ "s541811343", "s970307541" ]
u593567568
p02996
python
s623020582
s365268469
986
689
53,852
54,088
Accepted
Accepted
30.12
N = int(eval(input())) AB = [[int(x) for x in input().split()] for _ in range(N)] AB.sort(key=lambda x:(x[1],x[0])) t = 0 ans = 'Yes' for a,b in AB: t += a if t <= b: continue else: ans = 'No' break print(ans)
import sys input = sys.stdin.readline N = int(eval(input())) AB = [[int(x) for x in input().split()] for _ in range(N)] AB.sort(key=lambda x:(x[1],x[0])) t = 0 ans = 'Yes' for a,b in AB: t += a if t <= b: continue else: ans = 'No' break print(ans)
15
19
257
301
N = int(eval(input())) AB = [[int(x) for x in input().split()] for _ in range(N)] AB.sort(key=lambda x: (x[1], x[0])) t = 0 ans = "Yes" for a, b in AB: t += a if t <= b: continue else: ans = "No" break print(ans)
import sys input = sys.stdin.readline N = int(eval(input())) AB = [[int(x) for x in input().split()] for _ in range(N)] AB.sort(key=lambda x: (x[1], x[0])) t = 0 ans = "Yes" for a, b in AB: t += a if t <= b: continue else: ans = "No" break print(ans)
false
21.052632
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.039014
0.038713
1.007781
[ "s623020582", "s365268469" ]
u175034939
p03160
python
s889576154
s436292779
149
131
13,924
13,924
Accepted
Accepted
12.08
n = int(eval(input())) h = list(map(int, input().split())) INF = 10**8 dp = [INF]*n dp[0] = 0 for i in range(n-1): if i == 0: dp[i+1] = abs(h[i+1]-h[i]) else: dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]), dp[i-1]+abs(h[i+1]-h[i-1])) print((dp[n-1]))
n = int(eval(input())) h = list(map(int, input().split())) INF = 10**8 dp = [INF]*n dp[0] = 0 for i in range(1, n): if i == 1: dp[i] = abs(h[i]-h[i-1]) else: dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print((dp[n-1]))
11
11
268
265
n = int(eval(input())) h = list(map(int, input().split())) INF = 10**8 dp = [INF] * n dp[0] = 0 for i in range(n - 1): if i == 0: dp[i + 1] = abs(h[i + 1] - h[i]) else: dp[i + 1] = min( dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1]) ) print((dp[n - 1]))
n = int(eval(input())) h = list(map(int, input().split())) INF = 10**8 dp = [INF] * n dp[0] = 0 for i in range(1, n): if i == 1: dp[i] = abs(h[i] - h[i - 1]) else: dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[n - 1]))
false
0
[ "-for i in range(n - 1):", "- if i == 0:", "- dp[i + 1] = abs(h[i + 1] - h[i])", "+for i in range(1, n):", "+ if i == 1:", "+ dp[i] = abs(h[i] - h[i - 1])", "- dp[i + 1] = min(", "- dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1])", "- )...
false
0.041776
0.042277
0.988156
[ "s889576154", "s436292779" ]
u934442292
p03958
python
s373830388
s746437434
85
74
3,316
9,164
Accepted
Accepted
12.94
import sys from collections import Counter input = sys.stdin.readline def main(): K, T = list(map(int, input().split())) a = list(map(int, input().split())) ans = 0 prev_j = -1 for i in range(K): j_max = 0 n_max = 0 for j in range(T): if j == p...
import sys input = sys.stdin.readline def main(): K, T = list(map(int, input().split())) A = list(map(int, input().split())) prev_idx = -1 ans = 0 for _ in range(K): cur_idx = -1 max_num = 0 for i, a in enumerate(A): if i == prev_idx: ...
31
31
610
608
import sys from collections import Counter input = sys.stdin.readline def main(): K, T = list(map(int, input().split())) a = list(map(int, input().split())) ans = 0 prev_j = -1 for i in range(K): j_max = 0 n_max = 0 for j in range(T): if j == prev_j: ...
import sys input = sys.stdin.readline def main(): K, T = list(map(int, input().split())) A = list(map(int, input().split())) prev_idx = -1 ans = 0 for _ in range(K): cur_idx = -1 max_num = 0 for i, a in enumerate(A): if i == prev_idx: continue ...
false
0
[ "-from collections import Counter", "- a = list(map(int, input().split()))", "+ A = list(map(int, input().split()))", "+ prev_idx = -1", "- prev_j = -1", "- for i in range(K):", "- j_max = 0", "- n_max = 0", "- for j in range(T):", "- if j == prev_j:"...
false
0.037382
0.112684
0.331745
[ "s373830388", "s746437434" ]
u562935282
p02721
python
s883341135
s538204417
463
159
33,284
34,672
Accepted
Accepted
65.66
def main(): from bisect import bisect_left, bisect_right N, K, C = map(int, input().split()) s = input() L = [0] * (N + 2) R = [0] * (N + 2) # 1-indexedで管理した # 貪欲に端から配置した場合に達成可能な # 累積配置数 need = [0] * N i = 0 while i < N: if s[i] == 'o': ...
def main(): N, K, C = map(int, input().split()) S = input() L = [-1] * K # 0-ind i = 0 cur = 0 while i < N: if S[i] == 'o': L[cur] = i cur += 1 if cur == K: break i += C i += 1 R = [-1] * K # 0-ind i ...
62
34
1,331
637
def main(): from bisect import bisect_left, bisect_right N, K, C = map(int, input().split()) s = input() L = [0] * (N + 2) R = [0] * (N + 2) # 1-indexedで管理した # 貪欲に端から配置した場合に達成可能な # 累積配置数 need = [0] * N i = 0 while i < N: if s[i] == "o": L[i + 1] = 1 ...
def main(): N, K, C = map(int, input().split()) S = input() L = [-1] * K # 0-ind i = 0 cur = 0 while i < N: if S[i] == "o": L[cur] = i cur += 1 if cur == K: break i += C i += 1 R = [-1] * K # 0-ind i = N - ...
false
45.16129
[ "- from bisect import bisect_left, bisect_right", "-", "- s = input()", "- L = [0] * (N + 2)", "- R = [0] * (N + 2)", "- # 1-indexedで管理した", "- # 貪欲に端から配置した場合に達成可能な", "- # 累積配置数", "- need = [0] * N", "+ S = input()", "+ L = [-1] * K # 0-ind", "+ cur = 0", "- ...
false
0.046282
0.042259
1.095198
[ "s883341135", "s538204417" ]
u756829954
p02924
python
s165356623
s120682908
1,477
188
38,768
38,384
Accepted
Accepted
87.27
def p_d(): N = int(eval(input())) ans = 0 for i in range(N): ans += i print(ans) if __name__ == '__main__': p_d()
def p_d(): N = int(eval(input())) print((N * (N - 1)//2)) if __name__ == '__main__': p_d()
12
7
151
107
def p_d(): N = int(eval(input())) ans = 0 for i in range(N): ans += i print(ans) if __name__ == "__main__": p_d()
def p_d(): N = int(eval(input())) print((N * (N - 1) // 2)) if __name__ == "__main__": p_d()
false
41.666667
[ "- ans = 0", "- for i in range(N):", "- ans += i", "- print(ans)", "+ print((N * (N - 1) // 2))" ]
false
0.075544
0.042456
1.77934
[ "s165356623", "s120682908" ]
u162893962
p03607
python
s877580579
s058265319
210
193
16,272
17,888
Accepted
Accepted
8.1
n = int(eval(input())) nums = [int(eval(input())) for _ in range(n)] cnt = {} ans = 0 for x in nums: if x not in cnt: cnt[x] = 1 else: cnt[x] += 1 for y in list(cnt.values()): if y % 2 != 0: ans += 1 print(ans)
N = int(eval(input())) ds = {} for _ in range(N): A = eval(input()) if A not in ds: ds[A] = 0 else: ds[A] += 1 cnt = 0 for d in ds: if ds[d] % 2 == 0: cnt += 1 print(cnt)
14
17
242
219
n = int(eval(input())) nums = [int(eval(input())) for _ in range(n)] cnt = {} ans = 0 for x in nums: if x not in cnt: cnt[x] = 1 else: cnt[x] += 1 for y in list(cnt.values()): if y % 2 != 0: ans += 1 print(ans)
N = int(eval(input())) ds = {} for _ in range(N): A = eval(input()) if A not in ds: ds[A] = 0 else: ds[A] += 1 cnt = 0 for d in ds: if ds[d] % 2 == 0: cnt += 1 print(cnt)
false
17.647059
[ "-n = int(eval(input()))", "-nums = [int(eval(input())) for _ in range(n)]", "-cnt = {}", "-ans = 0", "-for x in nums:", "- if x not in cnt:", "- cnt[x] = 1", "+N = int(eval(input()))", "+ds = {}", "+for _ in range(N):", "+ A = eval(input())", "+ if A not in ds:", "+ d...
false
0.037205
0.034605
1.075146
[ "s877580579", "s058265319" ]
u112364985
p02658
python
s110779069
s414036598
93
84
84,812
21,388
Accepted
Accepted
9.68
import sys n=int(eval(input())) List=list(map(int,input().split())) List.sort(reverse=True) if List[-1]==0: print((0)) sys.exit() ans=1 for i in List: if ans<=10**18: ans*=i else: print((-1)) sys.exit() if ans<=10**18: print(ans) else: print((-1))
n=int(eval(input())) a=list(map(int,input().split())) ans=1 a.sort(reverse=True) if a[-1]==0: print((0)) exit() for i in range(len(a)): ans*=a[i] if ans>1000000000000000000: ans=-1 break print(ans)
18
13
300
233
import sys n = int(eval(input())) List = list(map(int, input().split())) List.sort(reverse=True) if List[-1] == 0: print((0)) sys.exit() ans = 1 for i in List: if ans <= 10**18: ans *= i else: print((-1)) sys.exit() if ans <= 10**18: print(ans) else: print((-1))
n = int(eval(input())) a = list(map(int, input().split())) ans = 1 a.sort(reverse=True) if a[-1] == 0: print((0)) exit() for i in range(len(a)): ans *= a[i] if ans > 1000000000000000000: ans = -1 break print(ans)
false
27.777778
[ "-import sys", "-", "-List = list(map(int, input().split()))", "-List.sort(reverse=True)", "-if List[-1] == 0:", "+a = list(map(int, input().split()))", "+ans = 1", "+a.sort(reverse=True)", "+if a[-1] == 0:", "- sys.exit()", "-ans = 1", "-for i in List:", "- if ans <= 10**18:", "- ...
false
0.037447
0.036964
1.013041
[ "s110779069", "s414036598" ]
u762420987
p03627
python
s682705409
s382795252
338
255
68,760
69,528
Accepted
Accepted
24.56
from collections import Counter N = int(eval(input())) Ac = Counter(list(map(int, input().split()))) sticks = sorted({k:v for k, v in list(Ac.items()) if v >= 2}.items())[::-1] if len(sticks) == 0: print((0)) else: if sticks[0][1] >= 4: print((sticks[0][0]**2)) else: print((sticks[...
from collections import Counter N = int(eval(input())) Alist = list(map(int, input().split())) Ac = Counter(Alist) length_list = sorted(list(Ac.keys()), reverse=True) can_use = [] for l in length_list: if Ac[l] >= 4: if can_use: print((can_use[0]*l)) exit() else: ...
11
22
323
503
from collections import Counter N = int(eval(input())) Ac = Counter(list(map(int, input().split()))) sticks = sorted({k: v for k, v in list(Ac.items()) if v >= 2}.items())[::-1] if len(sticks) == 0: print((0)) else: if sticks[0][1] >= 4: print((sticks[0][0] ** 2)) else: print((sticks[0][0] ...
from collections import Counter N = int(eval(input())) Alist = list(map(int, input().split())) Ac = Counter(Alist) length_list = sorted(list(Ac.keys()), reverse=True) can_use = [] for l in length_list: if Ac[l] >= 4: if can_use: print((can_use[0] * l)) exit() else: ...
false
50
[ "-Ac = Counter(list(map(int, input().split())))", "-sticks = sorted({k: v for k, v in list(Ac.items()) if v >= 2}.items())[::-1]", "-if len(sticks) == 0:", "- print((0))", "-else:", "- if sticks[0][1] >= 4:", "- print((sticks[0][0] ** 2))", "- else:", "- print((sticks[0][0] * ...
false
0.100731
0.067406
1.494392
[ "s682705409", "s382795252" ]
u934442292
p03044
python
s022343186
s513889744
750
544
79,488
79,492
Accepted
Accepted
27.47
import sys sys.setrecursionlimit(100000) N = int(eval(input())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 G[u].append((v, w)) G[v].append((u, w)) C = [-1 for _ in range(N)] def dfs(pos, color): C[pos] = color ...
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) N = int(eval(input())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 G[u].append((v, w)) G[v].append((u, w)) C = [-1 for _ in range(N)] def dfs(pos, col...
33
34
598
626
import sys sys.setrecursionlimit(100000) N = int(eval(input())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 G[u].append((v, w)) G[v].append((u, w)) C = [-1 for _ in range(N)] def dfs(pos, color): C[pos] = color for e in G[pos]:...
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) N = int(eval(input())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 G[u].append((v, w)) G[v].append((u, w)) C = [-1 for _ in range(N)] def dfs(pos, color): C[pos] =...
false
2.941176
[ "+input = sys.stdin.readline" ]
false
0.035453
0.037497
0.945502
[ "s022343186", "s513889744" ]
u197955752
p03108
python
s614812513
s105317014
978
526
76,120
28,800
Accepted
Accepted
46.22
# Union-Find木を使って書き直し # Union-Find木(サイズ付き) class UnionFind(): def __init__(self, n): # n要素で初期化 初めは全ての頂点が別々の木の根 self.parent = [None] * n # 親 self.rank = [None] * n # 木の深さ self._size = [1] * n # 要素が属する集合の大きさ(根の要素のみ参照すること) for i in range(n): self.parent[i] = i ...
# 20-08-12再トライ import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.rank = [0] * n self.par = list(range(n)) self._size = [1] * n # 木の根のみ有効、集合に属する要素数 def find(self, x): ch = [] while self.par[x] != x: ch.append(x...
73
57
1,967
1,417
# Union-Find木を使って書き直し # Union-Find木(サイズ付き) class UnionFind: def __init__(self, n): # n要素で初期化 初めは全ての頂点が別々の木の根 self.parent = [None] * n # 親 self.rank = [None] * n # 木の深さ self._size = [1] * n # 要素が属する集合の大きさ(根の要素のみ参照すること) for i in range(n): self.parent[i] = i ...
# 20-08-12再トライ import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.rank = [0] * n self.par = list(range(n)) self._size = [1] * n # 木の根のみ有効、集合に属する要素数 def find(self, x): ch = [] while self.par[x] != x: ch.append(x) ...
false
21.917808
[ "-# Union-Find木を使って書き直し", "-# Union-Find木(サイズ付き)", "+# 20-08-12再トライ", "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "- def __init__(self, n): # n要素で初期化 初めは全ての頂点が別々の木の根", "- self.parent = [None] * n # 親", "- self.rank = [None] * n # 木の深さ", "- self._size...
false
0.040133
0.040049
1.002088
[ "s614812513", "s105317014" ]
u136869985
p04045
python
s134023085
s105043683
182
46
39,792
3,060
Accepted
Accepted
74.73
def main(): N, K = list(map(int, input().split())) D = list(input().split()) i = 0 while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) ...
def main(): N, K = list(map(int, input().split())) D = list(input().split()) while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) if __name_...
19
18
353
342
def main(): N, K = list(map(int, input().split())) D = list(input().split()) i = 0 while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) if __name__ == "__ma...
def main(): N, K = list(map(int, input().split())) D = list(input().split()) while True: S = str(N) f = True for s in S: if s in D: f = False break if f: break N += 1 print(N) if __name__ == "__main__": ...
false
5.263158
[ "- i = 0" ]
false
0.037884
0.038411
0.986274
[ "s134023085", "s105043683" ]
u473291366
p03161
python
s519631944
s628097113
1,829
420
14,052
56,032
Accepted
Accepted
77.04
N, K = list(map(int, input().split())) H = list(map(int, input().split())) dp = [0 for _ in range(N)] for i, hi in enumerate(H): if i == 0: continue r = max(0, i - K) dp[i] = min(d + abs(hi - h) for d, h in zip(dp[r:i], H[r:i])) print((dp[N-1]))
N, K = list(map(int, input().split())) H = list(map(int, input().split())) dp = [0 for _ in range(N)] for i in range(1, N): min_v = 1050000000 for j in range(1, K+1): if i - j >= 0: min_v = min(min_v, dp[i - j] + abs(H[i] - H[i - j])) dp[i] = min_v print((dp[N-1]))
10
11
267
301
N, K = list(map(int, input().split())) H = list(map(int, input().split())) dp = [0 for _ in range(N)] for i, hi in enumerate(H): if i == 0: continue r = max(0, i - K) dp[i] = min(d + abs(hi - h) for d, h in zip(dp[r:i], H[r:i])) print((dp[N - 1]))
N, K = list(map(int, input().split())) H = list(map(int, input().split())) dp = [0 for _ in range(N)] for i in range(1, N): min_v = 1050000000 for j in range(1, K + 1): if i - j >= 0: min_v = min(min_v, dp[i - j] + abs(H[i] - H[i - j])) dp[i] = min_v print((dp[N - 1]))
false
9.090909
[ "-for i, hi in enumerate(H):", "- if i == 0:", "- continue", "- r = max(0, i - K)", "- dp[i] = min(d + abs(hi - h) for d, h in zip(dp[r:i], H[r:i]))", "+for i in range(1, N):", "+ min_v = 1050000000", "+ for j in range(1, K + 1):", "+ if i - j >= 0:", "+ min...
false
0.046739
0.037839
1.235227
[ "s519631944", "s628097113" ]
u200887663
p02995
python
s862421924
s155994964
41
35
5,432
5,048
Accepted
Accepted
14.63
a,b,c,d=list(map(int,input().split())) import fractions lcm=c*d//fractions.gcd(c,d) #1~Bの中 count=b-(b//c+b//d)+b//lcm #1~A-1の中 temp_count=a-1-((a-1)//c+(a-1)//d)+(a-1)//lcm print((count-temp_count))
#n=int(input()) a,b,c,d=list(map(int,input().split())) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] import fractions lcm=(c*d)//fractions.gcd(c,d)#最小公倍数 brng=b-(b//c+b//d)+b//lcm arng=(a-1)-((a-1)//c+(a-1)//d)+(a-1)//lcm ans=brng-arng print(ans)
9
11
200
293
a, b, c, d = list(map(int, input().split())) import fractions lcm = c * d // fractions.gcd(c, d) # 1~Bの中 count = b - (b // c + b // d) + b // lcm # 1~A-1の中 temp_count = a - 1 - ((a - 1) // c + (a - 1) // d) + (a - 1) // lcm print((count - temp_count))
# n=int(input()) a, b, c, d = list(map(int, input().split())) # l=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] import fractions lcm = (c * d) // fractions.gcd(c, d) # 最小公倍数 brng = b - (b // c + b // d) + b // lcm arng = (a - 1) - ((a - 1) // c + (a - 1) // d) + (a - 1) // lcm ...
false
18.181818
[ "+# n=int(input())", "+# l=list(map(int,input().split()))", "+# l=[list(map(int,input().split())) for i in range(n)]", "-lcm = c * d // fractions.gcd(c, d)", "-# 1~Bの中", "-count = b - (b // c + b // d) + b // lcm", "-# 1~A-1の中", "-temp_count = a - 1 - ((a - 1) // c + (a - 1) // d) + (a - 1) // lcm", ...
false
0.050353
0.050342
1.000231
[ "s862421924", "s155994964" ]
u493520238
p02861
python
s464100143
s936263144
470
92
3,064
80,228
Accepted
Accepted
80.43
import itertools n = int(eval(input())) p_list = itertools.permutations([x for x in range(n)]) # for p in p_list: # print(p) a_list = [] for i in range(n): a_list.append(list(map(int,input().split()))) d_sum = 0 cnt = 0 for p in p_list: cnt+=1 curr_d_sum = 0 curr_pos = p[0] ...
from itertools import permutations from math import sqrt n = int(eval(input())) xyl = [] for _ in range(n): x,y = list(map(int, input().split())) xyl.append((x,y)) ll = list(range(0,n)) perml = list(permutations(ll, n)) val = 0 for perm in perml: prev_x = 0 prev_y = 0 for i,p in e...
27
28
555
574
import itertools n = int(eval(input())) p_list = itertools.permutations([x for x in range(n)]) # for p in p_list: # print(p) a_list = [] for i in range(n): a_list.append(list(map(int, input().split()))) d_sum = 0 cnt = 0 for p in p_list: cnt += 1 curr_d_sum = 0 curr_pos = p[0] for i in p: ...
from itertools import permutations from math import sqrt n = int(eval(input())) xyl = [] for _ in range(n): x, y = list(map(int, input().split())) xyl.append((x, y)) ll = list(range(0, n)) perml = list(permutations(ll, n)) val = 0 for perm in perml: prev_x = 0 prev_y = 0 for i, p in enumerate(perm)...
false
3.571429
[ "-import itertools", "+from itertools import permutations", "+from math import sqrt", "-p_list = itertools.permutations([x for x in range(n)])", "-# for p in p_list:", "-# print(p)", "-a_list = []", "-for i in range(n):", "- a_list.append(list(map(int, input().split())))", "-d_sum = 0", "...
false
0.074623
0.039095
1.908736
[ "s464100143", "s936263144" ]
u968166680
p02833
python
s344222646
s100107312
67
31
61,920
9,160
Accepted
Accepted
53.73
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) if N % 2: print((0)) return N //= 10 ans = N while N: N //= 5 ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) if N % 2: print((0)) return ans = 0 N //= 2 while N: N //= 5 ...
29
29
410
409
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) if N % 2: print((0)) return N //= 10 ans = N while N: N //= 5 ans += N pri...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) if N % 2: print((0)) return ans = 0 N //= 2 while N: N //= 5 ans += N prin...
false
0
[ "- N //= 10", "- ans = N", "+ ans = 0", "+ N //= 2" ]
false
0.03688
0.061157
0.60303
[ "s344222646", "s100107312" ]
u353895424
p02916
python
s660658674
s409735935
167
17
38,256
3,064
Accepted
Accepted
89.82
n=int(eval(input())) a=list(map(int, input().split())) b=list(map(int, input().split())) c=list(map(int, input().split())) ans=sum(b) for i in range(n-1): if a[i+1] - a[i] == 1: ans += c[a[i]-1] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): ans += b[a[i]-1] if i < n-1 and a[i+1]-1 == a[i]: ans += c[a[i]-1] print(ans)
9
10
219
254
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans = sum(b) for i in range(n - 1): if a[i + 1] - a[i] == 1: ans += c[a[i] - 1] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): ans += b[a[i] - 1] if i < n - 1 and a[i + 1] - 1 == a[i]: ans += c[a[i] - 1] print(ans)
false
10
[ "-ans = sum(b)", "-for i in range(n - 1):", "- if a[i + 1] - a[i] == 1:", "+ans = 0", "+for i in range(n):", "+ ans += b[a[i] - 1]", "+ if i < n - 1 and a[i + 1] - 1 == a[i]:" ]
false
0.043824
0.043374
1.010365
[ "s660658674", "s409735935" ]
u525065967
p02574
python
s353146003
s498462631
762
589
126,708
126,684
Accepted
Accepted
22.7
n = int(eval(input())) A = [*list(map(int, input().split()))] def solve(): MAX_A = 10**6 + 1 C = [0] * MAX_A for a in A: C[a] += 1 pairwise = True for i in range(2, MAX_A): if sum(C[i:MAX_A:i]) > 1: pairwise = False if pairwise: return 'pairwise' from math import gcd g...
n = int(eval(input())) A = [*list(map(int, input().split()))] def solve(): MAX_A = 10**6 + 1 C = [0] * MAX_A for a in A: C[a] += 1 pairwise = True if sum(C[2:MAX_A:2]) > 1: pairwise = False for i in range(3, MAX_A, 2): if sum(C[i:MAX_A:i]) > 1: pairwise = False if pairwise:...
16
17
422
473
n = int(eval(input())) A = [*list(map(int, input().split()))] def solve(): MAX_A = 10**6 + 1 C = [0] * MAX_A for a in A: C[a] += 1 pairwise = True for i in range(2, MAX_A): if sum(C[i:MAX_A:i]) > 1: pairwise = False if pairwise: return "pairwise" from ma...
n = int(eval(input())) A = [*list(map(int, input().split()))] def solve(): MAX_A = 10**6 + 1 C = [0] * MAX_A for a in A: C[a] += 1 pairwise = True if sum(C[2:MAX_A:2]) > 1: pairwise = False for i in range(3, MAX_A, 2): if sum(C[i:MAX_A:i]) > 1: pairwise = Fa...
false
5.882353
[ "- for i in range(2, MAX_A):", "+ if sum(C[2:MAX_A:2]) > 1:", "+ pairwise = False", "+ for i in range(3, MAX_A, 2):" ]
false
1.169515
0.511179
2.287879
[ "s353146003", "s498462631" ]
u969850098
p03210
python
s945775707
s930063197
20
17
3,316
2,940
Accepted
Accepted
15
X = int(eval(input())) if X == 7 or X == 5 or X == 3: print('YES') else: print('NO')
x = int(eval(input())) if x in [7, 5, 3]: print('YES') else: print('NO')
5
5
90
78
X = int(eval(input())) if X == 7 or X == 5 or X == 3: print("YES") else: print("NO")
x = int(eval(input())) if x in [7, 5, 3]: print("YES") else: print("NO")
false
0
[ "-X = int(eval(input()))", "-if X == 7 or X == 5 or X == 3:", "+x = int(eval(input()))", "+if x in [7, 5, 3]:" ]
false
0.040945
0.03984
1.027727
[ "s945775707", "s930063197" ]
u352394527
p00496
python
s044075002
s756293900
7,410
5,660
172,020
171,732
Accepted
Accepted
23.62
def main(): n, t, s = list(map(int, input().split())) A = [] B = [] for _ in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) """ dp[x + 1][y] ... 店xまででで時刻yまでの最大値 dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1], dp[x][y - B[x]] + A[x]) (not y - B[x] < s < y)...
def main(): n, t, s = list(map(int, input().split())) A = [] B = [] for _ in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) """ dp[x + 1][y] ... 店xまででで時刻yまでの最大値 dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1], dp[x][y - B[x]] + A[x]) (not y - B[x] < s < y)...
28
30
727
740
def main(): n, t, s = list(map(int, input().split())) A = [] B = [] for _ in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) """ dp[x + 1][y] ... 店xまででで時刻yまでの最大値 dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1], dp[x][y - B[x]] + A[x]) (not y - B[x] ...
def main(): n, t, s = list(map(int, input().split())) A = [] B = [] for _ in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) """ dp[x + 1][y] ... 店xまででで時刻yまでの最大値 dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1], dp[x][y - B[x]] + A[x]) (not y - B[x] ...
false
6.666667
[ "+ dpx = dp[x]", "+ dpx1 = dp[x + 1]", "- dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1], dp[x][y - bx] + ax)", "+ dpx1[y] = max(dpx[y], dpx1[y - 1], dpx[y - bx] + ax)", "- dp[x + 1][y] = max(dp[x][y], dp[x + 1][y - 1])", "+ dpx1[y] ...
false
0.048966
0.043602
1.123033
[ "s044075002", "s756293900" ]
u043048943
p02960
python
s837509510
s139508966
664
505
61,404
61,276
Accepted
Accepted
23.95
import sys sys.setrecursionlimit(2**31-1) input = sys.stdin.readline write = sys.stdout.write LMIIS = lambda : list(map(int,input().split())) II = lambda : int(input()) dbg = lambda *something : print(*something) if DEBUG is True else 0 DEBUG = True MOD = 10**9 + 7 class ModInt: def __init__(self,...
import sys sys.setrecursionlimit(2**31-1) input = sys.stdin.readline write = sys.stdout.write LMIIS = lambda : list(map(int,input().split())) II = lambda : int(input()) dbg = lambda *something : print(*something) if DEBUG is True else 0 DEBUG = True MOD = 10**9 + 7 class ModInt: def __init__(self,...
80
82
2,573
2,516
import sys sys.setrecursionlimit(2**31 - 1) input = sys.stdin.readline write = sys.stdout.write LMIIS = lambda: list(map(int, input().split())) II = lambda: int(input()) dbg = lambda *something: print(*something) if DEBUG is True else 0 DEBUG = True MOD = 10**9 + 7 class ModInt: def __init__(self, x): se...
import sys sys.setrecursionlimit(2**31 - 1) input = sys.stdin.readline write = sys.stdout.write LMIIS = lambda: list(map(int, input().split())) II = lambda: int(input()) dbg = lambda *something: print(*something) if DEBUG is True else 0 DEBUG = True MOD = 10**9 + 7 class ModInt: def __init__(self, x): se...
false
2.439024
[ "- for j in range(13):", "- for k in range(10):", "- dp[i][(j * 10 + k) % 13] = (", "- dp[i][(j * 10 + k) % 13] + dp[i - 1][j]", "- ) % MOD", "+ R = range(10)", "- for j in range(13):", "- ...
false
0.037964
0.151047
0.251341
[ "s837509510", "s139508966" ]
u592248346
p03844
python
s317056993
s622663248
19
17
2,940
2,940
Accepted
Accepted
10.53
print((eval(input())))
a = eval(input()) print((eval(a)))
1
2
20
27
print((eval(input())))
a = eval(input()) print((eval(a)))
false
50
[ "-print((eval(input())))", "+a = eval(input())", "+print((eval(a)))" ]
false
0.047442
0.04733
1.002372
[ "s317056993", "s622663248" ]
u845643816
p02240
python
s464173415
s951425608
700
610
7,016
7,012
Accepted
Accepted
12.86
n, m = list(map(int, input().split())) rootList = [-1 for i in range(n)] def getRoot(x): if rootList[x] < 0: rootList[x] = x elif rootList[x] != x: rootList[x] = getRoot(rootList[x]) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) rootL...
n, m = list(map(int, input().split())) rootList = [-1 for i in range(n)] def getRoot(x): r = rootList[x] if r < 0: rootList[x] = x elif r != x: rootList[x] = getRoot(r) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: ...
23
25
578
573
n, m = list(map(int, input().split())) rootList = [-1 for i in range(n)] def getRoot(x): if rootList[x] < 0: rootList[x] = x elif rootList[x] != x: rootList[x] = getRoot(rootList[x]) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) rootList[x], rootList...
n, m = list(map(int, input().split())) rootList = [-1 for i in range(n)] def getRoot(x): r = rootList[x] if r < 0: rootList[x] = x elif r != x: rootList[x] = getRoot(r) return rootList[x] def setSameRoot(x, y): x = getRoot(x) y = getRoot(y) if x != y: rootList[x] ...
false
8
[ "- if rootList[x] < 0:", "+ r = rootList[x]", "+ if r < 0:", "- elif rootList[x] != x:", "- rootList[x] = getRoot(rootList[x])", "+ elif r != x:", "+ rootList[x] = getRoot(r)", "- rootList[x], rootList[y] = min(x, y), min(x, y)", "+ if x != y:", "+ rootLis...
false
0.056062
0.043657
1.284137
[ "s464173415", "s951425608" ]
u597374218
p03774
python
s675571872
s196320449
21
19
3,064
3,060
Accepted
Accepted
9.52
n,m=list(map(int,input().split())) a=[[int(j) for j in input().split()] for i in range(n)] c=[[int(j) for j in input().split()] for i in range(m)] for i in range(n): d=10e8 b=0 for j in range(m): if abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])<d: d=abs(a[i][0]-c[j][0])+abs(a[i][1]-c...
n,m=list(map(int,input().split())) ab=[[int(j) for j in input().split()] for i in range(n)] cd=[[int(j) for j in input().split()] for i in range(m)] for a,b in ab: l=[abs(a-c)+abs(b-d) for c,d in cd] print((l.index(min(l))+1))
11
6
354
231
n, m = list(map(int, input().split())) a = [[int(j) for j in input().split()] for i in range(n)] c = [[int(j) for j in input().split()] for i in range(m)] for i in range(n): d = 10e8 b = 0 for j in range(m): if abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) < d: d = abs(a[i][0] - c[j][0...
n, m = list(map(int, input().split())) ab = [[int(j) for j in input().split()] for i in range(n)] cd = [[int(j) for j in input().split()] for i in range(m)] for a, b in ab: l = [abs(a - c) + abs(b - d) for c, d in cd] print((l.index(min(l)) + 1))
false
45.454545
[ "-a = [[int(j) for j in input().split()] for i in range(n)]", "-c = [[int(j) for j in input().split()] for i in range(m)]", "-for i in range(n):", "- d = 10e8", "- b = 0", "- for j in range(m):", "- if abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) < d:", "- d = abs(a[i][0]...
false
0.164904
0.043942
3.752767
[ "s675571872", "s196320449" ]
u893063840
p02990
python
s883006494
s381054574
274
23
5,620
3,572
Accepted
Accepted
91.61
def main(): n, k = list(map(int, input().split())) mod = 10 ** 9 + 7 fact = [1] for i in range(1, 2001): fact.append(fact[-1] * i) def comb(l, r): return fact[l] // fact[r] // fact[l - r] for i in range(1, k + 1): print(((comb(n - k + 1, i) * comb(k - 1, i ...
n, k = list(map(int, input().split())) mod = 10 ** 9 + 7 MAX = 2000 fact = [1] * (MAX + 1) for i in range(1, MAX + 1): fact[i] = (fact[i-1] * i) % mod inv = [1] * (MAX + 1) for i in range(2, MAX + 1): inv[i] = inv[mod % i] * (mod - mod // i) % mod fact_inv = [1] * (MAX + 1) for i in range(1, M...
17
27
370
585
def main(): n, k = list(map(int, input().split())) mod = 10**9 + 7 fact = [1] for i in range(1, 2001): fact.append(fact[-1] * i) def comb(l, r): return fact[l] // fact[r] // fact[l - r] for i in range(1, k + 1): print(((comb(n - k + 1, i) * comb(k - 1, i - 1)) % mod)) ...
n, k = list(map(int, input().split())) mod = 10**9 + 7 MAX = 2000 fact = [1] * (MAX + 1) for i in range(1, MAX + 1): fact[i] = (fact[i - 1] * i) % mod inv = [1] * (MAX + 1) for i in range(2, MAX + 1): inv[i] = inv[mod % i] * (mod - mod // i) % mod fact_inv = [1] * (MAX + 1) for i in range(1, MAX + 1): fact_...
false
37.037037
[ "-def main():", "- n, k = list(map(int, input().split()))", "- mod = 10**9 + 7", "- fact = [1]", "- for i in range(1, 2001):", "- fact.append(fact[-1] * i)", "-", "- def comb(l, r):", "- return fact[l] // fact[r] // fact[l - r]", "-", "- for i in range(1, k + 1):"...
false
0.173815
0.059152
2.938456
[ "s883006494", "s381054574" ]
u787059958
p02549
python
s418329940
s734309619
827
761
30,216
26,988
Accepted
Accepted
7.98
# 配るDP、もらうDP n, k = list(map(int, input().split())) mod = 998244353 kukan = [] for _ in range(k): # 区間の問題は扱いやすいように[ ) の形に直せるなら直す l, r = list(map(int, input().split())) l -= 1 kukan.append([l, r]) dp = [0 for i in range(n)] dp[0] = 1 # 区間のL, Rは数字が大きいため、その差一つ一つを考えると時間がない! # それゆえにL, Rの端...
N, K = list(map(int, input().split())) mod = 998244353 L = [] for _ in range(K): a, b = list(map(int, input().split())) b += 1 L.append([a, b]) ruiwa = [0] * (N + 1) dp = [0] * (N + 1) dp[1] = 1 ruiwa[1] = 1 for i in range(2, N + 1): for l, r in L: l = i - l r = i - r ...
35
28
782
595
# 配るDP、もらうDP n, k = list(map(int, input().split())) mod = 998244353 kukan = [] for _ in range(k): # 区間の問題は扱いやすいように[ ) の形に直せるなら直す l, r = list(map(int, input().split())) l -= 1 kukan.append([l, r]) dp = [0 for i in range(n)] dp[0] = 1 # 区間のL, Rは数字が大きいため、その差一つ一つを考えると時間がない! # それゆえにL, Rの端を考えればいいようにするためにそこまでの...
N, K = list(map(int, input().split())) mod = 998244353 L = [] for _ in range(K): a, b = list(map(int, input().split())) b += 1 L.append([a, b]) ruiwa = [0] * (N + 1) dp = [0] * (N + 1) dp[1] = 1 ruiwa[1] = 1 for i in range(2, N + 1): for l, r in L: l = i - l r = i - r l, r = r, l...
false
20
[ "-# 配るDP、もらうDP", "-n, k = list(map(int, input().split()))", "+N, K = list(map(int, input().split()))", "-kukan = []", "-for _ in range(k):", "- # 区間の問題は扱いやすいように[ ) の形に直せるなら直す", "- l, r = list(map(int, input().split()))", "- l -= 1", "- kukan.append([l, r])", "-dp = [0 for i in range(n)...
false
0.046736
0.046196
1.011697
[ "s418329940", "s734309619" ]
u572012241
p02720
python
s874569890
s933184585
224
59
43,408
7,172
Accepted
Accepted
73.66
def make_tree(G,keta,count): if keta==1: num =[] for i in range(1,10): count+=1 if count ==k: print(i) exit() else: num.append(i) G.append(num) make_tree(G,2,count) else: ...
def is_count_k(count,n): count +=1 if count == k : print(n) exit() return count def make_tree(G,keta,count): num_list = G[keta-2] new_list =[] for num in num_list: r = num%10 if r != 0 : count = is_count_k(count,num*10 + (r-1)) ...
65
29
2,010
721
def make_tree(G, keta, count): if keta == 1: num = [] for i in range(1, 10): count += 1 if count == k: print(i) exit() else: num.append(i) G.append(num) make_tree(G, 2, count) else: num_li...
def is_count_k(count, n): count += 1 if count == k: print(n) exit() return count def make_tree(G, keta, count): num_list = G[keta - 2] new_list = [] for num in num_list: r = num % 10 if r != 0: count = is_count_k(count, num * 10 + (r - 1)) ...
false
55.384615
[ "+def is_count_k(count, n):", "+ count += 1", "+ if count == k:", "+ print(n)", "+ exit()", "+ return count", "+", "+", "- if keta == 1:", "- num = []", "- for i in range(1, 10):", "- count += 1", "- if count == k:", "- ...
false
0.060533
0.081959
0.738584
[ "s874569890", "s933184585" ]
u884323674
p03835
python
s402937999
s701459271
1,665
1,388
2,940
2,940
Accepted
Accepted
16.64
K, S = list(map(int, input().split())) ans = 0 for i in range(K+1): x = i for j in range(K+1): y = j z = S - x - y if 0 <= z <= K: ans += 1 print(ans)
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
201
168
K, S = list(map(int, input().split())) ans = 0 for i in range(K + 1): x = i for j in range(K + 1): y = j z = S - x - y if 0 <= z <= K: ans += 1 print(ans)
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
[ "-ans = 0", "-for i in range(K + 1):", "- x = i", "- for j in range(K + 1):", "- y = j", "- z = S - x - y", "- if 0 <= z <= K:", "- ans += 1", "-print(ans)", "+count = 0", "+for x in range(K + 1):", "+ for y in range(K + 1):", "+ if 0 <= S - (x...
false
0.041572
0.039486
1.05284
[ "s402937999", "s701459271" ]
u335406314
p02953
python
s457279783
s670018828
82
73
20,148
19,976
Accepted
Accepted
10.98
N,*H=list(map(int,open(0).read().split())) H[0]-=1 def main(): ihmax=0 hmax=H[0] for i in range(1,N): if H[i-1]<H[i]: ihmax=i-1 H[i]-=1 hmax=max(H[i],hmax) elif H[i-1]==H[i]: continue else: return 'No' retu...
N,*H=list(map(int,open(0).read().split())) H[0]-=1 def main(): for i in range(1,N): if H[i-1]<H[i]: H[i]-=1 elif H[i-1]==H[i]: continue else: return 'No' return 'Yes' print((main()))
16
12
337
253
N, *H = list(map(int, open(0).read().split())) H[0] -= 1 def main(): ihmax = 0 hmax = H[0] for i in range(1, N): if H[i - 1] < H[i]: ihmax = i - 1 H[i] -= 1 hmax = max(H[i], hmax) elif H[i - 1] == H[i]: continue else: retu...
N, *H = list(map(int, open(0).read().split())) H[0] -= 1 def main(): for i in range(1, N): if H[i - 1] < H[i]: H[i] -= 1 elif H[i - 1] == H[i]: continue else: return "No" return "Yes" print((main()))
false
25
[ "- ihmax = 0", "- hmax = H[0]", "- ihmax = i - 1", "- hmax = max(H[i], hmax)" ]
false
0.11892
0.107787
1.103284
[ "s457279783", "s670018828" ]
u883048396
p03828
python
s369611798
s523060936
29
22
3,064
3,064
Accepted
Accepted
24.14
def 解(): iN = int(eval(input())) iD = 10**9 + 7 if iN < 3: print(iN) exit() aS = [1]*(iN+1) dP={} for i in range(2,iN+1): if aS[i]: dP[i] = 1 for j in range(i*2,iN+1,i): aS[j] = 0 for i in range(2,iN+1): ...
def 解(): iN = int(eval(input())) iD = 10**9 + 7 if iN < 3: print(iN) exit() aS = [1]*(iN+1) dP={} for i in range(2,iN+1): if aS[i]: dP[i] = 1 for j in range(i*2,iN+1,i): aS[j] = 0 for i in range(2,iN+1): ...
27
30
516
565
def 解(): iN = int(eval(input())) iD = 10**9 + 7 if iN < 3: print(iN) exit() aS = [1] * (iN + 1) dP = {} for i in range(2, iN + 1): if aS[i]: dP[i] = 1 for j in range(i * 2, iN + 1, i): aS[j] = 0 for i in range(2, iN + 1): ...
def 解(): iN = int(eval(input())) iD = 10**9 + 7 if iN < 3: print(iN) exit() aS = [1] * (iN + 1) dP = {} for i in range(2, iN + 1): if aS[i]: dP[i] = 1 for j in range(i * 2, iN + 1, i): aS[j] = 0 for i in range(2, iN + 1): ...
false
10
[ "+ if i == 1:", "+ break" ]
false
0.098616
0.04882
2.020005
[ "s369611798", "s523060936" ]
u379559362
p03775
python
s376999413
s526710554
1,931
46
3,064
2,940
Accepted
Accepted
97.62
import itertools n = int(eval(input())) def prime_decomposition(n): i = 2 table = [] while i * i <= n: while n % i == 0: n /= i table.append(i) i += 1 if n > 1: table.append(n) return table n_table = prime_decomposition(n) if no...
n = int(eval(input())) i = 1 ans = n while i * i <= n: if n % i == 0: b = n // i f = len(str(max(ans, b))) ans = min(ans, f) i += 1 print(ans)
44
13
841
184
import itertools n = int(eval(input())) def prime_decomposition(n): i = 2 table = [] while i * i <= n: while n % i == 0: n /= i table.append(i) i += 1 if n > 1: table.append(n) return table n_table = prime_decomposition(n) if not n_table: n_ta...
n = int(eval(input())) i = 1 ans = n while i * i <= n: if n % i == 0: b = n // i f = len(str(max(ans, b))) ans = min(ans, f) i += 1 print(ans)
false
70.454545
[ "-import itertools", "-", "-", "-", "-def prime_decomposition(n):", "- i = 2", "- table = []", "- while i * i <= n:", "- while n % i == 0:", "- n /= i", "- table.append(i)", "- i += 1", "- if n > 1:", "- table.append(n)", "- retur...
false
0.164175
0.051379
3.195374
[ "s376999413", "s526710554" ]
u127499732
p02935
python
s788947869
s852855979
21
17
3,316
2,940
Accepted
Accepted
19.05
def main(): import sys from collections import deque n=int(eval(input())) v=list(map(int,sys.stdin.read().split())) w=deque(sorted(v)) ans=(w.popleft()+w.popleft())/2 for i in range(n-2): ans=ans/2 ans+=w.popleft()/2 print(ans) if __name__=="__main__": main()
def main(): n=int(eval(input())) w=sorted(map(int,input().split())) ans=(w[0]+w[1])/2 for i in range(2,n): ans=ans/2+w[i]/2 print(ans) if __name__=="__main__": main()
13
9
291
184
def main(): import sys from collections import deque n = int(eval(input())) v = list(map(int, sys.stdin.read().split())) w = deque(sorted(v)) ans = (w.popleft() + w.popleft()) / 2 for i in range(n - 2): ans = ans / 2 ans += w.popleft() / 2 print(ans) if __name__ == "__...
def main(): n = int(eval(input())) w = sorted(map(int, input().split())) ans = (w[0] + w[1]) / 2 for i in range(2, n): ans = ans / 2 + w[i] / 2 print(ans) if __name__ == "__main__": main()
false
30.769231
[ "- import sys", "- from collections import deque", "-", "- v = list(map(int, sys.stdin.read().split()))", "- w = deque(sorted(v))", "- ans = (w.popleft() + w.popleft()) / 2", "- for i in range(n - 2):", "- ans = ans / 2", "- ans += w.popleft() / 2", "+ w = sorted...
false
0.041306
0.041093
1.005185
[ "s788947869", "s852855979" ]
u706786134
p03545
python
s538132873
s848072432
154
17
14,488
3,060
Accepted
Accepted
88.96
import numpy as np S = input() X = list(int(x) for x in S) def test(Z): a = X[0] b = X[1] if Z[0] else -X[1] c = X[2] if Z[1] else -X[2] d = X[3] if Z[2] else -X[3] return a + b + c + d == 7 Y = [None] * (2 * len(X) - 1) Y[::2] = X for i in range(8): Z = [i & 1, i & 2, i & ...
import itertools X = str(eval(input())) for op in list(itertools.product(['+', '-'], repeat=3)): eq = X[0] + op[0] + X[1] + op[1] + X[2] + op[2] + X[3] result = eval(eq) if result == 7: break print((eq + '=7'))
22
10
436
234
import numpy as np S = input() X = list(int(x) for x in S) def test(Z): a = X[0] b = X[1] if Z[0] else -X[1] c = X[2] if Z[1] else -X[2] d = X[3] if Z[2] else -X[3] return a + b + c + d == 7 Y = [None] * (2 * len(X) - 1) Y[::2] = X for i in range(8): Z = [i & 1, i & 2, i & 4] if test(Z)...
import itertools X = str(eval(input())) for op in list(itertools.product(["+", "-"], repeat=3)): eq = X[0] + op[0] + X[1] + op[1] + X[2] + op[2] + X[3] result = eval(eq) if result == 7: break print((eq + "=7"))
false
54.545455
[ "-import numpy as np", "+import itertools", "-S = input()", "-X = list(int(x) for x in S)", "-", "-", "-def test(Z):", "- a = X[0]", "- b = X[1] if Z[0] else -X[1]", "- c = X[2] if Z[1] else -X[2]", "- d = X[3] if Z[2] else -X[3]", "- return a + b + c + d == 7", "-", "-", ...
false
0.06946
0.007046
9.858743
[ "s538132873", "s848072432" ]
u506858457
p02708
python
s384021383
s454240775
135
95
37,728
9,172
Accepted
Accepted
29.63
'''ika tako 選ぶ個数を固定して、それ毎に結果を足し合わせればよい。 k 個の数を選ぶとき、各項に含まれる 10^100 は除いて考えても 和の個数を求める上では問題ない。 最小値は小さい方から k 個を足し合わせた数0+1+2+…+(k-1) 初項 0 、末項 k−1 、長さ k の等差数列の総和なので k(k−1)/2 最大値は大きい方から k 個を足し合わせた数(N-k+1)+…+(N-1)+N 初項 N−k+1 、末項N 、長さk の等差数列の総和なので k(2N−k+1)/2 数字は1刻みで、特に選び方に制約も無いので、最小値~最大値の間の整数は全て作れる...
N, K = list(map(int,input().split())) ans = 0 MOD = 10**9 + 7 for i in range(K,N+2): x = (N+1-i) * i + 1 ans += x ans %= MOD print (ans)
25
8
670
149
"""ika tako 選ぶ個数を固定して、それ毎に結果を足し合わせればよい。 k 個の数を選ぶとき、各項に含まれる 10^100 は除いて考えても 和の個数を求める上では問題ない。 最小値は小さい方から k 個を足し合わせた数0+1+2+…+(k-1) 初項 0 、末項 k−1 、長さ k の等差数列の総和なので k(k−1)/2 最大値は大きい方から k 個を足し合わせた数(N-k+1)+…+(N-1)+N 初項 N−k+1 、末項N 、長さk の等差数列の総和なので k(2N−k+1)/2 数字は1刻みで、特に選び方に制約も無いので、最小値~最大値の間の整数は全て作れる。 """ # 累積...
N, K = list(map(int, input().split())) ans = 0 MOD = 10**9 + 7 for i in range(K, N + 2): x = (N + 1 - i) * i + 1 ans += x ans %= MOD print(ans)
false
68
[ "-\"\"\"ika tako", "-選ぶ個数を固定して、それ毎に結果を足し合わせればよい。", "-k 個の数を選ぶとき、各項に含まれる 10^100 は除いて考えても", "-和の個数を求める上では問題ない。", "-最小値は小さい方から k 個を足し合わせた数0+1+2+…+(k-1)", "-初項 0 、末項 k−1 、長さ k の等差数列の総和なので", "-k(k−1)/2", "-最大値は大きい方から k 個を足し合わせた数(N-k+1)+…+(N-1)+N", "-初項 N−k+1 、末項N 、長さk の等差数列の総和なので", "-k(2N−...
false
0.18548
0.055877
3.319434
[ "s384021383", "s454240775" ]
u678167152
p02558
python
s454441837
s834188161
487
350
84,084
80,984
Accepted
Accepted
28.13
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y...
57
59
1,285
1,325
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.f...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.f...
false
3.389831
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.045394
0.042007
1.080629
[ "s454441837", "s834188161" ]