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
u970308980
p03479
python
s790696147
s735255979
19
17
2,940
2,940
Accepted
Accepted
10.53
X, Y = list(map(int, input().split())) ans = 0 tmp = X while tmp <= Y: tmp *= 2 ans += 1 print(ans)
X, Y = list(map(int, input().split())) cnt = 0 while X <= Y: cnt += 1 X *= 2 print(cnt)
9
8
112
99
X, Y = list(map(int, input().split())) ans = 0 tmp = X while tmp <= Y: tmp *= 2 ans += 1 print(ans)
X, Y = list(map(int, input().split())) cnt = 0 while X <= Y: cnt += 1 X *= 2 print(cnt)
false
11.111111
[ "-ans = 0", "-tmp = X", "-while tmp <= Y:", "- tmp *= 2", "- ans += 1", "-print(ans)", "+cnt = 0", "+while X <= Y:", "+ cnt += 1", "+ X *= 2", "+print(cnt)" ]
false
0.039268
0.040503
0.96951
[ "s790696147", "s735255979" ]
u729133443
p03658
python
s361764328
s543193519
178
17
38,256
2,940
Accepted
Accepted
90.45
_,k,*l=list(map(int,open(0).read().split()));print((sum(sorted(l)[-k:])))
t,l=open(0);print((sum(sorted(map(int,l.split()))[-int(t[2:]):])))
1
1
65
64
_, k, *l = list(map(int, open(0).read().split())) print((sum(sorted(l)[-k:])))
t, l = open(0) print((sum(sorted(map(int, l.split()))[-int(t[2:]) :])))
false
0
[ "-_, k, *l = list(map(int, open(0).read().split()))", "-print((sum(sorted(l)[-k:])))", "+t, l = open(0)", "+print((sum(sorted(map(int, l.split()))[-int(t[2:]) :])))" ]
false
0.078459
0.046123
1.701075
[ "s361764328", "s543193519" ]
u489762173
p02947
python
s114685659
s546347925
362
234
18,456
18,336
Accepted
Accepted
35.36
import sys from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, list(range(n, n - r, -1)), 1) denom = reduce(mul, list(range(1, r + 1)), 1) return numer // denom def main(): N = int(eval(input())) Ss = {} f...
import sys from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, list(range(n, n - r, -1)), 1) denom = reduce(mul, list(range(1, r + 1)), 1) return numer // denom def main(): N = int(eval(input())) Ss = {} f...
32
32
589
611
import sys from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, list(range(n, n - r, -1)), 1) denom = reduce(mul, list(range(1, r + 1)), 1) return numer // denom def main(): N = int(eval(input())) Ss = {} for x in range...
import sys from operator import mul from functools import reduce def combinations_count(n, r): r = min(r, n - r) numer = reduce(mul, list(range(n, n - r, -1)), 1) denom = reduce(mul, list(range(1, r + 1)), 1) return numer // denom def main(): N = int(eval(input())) Ss = {} for x in range...
false
0
[ "- tmp = \"\".join(sorted(eval(input())))", "+ tmp = \"\".join(sorted(sys.stdin.readline().rstrip()))" ]
false
0.038158
0.03769
1.012411
[ "s114685659", "s546347925" ]
u110859855
p02689
python
s436007959
s403552830
317
274
20,916
20,088
Accepted
Accepted
13.56
import copy n,m = list(map(int,input().split())) tall = [int(e) for e in input().split()] bridge = copy.copy(tall) for i in range(m): c = [int(f)-1 for f in input().split()] a,b = c[0],c[1] if bridge[a] < tall[b]: bridge[a] = tall[b] elif bridge[a] == tall[b]: bridge[a] = 1...
n,m = list(map(int,input().split())) tall = [int(e) for e in input().split()] is_best = [True]*n for i in range(m): c = [int(f)-1 for f in input().split()] a,b = c[0],c[1] if tall[a] < tall[b]: is_best[a] = False elif tall[b] < tall[a]: is_best[b] = False else: ...
24
18
530
384
import copy n, m = list(map(int, input().split())) tall = [int(e) for e in input().split()] bridge = copy.copy(tall) for i in range(m): c = [int(f) - 1 for f in input().split()] a, b = c[0], c[1] if bridge[a] < tall[b]: bridge[a] = tall[b] elif bridge[a] == tall[b]: bridge[a] = 10**10 ...
n, m = list(map(int, input().split())) tall = [int(e) for e in input().split()] is_best = [True] * n for i in range(m): c = [int(f) - 1 for f in input().split()] a, b = c[0], c[1] if tall[a] < tall[b]: is_best[a] = False elif tall[b] < tall[a]: is_best[b] = False else: is_bes...
false
25
[ "-import copy", "-", "-bridge = copy.copy(tall)", "+is_best = [True] * n", "- if bridge[a] < tall[b]:", "- bridge[a] = tall[b]", "- elif bridge[a] == tall[b]:", "- bridge[a] = 10**10", "- if bridge[b] < tall[a]:", "- bridge[b] = tall[a]", "- elif bridge[b] == tal...
false
0.047421
0.03926
1.20788
[ "s436007959", "s403552830" ]
u645250356
p03315
python
s585914273
s581530990
312
35
67,308
10,312
Accepted
Accepted
88.78
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) s = ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush from bisect import bisect_left,bisect_right import sys,math,itertools,fractions sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.std...
11
18
370
457
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().s...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush from bisect import bisect_left, bisect_right import sys, math, itertools, fractions sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map...
false
38.888889
[ "-from heapq import heappop, heappush, heapify", "-import sys, bisect, math, itertools, fractions", "+from heapq import heappop, heappush", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions", "-s = list(eval(input()))", "-print((s.count(\"+\") - s.count(\"-\")))",...
false
0.07616
0.035522
2.144003
[ "s585914273", "s581530990" ]
u186838327
p03283
python
s869763188
s039553031
622
457
79,924
22,692
Accepted
Accepted
26.53
n, m, q = list(map(int, input().split())) A = [[0]*n for i in range(n)] for i in range(m): l, r = list(map(int, input().split())) l, r = l-1, r-1 A[l][r] += 1 #print(A) s = [[0]*(n+1) for _ in range(n+1)] for i in range(n): for j in range(n): s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i...
import sys import io, os #input = sys.stdin.buffer.readline input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, m, Q = list(map(int, input().split())) C = [[0]*n for _ in range(n)] for i in range(m): l, r = list(map(int, input().split())) l, r = l-1, r-1 C[l][r] += 1 s = [[0]*(n+1) ...
23
22
490
586
n, m, q = list(map(int, input().split())) A = [[0] * n for i in range(n)] for i in range(m): l, r = list(map(int, input().split())) l, r = l - 1, r - 1 A[l][r] += 1 # print(A) s = [[0] * (n + 1) for _ in range(n + 1)] for i in range(n): for j in range(n): s[i + 1][j + 1] = s[i + 1][j] + s[i][j +...
import sys import io, os # input = sys.stdin.buffer.readline input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n, m, Q = list(map(int, input().split())) C = [[0] * n for _ in range(n)] for i in range(m): l, r = list(map(int, input().split())) l, r = l - 1, r - 1 C[l][r] += 1 s = [[0] * (n + 1) f...
false
4.347826
[ "-n, m, q = list(map(int, input().split()))", "-A = [[0] * n for i in range(n)]", "+import sys", "+import io, os", "+", "+# input = sys.stdin.buffer.readline", "+input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline", "+n, m, Q = list(map(int, input().split()))", "+C = [[0] * n for _ in range...
false
0.038225
0.207728
0.184017
[ "s869763188", "s039553031" ]
u984592063
p02679
python
s424693486
s388389766
1,750
885
68,480
68,572
Accepted
Accepted
49.43
from collections import defaultdict def gcd(a, b): return gcd(b, a%b) if b else a mod = 10 ** 9 + 7 N = int(eval(input())) X = defaultdict(lambda: [0, 0]) # X = dict() x = 0 y = 0 z = 0 for i in range(N): a, b = list(map(int, input().split())) g = abs(gcd(a, b)) if a * b > 0: X...
mod = 10 ** 9 + 7 from math import gcd N = int(eval(input())) from collections import defaultdict X = defaultdict(lambda: [0, 0]) x = 0 y = 0 z = 0 for i in range(N): a, b = list(map(int, input().split())) g = abs(gcd(a, b)) if a * b > 0: X[(abs(a) // g, abs(b) // g)][0] += 1 elif a * b < 0: ...
36
33
814
649
from collections import defaultdict def gcd(a, b): return gcd(b, a % b) if b else a mod = 10**9 + 7 N = int(eval(input())) X = defaultdict(lambda: [0, 0]) # X = dict() x = 0 y = 0 z = 0 for i in range(N): a, b = list(map(int, input().split())) g = abs(gcd(a, b)) if a * b > 0: X[(abs(a) // g,...
mod = 10**9 + 7 from math import gcd N = int(eval(input())) from collections import defaultdict X = defaultdict(lambda: [0, 0]) x = 0 y = 0 z = 0 for i in range(N): a, b = list(map(int, input().split())) g = abs(gcd(a, b)) if a * b > 0: X[(abs(a) // g, abs(b) // g)][0] += 1 elif a * b < 0: ...
false
8.333333
[ "+mod = 10**9 + 7", "+from math import gcd", "+", "+N = int(eval(input()))", "-", "-def gcd(a, b):", "- return gcd(b, a % b) if b else a", "-", "-", "-mod = 10**9 + 7", "-N = int(eval(input()))", "-# X = dict()", "-# suppose we have a super head point which can put togother with every poi...
false
0.091605
0.049201
1.861837
[ "s424693486", "s388389766" ]
u536034761
p02684
python
s852110828
s221163552
195
141
47,460
32,304
Accepted
Accepted
27.69
N, K = list(map(int, input().split(" "))) routs = {} location = [0 for i in range(N + 1)] tereporter = list(map(int, input().split())) for i in range(N): routs[i] = tereporter[i] - 1 present_location = 0 n = 0 for i in range(K): n += 1 present_location = routs[present_location] if location[present_lo...
N, K = list(map(int, input().split())) teleporters = list(map(int, input().split())) n = 0 present = 0 praces = [-1 for i in range(N)] praces[0] = 0 for i in range(K): present = teleporters[present] - 1 n += 1 if praces[present] == -1: praces[present] = n else: before = praces[present] ...
22
18
651
447
N, K = list(map(int, input().split(" "))) routs = {} location = [0 for i in range(N + 1)] tereporter = list(map(int, input().split())) for i in range(N): routs[i] = tereporter[i] - 1 present_location = 0 n = 0 for i in range(K): n += 1 present_location = routs[present_location] if location[present_locat...
N, K = list(map(int, input().split())) teleporters = list(map(int, input().split())) n = 0 present = 0 praces = [-1 for i in range(N)] praces[0] = 0 for i in range(K): present = teleporters[present] - 1 n += 1 if praces[present] == -1: praces[present] = n else: before = praces[present] ...
false
18.181818
[ "-N, K = list(map(int, input().split(\" \")))", "-routs = {}", "-location = [0 for i in range(N + 1)]", "-tereporter = list(map(int, input().split()))", "-for i in range(N):", "- routs[i] = tereporter[i] - 1", "-present_location = 0", "+N, K = list(map(int, input().split()))", "+teleporters = lis...
false
0.102024
0.045997
2.21805
[ "s852110828", "s221163552" ]
u534308356
p02707
python
s293115657
s405488614
178
148
34,208
33,924
Accepted
Accepted
16.85
import collections n = int(eval(input())) data = list(map(int, input().split())) c = collections.Counter(data) for i in range(1, n+1): print((c[i]))
import collections n = int(eval(input())) data = list(map(int, input().split())) count = [0] * n for d in data: count[d-1] += 1 for c in count: print(c)
9
12
154
166
import collections n = int(eval(input())) data = list(map(int, input().split())) c = collections.Counter(data) for i in range(1, n + 1): print((c[i]))
import collections n = int(eval(input())) data = list(map(int, input().split())) count = [0] * n for d in data: count[d - 1] += 1 for c in count: print(c)
false
25
[ "-c = collections.Counter(data)", "-for i in range(1, n + 1):", "- print((c[i]))", "+count = [0] * n", "+for d in data:", "+ count[d - 1] += 1", "+for c in count:", "+ print(c)" ]
false
0.082853
0.034679
2.389131
[ "s293115657", "s405488614" ]
u623814058
p03494
python
s391948206
s170593752
26
23
9,216
9,120
Accepted
Accepted
11.54
N = int(eval(input())) A = list(map(int, input().split())) count = 0 while all(a % 2 == 0 for a in A): A = list([x / 2 for x in A]) count = count + 1 print(count)
N=int(eval(input())) A=list(map(int, input().split())) count=0 while all(a%2==0 for a in A): A=[i/2 for i in A] count+=1 print(count)
9
7
179
141
N = int(eval(input())) A = list(map(int, input().split())) count = 0 while all(a % 2 == 0 for a in A): A = list([x / 2 for x in A]) count = count + 1 print(count)
N = int(eval(input())) A = list(map(int, input().split())) count = 0 while all(a % 2 == 0 for a in A): A = [i / 2 for i in A] count += 1 print(count)
false
22.222222
[ "- A = list([x / 2 for x in A])", "- count = count + 1", "+ A = [i / 2 for i in A]", "+ count += 1" ]
false
0.101705
0.048637
2.091112
[ "s391948206", "s170593752" ]
u490553751
p02784
python
s119541906
s748772258
60
47
13,588
14,268
Accepted
Accepted
21.67
import sys input = sys.stdin.readline H,N = [int(i) for i in input().split()] A = [int(i) for i in input().split()] sum = 0 for i in range(N) : sum += A[i] if sum >= H : print("Yes") else : print("No")
#template from collections import Counter def inputlist(): return [int(j) for j in input().split()] H,N = inputlist() A = inputlist() s = sum(A) if H <= s: print("Yes") else: print("No")
11
10
223
203
import sys input = sys.stdin.readline H, N = [int(i) for i in input().split()] A = [int(i) for i in input().split()] sum = 0 for i in range(N): sum += A[i] if sum >= H: print("Yes") else: print("No")
# template from collections import Counter def inputlist(): return [int(j) for j in input().split()] H, N = inputlist() A = inputlist() s = sum(A) if H <= s: print("Yes") else: print("No")
false
9.090909
[ "-import sys", "+# template", "+from collections import Counter", "-input = sys.stdin.readline", "-H, N = [int(i) for i in input().split()]", "-A = [int(i) for i in input().split()]", "-sum = 0", "-for i in range(N):", "- sum += A[i]", "-if sum >= H:", "+", "+def inputlist():", "+ retu...
false
0.040445
0.0481
0.840857
[ "s119541906", "s748772258" ]
u634079249
p03835
python
s610063890
s045371902
1,280
748
2,940
39,832
Accepted
Accepted
41.56
import sys import os def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") K, S = list(map(int, sys.stdin.readline().split())) ret = 0 for x in range(K + 1): for y in range(K + 1): if S - x - y <= K and S - x - y >= 0: ret += ...
import sys import os import math ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambd...
20
27
376
799
import sys import os def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") K, S = list(map(int, sys.stdin.readline().split())) ret = 0 for x in range(K + 1): for y in range(K + 1): if S - x - y <= K and S - x - y >= 0: ret += 1 print(ret)...
import sys import os import math ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.std...
false
25.925926
[ "+import math", "+", "+ii = lambda: int(sys.stdin.buffer.readline().rstrip())", "+il = lambda: list(map(int, sys.stdin.buffer.readline().split()))", "+fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))", "+iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]", "+...
false
0.043382
0.083778
0.517828
[ "s610063890", "s045371902" ]
u659159398
p02712
python
s258445408
s768326191
151
68
9,168
64,712
Accepted
Accepted
54.97
n = int(eval(input())) totsum = 0 for num in range(1, n+1): if num%3!=0 and num%5!=0: totsum+=num print(totsum)
n = int(eval(input())) ans = 0 for i in range(1, n+1): if i%3 == 0 or i%5==0: pass else: ans += i print(ans)
7
8
122
133
n = int(eval(input())) totsum = 0 for num in range(1, n + 1): if num % 3 != 0 and num % 5 != 0: totsum += num print(totsum)
n = int(eval(input())) ans = 0 for i in range(1, n + 1): if i % 3 == 0 or i % 5 == 0: pass else: ans += i print(ans)
false
12.5
[ "-totsum = 0", "-for num in range(1, n + 1):", "- if num % 3 != 0 and num % 5 != 0:", "- totsum += num", "-print(totsum)", "+ans = 0", "+for i in range(1, n + 1):", "+ if i % 3 == 0 or i % 5 == 0:", "+ pass", "+ else:", "+ ans += i", "+print(ans)" ]
false
0.11844
0.255504
0.463553
[ "s258445408", "s768326191" ]
u193264896
p02814
python
s978914008
s185515563
772
245
27,232
39,688
Accepted
Accepted
68.26
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree from scipy.sparse import csr_matrix, coo_matrix, lil_matrix import numpy as np from collections import deque, Counter, defaultdict from itertools import product, permutations,combinations from ope...
import sys from math import gcd from functools import reduce import numpy as np read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def lcm_base(a, b): return (a * b) // gcd(a, b) def lcm_list(numbers): return r...
50
44
1,281
846
from scipy.sparse.csgraph import ( shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree, ) from scipy.sparse import csr_matrix, coo_matrix, lil_matrix import numpy as np from collections import deque, Counter, defaultdict from itertools import product, permutatio...
import sys from math import gcd from functools import reduce import numpy as np read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def lcm_base(a, b): return (a * b) // gcd(a, b) def lcm_list(numbers): return reduce(lcm_base, numbers, ...
false
12
[ "-from scipy.sparse.csgraph import (", "- shortest_path,", "- floyd_warshall,", "- dijkstra,", "- bellman_ford,", "- johnson,", "- minimum_spanning_tree,", "-)", "-from scipy.sparse import csr_matrix, coo_matrix, lil_matrix", "+import sys", "+from math import gcd", "+from fun...
false
0.226891
0.274772
0.825745
[ "s978914008", "s185515563" ]
u589381719
p03161
python
s424240069
s242331973
444
340
52,448
52,448
Accepted
Accepted
23.42
# 貰うDP N,K=list(map(int,input().split())) h=list(map(int,input().split())) INF=10**9 dp=[INF]*(N) dp[0]=0 for n in range(1,N): dp[n]=min([dp[k] + abs(h[n] - h[k]) for k in range(max(0,n-K), n)]) print((dp[N-1]))
# 配るDP N,K=list(map(int,input().split())) H=list(map(int,input().split())) INF=10**9 add_list=[INF]*K H.extend(add_list) dp=[INF]*(N+100) #Kの分追加 dp[0]=0 for n in range(N): for k in range(n+1,n+K+1): dp[k]=min(dp[k], dp[n]+abs(H[n]-H[k])) print((dp[N-1]))
10
14
217
273
# 貰うDP N, K = list(map(int, input().split())) h = list(map(int, input().split())) INF = 10**9 dp = [INF] * (N) dp[0] = 0 for n in range(1, N): dp[n] = min([dp[k] + abs(h[n] - h[k]) for k in range(max(0, n - K), n)]) print((dp[N - 1]))
# 配るDP N, K = list(map(int, input().split())) H = list(map(int, input().split())) INF = 10**9 add_list = [INF] * K H.extend(add_list) dp = [INF] * (N + 100) # Kの分追加 dp[0] = 0 for n in range(N): for k in range(n + 1, n + K + 1): dp[k] = min(dp[k], dp[n] + abs(H[n] - H[k])) print((dp[N - 1]))
false
28.571429
[ "-# 貰うDP", "+# 配るDP", "-h = list(map(int, input().split()))", "+H = list(map(int, input().split()))", "-dp = [INF] * (N)", "+add_list = [INF] * K", "+H.extend(add_list)", "+dp = [INF] * (N + 100) # Kの分追加", "-for n in range(1, N):", "- dp[n] = min([dp[k] + abs(h[n] - h[k]) for k in range(max(0,...
false
0.065984
0.117927
0.559532
[ "s424240069", "s242331973" ]
u075012704
p02586
python
s895762014
s690228172
1,208
1,001
433,756
357,588
Accepted
Accepted
17.14
def main(): import sys my_input = sys.stdin.readline H, W, K = list(map(int, my_input().split())) V = [[0] * W for _ in range(H)] for i in range(K): h, w, v = list(map(int, my_input().split())) h, w = h - 1, w - 1 V[h][w] = v # dp1 ~ 4[h][w][x] := h行w列にいて、h行からn...
def main(): import sys my_input = sys.stdin.readline H, W, K = list(map(int, my_input().split())) V = [[0] * W for _ in range(H)] for i in range(K): h, w, v = list(map(int, my_input().split())) h, w = h - 1, w - 1 V[h][w] = v # dp1 ~ 4[h][w][x] := h行w列にいて、h行からn...
44
42
1,281
1,182
def main(): import sys my_input = sys.stdin.readline H, W, K = list(map(int, my_input().split())) V = [[0] * W for _ in range(H)] for i in range(K): h, w, v = list(map(int, my_input().split())) h, w = h - 1, w - 1 V[h][w] = v # dp1 ~ 4[h][w][x] := h行w列にいて、h行からn個アイテムを拾ってい...
def main(): import sys my_input = sys.stdin.readline H, W, K = list(map(int, my_input().split())) V = [[0] * W for _ in range(H)] for i in range(K): h, w, v = list(map(int, my_input().split())) h, w = h - 1, w - 1 V[h][w] = v # dp1 ~ 4[h][w][x] := h行w列にいて、h行からn個アイテムを拾ってい...
false
4.545455
[ "- dp0 = [[0] * (W + 1) for _ in range(H + 1)]", "- dp1[h][w] = max(", "- dp1[h][w],", "- dp3[h - 1][w] + V[h - 1][w - 1],", "- dp1[h][w - 1],", "- dp0[h][w - 1] + V[h - 1][w - 1],", "- )", "+ dp1[h][w] = m...
false
0.036447
0.038165
0.954996
[ "s895762014", "s690228172" ]
u188827677
p02983
python
s055764395
s932129934
773
45
2,940
3,060
Accepted
Accepted
94.18
l,r = list(map(int, input().split())) if r - l >= 2018: print((0)) else: ans = 2019 for i in range(l, r): for j in range(i + 1, r + 1): ans = min(ans, i * j % 2019) print(ans)
l,r = list(map(int, input().split())) ans = 2019 for i in range(l, r): for j in range(i+1, r+1): t = i*j%2019 if ans > t: ans = t if ans == 0: print(ans) exit() print(ans)
9
12
193
209
l, r = list(map(int, input().split())) if r - l >= 2018: print((0)) else: ans = 2019 for i in range(l, r): for j in range(i + 1, r + 1): ans = min(ans, i * j % 2019) print(ans)
l, r = list(map(int, input().split())) ans = 2019 for i in range(l, r): for j in range(i + 1, r + 1): t = i * j % 2019 if ans > t: ans = t if ans == 0: print(ans) exit() print(ans)
false
25
[ "-if r - l >= 2018:", "- print((0))", "-else:", "- ans = 2019", "- for i in range(l, r):", "- for j in range(i + 1, r + 1):", "- ans = min(ans, i * j % 2019)", "- print(ans)", "+ans = 2019", "+for i in range(l, r):", "+ for j in range(i + 1, r + 1):", "+ ...
false
0.067371
0.038282
1.759884
[ "s055764395", "s932129934" ]
u120810144
p03425
python
s474877969
s903131242
163
150
10,520
10,520
Accepted
Accepted
7.98
n = int(eval(input())) s = [eval(input()) for i in range(n)] order = "MARCH" nums = [[name[0] for name in s].count(order[i]) for i in range(len(order))] ans = 0 for i in range(0, 5): for j in range(i+1, 5): for k in range(j+1, 5): ans += nums[i] * nums[j] * nums[k] ...
n = int(eval(input())) s = [eval(input()) for i in range(n)] order = "MARCH" initial_array = [name[0] for name in s] nums = [initial_array.count(order[i]) for i in range(len(order))] ans = 0 for i in range(0, 5): for j in range(i+1, 5): for k in range(j+1, 5): ans += nums[i] * n...
16
17
322
353
n = int(eval(input())) s = [eval(input()) for i in range(n)] order = "MARCH" nums = [[name[0] for name in s].count(order[i]) for i in range(len(order))] ans = 0 for i in range(0, 5): for j in range(i + 1, 5): for k in range(j + 1, 5): ans += nums[i] * nums[j] * nums[k] print(ans)
n = int(eval(input())) s = [eval(input()) for i in range(n)] order = "MARCH" initial_array = [name[0] for name in s] nums = [initial_array.count(order[i]) for i in range(len(order))] ans = 0 for i in range(0, 5): for j in range(i + 1, 5): for k in range(j + 1, 5): ans += nums[i] * nums[j] * nums...
false
5.882353
[ "-nums = [[name[0] for name in s].count(order[i]) for i in range(len(order))]", "+initial_array = [name[0] for name in s]", "+nums = [initial_array.count(order[i]) for i in range(len(order))]" ]
false
0.048744
0.040589
1.200924
[ "s474877969", "s903131242" ]
u539281377
p02784
python
s747695385
s051772472
78
41
13,964
13,916
Accepted
Accepted
47.44
H,N=list(map(int,input().split())) A=sorted((list(map(int,input().split())))) A=A[::-1] print(("Yes" if sum(A[0:N])>=H else "No"))
H,N,*A=list(map(int,open(0).read().split())) print(("Yes" if sum(A)>=H else "No"))
4
2
125
75
H, N = list(map(int, input().split())) A = sorted((list(map(int, input().split())))) A = A[::-1] print(("Yes" if sum(A[0:N]) >= H else "No"))
H, N, *A = list(map(int, open(0).read().split())) print(("Yes" if sum(A) >= H else "No"))
false
50
[ "-H, N = list(map(int, input().split()))", "-A = sorted((list(map(int, input().split()))))", "-A = A[::-1]", "-print((\"Yes\" if sum(A[0:N]) >= H else \"No\"))", "+H, N, *A = list(map(int, open(0).read().split()))", "+print((\"Yes\" if sum(A) >= H else \"No\"))" ]
false
0.042061
0.042999
0.978165
[ "s747695385", "s051772472" ]
u332906195
p02583
python
s612782048
s056844504
144
87
9,188
9,168
Accepted
Accepted
39.58
N = int(input()) L = list(map(int, input().split())) ans = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j] \ and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]: ...
N = int(eval(input())) L = sorted(list(map(int, input().split()))) ans = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if L[i] + L[j] > L[k] and L[i] != L[j] and L[j] != L[k]: ans += 1 print(ans)
11
9
345
265
N = int(input()) L = list(map(int, input().split())) ans = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if ( L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j] and L[i] != L[j] ...
N = int(eval(input())) L = sorted(list(map(int, input().split()))) ans = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if L[i] + L[j] > L[k] and L[i] != L[j] and L[j] != L[k]: ans += 1 print(ans)
false
18.181818
[ "-N = int(input())", "-L = list(map(int, input().split()))", "+N = int(eval(input()))", "+L = sorted(list(map(int, input().split())))", "- if (", "- L[i] + L[j] > L[k]", "- and L[j] + L[k] > L[i]", "- and L[k] + L[i] > L[j]", "- ...
false
0.106208
0.085092
1.248156
[ "s612782048", "s056844504" ]
u652057333
p02695
python
s690245351
s503905852
249
182
9,232
70,644
Accepted
Accepted
26.91
from itertools import combinations import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(20000000) n, m, q = list(map(int, input().split())) abcd = [] for i in range(q): a, b, c, d = list(map(int, input().split())) abcd.append([a-1, b-1, c, d]) # def check(Q): # A = [1...
from itertools import combinations import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(20000000) n, m, q = list(map(int, input().split())) abcd = [] for i in range(q): a, b, c, d = list(map(int, input().split())) abcd.append([a-1, b-1, c, d]) def dfs(A, depth, max_a): ...
50
26
1,403
611
from itertools import combinations import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(20000000) n, m, q = list(map(int, input().split())) abcd = [] for i in range(q): a, b, c, d = list(map(int, input().split())) abcd.append([a - 1, b - 1, c, d]) # def check(Q): # A = [1] + [-1 f...
from itertools import combinations import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(20000000) n, m, q = list(map(int, input().split())) abcd = [] for i in range(q): a, b, c, d = list(map(int, input().split())) abcd.append([a - 1, b - 1, c, d]) def dfs(A, depth, max_a): if de...
false
48
[ "-# def check(Q):", "-# A = [1] + [-1 for _ in range(n-1)]", "-# score = 0", "-# for a, b, c, d in Q:", "-# if A[a] == -1 and A[b] == -1:", "-# tmp_b = min(A[b:])", "-# if tmp_b == -1 or tmp_b >= max(A[:a]) + c:", "-# A[a] = max(A[:a])", "-...
false
0.103857
0.043432
2.39125
[ "s690245351", "s503905852" ]
u086503932
p02936
python
s024888778
s237565209
1,841
1,669
230,960
56,156
Accepted
Accepted
9.34
import sys input = sys.stdin.readline #for input speed sys.setrecursionlimit(10**6) def DFS(v, parent): global v_count for u in adj[v]: if u != parent: v_count[u] += v_count[v] DFS(u,v) N, Q = list(map(int, input().split())) adj = [[] for _ in range(N)] v_count = [0] * N for i in...
from collections import deque N, Q = list(map(int, input().split())) adj = [[] for _ in range(N)] count = [0] * N for _ in range(N-1): a,b = list(map(int, input().split())) adj[a-1].append(b-1) adj[b-1].append(a-1) for _ in range(Q): p,x = list(map(int, input().split())) count[p-1] += x q...
30
27
588
530
import sys input = sys.stdin.readline # for input speed sys.setrecursionlimit(10**6) def DFS(v, parent): global v_count for u in adj[v]: if u != parent: v_count[u] += v_count[v] DFS(u, v) N, Q = list(map(int, input().split())) adj = [[] for _ in range(N)] v_count = [0] * N ...
from collections import deque N, Q = list(map(int, input().split())) adj = [[] for _ in range(N)] count = [0] * N for _ in range(N - 1): a, b = list(map(int, input().split())) adj[a - 1].append(b - 1) adj[b - 1].append(a - 1) for _ in range(Q): p, x = list(map(int, input().split())) count[p - 1] +=...
false
10
[ "-import sys", "-", "-input = sys.stdin.readline # for input speed", "-sys.setrecursionlimit(10**6)", "-", "-", "-def DFS(v, parent):", "- global v_count", "- for u in adj[v]:", "- if u != parent:", "- v_count[u] += v_count[v]", "- DFS(u, v)", "-", "+fro...
false
0.039789
0.038666
1.029052
[ "s024888778", "s237565209" ]
u690037900
p03574
python
s493411911
s050148833
218
30
14,472
3,064
Accepted
Accepted
86.24
import numpy as np h,w=list(map(int,input().split())) L=[[i for i in eval(input())] for i in range(h)] L_first=np.zeros((2,w),dtype=str) L_first2=np.zeros((1,1),dtype=str) L=np.array(L,dtype=str) L=np.insert(L_first,1,L,axis=0) L=np.insert(L,0,L_first2,axis=1) L=np.insert(L,w+1,L_first2,axis=1) ans=np.zeros((h...
H, W = list(map(int, input().split())) src = [list(eval(input())) for i in range(H)] ans=src dxy = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)] for y in range(H): for x in range(W): if src[y][x] == '#': continue c = 0 for dx, dy in dxy: if x +...
19
16
575
509
import numpy as np h, w = list(map(int, input().split())) L = [[i for i in eval(input())] for i in range(h)] L_first = np.zeros((2, w), dtype=str) L_first2 = np.zeros((1, 1), dtype=str) L = np.array(L, dtype=str) L = np.insert(L_first, 1, L, axis=0) L = np.insert(L, 0, L_first2, axis=1) L = np.insert(L, w + 1, L_first...
H, W = list(map(int, input().split())) src = [list(eval(input())) for i in range(H)] ans = src dxy = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)] for y in range(H): for x in range(W): if src[y][x] == "#": continue c = 0 for dx, dy in dxy: if ...
false
15.789474
[ "-import numpy as np", "-", "-h, w = list(map(int, input().split()))", "-L = [[i for i in eval(input())] for i in range(h)]", "-L_first = np.zeros((2, w), dtype=str)", "-L_first2 = np.zeros((1, 1), dtype=str)", "-L = np.array(L, dtype=str)", "-L = np.insert(L_first, 1, L, axis=0)", "-L = np.insert(L...
false
0.319639
0.043596
7.331796
[ "s493411911", "s050148833" ]
u969850098
p03103
python
s372741312
s507594379
1,767
337
24,444
27,756
Accepted
Accepted
80.93
import sys n_shops, n_drinks = list(map(int, input().split())) shop_info = sorted([tuple(map(int, line.split())) for line in sys.stdin.readlines()]) cost = 0 purchased_n_drinks = 0 for _ in range(len(shop_info)): info = shop_info.pop(0) if (purchased_n_drinks + info[1]) >= n_drinks: cost += ( n_...
import sys readline = sys.stdin.readline def main(): N, M = list(map(int, readline().rstrip().split())) AB = [list(map(int, readline().rstrip().split())) for _ in range(N)] AB.sort() pro = 0 cost = 0 for a, b in AB: if pro + b >= M: cost += (M - pro) * a ...
13
21
446
431
import sys n_shops, n_drinks = list(map(int, input().split())) shop_info = sorted([tuple(map(int, line.split())) for line in sys.stdin.readlines()]) cost = 0 purchased_n_drinks = 0 for _ in range(len(shop_info)): info = shop_info.pop(0) if (purchased_n_drinks + info[1]) >= n_drinks: cost += (n_drinks -...
import sys readline = sys.stdin.readline def main(): N, M = list(map(int, readline().rstrip().split())) AB = [list(map(int, readline().rstrip().split())) for _ in range(N)] AB.sort() pro = 0 cost = 0 for a, b in AB: if pro + b >= M: cost += (M - pro) * a break ...
false
38.095238
[ "-n_shops, n_drinks = list(map(int, input().split()))", "-shop_info = sorted([tuple(map(int, line.split())) for line in sys.stdin.readlines()])", "-cost = 0", "-purchased_n_drinks = 0", "-for _ in range(len(shop_info)):", "- info = shop_info.pop(0)", "- if (purchased_n_drinks + info[1]) >= n_drink...
false
0.035301
0.035684
0.989266
[ "s372741312", "s507594379" ]
u353919145
p03160
python
s469975455
s899819365
145
133
13,928
21,032
Accepted
Accepted
8.28
n = int(eval(input())) h = list(map(int, input().split())) dp = [float("inf") for i in range(n)] dp[0] = 0 dp[1] = dp[0] + (h[1] - h[0]) for i in range(1, n): dp[i] = min(dp[i - 2] + (abs(h[i] - h[i - 2])), dp[i - 1] + (abs(h[i] - h[i - 1]))) print((dp[n - 1]))
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ sys.setrecursionlimit(1000000) # do magic here n = int(eval(input())) heights = [int(x) for x in input().split()] dp = [0 for x in range(n+1)] dp[1] = abs(heights[1]-heights[0]) for x in range(2, n): a = abs(heights[x]-heigh...
8
18
264
422
n = int(eval(input())) h = list(map(int, input().split())) dp = [float("inf") for i in range(n)] dp[0] = 0 dp[1] = dp[0] + (h[1] - h[0]) for i in range(1, n): dp[i] = min(dp[i - 2] + (abs(h[i] - h[i - 2])), dp[i - 1] + (abs(h[i] - h[i - 1]))) print((dp[n - 1]))
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ sys.setrecursionlimit(1000000) # do magic here n = int(eval(input())) heights = [int(x) for x in input().split()] dp = [0 for x in range(n + 1)] dp[1] = abs(heights[1] - heights[0]) for x in range(2, n): a = abs(heights[x] - heights[x - 1]...
false
55.555556
[ "+import sys", "+", "+reader = (s.rstrip() for s in sys.stdin)", "+input = reader.__next__", "+sys.setrecursionlimit(1000000)", "+# do magic here", "-h = list(map(int, input().split()))", "-dp = [float(\"inf\") for i in range(n)]", "-dp[0] = 0", "-dp[1] = dp[0] + (h[1] - h[0])", "-for i in range...
false
0.06976
0.046718
1.493227
[ "s469975455", "s899819365" ]
u991567869
p03814
python
s853997748
s534491723
36
18
3,516
3,512
Accepted
Accepted
50
s = eval(input()) for i in range(len(s)): if s[i] == "A": start = i break for i in range(len(s))[::-1]: if s[i] == "Z": end = i break ans = end - start + 1 print(ans)
s = eval(input()) ans = len(s[s.find("A"): s.rfind("Z")]) + 1 print(ans)
14
3
216
68
s = eval(input()) for i in range(len(s)): if s[i] == "A": start = i break for i in range(len(s))[::-1]: if s[i] == "Z": end = i break ans = end - start + 1 print(ans)
s = eval(input()) ans = len(s[s.find("A") : s.rfind("Z")]) + 1 print(ans)
false
78.571429
[ "-for i in range(len(s)):", "- if s[i] == \"A\":", "- start = i", "- break", "-for i in range(len(s))[::-1]:", "- if s[i] == \"Z\":", "- end = i", "- break", "-ans = end - start + 1", "+ans = len(s[s.find(\"A\") : s.rfind(\"Z\")]) + 1" ]
false
0.082249
0.088227
0.932238
[ "s853997748", "s534491723" ]
u811733736
p00030
python
s064211294
s457601956
50
40
7,884
7,888
Accepted
Accepted
20
from collections import deque class Bt(object): def __init__(self): self.used = [False] * 10 # 0-9????????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°???????¨???¶??¨ ...
from collections import deque class Bt(object): def __init__(self): self.used = [False] * 10 # 0-9????????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°???????¨???¶??¨ ...
54
57
1,702
1,783
from collections import deque class Bt(object): def __init__(self): self.used = [ False ] * 10 # 0-9????????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°??????...
from collections import deque class Bt(object): def __init__(self): self.used = [ False ] * 10 # 0-9????????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°??????...
false
5.263158
[ "- # self.Q.append(remain)", "+ self.Q.append(remain)", "- # ans.sort()", "- # if not ans in self.answers:", "- # self.answers.append(ans)", "- # self.Q.pop()", "- self.answers.append(1)", "+ ans = []", "+ ...
false
0.046201
0.067297
0.686517
[ "s064211294", "s457601956" ]
u919633157
p03854
python
s269412183
s657833154
76
27
3,188
11,636
Accepted
Accepted
64.47
s=input()[::-1] ans='YES' while len(s)>0: if s[:5] in ['dream'[::-1],'erase'[::-1]]: s=s[5:] elif s[:6] in ['eraser'[::-1]]: s=s[6:] elif s[:7] in ['dreamer'[::-1]]: s=s[7:] else: ans='NO' break print(ans)
import re s=eval(input()) pat=r'^(dream(er)?|erase(r)?)*$' a=re.match(pat,s) print(('YES' if a else 'NO'))
13
5
273
102
s = input()[::-1] ans = "YES" while len(s) > 0: if s[:5] in ["dream"[::-1], "erase"[::-1]]: s = s[5:] elif s[:6] in ["eraser"[::-1]]: s = s[6:] elif s[:7] in ["dreamer"[::-1]]: s = s[7:] else: ans = "NO" break print(ans)
import re s = eval(input()) pat = r"^(dream(er)?|erase(r)?)*$" a = re.match(pat, s) print(("YES" if a else "NO"))
false
61.538462
[ "-s = input()[::-1]", "-ans = \"YES\"", "-while len(s) > 0:", "- if s[:5] in [\"dream\"[::-1], \"erase\"[::-1]]:", "- s = s[5:]", "- elif s[:6] in [\"eraser\"[::-1]]:", "- s = s[6:]", "- elif s[:7] in [\"dreamer\"[::-1]]:", "- s = s[7:]", "- else:", "- ans...
false
0.043745
0.048829
0.895881
[ "s269412183", "s657833154" ]
u200887663
p02773
python
s325833164
s413336316
770
711
32,096
32,096
Accepted
Accepted
7.66
n=int(eval(input())) dic={} for i in range(n): s=eval(input()) count=dic.get(s,0) count+=1 dic[s]=count mx=1 for v in list(dic.values()): mx=max(v,mx) ans=[] for k,v in list(dic.items()): if v==mx: ans.append(k) ans.sort() #print("---") for st in ans: print(st) ...
n=int(eval(input())) #n,m=map(int,input().split()) #hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] dic={} for i in range(n): s=eval(input()) dic[s]=dic.get(s,0)+1 mx=max(dic.values()) ansl=[] for k, v in list(dic.items()): if v==mx: ansl.app...
21
21
297
357
n = int(eval(input())) dic = {} for i in range(n): s = eval(input()) count = dic.get(s, 0) count += 1 dic[s] = count mx = 1 for v in list(dic.values()): mx = max(v, mx) ans = [] for k, v in list(dic.items()): if v == mx: ans.append(k) ans.sort() # print("---") for st in ans: print(st...
n = int(eval(input())) # n,m=map(int,input().split()) # hl=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] dic = {} for i in range(n): s = eval(input()) dic[s] = dic.get(s, 0) + 1 mx = max(dic.values()) ansl = [] for k, v in list(dic.items()): if v == mx: ansl.a...
false
0
[ "+# n,m=map(int,input().split())", "+# hl=list(map(int,input().split()))", "+# l=[list(map(int,input().split())) for i in range(n)]", "- count = dic.get(s, 0)", "- count += 1", "- dic[s] = count", "-mx = 1", "-for v in list(dic.values()):", "- mx = max(v, mx)", "-ans = []", "+ dic...
false
0.160504
0.105583
1.520176
[ "s325833164", "s413336316" ]
u619819312
p03845
python
s239396441
s862276674
21
18
3,060
3,060
Accepted
Accepted
14.29
s=int(eval(input())) a=list(map(int,input().split())) b=int(eval(input())) s=[] for i in range(b): c,d=list(map(int,input().split())) s.append(sum(a[:c-1])+sum(a[c:])+d) print((s[i]))
s=int(eval(input())) a=list(map(int,input().split())) b=int(eval(input())) for i in range(b): c,d=list(map(int,input().split())) print((sum(a[:c-1])+sum(a[c:])+d))
8
6
185
159
s = int(eval(input())) a = list(map(int, input().split())) b = int(eval(input())) s = [] for i in range(b): c, d = list(map(int, input().split())) s.append(sum(a[: c - 1]) + sum(a[c:]) + d) print((s[i]))
s = int(eval(input())) a = list(map(int, input().split())) b = int(eval(input())) for i in range(b): c, d = list(map(int, input().split())) print((sum(a[: c - 1]) + sum(a[c:]) + d))
false
25
[ "-s = []", "- s.append(sum(a[: c - 1]) + sum(a[c:]) + d)", "- print((s[i]))", "+ print((sum(a[: c - 1]) + sum(a[c:]) + d))" ]
false
0.073303
0.106966
0.685292
[ "s239396441", "s862276674" ]
u673361376
p03575
python
s633134428
s384488625
182
21
39,536
3,316
Accepted
Accepted
88.46
def findunit(edges, N): roots = [i for i in range(N)] for edge in edges: if roots[edge[0]] == roots[edge[1]]:continue prv_root = roots[edge[1]] for idx, root in enumerate(roots): if root == prv_root: roots[idx] = roots[edge[0]] return roots N,M=list(map(int,input().split())) ...
from collections import deque def is_all_nodes_connected(): q = deque() used = set() q.append(1) used.add(1) while len(q) > 0: prv_node = q.pop() for node in g[prv_node]: if node in used: continue else: q.append(...
16
41
487
823
def findunit(edges, N): roots = [i for i in range(N)] for edge in edges: if roots[edge[0]] == roots[edge[1]]: continue prv_root = roots[edge[1]] for idx, root in enumerate(roots): if root == prv_root: roots[idx] = roots[edge[0]] return roots ...
from collections import deque def is_all_nodes_connected(): q = deque() used = set() q.append(1) used.add(1) while len(q) > 0: prv_node = q.pop() for node in g[prv_node]: if node in used: continue else: q.append(node) ...
false
60.97561
[ "-def findunit(edges, N):", "- roots = [i for i in range(N)]", "- for edge in edges:", "- if roots[edge[0]] == roots[edge[1]]:", "- continue", "- prv_root = roots[edge[1]]", "- for idx, root in enumerate(roots):", "- if root == prv_root:", "- ...
false
0.046401
0.147012
0.315627
[ "s633134428", "s384488625" ]
u815878613
p03452
python
s499581008
s726872069
1,025
907
62,136
63,036
Accepted
Accepted
11.51
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline class WeightedUnionFind: def __init__(self, N): self.par = [i for i in range(N)] self.rank = [0] * N self.weight = [0] * N # 親までの距離 def find(self, x): if self.par[x] == x: ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline class WeightedUnionFind: def __init__(self, N): self.par = [i for i in range(N)] self.rank = [0] * N self.weight = [0] * N # 親までの距離 def find(self, x): if self.par[x] == x: ...
62
66
1,446
1,505
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline class WeightedUnionFind: def __init__(self, N): self.par = [i for i in range(N)] self.rank = [0] * N self.weight = [0] * N # 親までの距離 def find(self, x): if self.par[x] == x: return x ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline class WeightedUnionFind: def __init__(self, N): self.par = [i for i in range(N)] self.rank = [0] * N self.weight = [0] * N # 親までの距離 def find(self, x): if self.par[x] == x: return x ...
false
6.060606
[ "+ a = []", "+ a.append(l)", "+ a.append(r)", "+ for i in set(a):", "+ D.find(i)", "- D.find(l)", "- D.find(r)" ]
false
0.046326
0.046346
0.999574
[ "s499581008", "s726872069" ]
u256464928
p02845
python
s958277263
s703690109
108
78
20,952
14,020
Accepted
Accepted
27.78
def main(): from collections import defaultdict N = int(eval(input())) A = list(map(int,input().split())) MOD = 1000000007 c = defaultdict(int) c[0] = 3 ans = 1 for i in range(N): if not c[A[i]]: print((0)) exit() ans *= c[A[i]] ans %= MOD c[A[i]] -= 1 c[A[...
def main(): N = int(eval(input())) A = list(map(int,input().split())) MOD = 1000000007 c = [0] * (N+1) c[0] = 3 ans = 1 for i in range(N): if not c[A[i]]: print((0)) exit() ans *= c[A[i]] ans %= MOD c[A[i]] -= 1 c[A[i]+1] += 1 print(ans) main() ...
19
18
359
315
def main(): from collections import defaultdict N = int(eval(input())) A = list(map(int, input().split())) MOD = 1000000007 c = defaultdict(int) c[0] = 3 ans = 1 for i in range(N): if not c[A[i]]: print((0)) exit() ans *= c[A[i]] ans %= MO...
def main(): N = int(eval(input())) A = list(map(int, input().split())) MOD = 1000000007 c = [0] * (N + 1) c[0] = 3 ans = 1 for i in range(N): if not c[A[i]]: print((0)) exit() ans *= c[A[i]] ans %= MOD c[A[i]] -= 1 c[A[i] + 1] +...
false
5.263158
[ "- from collections import defaultdict", "-", "- c = defaultdict(int)", "+ c = [0] * (N + 1)" ]
false
0.035809
0.035622
1.005254
[ "s958277263", "s703690109" ]
u906501980
p03161
python
s432251256
s980139152
1,500
364
13,908
52,448
Accepted
Accepted
75.73
def main(): n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [None]*n dp[0], dp[1] = 0, abs(h[0]-h[1]) for i, hi in enumerate(h[2:], 2): di = 10**9 m = max(0, i-k) for dj, hj in zip(dp[m:i], h[m:i]): hh = hj-hi ...
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [10**9+1]*n dp[0] = 0 dp[1] = abs(h[1]-h[0]) for i in range(2, n): for j in range(1, min(i+1, k+1)): dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j])) print((dp[n-1]))
21
10
528
260
def main(): n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [None] * n dp[0], dp[1] = 0, abs(h[0] - h[1]) for i, hi in enumerate(h[2:], 2): di = 10**9 m = max(0, i - k) for dj, hj in zip(dp[m:i], h[m:i]): hh = hj - hi if...
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [10**9 + 1] * n dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, n): for j in range(1, min(i + 1, k + 1)): dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j])) print((dp[n - 1]))
false
52.380952
[ "-def main():", "- n, k = list(map(int, input().split()))", "- h = list(map(int, input().split()))", "- dp = [None] * n", "- dp[0], dp[1] = 0, abs(h[0] - h[1])", "- for i, hi in enumerate(h[2:], 2):", "- di = 10**9", "- m = max(0, i - k)", "- for dj, hj in zip(dp[...
false
0.099387
0.042164
2.357184
[ "s432251256", "s980139152" ]
u843175622
p02596
python
s430867984
s831382655
545
68
16,696
63,280
Accepted
Accepted
87.52
k = int(eval(input())) now = 7 cnt = 1 used = [False] * k ten = 10 while not used[now % k]: if now % k == 0: print(cnt) exit() used[now % k] = True now = (now + ten * 7) % k ten = ten * 10 % k cnt += 1 print((-1))
k = int(eval(input())) n = 7 for i in range(k): if n % k == 0: print((i + 1)) exit() n = (n * 10 + 7) % k print((-1))
15
8
257
139
k = int(eval(input())) now = 7 cnt = 1 used = [False] * k ten = 10 while not used[now % k]: if now % k == 0: print(cnt) exit() used[now % k] = True now = (now + ten * 7) % k ten = ten * 10 % k cnt += 1 print((-1))
k = int(eval(input())) n = 7 for i in range(k): if n % k == 0: print((i + 1)) exit() n = (n * 10 + 7) % k print((-1))
false
46.666667
[ "-now = 7", "-cnt = 1", "-used = [False] * k", "-ten = 10", "-while not used[now % k]:", "- if now % k == 0:", "- print(cnt)", "+n = 7", "+for i in range(k):", "+ if n % k == 0:", "+ print((i + 1))", "- used[now % k] = True", "- now = (now + ten * 7) % k", "- t...
false
0.143259
0.09642
1.485785
[ "s430867984", "s831382655" ]
u250583425
p02720
python
s163950852
s088414564
99
68
10,792
10,816
Accepted
Accepted
31.31
import sys import heapq def input(): return sys.stdin.readline().rstrip() def main(): K = int(eval(input())) q = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapq.heapify(q) while len(q) < K: K -= len(q) new_q = [] for i in q: d1 = int(str(i)[-1]) if d1 > 0:...
import sys import heapq def input(): return sys.stdin.readline().rstrip() def main(): K = int(eval(input())) q = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapq.heapify(q) while len(q) < K: K -= len(q) new_q = [] for i in q: d1 = i % 10 if d1 > 0: ...
24
24
578
569
import sys import heapq def input(): return sys.stdin.readline().rstrip() def main(): K = int(eval(input())) q = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapq.heapify(q) while len(q) < K: K -= len(q) new_q = [] for i in q: d1 = int(str(i)[-1]) if d1 > 0: ...
import sys import heapq def input(): return sys.stdin.readline().rstrip() def main(): K = int(eval(input())) q = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapq.heapify(q) while len(q) < K: K -= len(q) new_q = [] for i in q: d1 = i % 10 if d1 > 0: ...
false
0
[ "- d1 = int(str(i)[-1])", "+ d1 = i % 10" ]
false
0.043908
0.078341
0.560474
[ "s163950852", "s088414564" ]
u057109575
p02714
python
s766599560
s801710736
1,402
146
69,080
68,052
Accepted
Accepted
89.59
from bisect import bisect_right N = int(eval(input())) S = eval(input()) d = [[0] * N for _ in range(3)] for i in range(3): for j in range(N): d[i][j] = int(S[j] == "RGB"[i]) cumsum = [[0] * (N + 1) for _ in range(3)] for i in range(3): for j in range(N): cumsum[i][j + 1]...
N = int(eval(input())) S = eval(input()) d = {"R": 0, "G": 0, "B": 0} for i in range(N): d[S[i]] += 1 ans = d["R"] * d["G"] * d["B"] cnt = 0 for i in range(1, N - 1): for j in range(i + 1, N): k = 2 * j - i if k > N or S[i - 1] == S[j - 1]: continue ...
33
21
788
424
from bisect import bisect_right N = int(eval(input())) S = eval(input()) d = [[0] * N for _ in range(3)] for i in range(3): for j in range(N): d[i][j] = int(S[j] == "RGB"[i]) cumsum = [[0] * (N + 1) for _ in range(3)] for i in range(3): for j in range(N): cumsum[i][j + 1] = cumsum[i][j] + d[i][...
N = int(eval(input())) S = eval(input()) d = {"R": 0, "G": 0, "B": 0} for i in range(N): d[S[i]] += 1 ans = d["R"] * d["G"] * d["B"] cnt = 0 for i in range(1, N - 1): for j in range(i + 1, N): k = 2 * j - i if k > N or S[i - 1] == S[j - 1]: continue if S[i - 1] != S[k - 1] an...
false
36.363636
[ "-from bisect import bisect_right", "-", "-d = [[0] * N for _ in range(3)]", "-for i in range(3):", "- for j in range(N):", "- d[i][j] = int(S[j] == \"RGB\"[i])", "-cumsum = [[0] * (N + 1) for _ in range(3)]", "-for i in range(3):", "- for j in range(N):", "- cumsum[i][j + 1] =...
false
0.105318
0.039979
2.63432
[ "s766599560", "s801710736" ]
u367701763
p02550
python
s600991992
s395809412
84
75
75,052
77,860
Accepted
Accepted
10.71
def cycle_getter(N, start): """ :param N: 移動回数 :param start: 初期条件 :return front: cycleまでの要素のリスト cycle: cycle内の要素のリスト end: cycle後の余った部分の要素のリスト cnt: cycle回数 """ p = start front, cycle, end = [], [], [] cnt = 0 visit = {p:0} L, R = N,...
def cycle_getter(N, start): """ :param N: 移動回数 :param start: 初期条件 :return front: cycleまでの要素のリスト cycle: cycle内の要素のリスト end: cycle後の余った部分の要素のリスト cnt: cycle回数 """ p = start front, cycle, end = [], [], [] cnt = 0 visit = {p:0} L, R = N,...
48
45
1,264
1,140
def cycle_getter(N, start): """ :param N: 移動回数 :param start: 初期条件 :return front: cycleまでの要素のリスト cycle: cycle内の要素のリスト end: cycle後の余った部分の要素のリスト cnt: cycle回数 """ p = start front, cycle, end = [], [], [] cnt = 0 visit = {p: 0} L, R = N, -1 for ...
def cycle_getter(N, start): """ :param N: 移動回数 :param start: 初期条件 :return front: cycleまでの要素のリスト cycle: cycle内の要素のリスト end: cycle後の余った部分の要素のリスト cnt: cycle回数 """ p = start front, cycle, end = [], [], [] cnt = 0 visit = {p: 0} L, R = N, -1 P = ...
false
6.25
[ "+ P = [p]", "- p = start", "- for _ in range(L):", "- front.append(p)", "- p = lift(p)", "+ P.append(p)", "+ front = P[:L]", "- for _ in range(L, R):", "- cycle.append(p)", "- p = lift(p)", "- for _ in range(N - (N - L) % peri...
false
0.040291
0.038389
1.049553
[ "s600991992", "s395809412" ]
u038021590
p03162
python
s856780664
s888208034
693
269
76,120
91,100
Accepted
Accepted
61.18
N = int(eval(input())) A_B_C = [] for i in range(N): A_B_C.append(tuple(map(int, input().split()))) DP = [[0]*3 for i in range(N)] DP[0][0] = A_B_C[0][0] DP[0][1] = A_B_C[0][1] DP[0][2] = A_B_C[0][2] for i in range(1, N): for j in range(3): j_a = (j + 1) % 3 j_b = (j + 2) % 3 ...
N = int(eval(input())) F = [tuple(map(int, input().split())) for _ in range(N)] DP = [0] * 3 for f in F: D = [0] * 3 S = {0, 1, 2} for i in range(3): S.remove(i) for s in S: D[i] = max(D[i], f[i] + DP[s]) S.add(i) DP = D print((max(DP)))
17
16
425
299
N = int(eval(input())) A_B_C = [] for i in range(N): A_B_C.append(tuple(map(int, input().split()))) DP = [[0] * 3 for i in range(N)] DP[0][0] = A_B_C[0][0] DP[0][1] = A_B_C[0][1] DP[0][2] = A_B_C[0][2] for i in range(1, N): for j in range(3): j_a = (j + 1) % 3 j_b = (j + 2) % 3 DP[i][j] ...
N = int(eval(input())) F = [tuple(map(int, input().split())) for _ in range(N)] DP = [0] * 3 for f in F: D = [0] * 3 S = {0, 1, 2} for i in range(3): S.remove(i) for s in S: D[i] = max(D[i], f[i] + DP[s]) S.add(i) DP = D print((max(DP)))
false
5.882353
[ "-A_B_C = []", "-for i in range(N):", "- A_B_C.append(tuple(map(int, input().split())))", "-DP = [[0] * 3 for i in range(N)]", "-DP[0][0] = A_B_C[0][0]", "-DP[0][1] = A_B_C[0][1]", "-DP[0][2] = A_B_C[0][2]", "-for i in range(1, N):", "- for j in range(3):", "- j_a = (j + 1) % 3", "-...
false
0.0352
0.036177
0.973007
[ "s856780664", "s888208034" ]
u723711163
p02924
python
s812683795
s278582382
1,461
29
38,384
8,932
Accepted
Accepted
98.02
N = int(eval(input())) S = sum(range(1,N)) print(S)
n = int(eval(input())) n -= 1 print((n*(n+1)//2))
5
4
51
45
N = int(eval(input())) S = sum(range(1, N)) print(S)
n = int(eval(input())) n -= 1 print((n * (n + 1) // 2))
false
20
[ "-N = int(eval(input()))", "-S = sum(range(1, N))", "-print(S)", "+n = int(eval(input()))", "+n -= 1", "+print((n * (n + 1) // 2))" ]
false
0.041475
0.035847
1.157012
[ "s812683795", "s278582382" ]
u561231954
p03168
python
s881297082
s831515383
796
336
274,696
82,808
Accepted
Accepted
57.79
def main(): n=int(eval(input())) p=[float(i) for i in input().split()] dp=[[0]*(n+1) for i in range(n+1)] dp[0][0]=1 for i in range(n): dp[i+1][0]=dp[i][0]*(1-p[i]) for j in range(i+1): dp[i+1][j+1]=dp[i][j]*p[i]+dp[i][j+1]*(1-p[i]) print((sum(dp[n][(n+1)//2:]))) if __nam...
def main(): import numpy as np n=int(eval(input())) p=np.array([float(i) for i in input().split()]) dp=np.zeros([n+1,n+1],dtype=np.float64) dp[0][0]=1 for i in range(n): tmp=np.roll(dp[i],1) tmp[0]=0 dp[i+1]+=dp[i]*(1-p[i])+tmp*p[i] print((sum(dp[n][(n+1)//2:]))) ...
14
18
338
357
def main(): n = int(eval(input())) p = [float(i) for i in input().split()] dp = [[0] * (n + 1) for i in range(n + 1)] dp[0][0] = 1 for i in range(n): dp[i + 1][0] = dp[i][0] * (1 - p[i]) for j in range(i + 1): dp[i + 1][j + 1] = dp[i][j] * p[i] + dp[i][j + 1] * (1 - p[i])...
def main(): import numpy as np n = int(eval(input())) p = np.array([float(i) for i in input().split()]) dp = np.zeros([n + 1, n + 1], dtype=np.float64) dp[0][0] = 1 for i in range(n): tmp = np.roll(dp[i], 1) tmp[0] = 0 dp[i + 1] += dp[i] * (1 - p[i]) + tmp * p[i] pri...
false
22.222222
[ "+ import numpy as np", "+", "- p = [float(i) for i in input().split()]", "- dp = [[0] * (n + 1) for i in range(n + 1)]", "+ p = np.array([float(i) for i in input().split()])", "+ dp = np.zeros([n + 1, n + 1], dtype=np.float64)", "- dp[i + 1][0] = dp[i][0] * (1 - p[i])", "- ...
false
0.039083
0.266088
0.14688
[ "s881297082", "s831515383" ]
u865741247
p03006
python
s788444186
s172188389
1,203
309
3,064
45,460
Accepted
Accepted
74.31
n = int(eval(input())) points = [list(map(int, input().split(" "))) for _ in range(n)] X = 0 Y = 1 ans = 10 ** 14 for i in range(n): for j in range(n): if i == j: continue x1, y1 = points[i] x2, y2 = points[j] p = x1 - x2 q = y1 - y2 cost = ...
n = int(eval(input())) points = [list(map(int, input().split(" "))) for _ in range(n)] X = 0 Y = 1 ans = 10 ** 14 if n == 1: ans = 1 else: for i in range(n): for j in range(n): if i == j: continue x1, y1 = points[i] x2, y2 = points[j] ...
28
31
698
771
n = int(eval(input())) points = [list(map(int, input().split(" "))) for _ in range(n)] X = 0 Y = 1 ans = 10**14 for i in range(n): for j in range(n): if i == j: continue x1, y1 = points[i] x2, y2 = points[j] p = x1 - x2 q = y1 - y2 cost = n for poi...
n = int(eval(input())) points = [list(map(int, input().split(" "))) for _ in range(n)] X = 0 Y = 1 ans = 10**14 if n == 1: ans = 1 else: for i in range(n): for j in range(n): if i == j: continue x1, y1 = points[i] x2, y2 = points[j] p = x1 ...
false
9.677419
[ "-for i in range(n):", "- for j in range(n):", "- if i == j:", "- continue", "- x1, y1 = points[i]", "- x2, y2 = points[j]", "- p = x1 - x2", "- q = y1 - y2", "- cost = n", "- for point1 in points: # そのpointからcost0で遷移できる先があるかどうか", "...
false
0.046989
0.038107
1.233069
[ "s788444186", "s172188389" ]
u340781749
p02775
python
s197791203
s801371770
1,517
1,188
5,492
5,492
Accepted
Accepted
21.69
n = eval(input()) precise = 0 ok_over = 1 ok_prec = 0 for d in n: d = int(d) new_over = min(precise + d + 1, ok_over + d + 2, ok_over + 9 - d, ok_prec + d + 1) new_prec = min(ok_over + d + 1, ok_prec + d) precise += d ok_over = new_over ok_prec = new_prec ok_over += 1 print((min(prec...
n = eval(input()) precise = 0 over = 1 for d in n: d = int(d) new_over = min(precise + d + 1, over + d + 2, over + 9 - d) precise = min(over + d + 1, precise + d) over = new_over over += 1 print((min(precise, over)))
13
10
337
234
n = eval(input()) precise = 0 ok_over = 1 ok_prec = 0 for d in n: d = int(d) new_over = min(precise + d + 1, ok_over + d + 2, ok_over + 9 - d, ok_prec + d + 1) new_prec = min(ok_over + d + 1, ok_prec + d) precise += d ok_over = new_over ok_prec = new_prec ok_over += 1 print((min(precise, ok_over...
n = eval(input()) precise = 0 over = 1 for d in n: d = int(d) new_over = min(precise + d + 1, over + d + 2, over + 9 - d) precise = min(over + d + 1, precise + d) over = new_over over += 1 print((min(precise, over)))
false
23.076923
[ "-ok_over = 1", "-ok_prec = 0", "+over = 1", "- new_over = min(precise + d + 1, ok_over + d + 2, ok_over + 9 - d, ok_prec + d + 1)", "- new_prec = min(ok_over + d + 1, ok_prec + d)", "- precise += d", "- ok_over = new_over", "- ok_prec = new_prec", "-ok_over += 1", "-print((min(prec...
false
0.083525
0.038621
2.162692
[ "s197791203", "s801371770" ]
u729133443
p02614
python
s775305689
s599650326
97
73
9,020
9,092
Accepted
Accepted
24.74
h,*c=open(0) h,w,k=list(map(int,h.split())) print((sum(k==sum(y>>w+z//w&y%2**w>>z%w&1and'.'>c[z//w][z%w]for z in range(h*w))for y in range(1<<h+w))))
h,*c=open(0) h,w,k=list(map(int,h.split())) print((sum(k==sum(y>>w+z//w&y>>z%w&1and'.'>c[z//w][z%w]for z in range(h*w))for y in range(1<<h+w))))
3
3
143
138
h, *c = open(0) h, w, k = list(map(int, h.split())) print( ( sum( k == sum( y >> w + z // w & y % 2**w >> z % w & 1 and "." > c[z // w][z % w] for z in range(h * w) ) for y in range(1 << h + w) ) ) )
h, *c = open(0) h, w, k = list(map(int, h.split())) print( ( sum( k == sum( y >> w + z // w & y >> z % w & 1 and "." > c[z // w][z % w] for z in range(h * w) ) for y in range(1 << h + w) ) ) )
false
0
[ "- y >> w + z // w & y % 2**w >> z % w & 1 and \".\" > c[z // w][z % w]", "+ y >> w + z // w & y >> z % w & 1 and \".\" > c[z // w][z % w]" ]
false
0.169626
0.08808
1.92582
[ "s775305689", "s599650326" ]
u136090046
p03294
python
s507034294
s376446562
57
18
5,688
3,316
Accepted
Accepted
68.42
from fractions import gcd n = int(eval(input())) array = sorted([int(x) for x in input().split()]) res = 0 for i in array: res += i-1 print(res)
n = int(eval(input())) array = [int(x) for x in input().split()] res = 0 for i in array: res += i-1 print(res)
9
7
152
115
from fractions import gcd n = int(eval(input())) array = sorted([int(x) for x in input().split()]) res = 0 for i in array: res += i - 1 print(res)
n = int(eval(input())) array = [int(x) for x in input().split()] res = 0 for i in array: res += i - 1 print(res)
false
22.222222
[ "-from fractions import gcd", "-", "-array = sorted([int(x) for x in input().split()])", "+array = [int(x) for x in input().split()]" ]
false
0.034556
0.037519
0.921026
[ "s507034294", "s376446562" ]
u604774382
p02258
python
s096306185
s697206716
800
280
6,724
4,208
Accepted
Accepted
65
n = int( eval(input( )) ) mi = int( eval(input( )) ) profit = 0 - 1000000000 for i in range( n-1 ): num = int( eval(input( )) ) diff = num - mi if profit < diff: profit = diff if num < mi: mi = num print( profit )
n = int( input( ) ) mi = int( input( ) ) profit = 0 - 1000000000 n -= 1 i = 0 while i < n: num = int( input( ) ) diff = num - mi if profit < diff: profit = diff if num < mi: mi = num i += 1 print( profit )
17
18
228
248
n = int(eval(input())) mi = int(eval(input())) profit = 0 - 1000000000 for i in range(n - 1): num = int(eval(input())) diff = num - mi if profit < diff: profit = diff if num < mi: mi = num print(profit)
n = int(input()) mi = int(input()) profit = 0 - 1000000000 n -= 1 i = 0 while i < n: num = int(input()) diff = num - mi if profit < diff: profit = diff if num < mi: mi = num i += 1 print(profit)
false
5.555556
[ "-n = int(eval(input()))", "-mi = int(eval(input()))", "+n = int(input())", "+mi = int(input())", "-for i in range(n - 1):", "- num = int(eval(input()))", "+n -= 1", "+i = 0", "+while i < n:", "+ num = int(input())", "+ i += 1" ]
false
0.09892
0.043823
2.257267
[ "s096306185", "s697206716" ]
u863964720
p02702
python
s246490021
s378519219
313
289
27,412
27,176
Accepted
Accepted
7.67
from operator import mul from functools import reduce import numpy as np #def ConZ(i): #z_num = i+int(i*(i-1)/2) #return z_num #def ConN(i): #n_num = int(i*(i-1)/2) #return n_num def cmb(n): over = reduce(mul, list(range(n, n - 2, -1))) under = reduce(mul, list(range(1,2 + 1))) ...
from operator import mul from functools import reduce import numpy as np def ConZ(i): z_num = i+int(i*(i-1)/2) return z_num #def ConN(i): #n_num = int(i*(i-1)/2) #return n_num def cmb(n): over = reduce(mul, list(range(n, n - 2, -1))) under = reduce(mul, list(range(1,2 + 1))) retu...
37
35
740
721
from operator import mul from functools import reduce import numpy as np # def ConZ(i): # z_num = i+int(i*(i-1)/2) # return z_num # def ConN(i): # n_num = int(i*(i-1)/2) # return n_num def cmb(n): over = reduce(mul, list(range(n, n - 2, -1))) under = reduce(mul, list(range(1, 2 + 1))) return over // under ...
from operator import mul from functools import reduce import numpy as np def ConZ(i): z_num = i + int(i * (i - 1) / 2) return z_num # def ConN(i): # n_num = int(i*(i-1)/2) # return n_num def cmb(n): over = reduce(mul, list(range(n, n - 2, -1))) under = reduce(mul, list(range(1, 2 + 1))) return o...
false
5.405405
[ "-# def ConZ(i):", "-# z_num = i+int(i*(i-1)/2)", "-# return z_num", "+", "+def ConZ(i):", "+ z_num = i + int(i * (i - 1) / 2)", "+ return z_num", "+", "+", "-mod[0] += 1", "-# x += ConZ(mod[0])", "+x += ConZ(mod[0])", "-# for j in range(len(mod)):", "-# x+=cmb(mod[j])", "-# print(...
false
0.218522
0.333566
0.655107
[ "s246490021", "s378519219" ]
u994988729
p02559
python
s240438541
s677552461
2,958
699
59,420
61,416
Accepted
Accepted
76.37
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) class BinaryIndexTree: # 1-indexed def __init__(self, N): """ INPUT N [int] -> 全部0で初期化 N [list] -> そのまま初期化 """ if isinstance(N, int): self.N = N self.d...
code = r""" # distutils: language=c++ # distutils: include_dirs = [/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl] from libcpp cimport * cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder": cdef cppclass fenwick_tree[T]: fenwick_t...
72
37
1,795
952
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) class BinaryIndexTree: # 1-indexed def __init__(self, N): """ INPUT N [int] -> 全部0で初期化 N [list] -> そのまま初期化 """ if isinstance(N, int): self.N = N self.depth = N.bit_le...
code = r""" # distutils: language=c++ # distutils: include_dirs = [/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl] from libcpp cimport * cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "atcoder": cdef cppclass fenwick_tree[T]: fenwick_tree() ...
false
48.611111
[ "+code = r\"\"\"", "+# distutils: language=c++", "+# distutils: include_dirs = [/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]", "+from libcpp cimport *", "+cdef extern from \"/opt/atcoder-stl/atcoder/fenwicktree.hpp\" namespace \"atcoder\":", "+ cdef cppclass...
false
0.035557
0.041115
0.864826
[ "s240438541", "s677552461" ]
u498487134
p02756
python
s510816615
s155110908
891
335
97,948
144,972
Accepted
Accepted
62.4
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) from collections import deque def main(): mod=10**9+7 S=deque(eval(input())) Q=I() dir=0#0で手前につける for _ in range(Q): q=list(input().spl...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) from collections import deque def main(): mod=10**9+7 S=eval(input()) from collections import deque dq=deque() for c in S: dq.app...
38
47
738
878
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) from collections import deque def main(): mod = 10**9 + 7 S = deque(eval(input())) Q = I() dir = 0 # 0で手前につける for _ in range(Q): q = list(...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) from collections import deque def main(): mod = 10**9 + 7 S = eval(input()) from collections import deque dq = deque() for c in S: dq.appe...
false
19.148936
[ "- S = deque(eval(input()))", "+ S = eval(input())", "+ from collections import deque", "+", "+ dq = deque()", "+ for c in S:", "+ dq.appendleft(c)", "+ rev = 0", "- dir = 0 # 0で手前につける", "- q = list(input().split())", "+ q = input().split()", "- ...
false
0.03404
0.03577
0.951634
[ "s510816615", "s155110908" ]
u347600233
p02934
python
s779743451
s088746186
31
26
9,076
8,912
Accepted
Accepted
16.13
n = int(eval(input())) a = [int(i) for i in input().split()] print((1 / sum(1 / ai for ai in a)))
n = int(eval(input())) a = list(map(int, input().split())) print((1 / sum(1 / ai for ai in a)))
3
3
91
89
n = int(eval(input())) a = [int(i) for i in input().split()] print((1 / sum(1 / ai for ai in a)))
n = int(eval(input())) a = list(map(int, input().split())) print((1 / sum(1 / ai for ai in a)))
false
0
[ "-a = [int(i) for i in input().split()]", "+a = list(map(int, input().split()))" ]
false
0.067602
0.065978
1.024613
[ "s779743451", "s088746186" ]
u148551245
p03415
python
s278802118
s321787166
175
17
38,256
2,940
Accepted
Accepted
90.29
l = [0] * 3 for i in range(3): l[i] = list(input()) for i in range(3): for j in range(3): if i == j: print(l[i][j], end='') print("")
for i in range(3): print(input()[i], end='') print()
9
3
170
59
l = [0] * 3 for i in range(3): l[i] = list(input()) for i in range(3): for j in range(3): if i == j: print(l[i][j], end="") print("")
for i in range(3): print(input()[i], end="") print()
false
66.666667
[ "-l = [0] * 3", "- l[i] = list(input())", "-for i in range(3):", "- for j in range(3):", "- if i == j:", "- print(l[i][j], end=\"\")", "-print(\"\")", "+ print(input()[i], end=\"\")", "+print()" ]
false
0.042463
0.074577
0.569381
[ "s278802118", "s321787166" ]
u312025627
p03262
python
s294572331
s229226653
320
258
81,812
64,360
Accepted
Accepted
19.38
def main(): N, X = (int(i) for i in input().split()) x = [abs(int(i) - X) for i in input().split()] from fractions import gcd for i in range(1,N): x[i] = gcd(x[i-1], x[i]) print((x[-1])) if __name__ == '__main__': main()
def gcd(x, y): if y == 0: return x while y != 0: x, y = y, x % y return x def main(): N, X = (int(i) for i in input().split()) A = [int(i) for i in input().split()] + [X] A.sort() diff = [A[i+1] - A[i] for i in range(N)] ans = diff[0] for d in diff: ...
11
22
262
407
def main(): N, X = (int(i) for i in input().split()) x = [abs(int(i) - X) for i in input().split()] from fractions import gcd for i in range(1, N): x[i] = gcd(x[i - 1], x[i]) print((x[-1])) if __name__ == "__main__": main()
def gcd(x, y): if y == 0: return x while y != 0: x, y = y, x % y return x def main(): N, X = (int(i) for i in input().split()) A = [int(i) for i in input().split()] + [X] A.sort() diff = [A[i + 1] - A[i] for i in range(N)] ans = diff[0] for d in diff: ans = ...
false
50
[ "+def gcd(x, y):", "+ if y == 0:", "+ return x", "+ while y != 0:", "+ x, y = y, x % y", "+ return x", "+", "+", "- x = [abs(int(i) - X) for i in input().split()]", "- from fractions import gcd", "-", "- for i in range(1, N):", "- x[i] = gcd(x[i - 1], x...
false
0.139798
0.043923
3.182764
[ "s294572331", "s229226653" ]
u498487134
p02733
python
s770351359
s777722094
1,644
452
49,756
74,376
Accepted
Accepted
72.51
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 H,W,K=MI() S=[[]for _ in range(H)] for i in range(H): S[i]=list(eval(input())) ans=10**10 import iterto...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 H,W,K=MI() S=[] for _ in range(H): s=eval(input()) S.append(s) # Hに関してbit全探索 import itertools ...
74
71
1,859
1,651
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 H, W, K = MI() S = [[] for _ in range(H)] for i in range(H): S[i] = list(eval(input())) ans = 10**10 import i...
def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 H, W, K = MI() S = [] for _ in range(H): s = eval(input()) S.append(s) # Hに関してbit全探索 import itertools...
false
4.054054
[ "- S = [[] for _ in range(H)]", "- for i in range(H):", "- S[i] = list(eval(input()))", "- ans = 10**10", "+ S = []", "+ for _ in range(H):", "+ s = eval(input())", "+ S.append(s)", "+ # Hに関してbit全探索", "+", "+ inf = 10**10", "+ ans = inf", "- fo...
false
0.046637
0.04652
1.002502
[ "s770351359", "s777722094" ]
u130900604
p02659
python
s260375038
s166516957
88
29
71,388
9,036
Accepted
Accepted
67.05
from decimal import Decimal a,b=list(map(Decimal,input().split())) b=100*b print((a*b//100))
a,b=input().split() a=int(a) b=b.replace(".","") b=int(b) print((a*b//100))
4
5
87
77
from decimal import Decimal a, b = list(map(Decimal, input().split())) b = 100 * b print((a * b // 100))
a, b = input().split() a = int(a) b = b.replace(".", "") b = int(b) print((a * b // 100))
false
20
[ "-from decimal import Decimal", "-", "-a, b = list(map(Decimal, input().split()))", "-b = 100 * b", "+a, b = input().split()", "+a = int(a)", "+b = b.replace(\".\", \"\")", "+b = int(b)" ]
false
0.084897
0.038706
2.193381
[ "s260375038", "s166516957" ]
u811733736
p02361
python
s363255787
s937112714
4,730
2,980
196,712
195,896
Accepted
Accepted
37
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp """ from enum import Enum from heapq import heappush, heappop, heapify class Sssp(object): """ single source shortest path """ class Status(Enum): """ ?????????????¨??????¶??? """ whi...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp 4.73[s]??§????????????AC """ from enum import Enum from heapq import heappush, heappop class Sssp(object): """ single source shortest path """ class Status(Enum): """ ?????????????¨??????...
68
101
2,041
2,802
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp """ from enum import Enum from heapq import heappush, heappop, heapify class Sssp(object): """single source shortest path""" class Status(Enum): """?????????????¨??????¶???""" white = 1 # ??...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp 4.73[s]??§????????????AC """ from enum import Enum from heapq import heappush, heappop class Sssp(object): """single source shortest path""" class Status(Enum): """?????????????¨??????¶???""" ...
false
32.673267
[ "+4.73[s]??§????????????AC", "-from heapq import heappush, heappop, heapify", "+from heapq import heappush, heappop", "+def solve(V, r, data):", "+ WHITE = 0", "+ GRAY = 1", "+ BLACK = 2", "+ num_of_nodes = V", "+ color = [WHITE] * num_of_nodes # ????????????????¨??????¶???", "+ ...
false
0.098611
0.070183
1.405056
[ "s363255787", "s937112714" ]
u556589653
p03659
python
s844052044
s015074912
255
207
24,812
24,824
Accepted
Accepted
18.82
N = int(eval(input())) A = list(map(int,input().split())) ruiseki = [0]*(N+1) total = 0 now = 10**20 sa = 0 now_2 = 0 for i in range(N): total += A[i] ruiseki[i+1] = total for i in range(1,len(ruiseki)-1): snuke = ruiseki[i]-ruiseki[0] arai = ruiseki[N]-ruiseki[i] now_2 = abs(snuke-arai) now =...
N = int(eval(input())) A = list(map(int,input().split())) ruisekiwa = [0]*(N+1) now = 0 minimum = 10**10 for i in range(N): now += A[i] ruisekiwa[i+1] = now for i in range(N-1): snuke = ruisekiwa[i+1] arai = ruisekiwa[N]-snuke K = abs(snuke-arai) if K < minimum: minimum = K print(minimum)
16
15
342
313
N = int(eval(input())) A = list(map(int, input().split())) ruiseki = [0] * (N + 1) total = 0 now = 10**20 sa = 0 now_2 = 0 for i in range(N): total += A[i] ruiseki[i + 1] = total for i in range(1, len(ruiseki) - 1): snuke = ruiseki[i] - ruiseki[0] arai = ruiseki[N] - ruiseki[i] now_2 = abs(snuke - a...
N = int(eval(input())) A = list(map(int, input().split())) ruisekiwa = [0] * (N + 1) now = 0 minimum = 10**10 for i in range(N): now += A[i] ruisekiwa[i + 1] = now for i in range(N - 1): snuke = ruisekiwa[i + 1] arai = ruisekiwa[N] - snuke K = abs(snuke - arai) if K < minimum: minimum = ...
false
6.25
[ "-ruiseki = [0] * (N + 1)", "-total = 0", "-now = 10**20", "-sa = 0", "-now_2 = 0", "+ruisekiwa = [0] * (N + 1)", "+now = 0", "+minimum = 10**10", "- total += A[i]", "- ruiseki[i + 1] = total", "-for i in range(1, len(ruiseki) - 1):", "- snuke = ruiseki[i] - ruiseki[0]", "- arai ...
false
0.041399
0.040386
1.025089
[ "s844052044", "s015074912" ]
u562935282
p02624
python
s153699958
s615227236
1,296
30
9,148
9,180
Accepted
Accepted
97.69
# 解説 def main(): N = int(eval(input())) ans = 0 for div in range(1, N + 1): m = N // div # div, div*2, ..., div*m ans += (m * (m + 1) // 2) * div print(ans) if __name__ == '__main__': main()
def main(): from math import isqrt # Return the integer part of the square root of the input. N = int(eval(input())) def f(x): return x * (x + 1) // 2 ans = 0 for k in range(1, isqrt(N) + 1): # https://maspypy.com/atcoder-%e5%8f%82%e5%8a%a0%e6%84%9f%e6%83%b3-2020-06...
14
24
239
613
# 解説 def main(): N = int(eval(input())) ans = 0 for div in range(1, N + 1): m = N // div # div, div*2, ..., div*m ans += (m * (m + 1) // 2) * div print(ans) if __name__ == "__main__": main()
def main(): from math import isqrt # Return the integer part of the square root of the input. N = int(eval(input())) def f(x): return x * (x + 1) // 2 ans = 0 for k in range(1, isqrt(N) + 1): # https://maspypy.com/atcoder-%e5%8f%82%e5%8a%a0%e6%84%9f%e6%83%b3-2020-06-27abc-172 ...
false
41.666667
[ "-# 解説", "+ from math import isqrt", "+", "+ # Return the integer part of the square root of the input.", "+", "+ def f(x):", "+ return x * (x + 1) // 2", "+", "- for div in range(1, N + 1):", "- m = N // div # div, div*2, ..., div*m", "- ans += (m * (m + 1) // ...
false
0.90927
0.032336
28.118996
[ "s153699958", "s615227236" ]
u057109575
p03262
python
s439627827
s255849804
136
92
16,080
16,280
Accepted
Accepted
32.35
from fractions import gcd N, *X = list(map(int, open(0).read().split())) X.sort() y = [X[i + 1] - X[i] for i in range(N)] ans = y[0] for v in y[1:]: ans = gcd(ans, v) print(ans)
from fractions import gcd from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) y = [abs(x[i] - X) for i in range(N)] print((reduce(gcd, y)))
9
6
183
188
from fractions import gcd N, *X = list(map(int, open(0).read().split())) X.sort() y = [X[i + 1] - X[i] for i in range(N)] ans = y[0] for v in y[1:]: ans = gcd(ans, v) print(ans)
from fractions import gcd from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) y = [abs(x[i] - X) for i in range(N)] print((reduce(gcd, y)))
false
33.333333
[ "+from functools import reduce", "-N, *X = list(map(int, open(0).read().split()))", "-X.sort()", "-y = [X[i + 1] - X[i] for i in range(N)]", "-ans = y[0]", "-for v in y[1:]:", "- ans = gcd(ans, v)", "-print(ans)", "+N, X = list(map(int, input().split()))", "+x = list(map(int, input().split()))"...
false
0.110276
0.142588
0.77339
[ "s439627827", "s255849804" ]
u581187895
p03018
python
s627576323
s609089669
66
49
3,500
9,292
Accepted
Accepted
25.76
S = input().replace("BC", "D") acc = 0 ans = 0 for s in S: if s == "B" or s == "C": acc = 0 continue if s == "A": acc += 1 if s == "D": ans += acc print(ans)
def resolve(): S = eval(input()) rep_S = S.replace("BC", "D") cnt = 0 ans = 0 for i in range(len(rep_S)): if rep_S[i] == "A": cnt += 1 elif rep_S[i] == "D": ans += cnt else: cnt = 0 print(ans) if __name__ == "__ma...
12
20
194
335
S = input().replace("BC", "D") acc = 0 ans = 0 for s in S: if s == "B" or s == "C": acc = 0 continue if s == "A": acc += 1 if s == "D": ans += acc print(ans)
def resolve(): S = eval(input()) rep_S = S.replace("BC", "D") cnt = 0 ans = 0 for i in range(len(rep_S)): if rep_S[i] == "A": cnt += 1 elif rep_S[i] == "D": ans += cnt else: cnt = 0 print(ans) if __name__ == "__main__": resolve()
false
40
[ "-S = input().replace(\"BC\", \"D\")", "-acc = 0", "-ans = 0", "-for s in S:", "- if s == \"B\" or s == \"C\":", "- acc = 0", "- continue", "- if s == \"A\":", "- acc += 1", "- if s == \"D\":", "- ans += acc", "-print(ans)", "+def resolve():", "+ S =...
false
0.075574
0.086546
0.873224
[ "s627576323", "s609089669" ]
u761320129
p03948
python
s528368189
s142345675
96
88
14,680
14,252
Accepted
Accepted
8.33
N,T = list(map(int,input().split())) A = list(map(int,input().split())) cummax = [A[-1]] for a in reversed(A[:-1]): cummax.append(max(cummax[-1], a)) cummax.reverse() maxgain = n = 0 for buy,sell in zip(A,cummax): gain = sell - buy if gain > maxgain: maxgain = gain n = 1 ...
N,T = list(map(int,input().split())) A = list(map(int,input().split())) cnt = max_profit = 0 INF = float('inf') min_cost = INF for a in A: profit = a - min_cost if profit == max_profit: cnt += 1 elif profit > max_profit: cnt = 1 max_profit = profit min_cost = min(mi...
17
16
362
338
N, T = list(map(int, input().split())) A = list(map(int, input().split())) cummax = [A[-1]] for a in reversed(A[:-1]): cummax.append(max(cummax[-1], a)) cummax.reverse() maxgain = n = 0 for buy, sell in zip(A, cummax): gain = sell - buy if gain > maxgain: maxgain = gain n = 1 elif gain =...
N, T = list(map(int, input().split())) A = list(map(int, input().split())) cnt = max_profit = 0 INF = float("inf") min_cost = INF for a in A: profit = a - min_cost if profit == max_profit: cnt += 1 elif profit > max_profit: cnt = 1 max_profit = profit min_cost = min(min_cost, a) ...
false
5.882353
[ "-cummax = [A[-1]]", "-for a in reversed(A[:-1]):", "- cummax.append(max(cummax[-1], a))", "-cummax.reverse()", "-maxgain = n = 0", "-for buy, sell in zip(A, cummax):", "- gain = sell - buy", "- if gain > maxgain:", "- maxgain = gain", "- n = 1", "- elif gain == maxgain...
false
0.035576
0.035865
0.991935
[ "s528368189", "s142345675" ]
u476604182
p02960
python
s752250077
s307104375
905
484
137,120
43,884
Accepted
Accepted
46.52
S = eval(input()) con = 10**9 + 7 T = [s if s != "?" else "0" for s in S] T = int(''.join(T)) SS = T % 13 def get_mod(S): c = {} iii = 1 for i in range(len(S)): if S[len(S) - i - 1] != "?": iii *= 10 iii %= 13 continue c[i] = {(j * iii) % ...
N = input()[::-1] iv = 1 MOD = 10**9+7 pdp = [0 for i in range(13)] pdp[0]=1 dp = [0 for i in range(13)] for i in range(len(N)): x = N[i] if x=='?': for j in range(13): for h in range(10): dp[(h*iv+j)%13] += pdp[j] for j in range(13): pdp[j] = (dp[j]%MOD) dp[j] = 0 ...
38
25
774
505
S = eval(input()) con = 10**9 + 7 T = [s if s != "?" else "0" for s in S] T = int("".join(T)) SS = T % 13 def get_mod(S): c = {} iii = 1 for i in range(len(S)): if S[len(S) - i - 1] != "?": iii *= 10 iii %= 13 continue c[i] = {(j * iii) % 13: 1 for j in ...
N = input()[::-1] iv = 1 MOD = 10**9 + 7 pdp = [0 for i in range(13)] pdp[0] = 1 dp = [0 for i in range(13)] for i in range(len(N)): x = N[i] if x == "?": for j in range(13): for h in range(10): dp[(h * iv + j) % 13] += pdp[j] for j in range(13): pdp[j] = ...
false
34.210526
[ "-S = eval(input())", "-con = 10**9 + 7", "-T = [s if s != \"?\" else \"0\" for s in S]", "-T = int(\"\".join(T))", "-SS = T % 13", "-", "-", "-def get_mod(S):", "- c = {}", "- iii = 1", "- for i in range(len(S)):", "- if S[len(S) - i - 1] != \"?\":", "- iii *= 10"...
false
0.035847
0.076786
0.466851
[ "s752250077", "s307104375" ]
u222668979
p03583
python
s036076907
s703199739
1,983
1,418
9,124
8,924
Accepted
Accepted
28.49
n = int(eval(input())) for h in range(1, 3501): for w in range(1, 3501): bns = n * h * w bnb = 4 * h * w - n * (h + w) if bnb >= 1 and bns % bnb == 0: print((h, w, bns // bnb)) exit()
n = int(eval(input())) for h in range(1, 3501): for w in range(h, 3501): bns = n * h * w bnb = 4 * h * w - n * (h + w) if bnb >= 1 and bns % bnb == 0: print((h, w, bns // bnb)) exit()
9
9
237
237
n = int(eval(input())) for h in range(1, 3501): for w in range(1, 3501): bns = n * h * w bnb = 4 * h * w - n * (h + w) if bnb >= 1 and bns % bnb == 0: print((h, w, bns // bnb)) exit()
n = int(eval(input())) for h in range(1, 3501): for w in range(h, 3501): bns = n * h * w bnb = 4 * h * w - n * (h + w) if bnb >= 1 and bns % bnb == 0: print((h, w, bns // bnb)) exit()
false
0
[ "- for w in range(1, 3501):", "+ for w in range(h, 3501):" ]
false
1.172413
1.160112
1.010603
[ "s036076907", "s703199739" ]
u716530146
p02763
python
s151945089
s237391599
671
488
70,660
73,784
Accepted
Accepted
27.27
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 class SegmentTree: __slots__ = ['ide','n','seg','segfunc'] def __init__(self,size,func,ele...
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 class SegmentTree: __slots__ = ['ide','n','seg','segfunc'] def __init__(self,size,func,ele...
77
66
1,872
1,714
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") inf = float("inf") mod = 10**9 + 7 mans = inf ans = 0 count = 0 pro = 1 class SegmentTree: __slots__ = ["ide", "n", "seg", "segfunc"] def __init__(self, size, func, el...
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") inf = float("inf") mod = 10**9 + 7 mans = inf ans = 0 count = 0 pro = 1 class SegmentTree: __slots__ = ["ide", "n", "seg", "segfunc"] def __init__(self, size, func, el...
false
14.285714
[ "- def notrec(self, l, r):", "+ def query(self, l, r):", "-def makebin(s):", "- k = ord(s) - ord(\"a\")", "- # print(1<<k,k)", "- return 1 << k", "-", "-", "-def segfunc(a, b):", "+def segor(a, b):", "-def out(n):", "- count = 0", "- while n:", "- if n & 1 == 1:...
false
0.037063
0.036861
1.00547
[ "s151945089", "s237391599" ]
u992465933
p02898
python
s222842819
s057329121
51
44
11,892
11,912
Accepted
Accepted
13.73
def main(): n, k = [int(x) for x in input().split()] h = [int(x) for x in input().split()] count = 0 for i in range(n): if h[i] >= k: count += 1 print(count) if __name__ == '__main__': main()
def main(): n,k = list(map(int,input().split())) H = list(map(int,input().split())) count = 0 for h in H: if h >= k: count += 1 print(count) if __name__ == '__main__': main()
14
13
253
228
def main(): n, k = [int(x) for x in input().split()] h = [int(x) for x in input().split()] count = 0 for i in range(n): if h[i] >= k: count += 1 print(count) if __name__ == "__main__": main()
def main(): n, k = list(map(int, input().split())) H = list(map(int, input().split())) count = 0 for h in H: if h >= k: count += 1 print(count) if __name__ == "__main__": main()
false
7.142857
[ "- n, k = [int(x) for x in input().split()]", "- h = [int(x) for x in input().split()]", "+ n, k = list(map(int, input().split()))", "+ H = list(map(int, input().split()))", "- for i in range(n):", "- if h[i] >= k:", "+ for h in H:", "+ if h >= k:" ]
false
0.007487
0.041644
0.179781
[ "s222842819", "s057329121" ]
u130900604
p02713
python
s123675688
s661569685
651
546
73,388
68,120
Accepted
Accepted
16.13
from math import*;from itertools import*;r=list(range(1,int(eval(input()))+1));print((sum(gcd(a,gcd(b,c))for a,b,c in product(r,r,r))))
from math import*;r=list(range(1,int(eval(input()))+1));print((sum(gcd(a,gcd(b,c))for a in r for b in r for c in r)))
1
1
121
103
from math import * from itertools import * r = list(range(1, int(eval(input())) + 1)) print((sum(gcd(a, gcd(b, c)) for a, b, c in product(r, r, r))))
from math import * r = list(range(1, int(eval(input())) + 1)) print((sum(gcd(a, gcd(b, c)) for a in r for b in r for c in r)))
false
0
[ "-from itertools import *", "-print((sum(gcd(a, gcd(b, c)) for a, b, c in product(r, r, r))))", "+print((sum(gcd(a, gcd(b, c)) for a in r for b in r for c in r)))" ]
false
0.049413
0.188498
0.262139
[ "s123675688", "s661569685" ]
u278057806
p02813
python
s666032524
s484558660
44
32
3,064
3,060
Accepted
Accepted
27.27
import itertools N = int(eval(input())) P = list(map(int, (input().split()))) Q = list(map(int, (input().split()))) a = 0 b = 0 cnt = 0 tmp = sorted(P) for x in itertools.permutations(tmp): cnt += 1 if P == list(x): a = cnt if Q == list(x): b = cnt print((abs(a - ...
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) a = 0 b = 0 ans = 0 for i in permutations(list(range(1, N + 1))): a += 1 b += 1 if i == P: ans = abs(ans - a) if i == Q: ans = abs(an...
22
21
317
329
import itertools N = int(eval(input())) P = list(map(int, (input().split()))) Q = list(map(int, (input().split()))) a = 0 b = 0 cnt = 0 tmp = sorted(P) for x in itertools.permutations(tmp): cnt += 1 if P == list(x): a = cnt if Q == list(x): b = cnt print((abs(a - b)))
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) a = 0 b = 0 ans = 0 for i in permutations(list(range(1, N + 1))): a += 1 b += 1 if i == P: ans = abs(ans - a) if i == Q: ans = abs(ans - b) print(ans)
false
4.545455
[ "-import itertools", "+from itertools import permutations", "-P = list(map(int, (input().split())))", "-Q = list(map(int, (input().split())))", "+P = tuple(map(int, input().split()))", "+Q = tuple(map(int, input().split()))", "-cnt = 0", "-tmp = sorted(P)", "-for x in itertools.permutations(tmp):", ...
false
0.199515
0.043147
4.624042
[ "s666032524", "s484558660" ]
u995102075
p02971
python
s387867329
s395962408
675
546
15,672
14,856
Accepted
Accepted
19.11
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] ans = [] front_max_list, back_max_list = [0], [0] for i in range(N): front_max_list.append(max(front_max_list[i], A[i])) back_max_list.append(max(back_max_list[i], A[N - i - 1])) for i in range(N): print((max(front_max_list[i], ...
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] A_ = sorted(A.copy(), reverse=True) max_num = [A_[0], A_[1]] for i in range(N): if A[i] != max_num[0]: print((max_num[0])) else: print((max_num[1]))
12
11
334
235
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] ans = [] front_max_list, back_max_list = [0], [0] for i in range(N): front_max_list.append(max(front_max_list[i], A[i])) back_max_list.append(max(back_max_list[i], A[N - i - 1])) for i in range(N): print((max(front_max_list[i], back_max_list[...
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] A_ = sorted(A.copy(), reverse=True) max_num = [A_[0], A_[1]] for i in range(N): if A[i] != max_num[0]: print((max_num[0])) else: print((max_num[1]))
false
8.333333
[ "-ans = []", "-front_max_list, back_max_list = [0], [0]", "+A_ = sorted(A.copy(), reverse=True)", "+max_num = [A_[0], A_[1]]", "- front_max_list.append(max(front_max_list[i], A[i]))", "- back_max_list.append(max(back_max_list[i], A[N - i - 1]))", "-for i in range(N):", "- print((max(front_max...
false
0.078937
0.036767
2.146942
[ "s387867329", "s395962408" ]
u327532412
p02831
python
s055684467
s303261293
35
30
5,052
9,108
Accepted
Accepted
14.29
import fractions A, B = list(map(int, input().split())) def lcm(a, b): return (a * b) / fractions.gcd(a, b) print((int(lcm(A, B))))
import math def lcm(A, B): return int((A * B) / math.gcd(A, B)) A, B = list(map(int, input().split())) print((lcm(A,B)))
5
5
131
120
import fractions A, B = list(map(int, input().split())) def lcm(a, b): return (a * b) / fractions.gcd(a, b) print((int(lcm(A, B))))
import math def lcm(A, B): return int((A * B) / math.gcd(A, B)) A, B = list(map(int, input().split())) print((lcm(A, B)))
false
0
[ "-import fractions", "+import math", "+", "+", "+def lcm(A, B):", "+ return int((A * B) / math.gcd(A, B))", "+", "-", "-", "-def lcm(a, b):", "- return (a * b) / fractions.gcd(a, b)", "-", "-", "-print((int(lcm(A, B))))", "+print((lcm(A, B)))" ]
false
0.117125
0.038814
3.017626
[ "s055684467", "s303261293" ]
u780962115
p02851
python
s177380103
s742350671
846
382
69,000
68,184
Accepted
Accepted
54.85
def shaku(K,lists): ans=0 SUMS=0 index=0 for l in range(len(lists)): while index < l or index< len(lists) and SUMS +lists[index] < K: SUMS += lists[index] index+= 1 ans += index-l SUMS -= lists[l] return ans n,k=list(map(int,input()....
# Rem of sum is Num # Reviewing problem from collections import defaultdict def cnt_func(X): res = 0 right = 0 L = len(X) for i in range(L): while right+1 < L and X[right+1] < K+X[i]: right += 1 res += right-i return res N, K = list(map(int, input(...
42
34
957
642
def shaku(K, lists): ans = 0 SUMS = 0 index = 0 for l in range(len(lists)): while index < l or index < len(lists) and SUMS + lists[index] < K: SUMS += lists[index] index += 1 ans += index - l SUMS -= lists[l] return ans n, k = list(map(int, input().s...
# Rem of sum is Num # Reviewing problem from collections import defaultdict def cnt_func(X): res = 0 right = 0 L = len(X) for i in range(L): while right + 1 < L and X[right + 1] < K + X[i]: right += 1 res += right - i return res N, K = list(map(int, input().split())) ...
false
19.047619
[ "-def shaku(K, lists):", "- ans = 0", "- SUMS = 0", "- index = 0", "- for l in range(len(lists)):", "- while index < l or index < len(lists) and SUMS + lists[index] < K:", "- SUMS += lists[index]", "- index += 1", "- ans += index - l", "- SUMS...
false
0.037769
0.072931
0.517871
[ "s177380103", "s742350671" ]
u145950990
p02984
python
s570723139
s790251458
140
108
14,032
20,728
Accepted
Accepted
22.86
n = int(eval(input())) a = list(map(int,input().split())) ans = [0] for i in range(n-1): ans.append(a[i]-ans[i]) ans[0] = a[-1]-(ans[0]+ans[-1]) for i in range(1,n): ans[i] = (a[i-1]-ans[i-1]//2)*2 print((*ans))
n = int(eval(input())) a = list(map(int,input().split())) x = 0 for i in range(n): x = a[i] - x ans = [] ans.append(x) for i in range(n-1): ans.append((a[i]-ans[-1]//2)*2) print((*ans))
9
10
220
195
n = int(eval(input())) a = list(map(int, input().split())) ans = [0] for i in range(n - 1): ans.append(a[i] - ans[i]) ans[0] = a[-1] - (ans[0] + ans[-1]) for i in range(1, n): ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2 print((*ans))
n = int(eval(input())) a = list(map(int, input().split())) x = 0 for i in range(n): x = a[i] - x ans = [] ans.append(x) for i in range(n - 1): ans.append((a[i] - ans[-1] // 2) * 2) print((*ans))
false
10
[ "-ans = [0]", "+x = 0", "+for i in range(n):", "+ x = a[i] - x", "+ans = []", "+ans.append(x)", "- ans.append(a[i] - ans[i])", "-ans[0] = a[-1] - (ans[0] + ans[-1])", "-for i in range(1, n):", "- ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2", "+ ans.append((a[i] - ans[-1] // 2) * 2)" ]
false
0.048524
0.047146
1.029223
[ "s570723139", "s790251458" ]
u391475811
p03377
python
s794799285
s769712177
19
17
3,316
2,940
Accepted
Accepted
10.53
A,B,X=list(map(int,input().split())) if A <= X <= (A+B): print("YES") else: print("NO")
A,B,X=list(map(int,input().split())) if A>X or A+B <X: print("NO") else: print("YES")
5
6
89
89
A, B, X = list(map(int, input().split())) if A <= X <= (A + B): print("YES") else: print("NO")
A, B, X = list(map(int, input().split())) if A > X or A + B < X: print("NO") else: print("YES")
false
16.666667
[ "-if A <= X <= (A + B):", "+if A > X or A + B < X:", "+ print(\"NO\")", "+else:", "-else:", "- print(\"NO\")" ]
false
0.052277
0.049436
1.057479
[ "s794799285", "s769712177" ]
u134019875
p02773
python
s233759297
s338355901
901
484
29,616
35,424
Accepted
Accepted
46.28
n = int(eval(input())) L = sorted(eval(input()) for _ in range(n)) s = sorted(set(L)) c = [0] * len(s) prev = L[0] cnt = 1 l = 0 for i in range(1, len(L)): if L[i] == prev: cnt += 1 else: c[l] = cnt l += 1 cnt = 1 prev = L[i] c[-1] = cnt m = max(c) for j ...
n = int(eval(input())) d = {} for _ in range(n): s = str(eval(input())) d[s] = 1 if s not in d else d[s] + 1 M = max(d.values()) L = [] for k, v in list(d.items()): if v == M: L.append(k) L.sort() for x in L: print(x)
20
14
366
238
n = int(eval(input())) L = sorted(eval(input()) for _ in range(n)) s = sorted(set(L)) c = [0] * len(s) prev = L[0] cnt = 1 l = 0 for i in range(1, len(L)): if L[i] == prev: cnt += 1 else: c[l] = cnt l += 1 cnt = 1 prev = L[i] c[-1] = cnt m = max(c) for j in range(len(c)):...
n = int(eval(input())) d = {} for _ in range(n): s = str(eval(input())) d[s] = 1 if s not in d else d[s] + 1 M = max(d.values()) L = [] for k, v in list(d.items()): if v == M: L.append(k) L.sort() for x in L: print(x)
false
30
[ "-L = sorted(eval(input()) for _ in range(n))", "-s = sorted(set(L))", "-c = [0] * len(s)", "-prev = L[0]", "-cnt = 1", "-l = 0", "-for i in range(1, len(L)):", "- if L[i] == prev:", "- cnt += 1", "- else:", "- c[l] = cnt", "- l += 1", "- cnt = 1", "- ...
false
0.035631
0.034478
1.033426
[ "s233759297", "s338355901" ]
u670180528
p03241
python
s439931977
s243469367
470
23
40,044
3,060
Accepted
Accepted
95.11
n,m=list(map(int,input().split())) for i in range(m//n+1)[::-1]: if m%i<1: print(i) exit()
n,m=list(map(int,input().split())) ans=1 for i in range(1,int(m**.5)+1): if m%i==0: if i*n<=m and ans<i: ans=i if n<=i and ans<m//i: ans=m//i print(ans)
5
9
93
176
n, m = list(map(int, input().split())) for i in range(m // n + 1)[::-1]: if m % i < 1: print(i) exit()
n, m = list(map(int, input().split())) ans = 1 for i in range(1, int(m**0.5) + 1): if m % i == 0: if i * n <= m and ans < i: ans = i if n <= i and ans < m // i: ans = m // i print(ans)
false
44.444444
[ "-for i in range(m // n + 1)[::-1]:", "- if m % i < 1:", "- print(i)", "- exit()", "+ans = 1", "+for i in range(1, int(m**0.5) + 1):", "+ if m % i == 0:", "+ if i * n <= m and ans < i:", "+ ans = i", "+ if n <= i and ans < m // i:", "+ ans ...
false
0.075609
0.037319
2.026019
[ "s439931977", "s243469367" ]
u922449550
p03732
python
s741153276
s581924646
1,708
218
53,648
42,988
Accepted
Accepted
87.24
N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for i in range(N)] w1 = wv[0][0] w_to_idx = {0:0} idx_to_w = {0:0} idx_W = 0 def calc(): global w_to_idx, idx_to_w, idx_W idx = 1 w_max = 0 for i in range(1, N+1): w = w1*i for j in range(3*i + 1): ww = w +...
from itertools import accumulate N, W = list(map(int, input().split())) wv = {} w1 = 0 for i in range(N): w, v = list(map(int, input().split())) if i == 0: w1 = w if w in wv: wv[w].append(v) else: wv[w] = [v] for w in wv: wv[w].sort(reverse=True) wv[w] = [0] + list(accumulate(w...
36
33
814
714
N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for i in range(N)] w1 = wv[0][0] w_to_idx = {0: 0} idx_to_w = {0: 0} idx_W = 0 def calc(): global w_to_idx, idx_to_w, idx_W idx = 1 w_max = 0 for i in range(1, N + 1): w = w1 * i for j in range(3 * i + 1): ...
from itertools import accumulate N, W = list(map(int, input().split())) wv = {} w1 = 0 for i in range(N): w, v = list(map(int, input().split())) if i == 0: w1 = w if w in wv: wv[w].append(v) else: wv[w] = [v] for w in wv: wv[w].sort(reverse=True) wv[w] = [0] + list(accum...
false
8.333333
[ "+from itertools import accumulate", "+", "-wv = [list(map(int, input().split())) for i in range(N)]", "-w1 = wv[0][0]", "-w_to_idx = {0: 0}", "-idx_to_w = {0: 0}", "-idx_W = 0", "-", "-", "-def calc():", "- global w_to_idx, idx_to_w, idx_W", "- idx = 1", "- w_max = 0", "- for ...
false
0.040947
0.044963
0.910683
[ "s741153276", "s581924646" ]
u600402037
p03309
python
s570244658
s226662047
254
214
34,216
34,188
Accepted
Accepted
15.75
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = np.array(lr()) A -= np.arange(1, N+1) A.sort() def check(i): ret = np.abs(A - A[i]).sum() return ret answer = min(check(0), ...
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = np.array(lr(), dtype=np.int32) A -= np.arange(1, N+1) answer = np.abs(A - int(np.median(A))).sum() print(answer)
32
13
692
294
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = np.array(lr()) A -= np.arange(1, N + 1) A.sort() def check(i): ret = np.abs(A - A[i]).sum() return ret answer = min(check(0), check(-1)) lef...
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = np.array(lr(), dtype=np.int32) A -= np.arange(1, N + 1) answer = np.abs(A - int(np.median(A))).sum() print(answer)
false
59.375
[ "-A = np.array(lr())", "+A = np.array(lr(), dtype=np.int32)", "-A.sort()", "-", "-", "-def check(i):", "- ret = np.abs(A - A[i]).sum()", "- return ret", "-", "-", "-answer = min(check(0), check(-1))", "-left = 0", "-right = N - 1", "-l_mid = (left * 2 + right) // 3", "-r_mid = (lef...
false
0.213555
0.267711
0.797706
[ "s570244658", "s226662047" ]
u037430802
p03837
python
s047619297
s275038193
684
125
3,452
3,572
Accepted
Accepted
81.73
n,m = list(map(int, input().split())) INF = 1000*n+1 #edges = [[] for _ in range(m)] edge = [[INF for _ in range(n)] for _ in range(n)] d = [[INF for _ in range(n)] for _ in range(n)] abc = [list(map(int, input().split())) for _ in range(m)] for a,b,c in abc: edge[a-1][b-1] = c edge[b-1][a-1] =...
import heapq N, M = list(map(int, input().split())) es = [[] for _ in range(N)] INF = float("inf") for i in range(M): a, b, c = list(map(int, input().split())) a, b = a-1, b-1 es[a].append((b,c)) es[b].append((a,c)) def djkstra(start, n, es): # start:スタート地点のノード # n:ノード数 # e...
42
51
910
1,270
n, m = list(map(int, input().split())) INF = 1000 * n + 1 # edges = [[] for _ in range(m)] edge = [[INF for _ in range(n)] for _ in range(n)] d = [[INF for _ in range(n)] for _ in range(n)] abc = [list(map(int, input().split())) for _ in range(m)] for a, b, c in abc: edge[a - 1][b - 1] = c edge[b - 1][a - 1] =...
import heapq N, M = list(map(int, input().split())) es = [[] for _ in range(N)] INF = float("inf") for i in range(M): a, b, c = list(map(int, input().split())) a, b = a - 1, b - 1 es[a].append((b, c)) es[b].append((a, c)) def djkstra(start, n, es): # start:スタート地点のノード # n:ノード数 # es:edges, ...
false
17.647059
[ "-n, m = list(map(int, input().split()))", "-INF = 1000 * n + 1", "-# edges = [[] for _ in range(m)]", "-edge = [[INF for _ in range(n)] for _ in range(n)]", "-d = [[INF for _ in range(n)] for _ in range(n)]", "-abc = [list(map(int, input().split())) for _ in range(m)]", "-for a, b, c in abc:", "- ...
false
0.135593
0.048472
2.797334
[ "s047619297", "s275038193" ]
u271469978
p02999
python
s626733929
s770603790
169
17
39,988
2,940
Accepted
Accepted
89.94
x, a = list(map(int, input().split())) print((0 if x < a else 10))
x,a=input().split();print(((x>=a)*10))
2
1
59
36
x, a = list(map(int, input().split())) print((0 if x < a else 10))
x, a = input().split() print(((x >= a) * 10))
false
50
[ "-x, a = list(map(int, input().split()))", "-print((0 if x < a else 10))", "+x, a = input().split()", "+print(((x >= a) * 10))" ]
false
0.142522
0.05932
2.402603
[ "s626733929", "s770603790" ]
u703442202
p02781
python
s827364419
s107460295
216
23
3,436
3,064
Accepted
Accepted
89.35
n = eval(input()) k = int(eval(input())) dp = [[[0 for i in range(len(n)+1)] for i in range(2)] for i in range(len(n)+1)] dp[0][0][0] = 1 for a in range(len(n)): for b in range(2): for c in range(len(n)): for i in range(10): if b ==1: if i != 0: dp[a+1][1][c+1] += dp[...
n = eval(input()) k = int(eval(input())) dp = [[[0 for i in range(k+1)] for i in range(2)] for i in range(len(n)+1)] dp[0][0][0] = 1 for a in range(len(n)): for b in range(2): for c in range(k+1): for i in range(10): if b ==1: if c ==k: if i == 0: dp[...
29
40
849
1,145
n = eval(input()) k = int(eval(input())) dp = [[[0 for i in range(len(n) + 1)] for i in range(2)] for i in range(len(n) + 1)] dp[0][0][0] = 1 for a in range(len(n)): for b in range(2): for c in range(len(n)): for i in range(10): if b == 1: if i != 0: ...
n = eval(input()) k = int(eval(input())) dp = [[[0 for i in range(k + 1)] for i in range(2)] for i in range(len(n) + 1)] dp[0][0][0] = 1 for a in range(len(n)): for b in range(2): for c in range(k + 1): for i in range(10): if b == 1: if c == k: ...
false
27.5
[ "-dp = [[[0 for i in range(len(n) + 1)] for i in range(2)] for i in range(len(n) + 1)]", "+dp = [[[0 for i in range(k + 1)] for i in range(2)] for i in range(len(n) + 1)]", "- for c in range(len(n)):", "+ for c in range(k + 1):", "- if i != 0:", "- d...
false
0.115675
0.037677
3.070199
[ "s827364419", "s107460295" ]
u983918956
p03200
python
s501480431
s393925262
69
46
4,840
3,500
Accepted
Accepted
33.33
S = list(eval(input())) count_B = 0 ans = 0 for i in range(len(S)): if S[i] == "B": count_B += 1 elif S[i] == "W": ans += count_B print(ans)
S = eval(input()) ans = 0 cnt = 0 for s in S: if s == "B": cnt += 1 else: ans += cnt print(ans)
9
9
166
121
S = list(eval(input())) count_B = 0 ans = 0 for i in range(len(S)): if S[i] == "B": count_B += 1 elif S[i] == "W": ans += count_B print(ans)
S = eval(input()) ans = 0 cnt = 0 for s in S: if s == "B": cnt += 1 else: ans += cnt print(ans)
false
0
[ "-S = list(eval(input()))", "-count_B = 0", "+S = eval(input())", "-for i in range(len(S)):", "- if S[i] == \"B\":", "- count_B += 1", "- elif S[i] == \"W\":", "- ans += count_B", "+cnt = 0", "+for s in S:", "+ if s == \"B\":", "+ cnt += 1", "+ else:", "+ ...
false
0.036234
0.038506
0.941009
[ "s501480431", "s393925262" ]
u644907318
p03959
python
s828420029
s614080281
168
117
18,924
98,752
Accepted
Accepted
30.36
p = 10**9+7 N = int(eval(input())) T = list(map(int,input().split())) A = list(map(int,input().split())) H = [0 for _ in range(N)] cnt = 1 H[0] = T[0] for i in range(1,N): if T[i]>T[i-1]: H[i] = T[i] if H[-1]>0 and H[-1]!=A[-1]: cnt = 0 else: H[-1] = A[-1] for i in range(-2,-N-1,-1...
p = 10**9+7 N = int(eval(input())) T = list(map(int,input().split())) A = list(map(int,input().split())) H = [0 for _ in range(N)] flag = 0 if T[N-1]!=A[0]: flag = 1 hmax = A[0] if flag==0: indmaxT=0 H[0] = T[0] for i in range(1,N): if T[i]>T[i-1]: H[i] = T[i] ...
31
47
750
1,051
p = 10**9 + 7 N = int(eval(input())) T = list(map(int, input().split())) A = list(map(int, input().split())) H = [0 for _ in range(N)] cnt = 1 H[0] = T[0] for i in range(1, N): if T[i] > T[i - 1]: H[i] = T[i] if H[-1] > 0 and H[-1] != A[-1]: cnt = 0 else: H[-1] = A[-1] for i in range(-2, -N - 1,...
p = 10**9 + 7 N = int(eval(input())) T = list(map(int, input().split())) A = list(map(int, input().split())) H = [0 for _ in range(N)] flag = 0 if T[N - 1] != A[0]: flag = 1 hmax = A[0] if flag == 0: indmaxT = 0 H[0] = T[0] for i in range(1, N): if T[i] > T[i - 1]: H[i] = T[i] ...
false
34.042553
[ "-cnt = 1", "-H[0] = T[0]", "-for i in range(1, N):", "- if T[i] > T[i - 1]:", "- H[i] = T[i]", "-if H[-1] > 0 and H[-1] != A[-1]:", "- cnt = 0", "+flag = 0", "+if T[N - 1] != A[0]:", "+ flag = 1", "+hmax = A[0]", "+if flag == 0:", "+ indmaxT = 0", "+ H[0] = T[0]", ...
false
0.037695
0.066947
0.563059
[ "s828420029", "s614080281" ]
u254871849
p03806
python
s760846028
s028031271
1,562
168
71,132
13,924
Accepted
Accepted
89.24
import sys INF = float('inf') n, ma, mb = list(map(int, sys.stdin.readline().split())) a, b, c = [], [], [] for _ in range(n): ai, bi, ci = list(map(int, sys.stdin.readline().split())) a.append(ai); b.append(bi); c.append(ci) def main(): sa = sum(a) sb = sum(b) res = [[[INF] * (sb + ...
import sys import numpy as np I = np.array(sys.stdin.read().split(), dtype=np.int64) n, ma, mb = I[:3] abc = I[3:].reshape(n, 3) def main(): sa, sb = np.sum(abc, axis=0)[:2] res = np.full((sa+1, sb+1), np.inf) res[0, 0] = 0 for a, b, c in abc: res[a:, b:] = np.minimum(res[a:, b:]...
34
26
929
602
import sys INF = float("inf") n, ma, mb = list(map(int, sys.stdin.readline().split())) a, b, c = [], [], [] for _ in range(n): ai, bi, ci = list(map(int, sys.stdin.readline().split())) a.append(ai) b.append(bi) c.append(ci) def main(): sa = sum(a) sb = sum(b) res = [[[INF] * (sb + 1) for ...
import sys import numpy as np I = np.array(sys.stdin.read().split(), dtype=np.int64) n, ma, mb = I[:3] abc = I[3:].reshape(n, 3) def main(): sa, sb = np.sum(abc, axis=0)[:2] res = np.full((sa + 1, sb + 1), np.inf) res[0, 0] = 0 for a, b, c in abc: res[a:, b:] = np.minimum(res[a:, b:], res[:-a...
false
23.529412
[ "+import numpy as np", "-INF = float(\"inf\")", "-n, ma, mb = list(map(int, sys.stdin.readline().split()))", "-a, b, c = [], [], []", "-for _ in range(n):", "- ai, bi, ci = list(map(int, sys.stdin.readline().split()))", "- a.append(ai)", "- b.append(bi)", "- c.append(ci)", "+I = np.arr...
false
0.092054
0.333684
0.275872
[ "s760846028", "s028031271" ]
u088552457
p03262
python
s936744908
s207731028
121
95
15,020
16,244
Accepted
Accepted
21.49
N, X = list(map(int, input().split())) a = list(map(int, input().split())) m = [] for aa in a: m.append(abs(X-aa)) ans = 0 import fractions for i, g in enumerate(m): ans = fractions.gcd(ans, g) print(ans)
def main(): n,m = input_list() x = input_list() if len(x) == 1: print((abs(x[0] - m))) exit(0) diffs = [] for i in range(len(x)): d = abs(m - x[i]) diffs.append(d) print((gcd_list(diffs))) def input_list(): return list(map(int, input().split())) def input_list_str(): ...
13
47
219
871
N, X = list(map(int, input().split())) a = list(map(int, input().split())) m = [] for aa in a: m.append(abs(X - aa)) ans = 0 import fractions for i, g in enumerate(m): ans = fractions.gcd(ans, g) print(ans)
def main(): n, m = input_list() x = input_list() if len(x) == 1: print((abs(x[0] - m))) exit(0) diffs = [] for i in range(len(x)): d = abs(m - x[i]) diffs.append(d) print((gcd_list(diffs))) def input_list(): return list(map(int, input().split())) def input...
false
72.340426
[ "-N, X = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-m = []", "-for aa in a:", "- m.append(abs(X - aa))", "-ans = 0", "+def main():", "+ n, m = input_list()", "+ x = input_list()", "+ if len(x) == 1:", "+ print((abs(x[0] - m)))", "+ exi...
false
0.048593
0.103276
0.470517
[ "s936744908", "s207731028" ]
u619379081
p03291
python
s267398243
s794135520
181
71
40,304
3,188
Accepted
Accepted
60.77
s = eval(input()) count = 0 a, c, q = 0, 0, 0 n = len(s) for i in range(n): if s[i] == 'C': c += 1 elif s[i] == '?': q += 1 else: continue c = 3 * c + q p = pow(3, q-3) for i in range(n): if s[i] == 'A': a += 3 elif s[i] == 'C': c -= 3 el...
s = eval(input()) count = 0 a = 0 q = s.count('?') c = 3 * s.count('C') + q p = pow(3, q-3) for i in range(len(s)): if s[i] == 'A': a += 3 elif s[i] == 'C': c -= 3 elif s[i] == 'B': count += 3*a*c else: c -= 1 count += a*c a += 1 print((in...
25
18
452
337
s = eval(input()) count = 0 a, c, q = 0, 0, 0 n = len(s) for i in range(n): if s[i] == "C": c += 1 elif s[i] == "?": q += 1 else: continue c = 3 * c + q p = pow(3, q - 3) for i in range(n): if s[i] == "A": a += 3 elif s[i] == "C": c -= 3 elif s[i] == "B": ...
s = eval(input()) count = 0 a = 0 q = s.count("?") c = 3 * s.count("C") + q p = pow(3, q - 3) for i in range(len(s)): if s[i] == "A": a += 3 elif s[i] == "C": c -= 3 elif s[i] == "B": count += 3 * a * c else: c -= 1 count += a * c a += 1 print((int(count *...
false
28
[ "-a, c, q = 0, 0, 0", "-n = len(s)", "-for i in range(n):", "- if s[i] == \"C\":", "- c += 1", "- elif s[i] == \"?\":", "- q += 1", "- else:", "- continue", "-c = 3 * c + q", "+a = 0", "+q = s.count(\"?\")", "+c = 3 * s.count(\"C\") + q", "-for i in range(n):"...
false
0.035884
0.035211
1.019105
[ "s267398243", "s794135520" ]
u844646164
p02888
python
s469868359
s353673353
1,962
1,745
51,292
51,804
Accepted
Accepted
11.06
import bisect from bisect import bisect_left n = int(eval(input())) l = list(map(int, input().split())) l = sorted(l) ans = 0 for i in range(n): for j in range(n-1, i, -1): s = l[i]+l[j] ans += bisect_left(l[j+1:n], s) print(ans)
import bisect N = int(eval(input())) L = list(map(int, input().split())) L = sorted(L) ans = 0 for i in range(N): for j in range(i+1, N): idx = bisect.bisect_left(L[j+1:], L[i]+L[j]) ans += idx print(ans)
13
12
248
226
import bisect from bisect import bisect_left n = int(eval(input())) l = list(map(int, input().split())) l = sorted(l) ans = 0 for i in range(n): for j in range(n - 1, i, -1): s = l[i] + l[j] ans += bisect_left(l[j + 1 : n], s) print(ans)
import bisect N = int(eval(input())) L = list(map(int, input().split())) L = sorted(L) ans = 0 for i in range(N): for j in range(i + 1, N): idx = bisect.bisect_left(L[j + 1 :], L[i] + L[j]) ans += idx print(ans)
false
7.692308
[ "-from bisect import bisect_left", "-n = int(eval(input()))", "-l = list(map(int, input().split()))", "-l = sorted(l)", "+N = int(eval(input()))", "+L = list(map(int, input().split()))", "+L = sorted(L)", "-for i in range(n):", "- for j in range(n - 1, i, -1):", "- s = l[i] + l[j]", "-...
false
0.035919
0.036458
0.985216
[ "s469868359", "s353673353" ]
u936985471
p03994
python
s469648374
s599977258
74
67
4,156
4,152
Accepted
Accepted
9.46
s=list(eval(input())) K=int(eval(input())) def calcCostToGetA(char): if char=='a': return 0 return (ord("z")+1)-ord(char) for i in range(len(s)): cost=calcCostToGetA(s[i]) if cost<=K: s[i]='a' K-=cost if K==0: break if K>0: s[-1]=chr(ord(s[-1])+K%26) print(("".jo...
# 頭から順にaに変えていく import sys readline = sys.stdin.readline S = list(readline().rstrip()) K = int(readline()) z = ord("z") for i in range(len(S) - 1): # aにするためのコストを求める if S[i] == "a": continue cost = z + 1 - ord(S[i]) if cost <= K: S[i] = "a" K -= cost K %= 26 nex = ord(S[-1]) + K...
20
25
313
393
s = list(eval(input())) K = int(eval(input())) def calcCostToGetA(char): if char == "a": return 0 return (ord("z") + 1) - ord(char) for i in range(len(s)): cost = calcCostToGetA(s[i]) if cost <= K: s[i] = "a" K -= cost if K == 0: break if K > 0: s[-1] ...
# 頭から順にaに変えていく import sys readline = sys.stdin.readline S = list(readline().rstrip()) K = int(readline()) z = ord("z") for i in range(len(S) - 1): # aにするためのコストを求める if S[i] == "a": continue cost = z + 1 - ord(S[i]) if cost <= K: S[i] = "a" K -= cost K %= 26 nex = ord(S[-1]) + K i...
false
20
[ "-s = list(eval(input()))", "-K = int(eval(input()))", "+# 頭から順にaに変えていく", "+import sys", "-", "-def calcCostToGetA(char):", "- if char == \"a\":", "- return 0", "- return (ord(\"z\") + 1) - ord(char)", "-", "-", "-for i in range(len(s)):", "- cost = calcCostToGetA(s[i])", "...
false
0.047711
0.047858
0.996913
[ "s469648374", "s599977258" ]
u588341295
p03722
python
s338834609
s591888690
848
594
3,404
3,404
Accepted
Accepted
29.95
# -*- coding: utf-8 -*- """ ・ベルマンフォード """ import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) edges = [None] * M for i in range(M): a, b, c = list(map(int, input().split())) # 0-indexed # コストの正負を逆転させれば最短経路問題として...
# -*- coding: utf-8 -*- """ ・ベルマンフォード """ import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) edges = [None] * M for i in range(M): a, b, c = list(map(int, input().split())) # 0-indexed # コストの正負を逆転させれば最短経路問題として...
45
44
1,128
1,080
# -*- coding: utf-8 -*- """ ・ベルマンフォード """ import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) edges = [None] * M for i in range(M): a, b, c = list(map(int, input().split())) # 0-indexed # コストの正負を逆転させれば最短経路問題として処理できる edge...
# -*- coding: utf-8 -*- """ ・ベルマンフォード """ import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) edges = [None] * M for i in range(M): a, b, c = list(map(int, input().split())) # 0-indexed # コストの正負を逆転させれば最短経路問題として処理できる edge...
false
2.222222
[ "- for i in range(N):", "- for src, dest, cost in edges:", "- if verts[src] + cost < verts[dest]:", "- verts[dest] = verts[src] + cost", "- if dest == N - 1:", "- # 頂点Nがそれに該当していたら空リストを返却", "- return []", "+ for...
false
0.040252
0.036662
1.097916
[ "s338834609", "s591888690" ]
u301624971
p03371
python
s436426449
s835458335
102
53
3,064
3,064
Accepted
Accepted
48.04
A, B, C, X, Y = list(map(int, input().split())) MAX = max(X, Y) MIN = 2*C*max(X, Y) i = MAX x=X y=Y while i > 0: tmpC = (MAX-i)*2*C total = (A*x)+(B*y)+tmpC if(MIN > total): MIN = total i-=1 if(x!=0): x-=1 if(y!=0): y-=1 print(MIN)
def myAnswer(A:int,B:int,C:int,X:int,Y:int) -> int: ans = 0 both = C * 2 AB=A+B while X!=0 or Y!=0: if(X>=1 and Y >=1): ans += min(AB,both) X-=1 Y-=1 elif(X>=1 and Y == 0): ans += min(both,A) X -= 1 else: ans += min(both,...
20
26
296
510
A, B, C, X, Y = list(map(int, input().split())) MAX = max(X, Y) MIN = 2 * C * max(X, Y) i = MAX x = X y = Y while i > 0: tmpC = (MAX - i) * 2 * C total = (A * x) + (B * y) + tmpC if MIN > total: MIN = total i -= 1 if x != 0: x -= 1 if y != 0: y -= 1 print(MIN)
def myAnswer(A: int, B: int, C: int, X: int, Y: int) -> int: ans = 0 both = C * 2 AB = A + B while X != 0 or Y != 0: if X >= 1 and Y >= 1: ans += min(AB, both) X -= 1 Y -= 1 elif X >= 1 and Y == 0: ans += min(both, A) X -= 1 ...
false
23.076923
[ "-A, B, C, X, Y = list(map(int, input().split()))", "-MAX = max(X, Y)", "-MIN = 2 * C * max(X, Y)", "-i = MAX", "-x = X", "-y = Y", "-while i > 0:", "- tmpC = (MAX - i) * 2 * C", "- total = (A * x) + (B * y) + tmpC", "- if MIN > total:", "- MIN = total", "- i -= 1", "- ...
false
0.146209
0.201182
0.726753
[ "s436426449", "s835458335" ]
u786020649
p03558
python
s717611943
s562775553
120
87
14,760
14,668
Accepted
Accepted
27.5
from collections import deque k=int(eval(input())) v=list(range(k)) stack=deque([1]) inf=float('inf') visited=[0]*k dist=[inf]*k dist[1]=0 while stack: v=stack.pop() if not visited[v]: nv0=10*v%k nv1=(v+1)%k if dist[nv0]>dist[v]: dist[nv0]=dist[v] stack.append(nv0) if d...
import sys from collections import deque readline=sys.stdin.readline def main(): k=int(readline()) v=list(range(k)) inf=float('inf') dist=[inf]*k visited=[0]*k stack=deque([1]) dist[1]=0 while stack: v=stack.pop() if not visited[v]: nv0=10*v%k ...
22
28
425
651
from collections import deque k = int(eval(input())) v = list(range(k)) stack = deque([1]) inf = float("inf") visited = [0] * k dist = [inf] * k dist[1] = 0 while stack: v = stack.pop() if not visited[v]: nv0 = 10 * v % k nv1 = (v + 1) % k if dist[nv0] > dist[v]: dist[nv0] =...
import sys from collections import deque readline = sys.stdin.readline def main(): k = int(readline()) v = list(range(k)) inf = float("inf") dist = [inf] * k visited = [0] * k stack = deque([1]) dist[1] = 0 while stack: v = stack.pop() if not visited[v]: nv...
false
21.428571
[ "+import sys", "-k = int(eval(input()))", "-v = list(range(k))", "-stack = deque([1])", "-inf = float(\"inf\")", "-visited = [0] * k", "-dist = [inf] * k", "-dist[1] = 0", "-while stack:", "- v = stack.pop()", "- if not visited[v]:", "- nv0 = 10 * v % k", "- nv1 = (v + 1)...
false
0.093755
0.137443
0.682138
[ "s717611943", "s562775553" ]
u200887663
p02689
python
s578347407
s022887009
315
263
24,444
19,980
Accepted
Accepted
16.51
#n=int(input()) n,m=list(map(int,input().split())) hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] dic={} for i in range(n): dic[i+1]=True for i in range(m): a,b=list(map(int,input().split())) if hl[a-1]<=hl[b-1]: dic[a]=False if hl[b-1]<=hl[a-1...
#k=int(input()) n,m=list(map(int,input().split())) hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] dic={} for i in range(m): a,b=list(map(int,input().split())) if hl[a-1] <= hl[b-1]: dic[a]=False if hl[b-1] <= hl[a-1]: dic[b]=False print((...
24
13
417
319
# n=int(input()) n, m = list(map(int, input().split())) hl = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] dic = {} for i in range(n): dic[i + 1] = True for i in range(m): a, b = list(map(int, input().split())) if hl[a - 1] <= hl[b - 1]: dic[a] = False if...
# k=int(input()) n, m = list(map(int, input().split())) hl = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] dic = {} for i in range(m): a, b = list(map(int, input().split())) if hl[a - 1] <= hl[b - 1]: dic[a] = False if hl[b - 1] <= hl[a - 1]: dic[b] =...
false
45.833333
[ "-# n=int(input())", "+# k=int(input())", "-for i in range(n):", "- dic[i + 1] = True", "-ans = 0", "-for k, v in list(dic.items()):", "- if v:", "- ans += 1", "-print(ans)", "+print((n - len(dic)))" ]
false
0.040225
0.039127
1.028048
[ "s578347407", "s022887009" ]
u656917242
p02990
python
s230576032
s568799067
595
545
3,944
3,944
Accepted
Accepted
8.4
from operator import mul from functools import reduce def cmb(n, r): if n < r: return 0 r = min(n - r, r) if r == 0: return 1 numer = reduce(mul, list(range(n, n - r, -1))) denom = reduce(mul, list(range(1, r + 1))) return numer // denom % INF N, K = list(map(int, input().split())) INF = 1...
from operator import mul from functools import reduce N, K=list(map(int, input().split())) def cmb(n, r): if(n<r): return 0 r=min(r,n-r) if(r==0): return 1 upper=reduce(mul, list(range(n, n-r, -1))) under=reduce(mul, list(range(1,r+1))) return upper // under % INF INF...
20
22
394
391
from operator import mul from functools import reduce def cmb(n, r): if n < r: return 0 r = min(n - r, r) if r == 0: return 1 numer = reduce(mul, list(range(n, n - r, -1))) denom = reduce(mul, list(range(1, r + 1))) return numer // denom % INF N, K = list(map(int, input().spl...
from operator import mul from functools import reduce N, K = list(map(int, input().split())) def cmb(n, r): if n < r: return 0 r = min(r, n - r) if r == 0: return 1 upper = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return upper // under ...
false
9.090909
[ "+", "+N, K = list(map(int, input().split()))", "- r = min(n - r, r)", "+ r = min(r, n - r)", "- numer = reduce(mul, list(range(n, n - r, -1)))", "- denom = reduce(mul, list(range(1, r + 1)))", "- return numer // denom % INF", "+ upper = reduce(mul, list(range(n, n - r, -1)))", "+ ...
false
0.095446
0.045297
2.107142
[ "s230576032", "s568799067" ]
u411353821
p02791
python
s738693770
s908827310
108
76
24,956
24,744
Accepted
Accepted
29.63
N, *D = [list(map(int, s.split())) for s in open(0)] N, D = N[0], D[0] cnt = 1 min_v = D[0] for i in range(1, len(D)): if min_v >= D[i]: cnt += 1 min_v = D[i] print(cnt)
def main(): _ = int(eval(input())) A = list(map(int, input().split())) min_value = 1e10 cnt = 0 for a in A: if a <= min_value: min_value = a cnt += 1 print(cnt) if __name__ == "__main__": main()
10
14
199
264
N, *D = [list(map(int, s.split())) for s in open(0)] N, D = N[0], D[0] cnt = 1 min_v = D[0] for i in range(1, len(D)): if min_v >= D[i]: cnt += 1 min_v = D[i] print(cnt)
def main(): _ = int(eval(input())) A = list(map(int, input().split())) min_value = 1e10 cnt = 0 for a in A: if a <= min_value: min_value = a cnt += 1 print(cnt) if __name__ == "__main__": main()
false
28.571429
[ "-N, *D = [list(map(int, s.split())) for s in open(0)]", "-N, D = N[0], D[0]", "-cnt = 1", "-min_v = D[0]", "-for i in range(1, len(D)):", "- if min_v >= D[i]:", "- cnt += 1", "- min_v = D[i]", "-print(cnt)", "+def main():", "+ _ = int(eval(input()))", "+ A = list(map(in...
false
0.077866
0.037427
2.080479
[ "s738693770", "s908827310" ]
u624475441
p03457
python
s609352118
s949402402
233
178
28,148
3,060
Accepted
Accepted
23.61
import sys eval(input()) e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin] for (t0, a0, b0), (t1, a1, b1) in zip(e, e[1:]): d = (t1 - t0) - abs(a1 - a0) - abs(b1 - b0) if d < 0 or d % 2 == 1: print('No') exit() print('Yes')
import sys eval(input()) pt, px, py = 0, 0, 0 for e in sys.stdin: ct, cx, cy = list(map(int, e.split())) d = (ct - pt) - abs(cx - px) - abs(cy - py) if d < 0 or d % 2 == 1: print('No') break pt, px, py = ct, cx, cy else: print('Yes')
9
12
264
268
import sys eval(input()) e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin] for (t0, a0, b0), (t1, a1, b1) in zip(e, e[1:]): d = (t1 - t0) - abs(a1 - a0) - abs(b1 - b0) if d < 0 or d % 2 == 1: print("No") exit() print("Yes")
import sys eval(input()) pt, px, py = 0, 0, 0 for e in sys.stdin: ct, cx, cy = list(map(int, e.split())) d = (ct - pt) - abs(cx - px) - abs(cy - py) if d < 0 or d % 2 == 1: print("No") break pt, px, py = ct, cx, cy else: print("Yes")
false
25
[ "-e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]", "-for (t0, a0, b0), (t1, a1, b1) in zip(e, e[1:]):", "- d = (t1 - t0) - abs(a1 - a0) - abs(b1 - b0)", "+pt, px, py = 0, 0, 0", "+for e in sys.stdin:", "+ ct, cx, cy = list(map(int, e.split()))", "+ d = (ct - pt) - abs(cx - px)...
false
0.041781
0.063968
0.653157
[ "s609352118", "s949402402" ]
u057109575
p02616
python
s433792952
s865835059
363
159
114,468
114,412
Accepted
Accepted
56.2
N, K = list(map(int, input().split())) X = list(map(int, input().split())) MOD = 10 ** 9 + 7 pos = sorted(v for v in X if v >= 0) neg = sorted(-v for v in X if v < 0) ok = False # True: ans>=0, False: ans<0 if pos: if N == K: # Select all -> number of negatives must be even ok = len(...
N, K = list(map(int, input().split())) X = list(map(int, input().split())) MOD = 10 ** 9 + 7 if K % 2 == 1 and all(v < 0 for v in X): # Minimize abs X.sort(key=lambda x: -x) ans = 1 for i in range(K): ans = ans * X[i] % MOD print(ans) elif K == N: ans = 1 for i in r...
45
40
980
833
N, K = list(map(int, input().split())) X = list(map(int, input().split())) MOD = 10**9 + 7 pos = sorted(v for v in X if v >= 0) neg = sorted(-v for v in X if v < 0) ok = False # True: ans>=0, False: ans<0 if pos: if N == K: # Select all -> number of negatives must be even ok = len(neg) % 2 == 0 ...
N, K = list(map(int, input().split())) X = list(map(int, input().split())) MOD = 10**9 + 7 if K % 2 == 1 and all(v < 0 for v in X): # Minimize abs X.sort(key=lambda x: -x) ans = 1 for i in range(K): ans = ans * X[i] % MOD print(ans) elif K == N: ans = 1 for i in range(K): ans...
false
11.111111
[ "-pos = sorted(v for v in X if v >= 0)", "-neg = sorted(-v for v in X if v < 0)", "-ok = False # True: ans>=0, False: ans<0", "-if pos:", "- if N == K:", "- # Select all -> number of negatives must be even", "- ok = len(neg) % 2 == 0", "- else:", "- ok = True", "+if K %...
false
0.041715
0.102819
0.405713
[ "s433792952", "s865835059" ]
u489186465
p03041
python
s060472939
s885147173
187
171
38,384
38,420
Accepted
Accepted
8.56
n, k = list(map(int, input().split())) s = eval(input()) print((s[:k-1] + s[k-1].lower() + s[k:]))
n, k = list(map(int, input().split())) s = list(eval(input())) s[k-1] = s[k-1].lower() print(("".join(s)))
4
5
88
97
n, k = list(map(int, input().split())) s = eval(input()) print((s[: k - 1] + s[k - 1].lower() + s[k:]))
n, k = list(map(int, input().split())) s = list(eval(input())) s[k - 1] = s[k - 1].lower() print(("".join(s)))
false
20
[ "-s = eval(input())", "-print((s[: k - 1] + s[k - 1].lower() + s[k:]))", "+s = list(eval(input()))", "+s[k - 1] = s[k - 1].lower()", "+print((\"\".join(s)))" ]
false
0.052152
0.034417
1.515285
[ "s060472939", "s885147173" ]
u671060652
p03107
python
s066823422
s009310799
326
81
73,836
71,844
Accepted
Accepted
75.15
import itertools import math import fractions import functools import copy s = list(eval(input())) one = s.count("1") zero = s.count("0") print((min(one,zero)*2))
def main(): # n = int(input()) # n, m = map(int, input().split()) # a = list(map(int, input().split())) s = list(eval(input())) # h = [int(input()) for _ in rane(n)] count0 = 0 count1 = 0 for i in s: if i == "0": count0 += 1 else: count...
10
19
164
401
import itertools import math import fractions import functools import copy s = list(eval(input())) one = s.count("1") zero = s.count("0") print((min(one, zero) * 2))
def main(): # n = int(input()) # n, m = map(int, input().split()) # a = list(map(int, input().split())) s = list(eval(input())) # h = [int(input()) for _ in rane(n)] count0 = 0 count1 = 0 for i in s: if i == "0": count0 += 1 else: count1 += 1 p...
false
47.368421
[ "-import itertools", "-import math", "-import fractions", "-import functools", "-import copy", "+def main():", "+ # n = int(input())", "+ # n, m = map(int, input().split())", "+ # a = list(map(int, input().split()))", "+ s = list(eval(input()))", "+ # h = [int(input()) for _ in ra...
false
0.03554
0.074065
0.479853
[ "s066823422", "s009310799" ]
u094191970
p03044
python
s014364745
s159285591
1,141
750
50,072
45,352
Accepted
Accepted
34.27
from collections import deque n=int(eval(input())) tree=[[] for i in range(n)] for i in range(n-1): u,v,w=list(map(int,input().split())) u-=1 v-=1 tree[u].append([v,w]) tree[v].append([u,w]) dist=[-1]*n dist[0]=0 ans=[-1]*n ans[0]=0 dq=deque() dq.append(0) while dq: x=dq.popleft(...
from collections import deque from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) n=int(eval(input())) tree=[[] for i in range(n)] for i in range(n-1): u,v,w=nii() u-=1 v-=1 tree[u].append([v,w]) tree[v].append([u,w]) ans=[-1 for i in range(n)] ans[0]=0 que=deque() q...
34
34
509
558
from collections import deque n = int(eval(input())) tree = [[] for i in range(n)] for i in range(n - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 tree[u].append([v, w]) tree[v].append([u, w]) dist = [-1] * n dist[0] = 0 ans = [-1] * n ans[0] = 0 dq = deque() dq.append(0) while dq: ...
from collections import deque from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) n = int(eval(input())) tree = [[] for i in range(n)] for i in range(n - 1): u, v, w = nii() u -= 1 v -= 1 tree[u].append([v, w]) tree[v].append([u, w]) ans = [-1 for i in range(n)] ans[0] = 0 ...
false
0
[ "+from sys import stdin", "+nii = lambda: list(map(int, stdin.readline().split()))", "- u, v, w = list(map(int, input().split()))", "+ u, v, w = nii()", "-dist = [-1] * n", "-dist[0] = 0", "-ans = [-1] * n", "+ans = [-1 for i in range(n)]", "-dq = deque()", "-dq.append(0)", "-while dq:", ...
false
0.044258
0.044042
1.004916
[ "s014364745", "s159285591" ]
u895445743
p04001
python
s154841915
s027958018
194
77
40,048
67,720
Accepted
Accepted
60.31
from itertools import product a=list(eval(input())) sum=0 text="" for i in product(["","+"],repeat=len(a)-1): text="" for j in range(len(a)-1): text+=a[j]+i[j] text+=a[len(a)-1] sum+=eval(text) print(sum)
from itertools import product s = str(eval(input())) a = list(product(['+', ''], repeat=len(s)-1)) ans = 0 tmp = "" for i in a: tmp = "" for j in range(len(s)-1): tmp += (s[j]+i[j]) tmp += s[len(s)-1] ans += eval(tmp) print(ans)
13
15
244
264
from itertools import product a = list(eval(input())) sum = 0 text = "" for i in product(["", "+"], repeat=len(a) - 1): text = "" for j in range(len(a) - 1): text += a[j] + i[j] text += a[len(a) - 1] sum += eval(text) print(sum)
from itertools import product s = str(eval(input())) a = list(product(["+", ""], repeat=len(s) - 1)) ans = 0 tmp = "" for i in a: tmp = "" for j in range(len(s) - 1): tmp += s[j] + i[j] tmp += s[len(s) - 1] ans += eval(tmp) print(ans)
false
13.333333
[ "-a = list(eval(input()))", "-sum = 0", "-text = \"\"", "-for i in product([\"\", \"+\"], repeat=len(a) - 1):", "- text = \"\"", "- for j in range(len(a) - 1):", "- text += a[j] + i[j]", "- text += a[len(a) - 1]", "- sum += eval(text)", "-print(sum)", "+s = str(eval(input()))"...
false
0.147699
0.035332
4.180345
[ "s154841915", "s027958018" ]
u508164527
p02819
python
s011326351
s384830069
31
17
2,940
3,060
Accepted
Accepted
45.16
X = int(eval(input())) for i in range(X, 100005): for j in range(2,i): if i%j == 0: break else: print(i) quit()
import math X = int(eval(input())) def isPrime(n): if n == 1: return False max = math.ceil(math.sqrt(n)) for i in range(2,max): if n % i == 0: return False return True while(True): if isPrime(X): print(X) quit() else: X = X+1
8
17
134
274
X = int(eval(input())) for i in range(X, 100005): for j in range(2, i): if i % j == 0: break else: print(i) quit()
import math X = int(eval(input())) def isPrime(n): if n == 1: return False max = math.ceil(math.sqrt(n)) for i in range(2, max): if n % i == 0: return False return True while True: if isPrime(X): print(X) quit() else: X = X + 1
false
52.941176
[ "+import math", "+", "-for i in range(X, 100005):", "- for j in range(2, i):", "- if i % j == 0:", "- break", "+", "+", "+def isPrime(n):", "+ if n == 1:", "+ return False", "+ max = math.ceil(math.sqrt(n))", "+ for i in range(2, max):", "+ if n ...
false
0.090021
0.125328
0.718287
[ "s011326351", "s384830069" ]
u757117214
p03060
python
s281465161
s846770491
22
17
3,572
3,060
Accepted
Accepted
22.73
from functools import reduce from operator import add n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] l=[v[i]-c[i] for i in range(n) if v[i]>c[i]] print((reduce(add,l) if l else 0))
n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] sum=0 for i in range(n): if v[i]>c[i]: sum+=v[i]-c[i] print(sum)
7
8
224
164
from functools import reduce from operator import add n = int(eval(input())) v = [int(i) for i in input().split()] c = [int(i) for i in input().split()] l = [v[i] - c[i] for i in range(n) if v[i] > c[i]] print((reduce(add, l) if l else 0))
n = int(eval(input())) v = [int(i) for i in input().split()] c = [int(i) for i in input().split()] sum = 0 for i in range(n): if v[i] > c[i]: sum += v[i] - c[i] print(sum)
false
12.5
[ "-from functools import reduce", "-from operator import add", "-", "-l = [v[i] - c[i] for i in range(n) if v[i] > c[i]]", "-print((reduce(add, l) if l else 0))", "+sum = 0", "+for i in range(n):", "+ if v[i] > c[i]:", "+ sum += v[i] - c[i]", "+print(sum)" ]
false
0.034001
0.033807
1.005728
[ "s281465161", "s846770491" ]
u654470292
p02973
python
s814387506
s160386934
439
141
47,704
14,300
Accepted
Accepted
67.88
import sys from collections import deque import time import bisect def input(): return sys.stdin.readline()[:-1] n=int(eval(input())) a=[int(eval(input())) for i in range(n)] # print(a) ans=deque([a[0]]) for i in range(1,n): loc=bisect.bisect_left(ans,a[i]) if loc==0: ans.appendleft(a[i...
import bisect, copy, heapq, math from math import inf import sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) def celi(a,b...
18
32
377
732
import sys from collections import deque import time import bisect def input(): return sys.stdin.readline()[:-1] n = int(eval(input())) a = [int(eval(input())) for i in range(n)] # print(a) ans = deque([a[0]]) for i in range(1, n): loc = bisect.bisect_left(ans, a[i]) if loc == 0: ans.appendleft(...
import bisect, copy, heapq, math from math import inf import sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0] + list(accumulate(lst)) def celi(a, b)...
false
43.75
[ "+import bisect, copy, heapq, math", "+from math import inf", "-from collections import deque", "-import time", "-import bisect", "+from collections import *", "+from functools import lru_cache", "+from itertools import accumulate, combinations, permutations, product", "+def ruiseki(lst):", "+ ...
false
0.057161
0.043266
1.321165
[ "s814387506", "s160386934" ]