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
u995004106
p02696
python
s232705104
s058563539
397
132
73,144
72,728
Accepted
Accepted
66.75
from math import floor,ceil import fractions import collections import itertools from collections import deque A,B,N=list(map(int,input().split())) piv=B/A #基本数 #for i in range(0,30): # print(A,i,B,floor(A*i/B)-A*floor(i/B)) #A<=Bなら #0,0,.. 1,1,.. ... (A-1),(A-1),...が #先頭から(B%A)の数字まではceil(piv)こ、あとは...
from math import floor,ceil import fractions import collections import itertools from collections import deque A,B,N=list(map(int,input().split())) piv=B/A #基本数 #for i in range(0,30): # print(A,i,B,floor(A*i/B)-A*floor(i/B)) #A<=Bなら #0,0,.. 1,1,.. ... (A-1),(A-1),...が #先頭から(B%A)の数字まではceil(piv)こ、あとは...
41
49
840
1,042
from math import floor, ceil import fractions import collections import itertools from collections import deque A, B, N = list(map(int, input().split())) piv = B / A # 基本数 # for i in range(0,30): # print(A,i,B,floor(A*i/B)-A*floor(i/B)) # A<=Bなら # 0,0,.. 1,1,.. ... (A-1),(A-1),...が # 先頭から(B%A)の数字まではceil(piv)こ、あとはf...
from math import floor, ceil import fractions import collections import itertools from collections import deque A, B, N = list(map(int, input().split())) piv = B / A # 基本数 # for i in range(0,30): # print(A,i,B,floor(A*i/B)-A*floor(i/B)) # A<=Bなら # 0,0,.. 1,1,.. ... (A-1),(A-1),...が # 先頭から(B%A)の数字まではceil(piv)こ、あとはf...
false
16.326531
[ "+# →これより、この答えはmod(B)の空間で単調増加とわかる", "+# よって、f(min(B-1,N))が答え", "+# A>Bでも同じくmod(B)にて単調増加なのを調べてたはずなので", "+# いずれにせよf(min(B-1,N))が答え", "-if A <= B:", "- if N >= B - 1:", "- print((A - 1))", "+\"\"\"", "+if A<=B:", "+ if N>=B-1:", "+ print(A-1)", "- if ceil(piv) * (B % A)...
false
0.056444
0.036784
1.53446
[ "s232705104", "s058563539" ]
u600402037
p02841
python
s032669213
s693900782
149
17
12,396
2,940
Accepted
Accepted
88.59
import sys import numpy as np sys.setrecursionlimit(10 ** 9) stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces M1, D1 = rl() M2, D2 = rl() print((1 if M1 != M2 else 0))
import sys stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces M1, D1 = rl() M2, D2 = rl() print((1 if M1 != M2 else 0))
13
11
293
241
import sys import numpy as np sys.setrecursionlimit(10**9) stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces M1, D1 = rl() M2, D2 = rl() print((1 if M1 != M2 else 0))
import sys stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces M1, D1 = rl() M2, D2 = rl() print((1 if M1 != M2 else 0))
false
15.384615
[ "-import numpy as np", "-sys.setrecursionlimit(10**9)" ]
false
0.036174
0.039603
0.913424
[ "s032669213", "s693900782" ]
u581187895
p02555
python
s759249960
s325590054
708
32
9,068
9,196
Accepted
Accepted
95.48
def resolve(): MOD = 10 ** 9 + 7 N = int(eval(input())) dp = [0] * (N + 1) dp[0] = 1 for n in range(N + 1): for i in range(3, N + 1): dp[n] += dp[n - i] dp[n] %= MOD print((dp[N])) if __name__ == "__main__": resolve()
def resolve(): MOD = 10 ** 9 + 7 N = int(eval(input())) dp = [0] * (N + 1) res = 1 for i in range(3, N + 1): res += dp[i - 3] res %= MOD dp[i] = res print((dp[N])) if __name__ == "__main__": resolve()
17
17
290
265
def resolve(): MOD = 10**9 + 7 N = int(eval(input())) dp = [0] * (N + 1) dp[0] = 1 for n in range(N + 1): for i in range(3, N + 1): dp[n] += dp[n - i] dp[n] %= MOD print((dp[N])) if __name__ == "__main__": resolve()
def resolve(): MOD = 10**9 + 7 N = int(eval(input())) dp = [0] * (N + 1) res = 1 for i in range(3, N + 1): res += dp[i - 3] res %= MOD dp[i] = res print((dp[N])) if __name__ == "__main__": resolve()
false
0
[ "- dp[0] = 1", "- for n in range(N + 1):", "- for i in range(3, N + 1):", "- dp[n] += dp[n - i]", "- dp[n] %= MOD", "+ res = 1", "+ for i in range(3, N + 1):", "+ res += dp[i - 3]", "+ res %= MOD", "+ dp[i] = res" ]
false
0.4393
0.035046
12.534919
[ "s759249960", "s325590054" ]
u163783894
p02774
python
s277125530
s991527270
1,766
1,062
116,504
124,184
Accepted
Accepted
39.86
import sys import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().de...
import sys import numpy as np from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = l...
96
105
2,021
2,368
import sys import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode("utf-8...
import sys import numpy as np from numba import njit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readl...
false
8.571429
[ "-import bisect", "+import numpy as np", "+from numba import njit", "-INF = 10**18", "-def binary_search(min_n, max_n, judge):", "- while max_n - min_n != 1:", "- tn = (min_n + max_n) // 2", "- if judge(tn):", "- max_n = tn", "- else:", "- min_n = tn...
false
0.047135
0.271951
0.173321
[ "s277125530", "s991527270" ]
u392029857
p03331
python
s822660745
s257520943
363
17
3,064
3,060
Accepted
Accepted
95.32
def digit_sum(x): a = list(range(1, x)) min_n = x for i in a: b = x - i p = sum(list(map(int, list(str(i))))) q = sum(list(map(int, list(str(b))))) if min_n > (p+q): min_n = p+q if a == b: break return min_n N = int(eval(input()...
N = int(eval(input())) p = N sums = 0 if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000: print((10)) else: while p >= 1: sums += p%10 p //= 10 print(sums)
14
10
331
198
def digit_sum(x): a = list(range(1, x)) min_n = x for i in a: b = x - i p = sum(list(map(int, list(str(i))))) q = sum(list(map(int, list(str(b))))) if min_n > (p + q): min_n = p + q if a == b: break return min_n N = int(eval(input())) pri...
N = int(eval(input())) p = N sums = 0 if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000: print((10)) else: while p >= 1: sums += p % 10 p //= 10 print(sums)
false
28.571429
[ "-def digit_sum(x):", "- a = list(range(1, x))", "- min_n = x", "- for i in a:", "- b = x - i", "- p = sum(list(map(int, list(str(i)))))", "- q = sum(list(map(int, list(str(b)))))", "- if min_n > (p + q):", "- min_n = p + q", "- if a == b:", ...
false
0.255655
0.034727
7.361891
[ "s822660745", "s257520943" ]
u036104576
p02851
python
s349488533
s033725468
245
152
42,808
130,564
Accepted
Accepted
37.96
import sys import itertools # import numpy as np import time import math import heapq from collections import defaultdict from collections import Counter sys.setrecursionlimit(10 ** 7) INF = 10 ** 18 MOD = 10 ** 9 + 7 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdi...
import sys import itertools # import numpy as np import time import math import heapq from collections import defaultdict from collections import Counter sys.setrecursionlimit(10 ** 7) INF = 10 ** 18 MOD = 10 ** 9 + 7 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdi...
52
55
1,133
1,190
import sys import itertools # import numpy as np import time import math import heapq from collections import defaultdict from collections import Counter sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines #...
import sys import itertools # import numpy as np import time import math import heapq from collections import defaultdict from collections import Counter sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines #...
false
5.454545
[ "- acc[i] = acc[i - 1] + A[i - 1] - 1", "+ acc[i] = acc[i - 1] + A[i - 1]", "+ acc[i] %= K", "+for i in range(0, N + 1):", "+ acc[i] -= i" ]
false
0.129975
0.038264
3.396809
[ "s349488533", "s033725468" ]
u436733497
p04044
python
s707351368
s101364283
129
64
62,232
62,432
Accepted
Accepted
50.39
x, y = list(map(int, input().split())) s = sorted([eval(input ()) for i in range(x)]) print(("".join(s)))
n, l = list(map(int, input().split())) k = [eval(input()) for _ in range(n)] s = sorted(k) print(("".join(s)))
3
4
93
99
x, y = list(map(int, input().split())) s = sorted([eval(input()) for i in range(x)]) print(("".join(s)))
n, l = list(map(int, input().split())) k = [eval(input()) for _ in range(n)] s = sorted(k) print(("".join(s)))
false
25
[ "-x, y = list(map(int, input().split()))", "-s = sorted([eval(input()) for i in range(x)])", "+n, l = list(map(int, input().split()))", "+k = [eval(input()) for _ in range(n)]", "+s = sorted(k)" ]
false
0.041677
0.038677
1.077559
[ "s707351368", "s101364283" ]
u189023301
p02574
python
s791424821
s519089131
503
440
194,456
195,252
Accepted
Accepted
12.52
from math import gcd n = int(eval(input())) s = list(map(int, input().split())) s.sort() dp = [0] * ((10 ** 6) + 100) res = s[0] for ss in s: dp[ss] += 1 res = gcd(res, ss) A = max(s) pairwise = True setwise = (res == 1) for i in range(2, A + 1): cnt = 0 for j in range(i, A + 1, i): ...
from math import gcd n = int(eval(input())) s = list(map(int, input().split())) s.sort() dp = [0] * ((10 ** 6) + 100) res = s[0] for ss in s: dp[ss] += 1 res = gcd(res, ss) A = max(s) pairwise = True setwise = (res == 1) for i in range(2, A + 1): cnt = 0 for j in range(i, A + 1, i): ...
28
29
504
519
from math import gcd n = int(eval(input())) s = list(map(int, input().split())) s.sort() dp = [0] * ((10**6) + 100) res = s[0] for ss in s: dp[ss] += 1 res = gcd(res, ss) A = max(s) pairwise = True setwise = res == 1 for i in range(2, A + 1): cnt = 0 for j in range(i, A + 1, i): cnt += dp[j] ...
from math import gcd n = int(eval(input())) s = list(map(int, input().split())) s.sort() dp = [0] * ((10**6) + 100) res = s[0] for ss in s: dp[ss] += 1 res = gcd(res, ss) A = max(s) pairwise = True setwise = res == 1 for i in range(2, A + 1): cnt = 0 for j in range(i, A + 1, i): cnt += dp[j] ...
false
3.448276
[ "+ break" ]
false
0.103106
0.050387
2.046279
[ "s791424821", "s519089131" ]
u095021077
p02958
python
s598765337
s785692887
187
151
38,256
12,508
Accepted
Accepted
19.25
N=int(eval(input())) p=list(map(int, input().split())) counter=0 for i in range(N): if p[i]!=int(i+1): counter+=1 if counter==0 or counter==2: print('YES') else: print('NO')
import numpy as np N=int(eval(input())) p=np.array(list(map(int, input().split()))) q=np.arange(N)+1 temp=np.sum(~(p==q)) if temp==0 or temp==2: print('YES') else: print('NO')
12
12
194
189
N = int(eval(input())) p = list(map(int, input().split())) counter = 0 for i in range(N): if p[i] != int(i + 1): counter += 1 if counter == 0 or counter == 2: print("YES") else: print("NO")
import numpy as np N = int(eval(input())) p = np.array(list(map(int, input().split()))) q = np.arange(N) + 1 temp = np.sum(~(p == q)) if temp == 0 or temp == 2: print("YES") else: print("NO")
false
0
[ "+import numpy as np", "+", "-p = list(map(int, input().split()))", "-counter = 0", "-for i in range(N):", "- if p[i] != int(i + 1):", "- counter += 1", "-if counter == 0 or counter == 2:", "+p = np.array(list(map(int, input().split())))", "+q = np.arange(N) + 1", "+temp = np.sum(~(p =...
false
0.037503
0.421691
0.088934
[ "s598765337", "s785692887" ]
u606033239
p03378
python
s000355513
s113743631
20
18
3,064
3,060
Accepted
Accepted
10
n,m,x=list(map(int,input().split())) a=list(map(int,input().split())) s=0 i=0 while a[i]<=x: s+=1 i+=1 print((min(s,m-s)))
n,m,x=list(map(int,input().split())) a=list(map(int,input().split())) i=0 while a[i]<=x: i+=1 print((min(i,m-i)))
8
6
129
114
n, m, x = list(map(int, input().split())) a = list(map(int, input().split())) s = 0 i = 0 while a[i] <= x: s += 1 i += 1 print((min(s, m - s)))
n, m, x = list(map(int, input().split())) a = list(map(int, input().split())) i = 0 while a[i] <= x: i += 1 print((min(i, m - i)))
false
25
[ "-s = 0", "- s += 1", "-print((min(s, m - s)))", "+print((min(i, m - i)))" ]
false
0.042746
0.038392
1.113415
[ "s000355513", "s113743631" ]
u347600233
p02724
python
s440287822
s126255076
30
23
9,032
9,100
Accepted
Accepted
23.33
x = int(eval(input())) print((1000*(x // 500) + 5*((x % 500) // 5) ))
x = int(eval(input())) print((1000*(x // 500) + 5*(x%500 // 5) ))
2
2
62
58
x = int(eval(input())) print((1000 * (x // 500) + 5 * ((x % 500) // 5)))
x = int(eval(input())) print((1000 * (x // 500) + 5 * (x % 500 // 5)))
false
0
[ "-print((1000 * (x // 500) + 5 * ((x % 500) // 5)))", "+print((1000 * (x // 500) + 5 * (x % 500 // 5)))" ]
false
0.037335
0.042325
0.882081
[ "s440287822", "s126255076" ]
u562935282
p03837
python
s216743736
s337620534
215
121
3,444
3,316
Accepted
Accepted
43.72
# https://atcoder.jp/contests/abc051/submissions/1055446 def main(): import sys input = sys.stdin.readline inf = 1000 * 100 + 10 N, M = list(map(int, input().split())) dist = [[inf for _ in range(N)] for _ in range(N)] for j in range(N): dist[j][j] = 0 es = [] ...
# https://atcoder.jp/contests/abc051/submissions/1055446 def main(): import sys input = sys.stdin.readline inf = 1000 * 100 + 10 N, M = list(map(int, input().split())) dist = [[inf for _ in range(N)] for _ in range(N)] for j in range(N): dist[j][j] = 0 es = [] ...
38
38
836
849
# https://atcoder.jp/contests/abc051/submissions/1055446 def main(): import sys input = sys.stdin.readline inf = 1000 * 100 + 10 N, M = list(map(int, input().split())) dist = [[inf for _ in range(N)] for _ in range(N)] for j in range(N): dist[j][j] = 0 es = [] for _ in range(M):...
# https://atcoder.jp/contests/abc051/submissions/1055446 def main(): import sys input = sys.stdin.readline inf = 1000 * 100 + 10 N, M = list(map(int, input().split())) dist = [[inf for _ in range(N)] for _ in range(N)] for j in range(N): dist[j][j] = 0 es = [] for _ in range(M):...
false
0
[ "- for i in range(N):", "- for j in range(N):", "+ for j in range(N):", "+ for i in range(j):", "- dist[i][j] = d", "+ dist[i][j] = dist[j][i] = d" ]
false
0.056481
0.091193
0.619355
[ "s216743736", "s337620534" ]
u619144316
p02813
python
s493177253
s370953553
19
17
3,064
3,064
Accepted
Accepted
10.53
N = int(eval(input())) P = [int(i) for i in input().split(' ')] Q = [int(i) for i in input().split(' ')] fact = [1] * 8 for i in range(1,8): fact[i] = fact[i-1] * i a = 0 remain = list(range(1,N+1)) for i , v in enumerate(P): num = remain.index(v) remain.remove(v) a += num * fact[(N - ...
N = int(eval(input())) P = list(map(int,input().split())) Q = list(map(int,input().split())) fact = [1] *(N+1) for i in range(1,N+1): fact[i] = fact[i-1] *i a = 1 b = 1 P2 = sorted(P) Q2 = sorted(Q) for i,(p,q) in enumerate(zip(P,Q)): a += P2.index(p)*fact[N-i-1] b += Q2.index(q)*fact[N-i-1] ...
25
18
493
368
N = int(eval(input())) P = [int(i) for i in input().split(" ")] Q = [int(i) for i in input().split(" ")] fact = [1] * 8 for i in range(1, 8): fact[i] = fact[i - 1] * i a = 0 remain = list(range(1, N + 1)) for i, v in enumerate(P): num = remain.index(v) remain.remove(v) a += num * fact[(N - i - 1)] b = 0...
N = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) fact = [1] * (N + 1) for i in range(1, N + 1): fact[i] = fact[i - 1] * i a = 1 b = 1 P2 = sorted(P) Q2 = sorted(Q) for i, (p, q) in enumerate(zip(P, Q)): a += P2.index(p) * fact[N - i - 1] b += Q2.index(q) * fact[...
false
28
[ "-P = [int(i) for i in input().split(\" \")]", "-Q = [int(i) for i in input().split(\" \")]", "-fact = [1] * 8", "-for i in range(1, 8):", "+P = list(map(int, input().split()))", "+Q = list(map(int, input().split()))", "+fact = [1] * (N + 1)", "+for i in range(1, N + 1):", "-a = 0", "-remain = lis...
false
0.040803
0.042163
0.967745
[ "s493177253", "s370953553" ]
u389910364
p03988
python
s940129777
s303845900
163
21
13,684
3,316
Accepted
Accepted
87.12
import bisect import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator imp...
import os import sys from collections import Counter if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) counts = Counter(A) m...
44
31
939
605
import bisect import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter...
import os import sys from collections import Counter if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) counts = Counter(A) ma = max(A) mi = min(A) ...
false
29.545455
[ "-import bisect", "-import heapq", "-import itertools", "-import math", "-import operator", "-import re", "-import string", "-from collections import Counter, deque, defaultdict", "-from copy import deepcopy", "-from decimal import Decimal", "-from fractions import gcd", "-from functools impor...
false
0.150485
0.034715
4.33486
[ "s940129777", "s303845900" ]
u883048396
p03645
python
s268058814
s754118640
309
263
56,620
6,132
Accepted
Accepted
14.89
import sys def 解(): iN,iM = [int(_) for _ in input().split()] a1 = [0]*iN aN = [0]*iN aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] for a,b in aAB: if a == 1: a1[b] = 1 if b == iN: aN[a] = 1 for i in range(iN): ...
import sys input = sys.stdin.readline def 解(): iN,iM = [int(_) for _ in input().split()] a1 = [0]*iN aN = [0]*iN for i in range(iM): a,b = [int(_) for _ in input().split()] if a == 1: a1[b] = 1 if b == iN: aN[a] = 1 for i in range(iN): ...
17
18
425
426
import sys def 解(): iN, iM = [int(_) for _ in input().split()] a1 = [0] * iN aN = [0] * iN aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] for a, b in aAB: if a == 1: a1[b] = 1 if b == iN: aN[a] = 1 for i in range(iN): ...
import sys input = sys.stdin.readline def 解(): iN, iM = [int(_) for _ in input().split()] a1 = [0] * iN aN = [0] * iN for i in range(iM): a, b = [int(_) for _ in input().split()] if a == 1: a1[b] = 1 if b == iN: aN[a] = 1 for i in range(iN): ...
false
5.555556
[ "+", "+input = sys.stdin.readline", "- aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]", "- for a, b in aAB:", "+ for i in range(iM):", "+ a, b = [int(_) for _ in input().split()]" ]
false
0.044257
0.045322
0.976482
[ "s268058814", "s754118640" ]
u277312083
p03835
python
s429407541
s176998513
1,768
1,158
2,940
9,076
Accepted
Accepted
34.5
k, s = list(map(int, input().split())) c = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - x - y and s - x - y <= k: c += 1 print(c)
k, s = list(map(int, input().split())) ans = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if 0 <= z and z <= k: ans += 1 print(ans)
7
8
169
182
k, s = list(map(int, input().split())) c = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - x - y and s - x - y <= k: c += 1 print(c)
k, s = list(map(int, input().split())) ans = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if 0 <= z and z <= k: ans += 1 print(ans)
false
12.5
[ "-c = 0", "+ans = 0", "- if 0 <= s - x - y and s - x - y <= k:", "- c += 1", "-print(c)", "+ z = s - x - y", "+ if 0 <= z and z <= k:", "+ ans += 1", "+print(ans)" ]
false
0.039102
0.036743
1.064215
[ "s429407541", "s176998513" ]
u480200603
p02629
python
s345968014
s842315881
33
27
9,048
9,184
Accepted
Accepted
18.18
n = int(input()) s = "abcdefghijklmnopqrstuvwxyz" ans = [] t = 1 while n > 26: tmp = n % 26 if tmp == 0: tmp = 26 n //= 26 n -= 1 ans.append(tmp) continue ans.append(tmp) n //= 26 ans.append(n) for i in ans[::-1]: print(s[i-1], end="")
n = int(input()) s = "abcdefghijklmnopqrstuvwxyz" ans = [] while n > 26: n -= 1 tmp = n % 26 ans.append(tmp) n //= 26 ans.append(n-1) for i in ans[::-1]: print(s[i], end="")
21
14
320
210
n = int(input()) s = "abcdefghijklmnopqrstuvwxyz" ans = [] t = 1 while n > 26: tmp = n % 26 if tmp == 0: tmp = 26 n //= 26 n -= 1 ans.append(tmp) continue ans.append(tmp) n //= 26 ans.append(n) for i in ans[::-1]: print(s[i - 1], end="")
n = int(input()) s = "abcdefghijklmnopqrstuvwxyz" ans = [] while n > 26: n -= 1 tmp = n % 26 ans.append(tmp) n //= 26 ans.append(n - 1) for i in ans[::-1]: print(s[i], end="")
false
33.333333
[ "-t = 1", "+ n -= 1", "- if tmp == 0:", "- tmp = 26", "- n //= 26", "- n -= 1", "- ans.append(tmp)", "- continue", "-ans.append(n)", "+ans.append(n - 1)", "- print(s[i - 1], end=\"\")", "+ print(s[i], end=\"\")" ]
false
0.033467
0.035736
0.936487
[ "s345968014", "s842315881" ]
u246401133
p02584
python
s725387205
s627597758
30
26
9,176
9,188
Accepted
Accepted
13.33
y, k, d = list(map(int, input().split())) x = abs(y) i = int(x / d) if i >= k: p = x - k * d elif i == x / d: if (i + k) % 2 == 0: p = 0 else: p = d else: if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0): p = x - i * d else: p = (i + 1) * d - x print...
y, k, d = list(map(int, input().split())) x = abs(y) if k * d <= x: a = x - k * d else: if x % d == 0: if (k - (x / d)) % 2 == 0: a = 0 else: a = d else: b = x // d if (k - b) % 2 == 0: a = x - d * b else: ...
16
17
322
343
y, k, d = list(map(int, input().split())) x = abs(y) i = int(x / d) if i >= k: p = x - k * d elif i == x / d: if (i + k) % 2 == 0: p = 0 else: p = d else: if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0): p = x - i * d else: p = (i + 1) * d - x print((int(p)))
y, k, d = list(map(int, input().split())) x = abs(y) if k * d <= x: a = x - k * d else: if x % d == 0: if (k - (x / d)) % 2 == 0: a = 0 else: a = d else: b = x // d if (k - b) % 2 == 0: a = x - d * b else: a = -x + b * d...
false
5.882353
[ "-i = int(x / d)", "-if i >= k:", "- p = x - k * d", "-elif i == x / d:", "- if (i + k) % 2 == 0:", "- p = 0", "+if k * d <= x:", "+ a = x - k * d", "+else:", "+ if x % d == 0:", "+ if (k - (x / d)) % 2 == 0:", "+ a = 0", "+ else:", "+ ...
false
0.033958
0.033477
1.014387
[ "s725387205", "s627597758" ]
u958506960
p03767
python
s801548213
s450256988
229
209
39,492
37,084
Accepted
Accepted
8.73
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) ans = 0 for i in range(n): ans += a[i * 2 + 1] print(ans)
n = int(eval(input())) a = sorted(map(int, input().split())) print((sum(a[n::2])))
8
3
145
76
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) ans = 0 for i in range(n): ans += a[i * 2 + 1] print(ans)
n = int(eval(input())) a = sorted(map(int, input().split())) print((sum(a[n::2])))
false
62.5
[ "-a = sorted(list(map(int, input().split())), reverse=True)", "-ans = 0", "-for i in range(n):", "- ans += a[i * 2 + 1]", "-print(ans)", "+a = sorted(map(int, input().split()))", "+print((sum(a[n::2])))" ]
false
0.04538
0.036659
1.237912
[ "s801548213", "s450256988" ]
u997521090
p03704
python
s749282574
s548682202
15
13
2,568
2,568
Accepted
Accepted
13.33
def func(d, cnt9, cnt0): if cnt9 < 1 : return d == 0 n = int("9" * cnt9 + "0" * cnt0) return sum(func(d + i * n, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) if abs(d + i * n) < n) D = eval(input()) print(sum(func(D, i, 0) * (10 - i % 2 * 9) for i in range(1, 21)))
def func(d, x, y): n = int("9" * x + "0" * y) return d == 0 if x < 1 else sum(func(d + i * n, x - 2, y + 1) * (10 - abs(i) - (y < 1)) for i in range(-9, 10) if abs(d + i * n) < n) D = eval(input());print(sum(func(D, i, 0) * (10 - i % 2 * 9) for i in range(1, 21)))
7
4
307
268
def func(d, cnt9, cnt0): if cnt9 < 1: return d == 0 n = int("9" * cnt9 + "0" * cnt0) return sum( func(d + i * n, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) if abs(d + i * n) < n ) D = eval(input()) print(sum(func(D, i, 0) * (10 - i % 2 * ...
def func(d, x, y): n = int("9" * x + "0" * y) return ( d == 0 if x < 1 else sum( func(d + i * n, x - 2, y + 1) * (10 - abs(i) - (y < 1)) for i in range(-9, 10) if abs(d + i * n) < n ) ) D = eval(input()) print(sum(func(D, i, 0) * (10 - i ...
false
42.857143
[ "-def func(d, cnt9, cnt0):", "- if cnt9 < 1:", "- return d == 0", "- n = int(\"9\" * cnt9 + \"0\" * cnt0)", "- return sum(", "- func(d + i * n, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1))", "- for i in range(-9, 10)", "- if abs(d + i * n) < n", "+def func...
false
0.043954
0.03387
1.297706
[ "s749282574", "s548682202" ]
u987164499
p03611
python
s847560820
s814190486
204
82
14,300
13,964
Accepted
Accepted
59.8
from sys import stdin import bisect n = int(stdin.readline().rstrip()) li = list(map(int,stdin.readline().rstrip().split())) li.sort() ma = 0 if len(li) == 1: print((1)) elif len(li) == 2: if abs(li[0] - li[1]) <= 1: print((2)) else: print((1)) else: for i in range(...
n = int(eval(input())) a = list(map(int,input().split())) point = [0]*(10**5+2) for i in a: if i == 1: point[1] += 1 point[2] += 1 else: point[i] += 1 point[i-1] += 1 point[i+1] += 1 print((max(point)))
22
15
409
259
from sys import stdin import bisect n = int(stdin.readline().rstrip()) li = list(map(int, stdin.readline().rstrip().split())) li.sort() ma = 0 if len(li) == 1: print((1)) elif len(li) == 2: if abs(li[0] - li[1]) <= 1: print((2)) else: print((1)) else: for i in range(1, n - 1): m...
n = int(eval(input())) a = list(map(int, input().split())) point = [0] * (10**5 + 2) for i in a: if i == 1: point[1] += 1 point[2] += 1 else: point[i] += 1 point[i - 1] += 1 point[i + 1] += 1 print((max(point)))
false
31.818182
[ "-from sys import stdin", "-import bisect", "-", "-n = int(stdin.readline().rstrip())", "-li = list(map(int, stdin.readline().rstrip().split()))", "-li.sort()", "-ma = 0", "-if len(li) == 1:", "- print((1))", "-elif len(li) == 2:", "- if abs(li[0] - li[1]) <= 1:", "- print((2))", ...
false
0.041537
0.047136
0.881223
[ "s847560820", "s814190486" ]
u480138356
p03108
python
s931447643
s742810255
1,132
514
51,800
49,944
Accepted
Accepted
54.59
import sys input = sys.stdin.readline class Node: def __init__(self): self.is_root = True self.parent = None self.child_num = 0 def root_node(self): node = self while not node.is_root: node = node.parent return node def main(): ...
import sys input = sys.stdin.readline class Node: def __init__(self): self.is_root = True self.parent = None self.child_num = 0 def root_node(self): node = self while not node.is_root: node = node.parent return node def main(): ...
53
53
1,403
1,395
import sys input = sys.stdin.readline class Node: def __init__(self): self.is_root = True self.parent = None self.child_num = 0 def root_node(self): node = self while not node.is_root: node = node.parent return node def main(): N, M = list(ma...
import sys input = sys.stdin.readline class Node: def __init__(self): self.is_root = True self.parent = None self.child_num = 0 def root_node(self): node = self while not node.is_root: node = node.parent return node def main(): N, M = list(ma...
false
0
[ "- # if root_b.child_num > root_a.child_num:", "- # tmp = root_a", "- # root_a = root_b", "- # root_b = tmp", "+ if root_b.child_num > root_a.child_num:", "+ tmp = root_a", "+ root_a = root_b", "+ ...
false
0.11057
0.075205
1.47025
[ "s931447643", "s742810255" ]
u981931040
p02996
python
s631256743
s576235009
1,041
910
55,256
53,660
Accepted
Accepted
12.58
N = int (eval(input())) work = [] work_time = 0 flag = 0 for i in range(N): work.append(list(map(int , input().split()))) #print(work) work = sorted(work , key = lambda x: x[1]) #work.sort() #sort(work) #print() #print("sorting ... ") #print() #print(work) for i in range(N): work_time += work[i...
N = int(eval(input())) AB = list(list(map(int, input().split())) for _ in range(N)) AB.sort(key=lambda x: x[1]) now = 0 for a, b in AB: now += a if now > b: print("No") exit() print("Yes")
25
10
442
215
N = int(eval(input())) work = [] work_time = 0 flag = 0 for i in range(N): work.append(list(map(int, input().split()))) # print(work) work = sorted(work, key=lambda x: x[1]) # work.sort() # sort(work) # print() # print("sorting ... ") # print() # print(work) for i in range(N): work_time += work[i][0] if wor...
N = int(eval(input())) AB = list(list(map(int, input().split())) for _ in range(N)) AB.sort(key=lambda x: x[1]) now = 0 for a, b in AB: now += a if now > b: print("No") exit() print("Yes")
false
60
[ "-work = []", "-work_time = 0", "-flag = 0", "-for i in range(N):", "- work.append(list(map(int, input().split())))", "-# print(work)", "-work = sorted(work, key=lambda x: x[1])", "-# work.sort()", "-# sort(work)", "-# print()", "-# print(\"sorting ... \")", "-# print()", "-# print(work)"...
false
0.121536
0.038416
3.163678
[ "s631256743", "s576235009" ]
u077291787
p02837
python
s582203568
s850921436
50
45
3,064
3,064
Accepted
Accepted
10
# ABC147C - HonestOrUnkind2 from itertools import combinations def main(): N = int(eval(input())) testimonies = {i: {} for i in range(1, N + 1)} for i in range(1, N + 1): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) tes...
# ABC147C - HonestOrUnkind2 from itertools import combinations def main(): N = int(eval(input())) testimonies = [[] for i in range(N + 1)] for i in range(1, N + 1): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) testimoni...
32
32
990
983
# ABC147C - HonestOrUnkind2 from itertools import combinations def main(): N = int(eval(input())) testimonies = {i: {} for i in range(1, N + 1)} for i in range(1, N + 1): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) testimonies[i]...
# ABC147C - HonestOrUnkind2 from itertools import combinations def main(): N = int(eval(input())) testimonies = [[] for i in range(N + 1)] for i in range(1, N + 1): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) testimonies[i].appen...
false
0
[ "- testimonies = {i: {} for i in range(1, N + 1)}", "+ testimonies = [[] for i in range(N + 1)]", "- testimonies[i][x] = y", "+ testimonies[i].append((x, y))", "- for x, y in list(testimonies[i].items()):", "+ for x, y in testimonies[i]:" ]
false
0.038078
0.046616
0.816836
[ "s582203568", "s850921436" ]
u102461423
p03464
python
s355279915
s245298532
101
80
14,168
18,836
Accepted
Accepted
20.79
import sys input = sys.stdin.readline N = list(map(int,input().split())) A = [int(x) for x in input().split()] low,high = 2,2 for a in A[::-1]: low += (-low)%a high -= high%a high += (a-1) if low > high: print((-1)) else: print((low,high))
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A = list(map(int, read().split())) def f(A): low, high = 2, 2 for x in A[::-1]: low += (-low) % x high -= (high) % x if low > high: print((...
17
20
269
403
import sys input = sys.stdin.readline N = list(map(int, input().split())) A = [int(x) for x in input().split()] low, high = 2, 2 for a in A[::-1]: low += (-low) % a high -= high % a high += a - 1 if low > high: print((-1)) else: print((low, high))
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A = list(map(int, read().split())) def f(A): low, high = 2, 2 for x in A[::-1]: low += (-low) % x high -= (high) % x if low > high: print((-1)) ...
false
15
[ "-input = sys.stdin.readline", "-N = list(map(int, input().split()))", "-A = [int(x) for x in input().split()]", "-low, high = 2, 2", "-for a in A[::-1]:", "- low += (-low) % a", "- high -= high % a", "- high += a - 1", "-if low > high:", "- print((-1))", "-else:", "+read = sys.std...
false
0.10001
0.037324
2.679519
[ "s355279915", "s245298532" ]
u738898077
p02580
python
s311675710
s471982115
584
473
196,704
219,860
Accepted
Accepted
19.01
from bisect import bisect_left import sys input = sys.stdin.readline H,W,m = list(map(int,input().split())) h = [0]*(H+1) w = [0]*(W+1) c = [[-1,10**6] for i in range(H+1)] for i in range(m): a,b = list(map(int,input().split())) h[a] += 1 w[b] += 1 c[a].append(b) mh = max(h) mw = max(w) hk...
from bisect import bisect_left import sys input = sys.stdin.readline H,W,m = list(map(int,input().split())) h = [0]*(H+1) w = [0]*(W+1) c = [{-1,10**6} for i in range(H+1)] for i in range(m): a,b = list(map(int,input().split())) h[a] += 1 w[b] += 1 c[a].add(b) mh = max(h) mw = max(w) hkouh...
30
30
663
662
from bisect import bisect_left import sys input = sys.stdin.readline H, W, m = list(map(int, input().split())) h = [0] * (H + 1) w = [0] * (W + 1) c = [[-1, 10**6] for i in range(H + 1)] for i in range(m): a, b = list(map(int, input().split())) h[a] += 1 w[b] += 1 c[a].append(b) mh = max(h) mw = max(w)...
from bisect import bisect_left import sys input = sys.stdin.readline H, W, m = list(map(int, input().split())) h = [0] * (H + 1) w = [0] * (W + 1) c = [{-1, 10**6} for i in range(H + 1)] for i in range(m): a, b = list(map(int, input().split())) h[a] += 1 w[b] += 1 c[a].add(b) mh = max(h) mw = max(w) hk...
false
0
[ "-c = [[-1, 10**6] for i in range(H + 1)]", "+c = [{-1, 10**6} for i in range(H + 1)]", "- c[a].append(b)", "+ c[a].add(b)", "- c[i] = set(c[i])", "+ # c[i] = set(c[i])" ]
false
0.048014
0.04877
0.984497
[ "s311675710", "s471982115" ]
u345966487
p03682
python
s128814384
s694618162
1,909
1,141
126,108
62,776
Accepted
Accepted
40.23
import sys class UnionFind: def __init__(self, n): # total number of nodes. self.n = n # node id -> root node id self._root_table = list(range(n)) # root node id -> group size self._size_table = [1] * n def find(self, x): """Returns x's roo...
"""Minimum spanning tree with Kruskal's algorithm""" import sys class UnionFind: def __init__(self, n): # total number of nodes. self.n = n # node id -> root node id self._root_table = list(range(n)) # root node id -> group size self._size_table = [1] * n...
98
99
2,495
2,549
import sys class UnionFind: def __init__(self, n): # total number of nodes. self.n = n # node id -> root node id self._root_table = list(range(n)) # root node id -> group size self._size_table = [1] * n def find(self, x): """Returns x's root node id."""...
"""Minimum spanning tree with Kruskal's algorithm""" import sys class UnionFind: def __init__(self, n): # total number of nodes. self.n = n # node id -> root node id self._root_table = list(range(n)) # root node id -> group size self._size_table = [1] * n def f...
false
1.010101
[ "+\"\"\"Minimum spanning tree with Kruskal's algorithm\"\"\"" ]
false
0.041378
0.038403
1.077457
[ "s128814384", "s694618162" ]
u079022693
p03044
python
s236244882
s294932037
571
478
43,924
43,924
Accepted
Accepted
16.29
from sys import stdin from collections import deque def main(): #入力 readline=stdin.readline N=int(readline()) g=[[] for _ in range(N)] for _ in range(N-1): u,v,w=list(map(int,readline().split())) u-=1 v-=1 g[u].append((v,w)) g[v].append((u,w)) ...
from sys import stdin from collections import deque def main(): #入力 readline=stdin.readline n=int(readline()) G=[[] for _ in range(n+1)] for _ in range(n-1): u,v,w=list(map(int,readline().split())) G[u].append((v,w)) G[v].append((u,w)) d=[0]*(n+1) flags=...
36
32
789
739
from sys import stdin from collections import deque def main(): # 入力 readline = stdin.readline N = int(readline()) g = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, readline().split())) u -= 1 v -= 1 g[u].append((v, w)) g[v].append((u...
from sys import stdin from collections import deque def main(): # 入力 readline = stdin.readline n = int(readline()) G = [[] for _ in range(n + 1)] for _ in range(n - 1): u, v, w = list(map(int, readline().split())) G[u].append((v, w)) G[v].append((u, w)) d = [0] * (n + 1...
false
11.111111
[ "- N = int(readline())", "- g = [[] for _ in range(N)]", "- for _ in range(N - 1):", "+ n = int(readline())", "+ G = [[] for _ in range(n + 1)]", "+ for _ in range(n - 1):", "- u -= 1", "- v -= 1", "- g[u].append((v, w))", "- g[v].append((u, w))", "-...
false
0.046267
0.050873
0.90947
[ "s236244882", "s294932037" ]
u235376569
p02725
python
s728234773
s323605224
235
175
26,444
24,948
Accepted
Accepted
25.53
K,N=[int(x) for x in input().rstrip().split()] A=[int(x) for x in input().rstrip().split()] flag=1 now=0 mae=[] back=[] for i in range(N-1): mae.append(A[i+1]-A[i]) mae.append(A[len(A)-1]-A[0]) for i in range(N-1,0,-1): back.append(A[i]-A[i-1]) back.append(abs(A[0])+abs(K-A[N-1])) back.sort() mae...
K,N=[int(x) for x in input().rstrip().split()] A=[int(x) for x in input().rstrip().split()] A14=K-A[N-1]+A[0] sa=[A14] for i in range(N-1): sa.append(A[i+1]-A[i]) sa.sort() ans=0 for i in range(N-1): ans+=sa[i] print(ans)
19
13
395
239
K, N = [int(x) for x in input().rstrip().split()] A = [int(x) for x in input().rstrip().split()] flag = 1 now = 0 mae = [] back = [] for i in range(N - 1): mae.append(A[i + 1] - A[i]) mae.append(A[len(A) - 1] - A[0]) for i in range(N - 1, 0, -1): back.append(A[i] - A[i - 1]) back.append(abs(A[0]) + abs(K - A[N ...
K, N = [int(x) for x in input().rstrip().split()] A = [int(x) for x in input().rstrip().split()] A14 = K - A[N - 1] + A[0] sa = [A14] for i in range(N - 1): sa.append(A[i + 1] - A[i]) sa.sort() ans = 0 for i in range(N - 1): ans += sa[i] print(ans)
false
31.578947
[ "-flag = 1", "-now = 0", "-mae = []", "-back = []", "+A14 = K - A[N - 1] + A[0]", "+sa = [A14]", "- mae.append(A[i + 1] - A[i])", "-mae.append(A[len(A) - 1] - A[0])", "-for i in range(N - 1, 0, -1):", "- back.append(A[i] - A[i - 1])", "-back.append(abs(A[0]) + abs(K - A[N - 1]))", "-back...
false
0.068919
0.042897
1.606641
[ "s728234773", "s323605224" ]
u554133763
p02689
python
s654582434
s082641905
430
259
86,240
20,052
Accepted
Accepted
39.77
n, m= list(map(int, input().split())) high = list(map(int, input().split())) ans = [1]*n for i in range(m): a, b = list(map(int, input().split())) if high[a-1] > high[b-1]: ans[b-1] = 0 elif high[a-1] < high[b-1]: ans[a-1] = 0 else: ans[a-1] = 0 ans[b-1] = 0 ...
n, m= list(map(int, input().split())) high = list(map(int, input().split())) ans = [0]*n for i in range(m): a,b = list(map(int, input().split())) if high[a-1] > high[b-1]: if ans[a-1] == 0: ans[a-1] = 1 ans[b-1] = -1 elif high[a-1] < high[b-1]: if ans[b-1] ==...
14
18
324
453
n, m = list(map(int, input().split())) high = list(map(int, input().split())) ans = [1] * n for i in range(m): a, b = list(map(int, input().split())) if high[a - 1] > high[b - 1]: ans[b - 1] = 0 elif high[a - 1] < high[b - 1]: ans[a - 1] = 0 else: ans[a - 1] = 0 ans[b - 1...
n, m = list(map(int, input().split())) high = list(map(int, input().split())) ans = [0] * n for i in range(m): a, b = list(map(int, input().split())) if high[a - 1] > high[b - 1]: if ans[a - 1] == 0: ans[a - 1] = 1 ans[b - 1] = -1 elif high[a - 1] < high[b - 1]: if ans[b ...
false
22.222222
[ "-ans = [1] * n", "+ans = [0] * n", "- ans[b - 1] = 0", "+ if ans[a - 1] == 0:", "+ ans[a - 1] = 1", "+ ans[b - 1] = -1", "- ans[a - 1] = 0", "+ if ans[b - 1] == 0:", "+ ans[b - 1] = 1", "+ ans[a - 1] = -1", "- ans[a - 1] = 0...
false
0.047307
0.037455
1.263053
[ "s654582434", "s082641905" ]
u075595666
p03450
python
s415859802
s611906430
1,296
811
9,068
9,288
Accepted
Accepted
37.42
#重み付きUnion-Find #xの根を求める def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px #xの根から距離 def weight(x): find(x) return wei[x] #w[y]=w[x]+wとなるようにxとyを併合 def unite(x,y,w): w += wei[x]-wei[y...
#重み付きUnion-Find #xの根を求める def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px #xの根から距離 def weight(x): find(x) return wei[x] #w[y]=w[x]+wとなるようにxとyを併合 def unite(x,y,w): w += wei[x]-wei[y...
60
62
1,040
1,082
# 重み付きUnion-Find # xの根を求める def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px # xの根から距離 def weight(x): find(x) return wei[x] # w[y]=w[x]+wとなるようにxとyを併合 def unite(x, y, w): w += wei[x] - wei[y] x = fi...
# 重み付きUnion-Find # xの根を求める def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px # xの根から距離 def weight(x): find(x) return wei[x] # w[y]=w[x]+wとなるようにxとyを併合 def unite(x, y, w): w += wei[x] - wei[y] x = fi...
false
3.225806
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.048207
0.213586
0.225705
[ "s415859802", "s611906430" ]
u223663729
p03045
python
s845444504
s928097080
611
194
119,292
40,068
Accepted
Accepted
68.25
class UnionFind: def __init__(self, n=0): self.d = [-1]*n self.u = n def root(self, x): if self.d[x] < 0: return x self.d[x] = self.root(self.d[x]) return self.d[x] def unite(self, x, y): x, y = self.root(x), self.root(y) if ...
N, M, *X = list(map(int, open(0).read().split())) class UnionFind: def __init__(self, n=0): self.d = [-1]*n self.u = n def root(self, x): if self.d[x] < 0: return x self.d[x] = self.root(self.d[x]) return self.d[x] def unite(self, x, y): ...
43
39
858
835
class UnionFind: def __init__(self, n=0): self.d = [-1] * n self.u = n def root(self, x): if self.d[x] < 0: return x self.d[x] = self.root(self.d[x]) return self.d[x] def unite(self, x, y): x, y = self.root(x), self.root(y) if x == y: ...
N, M, *X = list(map(int, open(0).read().split())) class UnionFind: def __init__(self, n=0): self.d = [-1] * n self.u = n def root(self, x): if self.d[x] < 0: return x self.d[x] = self.root(self.d[x]) return self.d[x] def unite(self, x, y): x, y...
false
9.302326
[ "+N, M, *X = list(map(int, open(0).read().split()))", "+", "+", "- self.u -= 1", "+ self.u -= 1", "-N, M, *X = list(map(int, open(0).read().split()))", "-X = tuple(zip(*[iter(X)] * 3))", "-uf = UnionFind(N)", "-for x, y, z in X:", "- uf.unite(x - 1, y - 1)", "-print((uf.num_unio...
false
0.037319
0.037029
1.00785
[ "s845444504", "s928097080" ]
u553605501
p02614
python
s798579324
s576691531
191
159
74,880
76,884
Accepted
Accepted
16.75
import itertools import copy h,w,k=list(map(int,input().split())) c=[list(eval(input())) for _ in range(h)] num=0 for i in range(h): for j in range(w): if c[i][j]=='#': num+=1 ans=0 for a in range(1,h+1): for b in range(1,w+1): l=list(range(1,h+1)) m=list(range(...
import copy h,w,k = list(map(int,input().split())) c=[list(eval(input())) for _ in range(h)] ans = 0 for row in range(1<<h): for col in range(1<<w): d = copy.deepcopy(c) sum = 0 for i in range(h): if row & (1<<i): for j in range(w): ...
57
28
1,720
643
import itertools import copy h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] num = 0 for i in range(h): for j in range(w): if c[i][j] == "#": num += 1 ans = 0 for a in range(1, h + 1): for b in range(1, w + 1): l = list(range(1, h + 1)) ...
import copy h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for row in range(1 << h): for col in range(1 << w): d = copy.deepcopy(c) sum = 0 for i in range(h): if row & (1 << i): for j in range(w): ...
false
50.877193
[ "-import itertools", "-num = 0", "-for i in range(h):", "- for j in range(w):", "- if c[i][j] == \"#\":", "- num += 1", "-for a in range(1, h + 1):", "- for b in range(1, w + 1):", "- l = list(range(1, h + 1))", "- m = list(range(1, w + 1))", "- for p...
false
0.048235
0.047758
1.009988
[ "s798579324", "s576691531" ]
u623231048
p03166
python
s177838628
s672197414
1,113
975
33,660
22,704
Accepted
Accepted
12.4
import sys input = sys.stdin.readline n,m = list(map(int,input().split())) edges = [[] for _ in range(n)] edges2 = [[] for _ in range(n)] dis = [0] * n for _ in range(m): x,y = list(map(int,input().split())) edges[y-1].append(x-1) edges2[x-1].append(y-1) dis[x-1] = -1 q = [] for i ...
import sys input = sys.stdin.readline n,m = list(map(int,input().split())) edges = [[] for _ in range(n)] edges2 = [0] * n dis = [0] * n for _ in range(m): x,y = list(map(int,input().split())) edges[y-1].append(x-1) edges2[x-1] += 1 dis[x-1] = -1 q = [] for i in range(n): if d...
30
30
559
533
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) edges = [[] for _ in range(n)] edges2 = [[] for _ in range(n)] dis = [0] * n for _ in range(m): x, y = list(map(int, input().split())) edges[y - 1].append(x - 1) edges2[x - 1].append(y - 1) dis[x - 1] = -1 q = [] for i in rang...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) edges = [[] for _ in range(n)] edges2 = [0] * n dis = [0] * n for _ in range(m): x, y = list(map(int, input().split())) edges[y - 1].append(x - 1) edges2[x - 1] += 1 dis[x - 1] = -1 q = [] for i in range(n): if dis[i] == 0...
false
0
[ "-edges2 = [[] for _ in range(n)]", "+edges2 = [0] * n", "- edges2[x - 1].append(y - 1)", "+ edges2[x - 1] += 1", "- edges2[i].remove(l)", "- if not edges2[i]:", "+ edges2[i] -= 1", "+ if edges2[i] == 0:" ]
false
0.037923
0.038128
0.99463
[ "s177838628", "s672197414" ]
u191874006
p02841
python
s452945333
s499374400
173
71
38,384
65,508
Accepted
Accepted
58.96
#!/usr/bin/env python3 #三井住友信託銀行プログラミングコンテスト2019 A import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(1000000) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collec...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
26
25
662
637
#!/usr/bin/env python3 # 三井住友信託銀行プログラミングコンテスト2019 A import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(1000000) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections imp...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
false
3.846154
[ "-# 三井住友信託銀行プログラミングコンテスト2019 A", "-sys.setrecursionlimit(1000000)", "+sys.setrecursionlimit(2147483647)", "-if m1 == m2:", "+if m1 != m2:", "+ print((1))", "+else:", "-else:", "- print((1))" ]
false
0.068838
0.046307
1.486548
[ "s452945333", "s499374400" ]
u017415492
p02873
python
s510069532
s143925478
423
279
23,336
29,168
Accepted
Accepted
34.04
s=eval(input()) d=[0]*(len(s)+1) Z=[] scount=0 ans=0 if s[0]=="<": d[1]=d[0]+1 for i in range(1,len(s)-1): if s[i]==">": d[i+1]=0 scount+=1 Q=scount X=i if s[i-1]=="<": Z.append(i) elif s[i]=="<": d[i+1]=d[i]+1 for j in range(scount): d[i-scount+j]=(scou...
s=eval(input()) n=len(s) ans=[0]*(n+1) for i in range(0,n): if s[i]=='<': ans[i+1]=ans[i]+1 for i in range(n-1,-1,-1): if s[i]=='>': ans[i]=max(ans[i+1]+1,ans[i]) print((sum(ans)))
41
11
641
197
s = eval(input()) d = [0] * (len(s) + 1) Z = [] scount = 0 ans = 0 if s[0] == "<": d[1] = d[0] + 1 for i in range(1, len(s) - 1): if s[i] == ">": d[i + 1] = 0 scount += 1 Q = scount X = i if s[i - 1] == "<": Z.append(i) elif s[i] == "<": d[i + 1] =...
s = eval(input()) n = len(s) ans = [0] * (n + 1) for i in range(0, n): if s[i] == "<": ans[i + 1] = ans[i] + 1 for i in range(n - 1, -1, -1): if s[i] == ">": ans[i] = max(ans[i + 1] + 1, ans[i]) print((sum(ans)))
false
73.170732
[ "-d = [0] * (len(s) + 1)", "-Z = []", "-scount = 0", "-ans = 0", "-if s[0] == \"<\":", "- d[1] = d[0] + 1", "-for i in range(1, len(s) - 1):", "+n = len(s)", "+ans = [0] * (n + 1)", "+for i in range(0, n):", "+ if s[i] == \"<\":", "+ ans[i + 1] = ans[i] + 1", "+for i in range(n ...
false
0.04583
0.039561
1.158464
[ "s510069532", "s143925478" ]
u633068244
p00631
python
s230676743
s418442068
130
70
4,236
4,244
Accepted
Accepted
46.15
def S(i,x,y): d=2*max(x,y)-sum(a) return d if d>=0 else min(S(i+1,x+a[i],y),S(i+1,x,y+a[i])) while 1: if eval(input())==0:break a=sorted(map(int,input().split()))[::-1] print(S(1,a[0],0))
def S(i,x,y): if 2*x >= A: return 2*x-A if 2*y >= A: return 2*y-A return min(S(i+1,x+a[i],y),S(i+1,x,y+a[i])) while 1: n = eval(input()) if n == 0: break a = sorted(map(int,input().split()))[::-1] A = sum(a) print(S(1,a[0],0))
7
10
195
240
def S(i, x, y): d = 2 * max(x, y) - sum(a) return d if d >= 0 else min(S(i + 1, x + a[i], y), S(i + 1, x, y + a[i])) while 1: if eval(input()) == 0: break a = sorted(map(int, input().split()))[::-1] print(S(1, a[0], 0))
def S(i, x, y): if 2 * x >= A: return 2 * x - A if 2 * y >= A: return 2 * y - A return min(S(i + 1, x + a[i], y), S(i + 1, x, y + a[i])) while 1: n = eval(input()) if n == 0: break a = sorted(map(int, input().split()))[::-1] A = sum(a) print(S(1, a[0], 0))
false
30
[ "- d = 2 * max(x, y) - sum(a)", "- return d if d >= 0 else min(S(i + 1, x + a[i], y), S(i + 1, x, y + a[i]))", "+ if 2 * x >= A:", "+ return 2 * x - A", "+ if 2 * y >= A:", "+ return 2 * y - A", "+ return min(S(i + 1, x + a[i], y), S(i + 1, x, y + a[i]))", "- if eval(in...
false
0.044013
0.037963
1.159363
[ "s230676743", "s418442068" ]
u191874006
p02607
python
s488226737
s509565919
126
65
65,356
61,816
Accepted
Accepted
48.41
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in range(0, n, 2): if a[i] % 2: ans += 1 print(ans)
27
9
681
162
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in range(0, n, 2): if a[i] % 2: ans += 1 print(ans)
false
66.666667
[ "-import sys", "-import math", "-from bisect import bisect_right as br", "-from bisect import bisect_left as bl", "-", "-sys.setrecursionlimit(2147483647)", "-from heapq import heappush, heappop, heappushpop", "-from collections import defaultdict", "-from itertools import accumulate", "-from coll...
false
0.045448
0.045755
0.993277
[ "s488226737", "s509565919" ]
u242580186
p02640
python
s204709103
s215174528
30
27
9,084
9,184
Accepted
Accepted
10
import sys import time st = time.perf_counter() # ------------------------------ x, y = map(int, input().split()) ok = False for i in range(x + 1): if i * 4 + (x - i) * 2 == y: ok = True break if ok: print('Yes') else: print('No') # ------------------------------ ed = time...
import sys import time import math def inpl(): return list(map(int, input().split())) st = time.perf_counter() # ------------------------------ X, Y = map(int, input().split()) for i in range(X+1): if i*4 + (X-i)*2 == Y: print('Yes') sys.exit() print('No') # ------------------------------ ed ...
19
18
376
382
import sys import time st = time.perf_counter() # ------------------------------ x, y = map(int, input().split()) ok = False for i in range(x + 1): if i * 4 + (x - i) * 2 == y: ok = True break if ok: print("Yes") else: print("No") # ------------------------------ ed = time.perf_counter() pr...
import sys import time import math def inpl(): return list(map(int, input().split())) st = time.perf_counter() # ------------------------------ X, Y = map(int, input().split()) for i in range(X + 1): if i * 4 + (X - i) * 2 == Y: print("Yes") sys.exit() print("No") # -------------------------...
false
5.263158
[ "+import math", "+", "+", "+def inpl():", "+ return list(map(int, input().split()))", "+", "-x, y = map(int, input().split())", "-ok = False", "-for i in range(x + 1):", "- if i * 4 + (x - i) * 2 == y:", "- ok = True", "- break", "-if ok:", "- print(\"Yes\")", "-el...
false
0.038557
0.04378
0.880696
[ "s204709103", "s215174528" ]
u357751375
p03474
python
s555254600
s763533589
30
27
9,132
9,116
Accepted
Accepted
10
a,b = list(map(int,input().split())) s = eval(input()) for i in range(a): if s[i] == '-': print('No') exit(0) if s[a] != '-': print('No') exit(0) for i in range(a+1,a+b): if s[i] == '-': print('No') exit(0) print('Yes')
a,b = list(map(int,input().split())) s = eval(input()) if '-' in s[:a]: print('No') elif s[a] != '-': print('No') elif '-' in s[a+1:]: print('No') else: print('Yes')
17
10
274
178
a, b = list(map(int, input().split())) s = eval(input()) for i in range(a): if s[i] == "-": print("No") exit(0) if s[a] != "-": print("No") exit(0) for i in range(a + 1, a + b): if s[i] == "-": print("No") exit(0) print("Yes")
a, b = list(map(int, input().split())) s = eval(input()) if "-" in s[:a]: print("No") elif s[a] != "-": print("No") elif "-" in s[a + 1 :]: print("No") else: print("Yes")
false
41.176471
[ "-for i in range(a):", "- if s[i] == \"-\":", "- print(\"No\")", "- exit(0)", "-if s[a] != \"-\":", "+if \"-\" in s[:a]:", "- exit(0)", "-for i in range(a + 1, a + b):", "- if s[i] == \"-\":", "- print(\"No\")", "- exit(0)", "-print(\"Yes\")", "+elif s[a]...
false
0.038226
0.037779
1.011833
[ "s555254600", "s763533589" ]
u695261159
p03161
python
s732052895
s152474078
1,934
389
13,980
84,748
Accepted
Accepted
79.89
def main(): N,K=list(map(int, input().split())) A = list(map(int, input().split())) dp = [float('inf')] * N dp[0] = 0 for i in range(1,len(A)): jmp = max(0,i-K) dp[i] = min([dp[j]+abs(A[i]-A[j]) for j in range(jmp, i)]) print((dp[N-1])) main()
N,K=list(map(int, input().split())) A = list(map(int, input().split())) INF = 10**9 dp = [INF]*N for i in range(len(A)): if i == 0: dp[0] = 0 elif i == 1: dp[1] = abs(A[1]-A[0]) else: jmp = min(i,K) for j in range(1,jmp+1): dp[i] = min(dp[i], dp[...
12
17
288
366
def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) dp = [float("inf")] * N dp[0] = 0 for i in range(1, len(A)): jmp = max(0, i - K) dp[i] = min([dp[j] + abs(A[i] - A[j]) for j in range(jmp, i)]) print((dp[N - 1])) main()
N, K = list(map(int, input().split())) A = list(map(int, input().split())) INF = 10**9 dp = [INF] * N for i in range(len(A)): if i == 0: dp[0] = 0 elif i == 1: dp[1] = abs(A[1] - A[0]) else: jmp = min(i, K) for j in range(1, jmp + 1): dp[i] = min(dp[i], dp[i - j] ...
false
29.411765
[ "-def main():", "- N, K = list(map(int, input().split()))", "- A = list(map(int, input().split()))", "- dp = [float(\"inf\")] * N", "- dp[0] = 0", "- for i in range(1, len(A)):", "- jmp = max(0, i - K)", "- dp[i] = min([dp[j] + abs(A[i] - A[j]) for j in range(jmp, i)])", ...
false
0.06117
0.061113
1.000931
[ "s732052895", "s152474078" ]
u426764965
p03557
python
s067604184
s756592679
323
242
24,932
20,468
Accepted
Accepted
25.08
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def abc077_c(): N = int(readline()) A = list(map(int, readline().split())) B = list(map(int, readline().split())) C = list(map(int, readline().split())) A.sort() B.sort...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np def abc077_c(): ''' maspyさんお手本 ''' N = int(readline()) A = np.array(readline().split(), dtype=np.int64) B = np.array(readline().split(), dtype=np.int64) ...
36
30
870
767
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def abc077_c(): N = int(readline()) A = list(map(int, readline().split())) B = list(map(int, readline().split())) C = list(map(int, readline().split())) A.sort() B.sort() C....
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np def abc077_c(): """maspyさんお手本""" N = int(readline()) A = np.array(readline().split(), dtype=np.int64) B = np.array(readline().split(), dtype=np.int64) C = np.arra...
false
16.666667
[ "+import numpy as np", "+ \"\"\"maspyさんお手本\"\"\"", "- A = list(map(int, readline().split()))", "- B = list(map(int, readline().split()))", "- C = list(map(int, readline().split()))", "+ A = np.array(readline().split(), dtype=np.int64)", "+ B = np.array(readline().split(), dtype=np.int6...
false
0.04351
0.421179
0.103306
[ "s067604184", "s756592679" ]
u729133443
p03102
python
s931686308
s142299279
165
21
38,384
3,188
Accepted
Accepted
87.27
I=lambda:list(map(int,input().split()));n,m,c=I();*b,=I();print((sum(-c<sum(x*y for x,y in zip(I(),b))for _ in[0]*n)))
I=lambda:list(map(int,input().split()));n,m,c=I();*b,=I();print((eval('+(-c<sum(x*y for x,y in zip(I(),b)))'*n)))
1
1
110
105
I = lambda: list(map(int, input().split())) n, m, c = I() (*b,) = I() print((sum(-c < sum(x * y for x, y in zip(I(), b)) for _ in [0] * n)))
I = lambda: list(map(int, input().split())) n, m, c = I() (*b,) = I() print((eval("+(-c<sum(x*y for x,y in zip(I(),b)))" * n)))
false
0
[ "-print((sum(-c < sum(x * y for x, y in zip(I(), b)) for _ in [0] * n)))", "+print((eval(\"+(-c<sum(x*y for x,y in zip(I(),b)))\" * n)))" ]
false
0.035203
0.041521
0.847834
[ "s931686308", "s142299279" ]
u528470578
p03164
python
s739748828
s523969938
476
418
120,556
119,916
Accepted
Accepted
12.18
# Educational DP Contest E-knapsack 2 N,W=list(map(int,input().split())) items=[] for _ in range(N): w,v=list(map(int,input().strip().split())) items+=[(w,v)] MAX_val=N*10**3+1 # 最大の価値 dp=[[10**9+1]*MAX_val for i in range(N)] # 最大の価値でinitialize(価値の表) dp[0][items[0][1]]=items[0][0] # 最初の品物の価値の場...
N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(N)] dp = [] valmax = int(1e5) INF = int(1e10) for _ in range(N+1): dp.append([INF] * (valmax+1)) dp[0][0] = 0 for i in range(N): for v in range(valmax+1): dp[i+1][v] = min(dp[i][v], dp[i][v - wv[i][...
27
21
819
467
# Educational DP Contest E-knapsack 2 N, W = list(map(int, input().split())) items = [] for _ in range(N): w, v = list(map(int, input().strip().split())) items += [(w, v)] MAX_val = N * 10**3 + 1 # 最大の価値 dp = [[10**9 + 1] * MAX_val for i in range(N)] # 最大の価値でinitialize(価値の表) dp[0][items[0][1]] = items[0][0] ...
N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(N)] dp = [] valmax = int(1e5) INF = int(1e10) for _ in range(N + 1): dp.append([INF] * (valmax + 1)) dp[0][0] = 0 for i in range(N): for v in range(valmax + 1): dp[i + 1][v] = min(dp[i][v], dp[i][v - wv[i][1]] + ...
false
22.222222
[ "-# Educational DP Contest E-knapsack 2", "-items = []", "-for _ in range(N):", "- w, v = list(map(int, input().strip().split()))", "- items += [(w, v)]", "-MAX_val = N * 10**3 + 1 # 最大の価値", "-dp = [[10**9 + 1] * MAX_val for i in range(N)] # 最大の価値でinitialize(価値の表)", "-dp[0][items[0][1]] = item...
false
0.133101
0.721082
0.184585
[ "s739748828", "s523969938" ]
u511965386
p02815
python
s899164897
s116499174
638
322
87,628
87,500
Accepted
Accepted
49.53
N = int(eval(input())) C = [int(i) for i in input().split()] mod = 10 ** 9 + 7 C.sort() ret = 0 for i in range(N) : rest = N - i - 1 if rest == 0 : ret += C[i] * pow(4, i, mod) * pow(2, N - i, mod) * pow(2, rest, mod) % mod else : ret += C[i] * pow(4, i, mod) * pow(2, N - i, mod) * (rest + 2...
N = int(eval(input())) C = [int(i) for i in input().split()] mod = 10 ** 9 + 7 C.sort() ret = 0 P = pow(4, N - 1, mod) for i in range(N) : ret += C[i] * P * (N - i + 1) % mod ret %= mod print(ret)
16
13
373
209
N = int(eval(input())) C = [int(i) for i in input().split()] mod = 10**9 + 7 C.sort() ret = 0 for i in range(N): rest = N - i - 1 if rest == 0: ret += C[i] * pow(4, i, mod) * pow(2, N - i, mod) * pow(2, rest, mod) % mod else: ret += ( C[i] * pow(4, i, mod) ...
N = int(eval(input())) C = [int(i) for i in input().split()] mod = 10**9 + 7 C.sort() ret = 0 P = pow(4, N - 1, mod) for i in range(N): ret += C[i] * P * (N - i + 1) % mod ret %= mod print(ret)
false
18.75
[ "+P = pow(4, N - 1, mod)", "- rest = N - i - 1", "- if rest == 0:", "- ret += C[i] * pow(4, i, mod) * pow(2, N - i, mod) * pow(2, rest, mod) % mod", "- else:", "- ret += (", "- C[i]", "- * pow(4, i, mod)", "- * pow(2, N - i, mod)", "- ...
false
0.052806
0.036287
1.455255
[ "s899164897", "s116499174" ]
u189487046
p03627
python
s348978751
s094800572
87
69
18,600
18,600
Accepted
Accepted
20.69
import collections N = int(eval(input())) A = list(map(int, input().split())) CA = collections.Counter(A) max1 = 0 max2 = 0 for item in list(CA.items()): if item[1] >= 2 and item[0] > max1: if item[1] >= 4: max1 = item[0] max2 = item[0] else: max...
import collections N = int(eval(input())) A = list(map(int, input().split())) c = collections.Counter(A) max_1 = 0 max_2 = 0 for k, v in list(c.items()): if v >= 2: if k > max_1: if v >= 4: max_1, max_2 = k, k else: max_1, max_2 = k, ma...
20
19
430
382
import collections N = int(eval(input())) A = list(map(int, input().split())) CA = collections.Counter(A) max1 = 0 max2 = 0 for item in list(CA.items()): if item[1] >= 2 and item[0] > max1: if item[1] >= 4: max1 = item[0] max2 = item[0] else: max2 = max1 ...
import collections N = int(eval(input())) A = list(map(int, input().split())) c = collections.Counter(A) max_1 = 0 max_2 = 0 for k, v in list(c.items()): if v >= 2: if k > max_1: if v >= 4: max_1, max_2 = k, k else: max_1, max_2 = k, max_1 eli...
false
5
[ "-CA = collections.Counter(A)", "-max1 = 0", "-max2 = 0", "-for item in list(CA.items()):", "- if item[1] >= 2 and item[0] > max1:", "- if item[1] >= 4:", "- max1 = item[0]", "- max2 = item[0]", "- else:", "- max2 = max1", "- max1 = it...
false
0.044162
0.109844
0.40204
[ "s348978751", "s094800572" ]
u968166680
p02888
python
s007481159
s551519811
195
83
74,008
73,976
Accepted
Accepted
57.44
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, *L = list(map(int, read().split())) L.sort() max_L = max(L) C = [0] * (max_...
import sys from itertools import accumulate read = sys.stdin.buffer.read def main(): N, *L = list(map(int, read().split())) L.sort() max_L = L[-1] C = [0] * (max_L + 1) for l in L: C[l] += 1 C = list(accumulate(C)) ans = 0 for i, a in enumerate(L): ...
37
31
686
561
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, *L = list(map(int, read().split())) L.sort() max_L = max(L) C = [0] * (max_L + 1) for l in L: ...
import sys from itertools import accumulate read = sys.stdin.buffer.read def main(): N, *L = list(map(int, read().split())) L.sort() max_L = L[-1] C = [0] * (max_L + 1) for l in L: C[l] += 1 C = list(accumulate(C)) ans = 0 for i, a in enumerate(L): for j, b in enumerat...
false
16.216216
[ "-read = sys.stdin.read", "-readline = sys.stdin.readline", "-readlines = sys.stdin.readlines", "-sys.setrecursionlimit(10**9)", "-INF = 1 << 60", "-MOD = 1000000007", "+read = sys.stdin.buffer.read", "- max_L = max(L)", "+ max_L = L[-1]" ]
false
0.036952
0.055395
0.667061
[ "s007481159", "s551519811" ]
u504256702
p02887
python
s156390904
s663562271
57
44
4,652
3,316
Accepted
Accepted
22.81
N = int(eval(input())) S = list(eval(input())) prior = "" fusion = "" for i in range(N): if prior != S[i]: fusion += S[i] prior = S[i] #print(prior, end="") print((len(list(fusion))))
N = int(eval(input())) S = eval(input()) ans = 1 for i in range(1, N): if S[i - 1] != S[i]: ans += 1 print(ans)
11
7
190
111
N = int(eval(input())) S = list(eval(input())) prior = "" fusion = "" for i in range(N): if prior != S[i]: fusion += S[i] prior = S[i] # print(prior, end="") print((len(list(fusion))))
N = int(eval(input())) S = eval(input()) ans = 1 for i in range(1, N): if S[i - 1] != S[i]: ans += 1 print(ans)
false
36.363636
[ "-S = list(eval(input()))", "-prior = \"\"", "-fusion = \"\"", "-for i in range(N):", "- if prior != S[i]:", "- fusion += S[i]", "- prior = S[i]", "- # print(prior, end=\"\")", "-print((len(list(fusion))))", "+S = eval(input())", "+ans = 1", "+for i in range(1, N):", "+ if...
false
0.038439
0.084175
0.456659
[ "s156390904", "s663562271" ]
u995004106
p03525
python
s627110221
s723178277
442
72
217,964
71,148
Accepted
Accepted
83.71
import collections from collections import deque N=int(eval(input())) D=list(map(int,input().split())) c=collections.Counter(D) count0=0 count12=0 zeroflag=0 l=[] if c[12]>0: count12=c[12] if c[0]>0: count0=c[0]+1 #print(l,count0,count12) #print(n) allmax=0 q=deque() l=[] if (count0==0)a...
import collections from collections import deque N=int(eval(input())) D=list(map(int,input().split())) c=collections.Counter(D) count0=0 count12=0 zeroflag=0 l=[] if c[12]>0: count12=c[12] if c[0]>0: count0=c[0]+1 #print(l,count0,count12) #print(n) allmax=0 q=deque() l=[] if (count0==0)a...
120
92
2,516
1,952
import collections from collections import deque N = int(eval(input())) D = list(map(int, input().split())) c = collections.Counter(D) count0 = 0 count12 = 0 zeroflag = 0 l = [] if c[12] > 0: count12 = c[12] if c[0] > 0: count0 = c[0] + 1 # print(l,count0,count12) # print(n) allmax = 0 q = deque() l = [] if (c...
import collections from collections import deque N = int(eval(input())) D = list(map(int, input().split())) c = collections.Counter(D) count0 = 0 count12 = 0 zeroflag = 0 l = [] if c[12] > 0: count12 = c[12] if c[0] > 0: count0 = c[0] + 1 # print(l,count0,count12) # print(n) allmax = 0 q = deque() l = [] if (c...
false
23.333333
[ "- q.append([24])", "-elif (count0 == 1) and (zeroflag == 0):", "- q.append([0, 0])", "- q.append([0, 24])", "- q.append([24, 24])", "- buf1.extend(l)", "- buf1.extend([i, i])", "- buf2.extend(l)", "- buf2.extend([24 - i, 24 - i...
false
0.041714
0.037234
1.120334
[ "s627110221", "s723178277" ]
u981931040
p03262
python
s568912323
s427040499
185
104
14,252
14,252
Accepted
Accepted
43.78
import bisect def gcd(x , y): max_val = max(x , y) min_val = min(x , y) while min_val != 0: max_val , min_val = min_val , max_val % min_val return max_val N , X = list(map(int,input().split())) x = list(map(int,input().split())) x.sort() split_idx = bisect.bisect_left(x , X) BeforeLis...
def gcd(a, b): while b != 0: a, b = b, a % b return a N, X = list(map(int, input().split())) x = list(map(int, input().split())) x.insert(0, X) distance = [] for i in range(1, len(x)): distance.append(abs(x[i] - x[i - 1])) ans = distance[0] for i in range(1, len(distance)): a...
29
18
717
352
import bisect def gcd(x, y): max_val = max(x, y) min_val = min(x, y) while min_val != 0: max_val, min_val = min_val, max_val % min_val return max_val N, X = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() split_idx = bisect.bisect_left(x, X) BeforeList = x[:split...
def gcd(a, b): while b != 0: a, b = b, a % b return a N, X = list(map(int, input().split())) x = list(map(int, input().split())) x.insert(0, X) distance = [] for i in range(1, len(x)): distance.append(abs(x[i] - x[i - 1])) ans = distance[0] for i in range(1, len(distance)): ans = gcd(distance[...
false
37.931034
[ "-import bisect", "-", "-", "-def gcd(x, y):", "- max_val = max(x, y)", "- min_val = min(x, y)", "- while min_val != 0:", "- max_val, min_val = min_val, max_val % min_val", "- return max_val", "+def gcd(a, b):", "+ while b != 0:", "+ a, b = b, a % b", "+ retur...
false
0.036184
0.07237
0.499992
[ "s568912323", "s427040499" ]
u475675023
p02787
python
s365385832
s173524162
1,884
76
3,832
30,180
Accepted
Accepted
95.97
h,n=list(map(int,input().split())) ab=[list(map(int,input().split())) for _ in range(n)] mx=max(a for a,b in ab) dp=[10**10]*(h+1+mx) dp[0]=0 for i in range(1,h+1+mx): dp[i]=min(dp[i-a]+b for a,b in ab) print((min(dp[h:])))
from functools import lru_cache import sys sys.setrecursionlimit(10 ** 8) h,n=list(map(int,input().split())) ab=[tuple(map(int,input().split())) for _ in range(n)] ab.sort(key=lambda abi:(abi[1]/abi[0],abi[0])) @lru_cache(maxsize=None) def dp(i): if i<=0: return 0 else: ans=float('inf') fo...
8
22
224
443
h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] mx = max(a for a, b in ab) dp = [10**10] * (h + 1 + mx) dp[0] = 0 for i in range(1, h + 1 + mx): dp[i] = min(dp[i - a] + b for a, b in ab) print((min(dp[h:])))
from functools import lru_cache import sys sys.setrecursionlimit(10**8) h, n = list(map(int, input().split())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda abi: (abi[1] / abi[0], abi[0])) @lru_cache(maxsize=None) def dp(i): if i <= 0: return 0 else: ans = float...
false
63.636364
[ "+from functools import lru_cache", "+import sys", "+", "+sys.setrecursionlimit(10**8)", "-ab = [list(map(int, input().split())) for _ in range(n)]", "-mx = max(a for a, b in ab)", "-dp = [10**10] * (h + 1 + mx)", "-dp[0] = 0", "-for i in range(1, h + 1 + mx):", "- dp[i] = min(dp[i - a] + b for...
false
0.192903
0.037217
5.183166
[ "s365385832", "s173524162" ]
u700929101
p02923
python
s381466011
s626224047
81
69
14,252
15,020
Accepted
Accepted
14.81
n = int(eval(input())) h = list(map(int, input().split())) answer = 0#これなに m = 0#カウントするやつやね for i in range(n-1): if h[i] >= h[i+1]: m += 1 else: answer = max(answer,m) m = 0 answer = max(answer,m) print(answer)
n = int(eval(input())) h = list(map(int,input().split(" "))) plsl = [] plsn = 0 for i in range(n-1): if h[i]>= h[i+1]: plsn += 1 else: #i<i+1の時 plsl.append(plsn) plsn = 0 plsl.append(plsn) plsl.sort(reverse = True) print((plsl[0]))
12
13
248
268
n = int(eval(input())) h = list(map(int, input().split())) answer = 0 # これなに m = 0 # カウントするやつやね for i in range(n - 1): if h[i] >= h[i + 1]: m += 1 else: answer = max(answer, m) m = 0 answer = max(answer, m) print(answer)
n = int(eval(input())) h = list(map(int, input().split(" "))) plsl = [] plsn = 0 for i in range(n - 1): if h[i] >= h[i + 1]: plsn += 1 else: # i<i+1の時 plsl.append(plsn) plsn = 0 plsl.append(plsn) plsl.sort(reverse=True) print((plsl[0]))
false
7.692308
[ "-h = list(map(int, input().split()))", "-answer = 0 # これなに", "-m = 0 # カウントするやつやね", "+h = list(map(int, input().split(\" \")))", "+plsl = []", "+plsn = 0", "- m += 1", "- else:", "- answer = max(answer, m)", "- m = 0", "-answer = max(answer, m)", "-print(answer)", ...
false
0.040763
0.08179
0.498387
[ "s381466011", "s626224047" ]
u254871849
p03945
python
s324588928
s886459783
38
27
3,316
3,188
Accepted
Accepted
28.95
import sys s = sys.stdin.readline().rstrip() def main(): cnt = 0 for i in range(len(s) - 1): if s[i] != s[i+1]: cnt += 1 return cnt if __name__ == '__main__': ans = main() print(ans)
import sys s = sys.stdin.readline().rstrip() def main(): prev = '$' cnt = -1 for c in s: cnt += c != prev prev = c print(cnt) if __name__ == '__main__': main()
14
14
238
212
import sys s = sys.stdin.readline().rstrip() def main(): cnt = 0 for i in range(len(s) - 1): if s[i] != s[i + 1]: cnt += 1 return cnt if __name__ == "__main__": ans = main() print(ans)
import sys s = sys.stdin.readline().rstrip() def main(): prev = "$" cnt = -1 for c in s: cnt += c != prev prev = c print(cnt) if __name__ == "__main__": main()
false
0
[ "- cnt = 0", "- for i in range(len(s) - 1):", "- if s[i] != s[i + 1]:", "- cnt += 1", "- return cnt", "+ prev = \"$\"", "+ cnt = -1", "+ for c in s:", "+ cnt += c != prev", "+ prev = c", "+ print(cnt)", "- ans = main()", "- print(ans...
false
0.043035
0.047035
0.914967
[ "s324588928", "s886459783" ]
u367701763
p03148
python
s454637950
s720232013
236
153
90,532
80,248
Accepted
Accepted
35.17
import sys from heapq import * input = sys.stdin.readline N, K = list(map(int, input().split())) D, H, var, res = [], [], set(), 0 for _ in range(N): t,d = list(map(int, input().split())) D.append((t,d)) D.sort(key=lambda x: x[1], reverse=True) for t, d in D[:K]: if t not in var: var.add(t) e...
import sys from heapq import * input = sys.stdin.readline N, K = list(map(int, input().split())) D, H, var, res, L = [], [], set(), 0, N.bit_length()+2 for _ in range(N): t,d = list(map(int, input().split())) D.append((d<<L)+t) D.sort(reverse=True) for z in D[:K]: d, t = z>>L, z%(1<<L) if t n...
23
25
538
590
import sys from heapq import * input = sys.stdin.readline N, K = list(map(int, input().split())) D, H, var, res = [], [], set(), 0 for _ in range(N): t, d = list(map(int, input().split())) D.append((t, d)) D.sort(key=lambda x: x[1], reverse=True) for t, d in D[:K]: if t not in var: var.add(t) e...
import sys from heapq import * input = sys.stdin.readline N, K = list(map(int, input().split())) D, H, var, res, L = [], [], set(), 0, N.bit_length() + 2 for _ in range(N): t, d = list(map(int, input().split())) D.append((d << L) + t) D.sort(reverse=True) for z in D[:K]: d, t = z >> L, z % (1 << L) if ...
false
8
[ "-D, H, var, res = [], [], set(), 0", "+D, H, var, res, L = [], [], set(), 0, N.bit_length() + 2", "- D.append((t, d))", "-D.sort(key=lambda x: x[1], reverse=True)", "-for t, d in D[:K]:", "+ D.append((d << L) + t)", "+D.sort(reverse=True)", "+for z in D[:K]:", "+ d, t = z >> L, z % (1 << L...
false
0.063671
0.080818
0.787835
[ "s454637950", "s720232013" ]
u010110540
p03732
python
s057753748
s148718310
1,046
163
3,444
20,760
Accepted
Accepted
84.42
from collections import Counter from itertools import product N, W = list(map(int, input().split())) items = {} weight = [] for i in range(N): w, v = list(map(int, input().split())) weight.append(w) if items.get(w, None) is None: items[w] = [] items[w].append(v) items[w]...
N, W = list(map(int, input().split())) w, v = [], [] for _ in range(N): a, b = list(map(int, input().split())) w.append(a) v.append(b) memo = {} def nap(i, j): if i == N: return 0 if (i, j) in memo: return memo[i, j] elif j < w[i]: temp = nap(i+...
39
25
882
458
from collections import Counter from itertools import product N, W = list(map(int, input().split())) items = {} weight = [] for i in range(N): w, v = list(map(int, input().split())) weight.append(w) if items.get(w, None) is None: items[w] = [] items[w].append(v) items[w] = sorted(items[w], ...
N, W = list(map(int, input().split())) w, v = [], [] for _ in range(N): a, b = list(map(int, input().split())) w.append(a) v.append(b) memo = {} def nap(i, j): if i == N: return 0 if (i, j) in memo: return memo[i, j] elif j < w[i]: temp = nap(i + 1, j) else: ...
false
35.897436
[ "-from collections import Counter", "-from itertools import product", "+N, W = list(map(int, input().split()))", "+w, v = [], []", "+for _ in range(N):", "+ a, b = list(map(int, input().split()))", "+ w.append(a)", "+ v.append(b)", "+memo = {}", "-N, W = list(map(int, input().split()))", ...
false
0.040886
0.03899
1.048636
[ "s057753748", "s148718310" ]
u697690147
p03151
python
s212293727
s742898493
164
118
24,256
24,240
Accepted
Accepted
28.05
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) surplus = [] short = [] for i in range(n): if a[i] > b[i]: surplus.append(a[i]-b[i]) elif b[i] > a[i]: short.append(b[i]-a[i]) surplus = sorted(surplus) taken = False cnt = 0 for i i...
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) surplus = [] short = 0 cnt = 0 for i in range(n): if a[i] > b[i]: surplus.append(a[i]-b[i]) elif b[i] > a[i]: short += b[i]-a[i] cnt += 1 surplus = sorted(surplus) s = 0 w...
38
27
734
445
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) surplus = [] short = [] for i in range(n): if a[i] > b[i]: surplus.append(a[i] - b[i]) elif b[i] > a[i]: short.append(b[i] - a[i]) surplus = sorted(surplus) taken = False cnt = 0 for i in range(len(sho...
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) surplus = [] short = 0 cnt = 0 for i in range(n): if a[i] > b[i]: surplus.append(a[i] - b[i]) elif b[i] > a[i]: short += b[i] - a[i] cnt += 1 surplus = sorted(surplus) s = 0 while s < short: ...
false
28.947368
[ "-short = []", "+short = 0", "+cnt = 0", "- short.append(b[i] - a[i])", "+ short += b[i] - a[i]", "+ cnt += 1", "-taken = False", "-cnt = 0", "-for i in range(len(short)):", "- cost = short.pop()", "+s = 0", "+while s < short:", "+ if len(surplus) == 0:", "+ ...
false
0.034698
0.042438
0.817612
[ "s212293727", "s742898493" ]
u661290476
p00009
python
s025906539
s865844259
2,470
1,160
14,944
24,092
Accepted
Accepted
53.04
import sys prime=[False]*1000000 for i in range(2,1001): for j in range(i*2,1000000,i): prime[j]=True for n in sys.stdin: cnt=0 for i in range(2,int(n)+1): if not prime[i]: cnt+=1 print(cnt)
prime=[False]*1000000 for i in range(2,1001): for j in range(i*2,1000000,i): prime[j]=True while True: try: n=int(eval(input())) except: break print((prime[2:n+1].count(False)))
12
12
246
222
import sys prime = [False] * 1000000 for i in range(2, 1001): for j in range(i * 2, 1000000, i): prime[j] = True for n in sys.stdin: cnt = 0 for i in range(2, int(n) + 1): if not prime[i]: cnt += 1 print(cnt)
prime = [False] * 1000000 for i in range(2, 1001): for j in range(i * 2, 1000000, i): prime[j] = True while True: try: n = int(eval(input())) except: break print((prime[2 : n + 1].count(False)))
false
0
[ "-import sys", "-", "-for n in sys.stdin:", "- cnt = 0", "- for i in range(2, int(n) + 1):", "- if not prime[i]:", "- cnt += 1", "- print(cnt)", "+while True:", "+ try:", "+ n = int(eval(input()))", "+ except:", "+ break", "+ print((prime[2...
false
2.819951
1.768683
1.594379
[ "s025906539", "s865844259" ]
u089230684
p03448
python
s162744193
s114719746
46
20
3,064
4,672
Accepted
Accepted
56.52
#!/usr/bin/env python3 from itertools import product import sys def solve(AA: int, BB: int, CC: int, XX: int): print((sum( 1 for a, b, c in product(list(range(AA + 1)), list(range(BB + 1)), list(range(CC + 1))) if a * 500 + b * 100 + c * 50 == XX ))) def main(): ...
a = eval(input()) b = eval(input()) c = eval(input()) x = eval(input()) cache = {} def d(a, b, c, r): if r == 0: return 1 if r < 0: return 0 if (a, b, c, r) in cache: return cache[(a, b, c, r)] s = 0 if a > 0: s += d(a - 1, b, c, r - 500) if b > 0: s += d(0, b - 1, c, r - 100) ...
28
19
681
408
#!/usr/bin/env python3 from itertools import product import sys def solve(AA: int, BB: int, CC: int, XX: int): print( ( sum( 1 for a, b, c in product( list(range(AA + 1)), list(range(BB + 1)), list(range(CC + 1)) ) ...
a = eval(input()) b = eval(input()) c = eval(input()) x = eval(input()) cache = {} def d(a, b, c, r): if r == 0: return 1 if r < 0: return 0 if (a, b, c, r) in cache: return cache[(a, b, c, r)] s = 0 if a > 0: s += d(a - 1, b, c, r - 500) if b > 0: s += ...
false
32.142857
[ "-#!/usr/bin/env python3", "-from itertools import product", "-import sys", "+a = eval(input())", "+b = eval(input())", "+c = eval(input())", "+x = eval(input())", "+cache = {}", "-def solve(AA: int, BB: int, CC: int, XX: int):", "- print(", "- (", "- sum(", "- ...
false
0.079992
0.03627
2.205445
[ "s162744193", "s114719746" ]
u638795007
p03039
python
s242061391
s856618448
285
195
52,788
42,096
Accepted
Accepted
31.58
from operator import mul from functools import reduce def comb2(n,r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under def comb3(n, r): if n - r < r: r = n - r if r == 0: return 1 ...
class combination(): #素数のmod取るときのみ 速い def __init__(self, n, mod): self.n = n self.fac = [1] * (n + 1) self.inv = [1] * (n + 1) for j in range(1, n + 1): self.fac[j] = self.fac[j - 1] * j % mod self.inv[n] = pow(self.fac[n], mod - 2, mod) for...
62
49
1,475
1,270
from operator import mul from functools import reduce def comb2(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under def comb3(n, r): if n - r < r: r = n - r if r == 0: ...
class combination: # 素数のmod取るときのみ 速い def __init__(self, n, mod): self.n = n self.fac = [1] * (n + 1) self.inv = [1] * (n + 1) for j in range(1, n + 1): self.fac[j] = self.fac[j - 1] * j % mod self.inv[n] = pow(self.fac[n], mod - 2, mod) for j in range(...
false
20.967742
[ "-from operator import mul", "-from functools import reduce", "+class combination:", "+ # 素数のmod取るときのみ 速い", "+ def __init__(self, n, mod):", "+ self.n = n", "+ self.fac = [1] * (n + 1)", "+ self.inv = [1] * (n + 1)", "+ for j in range(1, n + 1):", "+ se...
false
0.093219
0.039463
2.362164
[ "s242061391", "s856618448" ]
u241159583
p03545
python
s717148425
s269057223
20
18
3,060
3,060
Accepted
Accepted
10
from itertools import product A, B, C, D = list(eval(input())) l = len(A) for ops in product(["+", "-"], repeat=3): eq = A + ops[0] + B + ops[1] + C + ops[2] + D x = eval(eq) if x == 7: break print((eq + "=7"))
import itertools a,b,c,d = list(eval(input())) for i in itertools.product(["+", "-"], repeat=3): x = a + i[0] + b + i[1] + c + i[2] + d if eval(x) == 7:break print((x+"=7"))
10
6
222
174
from itertools import product A, B, C, D = list(eval(input())) l = len(A) for ops in product(["+", "-"], repeat=3): eq = A + ops[0] + B + ops[1] + C + ops[2] + D x = eval(eq) if x == 7: break print((eq + "=7"))
import itertools a, b, c, d = list(eval(input())) for i in itertools.product(["+", "-"], repeat=3): x = a + i[0] + b + i[1] + c + i[2] + d if eval(x) == 7: break print((x + "=7"))
false
40
[ "-from itertools import product", "+import itertools", "-A, B, C, D = list(eval(input()))", "-l = len(A)", "-for ops in product([\"+\", \"-\"], repeat=3):", "- eq = A + ops[0] + B + ops[1] + C + ops[2] + D", "- x = eval(eq)", "- if x == 7:", "+a, b, c, d = list(eval(input()))", "+for i in...
false
0.037911
0.038848
0.975868
[ "s717148425", "s269057223" ]
u736524428
p02775
python
s368413560
s207464974
1,313
1,128
84,696
5,492
Accepted
Accepted
14.09
N = eval(input()) DP_just = [0] DP_plus = [1] for c in N: d = int(c) last_just = DP_just[-1] last_plus = DP_plus[-1] DP_just.append(min(last_just + d, last_plus + 10 - d)) d += 1 DP_plus.append(min(last_just + d, last_plus + 10 - d)) print((DP_just[-1]))
N = eval(input()) DP_just = 0 DP_plus = 1 for c in N: d = int(c) last_just = DP_just last_plus = DP_plus DP_just = min(last_just + d, last_plus + 10 - d) d += 1 DP_plus = min(last_just + d, last_plus + 10 - d) print(DP_just)
14
14
286
258
N = eval(input()) DP_just = [0] DP_plus = [1] for c in N: d = int(c) last_just = DP_just[-1] last_plus = DP_plus[-1] DP_just.append(min(last_just + d, last_plus + 10 - d)) d += 1 DP_plus.append(min(last_just + d, last_plus + 10 - d)) print((DP_just[-1]))
N = eval(input()) DP_just = 0 DP_plus = 1 for c in N: d = int(c) last_just = DP_just last_plus = DP_plus DP_just = min(last_just + d, last_plus + 10 - d) d += 1 DP_plus = min(last_just + d, last_plus + 10 - d) print(DP_just)
false
0
[ "-DP_just = [0]", "-DP_plus = [1]", "+DP_just = 0", "+DP_plus = 1", "- last_just = DP_just[-1]", "- last_plus = DP_plus[-1]", "- DP_just.append(min(last_just + d, last_plus + 10 - d))", "+ last_just = DP_just", "+ last_plus = DP_plus", "+ DP_just = min(last_just + d, last_plus + ...
false
0.044765
0.045204
0.990296
[ "s368413560", "s207464974" ]
u773265208
p02700
python
s182680656
s876264571
24
19
9,156
9,152
Accepted
Accepted
20.83
import math a,b,c,d = list(map(int,input().split())) ans1 = math.ceil(a / d) ans2 = math.ceil(c / b) if ans1 < ans2: print('No') else: print('Yes')
import math a,b,c,d = list(map(int,input().split())) num1 = math.ceil(c / b) num2 = math.ceil(a / d) if num1 <= num2: print('Yes') else: print('No')
11
11
159
164
import math a, b, c, d = list(map(int, input().split())) ans1 = math.ceil(a / d) ans2 = math.ceil(c / b) if ans1 < ans2: print("No") else: print("Yes")
import math a, b, c, d = list(map(int, input().split())) num1 = math.ceil(c / b) num2 = math.ceil(a / d) if num1 <= num2: print("Yes") else: print("No")
false
0
[ "-ans1 = math.ceil(a / d)", "-ans2 = math.ceil(c / b)", "-if ans1 < ans2:", "+num1 = math.ceil(c / b)", "+num2 = math.ceil(a / d)", "+if num1 <= num2:", "+ print(\"Yes\")", "+else:", "-else:", "- print(\"Yes\")" ]
false
0.043018
0.043978
0.978174
[ "s182680656", "s876264571" ]
u411203878
p03032
python
s939643993
s687200064
202
70
41,836
68,432
Accepted
Accepted
65.35
n,k=list(map(int,input().split())) V=list(map(int,input().split())) ans=0 for i in range(n+1): for j in range(n-i+1): #print(i, j) if i+j>k: continue tmp=V[:i]+V[n-j:] tmp.sort(reverse=True) for l in range(k-i-j): if tmp and tmp[-1]<0: ...
n,k = list(map(int,input().split())) v = list(map(int,input().split())) res = 0 for i in range(n+1): for j in range(n-i+1): if k < i+j: continue memo = v[:i] + v[n-j:] memo.sort() for _ in range(k-i-j): if memo and memo[0] < 0: ...
17
21
420
426
n, k = list(map(int, input().split())) V = list(map(int, input().split())) ans = 0 for i in range(n + 1): for j in range(n - i + 1): # print(i, j) if i + j > k: continue tmp = V[:i] + V[n - j :] tmp.sort(reverse=True) for l in range(k - i - j): if tmp ...
n, k = list(map(int, input().split())) v = list(map(int, input().split())) res = 0 for i in range(n + 1): for j in range(n - i + 1): if k < i + j: continue memo = v[:i] + v[n - j :] memo.sort() for _ in range(k - i - j): if memo and memo[0] < 0: ...
false
19.047619
[ "-V = list(map(int, input().split()))", "-ans = 0", "+v = list(map(int, input().split()))", "+res = 0", "- # print(i, j)", "- if i + j > k:", "+ if k < i + j:", "- tmp = V[:i] + V[n - j :]", "- tmp.sort(reverse=True)", "- for l in range(k - i - j):", "- ...
false
0.037866
0.043154
0.877454
[ "s939643993", "s687200064" ]
u879870653
p03163
python
s498982507
s942221718
645
498
171,656
120,300
Accepted
Accepted
22.79
N,W = list(map(int,input().split())) L = [list(map(int,input().split())) for i in range(N)] dp = [[0 for i in range(W+1)] for j in range(N+1)] for i in range(N) : weight_i,value_i = L[i] for weight in range(W+1) : if weight - weight_i >= 0 : dp[i+1][weight] = max(dp[i][weight], dp...
n,w = list(map(int,input().split())) dp = [[0]*(w+1) for i in range(n+1)] for i in range(1, n+1) : a, v = list(map(int,input().split())) for j in range(1, w+1) : if j < a : dp[i][j] = max(dp[i-1][j], dp[i][j-1]) else : dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i...
16
13
441
341
N, W = list(map(int, input().split())) L = [list(map(int, input().split())) for i in range(N)] dp = [[0 for i in range(W + 1)] for j in range(N + 1)] for i in range(N): weight_i, value_i = L[i] for weight in range(W + 1): if weight - weight_i >= 0: dp[i + 1][weight] = max(dp[i][weight], dp[i...
n, w = list(map(int, input().split())) dp = [[0] * (w + 1) for i in range(n + 1)] for i in range(1, n + 1): a, v = list(map(int, input().split())) for j in range(1, w + 1): if j < a: dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) else: dp[i][j] = max(dp[i - 1][j], dp[i][j - 1...
false
18.75
[ "-N, W = list(map(int, input().split()))", "-L = [list(map(int, input().split())) for i in range(N)]", "-dp = [[0 for i in range(W + 1)] for j in range(N + 1)]", "-for i in range(N):", "- weight_i, value_i = L[i]", "- for weight in range(W + 1):", "- if weight - weight_i >= 0:", "- ...
false
0.044351
0.095993
0.462026
[ "s498982507", "s942221718" ]
u337626942
p03038
python
s736493420
s503754232
938
402
71,064
88,936
Accepted
Accepted
57.14
N, M=list(map(int, input().split())) a=list(map(int, input().split())) a.sort() card=[] for i in range(M): b, c=list(map(int, input().split())) card.append((c, b)) card.sort(reverse=True) k=0 for c, b in card: while k < N and b > 0: if a[k]<c: a[k]=c b-=1 ...
n, m=list(map(int, input().split())) a=list(map(int, input().split())) a.sort() change=[] for i in range(m): b, c=list(map(int, input().split())) change.append((c, b)) change.sort(reverse=True) elem=0 for c, b in change: while elem<n and b>0: if a[elem]<c: a[elem]=c ...
20
20
337
356
N, M = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() card = [] for i in range(M): b, c = list(map(int, input().split())) card.append((c, b)) card.sort(reverse=True) k = 0 for c, b in card: while k < N and b > 0: if a[k] < c: a[k] = c b -= 1 ...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() change = [] for i in range(m): b, c = list(map(int, input().split())) change.append((c, b)) change.sort(reverse=True) elem = 0 for c, b in change: while elem < n and b > 0: if a[elem] < c: a[elem] = c ...
false
0
[ "-N, M = list(map(int, input().split()))", "+n, m = list(map(int, input().split()))", "-card = []", "-for i in range(M):", "+change = []", "+for i in range(m):", "- card.append((c, b))", "-card.sort(reverse=True)", "-k = 0", "-for c, b in card:", "- while k < N and b > 0:", "- if ...
false
0.126883
0.006803
18.651809
[ "s736493420", "s503754232" ]
u046158516
p03213
python
s574375882
s532437189
174
75
38,512
61,976
Accepted
Accepted
56.9
n=int(eval(input())) m=[0]*101 for i in range(1,n+1): for j in range(2,n+1): while i%j==0: a=i//j while (a+1)*j<=i: a+=1 i=a m[j]+=1 counter75=0 counter25=0 counter15=0 counter5=0 counter3=0 for i in range(101): if m[i]>=74: counter75+=1 if m[i]>=24: ...
import sys primes=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] num3=0 num5=0 num15=0 num25=0 num75=0 n=int(eval(input())) for i in primes: tmp=0 j=1 while n//pow(i,j)>0: tmp+=n//pow(i,j) j+=1 if tmp>=2: num3+=1 if tmp>=4: num...
30
27
596
506
n = int(eval(input())) m = [0] * 101 for i in range(1, n + 1): for j in range(2, n + 1): while i % j == 0: a = i // j while (a + 1) * j <= i: a += 1 i = a m[j] += 1 counter75 = 0 counter25 = 0 counter15 = 0 counter5 = 0 counter3 = 0 for i in ra...
import sys primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, ] num3 = 0 num5 = 0 num15 = 0 num25 = 0 num75 = 0 n = int(eval(input())) for i in primes: tmp = 0...
false
10
[ "+import sys", "+", "+primes = [", "+ 2,", "+ 3,", "+ 5,", "+ 7,", "+ 11,", "+ 13,", "+ 17,", "+ 19,", "+ 23,", "+ 29,", "+ 31,", "+ 37,", "+ 41,", "+ 43,", "+ 47,", "+ 53,", "+ 59,", "+ 61,", "+ 67,", "+ 71,", ...
false
0.089695
0.046624
1.923792
[ "s574375882", "s532437189" ]
u888337853
p02586
python
s480985521
s638658901
2,605
1,641
230,824
224,280
Accepted
Accepted
37.01
import sys import math import collections import bisect import itertools # import numpy as np sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline().rstrip()) ns = lambda: list(map(int, sys.stdin.readline().rstrip().split())) na = lambda...
import sys import math import collections import bisect import itertools # import numpy as np sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline().rstrip()) ns = lambda: list(map(int, sys.stdin.readline().rstrip().split())) na = lambda...
48
48
1,181
1,133
import sys import math import collections import bisect import itertools # import numpy as np sys.setrecursionlimit(10**7) INF = 10**20 MOD = 10**9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline().rstrip()) ns = lambda: list(map(int, sys.stdin.readline().rstrip().split())) na = lambda: list(map(int, sys.std...
import sys import math import collections import bisect import itertools # import numpy as np sys.setrecursionlimit(10**7) INF = 10**20 MOD = 10**9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline().rstrip()) ns = lambda: list(map(int, sys.stdin.readline().rstrip().split())) na = lambda: list(map(int, sys.std...
false
0
[ "- mat = [[0 for _ in range(c + 1)] for __ in range(r + 1)]", "+ mat = [[0] * (c + 1) for __ in range(r + 1)]", "- dp = [[0 for __ in range(4)] for _ in range(c + 1)]", "+ dp = [[0] * 4 for _ in range(c + 1)]", "- ndp = [[0 for __ in range(4)] for _ in range(c + 1)]", "+ ndp = [[...
false
0.042384
0.067526
0.627668
[ "s480985521", "s638658901" ]
u540631540
p02819
python
s656843419
s254376544
46
31
3,828
3,060
Accepted
Accepted
32.61
x = int(eval(input())) p = [True] * 100004 p[0] = False p[1] = False for i in range(int(100003 ** 0.5)): if p[i] == False: continue for j in range(2, 100003 // i + 1): p[i * j] = False for i in range(x, 100004): if p[i] == True: print(i) break
x = int(eval(input())) for i in range(x, 100003 + 1): for j in range(2, i): if i % j == 0: break else: print(i) break
13
8
293
162
x = int(eval(input())) p = [True] * 100004 p[0] = False p[1] = False for i in range(int(100003**0.5)): if p[i] == False: continue for j in range(2, 100003 // i + 1): p[i * j] = False for i in range(x, 100004): if p[i] == True: print(i) break
x = int(eval(input())) for i in range(x, 100003 + 1): for j in range(2, i): if i % j == 0: break else: print(i) break
false
38.461538
[ "-p = [True] * 100004", "-p[0] = False", "-p[1] = False", "-for i in range(int(100003**0.5)):", "- if p[i] == False:", "- continue", "- for j in range(2, 100003 // i + 1):", "- p[i * j] = False", "-for i in range(x, 100004):", "- if p[i] == True:", "+for i in range(x, 1000...
false
0.070868
0.10132
0.699446
[ "s656843419", "s254376544" ]
u562935282
p03283
python
s207773638
s195323597
720
575
15,588
19,084
Accepted
Accepted
20.14
class Acc2D: def __init__(self, src): self.acc2d = self._build(src) def _build(self, src): h, w = len(src), len(src[0]) ret = [[0] * w for _ in range(h)] for r in range(h): for c in range(w): ret[r][c] = src[r][c] if r > 0: ...
def main(): import sys input = sys.stdin.readline N, M, Q = map(int, input().split()) tb = [[0] * (N + 1) for _ in range(N + 1)] # tb[L][R]:=区間LR内を走る列車総数 for _ in range(M): L, R = map(int, input().split()) tb[L][R] += 1 for L in range(1, N + 1): for R ...
55
28
1,344
692
class Acc2D: def __init__(self, src): self.acc2d = self._build(src) def _build(self, src): h, w = len(src), len(src[0]) ret = [[0] * w for _ in range(h)] for r in range(h): for c in range(w): ret[r][c] = src[r][c] if r > 0: ...
def main(): import sys input = sys.stdin.readline N, M, Q = map(int, input().split()) tb = [[0] * (N + 1) for _ in range(N + 1)] # tb[L][R]:=区間LR内を走る列車総数 for _ in range(M): L, R = map(int, input().split()) tb[L][R] += 1 for L in range(1, N + 1): for R in range(1, N +...
false
49.090909
[ "-class Acc2D:", "- def __init__(self, src):", "- self.acc2d = self._build(src)", "-", "- def _build(self, src):", "- h, w = len(src), len(src[0])", "- ret = [[0] * w for _ in range(h)]", "- for r in range(h):", "- for c in range(w):", "- ...
false
0.065391
0.04261
1.534626
[ "s207773638", "s195323597" ]
u823044869
p03478
python
s917336548
s505452515
46
40
2,940
2,940
Accepted
Accepted
13.04
n, a, b = list(map(int,input().split())) result_sum = 0 for i in range(1,n+1): keta_sum = 0 for j in range(len(str(i))): keta_sum += int(str(i)[j]) if a <= keta_sum and b >= keta_sum: result_sum += i keta_sum = 0 print(result_sum)
n,b,c = list(map(int,input().split())) count = 0 for i in range(1,n+1): #startnumber, endnumber s = str(i) numSum = 0 for si in range(len(s)): numSum += int(s[si]) if numSum >= b and numSum <= c: count += i print(count)
14
13
274
248
n, a, b = list(map(int, input().split())) result_sum = 0 for i in range(1, n + 1): keta_sum = 0 for j in range(len(str(i))): keta_sum += int(str(i)[j]) if a <= keta_sum and b >= keta_sum: result_sum += i keta_sum = 0 print(result_sum)
n, b, c = list(map(int, input().split())) count = 0 for i in range(1, n + 1): # startnumber, endnumber s = str(i) numSum = 0 for si in range(len(s)): numSum += int(s[si]) if numSum >= b and numSum <= c: count += i print(count)
false
7.142857
[ "-n, a, b = list(map(int, input().split()))", "-result_sum = 0", "-for i in range(1, n + 1):", "- keta_sum = 0", "- for j in range(len(str(i))):", "- keta_sum += int(str(i)[j])", "- if a <= keta_sum and b >= keta_sum:", "- result_sum += i", "- keta_sum = 0", "-print(resul...
false
0.008012
0.039912
0.20075
[ "s917336548", "s505452515" ]
u875361824
p03401
python
s926582534
s694718932
219
199
17,104
14,164
Accepted
Accepted
9.13
def main(): N = int(eval(input())) *A, = list(map(int, input().split())) f(N, A) def f(N, A): """ 2 ≤ N ≤ 10^5 −5000 ≤ Ai ≤ 5000 (1≤ i≤ N) 第一印象: 累積和? """ costs = [abs(A[0])] costs_cumsum = [abs(A[0])] for i in range(1, N): cost = abs(A[i] - A[i-1]...
def main(): N = int(eval(input())) *A, = list(map(int, input().split())) f(N, A) def f(N, A): """ 2 ≤ N ≤ 10^5 −5000 ≤ Ai ≤ 5000 (1≤ i≤ N) 第一印象: 累積和? →不要,合計のみ必要だった """ costs = [abs(A[0])] for i in range(1, N): cost = abs(A[i] - A[i-1]) co...
46
43
958
830
def main(): N = int(eval(input())) (*A,) = list(map(int, input().split())) f(N, A) def f(N, A): """ 2 ≤ N ≤ 10^5 −5000 ≤ Ai ≤ 5000 (1≤ i≤ N) 第一印象: 累積和? """ costs = [abs(A[0])] costs_cumsum = [abs(A[0])] for i in range(1, N): cost = abs(A[i] - A[i - 1]) cumsu...
def main(): N = int(eval(input())) (*A,) = list(map(int, input().split())) f(N, A) def f(N, A): """ 2 ≤ N ≤ 10^5 −5000 ≤ Ai ≤ 5000 (1≤ i≤ N) 第一印象: 累積和? →不要,合計のみ必要だった """ costs = [abs(A[0])] for i in range(1, N): cost = abs(A[i] - A[i - 1]) costs.append(cost)...
false
6.521739
[ "+ →不要,合計のみ必要だった", "- costs_cumsum = [abs(A[0])]", "- cumsum = cost + costs_cumsum[-1]", "- costs_cumsum.append(cumsum)", "- costs_cumsum.append(cost_N_to_start + costs_cumsum[-1])", "+ costs_cumsum = sum(costs)", "- total = costs_cumsum[-1]", "+ total = costs_c...
false
0.045861
0.080543
0.569394
[ "s926582534", "s694718932" ]
u707124227
p03438
python
s694206503
s197834435
306
25
21,260
4,852
Accepted
Accepted
91.83
import numpy as np n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) d,e=0,0 for i in range(n): c=a[i]-b[i] if c>0: d+=c elif c%2==0: e+=-c else: e+=-c-1 print(('Yes' if 2*d<=e else 'No'))
def main(): n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) c=[a[i]-b[i] for i in range(n)] c0=sum([ci for ci in c if ci>0]) c1=sum([-2*((ci+2-1)//2) for ci in c if ci<0]) print(('Yes' if c1>=2*c0 else 'No')) if __name__=='__main__': main()
14
10
251
297
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) d, e = 0, 0 for i in range(n): c = a[i] - b[i] if c > 0: d += c elif c % 2 == 0: e += -c else: e += -c - 1 print(("Yes" if 2 * d <= e else "No"))
def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [a[i] - b[i] for i in range(n)] c0 = sum([ci for ci in c if ci > 0]) c1 = sum([-2 * ((ci + 2 - 1) // 2) for ci in c if ci < 0]) print(("Yes" if c1 >= 2 * c0 else "No")) if __name_...
false
28.571429
[ "-import numpy as np", "+def main():", "+ n = int(eval(input()))", "+ a = list(map(int, input().split()))", "+ b = list(map(int, input().split()))", "+ c = [a[i] - b[i] for i in range(n)]", "+ c0 = sum([ci for ci in c if ci > 0])", "+ c1 = sum([-2 * ((ci + 2 - 1) // 2) for ci in c if...
false
0.036769
0.036612
1.004297
[ "s694206503", "s197834435" ]
u334712262
p02925
python
s884865252
s971864661
1,708
1,544
46,452
46,448
Accepted
Accepted
9.6
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
106
106
1,906
1,903
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
false
0
[ "- for k in tuple(s2):", "+ s2_, s2 = s2, set()", "+ for k in s2_:", "- s2.remove(k)" ]
false
0.038373
0.037105
1.034189
[ "s884865252", "s971864661" ]
u073549161
p03457
python
s587781133
s279707702
566
227
46,184
9,084
Accepted
Accepted
59.89
n = int(eval(input())) pt = 0 px, py = 0, 0 f = True for i in range(n): t, x, y = list(map(int, input().split())) dis = abs(px-x) + abs(py-y) dt = t - pt #print("dis{0} dt = {1}".format(dis, dt)) if dt >= dis and abs(dis - dt) % 2 == 0: pass else: f = False pt, p...
n = int(eval(input())) can = True time = 0 x = 0 y = 0 for _ in range(n): t, xx, yy = list(map(int,input().split())) distance = abs(x-xx) + abs(y - yy) difft = t - time if difft < distance: can = False break if (distance - difft) % 2 == 1: can = False br...
15
21
353
384
n = int(eval(input())) pt = 0 px, py = 0, 0 f = True for i in range(n): t, x, y = list(map(int, input().split())) dis = abs(px - x) + abs(py - y) dt = t - pt # print("dis{0} dt = {1}".format(dis, dt)) if dt >= dis and abs(dis - dt) % 2 == 0: pass else: f = False pt, px, py = ...
n = int(eval(input())) can = True time = 0 x = 0 y = 0 for _ in range(n): t, xx, yy = list(map(int, input().split())) distance = abs(x - xx) + abs(y - yy) difft = t - time if difft < distance: can = False break if (distance - difft) % 2 == 1: can = False break x =...
false
28.571429
[ "-pt = 0", "-px, py = 0, 0", "-f = True", "-for i in range(n):", "- t, x, y = list(map(int, input().split()))", "- dis = abs(px - x) + abs(py - y)", "- dt = t - pt", "- # print(\"dis{0} dt = {1}\".format(dis, dt))", "- if dt >= dis and abs(dis - dt) % 2 == 0:", "- pass", "-...
false
0.039653
0.04464
0.888273
[ "s587781133", "s279707702" ]
u367130284
p03986
python
s826813764
s611890193
81
63
5,096
4,328
Accepted
Accepted
22.22
ans=0 stack=[] for s in eval(input()): if len(stack)>0 and s=="T": if stack[-1]=="S": del stack[-1] else: stack.append(s) else: stack.append(s) print((len(stack)))
s=eval(input()) stack=[] ans=0 for i in s: if i=="S": stack.append(1) elif len(stack)>0 and i=="T": stack.pop() ans+=1 print((len(s)-ans*2))
11
10
221
174
ans = 0 stack = [] for s in eval(input()): if len(stack) > 0 and s == "T": if stack[-1] == "S": del stack[-1] else: stack.append(s) else: stack.append(s) print((len(stack)))
s = eval(input()) stack = [] ans = 0 for i in s: if i == "S": stack.append(1) elif len(stack) > 0 and i == "T": stack.pop() ans += 1 print((len(s) - ans * 2))
false
9.090909
[ "+s = eval(input())", "+stack = []", "-stack = []", "-for s in eval(input()):", "- if len(stack) > 0 and s == \"T\":", "- if stack[-1] == \"S\":", "- del stack[-1]", "- else:", "- stack.append(s)", "- else:", "- stack.append(s)", "-print((len(st...
false
0.047276
0.039419
1.19932
[ "s826813764", "s611890193" ]
u840310460
p03160
python
s974565524
s318642802
224
129
52,208
13,928
Accepted
Accepted
42.41
def func(): N = int(eval(input())) H = [int(i) for i in input().split()] dp = [0]*N for i in range(1, N): L = [] for j in range(max(0, i-2), i): L.append(dp[j] + abs(H[i] - H[j])) dp[i] = min(L) print((dp[-1])) if __name__=="__main__": ...
N = int(eval(input())) H = [int(i) for i in input().split()] dp = [0] * N dp[1] = abs(H[1] - H[0]) for i in range(2, N): dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1])) print((dp[-1]))
15
9
319
214
def func(): N = int(eval(input())) H = [int(i) for i in input().split()] dp = [0] * N for i in range(1, N): L = [] for j in range(max(0, i - 2), i): L.append(dp[j] + abs(H[i] - H[j])) dp[i] = min(L) print((dp[-1])) if __name__ == "__main__": func()
N = int(eval(input())) H = [int(i) for i in input().split()] dp = [0] * N dp[1] = abs(H[1] - H[0]) for i in range(2, N): dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1])) print((dp[-1]))
false
40
[ "-def func():", "- N = int(eval(input()))", "- H = [int(i) for i in input().split()]", "- dp = [0] * N", "- for i in range(1, N):", "- L = []", "- for j in range(max(0, i - 2), i):", "- L.append(dp[j] + abs(H[i] - H[j]))", "- dp[i] = min(L)", "- print...
false
0.038579
0.045648
0.845154
[ "s974565524", "s318642802" ]
u721316601
p03262
python
s469826129
s276711993
670
141
23,244
16,284
Accepted
Accepted
78.96
import numpy as np N, X = list(map(int, input().split())) x = np.array(list(map(int, input().split()))) x = np.abs(X - x) for i in range(N-1): a, b = x[i:i+2] while b > 0: a, b = b, a % b x[i+1] = a print((x[-1]))
#import math import fractions as math N, X = list(map(int, input().split())) x = sorted([X] + list(map(int, input().split()))) nums = [-(x[i]-x[i+1]) for i in range(N)] ans = 0 for n in nums: ans = math.gcd(ans, n) print(ans)
13
10
247
239
import numpy as np N, X = list(map(int, input().split())) x = np.array(list(map(int, input().split()))) x = np.abs(X - x) for i in range(N - 1): a, b = x[i : i + 2] while b > 0: a, b = b, a % b x[i + 1] = a print((x[-1]))
# import math import fractions as math N, X = list(map(int, input().split())) x = sorted([X] + list(map(int, input().split()))) nums = [-(x[i] - x[i + 1]) for i in range(N)] ans = 0 for n in nums: ans = math.gcd(ans, n) print(ans)
false
23.076923
[ "-import numpy as np", "+# import math", "+import fractions as math", "-x = np.array(list(map(int, input().split())))", "-x = np.abs(X - x)", "-for i in range(N - 1):", "- a, b = x[i : i + 2]", "- while b > 0:", "- a, b = b, a % b", "- x[i + 1] = a", "-print((x[-1]))", "+x = so...
false
0.17322
0.113508
1.526061
[ "s469826129", "s276711993" ]
u347640436
p02848
python
s435573703
s100073094
25
19
3,060
3,060
Accepted
Accepted
24
N = int(eval(input())) S = eval(input()) print((''.join(chr((ord(c) - ord('A') + N) % 26 + ord('A')) for c in S)))
N = int(eval(input())) S = eval(input()) bs = S.encode('us-ascii') print((bytes((b - 65 + N) % 26 + 65 for b in bs).decode('us-ascii')))
4
5
105
128
N = int(eval(input())) S = eval(input()) print(("".join(chr((ord(c) - ord("A") + N) % 26 + ord("A")) for c in S)))
N = int(eval(input())) S = eval(input()) bs = S.encode("us-ascii") print((bytes((b - 65 + N) % 26 + 65 for b in bs).decode("us-ascii")))
false
20
[ "-print((\"\".join(chr((ord(c) - ord(\"A\") + N) % 26 + ord(\"A\")) for c in S)))", "+bs = S.encode(\"us-ascii\")", "+print((bytes((b - 65 + N) % 26 + 65 for b in bs).decode(\"us-ascii\")))" ]
false
0.046101
0.038323
1.202964
[ "s435573703", "s100073094" ]
u059210959
p03625
python
s462920234
s309886775
204
88
25,868
24,140
Accepted
Accepted
56.86
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import math N = int(eval(input())) A = [int(i) for i in input().split()] A.sort() len_dic = {} for a in A: if a in list(len_dic.keys()): len_dic[a] += 1 else: len_dic[a] = 1 ans = [0,0]...
#!/usr/bin/env python3 # encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import sys import collections from decimal import Decimal # 10進数で考慮できる mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.de...
30
33
559
719
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import math N = int(eval(input())) A = [int(i) for i in input().split()] A.sort() len_dic = {} for a in A: if a in list(len_dic.keys()): len_dic[a] += 1 else: len_dic[a] = 1 ans = [0, 0] for k, v in sorted(...
#!/usr/bin/env python3 # encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち import math import sys import collections from decimal import Decimal # 10進数で考慮できる mod = 10**9 + 7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() ...
false
9.090909
[ "+#!/usr/bin/env python3", "+import fractions # 最小公倍数などはこっち", "+import sys", "+import collections", "+from decimal import Decimal # 10進数で考慮できる", "+", "+mod = 10**9 + 7", "+sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000", "+d = collections.deque()", "+", "+", "+def LI():", "+ return l...
false
0.085664
0.182708
0.468857
[ "s462920234", "s309886775" ]
u035907840
p03171
python
s980639667
s726422894
445
209
206,040
135,168
Accepted
Accepted
53.03
N = int(eval(input())) *a, = list(map(int, input().split())) dp = [[None] * N for _ in range(N)] for i in range(N): dp[i][i] = a[i] for j in range(1, N): for i in range(j-1, -1, -1): dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]) print((dp[0][N-1]))
N = int(eval(input())) *a, = list(map(int, input().split())) dp = [[0] * N for _ in range(N)] for i in range(N): dp[i][i] = a[i] for j in range(1, N): for i in range(j-1, -1, -1): dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]) print((dp[0][N-1]))
11
11
267
264
N = int(eval(input())) (*a,) = list(map(int, input().split())) dp = [[None] * N for _ in range(N)] for i in range(N): dp[i][i] = a[i] for j in range(1, N): for i in range(j - 1, -1, -1): dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]) print((dp[0][N - 1]))
N = int(eval(input())) (*a,) = list(map(int, input().split())) dp = [[0] * N for _ in range(N)] for i in range(N): dp[i][i] = a[i] for j in range(1, N): for i in range(j - 1, -1, -1): dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]) print((dp[0][N - 1]))
false
0
[ "-dp = [[None] * N for _ in range(N)]", "+dp = [[0] * N for _ in range(N)]" ]
false
0.046781
0.047137
0.992455
[ "s980639667", "s726422894" ]
u977389981
p03241
python
s809560316
s224489839
38
21
2,940
3,064
Accepted
Accepted
44.74
N, M = list(map(int, input().split())) if M % N == 0: ans = M // N else: for i in range(1, M // N + 1): if M % i == 0: ans = i if M // i > i and M // i <= M // N: ans = M // i break print(ans)
N, M = list(map(int, input().split())) if M % N == 0: ans = M // N else: ans = 0 for i in range(1, int(M ** 0.5) + 1): if M % i == 0: if i <= M // N: ans = max(ans, i) if M // i <= M // N: ans = max(ans, M // i) print(ans...
13
14
280
315
N, M = list(map(int, input().split())) if M % N == 0: ans = M // N else: for i in range(1, M // N + 1): if M % i == 0: ans = i if M // i > i and M // i <= M // N: ans = M // i break print(ans)
N, M = list(map(int, input().split())) if M % N == 0: ans = M // N else: ans = 0 for i in range(1, int(M**0.5) + 1): if M % i == 0: if i <= M // N: ans = max(ans, i) if M // i <= M // N: ans = max(ans, M // i) print(ans)
false
7.142857
[ "- for i in range(1, M // N + 1):", "+ ans = 0", "+ for i in range(1, int(M**0.5) + 1):", "- ans = i", "- if M // i > i and M // i <= M // N:", "- ans = M // i", "- break", "+ if i <= M // N:", "+ ans = max(ans, i...
false
0.063243
0.07568
0.835664
[ "s809560316", "s224489839" ]
u956318161
p02577
python
s398912151
s923710875
742
72
9,200
9,216
Accepted
Accepted
90.3
N=int(eval(input())) n= str(N) total=0 for i in range(len(n)): k = n[i] k = int(k) total += k if total%9==0: print("Yes") else: print("No")
n = eval(input()) point=0 for i in range(len(n)): point+=int(n[i]) if point%9==0: print("Yes") else: print("No")
12
9
157
123
N = int(eval(input())) n = str(N) total = 0 for i in range(len(n)): k = n[i] k = int(k) total += k if total % 9 == 0: print("Yes") else: print("No")
n = eval(input()) point = 0 for i in range(len(n)): point += int(n[i]) if point % 9 == 0: print("Yes") else: print("No")
false
25
[ "-N = int(eval(input()))", "-n = str(N)", "-total = 0", "+n = eval(input())", "+point = 0", "- k = n[i]", "- k = int(k)", "- total += k", "-if total % 9 == 0:", "+ point += int(n[i])", "+if point % 9 == 0:" ]
false
0.089738
0.076269
1.176596
[ "s398912151", "s923710875" ]
u571281863
p02630
python
s018501586
s135306136
520
278
20,848
24,012
Accepted
Accepted
46.54
N=int(eval(input())) A=list(map(int,input().split())) Q=int(eval(input())) D=dict() s=0 for i in A: s+=i if i in D: D[i]+=1 else: D[i]=1 for _ in range(Q): b,c=list(map(int,input().split())) if b in D: s+=(c-b)*D[b] if c in D: D[c]+=D[b] else: D[c]=D[b] d...
import sys from collections import Counter readline=sys.stdin.readline n=readline() A=list(map(int,readline().split())) q=int(readline()) D=Counter(A) s=sum(A) for _ in range(q): b,c=list(map(int,readline().split())) s+=(c-b)*D[b] D[c]+=D[b] del D[b] print(s)
21
14
321
276
N = int(eval(input())) A = list(map(int, input().split())) Q = int(eval(input())) D = dict() s = 0 for i in A: s += i if i in D: D[i] += 1 else: D[i] = 1 for _ in range(Q): b, c = list(map(int, input().split())) if b in D: s += (c - b) * D[b] if c in D: D[...
import sys from collections import Counter readline = sys.stdin.readline n = readline() A = list(map(int, readline().split())) q = int(readline()) D = Counter(A) s = sum(A) for _ in range(q): b, c = list(map(int, readline().split())) s += (c - b) * D[b] D[c] += D[b] del D[b] print(s)
false
33.333333
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-Q = int(eval(input()))", "-D = dict()", "-s = 0", "-for i in A:", "- s += i", "- if i in D:", "- D[i] += 1", "- else:", "- D[i] = 1", "-for _ in range(Q):", "- b, c = list(map(int, input().split())...
false
0.04631
0.046369
0.998723
[ "s018501586", "s135306136" ]
u017415492
p02695
python
s075642490
s197382285
1,650
1,357
21,616
21,620
Accepted
Accepted
17.76
import itertools n,m,q=list(map(int,input().split())) abcd=[list(map(int,input().split())) for i in range(q)] d=list(itertools.combinations_with_replacement(list(range(1,m+1)), n)) ans=0 count=0 for i in range(len(d)): for j in range(q): if abcd[j][2]==d[i][abcd[j][1]-1]-d[i][abcd[j][0]-1]: count+=...
import itertools n,m,q=list(map(int,input().split())) d=[list(map(int,input().split())) for i in range(q)] ans=0 for i in list(itertools.combinations_with_replacement(list(range(1,m+1)), n)): a=list(i) hantei=0 for j in range(q): if (a[d[j][1]-1]-a[d[j][0]-1])==d[j][2]: hantei+=d[j][3] ans=m...
15
12
383
340
import itertools n, m, q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for i in range(q)] d = list(itertools.combinations_with_replacement(list(range(1, m + 1)), n)) ans = 0 count = 0 for i in range(len(d)): for j in range(q): if abcd[j][2] == d[i][abcd[j][1] - 1] - d[i][abcd[j]...
import itertools n, m, q = list(map(int, input().split())) d = [list(map(int, input().split())) for i in range(q)] ans = 0 for i in list(itertools.combinations_with_replacement(list(range(1, m + 1)), n)): a = list(i) hantei = 0 for j in range(q): if (a[d[j][1] - 1] - a[d[j][0] - 1]) == d[j][2]: ...
false
20
[ "-abcd = [list(map(int, input().split())) for i in range(q)]", "-d = list(itertools.combinations_with_replacement(list(range(1, m + 1)), n))", "+d = [list(map(int, input().split())) for i in range(q)]", "-count = 0", "-for i in range(len(d)):", "+for i in list(itertools.combinations_with_replacement(list(...
false
0.151927
0.076301
1.991163
[ "s075642490", "s197382285" ]
u709304134
p02684
python
s189026339
s890288470
279
151
39,600
32,348
Accepted
Accepted
45.88
N,K = list(map(int,input().split())) A = [0] + list(map(int,input().split())) d = dict() c = 1 loop = False k = 0 while(k<K): if not loop and str(c) in d: T = k-d[str(c)] #print ('K',k) a = max((((K-k) // T)) - 1,0) #print(a) k += a*T #print ('K',k) ...
N,K = list(map(int,input().split())) A = [0] + list(map(int,input().split())) turn = [-1] * (N+1) # いつ訪問したかを記録する c = 1 for k in range(K): if turn[c]!=-1: T = k - turn[c] # 周期 bias = turn[c] # バイアス break turn[c] = k c = A[c] else: print (c) exit() K -= bias # K...
20
22
386
397
N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) d = dict() c = 1 loop = False k = 0 while k < K: if not loop and str(c) in d: T = k - d[str(c)] # print ('K',k) a = max((((K - k) // T)) - 1, 0) # print(a) k += a * T # print ('K',k) ...
N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) turn = [-1] * (N + 1) # いつ訪問したかを記録する c = 1 for k in range(K): if turn[c] != -1: T = k - turn[c] # 周期 bias = turn[c] # バイアス break turn[c] = k c = A[c] else: print(c) exit() K -= bias # Kを減らしてリ...
false
9.090909
[ "-d = dict()", "+turn = [-1] * (N + 1) # いつ訪問したかを記録する", "-loop = False", "-k = 0", "-while k < K:", "- if not loop and str(c) in d:", "- T = k - d[str(c)]", "- # print ('K',k)", "- a = max((((K - k) // T)) - 1, 0)", "- # print(a)", "- k += a * T", "- ...
false
0.006501
0.072995
0.089061
[ "s189026339", "s890288470" ]
u780364430
p03061
python
s463209504
s444924847
351
301
24,776
23,148
Accepted
Accepted
14.25
from functools import reduce import numpy as np def _gcd(a, b): while b: a, b = b, a % b return a def gcd(*n): return reduce(_gcd, n) def my_bisect(x): def find_pos(left, right): return left + (right - left - 1) // 2 def func(left, right, prev): if...
from functools import reduce import numpy as np def _gcd(a, b): while b: a, b = b, a % b return a def gcd(*n): return reduce(_gcd, n) def my_bisect(x): def find_pos(left, right): return left + (right - left - 1) // 2 def func(left, right, prev): if...
40
38
917
831
from functools import reduce import numpy as np def _gcd(a, b): while b: a, b = b, a % b return a def gcd(*n): return reduce(_gcd, n) def my_bisect(x): def find_pos(left, right): return left + (right - left - 1) // 2 def func(left, right, prev): if right - left == 1: ...
from functools import reduce import numpy as np def _gcd(a, b): while b: a, b = b, a % b return a def gcd(*n): return reduce(_gcd, n) def my_bisect(x): def find_pos(left, right): return left + (right - left - 1) // 2 def func(left, right, prev): if right - left == 1: ...
false
5
[ "- return [left]", "- if right - left == 2:", "- return [left, left + 1]", "+ return left", "-print((max([gcd(*np.delete(A, i)) for i in my_bisect(A)])))", "+print((gcd(*np.delete(A, my_bisect(A)))))" ]
false
0.678047
0.330219
2.053328
[ "s463209504", "s444924847" ]
u116002573
p03378
python
s840054776
s288698641
19
17
3,060
2,940
Accepted
Accepted
10.53
def main(): N, M, X = list(map(int, input().split())) A = [int(a) for a in input().split()] costL = 0 for i in range(len(A)): if A[i] < X: costL += 1 return min(costL, M-costL) if __name__ == '__main__': print((main()))
def main(): N, M, X = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() count1 = 0 for i in range(M): if A[i] < X: count1 += 1 return min(count1, len(A)-count1) if __name__ == '__main__': print((main()))
11
14
270
276
def main(): N, M, X = list(map(int, input().split())) A = [int(a) for a in input().split()] costL = 0 for i in range(len(A)): if A[i] < X: costL += 1 return min(costL, M - costL) if __name__ == "__main__": print((main()))
def main(): N, M, X = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() count1 = 0 for i in range(M): if A[i] < X: count1 += 1 return min(count1, len(A) - count1) if __name__ == "__main__": print((main()))
false
21.428571
[ "- A = [int(a) for a in input().split()]", "- costL = 0", "- for i in range(len(A)):", "+ A = list(map(int, input().split()))", "+ A.sort()", "+ count1 = 0", "+ for i in range(M):", "- costL += 1", "- return min(costL, M - costL)", "+ count1 += 1", "...
false
0.046259
0.048003
0.963669
[ "s840054776", "s288698641" ]
u873915460
p03837
python
s455271493
s364074374
106
98
74,344
74,172
Accepted
Accepted
7.55
N,M=list(map(int,input().split())) E=[list(map(int,input().split())) for i in range(M)] INF=10**12 D=[[INF]*N for i in range(N)] for i in range(N): D[i][i]=0 for i in range(M): D[E[i][0]-1][E[i][1]-1]=E[i][2] D[E[i][1]-1][E[i][0]-1]=E[i][2] for k in range(N): for i in range(N): for j in range(N):...
N,M=list(map(int,input().split())) a,b,c=0,0,0 E=[] INF=10**12 D=[[INF]*N for i in range(N)] for i in range(N): D[i][i]=0 for i in range(M): a,b,c=list(map(int,input().split())) a,b=a-1,b-1 D[a][b]=c D[b][a]=c E.append((a,b,c)) for k in range(N): for i in range(N): for j in range(N): ...
21
22
550
430
N, M = list(map(int, input().split())) E = [list(map(int, input().split())) for i in range(M)] INF = 10**12 D = [[INF] * N for i in range(N)] for i in range(N): D[i][i] = 0 for i in range(M): D[E[i][0] - 1][E[i][1] - 1] = E[i][2] D[E[i][1] - 1][E[i][0] - 1] = E[i][2] for k in range(N): for i in range(N)...
N, M = list(map(int, input().split())) a, b, c = 0, 0, 0 E = [] INF = 10**12 D = [[INF] * N for i in range(N)] for i in range(N): D[i][i] = 0 for i in range(M): a, b, c = list(map(int, input().split())) a, b = a - 1, b - 1 D[a][b] = c D[b][a] = c E.append((a, b, c)) for k in range(N): for i ...
false
4.545455
[ "-E = [list(map(int, input().split())) for i in range(M)]", "+a, b, c = 0, 0, 0", "+E = []", "- D[E[i][0] - 1][E[i][1] - 1] = E[i][2]", "- D[E[i][1] - 1][E[i][0] - 1] = E[i][2]", "+ a, b, c = list(map(int, input().split()))", "+ a, b = a - 1, b - 1", "+ D[a][b] = c", "+ D[b][a] = c...
false
0.037435
0.043279
0.864977
[ "s455271493", "s364074374" ]
u854992222
p02713
python
s585019998
s934752491
1,806
1,498
9,204
9,184
Accepted
Accepted
17.05
from math import gcd k = int(eval(input())) sum =0 for a in range(1, k+1): for b in range(1, k+1): for c in range(1, k+1): sum += gcd(gcd(a, b), c) print(sum)
import math k = int(eval(input())) sum =0 for a in range(1, k+1): for b in range(1, k+1): x = math.gcd(a, b) for c in range(1, k+1): sum += math.gcd(x, c) print(sum)
8
9
186
203
from math import gcd k = int(eval(input())) sum = 0 for a in range(1, k + 1): for b in range(1, k + 1): for c in range(1, k + 1): sum += gcd(gcd(a, b), c) print(sum)
import math k = int(eval(input())) sum = 0 for a in range(1, k + 1): for b in range(1, k + 1): x = math.gcd(a, b) for c in range(1, k + 1): sum += math.gcd(x, c) print(sum)
false
11.111111
[ "-from math import gcd", "+import math", "+ x = math.gcd(a, b)", "- sum += gcd(gcd(a, b), c)", "+ sum += math.gcd(x, c)" ]
false
0.11611
0.083579
1.389222
[ "s585019998", "s934752491" ]
u678505520
p02725
python
s264746014
s052970421
135
102
25,928
26,444
Accepted
Accepted
24.44
K,N=list(map(int,input().split())) A=list(map(int,input().split())) M = 0 i = 0 while i<N-1: if M<(A[i+1]-A[i]): M=(A[i+1]-A[i]) i+=1 print((min(K-M,A[N-1]-A[0])))
k,n = list(map(int,input().split())) A = list(map(int,input().split())) A.append(k+A[0]) M = 0 for i in range(n): if A[i+1] - A[i] > M: M = A[i+1] - A[i] print((k-M))
10
8
181
177
K, N = list(map(int, input().split())) A = list(map(int, input().split())) M = 0 i = 0 while i < N - 1: if M < (A[i + 1] - A[i]): M = A[i + 1] - A[i] i += 1 print((min(K - M, A[N - 1] - A[0])))
k, n = list(map(int, input().split())) A = list(map(int, input().split())) A.append(k + A[0]) M = 0 for i in range(n): if A[i + 1] - A[i] > M: M = A[i + 1] - A[i] print((k - M))
false
20
[ "-K, N = list(map(int, input().split()))", "+k, n = list(map(int, input().split()))", "+A.append(k + A[0])", "-i = 0", "-while i < N - 1:", "- if M < (A[i + 1] - A[i]):", "+for i in range(n):", "+ if A[i + 1] - A[i] > M:", "- i += 1", "-print((min(K - M, A[N - 1] - A[0])))", "+print((k ...
false
0.080021
0.122624
0.652575
[ "s264746014", "s052970421" ]
u968166680
p02838
python
s392786525
s322668655
348
195
126,056
125,868
Accepted
Accepted
43.97
import sys read = sys.stdin.buffer.read MOD = 1000000007 def main(): N, *A = list(map(int, read().split())) M = 60 ans = 0 p = 1 for _ in range(M): n = 0 for i, a in enumerate(A): if not a: continue A[i], d = a // 2, a % 2 ...
import sys read = sys.stdin.buffer.read MOD = 1000000007 def main(): N, *A = list(map(int, read().split())) M = 60 ans = 0 p = 1 for _ in range(M): n = 0 for i in range(N): A[i], d = A[i] // 2, A[i] % 2 n += d ans = (ans + n * (N -...
29
26
501
428
import sys read = sys.stdin.buffer.read MOD = 1000000007 def main(): N, *A = list(map(int, read().split())) M = 60 ans = 0 p = 1 for _ in range(M): n = 0 for i, a in enumerate(A): if not a: continue A[i], d = a // 2, a % 2 if d: ...
import sys read = sys.stdin.buffer.read MOD = 1000000007 def main(): N, *A = list(map(int, read().split())) M = 60 ans = 0 p = 1 for _ in range(M): n = 0 for i in range(N): A[i], d = A[i] // 2, A[i] % 2 n += d ans = (ans + n * (N - n) * p) % MOD ...
false
10.344828
[ "- for i, a in enumerate(A):", "- if not a:", "- continue", "- A[i], d = a // 2, a % 2", "- if d:", "- n += 1", "+ for i in range(N):", "+ A[i], d = A[i] // 2, A[i] % 2", "+ n += d" ]
false
0.036723
0.033634
1.091833
[ "s392786525", "s322668655" ]
u808429775
p00111
python
s584564795
s408209812
70
60
5,608
5,600
Accepted
Accepted
14.29
import sys CharToSign = { "A": "00000", "B": "00001", "C": "00010", "D": "00011", "E": "00100", "F": "00101", "G": "00110", "H": "00111", "I": "01000", "J": "01001", "K": "01010", "L": "01011", "M": "01100", "N": "01101", "O": "01110", "P": "01111", "Q": "10000", "R": "10001", "S": "10010", ...
import sys CharToSign = { "A": "00000", "B": "00001", "C": "00010", "D": "00011", "E": "00100", "F": "00101", "G": "00110", "H": "00111", "I": "01000", "J": "01001", "K": "01010", "L": "01011", "M": "01100", "N": "01101", "O": "01110", "P": "01111", "Q": "10000", "R": "10001", "S": "10010", ...
53
42
1,666
1,382
import sys CharToSign = { "A": "00000", "B": "00001", "C": "00010", "D": "00011", "E": "00100", "F": "00101", "G": "00110", "H": "00111", "I": "01000", "J": "01001", "K": "01010", "L": "01011", "M": "01100", "N": "01101", "O": "01110", "P": "01111", "...
import sys CharToSign = { "A": "00000", "B": "00001", "C": "00010", "D": "00011", "E": "00100", "F": "00101", "G": "00110", "H": "00111", "I": "01000", "J": "01001", "K": "01010", "L": "01011", "M": "01100", "N": "01101", "O": "01110", "P": "01111", "...
false
20.754717
[ "- sign = []", "+ sign = \"\"", "- convert = CharToSign[char]", "- sign.append(convert)", "- sign = \"\".join(sign)", "- startIndex = 0", "- endIndex = 3", "- string = []", "- length = len(sign)", "- while endIndex <= length:", "- part = sign[startInd...
false
0.120356
0.18733
0.642483
[ "s584564795", "s408209812" ]
u193264896
p02713
python
s883858875
s170802558
1,247
226
10,680
9,188
Accepted
Accepted
81.88
from fractions import gcd def main(): k = int(eval(input())) ans = 0 for a in range(1, k+1): for b in range(a, k+1): x = gcd(a,b) for c in range(b,k+1): if a==b and b==c: ans += a elif a==b or b==c: ans += gcd(x,c) * 3 else: ans...
from math import gcd def main(): k = int(eval(input())) ans = 0 for a in range(1, k+1): for b in range(a, k+1): x = gcd(a,b) for c in range(b,k+1): if a==b and b==c: ans += a elif a==b or b==c: ans += gcd(x,c) * 3 else: ans += g...
20
20
390
386
from fractions import gcd def main(): k = int(eval(input())) ans = 0 for a in range(1, k + 1): for b in range(a, k + 1): x = gcd(a, b) for c in range(b, k + 1): if a == b and b == c: ans += a elif a == b or b == c: ...
from math import gcd def main(): k = int(eval(input())) ans = 0 for a in range(1, k + 1): for b in range(a, k + 1): x = gcd(a, b) for c in range(b, k + 1): if a == b and b == c: ans += a elif a == b or b == c: ...
false
0
[ "-from fractions import gcd", "+from math import gcd" ]
false
0.159177
0.112871
1.410254
[ "s883858875", "s170802558" ]
u747220349
p02811
python
s317207115
s024634851
171
17
38,256
2,940
Accepted
Accepted
90.06
n,k=list(map(int,input().split())) g=500*n if g>=k: print("Yes") else: print("No")
k,n=list(map(int,input().split())) if 500*k>=n: print("Yes") else: print("No")
6
5
89
84
n, k = list(map(int, input().split())) g = 500 * n if g >= k: print("Yes") else: print("No")
k, n = list(map(int, input().split())) if 500 * k >= n: print("Yes") else: print("No")
false
16.666667
[ "-n, k = list(map(int, input().split()))", "-g = 500 * n", "-if g >= k:", "+k, n = list(map(int, input().split()))", "+if 500 * k >= n:" ]
false
0.083019
0.036783
2.256972
[ "s317207115", "s024634851" ]
u771167374
p03290
python
s028370241
s565065867
46
34
9,120
9,140
Accepted
Accepted
26.09
#abc104c all green d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for _ in range(d)] all_sum = [] for bit in range(1<<d): s = 0 a = 0 rest = [] for i in range(d): if bit & (1<<i): s += pc[i][0]*100*(i+1) + pc[i][1] a += pc[i][0] ...
def dfs(i, sum, count, rest): global ans if i == d: if sum < g: rest_max = max(rest) n = min(l[rest_max-1][0], -(-(g-sum)//(rest_max*100))) count += n sum += n * rest_max * 100 if sum >= g: ans = min(ans, count) else : ...
24
19
593
616
# abc104c all green d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for _ in range(d)] all_sum = [] for bit in range(1 << d): s = 0 a = 0 rest = [] for i in range(d): if bit & (1 << i): s += pc[i][0] * 100 * (i + 1) + pc[i][1] a += pc[i][0] ...
def dfs(i, sum, count, rest): global ans if i == d: if sum < g: rest_max = max(rest) n = min(l[rest_max - 1][0], -(-(g - sum) // (rest_max * 100))) count += n sum += n * rest_max * 100 if sum >= g: ans = min(ans, count) else: ...
false
20.833333
[ "-# abc104c all green", "+def dfs(i, sum, count, rest):", "+ global ans", "+ if i == d:", "+ if sum < g:", "+ rest_max = max(rest)", "+ n = min(l[rest_max - 1][0], -(-(g - sum) // (rest_max * 100)))", "+ count += n", "+ sum += n * rest_max * 1...
false
0.042336
0.042361
0.999421
[ "s028370241", "s565065867" ]
u050428930
p03592
python
s821458987
s216121361
331
305
3,060
42,648
Accepted
Accepted
7.85
n,m,k=list(map(int,input().split())) for i in range(n+1): for j in range(m+1): if m*i+n*j-2*(i*j)==k: print("Yes") exit() print("No")
n,m,k=list(map(int,input().split())) s=[] u=n for i in range(1,n+1): u-=2 for j in range(m+1): s.append(m*i+u*j) if k in s: print("Yes") else: print("No")
7
11
172
182
n, m, k = list(map(int, input().split())) for i in range(n + 1): for j in range(m + 1): if m * i + n * j - 2 * (i * j) == k: print("Yes") exit() print("No")
n, m, k = list(map(int, input().split())) s = [] u = n for i in range(1, n + 1): u -= 2 for j in range(m + 1): s.append(m * i + u * j) if k in s: print("Yes") else: print("No")
false
36.363636
[ "-for i in range(n + 1):", "+s = []", "+u = n", "+for i in range(1, n + 1):", "+ u -= 2", "- if m * i + n * j - 2 * (i * j) == k:", "- print(\"Yes\")", "- exit()", "-print(\"No\")", "+ s.append(m * i + u * j)", "+if k in s:", "+ print(\"Yes\")", "+el...
false
0.035863
0.03619
0.990947
[ "s821458987", "s216121361" ]
u982896977
p03494
python
s980993319
s226277045
21
19
2,940
3,060
Accepted
Accepted
9.52
n = int(eval(input())) a = [int(i) for i in input().split()] ans = 10**10 for i in range(n): counter = 0 while a[i] % 2 == 0: a[i] /= 2 counter += 1 if counter <= ans: ans = counter print(ans)
n = int(eval(input())) A = list(map(int,input().split())) counter = 0 breaker = 0 while True: for i in range(n): if A[i]%2 == 0: A[i] = A[i] // 2 else: breaker = 1 if breaker == 0: counter += 1 else: break print(counter)
11
15
205
245
n = int(eval(input())) a = [int(i) for i in input().split()] ans = 10**10 for i in range(n): counter = 0 while a[i] % 2 == 0: a[i] /= 2 counter += 1 if counter <= ans: ans = counter print(ans)
n = int(eval(input())) A = list(map(int, input().split())) counter = 0 breaker = 0 while True: for i in range(n): if A[i] % 2 == 0: A[i] = A[i] // 2 else: breaker = 1 if breaker == 0: counter += 1 else: break print(counter)
false
26.666667
[ "-a = [int(i) for i in input().split()]", "-ans = 10**10", "-for i in range(n):", "- counter = 0", "- while a[i] % 2 == 0:", "- a[i] /= 2", "+A = list(map(int, input().split()))", "+counter = 0", "+breaker = 0", "+while True:", "+ for i in range(n):", "+ if A[i] % 2 == 0...
false
0.059344
0.071082
0.834864
[ "s980993319", "s226277045" ]
u598699652
p03846
python
s311107348
s609392518
113
65
14,768
14,008
Accepted
Accepted
42.48
N = int(eval(input())) evenFlg = False flg = False lastIndex = int((N - (N % 2))/2) if N % 2 == 0: evenFlg = True ary = [2 for i in range(lastIndex)] l = list(map(int, input().split())) # for i in range(lastIndex): # ary.append(2) if not evenFlg: ary.insert(0, 1) for r in range(N): if evenFlg: ...
N = int(eval(input())) A = list(map(int, input().split())) ans = pow(2, N // 2) # 0*1 2*2 4*2 2^N/2*2 check = [0 for p in range(0, N // 2 + N % 2)] for o in A: check[o // 2] += 1 for q in range(0, N // 2 + N % 2): if q == 0 and N % 2 == 1: if check[q] != 1: ans = 0 b...
26
18
561
427
N = int(eval(input())) evenFlg = False flg = False lastIndex = int((N - (N % 2)) / 2) if N % 2 == 0: evenFlg = True ary = [2 for i in range(lastIndex)] l = list(map(int, input().split())) # for i in range(lastIndex): # ary.append(2) if not evenFlg: ary.insert(0, 1) for r in range(N): if evenFlg: l...
N = int(eval(input())) A = list(map(int, input().split())) ans = pow(2, N // 2) # 0*1 2*2 4*2 2^N/2*2 check = [0 for p in range(0, N // 2 + N % 2)] for o in A: check[o // 2] += 1 for q in range(0, N // 2 + N % 2): if q == 0 and N % 2 == 1: if check[q] != 1: ans = 0 break else...
false
30.769231
[ "-evenFlg = False", "-flg = False", "-lastIndex = int((N - (N % 2)) / 2)", "-if N % 2 == 0:", "- evenFlg = True", "-ary = [2 for i in range(lastIndex)]", "-l = list(map(int, input().split()))", "-# for i in range(lastIndex):", "-# ary.append(2)", "-if not evenFlg:", "- ary.insert(0, 1)",...
false
0.06179
0.082769
0.746541
[ "s311107348", "s609392518" ]
u546285759
p00136
python
s079799982
s956610618
30
20
7,760
7,652
Accepted
Accepted
33.33
h = [float(eval(input())) for _ in range(int(eval(input())))] d = {"1": ":","2": ":","3": ":","4": ":","5": ":","6": ":"} for v in h: if v < 165.0: d["1"] += "*" elif v >= 165.0 and v < 170.0: d["2"] += "*" elif v >= 170.0 and v < 175.0: d["3"] += "*" elif v >= 175.0 and...
n = int(eval(input())) data = {k: 0 for k in range(1, 7)} for _ in range(n): tmp = float(eval(input())) if tmp < 165.0: data[1] += 1 elif 165.0 <= tmp < 170.0: data[2] += 1 elif 170.0 <= tmp < 175.0: data[3] += 1 elif 175.0 <= tmp < 180.0: data[4] += 1 ...
18
19
510
456
h = [float(eval(input())) for _ in range(int(eval(input())))] d = {"1": ":", "2": ":", "3": ":", "4": ":", "5": ":", "6": ":"} for v in h: if v < 165.0: d["1"] += "*" elif v >= 165.0 and v < 170.0: d["2"] += "*" elif v >= 170.0 and v < 175.0: d["3"] += "*" elif v >= 175.0 and v <...
n = int(eval(input())) data = {k: 0 for k in range(1, 7)} for _ in range(n): tmp = float(eval(input())) if tmp < 165.0: data[1] += 1 elif 165.0 <= tmp < 170.0: data[2] += 1 elif 170.0 <= tmp < 175.0: data[3] += 1 elif 175.0 <= tmp < 180.0: data[4] += 1 elif 180.0 ...
false
5.263158
[ "-h = [float(eval(input())) for _ in range(int(eval(input())))]", "-d = {\"1\": \":\", \"2\": \":\", \"3\": \":\", \"4\": \":\", \"5\": \":\", \"6\": \":\"}", "-for v in h:", "- if v < 165.0:", "- d[\"1\"] += \"*\"", "- elif v >= 165.0 and v < 170.0:", "- d[\"2\"] += \"*\"", "- ...
false
0.043861
0.046211
0.949147
[ "s079799982", "s956610618" ]
u352394527
p00484
python
s733108918
s465156517
500
410
6,324
6,320
Accepted
Accepted
18
def solve(): n, k = list(map(int,input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [[0] for i in range(group_num)] for i in range(n): c, g = list(map(int,input().split())) book_map[g - 1].append(c) for i in range(group_num): bmi = book_map[i] ...
def solve(): n, k = list(map(int,input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [] for i in range(n): c, g = list(map(int,input().split())) book_map[g - 1].append(c) for i in range(group_num): bmi = book_map[i] bmi.sort(reverse=True) ...
30
29
765
760
def solve(): n, k = list(map(int, input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [[0] for i in range(group_num)] for i in range(n): c, g = list(map(int, input().split())) book_map[g - 1].append(c) for i in range(group_num): bmi = book...
def solve(): n, k = list(map(int, input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [] for i in range(n): c, g = list(map(int, input().split())) book_map[g - 1].append(c) for i in range(group_num): bmi = book_map[i] bmi.sort(reve...
false
3.333333
[ "- acc_map = [[0] for i in range(group_num)]", "+ acc_map = []", "- ami = acc_map[i]", "- acc = 0", "+ ami = [0 for i in range(len(bmi) + 1)]", "- acc += bmi[j] + j * 2", "- ami.append(acc)", "+ ami[j + 1] = ami[j] + bmi[j] + j * 2", "+ ...
false
0.037159
0.035399
1.049728
[ "s733108918", "s465156517" ]