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
u216015528
p02936
python
s925967666
s474839352
1,722
1,310
255,060
251,956
Accepted
Accepted
23.93
#!/usr/bin/env python3 from sys import setrecursionlimit setrecursionlimit(10 ** 8) def dfs(now): seen[now] = True score[now] += operation[now] for next in branch[now]: if seen[next] is False: score[next] += score[now] dfs(next) N, Q = map(int, input().spl...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def dfs(now): seen[now] = True for next in branch[now]: if seen[next] is False: score[next] += score[now] dfs(next) N, Q = list(map(int, input().split())) branch = [se...
34
32
737
658
#!/usr/bin/env python3 from sys import setrecursionlimit setrecursionlimit(10**8) def dfs(now): seen[now] = True score[now] += operation[now] for next in branch[now]: if seen[next] is False: score[next] += score[now] dfs(next) N, Q = map(int, input().split()) branch = [s...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline def dfs(now): seen[now] = True for next in branch[now]: if seen[next] is False: score[next] += score[now] dfs(next) N, Q = list(map(int, input().split())) branch = [set() for _ in range...
false
5.882353
[ "-from sys import setrecursionlimit", "+import sys", "-setrecursionlimit(10**8)", "+sys.setrecursionlimit(10**8)", "+input = sys.stdin.readline", "- score[now] += operation[now]", "-N, Q = map(int, input().split())", "+N, Q = list(map(int, input().split()))", "- a, b = map(int, input().split()...
false
0.035985
0.04071
0.883953
[ "s925967666", "s474839352" ]
u249447366
p03352
python
s602211697
s579616915
23
17
2,940
3,060
Accepted
Accepted
26.09
x = int(eval(input())) num = 0 if x == 1: num = 1 else: for b in range(2,x): for p in range(2,11): tmp = pow(b, p) if tmp <= x and num < tmp: num = tmp print(num)
x = int(eval(input())) num = 0 if x == 1: num = 1 else: for b in range(2, 33): for p in range(2, 11): tmp = pow(b, p) if tmp <= x and num < tmp: num = tmp print(num)
13
13
226
229
x = int(eval(input())) num = 0 if x == 1: num = 1 else: for b in range(2, x): for p in range(2, 11): tmp = pow(b, p) if tmp <= x and num < tmp: num = tmp print(num)
x = int(eval(input())) num = 0 if x == 1: num = 1 else: for b in range(2, 33): for p in range(2, 11): tmp = pow(b, p) if tmp <= x and num < tmp: num = tmp print(num)
false
0
[ "- for b in range(2, x):", "+ for b in range(2, 33):" ]
false
0.038665
0.035676
1.083783
[ "s602211697", "s579616915" ]
u947883560
p02621
python
s704054313
s181586988
26
23
9,172
9,120
Accepted
Accepted
11.54
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) INF = float("inf") def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def...
#!/usr/bin/env python3 import sys def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return list(zip(*(MAP() for _ in range(n)))) def main(): sys.setrecursion...
34
19
473
440
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) INF = float("inf") def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return l...
#!/usr/bin/env python3 import sys def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return list(zip(*(MAP() for _ in range(n)))) def main()...
false
44.117647
[ "-", "-sys.setrecursionlimit(10**8)", "-INF = float(\"inf\")", "+ sys.setrecursionlimit(10**8)", "+ INF = float(\"inf\")" ]
false
0.036541
0.045527
0.802629
[ "s704054313", "s181586988" ]
u408260374
p02361
python
s221019424
s672125182
4,560
3,590
150,640
143,708
Accepted
Accepted
21.27
import heapq class Edge: def __init__(self, dst, weight): self.dst, self.weight = dst, weight def __lt__(self, e): return self.weight > e.weight class Graph: def __init__(self, V): self.V = V self.E = [[] for _ in range(V)] def add_edge(self, src, ds...
import heapq class Edge: def __init__(self, dst, weight): self.dst, self.weight = dst, weight def __lt__(self, e): return self.weight > e.weight class Graph: def __init__(self, V): self.V = V self.E = [[] for _ in range(V)] def add_edge(self, src, ds...
77
76
2,159
2,161
import heapq class Edge: def __init__(self, dst, weight): self.dst, self.weight = dst, weight def __lt__(self, e): return self.weight > e.weight class Graph: def __init__(self, V): self.V = V self.E = [[] for _ in range(V)] def add_edge(self, src, dst, weight): ...
import heapq class Edge: def __init__(self, dst, weight): self.dst, self.weight = dst, weight def __lt__(self, e): return self.weight > e.weight class Graph: def __init__(self, V): self.V = V self.E = [[] for _ in range(V)] def add_edge(self, src, dst, weight): ...
false
1.298701
[ "-class Node:", "- def __init__(self, v, cost):", "- self.v, self.cost = v, cost", "-", "- def __lt__(self, n):", "- return self.cost < n.cost", "-", "-", "+ class Node:", "+ def __init__(self, v, cost):", "+ self.v, self.cost = v, cost", "+", "+ ...
false
0.040316
0.041001
0.983294
[ "s221019424", "s672125182" ]
u043048943
p02803
python
s359716284
s016821982
1,739
654
113,044
92,764
Accepted
Accepted
62.39
#coding:utf-8 import sys sys.setrecursionlimit(10**6) write = sys.stdout.write dbg = lambda *something : print(*something) if DEBUG else 0 DEBUG = False def main(given = sys.stdin.readline): input = lambda : given().rstrip() LMIIS = lambda : list(map(int,input().split())) II = lambda : int(input())...
#coding:utf-8 import sys sys.setrecursionlimit(10**6) write = sys.stdout.write dbg = lambda *something : print(*something) if DEBUG else 0 DEBUG = False def main(given = sys.stdin.readline): input = lambda : given().rstrip() LMIIS = lambda : list(map(int,input().split())) II = lambda : int(input())...
66
62
1,644
1,607
# coding:utf-8 import sys sys.setrecursionlimit(10**6) write = sys.stdout.write dbg = lambda *something: print(*something) if DEBUG else 0 DEBUG = False def main(given=sys.stdin.readline): input = lambda: given().rstrip() LMIIS = lambda: list(map(int, input().split())) II = lambda: int(input()) XLMII...
# coding:utf-8 import sys sys.setrecursionlimit(10**6) write = sys.stdout.write dbg = lambda *something: print(*something) if DEBUG else 0 DEBUG = False def main(given=sys.stdin.readline): input = lambda: given().rstrip() LMIIS = lambda: list(map(int, input().split())) II = lambda: int(input()) XLMII...
false
6.060606
[ "+ from collections import deque", "- def tansaku(S, V, y, x, length):", "- if x >= 1 and S[y][x - 1] == \".\" and V[y][x - 1] > length + 1:", "- V[y][x - 1] = length + 1", "- tansaku(S, V, y, x - 1, length + 1)", "- if x < W - 1 and S[y][x + 1] == \".\" and V[y][...
false
0.077861
0.036374
2.140582
[ "s359716284", "s016821982" ]
u729133443
p03478
python
s724684145
s733084514
197
31
41,708
2,940
Accepted
Accepted
84.26
n,a,b=list(map(int,input().split()));print((sum(i*(a<=sum(map(int,str(i)))<=b)for i in range(n+1))))
n,a,b=list(map(int,input().split()));c=0 while n:c+=n*(a<=sum(map(int,str(n)))<=b);n-=1 print(c)
1
3
92
92
n, a, b = list(map(int, input().split())) print((sum(i * (a <= sum(map(int, str(i))) <= b) for i in range(n + 1))))
n, a, b = list(map(int, input().split())) c = 0 while n: c += n * (a <= sum(map(int, str(n))) <= b) n -= 1 print(c)
false
66.666667
[ "-print((sum(i * (a <= sum(map(int, str(i))) <= b) for i in range(n + 1))))", "+c = 0", "+while n:", "+ c += n * (a <= sum(map(int, str(n))) <= b)", "+ n -= 1", "+print(c)" ]
false
0.042255
0.145098
0.291214
[ "s724684145", "s733084514" ]
u941753895
p03274
python
s499505447
s767250059
129
97
17,120
17,136
Accepted
Accepted
24.81
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def II(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n,k...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n,k=...
63
28
1,121
544
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def II(): return int(eval(input())) def LS(): return input().split() def S(): return eva...
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval...
false
55.555556
[ "-def II():", "+def I():", "- if l.count(0) > 0:", "- k -= 1", "- l.remove(0)", "- if k == 0:", "- print((0))", "- exit()", "- if len(l) == 0:", "- print((0))", "- exit()", "- idx = len(l) - 1", "- for i in range(len(l)):", "- ...
false
0.04679
0.056413
0.829429
[ "s499505447", "s767250059" ]
u864013199
p03326
python
s267654128
s043510204
1,419
152
22,044
12,512
Accepted
Accepted
89.29
import numpy as np N,M = list(map(int,input().split())) L = np.array([list(map(int,input().split())) for _ in range(N)]) l = [[1,1,1],[1,1,-1],[1,-1,1],[-1,1,1],[1,-1,-1],[-1,-1,1],[-1,1,-1],[-1,-1,-1]] ans = 0 for i in range(8): su = L[:,0]*l[i][0]+L[:,1]*l[i][1]+L[:,2]*l[i][2] s = np.sort(su)[::-1] ...
import numpy as np N,M = list(map(int,input().split())) L = np.array([list(map(int,input().split())) for _ in range(N)]) l = [[1,1,1],[1,1,-1],[1,-1,1],[-1,1,1],[1,-1,-1],[-1,-1,1],[-1,1,-1],[-1,-1,-1]] ans = 0 for i in range(8): su = L[:,0]*l[i][0]+L[:,1]*l[i][1]+L[:,2]*l[i][2] s = np.sort(su)[::-1] ...
10
10
353
356
import numpy as np N, M = list(map(int, input().split())) L = np.array([list(map(int, input().split())) for _ in range(N)]) l = [ [1, 1, 1], [1, 1, -1], [1, -1, 1], [-1, 1, 1], [1, -1, -1], [-1, -1, 1], [-1, 1, -1], [-1, -1, -1], ] ans = 0 for i in range(8): su = L[:, 0] * l[i][0] +...
import numpy as np N, M = list(map(int, input().split())) L = np.array([list(map(int, input().split())) for _ in range(N)]) l = [ [1, 1, 1], [1, 1, -1], [1, -1, 1], [-1, 1, 1], [1, -1, -1], [-1, -1, 1], [-1, 1, -1], [-1, -1, -1], ] ans = 0 for i in range(8): su = L[:, 0] * l[i][0] +...
false
0
[ "- ans = max(ans, sum(s[:M]))", "+ ans = max(ans, np.sum(s[:M]))" ]
false
0.744186
0.360672
2.063332
[ "s267654128", "s043510204" ]
u790710233
p03363
python
s541969435
s620094548
241
195
40,868
45,824
Accepted
Accepted
19.09
from collections import defaultdict n = int(eval(input())) A = list(map(int, input().split())) dd = defaultdict(int) dd[0] += 1 S = [0]*(n+1) for i in range(n): S[i+1] = S[i]+A[i] dd[S[i+1]] += 1 print((sum(v*(v-1)//2 for v in list(dd.values()))))
from collections import defaultdict from itertools import accumulate n = int(eval(input())) A = accumulate(list(map(int, input().split()))) cnt = defaultdict(int) cnt[0] += 1 for a in A: cnt[a] += 1 print((sum(v*(v-1)//2 for v in list(cnt.values()))))
10
9
251
243
from collections import defaultdict n = int(eval(input())) A = list(map(int, input().split())) dd = defaultdict(int) dd[0] += 1 S = [0] * (n + 1) for i in range(n): S[i + 1] = S[i] + A[i] dd[S[i + 1]] += 1 print((sum(v * (v - 1) // 2 for v in list(dd.values()))))
from collections import defaultdict from itertools import accumulate n = int(eval(input())) A = accumulate(list(map(int, input().split()))) cnt = defaultdict(int) cnt[0] += 1 for a in A: cnt[a] += 1 print((sum(v * (v - 1) // 2 for v in list(cnt.values()))))
false
10
[ "+from itertools import accumulate", "-A = list(map(int, input().split()))", "-dd = defaultdict(int)", "-dd[0] += 1", "-S = [0] * (n + 1)", "-for i in range(n):", "- S[i + 1] = S[i] + A[i]", "- dd[S[i + 1]] += 1", "-print((sum(v * (v - 1) // 2 for v in list(dd.values()))))", "+A = accumulate...
false
0.036233
0.075687
0.478722
[ "s541969435", "s620094548" ]
u033183216
p02721
python
s825135394
s284920520
376
298
20,584
58,104
Accepted
Accepted
20.74
# https://atcoder.jp/contests/abc161/tasks/abc161_e N, K, C = list(map(int, input().split())) S = eval(input()) i = 0 left = [] while i < N and len(left) < K: if S[i] == 'o': left.append(i) i += (C + 1) continue i += 1 i = N - 1 right = [] while i >= 0 and len(right) < K...
# https://atcoder.jp/contests/abc161/tasks/abc161_e N, K, C = list(map(int, input().split())) S = eval(input()) left = [] i = 0 while K > len(left): while True: if S[i] == 'o': left.append(i) i += C + 1 break i += 1 right = [] i = N - 1 while K...
26
31
510
562
# https://atcoder.jp/contests/abc161/tasks/abc161_e N, K, C = list(map(int, input().split())) S = eval(input()) i = 0 left = [] while i < N and len(left) < K: if S[i] == "o": left.append(i) i += C + 1 continue i += 1 i = N - 1 right = [] while i >= 0 and len(right) < K: if S[i] == "o...
# https://atcoder.jp/contests/abc161/tasks/abc161_e N, K, C = list(map(int, input().split())) S = eval(input()) left = [] i = 0 while K > len(left): while True: if S[i] == "o": left.append(i) i += C + 1 break i += 1 right = [] i = N - 1 while K > len(right): w...
false
16.129032
[ "+left = []", "-left = []", "-while i < N and len(left) < K:", "- if S[i] == \"o\":", "- left.append(i)", "- i += C + 1", "- continue", "- i += 1", "+while K > len(left):", "+ while True:", "+ if S[i] == \"o\":", "+ left.append(i)", "+ ...
false
0.033466
0.044795
0.747093
[ "s825135394", "s284920520" ]
u186838327
p03403
python
s466326053
s276400800
170
147
86,752
82,460
Accepted
Accepted
13.53
n = int(eval(input())) A = list(map(int, input().split())) A = [0]+A+[0] s = 0 for i in range(1, n+2): s += abs(A[i]-A[i-1]) for i in range(1, n+1): ans = s ans -= abs(A[i]-A[i-1]) ans -= abs(A[i+1]-A[i]) ans += abs(A[i+1]-A[i-1]) print(ans)
n = int(input()) A = list(map(int, input().split())) res = 0 pre = 0 for a in A: res += abs(a-pre) pre = a else: res += abs(0-pre) #print(res) ans = [0]*n A = [0]+A+[0] for i in range(n): j = i+1 temp = res-abs(A[j-1]-A[j])-abs(A[j+1]-A[j])+abs(A[j+1]-A[j-1]) ans[i] = temp prin...
15
18
277
338
n = int(eval(input())) A = list(map(int, input().split())) A = [0] + A + [0] s = 0 for i in range(1, n + 2): s += abs(A[i] - A[i - 1]) for i in range(1, n + 1): ans = s ans -= abs(A[i] - A[i - 1]) ans -= abs(A[i + 1] - A[i]) ans += abs(A[i + 1] - A[i - 1]) print(ans)
n = int(input()) A = list(map(int, input().split())) res = 0 pre = 0 for a in A: res += abs(a - pre) pre = a else: res += abs(0 - pre) # print(res) ans = [0] * n A = [0] + A + [0] for i in range(n): j = i + 1 temp = res - abs(A[j - 1] - A[j]) - abs(A[j + 1] - A[j]) + abs(A[j + 1] - A[j - 1]) ans...
false
16.666667
[ "-n = int(eval(input()))", "+n = int(input())", "+res = 0", "+pre = 0", "+for a in A:", "+ res += abs(a - pre)", "+ pre = a", "+else:", "+ res += abs(0 - pre)", "+# print(res)", "+ans = [0] * n", "-s = 0", "-for i in range(1, n + 2):", "- s += abs(A[i] - A[i - 1])", "-for i i...
false
0.044468
0.109526
0.406003
[ "s466326053", "s276400800" ]
u790710233
p03546
python
s242091669
s760551271
500
260
26,700
17,364
Accepted
Accepted
48
from scipy.sparse import csr_matrix from scipy.sparse.csgraph import dijkstra from collections import defaultdict h, w = list(map(int, input().split())) table = [list(map(int, input().split())) for _ in range(10)] dd = defaultdict(int) for _ in range(h): for x in map(int, input().split()): if x == -...
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense from collections import defaultdict h, w = list(map(int, input().split())) table = [list(map(int, input().split())) for _ in range(10)] dd = defaultdict(int) for _ in range(h): for x in map(int, input().split()): if x == -1: c...
18
18
524
516
from scipy.sparse import csr_matrix from scipy.sparse.csgraph import dijkstra from collections import defaultdict h, w = list(map(int, input().split())) table = [list(map(int, input().split())) for _ in range(10)] dd = defaultdict(int) for _ in range(h): for x in map(int, input().split()): if x == -1: ...
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense from collections import defaultdict h, w = list(map(int, input().split())) table = [list(map(int, input().split())) for _ in range(10)] dd = defaultdict(int) for _ in range(h): for x in map(int, input().split()): if x == -1: continue...
false
0
[ "-from scipy.sparse import csr_matrix", "-from scipy.sparse.csgraph import dijkstra", "+from scipy.sparse.csgraph import dijkstra, csgraph_from_dense", "-scores = dijkstra(csr_matrix(trans_table), indices=1)", "+scores = dijkstra(csgraph_from_dense(trans_table), indices=1)" ]
false
0.526035
0.562601
0.935004
[ "s242091669", "s760551271" ]
u391731808
p03576
python
s115405979
s110682077
778
107
3,064
3,064
Accepted
Accepted
86.25
N,K = list(map(int,input().split())) XY = [list(map(int,input().split())) for _ in [0]*N] iX = sorted(x for x,y in XY) iY = sorted(y for x,y in XY) X = {x:i for i,x in enumerate(iX)} Y = {y:i for i,y in enumerate(iY)} c = [[0]*(N+1) for i in [0]*(N+1)] for x,y in XY: c[Y[y]+1][X[x]+1] = 1 for i in ra...
N,K = list(map(int,input().split())) XY = [list(map(int,input().split())) for _ in [0]*N] iX = sorted(x for x,y in XY) iY = sorted(y for x,y in XY) X = {x:i for i,x in enumerate(iX)} Y = {y:i for i,y in enumerate(iY)} c = [[0]*(N+1) for i in [0]*(N+1)] for x,y in XY: c[Y[y]+1][X[x]+1] = 1 for i in ra...
30
32
786
778
N, K = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in [0] * N] iX = sorted(x for x, y in XY) iY = sorted(y for x, y in XY) X = {x: i for i, x in enumerate(iX)} Y = {y: i for i, y in enumerate(iY)} c = [[0] * (N + 1) for i in [0] * (N + 1)] for x, y in XY: c[Y[y] + 1][X[x] + 1] = 1 fo...
N, K = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in [0] * N] iX = sorted(x for x, y in XY) iY = sorted(y for x, y in XY) X = {x: i for i, x in enumerate(iX)} Y = {y: i for i, y in enumerate(iY)} c = [[0] * (N + 1) for i in [0] * (N + 1)] for x, y in XY: c[Y[y] + 1][X[x] + 1] = 1 fo...
false
6.25
[ "- for u in range(N):", "- for r in range(l + 1, N):", "- for d in range(u + 1, N):", "- if c[d + 1][r + 1] + c[u][l] - c[u][r + 1] - c[d + 1][l] >= K:", "- ans = min(ans, (iX[r] - iX[l]) * (iY[d] - iY[u]))", "- break", "+ for ...
false
0.157983
0.037734
4.186808
[ "s115405979", "s110682077" ]
u761320129
p03210
python
s054363954
s445162872
19
17
3,316
2,940
Accepted
Accepted
10.53
X = int(eval(input())) print(('YES' if X in (3,5,7) else 'NO'))
X = int(eval(input())) print(('YES' if X in (7,5,3) else 'NO'))
2
2
56
56
X = int(eval(input())) print(("YES" if X in (3, 5, 7) else "NO"))
X = int(eval(input())) print(("YES" if X in (7, 5, 3) else "NO"))
false
0
[ "-print((\"YES\" if X in (3, 5, 7) else \"NO\"))", "+print((\"YES\" if X in (7, 5, 3) else \"NO\"))" ]
false
0.077152
0.078093
0.987957
[ "s054363954", "s445162872" ]
u712429027
p02597
python
s477202080
s418207068
61
49
12,684
10,792
Accepted
Accepted
19.67
import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print('\n'.join(map(str, x))) n = ini() s = list(ins()) n = s.count("R") t = sorted(s) ans = 0 for ...
import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print('\n'.join(map(str, x))) n = ini() s = list(ins()) n = s.count("R") ans = 0 for i in range(n): ...
17
16
386
370
import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print("\n".join(map(str, x))) n = ini() s = list(ins()) n = s.count("R") t = sorted(s) ans = 0 for i in range(n)...
import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print("\n".join(map(str, x))) n = ini() s = list(ins()) n = s.count("R") ans = 0 for i in range(n): if s[i] ...
false
5.882353
[ "-t = sorted(s)", "- if s[i] != t[i]:", "+ if s[i] != \"R\":" ]
false
0.040589
0.077921
0.5209
[ "s477202080", "s418207068" ]
u498487134
p02887
python
s658436525
s686598811
177
65
39,408
68,316
Accepted
Accepted
63.28
n = int(eval(input())) s = eval(input()) ans = 1 for i in range(1,n): if s[i]!=s[i-1]: ans+=1 print(ans)
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 cnt=0 N=I() S=eval(input()) now="A" for i in range(N): if S[i]!=now: cnt+=1 now=S[i] ...
8
19
112
328
n = int(eval(input())) s = eval(input()) ans = 1 for i in range(1, n): if s[i] != s[i - 1]: ans += 1 print(ans)
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 cnt = 0 N = I() S = eval(input()) now = "A" for i in range(N): if S[i] != now: cnt += 1 n...
false
57.894737
[ "-n = int(eval(input()))", "-s = eval(input())", "-ans = 1", "-for i in range(1, n):", "- if s[i] != s[i - 1]:", "- ans += 1", "-print(ans)", "+def I():", "+ return int(eval(input()))", "+", "+", "+def MI():", "+ return list(map(int, input().split()))", "+", "+", "+def ...
false
0.0443
0.044775
0.989383
[ "s658436525", "s686598811" ]
u347640436
p02630
python
s885991054
s254405837
271
202
23,572
20,412
Accepted
Accepted
25.46
from sys import stdin readline = stdin.readline N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) t = sum(A) d = {} for a in A: d.setdefault(a, 0) d[a] += 1 for _ in range(Q): B, C = list(map(int, readline().split())) d.setdefault(B, 0) d.setdefault(C,...
from sys import stdin readline = stdin.readline N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) t = [0] * (10 ** 5 + 1) s = sum(A) for a in A: t[a] += 1 for _ in range(Q): B, C = list(map(int, readline().split())) s -= B * t[B] s += C * t[B] t[C] += ...
22
19
402
347
from sys import stdin readline = stdin.readline N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) t = sum(A) d = {} for a in A: d.setdefault(a, 0) d[a] += 1 for _ in range(Q): B, C = list(map(int, readline().split())) d.setdefault(B, 0) d.setdefault(C, 0) t -= B * d...
from sys import stdin readline = stdin.readline N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) t = [0] * (10**5 + 1) s = sum(A) for a in A: t[a] += 1 for _ in range(Q): B, C = list(map(int, readline().split())) s -= B * t[B] s += C * t[B] t[C] += t[B] t[B] = 0 ...
false
13.636364
[ "-t = sum(A)", "-d = {}", "+t = [0] * (10**5 + 1)", "+s = sum(A)", "- d.setdefault(a, 0)", "- d[a] += 1", "+ t[a] += 1", "- d.setdefault(B, 0)", "- d.setdefault(C, 0)", "- t -= B * d[B]", "- t += C * d[B]", "- d[C] += d[B]", "- d[B] = 0", "- print(t)", "+ ...
false
0.046832
0.047967
0.97632
[ "s885991054", "s254405837" ]
u241159583
p03274
python
s886416693
s540738080
103
95
14,224
14,252
Accepted
Accepted
7.77
n, k = list(map(int, input().split())) X = list(map(int, input().split())) ans = float('inf') for i in range(n-k+1): l, r = X[i], X[i+k-1] if r <= 0: ans = min(abs(l), ans) elif 0 <= l: ans = min(abs(r), ans) else: dist = min(abs(l), abs(r))*2+max(abs(l), abs(r)) ...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) ans = float("inf") for i in range(n-k+1): l, r = x[i], x[i+k-1] if r <= 0: a = abs(l) elif l >= 0: a = r else: a = min(abs(l), abs(r)) * 2 + max(abs(l), abs(r)) if ans > a: ans = a print(an...
14
13
351
316
n, k = list(map(int, input().split())) X = list(map(int, input().split())) ans = float("inf") for i in range(n - k + 1): l, r = X[i], X[i + k - 1] if r <= 0: ans = min(abs(l), ans) elif 0 <= l: ans = min(abs(r), ans) else: dist = min(abs(l), abs(r)) * 2 + max(abs(l), abs(r)) ...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) ans = float("inf") for i in range(n - k + 1): l, r = x[i], x[i + k - 1] if r <= 0: a = abs(l) elif l >= 0: a = r else: a = min(abs(l), abs(r)) * 2 + max(abs(l), abs(r)) if ans > a: ans = a prin...
false
7.142857
[ "-X = list(map(int, input().split()))", "+x = list(map(int, input().split()))", "- l, r = X[i], X[i + k - 1]", "+ l, r = x[i], x[i + k - 1]", "- ans = min(abs(l), ans)", "- elif 0 <= l:", "- ans = min(abs(r), ans)", "+ a = abs(l)", "+ elif l >= 0:", "+ a = r...
false
0.111637
0.046264
2.413053
[ "s886416693", "s540738080" ]
u163703551
p03806
python
s836736469
s458388953
592
342
40,228
6,124
Accepted
Accepted
42.23
import sys # sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) def solve(): M = 10 n, ma, mb = read_int...
import sys from collections import defaultdict # sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) M = 10 inf =...
71
61
1,724
1,258
import sys # sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) def solve(): M = 10 n, ma, mb = read_int_list() p = [read_int...
import sys from collections import defaultdict # sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) M = 10 inf = 10**20 def solve(): ...
false
14.084507
[ "+from collections import defaultdict", "+M = 10", "+inf = 10**20", "+", "+", "- M = 10", "- min_c = {(0, 0, 0): 0}", "- for i in range(1, n + 1):", "- a, b, c = p[i - 1]", "- for u in range(0, M * (i - 1) + 1):", "- for v in range(0, M * (i - 1) + 1):", "- ...
false
0.043695
0.035276
1.238666
[ "s836736469", "s458388953" ]
u077291787
p03425
python
s663298300
s134687000
165
61
9,772
9,772
Accepted
Accepted
63.03
# ABC089C - March from itertools import combinations def main(): n = int(eval(input())) lst = [input().rstrip() for _ in range(n)] cond = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in lst: if i[0] in "MARCH": cond[i[0]] += 1 ans = 0 for x, y, z in combinatio...
# ABC089C - March import sys input = sys.stdin.readline from itertools import combinations def main(): n = int(eval(input())) lst = [input().rstrip() for _ in range(n)] cond = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in lst: if i[0] in "MARCH": cond[i[0]] += 1 ...
19
22
433
475
# ABC089C - March from itertools import combinations def main(): n = int(eval(input())) lst = [input().rstrip() for _ in range(n)] cond = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in lst: if i[0] in "MARCH": cond[i[0]] += 1 ans = 0 for x, y, z in combinations("MARCH", ...
# ABC089C - March import sys input = sys.stdin.readline from itertools import combinations def main(): n = int(eval(input())) lst = [input().rstrip() for _ in range(n)] cond = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in lst: if i[0] in "MARCH": cond[i[0]] += 1 ans = 0 ...
false
13.636364
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.036017
0.037105
0.970688
[ "s663298300", "s134687000" ]
u281303342
p03315
python
s342243520
s902091656
19
17
2,940
2,940
Accepted
Accepted
10.53
S = eval(input()) print((S.count("+")-S.count("-")))
S = eval(input()) a = S.count("+") b = S.count("-") print((a-b))
2
4
45
60
S = eval(input()) print((S.count("+") - S.count("-")))
S = eval(input()) a = S.count("+") b = S.count("-") print((a - b))
false
50
[ "-print((S.count(\"+\") - S.count(\"-\")))", "+a = S.count(\"+\")", "+b = S.count(\"-\")", "+print((a - b))" ]
false
0.050927
0.049652
1.025678
[ "s342243520", "s902091656" ]
u425351967
p03163
python
s976765080
s431986233
473
414
120,044
118,512
Accepted
Accepted
12.47
N, W = (int(n) for n in input().split()) w, v = [], [] for _ in range(N): w_, v_ = (int(n) for n in input().split()) w.append(w_) v.append(v_) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(N): for w_ in range(W + 1): if w_ >= w[i]: dp[i + 1][w_] = max(dp[i][...
N, weight_capacity = (int(n) for n in input().split()) weights, values = [], [] for _ in range(N): w, v = (int(n) for n in input().split()) weights.append(w) values.append(v) def knapsack_dp(weight_capacity, weights, values): """Solve knapsack problem by dynamic programming""" N = len(weig...
17
22
422
737
N, W = (int(n) for n in input().split()) w, v = [], [] for _ in range(N): w_, v_ = (int(n) for n in input().split()) w.append(w_) v.append(v_) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(N): for w_ in range(W + 1): if w_ >= w[i]: dp[i + 1][w_] = max(dp[i][w_], dp[i][w_ ...
N, weight_capacity = (int(n) for n in input().split()) weights, values = [], [] for _ in range(N): w, v = (int(n) for n in input().split()) weights.append(w) values.append(v) def knapsack_dp(weight_capacity, weights, values): """Solve knapsack problem by dynamic programming""" N = len(weights) ...
false
22.727273
[ "-N, W = (int(n) for n in input().split())", "-w, v = [], []", "+N, weight_capacity = (int(n) for n in input().split())", "+weights, values = [], []", "- w_, v_ = (int(n) for n in input().split())", "- w.append(w_)", "- v.append(v_)", "-dp = [[0] * (W + 1) for _ in range(N + 1)]", "-for i i...
false
0.047261
0.116151
0.406891
[ "s976765080", "s431986233" ]
u906501980
p02713
python
s286005751
s597326422
206
44
75,244
9,372
Accepted
Accepted
78.64
def main(): k = int(eval(input())) gcds = list(sorted([gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)])) j = 0 s = list(sorted(list(set(gcds)))) m = k**2-1 gcdss = [0]*len(s) flag = False for i, l in enumerate(s): while gcds[j] == l: gcdss[i] += 1 ...
def main(): k = int(eval(input())) gcds = [] for i in range(1, k+1): for j in range(1, k+1): gcds.append(gcd(i, j)) ans = {i:0 for i in set(gcds)} for i in gcds: ans[i] += 1 out = 0 for i, v in list(ans.items()): for j in range(1, k+1): ...
32
23
734
479
def main(): k = int(eval(input())) gcds = list(sorted([gcd(i, j) for i in range(1, k + 1) for j in range(1, k + 1)])) j = 0 s = list(sorted(list(set(gcds)))) m = k**2 - 1 gcdss = [0] * len(s) flag = False for i, l in enumerate(s): while gcds[j] == l: gcdss[i] += 1 ...
def main(): k = int(eval(input())) gcds = [] for i in range(1, k + 1): for j in range(1, k + 1): gcds.append(gcd(i, j)) ans = {i: 0 for i in set(gcds)} for i in gcds: ans[i] += 1 out = 0 for i, v in list(ans.items()): for j in range(1, k + 1): ...
false
28.125
[ "- gcds = list(sorted([gcd(i, j) for i in range(1, k + 1) for j in range(1, k + 1)]))", "- j = 0", "- s = list(sorted(list(set(gcds))))", "- m = k**2 - 1", "- gcdss = [0] * len(s)", "- flag = False", "- for i, l in enumerate(s):", "- while gcds[j] == l:", "- gc...
false
0.30121
0.048938
6.154955
[ "s286005751", "s597326422" ]
u906501980
p02660
python
s415895864
s867816186
72
66
65,844
65,720
Accepted
Accepted
8.33
from collections import Counter def get_prime_factors(x): out = [] if x < 1: return out while not x%2: out.append(2) x //= 2 i = 3 while i*i <= x: if not x%i: out.append(i) x //= i else: i += 2 if x != 1...
from collections import Counter def get_prime_factors(x): out = [] if x < 1: return out while not x%2: out.append(2) x //= 2 i = 3 while i*i <= x: if not x%i: out.append(i) x //= i else: i += 2 if x != 1: ...
35
34
663
661
from collections import Counter def get_prime_factors(x): out = [] if x < 1: return out while not x % 2: out.append(2) x //= 2 i = 3 while i * i <= x: if not x % i: out.append(i) x //= i else: i += 2 if x != 1: ...
from collections import Counter def get_prime_factors(x): out = [] if x < 1: return out while not x % 2: out.append(2) x //= 2 i = 3 while i * i <= x: if not x % i: out.append(i) x //= i else: i += 2 if x != 1: ...
false
2.857143
[ "+ primes = Counter(get_prime_factors(n))", "- primes = Counter(get_prime_factors(n))" ]
false
0.038371
0.036699
1.045575
[ "s415895864", "s867816186" ]
u814986259
p03107
python
s857039111
s176891401
49
34
3,188
3,188
Accepted
Accepted
30.61
S = eval(input()) count = [0, 0] for x in S: count[int(x)] += 1 print((min(count)*2))
d = dict() d['0'] = 0 d['1'] = 0 S = eval(input()) for x in S: d[x] += 1 print((min(d['0'], d['1'])*2))
6
9
88
110
S = eval(input()) count = [0, 0] for x in S: count[int(x)] += 1 print((min(count) * 2))
d = dict() d["0"] = 0 d["1"] = 0 S = eval(input()) for x in S: d[x] += 1 print((min(d["0"], d["1"]) * 2))
false
33.333333
[ "+d = dict()", "+d[\"0\"] = 0", "+d[\"1\"] = 0", "-count = [0, 0]", "- count[int(x)] += 1", "-print((min(count) * 2))", "+ d[x] += 1", "+print((min(d[\"0\"], d[\"1\"]) * 2))" ]
false
0.036548
0.167109
0.218705
[ "s857039111", "s176891401" ]
u957198490
p03719
python
s705716815
s405355834
166
17
38,384
2,940
Accepted
Accepted
89.76
A,B,C = list(map(int,input().split())) if A <= C and C <= B: print('Yes') else: print('No')
a,b,c = list(map(int,input().split())) if a <= c and c <= b: print('Yes') else: print('No')
5
5
98
97
A, B, C = list(map(int, input().split())) if A <= C and C <= B: print("Yes") else: print("No")
a, b, c = list(map(int, input().split())) if a <= c and c <= b: print("Yes") else: print("No")
false
0
[ "-A, B, C = list(map(int, input().split()))", "-if A <= C and C <= B:", "+a, b, c = list(map(int, input().split()))", "+if a <= c and c <= b:" ]
false
0.081679
0.079591
1.026225
[ "s705716815", "s405355834" ]
u357751375
p03371
python
s273744491
s343042050
29
24
9,104
9,136
Accepted
Accepted
17.24
a,b,c,x,y = list(map(int,input().split())) l = 0 p = x if x > y: l += (x - y) * a p = y elif x < y: l += (y - x) * b p = x else: pass l += p * 2 * c n = max(x,y) * 2 * c m = x * a + y * b print((min(l,n,m)))
a,b,c,x,y = list(map(int,input().split())) l = 0 flg = x if x > y: l += (x - y) * a flg = y elif x < y: l += (y - x) * b else: pass l += flg * 2 * c n = max(x,y) * 2 * c m = x * a + y * b print((min(l,n,m)))
16
14
235
228
a, b, c, x, y = list(map(int, input().split())) l = 0 p = x if x > y: l += (x - y) * a p = y elif x < y: l += (y - x) * b p = x else: pass l += p * 2 * c n = max(x, y) * 2 * c m = x * a + y * b print((min(l, n, m)))
a, b, c, x, y = list(map(int, input().split())) l = 0 flg = x if x > y: l += (x - y) * a flg = y elif x < y: l += (y - x) * b else: pass l += flg * 2 * c n = max(x, y) * 2 * c m = x * a + y * b print((min(l, n, m)))
false
12.5
[ "-p = x", "+flg = x", "- p = y", "+ flg = y", "- p = x", "-l += p * 2 * c", "+l += flg * 2 * c" ]
false
0.036368
0.046015
0.790338
[ "s273744491", "s343042050" ]
u219494936
p02642
python
s977317747
s709669630
1,275
1,174
51,296
51,296
Accepted
Accepted
7.92
import numpy as np N = int(eval(input())) A = list(map(int, input().split(" "))) Amax = max(A) dp = np.ones(Amax, dtype=bool) appear = np.zeros(Amax, dtype=int) for a in A: appear[a-1] += 1 for i in range(1, len(dp)+1): if not dp[i-1]: continue if appear[i-1] != 0: j = 2 while j * i <...
import numpy as np N = int(eval(input())) A = [int(x) for x in input().split(" ")] Amax = max(A) dp = np.ones(Amax, dtype=bool) appear = np.zeros(Amax, dtype=int) for a in A: appear[a-1] += 1 for i in range(1, len(dp)+1): if not dp[i-1]: continue if appear[i-1] != 0: j = 2 while j * i...
30
26
542
475
import numpy as np N = int(eval(input())) A = list(map(int, input().split(" "))) Amax = max(A) dp = np.ones(Amax, dtype=bool) appear = np.zeros(Amax, dtype=int) for a in A: appear[a - 1] += 1 for i in range(1, len(dp) + 1): if not dp[i - 1]: continue if appear[i - 1] != 0: j = 2 whi...
import numpy as np N = int(eval(input())) A = [int(x) for x in input().split(" ")] Amax = max(A) dp = np.ones(Amax, dtype=bool) appear = np.zeros(Amax, dtype=int) for a in A: appear[a - 1] += 1 for i in range(1, len(dp) + 1): if not dp[i - 1]: continue if appear[i - 1] != 0: j = 2 w...
false
13.333333
[ "-A = list(map(int, input().split(\" \")))", "+A = [int(x) for x in input().split(\" \")]", "-# print(dp)", "-app_set = set([])", "-dup_set = set([])", "-print((count - len(dup_set)))", "+print(count)" ]
false
0.271825
0.282171
0.963335
[ "s977317747", "s709669630" ]
u357751375
p02881
python
s969286829
s257071519
158
146
9,164
9,112
Accepted
Accepted
7.59
import math n = int(eval(input())) p = 10 ** 12 m = math.floor(math.sqrt(n)) for i in range(1,m + 1): if n % i == 0: j = n // i p = min(p,i-1+j-1) print(p)
from math import sqrt from math import floor n = int(eval(input())) ans = 10 ** 12 m = floor(sqrt(n)) for i in range(1,m+1): if n % i == 0: j = n // i ans = min(ans,i+j-2) print(ans)
11
10
181
205
import math n = int(eval(input())) p = 10**12 m = math.floor(math.sqrt(n)) for i in range(1, m + 1): if n % i == 0: j = n // i p = min(p, i - 1 + j - 1) print(p)
from math import sqrt from math import floor n = int(eval(input())) ans = 10**12 m = floor(sqrt(n)) for i in range(1, m + 1): if n % i == 0: j = n // i ans = min(ans, i + j - 2) print(ans)
false
9.090909
[ "-import math", "+from math import sqrt", "+from math import floor", "-p = 10**12", "-m = math.floor(math.sqrt(n))", "+ans = 10**12", "+m = floor(sqrt(n))", "- p = min(p, i - 1 + j - 1)", "-print(p)", "+ ans = min(ans, i + j - 2)", "+print(ans)" ]
false
0.094179
0.082855
1.136663
[ "s969286829", "s257071519" ]
u583010173
p03457
python
s905320566
s512558251
403
365
21,108
3,064
Accepted
Accepted
9.43
# -*- coding: utf-8 -*- n = int(eval(input())) t_bef, x_bef, y_bef, flag = 0, 0, 0, 0 travel = [] for i in range(n): travel.append([int(x) for x in input().split()]) for j in travel: t, x, y = j[0], j[1], j[2] check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y) t_bef, x_bef, y_bef = t, x,...
# -*- coding: utf-8 -*- n = int(eval(input())) t_bef, x_bef, y_bef, flag = 0, 0, 0, 0 travel = [] for i in range(n): t, x, y = [int(x) for x in input().split()] check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y) t_bef, x_bef, y_bef = t, x, y if check < 0: print('No') flag ...
22
19
500
443
# -*- coding: utf-8 -*- n = int(eval(input())) t_bef, x_bef, y_bef, flag = 0, 0, 0, 0 travel = [] for i in range(n): travel.append([int(x) for x in input().split()]) for j in travel: t, x, y = j[0], j[1], j[2] check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y) t_bef, x_bef, y_bef = t, x, y if che...
# -*- coding: utf-8 -*- n = int(eval(input())) t_bef, x_bef, y_bef, flag = 0, 0, 0, 0 travel = [] for i in range(n): t, x, y = [int(x) for x in input().split()] check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y) t_bef, x_bef, y_bef = t, x, y if check < 0: print("No") flag = 1 ...
false
13.636364
[ "- travel.append([int(x) for x in input().split()])", "-for j in travel:", "- t, x, y = j[0], j[1], j[2]", "+ t, x, y = [int(x) for x in input().split()]" ]
false
0.069513
0.039033
1.780878
[ "s905320566", "s512558251" ]
u044220565
p02845
python
s380114675
s539062311
722
90
143,872
19,728
Accepted
Accepted
87.53
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math #from itertools import product, accumulate, combinations, product #impor...
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math #from itertools import product, accumulate, combinations, product #impor...
49
45
1,207
1,049
# coding: utf-8 import sys # from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math # from itertools import product, accumulate, combinations, product # import bi...
# coding: utf-8 import sys # from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read from heapq import heappop, heappush from collections import defaultdict sys.setrecursionlimit(10**7) import math # from itertools import product, accumulate, combinations, product # import bi...
false
8.163265
[ "- dp = [defaultdict(lambda: 0) for _ in range(N + 1)]", "- dp[0][(0, 0, 0)] = 1", "- for i in range(N):", "- a = A[i]", "- k = i + 1", "- for key in list(dp[k - 1].keys()):", "- for ii, v in enumerate(key):", "- if v == a:", "- ...
false
0.044246
0.034059
1.299109
[ "s380114675", "s539062311" ]
u803848678
p02839
python
s548821656
s815198222
1,990
243
691,464
55,900
Accepted
Accepted
87.79
def x(): return list(map(int,input().split())) v=list c=abs r=range h,w=x() p=v(r(h)) a=[v(x())for i in p] b=[v(x())for i in p] m=13120 D=[[[0]*m for i in r(w)]for i in p] for i in p: for j in r(w): k=c(a[i][j]-b[i][j]) if i|j: for l in r((i+j+1)*80+1): e=c(l-k) D[i][j][l]=D[i][j-1][e]...
h,w = list(map(int, input().split())) a = [list(map(int, input().split())) for i in range(h)] b = [list(map(int, input().split())) for i in range(h)] # zeroは真ん中にする ma = 80*2*80 DP = [[0]*w for i in range(h)] for i in range(h): for j in range(w): k = abs(a[i][j]-b[i][j]) if i|j: ...
21
21
410
530
def x(): return list(map(int, input().split())) v = list c = abs r = range h, w = x() p = v(r(h)) a = [v(x()) for i in p] b = [v(x()) for i in p] m = 13120 D = [[[0] * m for i in r(w)] for i in p] for i in p: for j in r(w): k = c(a[i][j] - b[i][j]) if i | j: for l in r((i + j + 1) ...
h, w = list(map(int, input().split())) a = [list(map(int, input().split())) for i in range(h)] b = [list(map(int, input().split())) for i in range(h)] # zeroは真ん中にする ma = 80 * 2 * 80 DP = [[0] * w for i in range(h)] for i in range(h): for j in range(w): k = abs(a[i][j] - b[i][j]) if i | j: ...
false
0
[ "-def x():", "- return list(map(int, input().split()))", "-", "-", "-v = list", "-c = abs", "-r = range", "-h, w = x()", "-p = v(r(h))", "-a = [v(x()) for i in p]", "-b = [v(x()) for i in p]", "-m = 13120", "-D = [[[0] * m for i in r(w)] for i in p]", "-for i in p:", "- for j in r(...
false
0.048294
0.039372
1.226586
[ "s548821656", "s815198222" ]
u952708174
p02889
python
s289652147
s111477097
1,007
910
41,632
41,652
Accepted
Accepted
9.63
def e_travel_by_car(INF=float('inf')): from copy import deepcopy from scipy.sparse.csgraph import floyd_warshall N, M, L = [int(i) for i in input().split()] Roads = [[int(i) for i in input().split()] for j in range(M)] Q = int(eval(input())) Queries = [[int(i) for i in input().split()] for...
def e_travel_by_car(INF=float('inf')): from copy import deepcopy from scipy.sparse.csgraph import floyd_warshall N, M, L = [int(i) for i in input().split()] Roads = [[int(i) for i in input().split()] for j in range(M)] Q = int(eval(input())) Queries = [[int(i) for i in input().split()] for...
26
26
868
881
def e_travel_by_car(INF=float("inf")): from copy import deepcopy from scipy.sparse.csgraph import floyd_warshall N, M, L = [int(i) for i in input().split()] Roads = [[int(i) for i in input().split()] for j in range(M)] Q = int(eval(input())) Queries = [[int(i) for i in input().split()] for j in...
def e_travel_by_car(INF=float("inf")): from copy import deepcopy from scipy.sparse.csgraph import floyd_warshall N, M, L = [int(i) for i in input().split()] Roads = [[int(i) for i in input().split()] for j in range(M)] Q = int(eval(input())) Queries = [[int(i) for i in input().split()] for j in...
false
0
[ "- for j in range(N):", "- fuel[i][j] = int(dist[i][j] <= L)", "+ for j in range(i):", "+ fuel[i][j] = fuel[j][i] = int(dist[i][j] <= L)" ]
false
0.255082
0.591247
0.431431
[ "s289652147", "s111477097" ]
u892487306
p02642
python
s351579834
s219646312
1,116
988
44,020
36,752
Accepted
Accepted
11.47
from collections import Counter def main(): N = int(eval(input())) A = list(map(int, input().split(' '))) counter = Counter(A) searched = [0 for _ in range(10 ** 6 + 1)] ans = 0 for i in range(1, 10 ** 6 + 1): if counter[i] == 0: continue if searched[i] ...
def main(): N = int(eval(input())) A = list(map(int, input().split(' '))) counter = [0 for _ in range(10 ** 6 + 1)] for a in A: counter[a] += 1 searched = [0 for _ in range(10 ** 6 + 1)] ans = 0 for i in range(1, 10 ** 6 + 1): if counter[i] == 0: continu...
21
20
504
530
from collections import Counter def main(): N = int(eval(input())) A = list(map(int, input().split(" "))) counter = Counter(A) searched = [0 for _ in range(10**6 + 1)] ans = 0 for i in range(1, 10**6 + 1): if counter[i] == 0: continue if searched[i] == 0 and counter...
def main(): N = int(eval(input())) A = list(map(int, input().split(" "))) counter = [0 for _ in range(10**6 + 1)] for a in A: counter[a] += 1 searched = [0 for _ in range(10**6 + 1)] ans = 0 for i in range(1, 10**6 + 1): if counter[i] == 0: continue if sea...
false
4.761905
[ "-from collections import Counter", "-", "-", "- counter = Counter(A)", "+ counter = [0 for _ in range(10**6 + 1)]", "+ for a in A:", "+ counter[a] += 1" ]
false
0.699581
0.355595
1.967351
[ "s351579834", "s219646312" ]
u489959379
p02881
python
s816242564
s060561753
161
116
3,560
3,268
Accepted
Accepted
27.95
n = int(eval(input())) divisors = [] for i in range(1, int(pow(n, 0.5)) + 1): if n % i == 0: divisors.append([i, n // i]) divisors = sorted(divisors, key= lambda x:x[1]) res = 0 for i in divisors[0]: res += i - 1 print(res)
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 # nの約数を列挙列挙する def make_divisors(n): divisors = [] for i in range(1, int(pow(n, 0.5)) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) ...
12
34
246
597
n = int(eval(input())) divisors = [] for i in range(1, int(pow(n, 0.5)) + 1): if n % i == 0: divisors.append([i, n // i]) divisors = sorted(divisors, key=lambda x: x[1]) res = 0 for i in divisors[0]: res += i - 1 print(res)
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 # nの約数を列挙列挙する def make_divisors(n): divisors = [] for i in range(1, int(pow(n, 0.5)) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() ...
false
64.705882
[ "-n = int(eval(input()))", "-divisors = []", "-for i in range(1, int(pow(n, 0.5)) + 1):", "- if n % i == 0:", "- divisors.append([i, n // i])", "-divisors = sorted(divisors, key=lambda x: x[1])", "-res = 0", "-for i in divisors[0]:", "- res += i - 1", "-print(res)", "+import sys", ...
false
0.040926
0.049788
0.821997
[ "s816242564", "s060561753" ]
u074220993
p03625
python
s951310898
s553864543
81
73
20,076
20,080
Accepted
Accepted
9.88
N = int(eval(input())) A = [int(x) for x in input().split()] pair = [] unpair = set() for a in A: if a in unpair: pair.append(a) unpair.remove(a) else: unpair.add(a) pair.sort() pair.reverse() if len(pair) <= 1: ans = 0 else: ans = pair[0] * pair[1] print(ans)
with open(0) as f: N, *A = list(map(int, f.read().split())) pair = [] unpair = set() for a in A: if a in unpair: unpair.remove(a) pair.append(a) else: unpair.add(a) pair.sort() print((pair.pop()*pair.pop() if len(pair) > 1 else 0))
19
13
314
272
N = int(eval(input())) A = [int(x) for x in input().split()] pair = [] unpair = set() for a in A: if a in unpair: pair.append(a) unpair.remove(a) else: unpair.add(a) pair.sort() pair.reverse() if len(pair) <= 1: ans = 0 else: ans = pair[0] * pair[1] print(ans)
with open(0) as f: N, *A = list(map(int, f.read().split())) pair = [] unpair = set() for a in A: if a in unpair: unpair.remove(a) pair.append(a) else: unpair.add(a) pair.sort() print((pair.pop() * pair.pop() if len(pair) > 1 else 0))
false
31.578947
[ "-N = int(eval(input()))", "-A = [int(x) for x in input().split()]", "+with open(0) as f:", "+ N, *A = list(map(int, f.read().split()))", "+ unpair.remove(a)", "- unpair.remove(a)", "-pair.reverse()", "-if len(pair) <= 1:", "- ans = 0", "-else:", "- ans = pair[0] * pair[1]...
false
0.061052
0.103829
0.588006
[ "s951310898", "s553864543" ]
u263830634
p02775
python
s166466677
s442466976
1,306
1,060
66,388
19,688
Accepted
Accepted
18.84
N = ['0'] + list(eval(input())) + ['0'] # print (N) n = len(N) ans = 0 flag = False count = 0 for i in range(n - 1, 0, -1): s = int(N[i]) if flag: s += 1 N[i] = str(s) else: pass if s <= 5: next_ = int(N[i - 1]) if s == 5 and next_ >= 5: ...
S = ['0'] + list(eval(input())) + ['0'] N = len(S) flag = False ans = 0 for i in range(N - 1, 0, -1): j = int(S[i]) if flag: j += 1 S[i] = j if j <= 5: if j == 5 and int(S[i - 1]) >= 5: ans += j flag = True else: ans += ...
43
43
674
617
N = ["0"] + list(eval(input())) + ["0"] # print (N) n = len(N) ans = 0 flag = False count = 0 for i in range(n - 1, 0, -1): s = int(N[i]) if flag: s += 1 N[i] = str(s) else: pass if s <= 5: next_ = int(N[i - 1]) if s == 5 and next_ >= 5: # ans -= 1 ...
S = ["0"] + list(eval(input())) + ["0"] N = len(S) flag = False ans = 0 for i in range(N - 1, 0, -1): j = int(S[i]) if flag: j += 1 S[i] = j if j <= 5: if j == 5 and int(S[i - 1]) >= 5: ans += j flag = True else: ans += j flag =...
false
0
[ "-N = [\"0\"] + list(eval(input())) + [\"0\"]", "-# print (N)", "-n = len(N)", "+S = [\"0\"] + list(eval(input())) + [\"0\"]", "+N = len(S)", "+flag = False", "-flag = False", "-count = 0", "-for i in range(n - 1, 0, -1):", "- s = int(N[i])", "+for i in range(N - 1, 0, -1):", "+ j = int(...
false
0.044866
0.04445
1.009375
[ "s166466677", "s442466976" ]
u764215612
p02708
python
s049837569
s836838081
99
91
9,188
9,192
Accepted
Accepted
8.08
n, k = list(map(int, input().split())) ans = 0 p = 10 ** 9 + 7 a = 0 b = 0 for j in range(k): a += j b += n-j for i in range(k, n+2): ans = (ans+b-a+1)%p a += i b += n-i print(ans)
n, k = list(map(int, input().split())) ans = 0 p = 10 ** 9 + 7 a = 0 b = 0 for j in range(k-1): a += j b += n-j for i in range(k-1, n+1): a += i b += n-i ans = (ans+b-a+1)%p print(ans)
13
13
196
200
n, k = list(map(int, input().split())) ans = 0 p = 10**9 + 7 a = 0 b = 0 for j in range(k): a += j b += n - j for i in range(k, n + 2): ans = (ans + b - a + 1) % p a += i b += n - i print(ans)
n, k = list(map(int, input().split())) ans = 0 p = 10**9 + 7 a = 0 b = 0 for j in range(k - 1): a += j b += n - j for i in range(k - 1, n + 1): a += i b += n - i ans = (ans + b - a + 1) % p print(ans)
false
0
[ "-for j in range(k):", "+for j in range(k - 1):", "-for i in range(k, n + 2):", "- ans = (ans + b - a + 1) % p", "+for i in range(k - 1, n + 1):", "+ ans = (ans + b - a + 1) % p" ]
false
0.187884
0.072659
2.585821
[ "s049837569", "s836838081" ]
u572122511
p02659
python
s095817390
s059329515
24
21
9,156
9,156
Accepted
Accepted
12.5
AB = list(input().split()) A = int(AB[0]) B = int(float(AB[1]) * 100 + 0.5) A *= B print((A // 100))
AB = list(input().split()) A = int(AB[0]) B = int(float(AB[1]) * 100 + 0.5) print((A * B // 100))
5
4
102
98
AB = list(input().split()) A = int(AB[0]) B = int(float(AB[1]) * 100 + 0.5) A *= B print((A // 100))
AB = list(input().split()) A = int(AB[0]) B = int(float(AB[1]) * 100 + 0.5) print((A * B // 100))
false
20
[ "-A *= B", "-print((A // 100))", "+print((A * B // 100))" ]
false
0.040624
0.04432
0.916614
[ "s095817390", "s059329515" ]
u435480265
p02579
python
s817941497
s111115638
637
569
167,676
96,356
Accepted
Accepted
10.68
h,w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) ch -= 1 cw -= 1 dh,dw = list(map(int, input().split())) dh -= 1 dw -= 1 def trans(s): res = [] for i in s: if i == '.': res.append(-1) else: res.append(-2) return res def...
h,w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) ch -= 1 cw -= 1 dh,dw = list(map(int, input().split())) dh -= 1 dw -= 1 def trans(s): res = [] for i in s: if i == '.': res.append(-1) else: res.append(-2) return res def...
61
58
1,754
1,649
h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) ch -= 1 cw -= 1 dh, dw = list(map(int, input().split())) dh -= 1 dw -= 1 def trans(s): res = [] for i in s: if i == ".": res.append(-1) else: res.append(-2) return res def move(x, y, d...
h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) ch -= 1 cw -= 1 dh, dw = list(map(int, input().split())) dh -= 1 dw -= 1 def trans(s): res = [] for i in s: if i == ".": res.append(-1) else: res.append(-2) return res def move(x, y, d...
false
4.918033
[ "- s_moved = set()", "- if not (xx, yy) in s_moved:", "- if xx == dh and yy == dw:", "- return m[xx][yy]", "- move(xx, yy, dq, dq_next)", "- s_moved.add((xx, yy))", "+ if xx == dh and yy == dw:", "+ ...
false
0.044177
0.044155
1.000488
[ "s817941497", "s111115638" ]
u751717561
p04033
python
s915230642
s681573567
311
153
20,948
12,256
Accepted
Accepted
50.8
import bisect,collections,copy,heapq,itertools,math,numpy,string import sys 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(sys.stdin.readline().rstrip().split()) #N = I() ...
import bisect,collections,copy,heapq,itertools,math,numpy,string import sys #N = I() #A = [LI() for _ in range(N)] a, b = list(map(int,sys.stdin.readline().rstrip().split())) if a > 0: print('Positive') elif a <= 0 and b >= 0: print('Zero') else: if (a+b)%2 == 0: print('Negative') ...
20
16
586
354
import bisect, collections, copy, heapq, itertools, math, numpy, string import sys 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(sys.stdin.readline().rs...
import bisect, collections, copy, heapq, itertools, math, numpy, string import sys # N = I() # A = [LI() for _ in range(N)] a, b = list(map(int, sys.stdin.readline().rstrip().split())) if a > 0: print("Positive") elif a <= 0 and b >= 0: print("Zero") else: if (a + b) % 2 == 0: print("Negative") ...
false
20
[ "-", "-", "-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(sys.stdin....
false
0.112027
0.040152
2.790097
[ "s915230642", "s681573567" ]
u197300260
p03495
python
s385923552
s030551009
203
145
39,344
44,184
Accepted
Accepted
28.57
# _*_ coding:utf-8 _*_ # Atcoder_Beginnger_Contest081-C # TODO https://atcoder.jp/contests/abc081/tasks/arc086_a import collections as col def solveProblem(neededBallKind,BallsList): AsListCounter = col.Counter(BallsList) allBallKind = len(AsListCounter) sortCounter = sorted(list(AsListCounter.items()),re...
# Problem: atcoder.jp/contests/abc081/tasks/arc086_a # Python 1st Try import sys # from collections import defaultdict import collections as col # import pprint # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().s...
27
40
856
1,227
# _*_ coding:utf-8 _*_ # Atcoder_Beginnger_Contest081-C # TODO https://atcoder.jp/contests/abc081/tasks/arc086_a import collections as col def solveProblem(neededBallKind, BallsList): AsListCounter = col.Counter(BallsList) allBallKind = len(AsListCounter) sortCounter = sorted(list(AsListCounter.items())...
# Problem: atcoder.jp/contests/abc081/tasks/arc086_a # Python 1st Try import sys # from collections import defaultdict import collections as col # import pprint # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline()....
false
32.5
[ "-# _*_ coding:utf-8 _*_", "-# Atcoder_Beginnger_Contest081-C", "-# TODO https://atcoder.jp/contests/abc081/tasks/arc086_a", "+# Problem: atcoder.jp/contests/abc081/tasks/arc086_a", "+# Python 1st Try", "+import sys", "+", "+# from collections import defaultdict", "+# import pprint", "+# import ...
false
0.056214
0.05348
1.051121
[ "s385923552", "s030551009" ]
u546338822
p02779
python
s855593554
s583216030
90
83
26,808
26,808
Accepted
Accepted
7.78
n = int(eval(input())) a = list(map(int,input().split())) if len(a) == len(set(a)): print('YES') else: print('NO')
n = int(eval(input())) a = list(map(int,input().split())) if n == len(set(a)): print('YES') else: print('NO')
9
7
127
118
n = int(eval(input())) a = list(map(int, input().split())) if len(a) == len(set(a)): print("YES") else: print("NO")
n = int(eval(input())) a = list(map(int, input().split())) if n == len(set(a)): print("YES") else: print("NO")
false
22.222222
[ "-if len(a) == len(set(a)):", "+if n == len(set(a)):" ]
false
0.046635
0.045872
1.016629
[ "s855593554", "s583216030" ]
u677523557
p03452
python
s730710784
s936984716
1,931
1,352
131,224
67,404
Accepted
Accepted
29.98
import sys sys.setrecursionlimit(1000000) N, M = list(map(int, input().split())) class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1]*(n+1) # 木をく...
class UnionFind(): # 作りたい要素数nで初期化 def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) # ノードxのrootノードを見つける def Find_Root(self, x): if(self.root[x] < 0): return x else: self.root[x] = self.Find_Root(self...
95
76
2,303
1,814
import sys sys.setrecursionlimit(1000000) N, M = list(map(int, input().split())) class UnionFind: # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランス...
class UnionFind: # 作りたい要素数nで初期化 def __init__(self, n): self.n = n self.root = [-1] * (n + 1) self.rnk = [0] * (n + 1) # ノードxのrootノードを見つける def Find_Root(self, x): if self.root[x] < 0: return x else: self.root[x] = self.Find_Root(self.root[x...
false
20
[ "-import sys", "-", "-sys.setrecursionlimit(1000000)", "-N, M = list(map(int, input().split()))", "-", "-", "- # 使用するインスタンス変数の初期化", "- # root[x]<0ならそのノードが根かつその値が木の要素数", "- # rootノードでその木の要素数を記録する", "- # 木をくっつける時にアンバランスにならないように調整する", "- # ここで代入しておくことで、後の繰り返しを避ける"...
false
0.121897
0.048991
2.488165
[ "s730710784", "s936984716" ]
u064505481
p02685
python
s371407946
s015915357
419
257
84,472
75,776
Accepted
Accepted
38.66
from sys import stdin, stdout rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float('inf'), float('-inf') def binom_tables(n, q): fact = [1 for _ in range(n + 1)] inv = [1 for _ in range(n + 1)] for i in range(1, n+...
from sys import stdin, stdout rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float('inf'), float('-inf') def binom_tables(n, q): fact = [1 for _ in range(n + 1)] inv = [1 for _ in range(n + 1)] for i in range(1, n+...
30
31
708
701
from sys import stdin, stdout rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float("inf"), float("-inf") def binom_tables(n, q): fact = [1 for _ in range(n + 1)] inv = [1 for _ in range(n + 1)] for i in range(1, n + ...
from sys import stdin, stdout rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float("inf"), float("-inf") def binom_tables(n, q): fact = [1 for _ in range(n + 1)] inv = [1 for _ in range(n + 1)] for i in range(1, n + ...
false
3.225806
[ "-def binom(n, k, q, F, I):", "- return (F[n] * ((I[k] * I[n - k]) % q)) % q", "-", "-", "+", "+ def binom(n, k, q):", "+ return (F[n] * ((I[k] * I[n - k]) % q)) % q", "+", "- ans += (binom(n - 1, i - 1, MOD, F, I) * m * pow(m - 1, i - 1, MOD)) % MOD", "+ ans += (binom(n...
false
0.424269
0.127267
3.333679
[ "s371407946", "s015915357" ]
u692746605
p02733
python
s389703333
s531725481
1,533
907
3,444
3,444
Accepted
Accepted
40.83
H,W,K=list(map(int,input().split())) S=[[int(x) for x in list(str(eval(input())))] for _ in range(H)] T=[[0]*(W+1) for x in range(H+1)] for h in range(H): for w in range(W): T[h][w]=T[h][w-1]+S[h][w] for h in range(1,H): for w in range(W): T[h][w]=T[h][w]+T[h-1][w] m=(H-1)*(W-1) for p in ran...
H,W,K=list(map(int,input().split())) S=[[int(x) for x in list(str(eval(input())))] for _ in range(H)] T=[[0]*(W+1) for x in range(H+1)] def main(): for h in range(H): for w in range(W): T[h][w]=T[h][w-1]+S[h][w] for h in range(1,H): for w in range(W): T[h][w]=T[h][w]+T[h-1][w] ...
33
34
652
721
H, W, K = list(map(int, input().split())) S = [[int(x) for x in list(str(eval(input())))] for _ in range(H)] T = [[0] * (W + 1) for x in range(H + 1)] for h in range(H): for w in range(W): T[h][w] = T[h][w - 1] + S[h][w] for h in range(1, H): for w in range(W): T[h][w] = T[h][w] + T[h - 1][w] m ...
H, W, K = list(map(int, input().split())) S = [[int(x) for x in list(str(eval(input())))] for _ in range(H)] T = [[0] * (W + 1) for x in range(H + 1)] def main(): for h in range(H): for w in range(W): T[h][w] = T[h][w - 1] + S[h][w] for h in range(1, H): for w in range(W): ...
false
2.941176
[ "-for h in range(H):", "- for w in range(W):", "- T[h][w] = T[h][w - 1] + S[h][w]", "-for h in range(1, H):", "- for w in range(W):", "- T[h][w] = T[h][w] + T[h - 1][w]", "-m = (H - 1) * (W - 1)", "-for p in range(2 ** (H - 1)):", "- D = [x for x in range(H - 1) if p & (2**x) ...
false
0.048336
0.048327
1.000177
[ "s389703333", "s531725481" ]
u397953026
p02688
python
s875734547
s925695685
29
26
9,184
9,180
Accepted
Accepted
10.34
n,k = list(map(int,input().split())) count = [0]*n for i in range(k): d = int(eval(input())) a = list(map(int,input().split())) for j in range(len(a)): count[a[j]-1] += 1 print((count.count(0)))
n,k = list(map(int,input().split())) ans = [0]*n for i in range(k): d = int(eval(input())) a = list(map(int,input().split())) for j in range(len(a)): ans[a[j]-1] += 1 print((ans.count(0)))
9
8
209
201
n, k = list(map(int, input().split())) count = [0] * n for i in range(k): d = int(eval(input())) a = list(map(int, input().split())) for j in range(len(a)): count[a[j] - 1] += 1 print((count.count(0)))
n, k = list(map(int, input().split())) ans = [0] * n for i in range(k): d = int(eval(input())) a = list(map(int, input().split())) for j in range(len(a)): ans[a[j] - 1] += 1 print((ans.count(0)))
false
11.111111
[ "-count = [0] * n", "+ans = [0] * n", "- count[a[j] - 1] += 1", "-print((count.count(0)))", "+ ans[a[j] - 1] += 1", "+print((ans.count(0)))" ]
false
0.049535
0.049602
0.998651
[ "s875734547", "s925695685" ]
u072717685
p02695
python
s383977486
s520755674
815
609
21,692
21,780
Accepted
Accepted
25.28
from itertools import combinations_with_replacement def main(): n, m, q = list(map(int, input().split())) qlist = [] for _ in range(q): qlist.append(tuple(map(int, input().split()))) nums = [i for i in range(1, m + 1)] alist = tuple(combinations_with_replacement(nums, n)) r =...
import sys read = sys.stdin.read readlines = sys.stdin.readlines from itertools import combinations_with_replacement def main(): n, m, q = list(map(int, input().split())) abcd = [] for _ in range(q): q = tuple(map(int, input().split())) abcd.append(q) c1 = tuple(combinations_wi...
26
25
640
624
from itertools import combinations_with_replacement def main(): n, m, q = list(map(int, input().split())) qlist = [] for _ in range(q): qlist.append(tuple(map(int, input().split()))) nums = [i for i in range(1, m + 1)] alist = tuple(combinations_with_replacement(nums, n)) r = 0 for...
import sys read = sys.stdin.read readlines = sys.stdin.readlines from itertools import combinations_with_replacement def main(): n, m, q = list(map(int, input().split())) abcd = [] for _ in range(q): q = tuple(map(int, input().split())) abcd.append(q) c1 = tuple(combinations_with_repl...
false
3.846154
[ "+import sys", "+", "+read = sys.stdin.read", "+readlines = sys.stdin.readlines", "- qlist = []", "+ abcd = []", "- qlist.append(tuple(map(int, input().split())))", "- nums = [i for i in range(1, m + 1)]", "- alist = tuple(combinations_with_replacement(nums, n))", "+ q = ...
false
0.068639
0.06725
1.020649
[ "s383977486", "s520755674" ]
u784022244
p02984
python
s347663416
s562936259
213
145
14,092
14,028
Accepted
Accepted
31.92
N=int(input()) #ダムに溜まった水 A=list(map(int, input().split())) """ + A[0]=B[0]//2+B[1]//2 - A[1]=B[1]//2+B[2]//2 + A[2]=B[2]//2+B[3]//2 ... + A[N-1]=B[N-1]//2+B[0]//2 #奇数番目 A[0]-A[1]+A[2]+....+A[N-1]=B[0] """ b_0=0 for i in range(N): if i%2==0: b_0+=A[i] else: b_0-=A[i] for i in ran...
N=int(eval(input())) A=list(map(int, input().split())) #ダムの水 #山ダム山ダム山ダム。。。。。 B=[0]*N A1=0 for i in range(N): if i%2==0: A1+=A[i] else: A1-=A[i] B[0]=A1 for i in range(1,N): B[i]=2*A[i-1]-B[i-1] print((*B))
31
14
451
238
N = int(input()) # ダムに溜まった水 A = list(map(int, input().split())) """ + A[0]=B[0]//2+B[1]//2 - A[1]=B[1]//2+B[2]//2 + A[2]=B[2]//2+B[3]//2 ... + A[N-1]=B[N-1]//2+B[0]//2 #奇数番目 A[0]-A[1]+A[2]+....+A[N-1]=B[0] """ b_0 = 0 for i in range(N): if i % 2 == 0: b_0 += A[i] else: b_0 -= A[i] for i in ran...
N = int(eval(input())) A = list(map(int, input().split())) # ダムの水 # 山ダム山ダム山ダム。。。。。 B = [0] * N A1 = 0 for i in range(N): if i % 2 == 0: A1 += A[i] else: A1 -= A[i] B[0] = A1 for i in range(1, N): B[i] = 2 * A[i - 1] - B[i - 1] print((*B))
false
54.83871
[ "-N = int(input())", "-# ダムに溜まった水", "-A = list(map(int, input().split()))", "-\"\"\"", "-+ A[0]=B[0]//2+B[1]//2", "-- A[1]=B[1]//2+B[2]//2", "-+ A[2]=B[2]//2+B[3]//2", "- ...", "-+ A[N-1]=B[N-1]//2+B[0]//2 #奇数番目", "-A[0]-A[1]+A[2]+....+A[N-1]=B[0]", "-\"\"\"", "-b_0 = 0", "+N = int(eval(inp...
false
0.037378
0.036399
1.026875
[ "s347663416", "s562936259" ]
u476604182
p02863
python
s596031697
s020600144
653
429
116,440
116,440
Accepted
Accepted
34.3
N, T = list(map(int, input().split())) ls = [] for i in range(N): a, b = list(map(int, input().split())) ls += [(a,b)] ls.sort(key=lambda x:x[0]) dp = [[0]*(T) for i in range(N+1)] for i in range(N): a,b = ls[i] for j in range(T-1, a-1, -1): dp[i+1][j] = max(dp[i][j], dp[i][j-a]+b) last = [...
N, T = list(map(int, input().split())) ls = [] for i in range(N): a, b = list(map(int, input().split())) ls += [(a,b)] ls.sort(key=lambda x:x[0]) t = [[0]*T for i in range(N+1)] for i in range(1,N+1): a, b = ls[i-1] for j in range(T): if j-a>=0: t[i][j] = max(t[i-1][j-a]+b,t[i-1][j]) last ...
25
20
496
471
N, T = list(map(int, input().split())) ls = [] for i in range(N): a, b = list(map(int, input().split())) ls += [(a, b)] ls.sort(key=lambda x: x[0]) dp = [[0] * (T) for i in range(N + 1)] for i in range(N): a, b = ls[i] for j in range(T - 1, a - 1, -1): dp[i + 1][j] = max(dp[i][j], dp[i][j - a] +...
N, T = list(map(int, input().split())) ls = [] for i in range(N): a, b = list(map(int, input().split())) ls += [(a, b)] ls.sort(key=lambda x: x[0]) t = [[0] * T for i in range(N + 1)] for i in range(1, N + 1): a, b = ls[i - 1] for j in range(T): if j - a >= 0: t[i][j] = max(t[i - 1][...
false
20
[ "-dp = [[0] * (T) for i in range(N + 1)]", "-for i in range(N):", "- a, b = ls[i]", "- for j in range(T - 1, a - 1, -1):", "- dp[i + 1][j] = max(dp[i][j], dp[i][j - a] + b)", "-last = [0] * N", "-last[-1] = ls[-1][1]", "-for i in range(N - 2, -1, -1):", "- last[i] = max(last[i + 1], ...
false
0.042923
0.041089
1.044635
[ "s596031697", "s020600144" ]
u737758066
p02684
python
s521954741
s957045097
236
157
32,836
32,384
Accepted
Accepted
33.47
n, k = list(map(int, input().split())) a = list(map(int, input().split())) pos = 0 visit = [0]*n move = [] roop = [] while visit[pos] != 2: if visit[pos] == 0: move.append(pos) else: roop.append(pos) visit[pos] += 1 pos = a[pos] - 1 if len(move) > k: print((move[k]+1)...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) num = 1 li = [1] flag = [True]*n flag[0] = False for i in range(k): num = a[num-1] if flag[num-1]: li.append(num) flag[num-1] = False else: break d = li.index(num) ans = (k-d) % (len(li)-d)...
18
19
379
333
n, k = list(map(int, input().split())) a = list(map(int, input().split())) pos = 0 visit = [0] * n move = [] roop = [] while visit[pos] != 2: if visit[pos] == 0: move.append(pos) else: roop.append(pos) visit[pos] += 1 pos = a[pos] - 1 if len(move) > k: print((move[k] + 1)) else: ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) num = 1 li = [1] flag = [True] * n flag[0] = False for i in range(k): num = a[num - 1] if flag[num - 1]: li.append(num) flag[num - 1] = False else: break d = li.index(num) ans = (k - d) % (len(li) - d) + d pri...
false
5.263158
[ "-pos = 0", "-visit = [0] * n", "-move = []", "-roop = []", "-while visit[pos] != 2:", "- if visit[pos] == 0:", "- move.append(pos)", "+num = 1", "+li = [1]", "+flag = [True] * n", "+flag[0] = False", "+for i in range(k):", "+ num = a[num - 1]", "+ if flag[num - 1]:", "+ ...
false
0.038741
0.084106
0.460626
[ "s521954741", "s957045097" ]
u334712262
p02579
python
s639663326
s382974667
1,676
1,165
270,500
216,040
Accepted
Accepted
30.49
# -*- coding: utf-8 -*- 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, product, permutati...
# -*- coding: utf-8 -*- 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, product, permutati...
98
98
2,099
2,135
# -*- coding: utf-8 -*- 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, product, permutations from...
# -*- coding: utf-8 -*- 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, product, permutations from...
false
0
[ "+ T = 10**6", "- if (x, y) in memo:", "+ if (x * T + y) in memo:", "- memo[(x, y)] = c", "+ memo[x * T + y] = c", "- return -1 if tuple(D) not in memo else memo[D]", "+ return -1 if (D[0] * T + D[1]) not in memo else memo[D[0] * T + D[1]]" ]
false
0.03632
0.035369
1.026903
[ "s639663326", "s382974667" ]
u263830634
p03862
python
s902885021
s099522527
147
124
14,252
14,052
Accepted
Accepted
15.65
N, x = list(map(int, input().split())) a = list(map(int, input().split())) count = 0 for i in range(N-1): if a[i] + a[i+1] > x: if a[i+1] >= a[i] + a[i+1] - x: count += a[i] + a[i+1] - x a[i+1] -= a[i] + a[i+1] - x else: count += a[i] + a[i+1] - x ...
N, x = list(map(int, input().split())) A = list(map(int, input().split())) ans = 0 for i in range(1, N): a = A[i - 1] b = A[i] if a + b <= x: continue over = (a + b) - x ans += over A[i] = max(0, b - over) print (ans)
15
15
372
261
N, x = list(map(int, input().split())) a = list(map(int, input().split())) count = 0 for i in range(N - 1): if a[i] + a[i + 1] > x: if a[i + 1] >= a[i] + a[i + 1] - x: count += a[i] + a[i + 1] - x a[i + 1] -= a[i] + a[i + 1] - x else: count += a[i] + a[i + 1] - x ...
N, x = list(map(int, input().split())) A = list(map(int, input().split())) ans = 0 for i in range(1, N): a = A[i - 1] b = A[i] if a + b <= x: continue over = (a + b) - x ans += over A[i] = max(0, b - over) print(ans)
false
0
[ "-a = list(map(int, input().split()))", "-count = 0", "-for i in range(N - 1):", "- if a[i] + a[i + 1] > x:", "- if a[i + 1] >= a[i] + a[i + 1] - x:", "- count += a[i] + a[i + 1] - x", "- a[i + 1] -= a[i] + a[i + 1] - x", "- else:", "- count += a[i] ...
false
0.183969
0.053779
3.420826
[ "s902885021", "s099522527" ]
u327466606
p03460
python
s946538969
s555762203
1,673
1,451
176,652
78,820
Accepted
Accepted
13.27
N,K = list(map(int,input().split())) import numpy as np blacks = np.zeros((2*K,2*K), dtype=int) offset = 0 for _ in range(N): x,y,c = input().split() x,y = int(x),int(y) x %= 2*K y %= 2*K if c == 'B': blacks[x,y] += 1 else: blacks[x,y] -= 1 offset += 1 m = np.zeros((3*K,2*K...
N,K = list(map(int,input().split())) import numpy as np m = np.zeros((3*K,3*K), dtype=np.int32) offset = 0 for _ in range(N): x,y,c = input().split() x,y = int(x),int(y) x %= 2*K y %= 2*K if c == 'B': m[x,y] += 1 else: m[x,y] -= 1 offset += 1 K2 = 2*K m[K2:,:K2] = m[:K,:K2...
43
31
748
586
N, K = list(map(int, input().split())) import numpy as np blacks = np.zeros((2 * K, 2 * K), dtype=int) offset = 0 for _ in range(N): x, y, c = input().split() x, y = int(x), int(y) x %= 2 * K y %= 2 * K if c == "B": blacks[x, y] += 1 else: blacks[x, y] -= 1 offset += 1 m...
N, K = list(map(int, input().split())) import numpy as np m = np.zeros((3 * K, 3 * K), dtype=np.int32) offset = 0 for _ in range(N): x, y, c = input().split() x, y = int(x), int(y) x %= 2 * K y %= 2 * K if c == "B": m[x, y] += 1 else: m[x, y] -= 1 offset += 1 K2 = 2 * K ...
false
27.906977
[ "-blacks = np.zeros((2 * K, 2 * K), dtype=int)", "+m = np.zeros((3 * K, 3 * K), dtype=np.int32)", "- blacks[x, y] += 1", "+ m[x, y] += 1", "- blacks[x, y] -= 1", "+ m[x, y] -= 1", "-m = np.zeros((3 * K, 2 * K), dtype=int)", "-m[: 2 * K, :] = blacks", "-m[2 * K :, :] = bla...
false
0.204104
0.201327
1.013796
[ "s946538969", "s555762203" ]
u312025627
p02983
python
s762593477
s872363096
950
193
3,060
38,896
Accepted
Accepted
79.68
l, r = (int(i) for i in input().split()) ans = float('inf') for i in range(l,min(l+2019,r)): for j in range(i+1,min(i+1+2019,r+1)): val = i*j % 2019 if val < ans: ans = val print(ans)
def main(): L, R = (int(i) for i in input().split()) MOD = 2019 R = min(L + 2020, R) ans = 2020 for i in range(L, R): for j in range(i+1, R+1): # print(i, j) ans = min(ans, (i*j) % MOD) print(ans) if __name__ == '__main__': main()
8
14
222
306
l, r = (int(i) for i in input().split()) ans = float("inf") for i in range(l, min(l + 2019, r)): for j in range(i + 1, min(i + 1 + 2019, r + 1)): val = i * j % 2019 if val < ans: ans = val print(ans)
def main(): L, R = (int(i) for i in input().split()) MOD = 2019 R = min(L + 2020, R) ans = 2020 for i in range(L, R): for j in range(i + 1, R + 1): # print(i, j) ans = min(ans, (i * j) % MOD) print(ans) if __name__ == "__main__": main()
false
42.857143
[ "-l, r = (int(i) for i in input().split())", "-ans = float(\"inf\")", "-for i in range(l, min(l + 2019, r)):", "- for j in range(i + 1, min(i + 1 + 2019, r + 1)):", "- val = i * j % 2019", "- if val < ans:", "- ans = val", "-print(ans)", "+def main():", "+ L, R = (in...
false
0.058419
0.056079
1.041744
[ "s762593477", "s872363096" ]
u201234972
p03044
python
s698416740
s375697253
935
396
98,464
44,924
Accepted
Accepted
57.65
from collections import defaultdict, deque N = int( eval(input())) d = defaultdict( int) E = [ [] for _ in range(N)] for _ in range(N-1): u, v, w = list(map( int, input().split())) u = u-1 v = v-1 E[u].append(v) E[v].append(u) d[(u,v)] = w%2 d[(v,u)] = w%2 V = [-1]*N V[0] = 0 q...
import sys input = sys.stdin.readline from collections import deque def main(): N = int( eval(input())) E = [[] for _ in range(N)] for _ in range(N-1): u, v, w = list(map( int, input().split())) u -= 1 v -= 1 E[u].append((v,w)) E[v].append((u,w)) V = [...
24
26
508
609
from collections import defaultdict, deque N = int(eval(input())) d = defaultdict(int) E = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u = u - 1 v = v - 1 E[u].append(v) E[v].append(u) d[(u, v)] = w % 2 d[(v, u)] = w % 2 V = [-1] * N V[0] = 0 q = ...
import sys input = sys.stdin.readline from collections import deque def main(): N = int(eval(input())) E = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 E[u].append((v, w)) E[v].append((u, w)) V = [-1] * N...
false
7.692308
[ "-from collections import defaultdict, deque", "+import sys", "-N = int(eval(input()))", "-d = defaultdict(int)", "-E = [[] for _ in range(N)]", "-for _ in range(N - 1):", "- u, v, w = list(map(int, input().split()))", "- u = u - 1", "- v = v - 1", "- E[u].append(v)", "- E[v].appe...
false
0.066558
0.069066
0.963681
[ "s698416740", "s375697253" ]
u544587633
p02660
python
s908866268
s070748245
189
73
69,852
68,276
Accepted
Accepted
61.38
#!/usr/bin/env python3 import sys from functools import reduce import math def is_prime(n): if n % 2 == 0 and n > 2: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def sieve(n): n=int(n) # Create a b...
#!/usr/bin/env python3 import sys from functools import reduce import math from collections import defaultdict from math import sqrt def is_prime(n): for i in range(2, int(sqrt(n))): if n % i == 0: return False return True def prime_factors(n): primes = defaultdic...
119
64
2,835
1,377
#!/usr/bin/env python3 import sys from functools import reduce import math def is_prime(n): if n % 2 == 0 and n > 2: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def sieve(n): n = int(n) # Create a boolean array "pr...
#!/usr/bin/env python3 import sys from functools import reduce import math from collections import defaultdict from math import sqrt def is_prime(n): for i in range(2, int(sqrt(n))): if n % i == 0: return False return True def prime_factors(n): primes = defaultdict(int) i = 2 ...
false
46.218487
[ "+from collections import defaultdict", "+from math import sqrt", "- if n % 2 == 0 and n > 2:", "- return False", "- for i in range(3, int(math.sqrt(n)) + 1, 2):", "+ for i in range(2, int(sqrt(n))):", "-def sieve(n):", "- n = int(n)", "- # Create a boolean array \"prime[0..n]\...
false
0.258486
0.061977
4.170663
[ "s908866268", "s070748245" ]
u577170763
p02862
python
s981688325
s502660577
1,400
875
3,064
92,248
Accepted
Accepted
37.5
class Solution: def solve(self, x: int, y: int) -> int: if (2*x - y) % 3 != 0 or (-x + 2*y) % 3 != 0: return 0 m = (2*x - y) // 3 n = (-x + 2*y) // 3 if m < 0 or n < 0: return 0 # calculate {m+n}C{n} def egcd(a, b): ...
class MathUtil: # calculate {m+n}C{n} def egcd(self, a: int, b: int): if a == 0: return b, 0, 1 else: g, y, x = self.egcd(b % a, a) return g, x - (b // a) * y, y def modinv(self, a: int, m: int): g, x, y = self.egcd(a, m) if g !...
45
37
1,120
865
class Solution: def solve(self, x: int, y: int) -> int: if (2 * x - y) % 3 != 0 or (-x + 2 * y) % 3 != 0: return 0 m = (2 * x - y) // 3 n = (-x + 2 * y) // 3 if m < 0 or n < 0: return 0 # calculate {m+n}C{n} def egcd(a, b): if a == ...
class MathUtil: # calculate {m+n}C{n} def egcd(self, a: int, b: int): if a == 0: return b, 0, 1 else: g, y, x = self.egcd(b % a, a) return g, x - (b // a) * y, y def modinv(self, a: int, m: int): g, x, y = self.egcd(a, m) if g != 1: ...
false
17.777778
[ "-class Solution:", "- def solve(self, x: int, y: int) -> int:", "- if (2 * x - y) % 3 != 0 or (-x + 2 * y) % 3 != 0:", "- return 0", "- m = (2 * x - y) // 3", "- n = (-x + 2 * y) // 3", "- if m < 0 or n < 0:", "- return 0", "- # calculate ...
false
0.300615
0.28207
1.065744
[ "s981688325", "s502660577" ]
u077291787
p03330
python
s120577952
s735776901
125
86
5,356
5,356
Accepted
Accepted
31.2
# ABC099D - Good Grid import sys input = sys.stdin.readline from collections import defaultdict from itertools import product def main(): N, C = list(map(int, input().split())) D = [0] + list([0] + list(map(int, input().split())) for _ in range(C)) grid = tuple(tuple(map(int, input().split()))...
# ABC099D - Good Grid import sys input = sys.stdin.readline from collections import Counter from itertools import product def main(): N, C = list(map(int, input().split())) D = [0] + list([0] + list(map(int, input().split())) for _ in range(C)) grid = tuple(tuple(map(int, input().split())) for...
32
34
990
1,105
# ABC099D - Good Grid import sys input = sys.stdin.readline from collections import defaultdict from itertools import product def main(): N, C = list(map(int, input().split())) D = [0] + list([0] + list(map(int, input().split())) for _ in range(C)) grid = tuple(tuple(map(int, input().split())) for _ in r...
# ABC099D - Good Grid import sys input = sys.stdin.readline from collections import Counter from itertools import product def main(): N, C = list(map(int, input().split())) D = [0] + list([0] + list(map(int, input().split())) for _ in range(C)) grid = tuple(tuple(map(int, input().split())) for _ in range...
false
5.882353
[ "-from collections import defaultdict", "+from collections import Counter", "- cost = {i: defaultdict(int) for i in range(3)}", "- for i, g in enumerate(grid):", "- for j, x in enumerate(g):", "- cost[(i + j) % 3][x] += 1", "+ cost = [Counter() for _ in range(3)]", "+ for...
false
0.036521
0.066133
0.552234
[ "s120577952", "s735776901" ]
u135389999
p02767
python
s667484972
s100433717
321
18
21,644
3,060
Accepted
Accepted
94.39
import numpy as np import math n = int(eval(input())) x = list(map(int,input().split())) p1_sum = [] p2_sum = [] p1 = math.floor((1/n) * sum(x)) p2 = math.ceil((1/n) * sum(x)) for i in x: p1_sum.append((p1 - i)** 2) p2_sum.append((p2 - i)** 2) print((min(sum(p1_sum),sum(p2_sum))))
n = int(eval(input())) x = list(map(int,input().split())) p = round((1/n) * sum(x)) ans = 0 for i in x: ans += (p -i) ** 2 print(ans)
17
9
302
141
import numpy as np import math n = int(eval(input())) x = list(map(int, input().split())) p1_sum = [] p2_sum = [] p1 = math.floor((1 / n) * sum(x)) p2 = math.ceil((1 / n) * sum(x)) for i in x: p1_sum.append((p1 - i) ** 2) p2_sum.append((p2 - i) ** 2) print((min(sum(p1_sum), sum(p2_sum))))
n = int(eval(input())) x = list(map(int, input().split())) p = round((1 / n) * sum(x)) ans = 0 for i in x: ans += (p - i) ** 2 print(ans)
false
47.058824
[ "-import numpy as np", "-import math", "-", "-p1_sum = []", "-p2_sum = []", "-p1 = math.floor((1 / n) * sum(x))", "-p2 = math.ceil((1 / n) * sum(x))", "+p = round((1 / n) * sum(x))", "+ans = 0", "- p1_sum.append((p1 - i) ** 2)", "- p2_sum.append((p2 - i) ** 2)", "-print((min(sum(p1_sum),...
false
0.035306
0.035357
0.99856
[ "s667484972", "s100433717" ]
u644907318
p02891
python
s520245543
s216629543
183
61
38,512
62,036
Accepted
Accepted
66.67
def f(k): T = S*k N = len(T) cur = T[0] cnt = 1 ans = 0 for i in range(1,N): if T[i]==cur: cnt += 1 else: ans += cnt//2 cur = T[i] cnt = 1 ans += cnt//2 return ans S = input().strip() K = int(eval(input())) ...
C = {} S = input().strip() N = len(S) K = int(eval(input())) for i in range(N): s = S[i] if s not in C: C[s]=0 C[s] += 1 if len(C)>1: a = 0 cnt = 1 for i in range(1,N): if S[i]==S[i-1]: cnt += 1 else: a += cnt//2 cnt = ...
27
47
477
888
def f(k): T = S * k N = len(T) cur = T[0] cnt = 1 ans = 0 for i in range(1, N): if T[i] == cur: cnt += 1 else: ans += cnt // 2 cur = T[i] cnt = 1 ans += cnt // 2 return ans S = input().strip() K = int(eval(input())) ans1 =...
C = {} S = input().strip() N = len(S) K = int(eval(input())) for i in range(N): s = S[i] if s not in C: C[s] = 0 C[s] += 1 if len(C) > 1: a = 0 cnt = 1 for i in range(1, N): if S[i] == S[i - 1]: cnt += 1 else: a += cnt // 2 cnt = 1 ...
false
42.553191
[ "-def f(k):", "- T = S * k", "- N = len(T)", "- cur = T[0]", "+C = {}", "+S = input().strip()", "+N = len(S)", "+K = int(eval(input()))", "+for i in range(N):", "+ s = S[i]", "+ if s not in C:", "+ C[s] = 0", "+ C[s] += 1", "+if len(C) > 1:", "+ a = 0", "- ...
false
0.035878
0.035676
1.005653
[ "s520245543", "s216629543" ]
u700805562
p03163
python
s606172725
s276973849
446
234
119,916
149,288
Accepted
Accepted
47.53
n, w = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(n)] dp = [[0]*(w+1) for _ in range(n+1)] for i in range(n): w_, v_ = wv[i] for j in range(w+1): if j < w_: dp[i+1][j] = dp[i][j] else: dp[i+1][j] = max(dp[i][j-w_]+v_, dp[...
N, W = list(map(int, input().split())) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): w, v = list(map(int, input().split())) for j in range(1, W+1): if j<w: dp[i+1][j] = dp[i][j] if w<=j: dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v) print((dp[-1][-1]))
11
10
337
300
n, w = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(n)] dp = [[0] * (w + 1) for _ in range(n + 1)] for i in range(n): w_, v_ = wv[i] for j in range(w + 1): if j < w_: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = max(dp[i][j - w_] + ...
N, W = list(map(int, input().split())) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(N): w, v = list(map(int, input().split())) for j in range(1, W + 1): if j < w: dp[i + 1][j] = dp[i][j] if w <= j: dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v) print((dp[-1][...
false
9.090909
[ "-n, w = list(map(int, input().split()))", "-wv = [list(map(int, input().split())) for _ in range(n)]", "-dp = [[0] * (w + 1) for _ in range(n + 1)]", "-for i in range(n):", "- w_, v_ = wv[i]", "- for j in range(w + 1):", "- if j < w_:", "+N, W = list(map(int, input().split()))", "+dp =...
false
0.055219
0.059064
0.934902
[ "s606172725", "s276973849" ]
u729133443
p02702
python
s292000350
s035102469
321
134
80,128
9,220
Accepted
Accepted
58.26
M=2019 a=i=0 d=[0]*M p=1 for j in'0'+input()[::-1]:i=(i+int(j)*p)%M;p=p*10%M;a+=d[i];d[i]+=1 print(a)
M=2019 a=i=0 d=[0]*M p=1 for j in input()[::-1]:d[i%M]+=1;i-=int(j)*p;a+=d[i%M];p=p*10%M print(a)
6
6
106
102
M = 2019 a = i = 0 d = [0] * M p = 1 for j in "0" + input()[::-1]: i = (i + int(j) * p) % M p = p * 10 % M a += d[i] d[i] += 1 print(a)
M = 2019 a = i = 0 d = [0] * M p = 1 for j in input()[::-1]: d[i % M] += 1 i -= int(j) * p a += d[i % M] p = p * 10 % M print(a)
false
0
[ "-for j in \"0\" + input()[::-1]:", "- i = (i + int(j) * p) % M", "+for j in input()[::-1]:", "+ d[i % M] += 1", "+ i -= int(j) * p", "+ a += d[i % M]", "- a += d[i]", "- d[i] += 1" ]
false
0.034702
0.034055
1.019001
[ "s292000350", "s035102469" ]
u141610915
p03086
python
s359887568
s460955565
165
63
38,384
62,164
Accepted
Accepted
61.82
S = eval(input()) res = 0 temp = 0 for i in range(len(S)): if S[i] in ["A", "T", "C", "G"]: temp += 1 res = max(temp, res) else: temp = 0 print(res)
import sys input = sys.stdin.readline S = list(eval(input()))[: -1] res = 0 for l in range(len(S)): for r in range(l + 1, len(S) + 1): for i in range(l, r): if not S[i] in ["A", "T", "C", "G"]: break else: res = max(res, r - l) print(res)
10
10
167
257
S = eval(input()) res = 0 temp = 0 for i in range(len(S)): if S[i] in ["A", "T", "C", "G"]: temp += 1 res = max(temp, res) else: temp = 0 print(res)
import sys input = sys.stdin.readline S = list(eval(input()))[:-1] res = 0 for l in range(len(S)): for r in range(l + 1, len(S) + 1): for i in range(l, r): if not S[i] in ["A", "T", "C", "G"]: break else: res = max(res, r - l) print(res)
false
0
[ "-S = eval(input())", "+import sys", "+", "+input = sys.stdin.readline", "+S = list(eval(input()))[:-1]", "-temp = 0", "-for i in range(len(S)):", "- if S[i] in [\"A\", \"T\", \"C\", \"G\"]:", "- temp += 1", "- res = max(temp, res)", "- else:", "- temp = 0", "+for ...
false
0.034549
0.044076
0.783861
[ "s359887568", "s460955565" ]
u094999522
p02735
python
s624126908
s111064958
491
39
9,524
9,328
Accepted
Accepted
92.06
#!/usr/bin/env python3 from collections import deque h, w = list(map(int, input().split())) maze = [[i == "#" for i in eval(input())] for _ in range(h)] dx = [1, 0] dy = [0, 1] que = deque([]) que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0)) count = [[h + w] * w for _ in range(h)] while que: ...
h, w = list(map(int, input().split())) s = [[i == "#" for i in eval(input())] for _ in range(h)] dp = [[10**9] * w for _ in range(h)] dp[0][0] = int(s[0][0]) for i in range(h): for j in range(w): a = dp[i - 1][j] + (not s[i - 1][j] and s[i][j]) b = dp[i][j - 1] + (not s[i][j -1] and s[i][j]) ...
28
10
695
366
#!/usr/bin/env python3 from collections import deque h, w = list(map(int, input().split())) maze = [[i == "#" for i in eval(input())] for _ in range(h)] dx = [1, 0] dy = [0, 1] que = deque([]) que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0)) count = [[h + w] * w for _ in range(h)] while que: x, y, b, c = que...
h, w = list(map(int, input().split())) s = [[i == "#" for i in eval(input())] for _ in range(h)] dp = [[10**9] * w for _ in range(h)] dp[0][0] = int(s[0][0]) for i in range(h): for j in range(w): a = dp[i - 1][j] + (not s[i - 1][j] and s[i][j]) b = dp[i][j - 1] + (not s[i][j - 1] and s[i][j]) ...
false
64.285714
[ "-#!/usr/bin/env python3", "-from collections import deque", "-", "-maze = [[i == \"#\" for i in eval(input())] for _ in range(h)]", "-dx = [1, 0]", "-dy = [0, 1]", "-que = deque([])", "-que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0))", "-count = [[h + w] * w for _ in range(h)]", "-while qu...
false
0.081845
0.044066
1.857323
[ "s624126908", "s111064958" ]
u562935282
p03037
python
s240583496
s527492720
536
308
43,608
10,996
Accepted
Accepted
42.54
N, M = list(map(int, input().split())) left = 1 right = N # 1-indexed # [left, right] for _ in range(M): L, R = list(map(int, input().split())) if L > left: left = L if R < right: right = R if right - left + 1 <= 0: break print((max(0, right - left + 1)))
n, m = list(map(int, input().split())) l, r = [], [] for _ in range(m): ll, rr = list(map(int, input().split())) l.append(ll) r.append(rr) print((max(0, min(r) - max(l) + 1)))
16
9
299
184
N, M = list(map(int, input().split())) left = 1 right = N # 1-indexed # [left, right] for _ in range(M): L, R = list(map(int, input().split())) if L > left: left = L if R < right: right = R if right - left + 1 <= 0: break print((max(0, right - left + 1)))
n, m = list(map(int, input().split())) l, r = [], [] for _ in range(m): ll, rr = list(map(int, input().split())) l.append(ll) r.append(rr) print((max(0, min(r) - max(l) + 1)))
false
43.75
[ "-N, M = list(map(int, input().split()))", "-left = 1", "-right = N", "-# 1-indexed", "-# [left, right]", "-for _ in range(M):", "- L, R = list(map(int, input().split()))", "- if L > left:", "- left = L", "- if R < right:", "- right = R", "- if right - left + 1 <= 0:"...
false
0.083608
0.042413
1.9713
[ "s240583496", "s527492720" ]
u816631826
p02699
python
s955098602
s292633448
64
26
61,792
9,004
Accepted
Accepted
59.38
a, b=[int(yy) for yy in input().split()] if b>=a: print('unsafe') else: print("safe")
S, W = [int(x) for x in input().split()] if W >= S: print('unsafe') else: print('safe')
5
5
92
99
a, b = [int(yy) for yy in input().split()] if b >= a: print("unsafe") else: print("safe")
S, W = [int(x) for x in input().split()] if W >= S: print("unsafe") else: print("safe")
false
0
[ "-a, b = [int(yy) for yy in input().split()]", "-if b >= a:", "+S, W = [int(x) for x in input().split()]", "+if W >= S:" ]
false
0.073506
0.087335
0.841658
[ "s955098602", "s292633448" ]
u937642029
p02683
python
s887343531
s036307963
73
61
10,896
9,240
Accepted
Accepted
16.44
import sys, bisect, math, itertools, string, queue, copy # import numpy as np # import scipy from collections import Counter,defaultdict,deque from itertools import permutations, combinations from heapq import heappop, heappush from fractions import gcd # input = sys.stdin.readline sys.setrecursionlimit(10**8) ...
import sys from itertools import combinations input = sys.stdin.readline def main(): n,m,x = list(map(int,input().split())) c = [list(map(int,input().split())) for _ in range(n)] ans = float('inf') for num in range(1,n+1): for e in combinations(list(range(n)),num): cost = ...
42
26
1,429
688
import sys, bisect, math, itertools, string, queue, copy # import numpy as np # import scipy from collections import Counter, defaultdict, deque from itertools import permutations, combinations from heapq import heappop, heappush from fractions import gcd # input = sys.stdin.readline sys.setrecursionlimit(10**8) mod ...
import sys from itertools import combinations input = sys.stdin.readline def main(): n, m, x = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(n)] ans = float("inf") for num in range(1, n + 1): for e in combinations(list(range(n)), num): cost = ...
false
38.095238
[ "-import sys, bisect, math, itertools, string, queue, copy", "+import sys", "+from itertools import combinations", "-# import numpy as np", "-# import scipy", "-from collections import Counter, defaultdict, deque", "-from itertools import permutations, combinations", "-from heapq import heappop, heapp...
false
0.035806
0.038887
0.920764
[ "s887343531", "s036307963" ]
u201234972
p03309
python
s567352018
s036016346
787
229
49,520
36,780
Accepted
Accepted
70.9
from statistics import median import math N = int(eval(input())) *A, = list(map(int, input().split())) B = [A[i]-i for i in range(N)] b = median(B) bm = math.floor(b) K = [x - bm for x in B] KZ = [abs(x) for x in K] Z = sum(KZ) for i in range(20): C = [abs(x-i+10) for x in K] Z = min([sum(C),Z]) pr...
from statistics import median import math N = int(eval(input())) *A, = list(map(int, input().split())) B = [A[i]-i for i in range(N)] b = median(B) bm = math.floor(b) bM = math.ceil(b) Bm = [abs(x - bm) for x in B] BM = [abs(x - bM) for x in B] m = sum(Bm) M = sum(BM) print((int(min([m,M]))))
14
13
319
291
from statistics import median import math N = int(eval(input())) (*A,) = list(map(int, input().split())) B = [A[i] - i for i in range(N)] b = median(B) bm = math.floor(b) K = [x - bm for x in B] KZ = [abs(x) for x in K] Z = sum(KZ) for i in range(20): C = [abs(x - i + 10) for x in K] Z = min([sum(C), Z]) print...
from statistics import median import math N = int(eval(input())) (*A,) = list(map(int, input().split())) B = [A[i] - i for i in range(N)] b = median(B) bm = math.floor(b) bM = math.ceil(b) Bm = [abs(x - bm) for x in B] BM = [abs(x - bM) for x in B] m = sum(Bm) M = sum(BM) print((int(min([m, M]))))
false
7.142857
[ "-K = [x - bm for x in B]", "-KZ = [abs(x) for x in K]", "-Z = sum(KZ)", "-for i in range(20):", "- C = [abs(x - i + 10) for x in K]", "- Z = min([sum(C), Z])", "-print((int(Z)))", "+bM = math.ceil(b)", "+Bm = [abs(x - bm) for x in B]", "+BM = [abs(x - bM) for x in B]", "+m = sum(Bm)", "...
false
0.147121
0.10767
1.366399
[ "s567352018", "s036016346" ]
u546285759
p00047
python
s647334521
s317779781
30
20
7,396
7,376
Accepted
Accepted
33.33
cup= [True, False, False] while True: try: p= list(map(str, input().split(','))) except: break x, y= sorted(p) if x=='A' and y=='B': cup[0], cup[1]= cup[1], cup[0] elif x=='A' and y=='C': cup[0], cup[2]= cup[2], cup[0] elif x=='B' and y=='C': c...
cup = {"A": 1, "B": 0, "C": 0} while True: try: x, y = input().split(",") except: break cup[x], cup[y] = cup[y], cup[x] for k, v in list(cup.items()): if v: print(k)
17
11
455
210
cup = [True, False, False] while True: try: p = list(map(str, input().split(","))) except: break x, y = sorted(p) if x == "A" and y == "B": cup[0], cup[1] = cup[1], cup[0] elif x == "A" and y == "C": cup[0], cup[2] = cup[2], cup[0] elif x == "B" and y == "C": ...
cup = {"A": 1, "B": 0, "C": 0} while True: try: x, y = input().split(",") except: break cup[x], cup[y] = cup[y], cup[x] for k, v in list(cup.items()): if v: print(k)
false
35.294118
[ "-cup = [True, False, False]", "+cup = {\"A\": 1, \"B\": 0, \"C\": 0}", "- p = list(map(str, input().split(\",\")))", "+ x, y = input().split(\",\")", "- x, y = sorted(p)", "- if x == \"A\" and y == \"B\":", "- cup[0], cup[1] = cup[1], cup[0]", "- elif x == \"A\" and y ==...
false
0.008526
0.044542
0.19142
[ "s647334521", "s317779781" ]
u394721319
p03294
python
s249859899
s623417146
171
28
38,896
9,360
Accepted
Accepted
83.63
N = int(eval(input())) A = [int(zz) for zz in input().split()] print((sum(A)-N))
N = int(eval(input())) print((sum([int(i)-1 for i in input().split()])))
4
2
77
66
N = int(eval(input())) A = [int(zz) for zz in input().split()] print((sum(A) - N))
N = int(eval(input())) print((sum([int(i) - 1 for i in input().split()])))
false
50
[ "-A = [int(zz) for zz in input().split()]", "-print((sum(A) - N))", "+print((sum([int(i) - 1 for i in input().split()])))" ]
false
0.03438
0.039421
0.872133
[ "s249859899", "s623417146" ]
u753803401
p02972
python
s042067912
s618552410
606
535
14,060
14,096
Accepted
Accepted
11.72
n = int(eval(input())) a = list(map(int, input().split())) b = [0] * (n + 1) ls = [] for i in range(n, 0, -1): cnt = 0 for j in range(i, n + 1, i): cnt += b[j] if a[i-1] != cnt % 2: b[i] = 1 ls.append(i) print((len(ls))) if len(ls) != 0: print((*ls))
n = int(eval(input())) a = list(map(int, input().split())) ls = [0] * n ans = [] for i in range(n-1, -1, -1): t = 0 for j in range(i, n, (i + 1)): t += ls[j] if a[i] != t % 2: ans.append(i + 1) ls[i] = 1 print((len(ans))) if len(ans) != 0: print((*ans))
14
14
294
297
n = int(eval(input())) a = list(map(int, input().split())) b = [0] * (n + 1) ls = [] for i in range(n, 0, -1): cnt = 0 for j in range(i, n + 1, i): cnt += b[j] if a[i - 1] != cnt % 2: b[i] = 1 ls.append(i) print((len(ls))) if len(ls) != 0: print((*ls))
n = int(eval(input())) a = list(map(int, input().split())) ls = [0] * n ans = [] for i in range(n - 1, -1, -1): t = 0 for j in range(i, n, (i + 1)): t += ls[j] if a[i] != t % 2: ans.append(i + 1) ls[i] = 1 print((len(ans))) if len(ans) != 0: print((*ans))
false
0
[ "-b = [0] * (n + 1)", "-ls = []", "-for i in range(n, 0, -1):", "- cnt = 0", "- for j in range(i, n + 1, i):", "- cnt += b[j]", "- if a[i - 1] != cnt % 2:", "- b[i] = 1", "- ls.append(i)", "-print((len(ls)))", "-if len(ls) != 0:", "- print((*ls))", "+ls = [0]...
false
0.040942
0.044858
0.912704
[ "s042067912", "s618552410" ]
u577170763
p03163
python
s286617195
s969254521
374
276
82,116
117,488
Accepted
Accepted
26.2
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) N, W = geta(int) cur = [0] * (W+1) for i in range(N): w, v = geta(int) update =...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) def main(): N, W = geta(int) cur = [0] * (W+1) for i in range(N): w, ...
22
25
461
557
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) N, W = geta(int) cur = [0] * (W + 1) for i in range(N): w, v = geta(int) update = cur[:] for...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) def main(): N, W = geta(int) cur = [0] * (W + 1) for i in range(N): w, v = geta(in...
false
12
[ "-N, W = geta(int)", "-cur = [0] * (W + 1)", "-for i in range(N):", "- w, v = geta(int)", "- update = cur[:]", "- for j in range(w, W + 1):", "- tmp = cur[j - w] + v", "- if tmp > cur[j]:", "- update[j] = tmp", "- cur = update", "-print((cur[W]))", "+", "...
false
0.045072
0.043785
1.029392
[ "s286617195", "s969254521" ]
u600402037
p02949
python
s329659483
s373256405
1,024
746
44,060
42,940
Accepted
Accepted
27.15
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M, P = lr() # 終了時、T*P枚支払う graph = [lr() for _ in range(M)] def bellmanford(start, N): INF = 10 ** 12 dist = [-INF] * (N+1) # 1-indexed dist[start] = 0 for i in range...
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M, P = lr() # 終了時、T*P枚支払う graph = [tuple(lr()) for _ in range(M)] def bellmanford(start, N): INF = 10 ** 12 dist = [-INF] * (N+1) # 1-indexed dist[start] = 0 for i i...
28
28
727
734
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M, P = lr() # 終了時、T*P枚支払う graph = [lr() for _ in range(M)] def bellmanford(start, N): INF = 10**12 dist = [-INF] * (N + 1) # 1-indexed dist[start] = 0 for i in range(N + N + 5): ...
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M, P = lr() # 終了時、T*P枚支払う graph = [tuple(lr()) for _ in range(M)] def bellmanford(start, N): INF = 10**12 dist = [-INF] * (N + 1) # 1-indexed dist[start] = 0 for i in range(N + N...
false
0
[ "-graph = [lr() for _ in range(M)]", "+graph = [tuple(lr()) for _ in range(M)]" ]
false
0.035281
0.035218
1.001768
[ "s329659483", "s373256405" ]
u257050137
p03337
python
s152630822
s269973707
20
17
3,188
2,940
Accepted
Accepted
15
a, b = list(map(int, input().split(' '))) print((max(a+b, a-b, a*b)))
a, b = list(map(int, input().split())) print((max(a + b, a - b, a * b)))
2
2
63
65
a, b = list(map(int, input().split(" "))) print((max(a + b, a - b, a * b)))
a, b = list(map(int, input().split())) print((max(a + b, a - b, a * b)))
false
0
[ "-a, b = list(map(int, input().split(\" \")))", "+a, b = list(map(int, input().split()))" ]
false
0.041799
0.046139
0.905925
[ "s152630822", "s269973707" ]
u875291233
p03108
python
s750628544
s003527810
807
560
27,140
24,784
Accepted
Accepted
30.61
class UnionFind: def __init__(self, size): self.parent = [-1]*size#非負なら親ノード,負ならグループの要素数 def root(self, x): #root(x): xの根ノードを返す. if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ return self.parent[x...
import sys class UnionFind: def __init__(self, size): self.parent = [-1 for i in range(size)]#非負なら親ノード,負ならグループの要素数 def root(self, x): #root(x): xの根ノードを返す. if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ ...
61
57
1,390
1,404
class UnionFind: def __init__(self, size): self.parent = [-1] * size # 非負なら親ノード,負ならグループの要素数 def root(self, x): # root(x): xの根ノードを返す. if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) # xをxの根に直接つなぐ return self.parent[x...
import sys class UnionFind: def __init__(self, size): self.parent = [-1 for i in range(size)] # 非負なら親ノード,負ならグループの要素数 def root(self, x): # root(x): xの根ノードを返す. if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) # xをxの根に直接つなぐ ...
false
6.557377
[ "+import sys", "+", "+", "- self.parent = [-1] * size # 非負なら親ノード,負ならグループの要素数", "+ self.parent = [-1 for i in range(size)] # 非負なら親ノード,負ならグループの要素数", "-n, m = [int(i) for i in input().split()]", "-A = [[int(i) - 1 for i in input().split()] for _ in range(m)]", "-ans = [0] * (m + 1)", "-...
false
0.077486
0.041035
1.888286
[ "s750628544", "s003527810" ]
u671060652
p03244
python
s311739374
s551706295
653
104
94,312
99,736
Accepted
Accepted
84.07
import itertools import math import fractions import functools import copy n = int(eval(input())) v = list(map(int, input().split())) kisu = [0]*(10**6) gusu = [0]*(10**6) for i in range(n): if i % 2 == 0: gusu[v[i]] += 1 else: kisu[v[i]] += 1 count = 0 gusu_m = gusu.index(m...
n = int(eval(input())) v = list(map(int, input().split())) kisu = [0]*(10**6) gusu = [0]*(10**6) for i in range(n): if i % 2 == 0: gusu[v[i]] += 1 else: kisu[v[i]] += 1 count = 0 gusu_m = gusu.index(max(gusu)) kisu_m = kisu.index(max(kisu)) if gusu_m == kisu_m: gusu[gu...
37
32
704
624
import itertools import math import fractions import functools import copy n = int(eval(input())) v = list(map(int, input().split())) kisu = [0] * (10**6) gusu = [0] * (10**6) for i in range(n): if i % 2 == 0: gusu[v[i]] += 1 else: kisu[v[i]] += 1 count = 0 gusu_m = gusu.index(max(gusu)) kisu_m...
n = int(eval(input())) v = list(map(int, input().split())) kisu = [0] * (10**6) gusu = [0] * (10**6) for i in range(n): if i % 2 == 0: gusu[v[i]] += 1 else: kisu[v[i]] += 1 count = 0 gusu_m = gusu.index(max(gusu)) kisu_m = kisu.index(max(kisu)) if gusu_m == kisu_m: gusu[gusu_m] = 0 kisu[...
false
13.513514
[ "-import itertools", "-import math", "-import fractions", "-import functools", "-import copy", "-" ]
false
0.143445
0.359382
0.399143
[ "s311739374", "s551706295" ]
u693378622
p02804
python
s060135311
s733429048
461
280
34,972
26,660
Accepted
Accepted
39.26
import numpy as np mod = 10 ** 9 + 7 def f(n,k): ans = 1 for i in range(k): ans = ans * n % mod n -= 1 return ans def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p fact = [1, 1] # f...
mod = 10 ** 9 + 7 def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, 1] # factinv 計算用 p = mod for i in range(2, 10**5 + 1):...
52
30
1,050
736
import numpy as np mod = 10**9 + 7 def f(n, k): ans = 1 for i in range(k): ans = ans * n % mod n -= 1 return ans def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n - r] % p fact = [1, 1] # fact[n] = (n! mod ...
mod = 10**9 + 7 def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n - r] % p fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, 1] # factinv 計算用 p = mod for i in range(2, 10**5 + 1): fact...
false
42.307692
[ "-import numpy as np", "-", "-", "-", "-def f(n, k):", "- ans = 1", "- for i in range(k):", "- ans = ans * n % mod", "- n -= 1", "- return ans", "-# print( cmb(4, 2, mod) )", "-sum = 0", "+ans = 0", "- k = A[i] * t % mod", "- # print(A[i], t, k)", "- sum...
false
0.259099
0.474725
0.545789
[ "s060135311", "s733429048" ]
u417309772
p04046
python
s169528854
s965975403
1,193
832
16,920
24,808
Accepted
Accepted
30.26
from math import comb h,w,a,b = list(map(int,input().split())) s = 0 nC = b-1 kC = 0 nD = w-b-1+h-1 kD = h-1 p = 1000000007 fac = [1] ff = 1 for i in range(1,200001): ff *= i ff %= p fac.append(ff) def ncr(n, r, p): return (fac[n] * pow(fac[r], p-2, p) % p * pow(fac[n-r], p-2, p) % p); for i ...
P = 10**9+7 fac = [1] ifac = [1] ff = 1 for i in range(1,200001): ff *= i ff %= P fac.append(ff) ifac.append(pow(ff, P-2, P)) def ncr(n, r): return (fac[n] * ifac[r] % P * ifac[n-r] % P); h,w,a,b = list(map(int,input().split())) s = 0 nC = b-1 kC = 0 nD = w-b-1+h-1 kD = h-1 for i in range(...
26
27
477
435
from math import comb h, w, a, b = list(map(int, input().split())) s = 0 nC = b - 1 kC = 0 nD = w - b - 1 + h - 1 kD = h - 1 p = 1000000007 fac = [1] ff = 1 for i in range(1, 200001): ff *= i ff %= p fac.append(ff) def ncr(n, r, p): return fac[n] * pow(fac[r], p - 2, p) % p * pow(fac[n - r], p - 2, p...
P = 10**9 + 7 fac = [1] ifac = [1] ff = 1 for i in range(1, 200001): ff *= i ff %= P fac.append(ff) ifac.append(pow(ff, P - 2, P)) def ncr(n, r): return fac[n] * ifac[r] % P * ifac[n - r] % P h, w, a, b = list(map(int, input().split())) s = 0 nC = b - 1 kC = 0 nD = w - b - 1 + h - 1 kD = h - 1 f...
false
3.703704
[ "-from math import comb", "+P = 10**9 + 7", "+fac = [1]", "+ifac = [1]", "+ff = 1", "+for i in range(1, 200001):", "+ ff *= i", "+ ff %= P", "+ fac.append(ff)", "+ ifac.append(pow(ff, P - 2, P))", "+", "+", "+def ncr(n, r):", "+ return fac[n] * ifac[r] % P * ifac[n - r] % P"...
false
0.007911
1.558434
0.005076
[ "s169528854", "s965975403" ]
u729133443
p03035
python
s388332559
s309252970
181
29
38,256
8,972
Accepted
Accepted
83.98
a,b=list(map(int,input().split()));print((b//-~(a<13)*(a>5)))
a,b=list(map(int,input().split())) print(((b>>(a<13))*(a>5)))
1
2
53
54
a, b = list(map(int, input().split())) print((b // -~(a < 13) * (a > 5)))
a, b = list(map(int, input().split())) print(((b >> (a < 13)) * (a > 5)))
false
50
[ "-print((b // -~(a < 13) * (a > 5)))", "+print(((b >> (a < 13)) * (a > 5)))" ]
false
0.05417
0.047208
1.147475
[ "s388332559", "s309252970" ]
u261103969
p02792
python
s235917707
s030970033
301
91
3,064
73,660
Accepted
Accepted
69.77
n = int(eval(input())) dp = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, n+1): top = int(str(i)[0]) end = int(str(i)[-1]) ans += 2 * dp[end][top] if top == end: ans += 1 dp[top][end] += 1 print(ans)
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): N = int(readline()) dp = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, N + 1): s = str(i) first = int(s[0]) second = int(s[-1]) ...
13
30
245
508
n = int(eval(input())) dp = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, n + 1): top = int(str(i)[0]) end = int(str(i)[-1]) ans += 2 * dp[end][top] if top == end: ans += 1 dp[top][end] += 1 print(ans)
import sys readline = sys.stdin.readline MOD = 10**9 + 7 INF = float("INF") sys.setrecursionlimit(10**5) def main(): N = int(readline()) dp = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, N + 1): s = str(i) first = int(s[0]) second = int(s[-1]) ans += 2 * dp[...
false
56.666667
[ "-n = int(eval(input()))", "-dp = [[0] * 10 for _ in range(10)]", "-ans = 0", "-for i in range(1, n + 1):", "- top = int(str(i)[0])", "- end = int(str(i)[-1])", "- ans += 2 * dp[end][top]", "- if top == end:", "- ans += 1", "- dp[top][end] += 1", "-print(ans)", "+import s...
false
0.083356
0.130096
0.64073
[ "s235917707", "s030970033" ]
u863442865
p02861
python
s083111871
s706666552
209
161
40,048
38,256
Accepted
Accepted
22.97
''' https://atcoder.jp/contests/abc145/tasks/abc145_c ''' def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools ...
def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools import accumulate, product from math import floor, ceil ...
30
23
819
662
""" https://atcoder.jp/contests/abc145/tasks/abc145_c """ def main(): import sys # input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations # from itertools im...
def main(): import sys # input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations # from itertools import accumulate, product from math import floor, ceil ...
false
23.333333
[ "-\"\"\"", "-https://atcoder.jp/contests/abc145/tasks/abc145_c", "-\"\"\"", "-", "-", "- grid = [list(map(int, input().split())) for _ in range(N)]", "+ xy = [list(map(int, input().split())) for _ in range(N)]", "- for path in permutations(grid, N):", "- for i in range(N - 1):", "-...
false
0.052031
0.051155
1.017119
[ "s083111871", "s706666552" ]
u790710233
p02685
python
s177567087
s880601178
1,394
639
24,656
24,572
Accepted
Accepted
54.16
MOD = 998244353 n, m, k = list(map(int, input().split())) fact = [0]*(n+1) fact[0] = 1 for i in range(1, n+1): fact[i] = fact[i-1]*i % MOD invfact = [0]*(n+1) for i in range(n+1): invfact[i] = pow(fact[i], MOD-2, MOD) def nCk(n, k): return fact[n]*invfact[k]*invfact[n-k] ans = 0 for ...
MOD = 998244353 n, m, k = list(map(int, input().split())) fact = [0]*(n+1) fact[0] = 1 for i in range(1, n+1): fact[i] = fact[i-1]*i % MOD invfact = [0]*(n+1) invfact[n] = pow(fact[n], MOD-2, MOD) for i in reversed(list(range(n))): invfact[i] = invfact[i+1]*(i+1) % MOD def nCk(n, k): retu...
22
23
406
452
MOD = 998244353 n, m, k = list(map(int, input().split())) fact = [0] * (n + 1) fact[0] = 1 for i in range(1, n + 1): fact[i] = fact[i - 1] * i % MOD invfact = [0] * (n + 1) for i in range(n + 1): invfact[i] = pow(fact[i], MOD - 2, MOD) def nCk(n, k): return fact[n] * invfact[k] * invfact[n - k] ans = 0 ...
MOD = 998244353 n, m, k = list(map(int, input().split())) fact = [0] * (n + 1) fact[0] = 1 for i in range(1, n + 1): fact[i] = fact[i - 1] * i % MOD invfact = [0] * (n + 1) invfact[n] = pow(fact[n], MOD - 2, MOD) for i in reversed(list(range(n))): invfact[i] = invfact[i + 1] * (i + 1) % MOD def nCk(n, k): ...
false
4.347826
[ "-for i in range(n + 1):", "- invfact[i] = pow(fact[i], MOD - 2, MOD)", "+invfact[n] = pow(fact[n], MOD - 2, MOD)", "+for i in reversed(list(range(n))):", "+ invfact[i] = invfact[i + 1] * (i + 1) % MOD" ]
false
0.13406
0.107361
1.248683
[ "s177567087", "s880601178" ]
u135331079
p02701
python
s849207051
s798802198
319
286
35,236
30,980
Accepted
Accepted
10.34
N = int(eval(input())) D = dict() for i in range(N): S = eval(input()) if S not in list(D.keys()): D[S] = 1 D[S] += 1 print((len(D)))
n = int(eval(input())) s = set() for i in range(n): s.add(eval(input())) print((len(s)))
9
6
142
84
N = int(eval(input())) D = dict() for i in range(N): S = eval(input()) if S not in list(D.keys()): D[S] = 1 D[S] += 1 print((len(D)))
n = int(eval(input())) s = set() for i in range(n): s.add(eval(input())) print((len(s)))
false
33.333333
[ "-N = int(eval(input()))", "-D = dict()", "-for i in range(N):", "- S = eval(input())", "- if S not in list(D.keys()):", "- D[S] = 1", "- D[S] += 1", "-print((len(D)))", "+n = int(eval(input()))", "+s = set()", "+for i in range(n):", "+ s.add(eval(input()))", "+print((len(...
false
0.047162
0.049273
0.957156
[ "s849207051", "s798802198" ]
u504588563
p03545
python
s341950902
s721078085
190
17
38,256
3,064
Accepted
Accepted
91.05
s=eval(input()) for i in range(1 << 3): ans="" for j in range(3): ans+=s[j] if (i>>j)& 1: ans+="+" else: ans+="-" ans+=s[-1] if eval(ans+"==7"): print((ans+"=7")) break
s=eval(input()) ans="" import sys for i in range(2**3): tmp=s[0] tmp_sum=(int(s[0])) for j in range(len(s)-1): if (i >> j) & 1: tmp+="+" tmp_sum+=int(s[j+1]) else: tmp+="-" tmp_sum-=int(s[j+1]) tmp+=s[j+1] # ...
13
19
252
397
s = eval(input()) for i in range(1 << 3): ans = "" for j in range(3): ans += s[j] if (i >> j) & 1: ans += "+" else: ans += "-" ans += s[-1] if eval(ans + "==7"): print((ans + "=7")) break
s = eval(input()) ans = "" import sys for i in range(2**3): tmp = s[0] tmp_sum = int(s[0]) for j in range(len(s) - 1): if (i >> j) & 1: tmp += "+" tmp_sum += int(s[j + 1]) else: tmp += "-" tmp_sum -= int(s[j + 1]) tmp += s[j + 1] #...
false
31.578947
[ "-for i in range(1 << 3):", "- ans = \"\"", "- for j in range(3):", "- ans += s[j]", "+ans = \"\"", "+import sys", "+", "+for i in range(2**3):", "+ tmp = s[0]", "+ tmp_sum = int(s[0])", "+ for j in range(len(s) - 1):", "- ans += \"+\"", "+ tmp += ...
false
0.059245
0.066328
0.893214
[ "s341950902", "s721078085" ]
u788703383
p03834
python
s766947207
s559952451
165
17
38,384
2,940
Accepted
Accepted
89.7
s = eval(input()) l = s.split(',') print((l[0] + ' '+ l[1] + ' ' + l[2]))
print((input().replace(',',' ')))
3
1
68
31
s = eval(input()) l = s.split(",") print((l[0] + " " + l[1] + " " + l[2]))
print((input().replace(",", " ")))
false
66.666667
[ "-s = eval(input())", "-l = s.split(\",\")", "-print((l[0] + \" \" + l[1] + \" \" + l[2]))", "+print((input().replace(\",\", \" \")))" ]
false
0.090354
0.036957
2.444826
[ "s766947207", "s559952451" ]
u375282392
p02923
python
s653909372
s197396006
98
90
14,252
14,252
Accepted
Accepted
8.16
n = int(eval(input())) h = [int(i) for i in input().split()] c = 0 m = 0 for i in range(n-1): if h[i] >= h[i+1]: if i == n - 1: c += 2 else: c += 1 m = max(c,m) else: c = 0 print(m)
n = int(eval(input())) h = [int(i) for i in input().split()] c = 0 m = 0 for i in range(n-1): if h[i] >= h[i+1]: c += 1 m = max(c,m) else: c = 0 print(m)
14
11
204
165
n = int(eval(input())) h = [int(i) for i in input().split()] c = 0 m = 0 for i in range(n - 1): if h[i] >= h[i + 1]: if i == n - 1: c += 2 else: c += 1 m = max(c, m) else: c = 0 print(m)
n = int(eval(input())) h = [int(i) for i in input().split()] c = 0 m = 0 for i in range(n - 1): if h[i] >= h[i + 1]: c += 1 m = max(c, m) else: c = 0 print(m)
false
21.428571
[ "- if i == n - 1:", "- c += 2", "- else:", "- c += 1", "+ c += 1" ]
false
0.046954
0.094581
0.496448
[ "s653909372", "s197396006" ]
u104171359
p02401
python
s923959398
s501686218
30
10
7,876
7,780
Accepted
Accepted
66.67
#!usr/bin/env python3 import sys import operator from math import floor def string_to_list_spliter(): lst = [int(i) if isinstance(i, int) == True else i for i in sys.stdin.readline().split()] return lst def main(): ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operat...
#!usr/bin/env python3 import sys import operator from math import floor def string_to_list_spliter(): lst = [i for i in sys.stdin.readline().split()] return lst def main(): ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv} # TODO Refactor the ugl...
31
32
835
859
#!usr/bin/env python3 import sys import operator from math import floor def string_to_list_spliter(): lst = [ int(i) if isinstance(i, int) == True else i for i in sys.stdin.readline().split() ] return lst def main(): ops = { "+": operator.add, "-": operator.sub, ...
#!usr/bin/env python3 import sys import operator from math import floor def string_to_list_spliter(): lst = [i for i in sys.stdin.readline().split()] return lst def main(): ops = { "+": operator.add, "-": operator.sub, "*": operator.mul, "/": operator.truediv, } #...
false
3.125
[ "- lst = [", "- int(i) if isinstance(i, int) == True else i", "- for i in sys.stdin.readline().split()", "- ]", "+ lst = [i for i in sys.stdin.readline().split()]", "+ # TODO Refactor the ugly code below into the function above." ]
false
0.037598
0.038094
0.986981
[ "s923959398", "s501686218" ]
u620084012
p02972
python
s961922859
s804003229
1,016
162
71,132
98,948
Accepted
Accepted
84.06
import math N = int(eval(input())) a = list(map(int,input().split())) b = [0]*N ans = [] for k in range(N,0,-1): if a[k-1]%2 != b[k-1]%2: ans.append(k) b[0] += 1 b[k-1] += 1 for l in range(2,math.floor(math.sqrt(k))+1): if k % l == 0: if l*l ==...
N = int(eval(input())) a = [0] + list(map(int,input().split())) ans = [0]*(N+1) for k in range(N,0,-1): temp = 0 l = k while l <= N: temp += ans[l] l += k if a[k] == 1 and temp%2 == 0: ans[k] = 1 elif a[k] == 0 and temp%2 == 1: ans[k] = 1 b = [] for k in...
20
19
495
397
import math N = int(eval(input())) a = list(map(int, input().split())) b = [0] * N ans = [] for k in range(N, 0, -1): if a[k - 1] % 2 != b[k - 1] % 2: ans.append(k) b[0] += 1 b[k - 1] += 1 for l in range(2, math.floor(math.sqrt(k)) + 1): if k % l == 0: if...
N = int(eval(input())) a = [0] + list(map(int, input().split())) ans = [0] * (N + 1) for k in range(N, 0, -1): temp = 0 l = k while l <= N: temp += ans[l] l += k if a[k] == 1 and temp % 2 == 0: ans[k] = 1 elif a[k] == 0 and temp % 2 == 1: ans[k] = 1 b = [] for k in ra...
false
5
[ "-import math", "-", "-a = list(map(int, input().split()))", "-b = [0] * N", "-ans = []", "+a = [0] + list(map(int, input().split()))", "+ans = [0] * (N + 1)", "- if a[k - 1] % 2 != b[k - 1] % 2:", "- ans.append(k)", "- b[0] += 1", "- b[k - 1] += 1", "- for l in ...
false
0.083178
0.076189
1.091737
[ "s961922859", "s804003229" ]
u991567869
p03680
python
s865892160
s984602792
216
75
7,852
7,852
Accepted
Accepted
65.28
n = int(eval(input())) a = [] l = [0]*(n + 1) cnt = 0 now = 1 for i in range(n): a.append(int(eval(input()))) for i in range(n): cnt += 1 now = a[now - 1] if now == 2: print(cnt) exit() print((-1))
import sys input = sys.stdin.readline def main(): n = int(eval(input())) a = [] l = [0]*(n + 1) cnt = 0 now = 1 for i in range(n): a.append(int(eval(input()))) for i in range(n): cnt += 1 now = a[now - 1] if now == 2: print(cnt)...
17
22
234
353
n = int(eval(input())) a = [] l = [0] * (n + 1) cnt = 0 now = 1 for i in range(n): a.append(int(eval(input()))) for i in range(n): cnt += 1 now = a[now - 1] if now == 2: print(cnt) exit() print((-1))
import sys input = sys.stdin.readline def main(): n = int(eval(input())) a = [] l = [0] * (n + 1) cnt = 0 now = 1 for i in range(n): a.append(int(eval(input()))) for i in range(n): cnt += 1 now = a[now - 1] if now == 2: print(cnt) ex...
false
22.727273
[ "-n = int(eval(input()))", "-a = []", "-l = [0] * (n + 1)", "-cnt = 0", "-now = 1", "-for i in range(n):", "- a.append(int(eval(input())))", "-for i in range(n):", "- cnt += 1", "- now = a[now - 1]", "- if now == 2:", "- print(cnt)", "- exit()", "-print((-1))", ...
false
0.03668
0.037578
0.976119
[ "s865892160", "s984602792" ]
u168489836
p03478
python
s473045928
s946260354
36
32
2,940
2,940
Accepted
Accepted
11.11
n, a, b = [int(x) for x in input().split()] count = 0 for i in range(a, n+1): if a <= sum([int(x) for x in list(str(i))]) <= b: count += i print(count)
n, a, b = [int(x) for x in input().split()] idx = 0 for i in range(1, n+1): if a <= sum([int(x) for x in str(i)]) <= b: idx += i print(idx)
6
6
168
156
n, a, b = [int(x) for x in input().split()] count = 0 for i in range(a, n + 1): if a <= sum([int(x) for x in list(str(i))]) <= b: count += i print(count)
n, a, b = [int(x) for x in input().split()] idx = 0 for i in range(1, n + 1): if a <= sum([int(x) for x in str(i)]) <= b: idx += i print(idx)
false
0
[ "-count = 0", "-for i in range(a, n + 1):", "- if a <= sum([int(x) for x in list(str(i))]) <= b:", "- count += i", "-print(count)", "+idx = 0", "+for i in range(1, n + 1):", "+ if a <= sum([int(x) for x in str(i)]) <= b:", "+ idx += i", "+print(idx)" ]
false
0.038416
0.047598
0.807089
[ "s473045928", "s946260354" ]
u072053884
p02244
python
s941843568
s784026074
30
20
7,872
5,616
Accepted
Accepted
33.33
row = [True] * 8 col = [True] * 8 dpos = [True] * 15 dneg = [True] * 15 board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)] import sys file_input = sys.stdin k = int(file_input.readline()) for line in file_input: r, c = map(int, line.split()) row[r] = "INIT" col[c] = ...
row = [False] * 8 col = [False] * 8 dpos = [False] * 15 dneg = [False] * 15 board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)] import sys file_input = sys.stdin k = int(file_input.readline()) for line in file_input: r, c = list(map(int, line.split())) row[r] = True c...
47
45
1,121
1,003
row = [True] * 8 col = [True] * 8 dpos = [True] * 15 dneg = [True] * 15 board = [[".", ".", ".", ".", ".", ".", ".", "."] for i in range(8)] import sys file_input = sys.stdin k = int(file_input.readline()) for line in file_input: r, c = map(int, line.split()) row[r] = "INIT" col[c] = "INIT" dpos[r + c]...
row = [False] * 8 col = [False] * 8 dpos = [False] * 15 dneg = [False] * 15 board = [[".", ".", ".", ".", ".", ".", ".", "."] for i in range(8)] import sys file_input = sys.stdin k = int(file_input.readline()) for line in file_input: r, c = list(map(int, line.split())) row[r] = True col[c] = True dpos[...
false
4.255319
[ "-row = [True] * 8", "-col = [True] * 8", "-dpos = [True] * 15", "-dneg = [True] * 15", "+row = [False] * 8", "+col = [False] * 8", "+dpos = [False] * 15", "+dneg = [False] * 15", "- r, c = map(int, line.split())", "- row[r] = \"INIT\"", "- col[c] = \"INIT\"", "- dpos[r + c] = Fals...
false
0.044388
0.04476
0.991705
[ "s941843568", "s784026074" ]
u852690916
p02824
python
s302608400
s010078255
304
250
119,488
62,704
Accepted
Accepted
17.76
N,M,V,P=list(map(int, input().split())) *A,=list(map(int, input().split())) A.sort() Ax = A[-P] #上位Pの中の最下位 def f(i): mine = A[i] + M #自分に全力で投票 if mine < Ax: return False #逆転不能 votes = M*V votes -= M #自分への票 votes -= min(P-1, V) * M #上位陣のx以外に全力で投票 votes -= sum([min(mine - A[j], M) f...
N,M,V,P=list(map(int, input().split())) *A,=list(map(int, input().split())) A.sort() #A[x]の問題が採用される可能性があるか? def check(x): r = A[-P] #無投票でギリギリ採用される問題のスコア if A[x] + M < r: return False votes = M*V votes -= M # A[x]に投票 votes -= M*(P-1) #上位の問題に投票 votes -= M*x #下位の問題に投票 #微...
24
27
528
519
N, M, V, P = list(map(int, input().split())) (*A,) = list(map(int, input().split())) A.sort() Ax = A[-P] # 上位Pの中の最下位 def f(i): mine = A[i] + M # 自分に全力で投票 if mine < Ax: return False # 逆転不能 votes = M * V votes -= M # 自分への票 votes -= min(P - 1, V) * M # 上位陣のx以外に全力で投票 votes -= sum( ...
N, M, V, P = list(map(int, input().split())) (*A,) = list(map(int, input().split())) A.sort() # A[x]の問題が採用される可能性があるか? def check(x): r = A[-P] # 無投票でギリギリ採用される問題のスコア if A[x] + M < r: return False votes = M * V votes -= M # A[x]に投票 votes -= M * (P - 1) # 上位の問題に投票 votes -= M * x # 下位の問題に...
false
11.111111
[ "-Ax = A[-P] # 上位Pの中の最下位", "+# A[x]の問題が採用される可能性があるか?", "+def check(x):", "+ r = A[-P] # 無投票でギリギリ採用される問題のスコア", "+ if A[x] + M < r:", "+ return False", "+ votes = M * V", "+ votes -= M # A[x]に投票", "+ votes -= M * (P - 1) # 上位の問題に投票", "+ votes -= M * x # 下位の問題に投票", "+ ...
false
0.074347
0.040881
1.818592
[ "s302608400", "s010078255" ]
u644907318
p03043
python
s638908020
s753910547
88
65
73,868
65,312
Accepted
Accepted
26.14
def f(n): k = 0 while n*2**k<K: k += 1 return k N,K = list(map(int,input().split())) if K<=N: P = (N-K+1)/N for i in range(1,K): P += 2**(-f(i))/N else: P = 0 for i in range(1,N+1): P += 2**(-f(i))/N print(P)
import math N,K = list(map(int,input().split())) P = max((N-K+1)/N,0) cnt = 0 for k in range(1,min(N,K-1)+1): cnt += 2**(-math.ceil(math.log2(K/k))) cnt = cnt/N P += cnt print(P)
15
9
268
184
def f(n): k = 0 while n * 2**k < K: k += 1 return k N, K = list(map(int, input().split())) if K <= N: P = (N - K + 1) / N for i in range(1, K): P += 2 ** (-f(i)) / N else: P = 0 for i in range(1, N + 1): P += 2 ** (-f(i)) / N print(P)
import math N, K = list(map(int, input().split())) P = max((N - K + 1) / N, 0) cnt = 0 for k in range(1, min(N, K - 1) + 1): cnt += 2 ** (-math.ceil(math.log2(K / k))) cnt = cnt / N P += cnt print(P)
false
40
[ "-def f(n):", "- k = 0", "- while n * 2**k < K:", "- k += 1", "- return k", "-", "+import math", "-if K <= N:", "- P = (N - K + 1) / N", "- for i in range(1, K):", "- P += 2 ** (-f(i)) / N", "-else:", "- P = 0", "- for i in range(1, N + 1):", "- ...
false
0.035245
0.088661
0.397521
[ "s638908020", "s753910547" ]
u520276780
p04020
python
s944432568
s410607840
571
520
52,184
50,776
Accepted
Accepted
8.93
#貪欲の手順がおかしかった #同一ペアを組むのはそれ以下の数を除いた後 #editorial参照、さらに単純に0で区切ってn//2になる n = int(eval(input())) a = [] for _ in range(n): a_ = int(eval(input())) a.append(a_) #print(a) ans = 0 """ for i in range(n-1): if a[i]&1: ans += a[i]//2 a[i] = 1 elif a[i] ==0: pass else: ...
#旧版のa[n-1]分を訂正してテスト n = int(eval(input())) a = [] for _ in range(n): a_ = int(eval(input())) a.append(a_) ans = 0 for i in range(n-1): if a[i]&1: ans += a[i]//2 a[i] = 1 elif a[i] ==0: pass else: ans += a[i]//2-1 a[i] = 2 for i in range(n...
32
29
553
481
# 貪欲の手順がおかしかった # 同一ペアを組むのはそれ以下の数を除いた後 # editorial参照、さらに単純に0で区切ってn//2になる n = int(eval(input())) a = [] for _ in range(n): a_ = int(eval(input())) a.append(a_) # print(a) ans = 0 """ for i in range(n-1): if a[i]&1: ans += a[i]//2 a[i] = 1 elif a[i] ==0: pass else: ans +...
# 旧版のa[n-1]分を訂正してテスト n = int(eval(input())) a = [] for _ in range(n): a_ = int(eval(input())) a.append(a_) ans = 0 for i in range(n - 1): if a[i] & 1: ans += a[i] // 2 a[i] = 1 elif a[i] == 0: pass else: ans += a[i] // 2 - 1 a[i] = 2 for i in range(n - 1): ...
false
9.375
[ "-# 貪欲の手順がおかしかった", "-# 同一ペアを組むのはそれ以下の数を除いた後", "-# editorial参照、さらに単純に0で区切ってn//2になる", "+# 旧版のa[n-1]分を訂正してテスト", "-# print(a)", "-\"\"\"", "-for i in range(n-1):", "- if a[i]&1:", "- ans += a[i]//2", "+for i in range(n - 1):", "+ if a[i] & 1:", "+ ans += a[i] // 2", "- eli...
false
0.037961
0.039377
0.964018
[ "s944432568", "s410607840" ]
u145950990
p03503
python
s106336528
s908876909
244
221
43,632
42,092
Accepted
Accepted
9.43
n = int(eval(input())) F = [list(map(int,input().split())) for _ in range(n)] P = [list(map(int,input().split())) for _ in range(n)] ans = -10**9 def bfs(x): if len(x) == 10: if 1 in x: global ans a = 0 for i in range(n): f,p = F[i],P[i] ...
import itertools n = int(eval(input())) f = [list(map(int,input().split())) for _ in range(n)] p = [list(map(int,input().split())) for _ in range(n)] data = list(itertools.product(list(range(2)), repeat = 10))[1:] ans = -10**9 for d in data: a = 0 for i in range(n): c = 0 for j in ran...
21
15
544
408
n = int(eval(input())) F = [list(map(int, input().split())) for _ in range(n)] P = [list(map(int, input().split())) for _ in range(n)] ans = -(10**9) def bfs(x): if len(x) == 10: if 1 in x: global ans a = 0 for i in range(n): f, p = F[i], P[i] ...
import itertools n = int(eval(input())) f = [list(map(int, input().split())) for _ in range(n)] p = [list(map(int, input().split())) for _ in range(n)] data = list(itertools.product(list(range(2)), repeat=10))[1:] ans = -(10**9) for d in data: a = 0 for i in range(n): c = 0 for j in range(10): ...
false
28.571429
[ "+import itertools", "+", "-F = [list(map(int, input().split())) for _ in range(n)]", "-P = [list(map(int, input().split())) for _ in range(n)]", "+f = [list(map(int, input().split())) for _ in range(n)]", "+p = [list(map(int, input().split())) for _ in range(n)]", "+data = list(itertools.product(list(r...
false
0.04867
0.072096
0.675076
[ "s106336528", "s908876909" ]
u394721319
p03495
python
s832111962
s172035818
420
194
25,732
39,296
Accepted
Accepted
53.81
import bisect N,K = [int(zz) for zz in input().split()] A = [int(zz) for zz in input().split()] B = set(A) A.sort() ans = [] for i in B: p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i) ans.append(p) ans.sort() j = 0 for i in range(len(B)-K): j += ans[i] print(j)
from collections import Counter N,K = [int(zz) for zz in input().split()] A = [int(zz) for zz in input().split()] tmp = Counter(A).most_common()[::-1] ans = 0 for i in range(len(tmp)-K): ans += tmp[i][1] print(ans)
17
11
303
232
import bisect N, K = [int(zz) for zz in input().split()] A = [int(zz) for zz in input().split()] B = set(A) A.sort() ans = [] for i in B: p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i) ans.append(p) ans.sort() j = 0 for i in range(len(B) - K): j += ans[i] print(j)
from collections import Counter N, K = [int(zz) for zz in input().split()] A = [int(zz) for zz in input().split()] tmp = Counter(A).most_common()[::-1] ans = 0 for i in range(len(tmp) - K): ans += tmp[i][1] print(ans)
false
35.294118
[ "-import bisect", "+from collections import Counter", "-B = set(A)", "-A.sort()", "-ans = []", "-for i in B:", "- p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i)", "- ans.append(p)", "-ans.sort()", "-j = 0", "-for i in range(len(B) - K):", "- j += ans[i]", "-print(j)", "+...
false
0.05915
0.079738
0.741802
[ "s832111962", "s172035818" ]
u077291787
p02558
python
s036163160
s535784624
347
315
18,796
58,008
Accepted
Accepted
9.22
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, data_size: int) -> None: self._data_size = data_size self._roots = [-1] * data_size def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x ...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, data_size: int) -> None: self._data_size = data_size self._roots = [-1] * data_size def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x ...
39
34
990
921
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, data_size: int) -> None: self._data_size = data_size self._roots = [-1] * data_size def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def is_...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, data_size: int) -> None: self._data_size = data_size self._roots = [-1] * data_size def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def is_...
false
12.820513
[ "-import sys", "-", "-readline = sys.stdin.buffer.readline", "-N, Q = list(map(int, readline().split()))", "+N, Q, *TUV = list(map(int, open(0).read().split()))", "-for _ in range(Q):", "- t, u, v = list(map(int, readline().split()))", "+for t, u, v in zip(*[iter(TUV)] * 3):" ]
false
0.04864
0.039471
1.232293
[ "s036163160", "s535784624" ]
u853185302
p03127
python
s254039793
s482010769
153
78
14,252
16,200
Accepted
Accepted
49.02
N = int(eval(input())) A = list(map(int,input().split())) A.sort() while(len(A) != 1): A_min = A.pop(0) A = [A[i]%A_min for i in range(len(A)) if A[i]%A_min > 0] A.append(A_min) A.sort() print((A[0]))
from functools import reduce from fractions import gcd n = int(eval(input())) a = list(map(int,input().split())) print((reduce(gcd,a)))
11
5
212
132
N = int(eval(input())) A = list(map(int, input().split())) A.sort() while len(A) != 1: A_min = A.pop(0) A = [A[i] % A_min for i in range(len(A)) if A[i] % A_min > 0] A.append(A_min) A.sort() print((A[0]))
from functools import reduce from fractions import gcd n = int(eval(input())) a = list(map(int, input().split())) print((reduce(gcd, a)))
false
54.545455
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-A.sort()", "-while len(A) != 1:", "- A_min = A.pop(0)", "- A = [A[i] % A_min for i in range(len(A)) if A[i] % A_min > 0]", "- A.append(A_min)", "- A.sort()", "-print((A[0]))", "+from functools import reduce", "+from...
false
0.087379
0.060668
1.44028
[ "s254039793", "s482010769" ]
u699089116
p03951
python
s350032925
s076558455
164
67
38,256
61,828
Accepted
Accepted
59.15
n = int(eval(input())) s = eval(input()) t = eval(input()) ans = len(s + t) for i in range(n): if s[i:] == t[:n-i]: print((n+i)) exit() print((n*2))
n = int(eval(input())) s = eval(input()) t = eval(input()) for i in range(n): if s[i:] == t[:n-i]: print((n + i)) exit() else: print((n*2))
10
10
156
151
n = int(eval(input())) s = eval(input()) t = eval(input()) ans = len(s + t) for i in range(n): if s[i:] == t[: n - i]: print((n + i)) exit() print((n * 2))
n = int(eval(input())) s = eval(input()) t = eval(input()) for i in range(n): if s[i:] == t[: n - i]: print((n + i)) exit() else: print((n * 2))
false
0
[ "-ans = len(s + t)", "-print((n * 2))", "+else:", "+ print((n * 2))" ]
false
0.036002
0.035623
1.010632
[ "s350032925", "s076558455" ]