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
u781262926
p03713
python
s514086411
s513234730
466
20
3,064
3,064
Accepted
Accepted
95.71
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: if h > w: h, w = w, h ans = h for w1 in range(w//3-2, w//3+3): s1 = w1 * h w2 = w-w1 for h1 in range(h//2 + 1): s2 = w2 * h1 s3 = w2 * (h-h1) ...
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: ans = min(w, h) for w1 in range(w//3, w//3+3): s1 = w1 * h w2 = w-w1 for h1 in range(h//2, h//2+2): s2 = w2 * h1 s3 = w2 * (h-h1) ans = min(ans, max(s1,...
23
21
631
607
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: if h > w: h, w = w, h ans = h for w1 in range(w // 3 - 2, w // 3 + 3): s1 = w1 * h w2 = w - w1 for h1 in range(h // 2 + 1): s2 = w2 * h1 s3 = w2 * (h - h1) ...
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: ans = min(w, h) for w1 in range(w // 3, w // 3 + 3): s1 = w1 * h w2 = w - w1 for h1 in range(h // 2, h // 2 + 2): s2 = w2 * h1 s3 = w2 * (h - h1) ans = min(ans, ma...
false
8.695652
[ "- if h > w:", "- h, w = w, h", "- ans = h", "- for w1 in range(w // 3 - 2, w // 3 + 3):", "+ ans = min(w, h)", "+ for w1 in range(w // 3, w // 3 + 3):", "- for h1 in range(h // 2 + 1):", "+ for h1 in range(h // 2, h // 2 + 2):", "- for w1 in range(w // 3 - 2, ...
false
0.593747
0.036567
16.237228
[ "s514086411", "s513234730" ]
u062147869
p03721
python
s078520478
s522512732
499
442
24,320
20,104
Accepted
Accepted
11.42
from bisect import bisect_left,bisect_right N,K=list(map(int,input().split())) table=[] for i in range(N): a,b=list(map(int,input().split())) table.append([a,b]) table.sort() cou=[0]*N cou[0]=table[0][1] for i in range(1,N): cou[i]=cou[i-1]+table[i][1] s = bisect_left(cou,K) print((table[s][0]))
N,K=list(map(int,input().split())) table=[] for i in range(N): a,b=list(map(int,input().split())) table.append([a,b]) table.sort() ans = 0 for x,y in table: ans += y if ans >=K: print(x) break
13
12
306
223
from bisect import bisect_left, bisect_right N, K = list(map(int, input().split())) table = [] for i in range(N): a, b = list(map(int, input().split())) table.append([a, b]) table.sort() cou = [0] * N cou[0] = table[0][1] for i in range(1, N): cou[i] = cou[i - 1] + table[i][1] s = bisect_left(cou, K) print...
N, K = list(map(int, input().split())) table = [] for i in range(N): a, b = list(map(int, input().split())) table.append([a, b]) table.sort() ans = 0 for x, y in table: ans += y if ans >= K: print(x) break
false
7.692308
[ "-from bisect import bisect_left, bisect_right", "-", "-cou = [0] * N", "-cou[0] = table[0][1]", "-for i in range(1, N):", "- cou[i] = cou[i - 1] + table[i][1]", "-s = bisect_left(cou, K)", "-print((table[s][0]))", "+ans = 0", "+for x, y in table:", "+ ans += y", "+ if ans >= K:", "...
false
0.037223
0.038742
0.960786
[ "s078520478", "s522512732" ]
u145410317
p03457
python
s658619013
s662891634
438
362
27,380
3,064
Accepted
Accepted
17.35
num = int(eval(input())) travels = [] for _ in range(num): travels.append(list(map(int, input().split()))) beforTime = 0 beforX = 0 beforY = 0 resultFrag = True for travel in travels: move = abs(beforX - travel[1]) + abs(beforY - travel[2]) canMoveTime = travel[0] - beforTime if move <=...
num = int(eval(input())) beforTime = 0 beforX = 0 beforY = 0 resultFrag = True for travel in range(num): time, x, y = list(map(int, input().split())) move = abs(beforX - x) + abs(beforY - y) canMoveTime = time - beforTime if move <= canMoveTime and (move + canMoveTime) % 2 == 0: be...
23
20
542
456
num = int(eval(input())) travels = [] for _ in range(num): travels.append(list(map(int, input().split()))) beforTime = 0 beforX = 0 beforY = 0 resultFrag = True for travel in travels: move = abs(beforX - travel[1]) + abs(beforY - travel[2]) canMoveTime = travel[0] - beforTime if move <= canMoveTime and ...
num = int(eval(input())) beforTime = 0 beforX = 0 beforY = 0 resultFrag = True for travel in range(num): time, x, y = list(map(int, input().split())) move = abs(beforX - x) + abs(beforY - y) canMoveTime = time - beforTime if move <= canMoveTime and (move + canMoveTime) % 2 == 0: beforTime = time...
false
13.043478
[ "-travels = []", "-for _ in range(num):", "- travels.append(list(map(int, input().split())))", "-for travel in travels:", "- move = abs(beforX - travel[1]) + abs(beforY - travel[2])", "- canMoveTime = travel[0] - beforTime", "+for travel in range(num):", "+ time, x, y = list(map(int, input...
false
0.041022
0.043123
0.951282
[ "s658619013", "s662891634" ]
u836311327
p02536
python
s375613383
s485120147
843
211
87,140
13,268
Accepted
Accepted
74.97
#!/usr/bin/env python3 from networkx.utils import UnionFind import sys def input(): return sys.stdin.readline().rstrip() def main(): n,m=list(map(int, input().split())) uf = UnionFind() for i in range(1,n+1): _=uf[i] for _ in range(m): a,b=list(map(int, input().split())) ...
import sys def input(): return sys.stdin.readline().rstrip() from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.pare...
21
66
498
1,736
#!/usr/bin/env python3 from networkx.utils import UnionFind import sys def input(): return sys.stdin.readline().rstrip() def main(): n, m = list(map(int, input().split())) uf = UnionFind() for i in range(1, n + 1): _ = uf[i] for _ in range(m): a, b = list(map(int, input().split()...
import sys def input(): return sys.stdin.readline().rstrip() from collections import defaultdict class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x]...
false
68.181818
[ "-#!/usr/bin/env python3", "-from networkx.utils import UnionFind", "+from collections import defaultdict", "+", "+", "+class UnionFind:", "+ def __init__(self, n):", "+ self.n = n", "+ self.parents = [-1] * n", "+", "+ def find(self, x):", "+ if self.parents[x] < 0:...
false
0.06731
0.040293
1.670504
[ "s375613383", "s485120147" ]
u595952233
p02579
python
s827148705
s519781181
1,966
880
164,476
132,520
Accepted
Accepted
55.24
from collections import deque """ ダイクストラ ギリギリ """ h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch-=1; cw-=1; dh-=1; dw-=1 area = [list(eval(input())) for _ in range(h)] inf = 10**100 dist = [[inf]*w for i in range(h)] dwalk = [(0...
from collections import deque h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch-=1; cw-=1; dh-=1; dw-=1 area = [list(eval(input())) for _ in range(h)] inf = 10**100 dist = [[inf]*w for i in range(h)] dwalk = [(0, 1), (0, -1), (1, 0), (-...
46
37
1,493
1,069
from collections import deque """ ダイクストラ ギリギリ """ h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch -= 1 cw -= 1 dh -= 1 dw -= 1 area = [list(eval(input())) for _ in range(h)] inf = 10**100 dist = [[inf] * w for i in range(h)] dwalk = [(0, 1), (...
from collections import deque h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch -= 1 cw -= 1 dh -= 1 dw -= 1 area = [list(eval(input())) for _ in range(h)] inf = 10**100 dist = [[inf] * w for i in range(h)] dwalk = [(0, 1), (0, -1), (1, 0), (-1,...
false
19.565217
[ "-\"\"\"", "-ダイクストラ ギリギリ", "-\"\"\"", "-", "-", "-def Dijkstra(ch, cw):", "- import heapq", "-", "- edgelist = [(0, ch, cw)]", "- heapq.heapify(edgelist)", "- dist[ch][cw] = 0", "- while len(edgelist):", "- cost, y, x = heapq.heappop(edgelist)", "- if y == dh a...
false
0.043031
0.043136
0.99757
[ "s827148705", "s519781181" ]
u285891772
p02900
python
s858688470
s651293025
267
132
5,204
5,320
Accepted
Accepted
50.56
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter,...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter,...
49
40
1,289
1,221
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, ) from itertools import ( accumulate, permutations, combinations, combi...
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, ) from itertools import ( accumulate, permutations, combinations, combi...
false
18.367347
[ "-def is_prime(num):", "- if num < 2:", "- return False", "- if num in [2, 3, 5]:", "- return True", "- if any(num % x == 0 for x in [2, 3, 5]):", "- return False", "- prime = 7", "- step = 4", "- while prime <= sqrt(num):", "- if num % prime == 0:",...
false
0.062061
0.060283
1.029491
[ "s858688470", "s651293025" ]
u083960235
p03805
python
s922031207
s299711745
52
45
6,376
4,980
Accepted
Accepted
13.46
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii...
51
49
1,350
1,326
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
false
3.921569
[ "-from fractions import gcd", "+from heapq import heapify, heappop, heappush", "-# E = defaultdict(list)", "-# print(permu)", "-for p_list in per:", "- p_list = [0] + list(p_list)", "- permu.append(p_list)", "+for p in per:", "+ p = [0] + list(p)", "+ permu.append(p)", "+ cnt = 0"...
false
0.045495
0.052904
0.859951
[ "s922031207", "s299711745" ]
u596536048
p03378
python
s794270614
s946479086
28
25
9,172
9,096
Accepted
Accepted
10.71
total_square, total_toll_gate, current_square = list(map(int, input().split())) toll_gate_square = list(map(int, input().split())) route1 = 0 route2 = 0 for i in range(total_toll_gate): if toll_gate_square[i] < current_square: route1 += 1 else: route2 += 1 print((min(route1, route2)))
N, M, X = list(map(int, input().split())) A = sum(int(i) < X for i in input().split()) print((min(A, M - A)))
10
3
310
103
total_square, total_toll_gate, current_square = list(map(int, input().split())) toll_gate_square = list(map(int, input().split())) route1 = 0 route2 = 0 for i in range(total_toll_gate): if toll_gate_square[i] < current_square: route1 += 1 else: route2 += 1 print((min(route1, route2)))
N, M, X = list(map(int, input().split())) A = sum(int(i) < X for i in input().split()) print((min(A, M - A)))
false
70
[ "-total_square, total_toll_gate, current_square = list(map(int, input().split()))", "-toll_gate_square = list(map(int, input().split()))", "-route1 = 0", "-route2 = 0", "-for i in range(total_toll_gate):", "- if toll_gate_square[i] < current_square:", "- route1 += 1", "- else:", "- ...
false
0.043363
0.038333
1.131217
[ "s794270614", "s946479086" ]
u979667682
p03014
python
s919480132
s990353049
1,893
1,089
311,664
187,632
Accepted
Accepted
42.47
from sys import stdin import math import fractions from collections import deque import itertools INF = 10 ** 10 # H <= 2000, W <= 2000 # H*W -> O(4*10^6) H, W = [int(x) for x in stdin.readline().rstrip().split()] S = [[x for x in stdin.readline().rstrip()] for _ in range(H)] # L[i][j]: i行目j列目に明かりを置いたとき...
from sys import stdin import math import fractions from collections import deque import itertools INF = 10 ** 10 # H <= 2000, W <= 2000 # H*W -> O(4*10^6) H, W = [int(x) for x in stdin.readline().rstrip().split()] S = [stdin.readline().rstrip() for _ in range(H)] # L[i][j]: i行目j列目に明かりを置いたときにそこから左方向に照らされ...
84
84
1,684
1,671
from sys import stdin import math import fractions from collections import deque import itertools INF = 10**10 # H <= 2000, W <= 2000 # H*W -> O(4*10^6) H, W = [int(x) for x in stdin.readline().rstrip().split()] S = [[x for x in stdin.readline().rstrip()] for _ in range(H)] # L[i][j]: i行目j列目に明かりを置いたときにそこから左方向に照らされるマスの...
from sys import stdin import math import fractions from collections import deque import itertools INF = 10**10 # H <= 2000, W <= 2000 # H*W -> O(4*10^6) H, W = [int(x) for x in stdin.readline().rstrip().split()] S = [stdin.readline().rstrip() for _ in range(H)] # L[i][j]: i行目j列目に明かりを置いたときにそこから左方向に照らされるマスの個数 # ...
false
0
[ "-S = [[x for x in stdin.readline().rstrip()] for _ in range(H)]", "+S = [stdin.readline().rstrip() for _ in range(H)]" ]
false
0.058725
0.059505
0.986884
[ "s919480132", "s990353049" ]
u893063840
p03503
python
s761255259
s039285480
481
118
3,064
9,228
Accepted
Accepted
75.47
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 = -float("inf") for i in range(1, 2 ** 10): i_bin = "{:010b}".format(i) sm = 0 for shop_i in range(n): cnt = 0 for j, dig in enumerate(i_bin):...
from itertools import combinations 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 ** 18 for i in range(1, 11): for pat in combinations(list(range(10)), i): cnt = [0] * n for e in pat: ...
17
21
464
505
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 = -float("inf") for i in range(1, 2**10): i_bin = "{:010b}".format(i) sm = 0 for shop_i in range(n): cnt = 0 for j, dig in enumerate(i_bin): ...
from itertools import combinations 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**18) for i in range(1, 11): for pat in combinations(list(range(10)), i): cnt = [0] * n for e in pat: for j...
false
19.047619
[ "+from itertools import combinations", "+", "-ans = -float(\"inf\")", "-for i in range(1, 2**10):", "- i_bin = \"{:010b}\".format(i)", "- sm = 0", "- for shop_i in range(n):", "- cnt = 0", "- for j, dig in enumerate(i_bin):", "- if f[shop_i][j] * int(dig): # == 1...
false
0.043648
0.042619
1.024147
[ "s761255259", "s039285480" ]
u768559443
p03107
python
s147498660
s918945223
180
46
39,408
3,956
Accepted
Accepted
74.44
s=eval(input()) a=0 b=0 for i in s: if i=="0": a+=1 else: b+=1 print((min(a,b)*2))
S=eval(input()) stack=[] cnt=0 for s in S: if not stack: stack.append(s) elif stack[-1]!=s: stack.pop() cnt+=2 else: stack.append(s) print(cnt)
11
13
100
176
s = eval(input()) a = 0 b = 0 for i in s: if i == "0": a += 1 else: b += 1 print((min(a, b) * 2))
S = eval(input()) stack = [] cnt = 0 for s in S: if not stack: stack.append(s) elif stack[-1] != s: stack.pop() cnt += 2 else: stack.append(s) print(cnt)
false
15.384615
[ "-s = eval(input())", "-a = 0", "-b = 0", "-for i in s:", "- if i == \"0\":", "- a += 1", "+S = eval(input())", "+stack = []", "+cnt = 0", "+for s in S:", "+ if not stack:", "+ stack.append(s)", "+ elif stack[-1] != s:", "+ stack.pop()", "+ cnt += 2",...
false
0.085641
0.044429
1.927578
[ "s147498660", "s918945223" ]
u678167152
p03137
python
s779732881
s722427616
110
86
13,968
20,300
Accepted
Accepted
21.82
N, M = list(map(int, input().split())) X = list(map(int, input().split())) X.sort() diff = [0]*(M-1) for i in range(M-1): diff[i] = X[i+1]-X[i] diff.sort() if N>=M: ans = 0 else: ans = sum(diff[:M-N]) print(ans)
def solve(): N, M = list(map(int, input().split())) X = list(map(int, input().split())) X.sort() lis = [] for i in range(M-1): lis.append(X[i+1]-X[i]) lis.sort(reverse=True) ans = X[-1]-X[0]-sum(lis[:N-1]) return ans print((solve()))
14
11
232
255
N, M = list(map(int, input().split())) X = list(map(int, input().split())) X.sort() diff = [0] * (M - 1) for i in range(M - 1): diff[i] = X[i + 1] - X[i] diff.sort() if N >= M: ans = 0 else: ans = sum(diff[: M - N]) print(ans)
def solve(): N, M = list(map(int, input().split())) X = list(map(int, input().split())) X.sort() lis = [] for i in range(M - 1): lis.append(X[i + 1] - X[i]) lis.sort(reverse=True) ans = X[-1] - X[0] - sum(lis[: N - 1]) return ans print((solve()))
false
21.428571
[ "-N, M = list(map(int, input().split()))", "-X = list(map(int, input().split()))", "-X.sort()", "-diff = [0] * (M - 1)", "-for i in range(M - 1):", "- diff[i] = X[i + 1] - X[i]", "-diff.sort()", "-if N >= M:", "- ans = 0", "-else:", "- ans = sum(diff[: M - N])", "-print(ans)", "+def...
false
0.047485
0.04637
1.02405
[ "s779732881", "s722427616" ]
u596536048
p03563
python
s554444013
s121077065
29
25
9,092
8,996
Accepted
Accepted
13.79
R, G = (int(eval(input())) for i in range(2)) print((G * 2 - R))
print((-int(eval(input())) + int(eval(input())) * 2))
2
1
57
40
R, G = (int(eval(input())) for i in range(2)) print((G * 2 - R))
print((-int(eval(input())) + int(eval(input())) * 2))
false
50
[ "-R, G = (int(eval(input())) for i in range(2))", "-print((G * 2 - R))", "+print((-int(eval(input())) + int(eval(input())) * 2))" ]
false
0.113185
0.032472
3.485571
[ "s554444013", "s121077065" ]
u098012509
p03476
python
s143250259
s673615436
750
286
34,108
23,044
Accepted
Accepted
61.87
import sys import bisect from functools import lru_cache input = sys.stdin.readline @lru_cache(maxsize=None) def is_prime(n): if n == 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def main(): Q = int(eval(...
import sys import bisect input = sys.stdin.readline def get_primes(n): sieve = [1] * n for i in range(3, int(n ** 0.5) + 1, 2): if sieve[i]: sieve[i * i:: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1) return [2] + [i for i in range(3, n, 2) if sieve[i]] def main(): ...
41
34
712
731
import sys import bisect from functools import lru_cache input = sys.stdin.readline @lru_cache(maxsize=None) def is_prime(n): if n == 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def main(): Q = int(eval(input())) lr = [...
import sys import bisect input = sys.stdin.readline def get_primes(n): sieve = [1] * n for i in range(3, int(n**0.5) + 1, 2): if sieve[i]: sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1) return [2] + [i for i in range(3, n, 2) if sieve[i]] def main(): Q = int(eval...
false
17.073171
[ "-from functools import lru_cache", "-@lru_cache(maxsize=None)", "-def is_prime(n):", "- if n == 1:", "- return False", "- for i in range(2, int(n**0.5) + 1):", "- if n % i == 0:", "- return False", "- return True", "+def get_primes(n):", "+ sieve = [1] * n",...
false
0.56793
0.147295
3.85573
[ "s143250259", "s673615436" ]
u351892848
p02773
python
s718173478
s528930233
659
434
35,572
38,812
Accepted
Accepted
34.14
from collections import Counter N = int(eval(input())) S = [] for _ in range(N): S.append(eval(input())) counter = Counter(S) max_val = max(counter.values()) ans = [] for key, value in list(counter.items()): if value == max_val: ans.append(key) ans = sorted(ans) for s in ans: ...
from collections import Counter N = int(eval(input())) S = [eval(input()) for _ in range(N)] counter = Counter(S) maxv = max(counter.values()) ans = [] for k, v in list(counter.items()): if v == maxv: ans.append(k) ans.sort() for s in ans: print(s)
19
16
311
266
from collections import Counter N = int(eval(input())) S = [] for _ in range(N): S.append(eval(input())) counter = Counter(S) max_val = max(counter.values()) ans = [] for key, value in list(counter.items()): if value == max_val: ans.append(key) ans = sorted(ans) for s in ans: print(s)
from collections import Counter N = int(eval(input())) S = [eval(input()) for _ in range(N)] counter = Counter(S) maxv = max(counter.values()) ans = [] for k, v in list(counter.items()): if v == maxv: ans.append(k) ans.sort() for s in ans: print(s)
false
15.789474
[ "-S = []", "-for _ in range(N):", "- S.append(eval(input()))", "+S = [eval(input()) for _ in range(N)]", "-max_val = max(counter.values())", "+maxv = max(counter.values())", "-for key, value in list(counter.items()):", "- if value == max_val:", "- ans.append(key)", "-ans = sorted(ans)...
false
0.085081
0.034991
2.43149
[ "s718173478", "s528930233" ]
u134302690
p03137
python
s881424846
s343474916
126
109
13,968
13,968
Accepted
Accepted
13.49
N, M = list(map(int, input().split())) X = list(map(int, input().split())) if N >= M: print((0)) else: X.sort() X_div = [0] * (M-1) for i in range(1,M): X_div[i-1] = X[i] - X[i-1] X_div.sort(reverse=True) m = 0 for i in range(N-1): m += X_div[i] print((X[-1]-...
N,M = list(map(int,input().split())) x = list(map(int,input().split())) x.sort() l = [0]*(M) for i in range(1,M): l[i] = x[i]-x[i-1] l.sort(reverse=True) print((sum(l[(N-1):])))
14
8
319
180
N, M = list(map(int, input().split())) X = list(map(int, input().split())) if N >= M: print((0)) else: X.sort() X_div = [0] * (M - 1) for i in range(1, M): X_div[i - 1] = X[i] - X[i - 1] X_div.sort(reverse=True) m = 0 for i in range(N - 1): m += X_div[i] print((X[-1] - X[...
N, M = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() l = [0] * (M) for i in range(1, M): l[i] = x[i] - x[i - 1] l.sort(reverse=True) print((sum(l[(N - 1) :])))
false
42.857143
[ "-X = list(map(int, input().split()))", "-if N >= M:", "- print((0))", "-else:", "- X.sort()", "- X_div = [0] * (M - 1)", "- for i in range(1, M):", "- X_div[i - 1] = X[i] - X[i - 1]", "- X_div.sort(reverse=True)", "- m = 0", "- for i in range(N - 1):", "- m ...
false
0.044834
0.042161
1.063395
[ "s881424846", "s343474916" ]
u312025627
p02792
python
s430115856
s146769717
212
79
40,428
67,932
Accepted
Accepted
62.74
def main(): N = int(eval(input())) c = [[0]*10 for _ in range(10)] for n in range(1, N+1): s = str(n) c[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): # if c[i][j]*c[j][i]: # print(i, j, c[i][j]*c[j][i])...
def main(): N = int(eval(input())) C = [[0]*10 for _ in range(10)] for num in range(1, N+1): s = str(num) px = int(s[0]) sf = int(s[-1]) C[px][sf] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += C[i][j] * C[j][i] p...
18
17
440
368
def main(): N = int(eval(input())) c = [[0] * 10 for _ in range(10)] for n in range(1, N + 1): s = str(n) c[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): # if c[i][j]*c[j][i]: # print(i, j, c[i][j]*c[j][i]) ...
def main(): N = int(eval(input())) C = [[0] * 10 for _ in range(10)] for num in range(1, N + 1): s = str(num) px = int(s[0]) sf = int(s[-1]) C[px][sf] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += C[i][j] * C[j][i] print(ans...
false
5.555556
[ "- c = [[0] * 10 for _ in range(10)]", "- for n in range(1, N + 1):", "- s = str(n)", "- c[int(s[0])][int(s[-1])] += 1", "+ C = [[0] * 10 for _ in range(10)]", "+ for num in range(1, N + 1):", "+ s = str(num)", "+ px = int(s[0])", "+ sf = int(s[-1])", ...
false
0.060852
0.058585
1.038684
[ "s430115856", "s146769717" ]
u241159583
p03107
python
s367663165
s845272267
20
18
3,956
3,188
Accepted
Accepted
10
S = list(eval(input())) n = len(S) red = S.count("0") blue = n - red print((n if red == blue else n - abs(red - blue)))
S = eval(input()) n = len(S) red = S.count("0") blue = n - red print((n if red == blue else min(red, blue) * 2))
5
5
115
108
S = list(eval(input())) n = len(S) red = S.count("0") blue = n - red print((n if red == blue else n - abs(red - blue)))
S = eval(input()) n = len(S) red = S.count("0") blue = n - red print((n if red == blue else min(red, blue) * 2))
false
0
[ "-S = list(eval(input()))", "+S = eval(input())", "-print((n if red == blue else n - abs(red - blue)))", "+print((n if red == blue else min(red, blue) * 2))" ]
false
0.044165
0.040716
1.084726
[ "s367663165", "s845272267" ]
u746419473
p03637
python
s085230202
s992797693
71
64
14,224
14,252
Accepted
Accepted
9.86
n = int(eval(input())) *a, = list(map(int, input().split())) *b, = [x for x in a if x%4 != 0] mul_4 = n-len(b) *c, = [x for x in b if x%2 != 0] mul_2 = (len(b)-len(c)) k = n-(mul_4+mul_2) if mul_2 == 0 and k <= mul_4+1: print("Yes") elif k <= mul_4: print("Yes") else: print("No")
n = int(eval(input())) *a, = list(map(int, input().split())) b1 = 0 b2 = 0 b4 = 0 for _a in a: if _a%4 == 0: b4 += 1 elif _a%2 == 0: b2 += 1 else: b1 += 1 if b2 == 0: print(("Yes" if b1 <= b4+1 else "No")) else: print(("Yes" if b1 <= b4 else "No"))
17
18
307
296
n = int(eval(input())) (*a,) = list(map(int, input().split())) (*b,) = [x for x in a if x % 4 != 0] mul_4 = n - len(b) (*c,) = [x for x in b if x % 2 != 0] mul_2 = len(b) - len(c) k = n - (mul_4 + mul_2) if mul_2 == 0 and k <= mul_4 + 1: print("Yes") elif k <= mul_4: print("Yes") else: print("No")
n = int(eval(input())) (*a,) = list(map(int, input().split())) b1 = 0 b2 = 0 b4 = 0 for _a in a: if _a % 4 == 0: b4 += 1 elif _a % 2 == 0: b2 += 1 else: b1 += 1 if b2 == 0: print(("Yes" if b1 <= b4 + 1 else "No")) else: print(("Yes" if b1 <= b4 else "No"))
false
5.555556
[ "-(*b,) = [x for x in a if x % 4 != 0]", "-mul_4 = n - len(b)", "-(*c,) = [x for x in b if x % 2 != 0]", "-mul_2 = len(b) - len(c)", "-k = n - (mul_4 + mul_2)", "-if mul_2 == 0 and k <= mul_4 + 1:", "- print(\"Yes\")", "-elif k <= mul_4:", "- print(\"Yes\")", "+b1 = 0", "+b2 = 0", "+b4 =...
false
0.046196
0.043003
1.074253
[ "s085230202", "s992797693" ]
u201234972
p02996
python
s133971799
s457559748
814
544
29,392
29,400
Accepted
Accepted
33.17
#import sys #input = sys.stdin.readline def main(): N = int( eval(input())) T = [ (0,0)]*N for i in range(N): a, b = list(map( int, input().split())) T[i] = (b,a) T.sort() time = 0 ans = "Yes" for i in range(N): time += T[i][1] if time > T[i][0]: ...
import sys input = sys.stdin.readline def main(): N = int( eval(input())) T = [ (0,0)]*N for i in range(N): a, b = list(map( int, input().split())) T[i] = (b,a) T.sort() time = 0 ans = "Yes" for i in range(N): time += T[i][1] if time > T[i][0]: ...
19
19
407
405
# import sys # input = sys.stdin.readline def main(): N = int(eval(input())) T = [(0, 0)] * N for i in range(N): a, b = list(map(int, input().split())) T[i] = (b, a) T.sort() time = 0 ans = "Yes" for i in range(N): time += T[i][1] if time > T[i][0]: ...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) T = [(0, 0)] * N for i in range(N): a, b = list(map(int, input().split())) T[i] = (b, a) T.sort() time = 0 ans = "Yes" for i in range(N): time += T[i][1] if time > T[i][0]: ...
false
0
[ "-# import sys", "-# input = sys.stdin.readline", "+import sys", "+", "+input = sys.stdin.readline", "+", "+" ]
false
0.047181
0.046546
1.013642
[ "s133971799", "s457559748" ]
u112364985
p02924
python
s973024685
s458557205
31
27
9,092
8,980
Accepted
Accepted
12.9
n=int(eval(input())) print((n*(n+1)//2-n))
n=int(eval(input())) print((n*(n-1)//2))
2
2
35
33
n = int(eval(input())) print((n * (n + 1) // 2 - n))
n = int(eval(input())) print((n * (n - 1) // 2))
false
0
[ "-print((n * (n + 1) // 2 - n))", "+print((n * (n - 1) // 2))" ]
false
0.039073
0.04465
0.87509
[ "s973024685", "s458557205" ]
u254871849
p03637
python
s558420205
s747541465
71
64
14,052
14,052
Accepted
Accepted
9.86
from sys import stdin n, *a = list(map(int, stdin.read().split())) c2, c4 = 0, 0 for i in a: if i % 2 == 0: c2 += 1 if i % 4 == 0: c4 += 1 if c4 >= len(a) // 2: ans = "Yes" elif (len(a) - c4 * 2) == (c2 - c4): ans = "Yes" else: ans = "No" print(ans)
from sys import stdin n, *a = list(map(int, stdin.read().split())) c2, c4 = 0, 0 for i in a: if i % 2 == 0: if i % 4 == 0: c4 += 1 else: c2 += 1 if c4 >= len(a) // 2: ans = "Yes" elif (len(a) - c4 * 2) == c2: ans = "Yes" else: ans = "No" print(ans)
12
15
264
303
from sys import stdin n, *a = list(map(int, stdin.read().split())) c2, c4 = 0, 0 for i in a: if i % 2 == 0: c2 += 1 if i % 4 == 0: c4 += 1 if c4 >= len(a) // 2: ans = "Yes" elif (len(a) - c4 * 2) == (c2 - c4): ans = "Yes" else: ans = "No" print(ans)
from sys import stdin n, *a = list(map(int, stdin.read().split())) c2, c4 = 0, 0 for i in a: if i % 2 == 0: if i % 4 == 0: c4 += 1 else: c2 += 1 if c4 >= len(a) // 2: ans = "Yes" elif (len(a) - c4 * 2) == c2: ans = "Yes" else: ans = "No" print(ans)
false
20
[ "- c2 += 1", "- if i % 4 == 0:", "- c4 += 1", "+ if i % 4 == 0:", "+ c4 += 1", "+ else:", "+ c2 += 1", "-elif (len(a) - c4 * 2) == (c2 - c4):", "+elif (len(a) - c4 * 2) == c2:" ]
false
0.044
0.037363
1.177643
[ "s558420205", "s747541465" ]
u075012704
p02948
python
s368499691
s600102118
944
588
84,536
31,964
Accepted
Accepted
37.71
import heapq N, M = list(map(int, input().split())) Work = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0]) ans = 0 can_work = [] i = 0 for m in range(M + 1): while (i < N) and (Work[i][0]) <= m: heapq.heappush(can_work, -Work[i][1]) i += 1 if can_work:...
import heapq N, M = list(map(int, input().split())) works = sorted([list(map(int, input().split())) for i in range(N)]) ans = 0 hq = [] i = 0 for limit in range(1, M + 1): while (i < N) and (works[i][0] <= limit): cost, value = works[i] heapq.heappush(hq, -value) i += 1 if...
15
17
370
368
import heapq N, M = list(map(int, input().split())) Work = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0]) ans = 0 can_work = [] i = 0 for m in range(M + 1): while (i < N) and (Work[i][0]) <= m: heapq.heappush(can_work, -Work[i][1]) i += 1 if can_work: an...
import heapq N, M = list(map(int, input().split())) works = sorted([list(map(int, input().split())) for i in range(N)]) ans = 0 hq = [] i = 0 for limit in range(1, M + 1): while (i < N) and (works[i][0] <= limit): cost, value = works[i] heapq.heappush(hq, -value) i += 1 if hq: a...
false
11.764706
[ "-Work = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0])", "+works = sorted([list(map(int, input().split())) for i in range(N)])", "-can_work = []", "+hq = []", "-for m in range(M + 1):", "- while (i < N) and (Work[i][0]) <= m:", "- heapq.heappush(can_work, -Wor...
false
0.040729
0.042156
0.966155
[ "s368499691", "s600102118" ]
u715107458
p03160
python
s446959799
s780255115
788
137
268,484
14,976
Accepted
Accepted
82.61
from functools import lru_cache import sys sys.setrecursionlimit(20000000) N = int(eval(input())) heights = [int(h) for h in input().split()] # heights = [10, 30, 40, 20] # heights = [10, 10] # heights = [30, 10, 60, 10, 60, 50] # 记忆化 @lru_cache(None) def dfs(i): if i == len(heights) - 1: ...
import sys from functools import lru_cache sys.setrecursionlimit(20000000) N = int(eval(input())) heights = [int(h) for h in input().split()] # heights = [10, 30, 40, 20] # heights = [10, 10] # heights = [30, 10, 60, 10, 60, 50] # 记忆化 @lru_cache(None) def dfs(i): if i == len(heights) - 1: ...
22
34
554
876
from functools import lru_cache import sys sys.setrecursionlimit(20000000) N = int(eval(input())) heights = [int(h) for h in input().split()] # heights = [10, 30, 40, 20] # heights = [10, 10] # heights = [30, 10, 60, 10, 60, 50] # 记忆化 @lru_cache(None) def dfs(i): if i == len(heights) - 1: return 0 retu...
import sys from functools import lru_cache sys.setrecursionlimit(20000000) N = int(eval(input())) heights = [int(h) for h in input().split()] # heights = [10, 30, 40, 20] # heights = [10, 10] # heights = [30, 10, 60, 10, 60, 50] # 记忆化 @lru_cache(None) def dfs(i): if i == len(heights) - 1: return 0 retu...
false
35.294118
[ "+import sys", "-import sys", "-print((dfs(0)))", "+def helper():", "+ dp = [float(\"inf\")] * len(heights)", "+ dp[0] = 0", "+ for i in range(1, len(heights)):", "+ dp[i] = min(dp[i], dp[i - 1] + abs(heights[i] - heights[i - 1]))", "+ if i > 1:", "+ dp[i] = min(d...
false
0.040575
0.037093
1.093865
[ "s446959799", "s780255115" ]
u327465093
p02608
python
s551452560
s223531373
282
89
71,144
9,224
Accepted
Accepted
68.44
from collections import Counter N = int(eval(input())) counter = [0] * 10001 for x in range(1, N+1): n1 = x * x if n1 >= N: continue for y in range(x, N+1): n2 = n1 + y * y + x * y if n2 >= N: continue for z in range(y, N+1): n = n2 + z...
N = int(eval(input())) counter = [0] * 10001 for x in range(1, 100+1): n1 = x * x if n1 >= N: continue for y in range(x, 100+1): n2 = n1 + y * y + x * y if n2 >= N: continue for z in range(y, 100+1): n = n2 + z * z + y * z + z * x ...
25
22
660
600
from collections import Counter N = int(eval(input())) counter = [0] * 10001 for x in range(1, N + 1): n1 = x * x if n1 >= N: continue for y in range(x, N + 1): n2 = n1 + y * y + x * y if n2 >= N: continue for z in range(y, N + 1): n = n2 + z * z + y ...
N = int(eval(input())) counter = [0] * 10001 for x in range(1, 100 + 1): n1 = x * x if n1 >= N: continue for y in range(x, 100 + 1): n2 = n1 + y * y + x * y if n2 >= N: continue for z in range(y, 100 + 1): n = n2 + z * z + y * z + z * x if ...
false
12
[ "-from collections import Counter", "-", "-for x in range(1, N + 1):", "+for x in range(1, 100 + 1):", "- for y in range(x, N + 1):", "+ for y in range(x, 100 + 1):", "- for z in range(y, N + 1):", "+ for z in range(y, 100 + 1):", "- s = len(Counter([x, y, z]))", ...
false
0.041932
0.078517
0.534044
[ "s551452560", "s223531373" ]
u070201429
p03409
python
s587110442
s559787992
72
66
63,908
63,100
Accepted
Accepted
8.33
def main(): from sys import stdin def input(): return stdin.readline().strip() n = int(eval(input())) red = [tuple(map(int, input().split())) for _ in range(n)] blue = [tuple(map(int, input().split())) for _ in range(n)] red.sort() blue.sort() now = 0 for ...
def main(): from sys import stdin def input(): return stdin.readline().strip() n = int(eval(input())) red = [tuple(map(int, input().split())) for _ in range(n)] blue = [tuple(map(int, input().split())) for _ in range(n)] red.sort() blue.sort() now = 0 for ...
31
41
710
930
def main(): from sys import stdin def input(): return stdin.readline().strip() n = int(eval(input())) red = [tuple(map(int, input().split())) for _ in range(n)] blue = [tuple(map(int, input().split())) for _ in range(n)] red.sort() blue.sort() now = 0 for i in blue: ...
def main(): from sys import stdin def input(): return stdin.readline().strip() n = int(eval(input())) red = [tuple(map(int, input().split())) for _ in range(n)] blue = [tuple(map(int, input().split())) for _ in range(n)] red.sort() blue.sort() now = 0 for i in blue: ...
false
24.390244
[ "- for j in range(len(l) - 1, -1, -1):", "- if l[j][1] < i[1]:", "- red.remove(l[j])", "- now -= 1", "- break", "+ if l[0][1] > i[1]:", "+ continue", "+ # binary search", "+ left = 0", "+ right = ...
false
0.034292
0.034216
1.002207
[ "s587110442", "s559787992" ]
u495903598
p03061
python
s210412298
s761735546
210
189
14,072
14,076
Accepted
Accepted
10
# coding: utf-8 # In[1]: import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) # In[2]: #import copy #import numpy as np try: from fractions import gcd except: from math import gcd # In[ ]: # 左からn個の最大公約数を求める O(n) # 右からn個の最大公約数を求める O(n) ...
# coding: utf-8 # In[1]: import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) # In[2]: #import copy #import numpy as np try: from fractions import gcd except: from math import gcd # In[ ]: # 左からn個の最大公約数を求める O(n) # 右からn個の最大公約数を求める O(n) ...
82
69
1,070
939
# coding: utf-8 # In[1]: import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) # In[2]: # import copy # import numpy as np try: from fractions import gcd except: from math import gcd # In[ ]: # 左からn個の最大公約数を求める O(n) # 右からn個の最大公約数を求める O(n) # n個目を抜いた最大公約数は n-1個目までの公約数とn+...
# coding: utf-8 # In[1]: import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) # In[2]: # import copy # import numpy as np try: from fractions import gcd except: from math import gcd # In[ ]: # 左からn個の最大公約数を求める O(n) # 右からn個の最大公約数を求める O(n) # n個目を抜いた最大公約数は n-1個目までの公約数とn+...
false
15.853659
[ "-# In[5]:", "+# In[ ]:", "-for i in range(N):", "- # print(i, lg[i], rg[N-i-1])", "- tmp = gcd(lg[i], rg[N - i - 1])", "- # print(tmp)", "- if ans < tmp:", "- ans = tmp", "- # print(ans)", "+# ans = [0]*N", "+ans = [gcd(lg[i], rg[N - 1 - i]) for i in range(N)]", "+# for ...
false
0.044087
0.046635
0.945361
[ "s210412298", "s761735546" ]
u227082700
p02913
python
s461819450
s989714186
422
354
270,408
270,404
Accepted
Accepted
16.11
n=int(eval(input())) s=eval(input()) dp=[(n+1)*[0]for _ in range(n+1)] for i in range(1,n): for j in range(i+1,n+1): if s[i-1]==s[j-1]: dp[i][j]=dp[i-1][j-1]+1 dp[i][j]=min(dp[i][j],i,j-i) print((max(max(i)for i in dp)))
n=int(eval(input())) s=eval(input()) dp=[(n+1)*[0]for _ in range(n+1)] ans=0 for i in range(1,n): for j in range(i+1,n+1): if s[i-1]==s[j-1]: dp[i][j]=min(dp[i-1][j-1]+1,j-i) ans=max(ans,dp[i][j]) print(ans)
9
10
246
240
n = int(eval(input())) s = eval(input()) dp = [(n + 1) * [0] for _ in range(n + 1)] for i in range(1, n): for j in range(i + 1, n + 1): if s[i - 1] == s[j - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 dp[i][j] = min(dp[i][j], i, j - i) print((max(max(i) for i in dp)))
n = int(eval(input())) s = eval(input()) dp = [(n + 1) * [0] for _ in range(n + 1)] ans = 0 for i in range(1, n): for j in range(i + 1, n + 1): if s[i - 1] == s[j - 1]: dp[i][j] = min(dp[i - 1][j - 1] + 1, j - i) ans = max(ans, dp[i][j]) print(ans)
false
10
[ "+ans = 0", "- dp[i][j] = dp[i - 1][j - 1] + 1", "- dp[i][j] = min(dp[i][j], i, j - i)", "-print((max(max(i) for i in dp)))", "+ dp[i][j] = min(dp[i - 1][j - 1] + 1, j - i)", "+ ans = max(ans, dp[i][j])", "+print(ans)" ]
false
0.042901
0.043944
0.976282
[ "s461819450", "s989714186" ]
u472696272
p02831
python
s829233671
s581351521
26
17
3,060
2,940
Accepted
Accepted
34.62
num1, num2 = list(map(int, input().split())) import math def gcd(num1, num2): for i in range(min(num1, num2),0,-1): if num1%i==0 and num2%i==0: return i print((int(num1*num2/gcd(num1,num2))))
a,b = list(map(int,input().split())) def euclid(num1,num2): if num1<num2: num1,num2 = num2,num1 while num2>0: r = num1%num2 num1 = num2 num2 = r return num1 gcd = euclid(a,b) lcm = int(a*b/gcd) print(lcm)
9
13
209
231
num1, num2 = list(map(int, input().split())) import math def gcd(num1, num2): for i in range(min(num1, num2), 0, -1): if num1 % i == 0 and num2 % i == 0: return i print((int(num1 * num2 / gcd(num1, num2))))
a, b = list(map(int, input().split())) def euclid(num1, num2): if num1 < num2: num1, num2 = num2, num1 while num2 > 0: r = num1 % num2 num1 = num2 num2 = r return num1 gcd = euclid(a, b) lcm = int(a * b / gcd) print(lcm)
false
30.769231
[ "-num1, num2 = list(map(int, input().split()))", "-import math", "+a, b = list(map(int, input().split()))", "-def gcd(num1, num2):", "- for i in range(min(num1, num2), 0, -1):", "- if num1 % i == 0 and num2 % i == 0:", "- return i", "+def euclid(num1, num2):", "+ if num1 < nu...
false
0.03981
0.073505
0.541592
[ "s829233671", "s581351521" ]
u261103969
p02819
python
s466511787
s833770889
383
20
8,600
3,060
Accepted
Accepted
94.78
n = int(eval(input())) const = 10**5+100 a = [i for i in range(2,const+1)] prime = [] for i in a: prime.append(i) if i > int(n**0.5): break a = [j for j in a if j % i != 0] prime += a ans = [i for i in a if i >= n][0] print(ans)
import sys n = int(eval(input())) while True: for i in range(2, int(n**0.5+1)): if n % i == 0: break else: print(n) sys.exit() n = n + 1
19
13
267
193
n = int(eval(input())) const = 10**5 + 100 a = [i for i in range(2, const + 1)] prime = [] for i in a: prime.append(i) if i > int(n**0.5): break a = [j for j in a if j % i != 0] prime += a ans = [i for i in a if i >= n][0] print(ans)
import sys n = int(eval(input())) while True: for i in range(2, int(n**0.5 + 1)): if n % i == 0: break else: print(n) sys.exit() n = n + 1
false
31.578947
[ "+import sys", "+", "-const = 10**5 + 100", "-a = [i for i in range(2, const + 1)]", "-prime = []", "-for i in a:", "- prime.append(i)", "- if i > int(n**0.5):", "- break", "- a = [j for j in a if j % i != 0]", "-prime += a", "-ans = [i for i in a if i >= n][0]", "-print(ans)...
false
0.116401
0.036375
3.200003
[ "s466511787", "s833770889" ]
u260216890
p02713
python
s347049059
s519179079
80
59
67,728
61,812
Accepted
Accepted
26.25
k = int(eval(input())) from math import gcd ans=0 for i in range(k): ans+=i+1 for j in range(i+1, k): x=gcd(i+1,j+1) ans+=6*gcd(i+1,j+1) for l in range(j+1, k): ans+=6*gcd(x,l+1) print(ans)
n=3 k=int(eval(input())) INF=10**9+7 l=[0]*k ans=0 for i in range(k-1,-1,-1): x=i+1 temp=pow(k//x,n,INF) for j in range(2,k//x+1): temp=(temp-l[j*x-1])%INF l[i]=temp ans=(ans+x*temp)%INF print(ans)
12
14
240
234
k = int(eval(input())) from math import gcd ans = 0 for i in range(k): ans += i + 1 for j in range(i + 1, k): x = gcd(i + 1, j + 1) ans += 6 * gcd(i + 1, j + 1) for l in range(j + 1, k): ans += 6 * gcd(x, l + 1) print(ans)
n = 3 k = int(eval(input())) INF = 10**9 + 7 l = [0] * k ans = 0 for i in range(k - 1, -1, -1): x = i + 1 temp = pow(k // x, n, INF) for j in range(2, k // x + 1): temp = (temp - l[j * x - 1]) % INF l[i] = temp ans = (ans + x * temp) % INF print(ans)
false
14.285714
[ "+n = 3", "-from math import gcd", "-", "+INF = 10**9 + 7", "+l = [0] * k", "-for i in range(k):", "- ans += i + 1", "- for j in range(i + 1, k):", "- x = gcd(i + 1, j + 1)", "- ans += 6 * gcd(i + 1, j + 1)", "- for l in range(j + 1, k):", "- ans += 6 * gc...
false
0.102523
0.085638
1.197175
[ "s347049059", "s519179079" ]
u054825571
p02572
python
s459899825
s773938065
136
121
94,332
94,248
Accepted
Accepted
11.03
MOD=10**9+7 N=int(eval(input())) A=list(map(int,input().split())) a_sum=sum(A)%MOD ans=0 for a in A: a_sum-=a%MOD ans+=a_sum*a ans%=MOD print(ans)
MOD=10**9+7 N=int(eval(input())) A=list(map(int,input().split())) ans=sum(A)**2 ans-=sum([x**2 for x in A]) ans//=2 print((ans%MOD))
10
7
161
135
MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) a_sum = sum(A) % MOD ans = 0 for a in A: a_sum -= a % MOD ans += a_sum * a ans %= MOD print(ans)
MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) ans = sum(A) ** 2 ans -= sum([x**2 for x in A]) ans //= 2 print((ans % MOD))
false
30
[ "-a_sum = sum(A) % MOD", "-ans = 0", "-for a in A:", "- a_sum -= a % MOD", "- ans += a_sum * a", "- ans %= MOD", "-print(ans)", "+ans = sum(A) ** 2", "+ans -= sum([x**2 for x in A])", "+ans //= 2", "+print((ans % MOD))" ]
false
0.046599
0.113737
0.409711
[ "s459899825", "s773938065" ]
u766684188
p02834
python
s619800600
s996244420
817
597
104,352
85,844
Accepted
Accepted
26.93
import sys input=sys.stdin.readline from collections import deque class LCA: def __init__(self,v,Edges,root=0): self.v=v self.Edges=Edges self.maxLog=18 self.Parent=[[-1]*v for _ in range(self.maxLog+1)] self.Depth=[0]*v self.__bfs(root) for i in ...
import sys input=sys.stdin.readline from collections import deque class LCA: def __init__(self,v,Edges,root=0): self.v=v self.Edges=Edges self.maxLog=18 self.Parent=[[-1]*v for _ in range(self.maxLog+1)] self.Depth=[0]*v self.__bfs(root) for i in ...
74
68
2,153
2,017
import sys input = sys.stdin.readline from collections import deque class LCA: def __init__(self, v, Edges, root=0): self.v = v self.Edges = Edges self.maxLog = 18 self.Parent = [[-1] * v for _ in range(self.maxLog + 1)] self.Depth = [0] * v self.__bfs(root) ...
import sys input = sys.stdin.readline from collections import deque class LCA: def __init__(self, v, Edges, root=0): self.v = v self.Edges = Edges self.maxLog = 18 self.Parent = [[-1] * v for _ in range(self.maxLog + 1)] self.Depth = [0] * v self.__bfs(root) ...
false
8.108108
[ "- dist = lca.dist(u, v)", "- ans = dist // 2", "+ ans = 0", "- m = lca.lca(u, l)", "- if lca.dist(u, m) >= lca.dist(v, m):", "+ if lca.dist(u, l) >= lca.dist(v, l):", "- d_u = lca.dist(u, l)", "- d_v = lca.dist(v, l)", "- d = d_v - d_u", "- ...
false
0.044575
0.157473
0.283062
[ "s619800600", "s996244420" ]
u086566114
p02412
python
s898141968
s748955745
100
40
6,332
6,376
Accepted
Accepted
60
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): if n1 + n2 + n3 == x: ans += 1 break return ans data = [] while...
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(min(n3 - 1, x - n3), (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): if n1 + n2 + n3 == x: ans += 1 break return ans dat...
25
25
589
602
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): if n1 + n2 + n3 == x: ans += 1 break return ans data = [] while True: [...
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(min(n3 - 1, x - n3), (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): if n1 + n2 + n3 == x: ans += 1 break return ans data = [] whil...
false
0
[ "- for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1):", "+ for n2 in range(min(n3 - 1, x - n3), (x - n3 + 1) / 2 - 1, -1):" ]
false
0.046697
0.043545
1.07239
[ "s898141968", "s748955745" ]
u952708174
p02691
python
s228980844
s361168121
336
172
35,296
50,892
Accepted
Accepted
48.81
def e_this_message_will_self_destruct_in_5s(): from bisect import bisect_left N = int(eval(input())) A = [int(i) for i in input().split()] add = [j + a for j, a in enumerate(A, 1)] diff = sorted([k - a for k, a in enumerate(A, 1)]) ans = 0 for p in add: ans += bisect_left(d...
def e_this_message_will_self_destruct_in_5s(): from collections import Counter N = int(eval(input())) A = [int(i) for i in input().split()] add = [j + a for j, a in enumerate(A, 1)] diff = [k - a for k, a in enumerate(A, 1)] count = Counter(diff) return sum([count[p] for p in add]) ...
13
11
416
365
def e_this_message_will_self_destruct_in_5s(): from bisect import bisect_left N = int(eval(input())) A = [int(i) for i in input().split()] add = [j + a for j, a in enumerate(A, 1)] diff = sorted([k - a for k, a in enumerate(A, 1)]) ans = 0 for p in add: ans += bisect_left(diff, p + ...
def e_this_message_will_self_destruct_in_5s(): from collections import Counter N = int(eval(input())) A = [int(i) for i in input().split()] add = [j + a for j, a in enumerate(A, 1)] diff = [k - a for k, a in enumerate(A, 1)] count = Counter(diff) return sum([count[p] for p in add]) print(...
false
15.384615
[ "- from bisect import bisect_left", "+ from collections import Counter", "- diff = sorted([k - a for k, a in enumerate(A, 1)])", "- ans = 0", "- for p in add:", "- ans += bisect_left(diff, p + 1) - bisect_left(diff, p)", "- return ans", "+ diff = [k - a for k, a in enumerat...
false
0.052115
0.035529
1.466842
[ "s228980844", "s361168121" ]
u593567568
p02769
python
s762057362
s991159864
1,996
1,660
51,516
28,044
Accepted
Accepted
16.83
import sys import numpy as np sys.setrecursionlimit(10 ** 7) # Wrong Answer # WA N, K = list(map(int, input().split())) MOD = 10 ** 9 + 7 # 階乗、Combinationコンビネーション(numpyを使う) def cumprod(arr, MOD): L = len(arr) Lsq = int(L**.5+1) arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) for n...
import sys import numpy as np sys.setrecursionlimit(10 ** 7) # Wrong Answer # WA N, K = list(map(int, input().split())) MOD = 10 ** 9 + 7 # 階乗、Combinationコンビネーション(numpyを使う) def cumprod(arr, MOD): L = len(arr) Lsq = int(L**.5+1) arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) for n...
71
71
1,365
1,469
import sys import numpy as np sys.setrecursionlimit(10**7) # Wrong Answer # WA N, K = list(map(int, input().split())) MOD = 10**9 + 7 # 階乗、Combinationコンビネーション(numpyを使う) def cumprod(arr, MOD): L = len(arr) Lsq = int(L**0.5 + 1) arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) for n in range(1, Lsq): ...
import sys import numpy as np sys.setrecursionlimit(10**7) # Wrong Answer # WA N, K = list(map(int, input().split())) MOD = 10**9 + 7 # 階乗、Combinationコンビネーション(numpyを使う) def cumprod(arr, MOD): L = len(arr) Lsq = int(L**0.5 + 1) arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) for n in range(1, Lsq): ...
false
0
[ "-fact, fact_inv = make_fact(U, MOD)", "+fact, fact_inv = make_fact(N * 2 + 10, MOD)", "+ a = int(mod_comb_k(N - 1, i, MOD)) * int(mod_comb_k(N, i, MOD))", "+ a %= MOD", "+ ans += a", "+ ans %= MOD", "- a = mod_comb_k(N - 1, i, MOD)", "- b = mod_comb_k(N, i, MOD)", "- c = a * b"...
false
0.397916
0.452686
0.87901
[ "s762057362", "s991159864" ]
u879870653
p02901
python
s969502292
s027587176
356
292
45,528
42,348
Accepted
Accepted
17.98
import sys #input = sys.stdin.readline INF = 10**12 N,M = list(map(int,input().split())) K = [] for i in range(M) : a,b = list(map(int,input().split())) s = 0 #setをbitで管理. cx = list(map(int,input().split())) for c in cx : s = s | (1 << (c-1)) #setの和集合 K.append([s, a]) #dp[bit...
import sys input = sys.stdin.readline INF = 10**12 N,M = list(map(int,input().split())) K = [] for i in range(M) : a,b = list(map(int,input().split())) s = 0 #setをbitで管理. cx = list(map(int,input().split())) for c in cx : s = s | (1 << (c-1)) #setの和集合 K.append([s, a]) #dp[bit]...
27
27
573
572
import sys # input = sys.stdin.readline INF = 10**12 N, M = list(map(int, input().split())) K = [] for i in range(M): a, b = list(map(int, input().split())) s = 0 # setをbitで管理. cx = list(map(int, input().split())) for c in cx: s = s | (1 << (c - 1)) # setの和集合 K.append([s, a]) # dp[bit]: 集...
import sys input = sys.stdin.readline INF = 10**12 N, M = list(map(int, input().split())) K = [] for i in range(M): a, b = list(map(int, input().split())) s = 0 # setをbitで管理. cx = list(map(int, input().split())) for c in cx: s = s | (1 << (c - 1)) # setの和集合 K.append([s, a]) # dp[bit]: 集合=...
false
0
[ "-# input = sys.stdin.readline", "+input = sys.stdin.readline" ]
false
0.036336
0.038336
0.947818
[ "s969502292", "s027587176" ]
u921168761
p03659
python
s112852880
s993161393
232
207
24,812
28,652
Accepted
Accepted
10.78
n = int(eval(input())) a = list(map(int, input().split())) s = [0] * (n + 1) for i in range(n): s[i + 1] = s[i] + a[i] ans = 3e9 for i in range(n - 1): ans = min(ans, abs((s[n] - s[i + 1]) - s[i + 1])) print(ans)
N=int(eval(input())) A=list(map(int,input().split())) s=[0]*(N+1) for i in range(N): s[i + 1]=s[i]+A[i] C=[0]*(N) C[0]=-s[N] x=10**10 p=0 for i in range(1, N): C[i]=C[i-1]+2*A[i-1] if x>abs(C[i]): x=abs(C[i]) p=i print(x) #print(C)
11
15
226
264
n = int(eval(input())) a = list(map(int, input().split())) s = [0] * (n + 1) for i in range(n): s[i + 1] = s[i] + a[i] ans = 3e9 for i in range(n - 1): ans = min(ans, abs((s[n] - s[i + 1]) - s[i + 1])) print(ans)
N = int(eval(input())) A = list(map(int, input().split())) s = [0] * (N + 1) for i in range(N): s[i + 1] = s[i] + A[i] C = [0] * (N) C[0] = -s[N] x = 10**10 p = 0 for i in range(1, N): C[i] = C[i - 1] + 2 * A[i - 1] if x > abs(C[i]): x = abs(C[i]) p = i print(x) # print(C)
false
26.666667
[ "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-s = [0] * (n + 1)", "-for i in range(n):", "- s[i + 1] = s[i] + a[i]", "-ans = 3e9", "-for i in range(n - 1):", "- ans = min(ans, abs((s[n] - s[i + 1]) - s[i + 1]))", "-print(ans)", "+N = int(eval(input()))", "+A = list(m...
false
0.077796
0.152558
0.509943
[ "s112852880", "s993161393" ]
u341533698
p02272
python
s158303542
s541253719
4,310
3,600
54,768
54,688
Accepted
Accepted
16.47
n = int(input()) S = list(map(int, input().split())) cnt = 0 def merge(A, left, mid, right): global cnt n1 = mid - left n2 = right - mid L = [0] * (n1+1) R = [0] * (n2+1) #L[:n1] = A[left:mid] #R[:n2] = A[mid:right] for i in range(n1): L[i] = A[left + i] for i...
n = int(input()) S = list(map(int, input().split())) cnt = 0 def merge(A, left, mid, right): global cnt n1 = mid - left n2 = right - mid L = [0] * (n1+1) R = [0] * (n2+1) L[:n1] = A[left:mid] R[:n2] = A[mid:right] #for i in xrange(n1): # L[i] = A[left + i] #for...
46
46
994
996
n = int(input()) S = list(map(int, input().split())) cnt = 0 def merge(A, left, mid, right): global cnt n1 = mid - left n2 = right - mid L = [0] * (n1 + 1) R = [0] * (n2 + 1) # L[:n1] = A[left:mid] # R[:n2] = A[mid:right] for i in range(n1): L[i] = A[left + i] for i in rang...
n = int(input()) S = list(map(int, input().split())) cnt = 0 def merge(A, left, mid, right): global cnt n1 = mid - left n2 = right - mid L = [0] * (n1 + 1) R = [0] * (n2 + 1) L[:n1] = A[left:mid] R[:n2] = A[mid:right] # for i in xrange(n1): # L[i] = A[left + i] # for i in xr...
false
0
[ "- # L[:n1] = A[left:mid]", "- # R[:n2] = A[mid:right]", "- for i in range(n1):", "- L[i] = A[left + i]", "- for i in range(n2):", "- R[i] = A[mid + i]", "+ L[:n1] = A[left:mid]", "+ R[:n2] = A[mid:right]", "+ # for i in xrange(n1):", "+ # L[i] = A[left + i...
false
0.043414
0.042561
1.020041
[ "s158303542", "s541253719" ]
u753803401
p03634
python
s520230446
s857744622
863
686
118,616
115,928
Accepted
Accepted
20.51
import sys import collections def solve(): input = sys.stdin.readline mod = 10 ** 9 + 7 n = int(input().rstrip('\n')) tmd = collections.defaultdict(list) tmdc = collections.defaultdict(int) for i in range(n-1): tma, tmb, tmc = list(map(int, input().rstrip('\n').split())) ...
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 n = int(readline()) tmd = collections.defaultdict(list) cl = collections.defaultdict(int) for i in range(n-1): tma, tmb, tmc = list(map(int, readline().split())) tmd[tm...
38
40
1,108
1,137
import sys import collections def solve(): input = sys.stdin.readline mod = 10**9 + 7 n = int(input().rstrip("\n")) tmd = collections.defaultdict(list) tmdc = collections.defaultdict(int) for i in range(n - 1): tma, tmb, tmc = list(map(int, input().rstrip("\n").split())) tmd[tm...
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 n = int(readline()) tmd = collections.defaultdict(list) cl = collections.defaultdict(int) for i in range(n - 1): tma, tmb, tmc = list(map(int, readline().split())) tmd[tma - 1] += [t...
false
5
[ "- input = sys.stdin.readline", "+ readline = sys.stdin.buffer.readline", "- n = int(input().rstrip(\"\\n\"))", "+ n = int(readline())", "- tmdc = collections.defaultdict(int)", "+ cl = collections.defaultdict(int)", "- tma, tmb, tmc = list(map(int, input().rstrip(\"\\n\").split...
false
0.040779
0.037128
1.098334
[ "s520230446", "s857744622" ]
u188827677
p02996
python
s067306293
s018177603
919
633
53,600
48,656
Accepted
Accepted
31.12
n = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda i: i[1]) t = 0 for i in ab: t += i[0] if t > i[1]: print("No") exit() print("Yes")
n = int(eval(input())) ab = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda i: i[1]) t = 0 for i in ab: t += i[0] if t > i[1]: print("No") exit() print("Yes")
11
10
198
199
n = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda i: i[1]) t = 0 for i in ab: t += i[0] if t > i[1]: print("No") exit() print("Yes")
n = int(eval(input())) ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda i: i[1]) t = 0 for i in ab: t += i[0] if t > i[1]: print("No") exit() print("Yes")
false
9.090909
[ "-ab = [list(map(int, input().split())) for _ in range(n)]", "-ab.sort(key=lambda i: i[1])", "+ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda i: i[1])" ]
false
0.037196
0.036774
1.011456
[ "s067306293", "s018177603" ]
u191874006
p02793
python
s522397683
s908852533
1,062
397
71,784
52,828
Accepted
Accepted
62.62
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
40
55
862
1,240
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
false
27.272727
[ "-def gcd(a, b):", "- if b == 0:", "- return a", "- else:", "- return gcd(b, a % b)", "-", "-", "-def lcm(a, b):", "- return a * b // gcd(a, b)", "+def factorization(n):", "+ arr = []", "+ temp = n", "+ for i in range(2, int(-(-(n**0.5) // 1)) + 1):", "+ ...
false
0.036504
0.442979
0.082406
[ "s522397683", "s908852533" ]
u638795007
p03111
python
s983351555
s289280984
298
192
50,416
10,588
Accepted
Accepted
35.57
def examC(): N, A, B, C = LI() L = [I() for _ in range(N)] loop = 4**N; ans = 10**9 for i in range(loop): cur = 0 curA = 0; curB = 0; curC = 0 for j in range(N): judge = (i//(4**j))%4 if judge==1: if curA>0: c...
def examA(): N = DI()/dec(7) ans = N print(N) return def examB(): ans = 0 print(ans) return def examC(): N, A, B, C = LI() L = [I()for _ in range(N)] loop = (1<<(2*N)) ans = inf for l in range(loop): cost = 0 bamboo_A = 0 bambo...
42
123
1,267
2,977
def examC(): N, A, B, C = LI() L = [I() for _ in range(N)] loop = 4**N ans = 10**9 for i in range(loop): cur = 0 curA = 0 curB = 0 curC = 0 for j in range(N): judge = (i // (4**j)) % 4 if judge == 1: if curA > 0: ...
def examA(): N = DI() / dec(7) ans = N print(N) return def examB(): ans = 0 print(ans) return def examC(): N, A, B, C = LI() L = [I() for _ in range(N)] loop = 1 << (2 * N) ans = inf for l in range(loop): cost = 0 bamboo_A = 0 bamboo_B = 0 ...
false
65.853659
[ "+def examA():", "+ N = DI() / dec(7)", "+ ans = N", "+ print(N)", "+ return", "+", "+", "+def examB():", "+ ans = 0", "+ print(ans)", "+ return", "+", "+", "- loop = 4**N", "- ans = 10**9", "- for i in range(loop):", "- cur = 0", "- curA...
false
0.202483
0.16927
1.196212
[ "s983351555", "s289280984" ]
u442877951
p03568
python
s933004077
s039806615
32
29
9,100
9,128
Accepted
Accepted
9.38
N = int(eval(input())) A = list(map(int,input().split())) odd_count = 1 for a in A: if a%2 != 0: odd_count *= 1 else: odd_count *= 2 print((3**N - odd_count))
N = int(eval(input())) A = list(map(int,input().split())) odd_count = 1 for a in A: if a%2 == 0: odd_count *= 2 print((3**N - odd_count))
12
10
176
147
N = int(eval(input())) A = list(map(int, input().split())) odd_count = 1 for a in A: if a % 2 != 0: odd_count *= 1 else: odd_count *= 2 print((3**N - odd_count))
N = int(eval(input())) A = list(map(int, input().split())) odd_count = 1 for a in A: if a % 2 == 0: odd_count *= 2 print((3**N - odd_count))
false
16.666667
[ "- if a % 2 != 0:", "- odd_count *= 1", "- else:", "+ if a % 2 == 0:" ]
false
0.049039
0.049175
0.997217
[ "s933004077", "s039806615" ]
u332385682
p03818
python
s011965612
s874832079
76
63
22,636
19,316
Accepted
Accepted
17.11
import sys from collections import Counter def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG: {} -> {}'.format(name, val), file=sys.stderr) return None N = int(input()) cnt_A = Counter(map(int, input().split())) # debug(cnt_A, locals()) # ...
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG: {} -> {}'.format(name, val), file=sys.stderr) return None N = int(input()) A = set(map(int, input().split())) # debug(A, locals()) m = len(A) if m % 2 == 0: ans = m - 1 ...
23
20
499
352
import sys from collections import Counter def debug(x, table): for name, val in table.items(): if x is val: print("DEBUG: {} -> {}".format(name, val), file=sys.stderr) return None N = int(input()) cnt_A = Counter(map(int, input().split())) # debug(cnt_A, locals()) # debug(cnt_A....
import sys def debug(x, table): for name, val in table.items(): if x is val: print("DEBUG: {} -> {}".format(name, val), file=sys.stderr) return None N = int(input()) A = set(map(int, input().split())) # debug(A, locals()) m = len(A) if m % 2 == 0: ans = m - 1 else: ans = ...
false
13.043478
[ "-from collections import Counter", "-cnt_A = Counter(map(int, input().split()))", "-# debug(cnt_A, locals())", "-# debug(cnt_A.values(), locals())", "-dabuli = sum(cnt_A.values()) - len(cnt_A.values())", "-if dabuli % 2 == 0:", "- ans = N - dabuli", "+A = set(map(int, input().split()))", "+# deb...
false
0.036371
0.039563
0.919309
[ "s011965612", "s874832079" ]
u077291787
p02993
python
s783861352
s460458777
19
17
2,940
2,940
Accepted
Accepted
10.53
# ABC131A - Security def main(): s = eval(input()) flg = all(s[i] != s[i + 1] for i in range(len(s) - 1)) print(("Good" if flg else "Bad")) if __name__ == "__main__": main()
# ABC131A - Security def main(): s = eval(input()) if all(i != j for i, j in zip(s, s[1:])): print("Good") else: print("Bad") if __name__ == "__main__": main()
9
11
191
198
# ABC131A - Security def main(): s = eval(input()) flg = all(s[i] != s[i + 1] for i in range(len(s) - 1)) print(("Good" if flg else "Bad")) if __name__ == "__main__": main()
# ABC131A - Security def main(): s = eval(input()) if all(i != j for i, j in zip(s, s[1:])): print("Good") else: print("Bad") if __name__ == "__main__": main()
false
18.181818
[ "- flg = all(s[i] != s[i + 1] for i in range(len(s) - 1))", "- print((\"Good\" if flg else \"Bad\"))", "+ if all(i != j for i, j in zip(s, s[1:])):", "+ print(\"Good\")", "+ else:", "+ print(\"Bad\")" ]
false
0.037616
0.070174
0.536038
[ "s783861352", "s460458777" ]
u332906195
p03476
python
s956321727
s091259306
1,167
1,019
5,732
53,196
Accepted
Accepted
12.68
def primes(N): '''Sieve of Eratosthenes''' p = [False, False] + [True] * (N - 1) for i in range(2, int(N ** 0.5) + 1): if p[i]: for j in range(i * 2, N + 1, i): p[j] = False return p p, c = primes(10 ** 5), [0] for i in range(1, 10 ** 5 + 1): c.appen...
def primes(N): p = [False, False] + [True] * (N - 1) for i in range(2, int(N ** 0.5) + 1): if p[i]: for j in range(i * 2, N + 1, i): p[j] = False return p p, c = primes(10 ** 5), [0] for i in range(1, 10 ** 5 + 1): c.append(c[-1] + 1 if p[i] and p[(i + 1)...
18
17
478
445
def primes(N): """Sieve of Eratosthenes""" p = [False, False] + [True] * (N - 1) for i in range(2, int(N**0.5) + 1): if p[i]: for j in range(i * 2, N + 1, i): p[j] = False return p p, c = primes(10**5), [0] for i in range(1, 10**5 + 1): c.append(c[-1] + 1 if p[i...
def primes(N): p = [False, False] + [True] * (N - 1) for i in range(2, int(N**0.5) + 1): if p[i]: for j in range(i * 2, N + 1, i): p[j] = False return p p, c = primes(10**5), [0] for i in range(1, 10**5 + 1): c.append(c[-1] + 1 if p[i] and p[(i + 1) // 2] else c[-1]...
false
5.555556
[ "- \"\"\"Sieve of Eratosthenes\"\"\"" ]
false
0.117571
0.083516
1.407761
[ "s956321727", "s091259306" ]
u380524497
p03645
python
s454895579
s224709557
416
157
65,908
44,752
Accepted
Accepted
62.26
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) edges = [set() for _ in range(n)] for _ in range(m): _from, to = list(map(int, input().split())) edges[_from-1].add(to-1) first = list(edges[0]) possible = False while first: island = first.pop() if n-1 in ...
import sys buf = sys.stdin.buffer n, m = list(map(int, buf.readline().split())) AB = list(map(int, buf.read().split())) reachable_from_start = set() reachable_to_goal = set() for a, b in zip(AB,AB): if a == 1: reachable_from_start.add(b) if b == n: reachable_to_goal.add(a) possi...
24
19
435
453
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) edges = [set() for _ in range(n)] for _ in range(m): _from, to = list(map(int, input().split())) edges[_from - 1].add(to - 1) first = list(edges[0]) possible = False while first: island = first.pop() if n - 1 in edges[island]:...
import sys buf = sys.stdin.buffer n, m = list(map(int, buf.readline().split())) AB = list(map(int, buf.read().split())) reachable_from_start = set() reachable_to_goal = set() for a, b in zip(AB, AB): if a == 1: reachable_from_start.add(b) if b == n: reachable_to_goal.add(a) possible = reachable...
false
20.833333
[ "-input = sys.stdin.readline", "-n, m = list(map(int, input().split()))", "-edges = [set() for _ in range(n)]", "-for _ in range(m):", "- _from, to = list(map(int, input().split()))", "- edges[_from - 1].add(to - 1)", "-first = list(edges[0])", "-possible = False", "-while first:", "- isl...
false
0.039167
0.041825
0.93644
[ "s454895579", "s224709557" ]
u926046014
p02773
python
s058010622
s485233659
628
506
51,792
38,584
Accepted
Accepted
19.43
from collections import Counter n = int(eval(input())) s = [] for i in range(n): s.append(eval(input())) c = Counter(s) d = c.most_common() t = [] t.append(d[0]) cnt = 1 if len(d)>1: for i in range(len(d)-1): if d[i+1][1]==t[0][1]: t.append(d[i+1]) cnt+=1 ...
n=int(eval(input())) ar = [] for i in range(n): a = eval(input()) ar.append(a) dic = {} for i in range(n): if ar[i] not in dic: dic[ar[i]]=1 else: dic[ar[i]]+=1 highest = max(dic.values()) ans = [] for keys in list(dic.keys()): if dic[keys] == highest: an...
28
23
438
366
from collections import Counter n = int(eval(input())) s = [] for i in range(n): s.append(eval(input())) c = Counter(s) d = c.most_common() t = [] t.append(d[0]) cnt = 1 if len(d) > 1: for i in range(len(d) - 1): if d[i + 1][1] == t[0][1]: t.append(d[i + 1]) cnt += 1 els...
n = int(eval(input())) ar = [] for i in range(n): a = eval(input()) ar.append(a) dic = {} for i in range(n): if ar[i] not in dic: dic[ar[i]] = 1 else: dic[ar[i]] += 1 highest = max(dic.values()) ans = [] for keys in list(dic.keys()): if dic[keys] == highest: ans.append(keys) ...
false
17.857143
[ "-from collections import Counter", "-", "-s = []", "+ar = []", "- s.append(eval(input()))", "-c = Counter(s)", "-d = c.most_common()", "-t = []", "-t.append(d[0])", "-cnt = 1", "-if len(d) > 1:", "- for i in range(len(d) - 1):", "- if d[i + 1][1] == t[0][1]:", "- t...
false
0.038079
0.036804
1.034649
[ "s058010622", "s485233659" ]
u633068244
p00040
python
s406183810
s086786660
230
170
4,260
4,268
Accepted
Accepted
26.09
dict = ["a","b","c","d","e","f","g","h","i","j","k","l","m",\ "n","o","p","q","r","s","t","u","v","w","x","y","z"] lsalpha = [1,3,5,7,9,11,15,17,19,21,23,25] n = int(input()) for roop in range(n): code = input() for alpha in lsalpha: flag = 0 for beta in range(26): ...
dict = ["a","b","c","d","e","f","g","h","i","j","k","l","m",\ "n","o","p","q","r","s","t","u","v","w","x","y","z"] lsalpha = [1,3,5,7,9,11,15,17,19,21,23,25] def decode(alpha, beta, code): msg = "" for chara in code: if chara != " ": f = dict.index(chara) for i ...
27
31
902
895
dict = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] lsalpha = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25] n = int(input()) for ...
dict = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] lsalpha = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25] def decode(alpha, b...
false
12.903226
[ "+", "+", "+def decode(alpha, beta, code):", "+ msg = \"\"", "+ for chara in code:", "+ if chara != \" \":", "+ f = dict.index(chara)", "+ for i in range(26):", "+ if (alpha * i + beta) % 26 == f:", "+ dechara = dict[i]", "+ ...
false
0.120148
0.051162
2.348393
[ "s406183810", "s086786660" ]
u299730702
p03738
python
s040985965
s832159433
19
17
3,060
2,940
Accepted
Accepted
10.53
import math A = int(eval(input())) B = int(eval(input())) A = math.log10(A) B = math.log10(B) if A > B: print('GREATER') elif A < B: print('LESS') else: print('EQUAL')
import math A = int(eval(input())) B = int(eval(input())) #A = math.log10(A) #B = math.log10(B) if A > B: print('GREATER') elif A < B: print('LESS') else: print('EQUAL')
13
13
182
184
import math A = int(eval(input())) B = int(eval(input())) A = math.log10(A) B = math.log10(B) if A > B: print("GREATER") elif A < B: print("LESS") else: print("EQUAL")
import math A = int(eval(input())) B = int(eval(input())) # A = math.log10(A) # B = math.log10(B) if A > B: print("GREATER") elif A < B: print("LESS") else: print("EQUAL")
false
0
[ "-A = math.log10(A)", "-B = math.log10(B)", "+# A = math.log10(A)", "+# B = math.log10(B)" ]
false
0.045619
0.046961
0.971413
[ "s040985965", "s832159433" ]
u906501980
p02727
python
s368776582
s987819279
359
250
105,444
22,524
Accepted
Accepted
30.36
def main(): x, y, a, b, c = list(map(int, input().split())) al = sorted(list(map(int, input().split())), reverse=True)[:x] bl = sorted(list(map(int, input().split())), reverse=True)[:y] cl = sorted(list(map(int, input().split())), reverse=True) ans = 0 xi, yi = 0, 0 for i in cl: ...
def main(): x, y, a, b, c = list(map(int, input().split())) p = list(sorted(list(map(int, input().split())), reverse=True))[:x] q = list(sorted(list(map(int, input().split())), reverse=True))[:y] r = list(map(int, input().split())) print((sum(list(sorted(p+q+r, reverse=True))[:(x+y)]))) if __n...
37
8
901
344
def main(): x, y, a, b, c = list(map(int, input().split())) al = sorted(list(map(int, input().split())), reverse=True)[:x] bl = sorted(list(map(int, input().split())), reverse=True)[:y] cl = sorted(list(map(int, input().split())), reverse=True) ans = 0 xi, yi = 0, 0 for i in cl: if a...
def main(): x, y, a, b, c = list(map(int, input().split())) p = list(sorted(list(map(int, input().split())), reverse=True))[:x] q = list(sorted(list(map(int, input().split())), reverse=True))[:y] r = list(map(int, input().split())) print((sum(list(sorted(p + q + r, reverse=True))[: (x + y)]))) if ...
false
78.378378
[ "- al = sorted(list(map(int, input().split())), reverse=True)[:x]", "- bl = sorted(list(map(int, input().split())), reverse=True)[:y]", "- cl = sorted(list(map(int, input().split())), reverse=True)", "- ans = 0", "- xi, yi = 0, 0", "- for i in cl:", "- if al:", "- a...
false
0.038083
0.037701
1.010137
[ "s368776582", "s987819279" ]
u347640436
p03160
python
s681126063
s128166114
166
131
13,908
13,928
Accepted
Accepted
21.08
n = int(eval(input())) h = list(map(int, input().split())) cost = [float('inf')] * n cost[0] = 0 for i in range(n - 2): cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i])) cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i + 2] - h[i])) cost[n - 1] = min(cost[n - 1], cost[n - 2] + abs(h[n - 1] - h[n...
n = int(eval(input())) h = list(map(int, input().split())) cost = [0] * n cost[1] = abs(h[1] - h[0]) for i in range(2, n): cost[i] = min(abs(h[i] - h[i - 1]) + cost[i - 1], abs(h[i] - h[i - 2]) + cost[i - 2]) print((cost[n - 1]))
9
7
342
230
n = int(eval(input())) h = list(map(int, input().split())) cost = [float("inf")] * n cost[0] = 0 for i in range(n - 2): cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i])) cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i + 2] - h[i])) cost[n - 1] = min(cost[n - 1], cost[n - 2] + abs(h[n - 1] - h[n - ...
n = int(eval(input())) h = list(map(int, input().split())) cost = [0] * n cost[1] = abs(h[1] - h[0]) for i in range(2, n): cost[i] = min( abs(h[i] - h[i - 1]) + cost[i - 1], abs(h[i] - h[i - 2]) + cost[i - 2] ) print((cost[n - 1]))
false
22.222222
[ "-cost = [float(\"inf\")] * n", "-cost[0] = 0", "-for i in range(n - 2):", "- cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]))", "- cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i + 2] - h[i]))", "-cost[n - 1] = min(cost[n - 1], cost[n - 2] + abs(h[n - 1] - h[n - 2]))", "+cost = [0]...
false
0.110957
0.042552
2.607556
[ "s681126063", "s128166114" ]
u631914718
p03163
python
s401689997
s405568523
324
174
21,372
14,568
Accepted
Accepted
46.3
import numpy as np N, W = list(map(int, input().split())) ndp = np.zeros(W+1, dtype= np.int64) for _ in range(N): w, v = list(map(int,input().split())) # 離散より連続で扱った方が簡単になる。 np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:]) print((ndp[-1])) """ https://atcoder.jp/contests/dp/submissions/6657472...
import numpy as np N,W = list(map(int,input().split())) ndp = np.zeros(W+1,dtype= np.int64) for _ in range(N): w,v = list(map(int,input().split())) np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:]) print((ndp[-1]))
17
7
335
214
import numpy as np N, W = list(map(int, input().split())) ndp = np.zeros(W + 1, dtype=np.int64) for _ in range(N): w, v = list(map(int, input().split())) # 離散より連続で扱った方が簡単になる。 np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:]) print((ndp[-1])) """ https://atcoder.jp/contests/dp/submissions/6657472 より失敬。 めっちゃスマー...
import numpy as np N, W = list(map(int, input().split())) ndp = np.zeros(W + 1, dtype=np.int64) for _ in range(N): w, v = list(map(int, input().split())) np.maximum(ndp[:-w] + v, ndp[w:], out=ndp[w:]) print((ndp[-1]))
false
58.823529
[ "- # 離散より連続で扱った方が簡単になる。", "-\"\"\"", "-https://atcoder.jp/contests/dp/submissions/6657472", "-より失敬。", "-めっちゃスマートな解法。", "-\"\"\"" ]
false
0.160603
0.171184
0.93819
[ "s401689997", "s405568523" ]
u993622994
p03126
python
s126339027
s513299658
20
17
3,060
3,060
Accepted
Accepted
15
n, m = list(map(int, input().split())) ka = [list(map(int, input().split())) for i in range(n)] ans = [0] * m for i in range(n): for j in range(1, len(ka[i])): for k in range(1, m+1): if ka[i][j] == k: ans[k-1] += 1 break print((ans.count(n)))
n, m = list(map(int, input().split())) ka = [list(map(int, input().split())) for i in range(n)] ans = [0] * m for i in range(n): for j in ka[i][1:]: ans[j-1] += 1 print((ans.count(n)))
12
9
304
198
n, m = list(map(int, input().split())) ka = [list(map(int, input().split())) for i in range(n)] ans = [0] * m for i in range(n): for j in range(1, len(ka[i])): for k in range(1, m + 1): if ka[i][j] == k: ans[k - 1] += 1 break print((ans.count(n)))
n, m = list(map(int, input().split())) ka = [list(map(int, input().split())) for i in range(n)] ans = [0] * m for i in range(n): for j in ka[i][1:]: ans[j - 1] += 1 print((ans.count(n)))
false
25
[ "- for j in range(1, len(ka[i])):", "- for k in range(1, m + 1):", "- if ka[i][j] == k:", "- ans[k - 1] += 1", "- break", "+ for j in ka[i][1:]:", "+ ans[j - 1] += 1" ]
false
0.069365
0.053961
1.28547
[ "s126339027", "s513299658" ]
u301624971
p03814
python
s180653916
s365046971
31
18
3,516
3,516
Accepted
Accepted
41.94
def myAnswer(s:str) -> int: start = 0 end = 0 for n,string in enumerate(s): if(string =="A"): start = n break for n,string in enumerate(s[::-1]): if(string == "Z"): end = len(s) - n break return end - start def modelAnswer(): tmp=1...
def myAnswer2(s:str) -> int: return len(s)-s[::-1].index("Z") - s.index("A") def main(): s = (eval(input())) print((myAnswer2(s))) if __name__ == '__main__': main()
25
9
415
178
def myAnswer(s: str) -> int: start = 0 end = 0 for n, string in enumerate(s): if string == "A": start = n break for n, string in enumerate(s[::-1]): if string == "Z": end = len(s) - n break return end - start def modelAnswer(): tm...
def myAnswer2(s: str) -> int: return len(s) - s[::-1].index("Z") - s.index("A") def main(): s = eval(input()) print((myAnswer2(s))) if __name__ == "__main__": main()
false
64
[ "-def myAnswer(s: str) -> int:", "- start = 0", "- end = 0", "- for n, string in enumerate(s):", "- if string == \"A\":", "- start = n", "- break", "- for n, string in enumerate(s[::-1]):", "- if string == \"Z\":", "- end = len(s) - n", ...
false
0.035561
0.038796
0.916605
[ "s180653916", "s365046971" ]
u680851063
p02947
python
s951248496
s715076297
551
439
20,860
11,408
Accepted
Accepted
20.33
# n = int(eval(input())) s = [] for _ in range(n): #s.append(list(input())) # !!! #s.append(sorted(list(input()))) # !!! #s.append(sorted(input())) # !!! s.append([''.join(sorted(eval(input())))]) #s += [''.join(sorted(input()))] #''.join(sorted((sorted(input())) s = sorted(s) #print(...
# 2回目のソートに気づけずTLE、納得のアルゴリズム n = int(eval(input())) s = [] for _ in range(n): #文字列の各要素をソートしリストに格納 #s.append(list(input())) # !!! #s.append(sorted(list(input()))) # !!! #s.append(sorted(input())) # !!! #s.append([''.join(sorted(input()))]) s += [''.join(sorted(eval(input())))] # appendよりも'+='の...
30
29
531
620
# n = int(eval(input())) s = [] for _ in range(n): # s.append(list(input())) # !!! # s.append(sorted(list(input()))) # !!! # s.append(sorted(input())) # !!! s.append(["".join(sorted(eval(input())))]) # s += [''.join(sorted(input()))] #''.join(sorted((sorted(input())) s = sorted(s) # print(s) a =...
# 2回目のソートに気づけずTLE、納得のアルゴリズム n = int(eval(input())) s = [] for _ in range(n): # 文字列の各要素をソートしリストに格納 # s.append(list(input())) # !!! # s.append(sorted(list(input()))) # !!! # s.append(sorted(input())) # !!! # s.append([''.join(sorted(input()))]) s += ["".join(sorted(eval(input())))] # appendよりも'+='の方...
false
3.333333
[ "-#", "+# 2回目のソートに気づけずTLE、納得のアルゴリズム", "-for _ in range(n):", "+for _ in range(n): # 文字列の各要素をソートしリストに格納", "- s.append([\"\".join(sorted(eval(input())))])", "- # s += [''.join(sorted(input()))]", "- #''.join(sorted((sorted(input()))", "-s = sorted(s)", "+ # s.append([''.join(sorted(input(...
false
0.03669
0.038748
0.946894
[ "s951248496", "s715076297" ]
u905895868
p03272
python
s221574635
s735672700
29
24
9,040
9,148
Accepted
Accepted
17.24
train_len, target_vehicle = list(map(int, input().split())) target_from_backside = train_len - (target_vehicle - 1) print(target_from_backside)
n, i = list(map(int, input().split())) print((n - i + 1))
4
3
142
53
train_len, target_vehicle = list(map(int, input().split())) target_from_backside = train_len - (target_vehicle - 1) print(target_from_backside)
n, i = list(map(int, input().split())) print((n - i + 1))
false
25
[ "-train_len, target_vehicle = list(map(int, input().split()))", "-target_from_backside = train_len - (target_vehicle - 1)", "-print(target_from_backside)", "+n, i = list(map(int, input().split()))", "+print((n - i + 1))" ]
false
0.037733
0.037888
0.995901
[ "s221574635", "s735672700" ]
u943057856
p03557
python
s801009350
s589827840
336
244
23,092
29,316
Accepted
Accepted
27.38
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: x=bisect.bisect_left(a,i) y=n-bisect.bisect_right(c,i) ans+=x*y print(ans)
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: A=bisect.bisect_left(a,i) B=len(b)-bisect.bisect_right(c,i) ans+=A*B print(ans)
11
11
266
271
import bisect n = int(eval(input())) a = sorted(list(map(int, input().split()))) b = sorted(list(map(int, input().split()))) c = sorted(list(map(int, input().split()))) ans = 0 for i in b: x = bisect.bisect_left(a, i) y = n - bisect.bisect_right(c, i) ans += x * y print(ans)
import bisect n = int(eval(input())) a = sorted(list(map(int, input().split()))) b = sorted(list(map(int, input().split()))) c = sorted(list(map(int, input().split()))) ans = 0 for i in b: A = bisect.bisect_left(a, i) B = len(b) - bisect.bisect_right(c, i) ans += A * B print(ans)
false
0
[ "- x = bisect.bisect_left(a, i)", "- y = n - bisect.bisect_right(c, i)", "- ans += x * y", "+ A = bisect.bisect_left(a, i)", "+ B = len(b) - bisect.bisect_right(c, i)", "+ ans += A * B" ]
false
0.087001
0.04076
2.134449
[ "s801009350", "s589827840" ]
u113971909
p02727
python
s861539227
s659076059
303
234
23,328
23,472
Accepted
Accepted
22.77
from heapq import heapify, heappop, heappush, heappushpop import sys input = sys.stdin.readline x,y,a,b,c=list(map(int, input().split())) p=list(map(int, input().split())) q=list(map(int, input().split())) r=list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort() p=p[:x] q=q[:y] h...
import sys input = sys.stdin.readline x,y,a,b,c=list(map(int, input().split())) p=list(map(int, input().split())) q=list(map(int, input().split())) r=list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) p=p[:x] q=q[:y] r=r+p+q r.sort(reverse=True) print((sum(r[:x+y])))
27
13
553
294
from heapq import heapify, heappop, heappush, heappushpop import sys input = sys.stdin.readline x, y, a, b, c = list(map(int, input().split())) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort() p = p[:x] q = q[...
import sys input = sys.stdin.readline x, y, a, b, c = list(map(int, input().split())) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) p = p[:x] q = q[:y] r = r + p + q r.sort(reverse=True) print((sum(r[: x + y])))
false
51.851852
[ "-from heapq import heapify, heappop, heappush, heappushpop", "-r.sort()", "-heapify(p)", "-heapify(q)", "-mp = heappop(p)", "-mq = heappop(q)", "-for ri in r:", "- if mp < mq:", "- if mp < ri:", "- heappush(p, ri)", "- mp = heappop(p)", "- else:", "- ...
false
0.037178
0.036562
1.016843
[ "s861539227", "s659076059" ]
u173148629
p02803
python
s436559619
s509664956
552
350
74,732
3,316
Accepted
Accepted
36.59
H,W=list(map(int,input().split())) S=[] for _ in range(H): S.append(list(eval(input()))) from collections import deque que=deque() maxx=0 for i in range(H): for j in range(W): if S[i][j]=="#": continue ans=[[500]*W for _ in range(H)] ans[i][j]=0 que...
H,W=list(map(int,input().split())) S=[] for _ in range(H): S.append(list(eval(input()))) from collections import deque que=deque() maxx=0 for i in range(H): for j in range(W): if S[i][j]=="#": continue ans=[[-1]*W for _ in range(H)] ans[i][j]=0 que....
37
37
1,091
1,086
H, W = list(map(int, input().split())) S = [] for _ in range(H): S.append(list(eval(input()))) from collections import deque que = deque() maxx = 0 for i in range(H): for j in range(W): if S[i][j] == "#": continue ans = [[500] * W for _ in range(H)] ans[i][j] = 0 que...
H, W = list(map(int, input().split())) S = [] for _ in range(H): S.append(list(eval(input()))) from collections import deque que = deque() maxx = 0 for i in range(H): for j in range(W): if S[i][j] == "#": continue ans = [[-1] * W for _ in range(H)] ans[i][j] = 0 que....
false
0
[ "- ans = [[500] * W for _ in range(H)]", "+ ans = [[-1] * W for _ in range(H)]", "- if ans[h - 1][w] == 500:", "+ if ans[h - 1][w] == -1:", "- if ans[h + 1][w] == 500:", "+ if ans[h + 1][w] == -1:", "- if ans[h][w -...
false
0.038074
0.037803
1.007146
[ "s436559619", "s509664956" ]
u614314290
p03086
python
s695511712
s525212518
35
19
3,316
3,188
Accepted
Accepted
45.71
import re S = eval(input()) H = re.findall("[ACGT]+", S) max_length = 0 for h in H: if max_length < len(h): max_length = len(h) print(max_length)
import re H = re.findall("[ACGT]+", eval(input())) print((len(max(H, key=lambda x: len(x))) if H else 0))
8
3
150
100
import re S = eval(input()) H = re.findall("[ACGT]+", S) max_length = 0 for h in H: if max_length < len(h): max_length = len(h) print(max_length)
import re H = re.findall("[ACGT]+", eval(input())) print((len(max(H, key=lambda x: len(x))) if H else 0))
false
62.5
[ "-S = eval(input())", "-H = re.findall(\"[ACGT]+\", S)", "-max_length = 0", "-for h in H:", "- if max_length < len(h):", "- max_length = len(h)", "-print(max_length)", "+H = re.findall(\"[ACGT]+\", eval(input()))", "+print((len(max(H, key=lambda x: len(x))) if H else 0))" ]
false
0.060952
0.066195
0.920798
[ "s695511712", "s525212518" ]
u729939940
p02595
python
s574852592
s346696987
475
389
9,124
9,192
Accepted
Accepted
18.11
from math import sqrt N,D=list(map(int,input().split())) ans=0 for i in range(N): x,y=list(map(int,input().split())) if x**2+y**2<=D**2: ans+=1 print(ans)
N,D=list(map(int,input().split())) ans=0 for i in range(N): x,y=list(map(int,input().split())) if x*x+y*y<=D*D: ans+=1 print(ans)
8
7
157
131
from math import sqrt N, D = list(map(int, input().split())) ans = 0 for i in range(N): x, y = list(map(int, input().split())) if x**2 + y**2 <= D**2: ans += 1 print(ans)
N, D = list(map(int, input().split())) ans = 0 for i in range(N): x, y = list(map(int, input().split())) if x * x + y * y <= D * D: ans += 1 print(ans)
false
12.5
[ "-from math import sqrt", "-", "- if x**2 + y**2 <= D**2:", "+ if x * x + y * y <= D * D:" ]
false
0.048328
0.049026
0.985756
[ "s574852592", "s346696987" ]
u729133443
p02819
python
s028726335
s417079325
92
30
4,668
2,940
Accepted
Accepted
67.39
from subprocess import* x=int(eval(input())) while len(Popen(['factor',str(x)],stdout=PIPE).communicate()[0].split())>2:x+=1 print(x)
x=int(eval(input())) while any(x%i<1for i in range(2,x)):x+=1 print(x)
4
3
130
66
from subprocess import * x = int(eval(input())) while len(Popen(["factor", str(x)], stdout=PIPE).communicate()[0].split()) > 2: x += 1 print(x)
x = int(eval(input())) while any(x % i < 1 for i in range(2, x)): x += 1 print(x)
false
25
[ "-from subprocess import *", "-", "-while len(Popen([\"factor\", str(x)], stdout=PIPE).communicate()[0].split()) > 2:", "+while any(x % i < 1 for i in range(2, x)):" ]
false
0.053899
0.038048
1.416606
[ "s028726335", "s417079325" ]
u814986259
p03062
python
s253788210
s598837398
140
92
14,412
14,412
Accepted
Accepted
34.29
N = int(eval(input())) A = list(map(int, input().split())) count = 0 A.sort(key=lambda x: abs(x)) for x in A: if x < 0: count += 1 A = [abs(x) for x in A] ans = 0 if count % 2 == 0: ans = sum(A) else: ans = sum(A[1:]) - A[0] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) if abs(A[0]) < abs(A[-1]): A = A[::-1] B = list(map(abs, A)) B.sort() C = [x for x in A if x < 0] n = len(C) if n % 2 == 0: print((sum(B))) else: print((sum(B[1:]) - B[0]))
15
13
265
247
N = int(eval(input())) A = list(map(int, input().split())) count = 0 A.sort(key=lambda x: abs(x)) for x in A: if x < 0: count += 1 A = [abs(x) for x in A] ans = 0 if count % 2 == 0: ans = sum(A) else: ans = sum(A[1:]) - A[0] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) if abs(A[0]) < abs(A[-1]): A = A[::-1] B = list(map(abs, A)) B.sort() C = [x for x in A if x < 0] n = len(C) if n % 2 == 0: print((sum(B))) else: print((sum(B[1:]) - B[0]))
false
13.333333
[ "-count = 0", "-A.sort(key=lambda x: abs(x))", "-for x in A:", "- if x < 0:", "- count += 1", "-A = [abs(x) for x in A]", "-ans = 0", "-if count % 2 == 0:", "- ans = sum(A)", "+if abs(A[0]) < abs(A[-1]):", "+ A = A[::-1]", "+B = list(map(abs, A))", "+B.sort()", "+C = [x for...
false
0.113947
0.079962
1.425018
[ "s253788210", "s598837398" ]
u966695411
p03805
python
s657659404
s636334878
53
48
3,064
3,064
Accepted
Accepted
9.43
import itertools N, M = list(map(int, input().split())) E = set([tuple(sorted(map(int, input().split()))) for x in range(M)]) cnt = 0 for i in itertools.permutations(list(range(2,N+1)), N-1): l = [1]+list(i) if sum(1 for x in range(N-1) if tuple(sorted(l[x:x+2])) in E) == N-1: cnt += 1 print(cnt...
import itertools N, M = list(map(int, input().split())) D = {tuple(sorted(map(int, input().split()))) for x in range(M)} cnt = 0 for i in itertools.permutations(list(range(2, N+1)), N-1): l = [1]+list(i) cnt += sum(1 for x in zip(l,l[1:]) if tuple(sorted(x)) in D) == N-1 print(cnt)
9
8
309
285
import itertools N, M = list(map(int, input().split())) E = set([tuple(sorted(map(int, input().split()))) for x in range(M)]) cnt = 0 for i in itertools.permutations(list(range(2, N + 1)), N - 1): l = [1] + list(i) if sum(1 for x in range(N - 1) if tuple(sorted(l[x : x + 2])) in E) == N - 1: cnt += 1 p...
import itertools N, M = list(map(int, input().split())) D = {tuple(sorted(map(int, input().split()))) for x in range(M)} cnt = 0 for i in itertools.permutations(list(range(2, N + 1)), N - 1): l = [1] + list(i) cnt += sum(1 for x in zip(l, l[1:]) if tuple(sorted(x)) in D) == N - 1 print(cnt)
false
11.111111
[ "-E = set([tuple(sorted(map(int, input().split()))) for x in range(M)])", "+D = {tuple(sorted(map(int, input().split()))) for x in range(M)}", "- if sum(1 for x in range(N - 1) if tuple(sorted(l[x : x + 2])) in E) == N - 1:", "- cnt += 1", "+ cnt += sum(1 for x in zip(l, l[1:]) if tuple(sorted(...
false
0.063324
0.05644
1.121955
[ "s657659404", "s636334878" ]
u732061897
p03111
python
s863136134
s255064448
236
67
9,200
9,152
Accepted
Accepted
71.61
N, A, B, C = list(map(int, input().split())) L_list = [int(eval(input())) for i in range(N)] import itertools Target = itertools.product([0, 1, 2, 3], repeat=N) INF = 10 ** 9 #Target = [(1,2,2,2,3)] ans = INF for T in Target: A_sum = 0 B_sum = 0 C_sum = 0 A_cost = 0 B_cost = 0 ...
N, A, B, C = list(map(int, input().split())) L_list = [int(eval(input())) for i in range(N)] INF = 10 ** 9 def dfs(a, b, c, n): if n == N: return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF ret1 = dfs(a, b, c, n + 1) ret2 = dfs(a + L_list[n], b, c, n + 1) + 10...
42
45
1,047
616
N, A, B, C = list(map(int, input().split())) L_list = [int(eval(input())) for i in range(N)] import itertools Target = itertools.product([0, 1, 2, 3], repeat=N) INF = 10**9 # Target = [(1,2,2,2,3)] ans = INF for T in Target: A_sum = 0 B_sum = 0 C_sum = 0 A_cost = 0 B_cost = 0 C_cost = 0 for...
N, A, B, C = list(map(int, input().split())) L_list = [int(eval(input())) for i in range(N)] INF = 10**9 def dfs(a, b, c, n): if n == N: return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF ret1 = dfs(a, b, c, n + 1) ret2 = dfs(a + L_list[n], b, c, n + 1) + 10 ret3 = d...
false
6.666667
[ "-import itertools", "+INF = 10**9", "-Target = itertools.product([0, 1, 2, 3], repeat=N)", "-INF = 10**9", "-# Target = [(1,2,2,2,3)]", "-ans = INF", "-for T in Target:", "- A_sum = 0", "- B_sum = 0", "- C_sum = 0", "- A_cost = 0", "- B_cost = 0", "- C_cost = 0", "- f...
false
0.768371
0.114961
6.68376
[ "s863136134", "s255064448" ]
u756388720
p03111
python
s082621879
s461961747
90
68
3,064
9,236
Accepted
Accepted
24.44
N, A, B, C = list(map(int, input().split())) l = [int(eval(input())) for i in range(N)] def dfs(d, a, b, c): if d == N: res = abs(a - A) + abs(b - B) + abs(c - C) - 30 return 1e9 if min(a, b, c) == 0 else res ret = [0] * 4 ret[0] = dfs(d + 1, a, b, c) ret[1] = dfs(d + 1, a + l[d], b, c) + 10 ...
N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for _ in range(N)] def rec(itr, a, b, c, mp): if itr == N: if a == 0 or b == 0 or c == 0: return 10 ** 9 return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30 res = rec(itr + 1, a, b, c, mp) res = min(re...
13
13
436
517
N, A, B, C = list(map(int, input().split())) l = [int(eval(input())) for i in range(N)] def dfs(d, a, b, c): if d == N: res = abs(a - A) + abs(b - B) + abs(c - C) - 30 return 1e9 if min(a, b, c) == 0 else res ret = [0] * 4 ret[0] = dfs(d + 1, a, b, c) ret[1] = dfs(d + 1, a + l[d], b, c...
N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for _ in range(N)] def rec(itr, a, b, c, mp): if itr == N: if a == 0 or b == 0 or c == 0: return 10**9 return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30 res = rec(itr + 1, a, b, c, mp) res = min(res, rec(i...
false
0
[ "-l = [int(eval(input())) for i in range(N)]", "+L = [int(eval(input())) for _ in range(N)]", "-def dfs(d, a, b, c):", "- if d == N:", "- res = abs(a - A) + abs(b - B) + abs(c - C) - 30", "- return 1e9 if min(a, b, c) == 0 else res", "- ret = [0] * 4", "- ret[0] = dfs(d + 1, a, ...
false
0.288771
0.07189
4.016871
[ "s082621879", "s461961747" ]
u287132915
p02838
python
s616226365
s329784561
586
310
122,936
48,808
Accepted
Accepted
47.1
n = int(eval(input())) a = list(map(int, input().split())) wa = 0 kazu = 10**9 + 7 for i in range(60): b = 0 for j in a: b += j & 1 wa = (wa + b*(n-b)*(1<<i)) % kazu for j in range(n): a[j] = a[j] >> 1 print(wa)
import numpy as np n = int(eval(input())) a = np.array(list(map(int, input().split()))) wa = 0 kazu = 10**9 + 7 for i in range(60): b = int((a & 1).sum()) wa = (wa + b*(n-b)*(1<<i)) % kazu a = a >> 1 print(wa)
14
13
252
230
n = int(eval(input())) a = list(map(int, input().split())) wa = 0 kazu = 10**9 + 7 for i in range(60): b = 0 for j in a: b += j & 1 wa = (wa + b * (n - b) * (1 << i)) % kazu for j in range(n): a[j] = a[j] >> 1 print(wa)
import numpy as np n = int(eval(input())) a = np.array(list(map(int, input().split()))) wa = 0 kazu = 10**9 + 7 for i in range(60): b = int((a & 1).sum()) wa = (wa + b * (n - b) * (1 << i)) % kazu a = a >> 1 print(wa)
false
7.142857
[ "+import numpy as np", "+", "-a = list(map(int, input().split()))", "+a = np.array(list(map(int, input().split())))", "- b = 0", "- for j in a:", "- b += j & 1", "+ b = int((a & 1).sum())", "- for j in range(n):", "- a[j] = a[j] >> 1", "+ a = a >> 1" ]
false
0.127184
0.891212
0.142709
[ "s616226365", "s329784561" ]
u268470352
p02923
python
s608788630
s359694548
60
47
11,128
11,132
Accepted
Accepted
21.67
N = int(eval(input())) H = list(map(int, input().split())) counter = -1 last_h = float('inf') _max = 0 for h in H: if h <= last_h: counter += 1 else: if _max < counter: _max = counter counter = 0 last_h = h if _max < counter: _max = counter print(_max...
def solve(N, H): last_h = float('inf') _count = -1 _max = 0 for h in H: if h <= last_h: _count += 1 else: if _max < _count: _max = _count _count = 0 last_h = h if _max < _count: _max = _count return...
17
24
309
465
N = int(eval(input())) H = list(map(int, input().split())) counter = -1 last_h = float("inf") _max = 0 for h in H: if h <= last_h: counter += 1 else: if _max < counter: _max = counter counter = 0 last_h = h if _max < counter: _max = counter print(_max)
def solve(N, H): last_h = float("inf") _count = -1 _max = 0 for h in H: if h <= last_h: _count += 1 else: if _max < _count: _max = _count _count = 0 last_h = h if _max < _count: _max = _count return _max if __n...
false
29.166667
[ "-N = int(eval(input()))", "-H = list(map(int, input().split()))", "-counter = -1", "-last_h = float(\"inf\")", "-_max = 0", "-for h in H:", "- if h <= last_h:", "- counter += 1", "- else:", "- if _max < counter:", "- _max = counter", "- counter = 0", "-...
false
0.101668
0.073626
1.380866
[ "s608788630", "s359694548" ]
u566428756
p02802
python
s879263646
s478196101
338
289
33,584
4,596
Accepted
Accepted
14.5
N,M=list(map(int,input().split())) PS=[list(input().split()) for _ in range(M)] wa=[0]*(N+1) ac=[0]*(N+1) ac_cnt=set() for ps in PS: if ps[1]=='AC': ac_cnt.add(ps[0]) ac[int(ps[0])]=1 if ps[1]=='WA' and ac[int(ps[0])]==0: wa[int(ps[0])]+=1 for i in range(1,N+1): if str(i)...
N,M=list(map(int,input().split())) ac=[0]*(N+1) wa=[0]*(N+1) for i in range(M): p,s=input().split() if ac[int(p)]==1: continue if s=='AC': ac[int(p)]=1 elif s=='WA': wa[int(p)]+=1 ac_ans,wa_ans=0,0 for a,w in zip(ac,wa): if a==0: continue ac_ans+=...
15
20
371
354
N, M = list(map(int, input().split())) PS = [list(input().split()) for _ in range(M)] wa = [0] * (N + 1) ac = [0] * (N + 1) ac_cnt = set() for ps in PS: if ps[1] == "AC": ac_cnt.add(ps[0]) ac[int(ps[0])] = 1 if ps[1] == "WA" and ac[int(ps[0])] == 0: wa[int(ps[0])] += 1 for i in range(1, ...
N, M = list(map(int, input().split())) ac = [0] * (N + 1) wa = [0] * (N + 1) for i in range(M): p, s = input().split() if ac[int(p)] == 1: continue if s == "AC": ac[int(p)] = 1 elif s == "WA": wa[int(p)] += 1 ac_ans, wa_ans = 0, 0 for a, w in zip(ac, wa): if a == 0: c...
false
25
[ "-PS = [list(input().split()) for _ in range(M)]", "+ac = [0] * (N + 1)", "-ac = [0] * (N + 1)", "-ac_cnt = set()", "-for ps in PS:", "- if ps[1] == \"AC\":", "- ac_cnt.add(ps[0])", "- ac[int(ps[0])] = 1", "- if ps[1] == \"WA\" and ac[int(ps[0])] == 0:", "- wa[int(ps[0])...
false
0.109034
0.092889
1.173809
[ "s879263646", "s478196101" ]
u952708174
p03151
python
s888156276
s149373152
138
113
18,356
18,356
Accepted
Accepted
18.12
def c_exam_and_wizard(N, A, B): ans = 0 short_val = 0 # 合格に不足する準備度 can_give = [] for a, b in zip(A, B): if a < b: ans += 1 short_val += b - a elif a > b: can_give.append(a - b) if short_val == 0: return 0 can_give.sort() ...
def c_exam_and_wizard(N, A, B): ans = 0 sum_of_shortage_for_passing_mark = 0 campensation_for_shortage = [] for a, b in zip(A, B): if a < b: ans += 1 sum_of_shortage_for_passing_mark += b - a elif a > b: campensation_for_shortage.append(a - b)...
35
30
764
863
def c_exam_and_wizard(N, A, B): ans = 0 short_val = 0 # 合格に不足する準備度 can_give = [] for a, b in zip(A, B): if a < b: ans += 1 short_val += b - a elif a > b: can_give.append(a - b) if short_val == 0: return 0 can_give.sort() idx = len(...
def c_exam_and_wizard(N, A, B): ans = 0 sum_of_shortage_for_passing_mark = 0 campensation_for_shortage = [] for a, b in zip(A, B): if a < b: ans += 1 sum_of_shortage_for_passing_mark += b - a elif a > b: campensation_for_shortage.append(a - b) if s...
false
14.285714
[ "- short_val = 0 # 合格に不足する準備度", "- can_give = []", "+ sum_of_shortage_for_passing_mark = 0", "+ campensation_for_shortage = []", "- short_val += b - a", "+ sum_of_shortage_for_passing_mark += b - a", "- can_give.append(a - b)", "- if short_val == 0:", ...
false
0.035124
0.036728
0.956345
[ "s888156276", "s149373152" ]
u747873993
p03501
python
s950521779
s922772163
19
17
2,940
2,940
Accepted
Accepted
10.53
N,A,B=(int(i) for i in input().split()) if A*N<B: print((A*N)) else: print(B)
N,A,B=(int(i) for i in input().split()) value=A*N if value<B: print(value) else: print(B)
5
6
87
102
N, A, B = (int(i) for i in input().split()) if A * N < B: print((A * N)) else: print(B)
N, A, B = (int(i) for i in input().split()) value = A * N if value < B: print(value) else: print(B)
false
16.666667
[ "-if A * N < B:", "- print((A * N))", "+value = A * N", "+if value < B:", "+ print(value)" ]
false
0.045341
0.044103
1.028072
[ "s950521779", "s922772163" ]
u452512115
p02996
python
s895823990
s407160579
1,017
855
38,224
39,756
Accepted
Accepted
15.93
N = int(eval(input())) lst = [] for i in range(N): N, K = list(map(int, input().split())) lst.append((K-N, N, K)) lst.sort() lst.sort(key=lambda tup: tup[2]) count = 0 for ind, x in enumerate(lst): if count > x[0]: print("No") exit() count += x[1] print("Yes")
N = int(eval(input())) lst = [] for i in range(N): N, K = list(map(int, input().split())) lst.append((K-N, N, K)) lst.sort(key=lambda tup: tup[2]) count = 0 for ind, x in enumerate(lst): if count > x[0]: print("No") exit() count += x[1] print("Yes")
17
16
284
272
N = int(eval(input())) lst = [] for i in range(N): N, K = list(map(int, input().split())) lst.append((K - N, N, K)) lst.sort() lst.sort(key=lambda tup: tup[2]) count = 0 for ind, x in enumerate(lst): if count > x[0]: print("No") exit() count += x[1] print("Yes")
N = int(eval(input())) lst = [] for i in range(N): N, K = list(map(int, input().split())) lst.append((K - N, N, K)) lst.sort(key=lambda tup: tup[2]) count = 0 for ind, x in enumerate(lst): if count > x[0]: print("No") exit() count += x[1] print("Yes")
false
5.882353
[ "-lst.sort()" ]
false
0.035927
0.037025
0.970343
[ "s895823990", "s407160579" ]
u227082700
p03779
python
s087827019
s612049538
40
28
2,940
2,940
Accepted
Accepted
30
x,t=int(eval(input())),0 while round(t*(t+1)/2)<x:t+=1 print(t)
x=int(eval(input())) for t in range(1,10**10): if t*(t+1)//2>=x:print(t);exit()
3
3
59
77
x, t = int(eval(input())), 0 while round(t * (t + 1) / 2) < x: t += 1 print(t)
x = int(eval(input())) for t in range(1, 10**10): if t * (t + 1) // 2 >= x: print(t) exit()
false
0
[ "-x, t = int(eval(input())), 0", "-while round(t * (t + 1) / 2) < x:", "- t += 1", "-print(t)", "+x = int(eval(input()))", "+for t in range(1, 10**10):", "+ if t * (t + 1) // 2 >= x:", "+ print(t)", "+ exit()" ]
false
0.041243
0.056719
0.727153
[ "s087827019", "s612049538" ]
u251515715
p02913
python
s462521465
s954656898
1,799
1,126
3,064
3,060
Accepted
Accepted
37.41
n=int(eval(input())) s=eval(input()) ans=0 tmp=0 for i in range(n-1): for j in range(i+2,n+1): if j-i>ans: if s[i:j] in s[j:]: tmp=j-i else: ans=max(tmp,ans) break ans=max(tmp,ans) print(ans)
n=int(eval(input())) s=eval(input()) ans=0 i=0 j=1 while i<n and j<=n: if s[i:j] in s[j:n]: ans=max(j-i,ans) j+=1 else: i+=1 print(ans)
14
12
234
150
n = int(eval(input())) s = eval(input()) ans = 0 tmp = 0 for i in range(n - 1): for j in range(i + 2, n + 1): if j - i > ans: if s[i:j] in s[j:]: tmp = j - i else: ans = max(tmp, ans) break ans = max(tmp, ans) print(ans)
n = int(eval(input())) s = eval(input()) ans = 0 i = 0 j = 1 while i < n and j <= n: if s[i:j] in s[j:n]: ans = max(j - i, ans) j += 1 else: i += 1 print(ans)
false
14.285714
[ "-tmp = 0", "-for i in range(n - 1):", "- for j in range(i + 2, n + 1):", "- if j - i > ans:", "- if s[i:j] in s[j:]:", "- tmp = j - i", "- else:", "- ans = max(tmp, ans)", "- break", "-ans = max(tmp, ans)", "+i = 0", ...
false
0.041193
0.035382
1.164242
[ "s462521465", "s954656898" ]
u944886577
p02627
python
s294139659
s689287902
35
28
9,864
8,864
Accepted
Accepted
20
import re a=eval(input()) if re.sub(r'[A-Z]',"",a)=="": print('A') else: print('a')
a=eval(input()) if a.isupper(): print('A') else: print('a')
6
5
87
61
import re a = eval(input()) if re.sub(r"[A-Z]", "", a) == "": print("A") else: print("a")
a = eval(input()) if a.isupper(): print("A") else: print("a")
false
16.666667
[ "-import re", "-", "-if re.sub(r\"[A-Z]\", \"\", a) == \"\":", "+if a.isupper():" ]
false
0.042234
0.039969
1.056657
[ "s294139659", "s689287902" ]
u460245024
p03078
python
s644576569
s350468089
1,200
253
140,004
48,988
Accepted
Accepted
78.92
import itertools X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) comb_ab = [] for a, b in itertools.product(A, B): comb_ab.append(sum([a, b])) comb_ab_top = sorted(comb_ab, revers...
X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) B = sorted(list(map(int, input().split())), reverse=True) C = sorted(list(map(int, input().split())), reverse=True) comb = [] for a in range(X): b_max = K // (a+1) for b in range(min(Y, b_max)): c_...
19
16
500
492
import itertools X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) comb_ab = [] for a, b in itertools.product(A, B): comb_ab.append(sum([a, b])) comb_ab_top = sorted(comb_ab, reverse=True)[:K] c...
X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) B = sorted(list(map(int, input().split())), reverse=True) C = sorted(list(map(int, input().split())), reverse=True) comb = [] for a in range(X): b_max = K // (a + 1) for b in range(min(Y, b_max)): c_max = K ...
false
15.789474
[ "-import itertools", "-", "-A = sorted(list(map(int, input().split())))", "-B = sorted(list(map(int, input().split())))", "-C = sorted(list(map(int, input().split())))", "-comb_ab = []", "-for a, b in itertools.product(A, B):", "- comb_ab.append(sum([a, b]))", "-comb_ab_top = sorted(comb_ab, reve...
false
0.12424
0.046622
2.664809
[ "s644576569", "s350468089" ]
u249218427
p02586
python
s915231954
s836384583
1,130
656
169,244
149,656
Accepted
Accepted
41.95
# -*- coding: utf-8 -*- R,C,K = list(map(int, input().split())) items = [[0 for _ in range(C+1)] for _ in range(R+1)] for i in range(K): r,c,v = list(map(int, input().split())) items[r][c] = v DP_prev = [0 for _ in range(C+1)] for r in range(1,R+1): DP1 = [0 for _ in range(C+1)] DP2 = [0 for _ in...
# -*- coding: utf-8 -*- R,C,K = list(map(int, input().split())) items = [[0 for _ in range(C+1)] for _ in range(R+1)] for i in range(K): r,c,v = list(map(int, input().split())) items[r][c] = v DP_prev = [0 for _ in range(C+1)] DP1 = [0 for _ in range(C+1)] DP2 = [0 for _ in range(C+1)] DP3 = [0 for _...
22
22
591
585
# -*- coding: utf-8 -*- R, C, K = list(map(int, input().split())) items = [[0 for _ in range(C + 1)] for _ in range(R + 1)] for i in range(K): r, c, v = list(map(int, input().split())) items[r][c] = v DP_prev = [0 for _ in range(C + 1)] for r in range(1, R + 1): DP1 = [0 for _ in range(C + 1)] DP2 = [0 ...
# -*- coding: utf-8 -*- R, C, K = list(map(int, input().split())) items = [[0 for _ in range(C + 1)] for _ in range(R + 1)] for i in range(K): r, c, v = list(map(int, input().split())) items[r][c] = v DP_prev = [0 for _ in range(C + 1)] DP1 = [0 for _ in range(C + 1)] DP2 = [0 for _ in range(C + 1)] DP3 = [0 fo...
false
0
[ "+DP1 = [0 for _ in range(C + 1)]", "+DP2 = [0 for _ in range(C + 1)]", "+DP3 = [0 for _ in range(C + 1)]", "- DP1 = [0 for _ in range(C + 1)]", "- DP2 = [0 for _ in range(C + 1)]", "- DP3 = [0 for _ in range(C + 1)]" ]
false
0.043673
0.04352
1.003521
[ "s915231954", "s836384583" ]
u486209657
p02639
python
s462741780
s309080107
25
23
9,116
9,168
Accepted
Accepted
8
x1, x2, x3, x4, x5 = list(map(int, input().split())) if x1 == 0: print((1)) elif x2 == 0: print((2)) elif x3 == 0: print((3)) elif x4 == 0: print((4)) else: print((5))
x = list(map(int, input().replace(' ',''))) x = list(x) for idx in range(len(x)): if x[idx] == 0: print((idx + 1)) break
12
7
173
129
x1, x2, x3, x4, x5 = list(map(int, input().split())) if x1 == 0: print((1)) elif x2 == 0: print((2)) elif x3 == 0: print((3)) elif x4 == 0: print((4)) else: print((5))
x = list(map(int, input().replace(" ", ""))) x = list(x) for idx in range(len(x)): if x[idx] == 0: print((idx + 1)) break
false
41.666667
[ "-x1, x2, x3, x4, x5 = list(map(int, input().split()))", "-if x1 == 0:", "- print((1))", "-elif x2 == 0:", "- print((2))", "-elif x3 == 0:", "- print((3))", "-elif x4 == 0:", "- print((4))", "-else:", "- print((5))", "+x = list(map(int, input().replace(\" \", \"\")))", "+x = l...
false
0.046553
0.045103
1.032147
[ "s462741780", "s309080107" ]
u075012704
p03557
python
s887134160
s760518272
902
476
25,596
107,108
Accepted
Accepted
47.23
import numpy as np N = int(eval(input())) A = np.array(list(map(int, input().split()))) B = np.array(list(map(int, input().split()))) C = np.array(list(map(int, input().split()))) A.sort() B.sort() C.sort() ans = 0 for b in B: AB = A.searchsorted(b, side='left') CB = len(B) - C.searchsorted(b, side...
from bisect import bisect_left, bisect_right N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for b in B: ans += bisect_left(A, b) * (N - bisect_right(C, b)) print(ans)
18
11
362
294
import numpy as np N = int(eval(input())) A = np.array(list(map(int, input().split()))) B = np.array(list(map(int, input().split()))) C = np.array(list(map(int, input().split()))) A.sort() B.sort() C.sort() ans = 0 for b in B: AB = A.searchsorted(b, side="left") CB = len(B) - C.searchsorted(b, side="right") ...
from bisect import bisect_left, bisect_right N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for b in B: ans += bisect_left(A, b) * (N - bisect_right(C, b)) print(ans)
false
38.888889
[ "-import numpy as np", "+from bisect import bisect_left, bisect_right", "-A = np.array(list(map(int, input().split())))", "-B = np.array(list(map(int, input().split())))", "-C = np.array(list(map(int, input().split())))", "-A.sort()", "-B.sort()", "-C.sort()", "+A = sorted(list(map(int, input().spli...
false
0.456169
0.143505
3.178765
[ "s887134160", "s760518272" ]
u225388820
p02913
python
s568088420
s127069338
421
84
77,704
10,848
Accepted
Accepted
80.05
def Z_algorithm(s): n = len(s) Z = [0] * n # z[i] = sum(s[0::n - i], s[i::n]) Z[0] = n i, j = 1, 0 while i < n: # 共通部分を見つけるパート while i + j < n and s[j] == s[i + j]: j += 1 Z[i] = j if j == 0: i += 1 continue ...
from random import randint class RollingHash: def __init__(self, s): self.base = [7073, 7577, 5445, 2742, 6972, 7547, 2267, 286, 6396, 7147, 3307, 188, 266, 8253, 2818, 9527, 5110, 1207, 4633, 6196, 309, 2646, 7533, 85, 9870, 4730, 6862, 9213, 7456, 7098, ...
36
80
761
2,682
def Z_algorithm(s): n = len(s) Z = [0] * n # z[i] = sum(s[0::n - i], s[i::n]) Z[0] = n i, j = 1, 0 while i < n: # 共通部分を見つけるパート while i + j < n and s[j] == s[i + j]: j += 1 Z[i] = j if j == 0: i += 1 continue # 計算の再利用パート ...
from random import randint class RollingHash: def __init__(self, s): self.base = [ 7073, 7577, 5445, 2742, 6972, 7547, 2267, 286, 6396, 7147, 3307, 188, ...
false
55
[ "-def Z_algorithm(s):", "- n = len(s)", "- Z = [0] * n # z[i] = sum(s[0::n - i], s[i::n])", "- Z[0] = n", "- i, j = 1, 0", "- while i < n:", "- # 共通部分を見つけるパート", "- while i + j < n and s[j] == s[i + j]:", "- j += 1", "- Z[i] = j", "- if j == ...
false
0.045711
0.042714
1.070147
[ "s568088420", "s127069338" ]
u142415823
p03625
python
s327947356
s536599783
135
89
18,600
14,252
Accepted
Accepted
34.07
import collections N = int(eval(input())) A = [int(i) for i in input().split()] stick_num = collections.Counter(A) flag = True ans = 0 for i in sorted(stick_num, reverse=True): if stick_num[i] >= 4: ans = i * i if flag else a * i break elif stick_num[i] >= 2: if flag: ...
N = int(eval(input())) A = [int(i) for i in input().split()] A.sort(reverse=True) flag_h = True flag_v = True h, v = 0, 0 for i in A: if flag_h: if h == i: flag_h = False else: h = i elif flag_v: if v == i: flag_v = False els...
21
24
427
405
import collections N = int(eval(input())) A = [int(i) for i in input().split()] stick_num = collections.Counter(A) flag = True ans = 0 for i in sorted(stick_num, reverse=True): if stick_num[i] >= 4: ans = i * i if flag else a * i break elif stick_num[i] >= 2: if flag: a = i ...
N = int(eval(input())) A = [int(i) for i in input().split()] A.sort(reverse=True) flag_h = True flag_v = True h, v = 0, 0 for i in A: if flag_h: if h == i: flag_h = False else: h = i elif flag_v: if v == i: flag_v = False else: v = ...
false
12.5
[ "-import collections", "-", "-stick_num = collections.Counter(A)", "-flag = True", "-ans = 0", "-for i in sorted(stick_num, reverse=True):", "- if stick_num[i] >= 4:", "- ans = i * i if flag else a * i", "- break", "- elif stick_num[i] >= 2:", "- if flag:", "- ...
false
0.070103
0.03862
1.81519
[ "s327947356", "s536599783" ]
u518711553
p00002
python
s174599418
s010149725
30
20
7,704
7,472
Accepted
Accepted
33.33
import sys from operator import add from math import log10 for i in sys.stdin: print((int(log10(add(*list(map(int, i.split()))))) + 1))
import sys from operator import add for i in sys.stdin: print((len(str(add(*list(map(int, i.split())))))))
6
5
143
113
import sys from operator import add from math import log10 for i in sys.stdin: print((int(log10(add(*list(map(int, i.split()))))) + 1))
import sys from operator import add for i in sys.stdin: print((len(str(add(*list(map(int, i.split())))))))
false
16.666667
[ "-from math import log10", "- print((int(log10(add(*list(map(int, i.split()))))) + 1))", "+ print((len(str(add(*list(map(int, i.split())))))))" ]
false
0.038841
0.038066
1.020355
[ "s174599418", "s010149725" ]
u561083515
p03053
python
s658637199
s867199294
994
692
105,976
105,976
Accepted
Accepted
30.38
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline H,W = list(map(int,input().split())) INF = 10**18 q = [] visited = [[True]*(W+2)] visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)] visited.append([True]*(W+2)) for i in range(1,H+1): for j in rang...
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline def main(): H,W = list(map(int,input().split())) # 番兵法 (#を外周に設置する) visited = [[True]*(W+2)] visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)] visited.append([True]*(W+2)) # #の位置を...
39
45
836
1,138
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline H, W = list(map(int, input().split())) INF = 10**18 q = [] visited = [[True] * (W + 2)] visited += [[True] + [x == "#" for x in input().rstrip()] + [True] for _ in range(H)] visited.append([True] * (W + 2)) for i in range(1, H + 1): for j in range(...
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline def main(): H, W = list(map(int, input().split())) # 番兵法 (#を外周に設置する) visited = [[True] * (W + 2)] visited += [ [True] + [x == "#" for x in input().rstrip()] + [True] for _ in range(H) ] visited.append([True] * (W + 2))...
false
13.333333
[ "-H, W = list(map(int, input().split()))", "-INF = 10**18", "-q = []", "-visited = [[True] * (W + 2)]", "-visited += [[True] + [x == \"#\" for x in input().rstrip()] + [True] for _ in range(H)]", "-visited.append([True] * (W + 2))", "-for i in range(1, H + 1):", "- for j in range(1, W + 1):", "- ...
false
0.036807
0.037626
0.978231
[ "s658637199", "s867199294" ]
u535171899
p03575
python
s086189622
s362854166
25
19
3,436
3,064
Accepted
Accepted
24
from collections import deque def dfs(n, start, graph): visited = [False] * n stack = deque() stack.append(start) visited[start] = True while stack: q = stack.popleft() nxts = graph[q] for nxt in nxts: if not visited[nxt]: visited[nxt] = True stack.append(nxt) ...
n,m=list(map(int,input().split())) edge=[[] for _ in range(n+1)] eab=[] for i in range(m): a,b=list(map(int,input().split())) edge[a-1].append(b-1) edge[b-1].append(a-1) eab.append([a-1,b-1]) def dfs(visited,count,node): visited[node]=True count+=1 ev=edge[node] for node i...
30
31
687
661
from collections import deque def dfs(n, start, graph): visited = [False] * n stack = deque() stack.append(start) visited[start] = True while stack: q = stack.popleft() nxts = graph[q] for nxt in nxts: if not visited[nxt]: visited[nxt] = True ...
n, m = list(map(int, input().split())) edge = [[] for _ in range(n + 1)] eab = [] for i in range(m): a, b = list(map(int, input().split())) edge[a - 1].append(b - 1) edge[b - 1].append(a - 1) eab.append([a - 1, b - 1]) def dfs(visited, count, node): visited[node] = True count += 1 ev = edg...
false
3.225806
[ "-from collections import deque", "+n, m = list(map(int, input().split()))", "+edge = [[] for _ in range(n + 1)]", "+eab = []", "+for i in range(m):", "+ a, b = list(map(int, input().split()))", "+ edge[a - 1].append(b - 1)", "+ edge[b - 1].append(a - 1)", "+ eab.append([a - 1, b - 1])",...
false
0.130989
0.066719
1.963293
[ "s086189622", "s362854166" ]
u110656379
p03043
python
s997166375
s050315204
63
48
2,940
2,940
Accepted
Accepted
23.81
n,k=list(map(int,input().split())) answer=0 for i in range(n): j=1 while (i+1)*j<k: j*=2 answer+=1/j*1/n print(answer)
n,k=list(map(int,input().split())) m=0 for i in range(1,n+1): l=k j=0 while l>i: l/=2 j+=1 m+=1/n*((1/2)**j) print(m)
8
10
129
136
n, k = list(map(int, input().split())) answer = 0 for i in range(n): j = 1 while (i + 1) * j < k: j *= 2 answer += 1 / j * 1 / n print(answer)
n, k = list(map(int, input().split())) m = 0 for i in range(1, n + 1): l = k j = 0 while l > i: l /= 2 j += 1 m += 1 / n * ((1 / 2) ** j) print(m)
false
20
[ "-answer = 0", "-for i in range(n):", "- j = 1", "- while (i + 1) * j < k:", "- j *= 2", "- answer += 1 / j * 1 / n", "-print(answer)", "+m = 0", "+for i in range(1, n + 1):", "+ l = k", "+ j = 0", "+ while l > i:", "+ l /= 2", "+ j += 1", "+ m +...
false
0.007739
0.052126
0.14847
[ "s997166375", "s050315204" ]
u896741788
p03911
python
s454626361
s080211979
753
684
62,936
62,808
Accepted
Accepted
9.16
n,m=map(int,input().split()) class UnionFind: #def -> foo=UnionFind(n,1) <- 1-based index, default is 0 #method -> foo.hoge(huga) __slots__ = ["_size", "_first_idx", "_parents"] def __init__(self, size: int, first_index: int = 0) -> None: self._size = size self._first_idx = fir...
n,m=map(int,input().split()) class UnionFind: #def -> foo=UnionFind(n,1) <- 1-based index, default is 0 #method -> foo.hoge(huga) __slots__ = ["_size", "_first_idx", "_parents"] def __init__(self, size: int, first_index: int = 0) -> None: self._size = size self._first_idx = fir...
36
36
1,364
1,358
n, m = map(int, input().split()) class UnionFind: # def -> foo=UnionFind(n,1) <- 1-based index, default is 0 # method -> foo.hoge(huga) __slots__ = ["_size", "_first_idx", "_parents"] def __init__(self, size: int, first_index: int = 0) -> None: self._size = size self._first_idx = f...
n, m = map(int, input().split()) class UnionFind: # def -> foo=UnionFind(n,1) <- 1-based index, default is 0 # method -> foo.hoge(huga) __slots__ = ["_size", "_first_idx", "_parents"] def __init__(self, size: int, first_index: int = 0) -> None: self._size = size self._first_idx = f...
false
0
[ "-print(\"YES\") if uf.group_count() == 1 else print(\"NO\")", "+print(\"YES\") if uf.size(0) == n else print(\"NO\")" ]
false
0.126879
0.084037
1.509804
[ "s454626361", "s080211979" ]
u784022244
p02990
python
s641436625
s888385112
608
24
3,944
3,572
Accepted
Accepted
96.05
N, K=list(map(int, input().split())) mod=10**9+7 #青K個 赤NーK個 #青をi個に分ける K-1Ci-1 #赤1個以上を仕切りに振り分ける (両端含むが、両端は0でもOK) #N-KCi-2+N-KCi-1+N-KCi #1997C1+ from operator import mul from functools import reduce def cmb(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) ...
n,k=list(map(int, input().split())) 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 p = 10 ** 9 + 7 N = 2000 # N は必要分だけ用意する fact = [1, 1] # fact[n] = (n! mod p) 階乗のmod factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, ...
41
21
735
568
N, K = list(map(int, input().split())) mod = 10**9 + 7 # 青K個 赤NーK個 # 青をi個に分ける K-1Ci-1 # 赤1個以上を仕切りに振り分ける (両端含むが、両端は0でもOK) # N-KCi-2+N-KCi-1+N-KCi # 1997C1+ from operator import mul from functools import reduce def cmb(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n ...
n, k = list(map(int, input().split())) 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 p = 10**9 + 7 N = 2000 # N は必要分だけ用意する fact = [1, 1] # fact[n] = (n! mod p) 階乗のmod factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv =...
false
48.780488
[ "-N, K = list(map(int, input().split()))", "-mod = 10**9 + 7", "-# 青K個 赤NーK個", "-# 青をi個に分ける K-1Ci-1", "-# 赤1個以上を仕切りに振り分ける (両端含むが、両端は0でもOK)", "-# N-KCi-2+N-KCi-1+N-KCi", "-# 1997C1+", "-from operator import mul", "-from functools import reduce", "+n, k = list(map(int, input().split()))", "-def c...
false
0.039116
0.039724
0.984709
[ "s641436625", "s888385112" ]
u530606147
p02708
python
s864934010
s653566170
136
22
9,184
9,168
Accepted
Accepted
83.82
n, k = list(map(int, input().split())) MOD = 10**9 + 7 ans = 0 for c in range(k, n + 2): m = c * (c - 1) // 2 M = c * (2 * (n + 1) - c - 1) // 2 ans += M - m + 1 ans %= MOD print(ans)
n, k = list(map(int, input().split())) MOD = 10**9 + 7 print(((-2 + k - n) * (-6 - 2 * k + 2 * k**2 - n - k * n - n**2) // 6 % MOD))
12
3
206
132
n, k = list(map(int, input().split())) MOD = 10**9 + 7 ans = 0 for c in range(k, n + 2): m = c * (c - 1) // 2 M = c * (2 * (n + 1) - c - 1) // 2 ans += M - m + 1 ans %= MOD print(ans)
n, k = list(map(int, input().split())) MOD = 10**9 + 7 print(((-2 + k - n) * (-6 - 2 * k + 2 * k**2 - n - k * n - n**2) // 6 % MOD))
false
75
[ "-ans = 0", "-for c in range(k, n + 2):", "- m = c * (c - 1) // 2", "- M = c * (2 * (n + 1) - c - 1) // 2", "- ans += M - m + 1", "- ans %= MOD", "-print(ans)", "+print(((-2 + k - n) * (-6 - 2 * k + 2 * k**2 - n - k * n - n**2) // 6 % MOD))" ]
false
0.080956
0.034277
2.361825
[ "s864934010", "s653566170" ]
u203962828
p02711
python
s804946265
s457252801
31
28
9,048
9,020
Accepted
Accepted
9.68
n = str(eval(input())) if n[0] == '7' or n[1] == '7' or n[2] == '7': print('Yes') else: print('No')
n = list(eval(input())) for i in n: if '7' in n: print('Yes') break else: print('No') break
6
9
107
134
n = str(eval(input())) if n[0] == "7" or n[1] == "7" or n[2] == "7": print("Yes") else: print("No")
n = list(eval(input())) for i in n: if "7" in n: print("Yes") break else: print("No") break
false
33.333333
[ "-n = str(eval(input()))", "-if n[0] == \"7\" or n[1] == \"7\" or n[2] == \"7\":", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+n = list(eval(input()))", "+for i in n:", "+ if \"7\" in n:", "+ print(\"Yes\")", "+ break", "+ else:", "+ print(\"No\")", "+...
false
0.035313
0.03489
1.012117
[ "s804946265", "s457252801" ]
u057109575
p02837
python
s258322913
s832912401
303
100
50,672
74,104
Accepted
Accepted
67
N = int(eval(input())) A = [0] * N XY = [] for i in range(N): tmp = [] a = int(eval(input())) A[i] = a for j in range(a): tmp.append(list(map(int, input().split()))) XY.append(tmp) def counter(x): if x == 0: return 0 else: return counter(x >> 1) + (x...
N = int(eval(input())) X = {} for i in range(N): A = int(eval(input())) tmp = [list(map(int, input().split())) for _ in range(A)] X[i] = tmp ans = 0 for bit in range(2 ** N): tmp = bit flag = True for i in range(N): if not (bit >> i & 1): continue f...
33
25
662
512
N = int(eval(input())) A = [0] * N XY = [] for i in range(N): tmp = [] a = int(eval(input())) A[i] = a for j in range(a): tmp.append(list(map(int, input().split()))) XY.append(tmp) def counter(x): if x == 0: return 0 else: return counter(x >> 1) + (x & 1) ans = 0 ...
N = int(eval(input())) X = {} for i in range(N): A = int(eval(input())) tmp = [list(map(int, input().split())) for _ in range(A)] X[i] = tmp ans = 0 for bit in range(2**N): tmp = bit flag = True for i in range(N): if not (bit >> i & 1): continue for x, y in X[i]: ...
false
24.242424
[ "-A = [0] * N", "-XY = []", "+X = {}", "- tmp = []", "- a = int(eval(input()))", "- A[i] = a", "- for j in range(a):", "- tmp.append(list(map(int, input().split())))", "- XY.append(tmp)", "-", "-", "-def counter(x):", "- if x == 0:", "- return 0", "- el...
false
0.085676
0.04902
1.747765
[ "s258322913", "s832912401" ]
u896741788
p03546
python
s911766056
s612239062
353
236
3,064
96,348
Accepted
Accepted
33.14
h,w=list(map(int,input().split())) tra=[list(map(int,input().split())) for i in range(10)] ll=[[tra[i][j] for j in range(10)] for i in range(10)] for i in range(10**3-1): for i in range(10): for j in range(10): if i!=j: ll[i][j]=min(ll[i][j],min(ll[i][o]+tra[o][j] for o in...
class WarshallFloyd: #O(V^3)で任意2頂点の最短距離 def __init__(self,n,_first_index=0): self.v = n self._first_idx=_first_index self.d = [[float("INF")]*(n) for _ in range(n)] for i in range(n): self.d[i][i] = 0 def path(self,x,y,c): if x == y: ...
14
35
480
1,017
h, w = list(map(int, input().split())) tra = [list(map(int, input().split())) for i in range(10)] ll = [[tra[i][j] for j in range(10)] for i in range(10)] for i in range(10**3 - 1): for i in range(10): for j in range(10): if i != j: ll[i][j] = min( ll[i][j], ...
class WarshallFloyd: # O(V^3)で任意2頂点の最短距離 def __init__(self, n, _first_index=0): self.v = n self._first_idx = _first_index self.d = [[float("INF")] * (n) for _ in range(n)] for i in range(n): self.d[i][i] = 0 def path(self, x, y, c): if x == y: ...
false
60
[ "+class WarshallFloyd:", "+ # O(V^3)で任意2頂点の最短距離", "+ def __init__(self, n, _first_index=0):", "+ self.v = n", "+ self._first_idx = _first_index", "+ self.d = [[float(\"INF\")] * (n) for _ in range(n)]", "+ for i in range(n):", "+ self.d[i][i] = 0", "+", ...
false
0.007946
0.04392
0.18093
[ "s911766056", "s612239062" ]
u002459665
p02813
python
s600602252
s939776638
45
27
15,092
8,052
Accepted
Accepted
40
N = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) import itertools A = [i for i in range(1, N+1)] T = [list(i) for i in list(itertools.permutations(A, N))] # print(T) n1 = T.index(P) n2 = T.index(Q) print((abs(n1-n2)))
N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) from itertools import permutations t = [i for i in range(1, N+1)] r = list(permutations(t)) # print(P) # print(Q) i1 = r.index(P) i2 = r.index(Q) print((abs(i1-i2)))
13
15
270
272
N = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) import itertools A = [i for i in range(1, N + 1)] T = [list(i) for i in list(itertools.permutations(A, N))] # print(T) n1 = T.index(P) n2 = T.index(Q) print((abs(n1 - n2)))
N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) from itertools import permutations t = [i for i in range(1, N + 1)] r = list(permutations(t)) # print(P) # print(Q) i1 = r.index(P) i2 = r.index(Q) print((abs(i1 - i2)))
false
13.333333
[ "-P = list(map(int, input().split()))", "-Q = list(map(int, input().split()))", "-import itertools", "+P = tuple(map(int, input().split()))", "+Q = tuple(map(int, input().split()))", "+from itertools import permutations", "-A = [i for i in range(1, N + 1)]", "-T = [list(i) for i in list(itertools.perm...
false
0.107709
0.054405
1.979763
[ "s600602252", "s939776638" ]
u759412327
p04030
python
s063038469
s738715323
19
17
2,940
2,940
Accepted
Accepted
10.53
S = input() a = [] for s in S: if s=="B": if a: a.pop() else: a.append(s) print(*a,sep="")
a = "" for s in eval(input()): if s=="B": a=a[:-1] else: a+=s print(a)
11
9
120
86
S = input() a = [] for s in S: if s == "B": if a: a.pop() else: a.append(s) print(*a, sep="")
a = "" for s in eval(input()): if s == "B": a = a[:-1] else: a += s print(a)
false
18.181818
[ "-S = input()", "-a = []", "-for s in S:", "+a = \"\"", "+for s in eval(input()):", "- if a:", "- a.pop()", "+ a = a[:-1]", "- a.append(s)", "-print(*a, sep=\"\")", "+ a += s", "+print(a)" ]
false
0.070651
0.070788
0.998061
[ "s063038469", "s738715323" ]
u409064224
p03037
python
s280783340
s291294291
347
282
16,616
3,060
Accepted
Accepted
18.73
n,m = list(map(int,input().split())) src = [tuple(map(int,input().split())) for i in range(m)] l_max,r_min = 0,10**5 for l,r in src: l_max = max(l_max,l) for l,r in src: r_min = min(r_min,r) else: if r_min-l_max < 0: print((0)) else: print((r_min-l_max+1))
n,m = list(map(int,input().split())) ll = 0 rr = 10**5+1 for i in range(m): l,r = list(map(int,input().split())) if l > ll: ll = l if r < rr: rr = r else: #print(rr-ll+1) if rr-ll+1>n: print(n) elif rr-ll+1<0: print((0)) else: print((rr...
14
17
301
312
n, m = list(map(int, input().split())) src = [tuple(map(int, input().split())) for i in range(m)] l_max, r_min = 0, 10**5 for l, r in src: l_max = max(l_max, l) for l, r in src: r_min = min(r_min, r) else: if r_min - l_max < 0: print((0)) else: print((r_min - l_max + 1))
n, m = list(map(int, input().split())) ll = 0 rr = 10**5 + 1 for i in range(m): l, r = list(map(int, input().split())) if l > ll: ll = l if r < rr: rr = r else: # print(rr-ll+1) if rr - ll + 1 > n: print(n) elif rr - ll + 1 < 0: print((0)) else: print(...
false
17.647059
[ "-src = [tuple(map(int, input().split())) for i in range(m)]", "-l_max, r_min = 0, 10**5", "-for l, r in src:", "- l_max = max(l_max, l)", "-for l, r in src:", "- r_min = min(r_min, r)", "+ll = 0", "+rr = 10**5 + 1", "+for i in range(m):", "+ l, r = list(map(int, input().split()))", "+ ...
false
0.039764
0.038392
1.035736
[ "s280783340", "s291294291" ]
u693953100
p02829
python
s822169432
s718869984
22
17
3,316
2,940
Accepted
Accepted
22.73
a = int(eval(input())) b = int(eval(input())) print((6-a-b))
def solve(): a=int(eval(input())) b=int(eval(input())) print((6-a-b)) if __name__ == "__main__": solve()
3
6
48
111
a = int(eval(input())) b = int(eval(input())) print((6 - a - b))
def solve(): a = int(eval(input())) b = int(eval(input())) print((6 - a - b)) if __name__ == "__main__": solve()
false
50
[ "-a = int(eval(input()))", "-b = int(eval(input()))", "-print((6 - a - b))", "+def solve():", "+ a = int(eval(input()))", "+ b = int(eval(input()))", "+ print((6 - a - b))", "+", "+", "+if __name__ == \"__main__\":", "+ solve()" ]
false
0.037723
0.039214
0.961995
[ "s822169432", "s718869984" ]
u784022244
p02678
python
s381587957
s951323999
1,320
695
33,640
33,928
Accepted
Accepted
47.35
N,M=list(map(int, input().split())) G=[[] for _ in range(N)] for i in range(M): a,b=list(map(int, input().split())) G[a-1].append(b-1) G[b-1].append(a-1) siru=[-1]*(N-1)#2~~N que=[0] while len(que)>0: #print(que) now=que.pop(0) nexlist=G[now] for nex in nexlist: if n...
from collections import deque N,M=list(map(int, input().split())) G=[[] for _ in range(N)] for i in range(M): a,b=list(map(int, input().split())) G[a-1].append(b-1) G[b-1].append(a-1) siru=[-1]*(N-1)#2~~N que=deque([0]) while que: #print(que) now=que.popleft() nexlist=G[now] ...
27
28
538
572
N, M = list(map(int, input().split())) G = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) G[a - 1].append(b - 1) G[b - 1].append(a - 1) siru = [-1] * (N - 1) # 2~~N que = [0] while len(que) > 0: # print(que) now = que.pop(0) nexlist = G[now] for nex in nexl...
from collections import deque N, M = list(map(int, input().split())) G = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) G[a - 1].append(b - 1) G[b - 1].append(a - 1) siru = [-1] * (N - 1) # 2~~N que = deque([0]) while que: # print(que) now = que.popleft() nexl...
false
3.571429
[ "+from collections import deque", "+", "-que = [0]", "-while len(que) > 0:", "+que = deque([0])", "+while que:", "- now = que.pop(0)", "+ now = que.popleft()" ]
false
0.04046
0.044501
0.909205
[ "s381587957", "s951323999" ]
u163703551
p02783
python
s285232796
s886702444
28
25
3,696
3,572
Accepted
Accepted
10.71
import sys import socket hostname = socket.gethostname() if hostname == 'F451C': sys.stdin = open('a1.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(): ...
import sys import socket hostname = socket.gethostname() if hostname == 'F451C': sys.stdin = open('a1.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(): ...
37
53
510
749
import sys import socket hostname = socket.gethostname() if hostname == "F451C": sys.stdin = open("a1.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()) ...
import sys import socket hostname = socket.gethostname() if hostname == "F451C": sys.stdin = open("a1.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()) ...
false
30.188679
[ "-def main():", "+def main_0():", "+def main_1():", "+ H, A = read_int_list()", "+ res = H // A", "+ if H % A != 0:", "+ res += 1", "+ print(res)", "+", "+", "+def main():", "+ H, A = read_int_list()", "+ res = 0", "+ while H > 0:", "+ H -= A", "+ ...
false
0.045186
0.045294
0.997615
[ "s285232796", "s886702444" ]
u512266180
p02621
python
s290774233
s277366701
29
26
9,124
9,148
Accepted
Accepted
10.34
a = int(eval(input())) ans = a + a**2 + a**3 print(ans)
a = int(eval(input())) print((a+a**2+a**3))
3
2
51
36
a = int(eval(input())) ans = a + a**2 + a**3 print(ans)
a = int(eval(input())) print((a + a**2 + a**3))
false
33.333333
[ "-ans = a + a**2 + a**3", "-print(ans)", "+print((a + a**2 + a**3))" ]
false
0.046874
0.048941
0.95777
[ "s290774233", "s277366701" ]