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
u906501980
p02659
python
s509176669
s206633776
482
28
88,824
9,916
Accepted
Accepted
94.19
from decimal import Decimal as dec def main(): a, b = list(map(dec, input().split())) print((int(dec(a*b)))) if __name__ == "__main__": main()
from decimal import Decimal as dec def main(): a, b = list(map(dec, input().split())) print((int(a*b))) if __name__ == "__main__": main()
8
9
155
156
from decimal import Decimal as dec def main(): a, b = list(map(dec, input().split())) print((int(dec(a * b)))) if __name__ == "__main__": main()
from decimal import Decimal as dec def main(): a, b = list(map(dec, input().split())) print((int(a * b))) if __name__ == "__main__": main()
false
11.111111
[ "- print((int(dec(a * b))))", "+ print((int(a * b)))" ]
false
0.04526
0.038991
1.160776
[ "s509176669", "s206633776" ]
u813102292
p03262
python
s831117062
s187058860
405
247
15,020
63,768
Accepted
Accepted
39.01
n,s = (int(i) for i in input().split()) x = list(int(i) for i in input().split()) x = sorted(x) if n>1: dif = [] for i in range(n-1): dif.append(x[i+1]-x[i]) difs = [] for i in range(n): difs.append(abs(s-x[i])) res = min(min(dif),min(difs)) for i in range(res): ...
N, X = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() dist = [abs(x[0]-X)] for i in range(N - 1): dist.append(x[i + 1] - x[i]) # dist内の最大公約数を求めればよい def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) res = dist[0] for i in range(1, N): ...
25
18
578
355
n, s = (int(i) for i in input().split()) x = list(int(i) for i in input().split()) x = sorted(x) if n > 1: dif = [] for i in range(n - 1): dif.append(x[i + 1] - x[i]) difs = [] for i in range(n): difs.append(abs(s - x[i])) res = min(min(dif), min(difs)) for i in range(res): ...
N, X = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() dist = [abs(x[0] - X)] for i in range(N - 1): dist.append(x[i + 1] - x[i]) # dist内の最大公約数を求めればよい def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) res = dist[0] for i in range(1, N): res = gc...
false
28
[ "-n, s = (int(i) for i in input().split())", "-x = list(int(i) for i in input().split())", "-x = sorted(x)", "-if n > 1:", "- dif = []", "- for i in range(n - 1):", "- dif.append(x[i + 1] - x[i])", "- difs = []", "- for i in range(n):", "- difs.append(abs(s - x[i]))", "...
false
0.051176
0.041762
1.225438
[ "s831117062", "s187058860" ]
u440985596
p03061
python
s174887346
s127522596
252
179
63,984
16,568
Accepted
Accepted
28.97
import sys import math def gcd(a, b): while b: a, b = b, a % b return a def input(): return sys.stdin.readline()[:-1] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def MA...
import sys import fractions def input(): return sys.stdin.readline()[:-1] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def MAT(h): return [list(map(int, input().split())) for _ ...
39
35
936
914
import sys import math def gcd(a, b): while b: a, b = b, a % b return a def input(): return sys.stdin.readline()[:-1] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(ma...
import sys import fractions def input(): return sys.stdin.readline()[:-1] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def MAT(h): return [list(map(in...
false
10.25641
[ "-import math", "-", "-", "-def gcd(a, b):", "- while b:", "- a, b = b, a % b", "- return a", "+import fractions", "- L[i + 1] = gcd(L[i], A[i])", "- R[N - i - 2] = gcd(R[N - i - 1], A[N - i - 1])", "+ L[i + 1] = fractions.gcd(L[i], A[i])", "+ R[N - i -...
false
0.03281
0.12708
0.258187
[ "s174887346", "s127522596" ]
u771007149
p02888
python
s168117093
s887927612
1,459
1,005
3,188
9,296
Accepted
Accepted
31.12
import bisect n = int(eval(input())) l = list(map(int,input().split())) cnt = 0 l.sort() for i in range(n): for j in range(i+1,n): k = bisect.bisect_left(l,l[i]+l[j]) if k > j: cnt += k - j - 1 else: pass print(cnt)
n = int(eval(input())) l = list(map(int,input().split())) import bisect l.sort() cnt = 0 for i in range(n): for j in range(i+1,n): idx = bisect.bisect_left(l,l[i]+l[j]) #print('idx',idx) if j < idx: cnt += idx - j - 1 print(cnt)
15
15
289
279
import bisect n = int(eval(input())) l = list(map(int, input().split())) cnt = 0 l.sort() for i in range(n): for j in range(i + 1, n): k = bisect.bisect_left(l, l[i] + l[j]) if k > j: cnt += k - j - 1 else: pass print(cnt)
n = int(eval(input())) l = list(map(int, input().split())) import bisect l.sort() cnt = 0 for i in range(n): for j in range(i + 1, n): idx = bisect.bisect_left(l, l[i] + l[j]) # print('idx',idx) if j < idx: cnt += idx - j - 1 print(cnt)
false
0
[ "+n = int(eval(input()))", "+l = list(map(int, input().split()))", "-n = int(eval(input()))", "-l = list(map(int, input().split()))", "+l.sort()", "-l.sort()", "- k = bisect.bisect_left(l, l[i] + l[j])", "- if k > j:", "- cnt += k - j - 1", "- else:", "- ...
false
0.120292
0.039224
3.066767
[ "s168117093", "s887927612" ]
u588354469
p00741
python
s505532973
s255738192
190
170
9,720
7,840
Accepted
Accepted
10.53
import sys from pprint import pprint class UnionFind: def __init__(self): self._parent = {} self._rank = {} self._equiv = {} def _find(self, x): if self._parent[x] == x: return self._parent[x] else: p = self._find(self._parent[...
import sys from pprint import pprint class UnionFind: def __init__(self): self._parent = {} self._rank = {} self._equiv = {} def _find(self, x): if self._parent[x] == x: return self._parent[x] else: p = self._find(self._parent[...
99
99
2,610
2,550
import sys from pprint import pprint class UnionFind: def __init__(self): self._parent = {} self._rank = {} self._equiv = {} def _find(self, x): if self._parent[x] == x: return self._parent[x] else: p = self._find(self._parent[x]) se...
import sys from pprint import pprint class UnionFind: def __init__(self): self._parent = {} self._rank = {} self._equiv = {} def _find(self, x): if self._parent[x] == x: return self._parent[x] else: p = self._find(self._parent[x]) se...
false
0
[ "-def solve(ncol, nrow, rows):", "- pairs = []", "+def pairs(ncol, nrow):", "- pairs.append([(x, y), (x + 1, y)])", "+ yield [(x, y), (x + 1, y)]", "- pairs.append([(x, y), (x, y + 1)])", "+ yield [(x, y), (x, y + 1)]", "- pairs.append([(x, y),...
false
0.044113
0.044262
0.996643
[ "s505532973", "s255738192" ]
u775681539
p03353
python
s905800452
s121427773
1,261
21
3,984
3,064
Accepted
Accepted
98.33
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(1000000) def main(): s = readline().rstrip().decode() K = int(readline()) #sに含まれる文字を一文字ずつ抽出する. #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく #K<=5だから高々26^5個の文字列を構成す...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(1000000) def main(): s = readline().rstrip().decode() K = int(readline()) #sに含まれる文字を一文字ずつ抽出する. #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく #K<=5だから高々26^5個の文字列を構成す...
29
29
750
757
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(1000000) def main(): s = readline().rstrip().decode() K = int(readline()) # sに含まれる文字を一文字ずつ抽出する. # ここで抽出した文字を組み合わせて辞書順に文字列を構成していく # K<=5だから高々26^5個の文字列を構成することになる...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(1000000) def main(): s = readline().rstrip().decode() K = int(readline()) # sに含まれる文字を一文字ずつ抽出する. # ここで抽出した文字を組み合わせて辞書順に文字列を構成していく # K<=5だから高々26^5個の文字列を構成することになる...
false
0
[ "- f(nx)", "+ return f(nx)" ]
false
0.097007
0.048079
2.017672
[ "s905800452", "s121427773" ]
u363610900
p03556
python
s664072793
s494643759
25
17
2,940
2,940
Accepted
Accepted
32
N = int(eval(input())) num = 0 for i in range(1,100000000): if i*i> N: break else: num = i*i print(num)
N = int(eval(input())) num = int(N**(1/2)) print((num **2))
8
3
128
53
N = int(eval(input())) num = 0 for i in range(1, 100000000): if i * i > N: break else: num = i * i print(num)
N = int(eval(input())) num = int(N ** (1 / 2)) print((num**2))
false
62.5
[ "-num = 0", "-for i in range(1, 100000000):", "- if i * i > N:", "- break", "- else:", "- num = i * i", "-print(num)", "+num = int(N ** (1 / 2))", "+print((num**2))" ]
false
0.038627
0.036146
1.068629
[ "s664072793", "s494643759" ]
u948524308
p02761
python
s607352821
s625812652
21
18
3,316
3,064
Accepted
Accepted
14.29
N,M=list(map(int,input().split())) C=[-1]*N for i in range(M): s,c=list(map(int,input().split())) if C[s-1]==-1: C[s-1]=c elif C[s-1]!=-1: if C[s-1]!=c: print((-1)) exit() if N==1 and C[0]==0: print((0)) exit() if N==1 and C[0]==-1: p...
N,M=list(map(int,input().split())) S=[] C=[] for i in range(M): s,c=list(map(int,input().split())) S.append(s-1) C.append(c) for n in range(1000): ns=str(n) nl=list(ns) if len(ns)!=N: continue f=True for m in range(M): if nl[int(S[m])]!=str(C[m]): ...
36
27
565
412
N, M = list(map(int, input().split())) C = [-1] * N for i in range(M): s, c = list(map(int, input().split())) if C[s - 1] == -1: C[s - 1] = c elif C[s - 1] != -1: if C[s - 1] != c: print((-1)) exit() if N == 1 and C[0] == 0: print((0)) exit() if N == 1 and C[0...
N, M = list(map(int, input().split())) S = [] C = [] for i in range(M): s, c = list(map(int, input().split())) S.append(s - 1) C.append(c) for n in range(1000): ns = str(n) nl = list(ns) if len(ns) != N: continue f = True for m in range(M): if nl[int(S[m])] != str(C[m]): ...
false
25
[ "-C = [-1] * N", "+S = []", "+C = []", "- if C[s - 1] == -1:", "- C[s - 1] = c", "- elif C[s - 1] != -1:", "- if C[s - 1] != c:", "- print((-1))", "- exit()", "-if N == 1 and C[0] == 0:", "- print((0))", "- exit()", "-if N == 1 and C[0] == -1:"...
false
0.040545
0.039568
1.024691
[ "s607352821", "s625812652" ]
u366482170
p02900
python
s092475675
s467154210
257
235
5,044
3,064
Accepted
Accepted
8.56
#import sys #input = sys.stdin.readline #import heapq import math import fractions def sosuhante(n): for k in range(2, int(math.sqrt(n))+1): if n% k ==0: return False return True def main(): # h,w,a,b = map(int, input().split()) a,b=list(map(int,input().split())) ...
#import sys #input = sys.stdin.readline #import heapq import math #import fractions def sosuhante(n): for k in range(2, int(math.sqrt(n))+1): if n% k ==0: return False return True def main(): # h,w,a,b = map(int, input().split()) a,b=list(map(int,input().split())) ...
59
57
1,080
1,011
# import sys # input = sys.stdin.readline # import heapq import math import fractions def sosuhante(n): for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def main(): # h,w,a,b = map(int, input().split()) a, b = list(map(int, input().split())) ...
# import sys # input = sys.stdin.readline # import heapq import math # import fractions def sosuhante(n): for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def main(): # h,w,a,b = map(int, input().split()) a, b = list(map(int, input().split())) ...
false
3.389831
[ "-import fractions", "-", "+# import fractions", "- count = 1", "+ count = 0", "- sosu = set()", "+ sosu = {1}", "- if sosu == set() and a != 1:", "- sosu.add(a)", "- if sosuhante(a) and a != 1:", "+ if a != 1:" ]
false
0.037783
0.035717
1.057834
[ "s092475675", "s467154210" ]
u796942881
p03503
python
s701758337
s336403304
246
59
3,064
3,064
Accepted
Accepted
76.02
from sys import stdin input = stdin.readline MAX_TIME = 10 N = int(eval(input())) F = [[int(j) for j in input().split()] for i in range(N)] P = [[int(j) for j in input().split()] for i in range(N)] def main(): ans = -11000000001 # 営業時間帯 最低でも ひとつの時間帯 # 選択パターン for i in range(1, 2...
MAX_TIME = 10 N = int(eval(input())) F = [int(input().replace(" ", ""), 2) for i in range(N)] P = [[int(j) for j in input().split()] for i in range(N)] def main(): # 1 から 2 ** MAX_TIME - 1 # 営業時間帯 最低でも ひとつの時間帯 # 選択する時間帯を2進法で表現したもの # F[店のインデックス] # 他の店 # 選択する時間帯を2進法で表現したもの ...
34
28
587
503
from sys import stdin input = stdin.readline MAX_TIME = 10 N = int(eval(input())) F = [[int(j) for j in input().split()] for i in range(N)] P = [[int(j) for j in input().split()] for i in range(N)] def main(): ans = -11000000001 # 営業時間帯 最低でも ひとつの時間帯 # 選択パターン for i in range(1, 2**MAX_TIME): tm...
MAX_TIME = 10 N = int(eval(input())) F = [int(input().replace(" ", ""), 2) for i in range(N)] P = [[int(j) for j in input().split()] for i in range(N)] def main(): # 1 から 2 ** MAX_TIME - 1 # 営業時間帯 最低でも ひとつの時間帯 # 選択する時間帯を2進法で表現したもの # F[店のインデックス] # 他の店 # 選択する時間帯を2進法で表現したもの # P[店のインデックス][合致した...
false
17.647059
[ "-from sys import stdin", "-", "-input = stdin.readline", "-F = [[int(j) for j in input().split()] for i in range(N)]", "+F = [int(input().replace(\" \", \"\"), 2) for i in range(N)]", "- ans = -11000000001", "+ # 1 から 2 ** MAX_TIME - 1", "- # 選択パターン", "- for i in range(1, 2**MAX_TIME):"...
false
0.042584
0.143269
0.297228
[ "s701758337", "s336403304" ]
u094999522
p02862
python
s989427010
s386856888
125
89
9,556
73,072
Accepted
Accepted
28.8
#!/usr/bin/env python3 from functools import reduce x, y = list(map(int, input().split())) mod = 10**9 + 7 def cmb(n, r, m): def mul(a, b): return a * b % m r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, li...
#!/usr/bin/env python3 from functools import reduce x, y = list(map(int, input().split())) mod = 10**9 + 7 def cmb(n, r, m): def mul(a, b): return a * b % m r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, li...
27
27
506
501
#!/usr/bin/env python3 from functools import reduce x, y = list(map(int, input().split())) mod = 10**9 + 7 def cmb(n, r, m): def mul(a, b): return a * b % m 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...
#!/usr/bin/env python3 from functools import reduce x, y = list(map(int, input().split())) mod = 10**9 + 7 def cmb(n, r, m): def mul(a, b): return a * b % m 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...
false
0
[ "-if l * 2 + r * 1 in (x, y) and l >= 0:", "+if (x + y) % 3 < 1 and l >= 0:" ]
false
0.178707
0.151914
1.176371
[ "s989427010", "s386856888" ]
u418149936
p02837
python
s104556806
s550223447
1,273
276
9,228
9,196
Accepted
Accepted
78.32
N = int(eval(input())) testimo_ls = [ [] for i in range(N) ] rst = 0 for i in range(N): A = int(eval(input())) for j in range(A): x, y = list(map(int, input().split(' '))) testimo_ls[i].append([x - 1, y]) for i in range(1 << N): honest_ls = [] for j in range(N): if i >...
N = int(eval(input())) testimo_ls = [ [] for i in range(N) ] rst = 0 for i in range(N): A = int(eval(input())) for j in range(A): x, y = list(map(int, input().split(' '))) testimo_ls[i].append([x - 1, y]) for i in range(1 << N): honest_ls = [] for j in range(N): if i >...
23
25
650
696
N = int(eval(input())) testimo_ls = [[] for i in range(N)] rst = 0 for i in range(N): A = int(eval(input())) for j in range(A): x, y = list(map(int, input().split(" "))) testimo_ls[i].append([x - 1, y]) for i in range(1 << N): honest_ls = [] for j in range(N): if i >> j & 1: ...
N = int(eval(input())) testimo_ls = [[] for i in range(N)] rst = 0 for i in range(N): A = int(eval(input())) for j in range(A): x, y = list(map(int, input().split(" "))) testimo_ls[i].append([x - 1, y]) for i in range(1 << N): honest_ls = [] for j in range(N): if i >> j & 1: ...
false
8
[ "+ if t[0] not in honest_ls and t[1] == 1:", "+ is_ok = False", "+ break", "- if t[0] not in honest_ls and t[1] == 1:", "- is_ok = False", "+ break" ]
false
0.059861
0.035216
1.699818
[ "s104556806", "s550223447" ]
u426649993
p03645
python
s823440534
s662858444
1,676
783
137,212
66,920
Accepted
Accepted
53.28
from collections import defaultdict from heapq import heappop, heappush class Graph(object): """ 隣接リストによる有向グラフ """ def __init__(self): self.graph = defaultdict(list) def __len__(self): return len(self.graph) def add_edge(self, src, dst, weight=1): sel...
from collections import defaultdict def main(): N, M = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(M)] g = defaultdict(list) for n in ab: g[n[0]].append(n[1]) if 1 not in g: print('IMPOSSIBLE') exit() for i in...
89
29
2,070
545
from collections import defaultdict from heapq import heappop, heappush class Graph(object): """ 隣接リストによる有向グラフ """ def __init__(self): self.graph = defaultdict(list) def __len__(self): return len(self.graph) def add_edge(self, src, dst, weight=1): self.graph[src].app...
from collections import defaultdict def main(): N, M = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(M)] g = defaultdict(list) for n in ab: g[n[0]].append(n[1]) if 1 not in g: print("IMPOSSIBLE") exit() for i in g[1]: if i ...
false
67.41573
[ "-from heapq import heappop, heappush", "-class Graph(object):", "- \"\"\"", "- 隣接リストによる有向グラフ", "- \"\"\"", "-", "- def __init__(self):", "- self.graph = defaultdict(list)", "-", "- def __len__(self):", "- return len(self.graph)", "-", "- def add_edge(self, sr...
false
0.042367
0.055936
0.757416
[ "s823440534", "s662858444" ]
u867503285
p02263
python
s392088937
s839411339
30
20
7,544
7,424
Accepted
Accepted
33.33
s=[] p=s.pop for e in input().split(): s+=[e if e.isdigit() else str(eval(p(-2)+e+p()))] print((*s))
s=[] p=s.pop for e in input().split(): s+=[str(eval(p(-2)+e+p()))if e in'*+-'else e] print((*s))
5
5
103
99
s = [] p = s.pop for e in input().split(): s += [e if e.isdigit() else str(eval(p(-2) + e + p()))] print((*s))
s = [] p = s.pop for e in input().split(): s += [str(eval(p(-2) + e + p())) if e in "*+-" else e] print((*s))
false
0
[ "- s += [e if e.isdigit() else str(eval(p(-2) + e + p()))]", "+ s += [str(eval(p(-2) + e + p())) if e in \"*+-\" else e]" ]
false
0.066531
0.05067
1.31302
[ "s392088937", "s839411339" ]
u546285759
p00008
python
s824796120
s153120972
150
60
7,560
5,592
Accepted
Accepted
60
r = range while True: try: n = int(eval(input())) ans = [] ans = [(a,b,c,d) for a in r(10) for b in r(10) for c in r(10) for d in r(10) if a+b+c+d==n and (a,b,c,d) not in ans] print((len(ans))) except: break
while True: try: n = int(eval(input())) except: break ans = 0 for a in range(10): for b in range(10): for c in range(10): d = n - (a + b + c) ans += 0 <= d <= 9 print(ans)
9
13
255
267
r = range while True: try: n = int(eval(input())) ans = [] ans = [ (a, b, c, d) for a in r(10) for b in r(10) for c in r(10) for d in r(10) if a + b + c + d == n and (a, b, c, d) not in ans ] print((len(a...
while True: try: n = int(eval(input())) except: break ans = 0 for a in range(10): for b in range(10): for c in range(10): d = n - (a + b + c) ans += 0 <= d <= 9 print(ans)
false
30.769231
[ "-r = range", "- ans = []", "- ans = [", "- (a, b, c, d)", "- for a in r(10)", "- for b in r(10)", "- for c in r(10)", "- for d in r(10)", "- if a + b + c + d == n and (a, b, c, d) not in ans", "- ]", "- ...
false
0.043925
0.042669
1.029427
[ "s824796120", "s153120972" ]
u297089927
p02753
python
s761951566
s632296941
182
17
38,256
3,064
Accepted
Accepted
90.66
S=eval(input()) if S == "AAA" or S == "BBB": print("No") else: print("Yes")
s=eval(input()) if s=="AAA" or s=="BBB": print("No") else: print("Yes")
5
5
77
73
S = eval(input()) if S == "AAA" or S == "BBB": print("No") else: print("Yes")
s = eval(input()) if s == "AAA" or s == "BBB": print("No") else: print("Yes")
false
0
[ "-S = eval(input())", "-if S == \"AAA\" or S == \"BBB\":", "+s = eval(input())", "+if s == \"AAA\" or s == \"BBB\":" ]
false
0.039509
0.008136
4.855929
[ "s761951566", "s632296941" ]
u189326411
p02720
python
s572815843
s211286688
1,029
129
12,480
15,780
Accepted
Accepted
87.46
import queue k = int(eval(input())) q = queue.Queue() num = 0 for i in range(1,10): q.put(i) while num<k: i = q.get() l = i%10 if l!=0: q.put(i*10+l-1) q.put(i*10+l) if l!=9: q.put(i*10+l+1) num += 1 print(i)
k = int(eval(input())) lst = [1,2,3,4,5,6,7,8,9] count = 0 for i in range(k): num = lst[count] if num%10!=0: lst.append(num*10+num%10-1) lst.append(num*10+num%10) if num%10!=9: lst.append(num*10+num%10+1) count += 1 print((lst[k-1]))
19
15
268
279
import queue k = int(eval(input())) q = queue.Queue() num = 0 for i in range(1, 10): q.put(i) while num < k: i = q.get() l = i % 10 if l != 0: q.put(i * 10 + l - 1) q.put(i * 10 + l) if l != 9: q.put(i * 10 + l + 1) num += 1 print(i)
k = int(eval(input())) lst = [1, 2, 3, 4, 5, 6, 7, 8, 9] count = 0 for i in range(k): num = lst[count] if num % 10 != 0: lst.append(num * 10 + num % 10 - 1) lst.append(num * 10 + num % 10) if num % 10 != 9: lst.append(num * 10 + num % 10 + 1) count += 1 print((lst[k - 1]))
false
21.052632
[ "-import queue", "-", "-q = queue.Queue()", "-num = 0", "-for i in range(1, 10):", "- q.put(i)", "-while num < k:", "- i = q.get()", "- l = i % 10", "- if l != 0:", "- q.put(i * 10 + l - 1)", "- q.put(i * 10 + l)", "- if l != 9:", "- q.put(i * 10 + l + 1)", ...
false
0.2561
0.125238
2.044903
[ "s572815843", "s211286688" ]
u543954314
p02644
python
s712603588
s384450699
1,996
1,578
38,280
36,768
Accepted
Accepted
20.94
import sys from collections import deque readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: list(map(int, readline().split())) nl = lambda: list(map(int, readline().split())) def solve(): h, w, k = nm() sy, s...
import sys from collections import deque readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: list(map(int, readline().split())) nl = lambda: list(map(int, readline().split())) def solve(): h, w, k = nm() sy, s...
40
42
1,119
1,197
import sys from collections import deque readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: list(map(int, readline().split())) nl = lambda: list(map(int, readline().split())) def solve(): h, w, k = nm() sy, sx, gy, gx = n...
import sys from collections import deque readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: list(map(int, readline().split())) nl = lambda: list(map(int, readline().split())) def solve(): h, w, k = nm() sy, sx, gy, gx = n...
false
4.761905
[ "- ans = G[gy][gx]", "- print((ans if ans < 10**7 else -1))", "+ if ny == gy and nx == gx:", "+ print((G[y][x] + 1))", "+ return", "+ print((-1))" ]
false
0.036264
0.037905
0.95671
[ "s712603588", "s384450699" ]
u492910842
p03309
python
s008328521
s963289456
1,085
135
104,248
104,388
Accepted
Accepted
87.56
n=int(eval(input())) a=list(map(int,input().split())) dp=[0]*n for i in range(n): dp[i]=a[i]-i dp.sort() ans=0 for j in range(n): ans+=abs(dp[j]-dp[n//2]) print(ans)
n=int(eval(input())) a=list(map(int,input().split())) dp=[0]*n for i in range(n): dp[i]=a[i]-i dp.sort() print((sum(abs(x-dp[n//2]) for x in dp)))
10
7
173
146
n = int(eval(input())) a = list(map(int, input().split())) dp = [0] * n for i in range(n): dp[i] = a[i] - i dp.sort() ans = 0 for j in range(n): ans += abs(dp[j] - dp[n // 2]) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) dp = [0] * n for i in range(n): dp[i] = a[i] - i dp.sort() print((sum(abs(x - dp[n // 2]) for x in dp)))
false
30
[ "-ans = 0", "-for j in range(n):", "- ans += abs(dp[j] - dp[n // 2])", "-print(ans)", "+print((sum(abs(x - dp[n // 2]) for x in dp)))" ]
false
0.15958
0.036267
4.400121
[ "s008328521", "s963289456" ]
u729133443
p03125
python
s274150063
s954430257
169
26
38,256
9,128
Accepted
Accepted
84.62
a,b=list(map(int,input().split()));print(((b-a)*(b%a>0)or a+b))
a,b=list(map(int,input().split())) print((a+b-2*a*(b%a>0)))
1
2
55
52
a, b = list(map(int, input().split())) print(((b - a) * (b % a > 0) or a + b))
a, b = list(map(int, input().split())) print((a + b - 2 * a * (b % a > 0)))
false
50
[ "-print(((b - a) * (b % a > 0) or a + b))", "+print((a + b - 2 * a * (b % a > 0)))" ]
false
0.056127
0.035478
1.582031
[ "s274150063", "s954430257" ]
u299869545
p02913
python
s891626186
s359592158
859
187
245,768
4,144
Accepted
Accepted
78.23
n = int(eval(input())) s = eval(input()) dp = [[0 if max(i,j) == n else -1 for i in range(n+1)] for j in range(n+1)] ans = 0 for i in range(n-1, -1, -1): for j in range(n-1, i, -1): if s[i] == s[j]:dp[i][j] = dp[i+1][j+1] + 1 else: dp[i][j] = 0 ans = max(ans, min(dp[i][j], j-i)) ...
n = int(eval(input())) s = eval(input()) MOD = 10 ** 18 + 7 A = 123456 def ok(l): rolling_hash = 0 strings = {} for i in range(n): rolling_hash *= A rolling_hash += ord(s[i]) if i - l >= 0: rolling_hash -= ord(s[i-l]) * pow(A, l, MOD) rolling_hash %= MOD ...
13
33
321
738
n = int(eval(input())) s = eval(input()) dp = [[0 if max(i, j) == n else -1 for i in range(n + 1)] for j in range(n + 1)] ans = 0 for i in range(n - 1, -1, -1): for j in range(n - 1, i, -1): if s[i] == s[j]: dp[i][j] = dp[i + 1][j + 1] + 1 else: dp[i][j] = 0 ans = max...
n = int(eval(input())) s = eval(input()) MOD = 10**18 + 7 A = 123456 def ok(l): rolling_hash = 0 strings = {} for i in range(n): rolling_hash *= A rolling_hash += ord(s[i]) if i - l >= 0: rolling_hash -= ord(s[i - l]) * pow(A, l, MOD) rolling_hash %= MOD ...
false
60.606061
[ "-dp = [[0 if max(i, j) == n else -1 for i in range(n + 1)] for j in range(n + 1)]", "-ans = 0", "-for i in range(n - 1, -1, -1):", "- for j in range(n - 1, i, -1):", "- if s[i] == s[j]:", "- dp[i][j] = dp[i + 1][j + 1] + 1", "- else:", "- dp[i][j] = 0", "- ...
false
0.040068
0.051951
0.771263
[ "s891626186", "s359592158" ]
u644907318
p03463
python
s527200669
s601790722
179
62
38,384
61,716
Accepted
Accepted
65.36
N,A,B = list(map(int,input().split())) if abs(A-B)%2==0: print("Alice") else: print("Borys")
N,A,B = list(map(int,input().split())) if (B-A)%2==0: print("Alice") else: print("Borys")
5
5
98
95
N, A, B = list(map(int, input().split())) if abs(A - B) % 2 == 0: print("Alice") else: print("Borys")
N, A, B = list(map(int, input().split())) if (B - A) % 2 == 0: print("Alice") else: print("Borys")
false
0
[ "-if abs(A - B) % 2 == 0:", "+if (B - A) % 2 == 0:" ]
false
0.041976
0.039055
1.074779
[ "s527200669", "s601790722" ]
u191635495
p02623
python
s305843964
s892134174
501
341
53,712
47,612
Accepted
Accepted
31.94
# Tsundoku import numpy as np N, M, K = list(map(int,input().split())) A = np.array([0] + list(map(int, input().split()))) B = np.array([0] + list(map(int, input().split()))) a = np.cumsum(A) b = np.cumsum(B) ans = 0 j = M for i in range(N+1): if a[i] > K: break while b[j] > K - a[i]: ...
# Tsundoku N,M,K = list(map(int,input().split())) A = list(map(int,input().split())) B = list(map(int,input().split())) if M > N: N,M = M,N A,B = B,A a = [0] b = [0] for _ in range(max(N, M)): if _ < min(N,M): a.append(a[_] + A[_]) b.append(b[_] + B[_]) else: a.appe...
19
24
370
481
# Tsundoku import numpy as np N, M, K = list(map(int, input().split())) A = np.array([0] + list(map(int, input().split()))) B = np.array([0] + list(map(int, input().split()))) a = np.cumsum(A) b = np.cumsum(B) ans = 0 j = M for i in range(N + 1): if a[i] > K: break while b[j] > K - a[i]: j -= 1...
# Tsundoku N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) if M > N: N, M = M, N A, B = B, A a = [0] b = [0] for _ in range(max(N, M)): if _ < min(N, M): a.append(a[_] + A[_]) b.append(b[_] + B[_]) else: a.append(a...
false
20.833333
[ "-import numpy as np", "-", "-A = np.array([0] + list(map(int, input().split())))", "-B = np.array([0] + list(map(int, input().split())))", "-a = np.cumsum(A)", "-b = np.cumsum(B)", "+A = list(map(int, input().split()))", "+B = list(map(int, input().split()))", "+if M > N:", "+ N, M = M, N", ...
false
0.235979
0.006934
34.030478
[ "s305843964", "s892134174" ]
u864197622
p02900
python
s391703447
s324232192
90
22
3,188
3,192
Accepted
Accepted
75.56
def primeFactor(N): i, n, ret, d, sq = 2, N, {}, 2, 99 while i <= sq: k = 0 while n % i == 0: n, k, ret[i] = n//i, k+1, k+1 if k > 0 or i == 97: sq = int(n**(1/2)+0.5) if i < 4: i = i * 2 - 1 else: i, d = i+d, d^6 if n > 1: ret[n] = 1 return ret def gc...
def primeFactor(N): i = 2 ret = {} n = N mrFlg = 0 while i**2 <= n: k = 0 while n % i == 0: n //= i k += 1 ret[i] = k i += 1 if i == 101 and n >= (2**20): def findFactorRho(N): def gcd(a, b)...
20
85
469
2,257
def primeFactor(N): i, n, ret, d, sq = 2, N, {}, 2, 99 while i <= sq: k = 0 while n % i == 0: n, k, ret[i] = n // i, k + 1, k + 1 if k > 0 or i == 97: sq = int(n ** (1 / 2) + 0.5) if i < 4: i = i * 2 - 1 else: i, d = i + d, ...
def primeFactor(N): i = 2 ret = {} n = N mrFlg = 0 while i**2 <= n: k = 0 while n % i == 0: n //= i k += 1 ret[i] = k i += 1 if i == 101 and n >= (2**20): def findFactorRho(N): def gcd(a, b): ...
false
76.470588
[ "- i, n, ret, d, sq = 2, N, {}, 2, 99", "- while i <= sq:", "+ i = 2", "+ ret = {}", "+ n = N", "+ mrFlg = 0", "+ while i**2 <= n:", "- n, k, ret[i] = n // i, k + 1, k + 1", "- if k > 0 or i == 97:", "- sq = int(n ** (1 / 2) + 0.5)", "- if...
false
0.038779
0.037162
1.043505
[ "s391703447", "s324232192" ]
u887207211
p03292
python
s530760679
s597399157
20
18
2,940
2,940
Accepted
Accepted
10
a, b, c = sorted(map(int,input().split())) print((b-a+c-b))
A, B, C = sorted(map(int,input().split())) print((C-B+B-A))
2
2
58
58
a, b, c = sorted(map(int, input().split())) print((b - a + c - b))
A, B, C = sorted(map(int, input().split())) print((C - B + B - A))
false
0
[ "-a, b, c = sorted(map(int, input().split()))", "-print((b - a + c - b))", "+A, B, C = sorted(map(int, input().split()))", "+print((C - B + B - A))" ]
false
0.042691
0.042481
1.004935
[ "s530760679", "s597399157" ]
u281610856
p02714
python
s083816690
s516501799
201
179
68,240
73,644
Accepted
Accepted
10.95
n = int(eval(input())) s = eval(input()) r = 0 g = 0 b = 0 for i in range(n): if s[i] == 'R': r += 1 elif s[i] == 'G': g += 1 else: b += 1 ans = r * b * g for c in range(n): center = s[c] for dif in range(n): if dif + c > n - 1 or c - dif < 0: ...
def main(): n = int(eval(input())) l = list(eval(input())) ans = l.count('R') * l.count('G') * l.count('B') for c in range(n): center = l[c] for dif in range(n): if dif + c > n - 1 or c - dif < 0: continue left = l[c - dif] ri...
26
18
482
480
n = int(eval(input())) s = eval(input()) r = 0 g = 0 b = 0 for i in range(n): if s[i] == "R": r += 1 elif s[i] == "G": g += 1 else: b += 1 ans = r * b * g for c in range(n): center = s[c] for dif in range(n): if dif + c > n - 1 or c - dif < 0: continue ...
def main(): n = int(eval(input())) l = list(eval(input())) ans = l.count("R") * l.count("G") * l.count("B") for c in range(n): center = l[c] for dif in range(n): if dif + c > n - 1 or c - dif < 0: continue left = l[c - dif] right = l[di...
false
30.769231
[ "-n = int(eval(input()))", "-s = eval(input())", "-r = 0", "-g = 0", "-b = 0", "-for i in range(n):", "- if s[i] == \"R\":", "- r += 1", "- elif s[i] == \"G\":", "- g += 1", "- else:", "- b += 1", "-ans = r * b * g", "-for c in range(n):", "- center = s[c...
false
0.044894
0.044835
1.001329
[ "s083816690", "s516501799" ]
u745561510
p03274
python
s515785795
s866351109
99
85
14,384
14,384
Accepted
Accepted
14.14
N, K = list(map(int, input().split())) x = list(map(int,input().split())) ans = 100000000000 #最初と最後だけ調べればOK for i in range(N - K + 1): tmp_min = x[i] tmp_max = x[i + K - 1] tmp = abs(tmp_min) + abs(tmp_min - tmp_max) tmp2 = abs(tmp_max) + abs(tmp_min - tmp_max) ans = min(ans, min(tmp, tmp...
N, K = list(map(int, input().split())) x = list(map(int,input().split())) ans = 100000000000 #最初と最後だけ調べればOK for i in range(N - K + 1): tmp_min = x[i] tmp_max = x[i + K - 1] ans = min(ans, min(abs(tmp_min), abs(tmp_max)) + abs(tmp_min - tmp_max)) print(ans)
15
13
336
279
N, K = list(map(int, input().split())) x = list(map(int, input().split())) ans = 100000000000 # 最初と最後だけ調べればOK for i in range(N - K + 1): tmp_min = x[i] tmp_max = x[i + K - 1] tmp = abs(tmp_min) + abs(tmp_min - tmp_max) tmp2 = abs(tmp_max) + abs(tmp_min - tmp_max) ans = min(ans, min(tmp, tmp2)) print...
N, K = list(map(int, input().split())) x = list(map(int, input().split())) ans = 100000000000 # 最初と最後だけ調べればOK for i in range(N - K + 1): tmp_min = x[i] tmp_max = x[i + K - 1] ans = min(ans, min(abs(tmp_min), abs(tmp_max)) + abs(tmp_min - tmp_max)) print(ans)
false
13.333333
[ "- tmp = abs(tmp_min) + abs(tmp_min - tmp_max)", "- tmp2 = abs(tmp_max) + abs(tmp_min - tmp_max)", "- ans = min(ans, min(tmp, tmp2))", "+ ans = min(ans, min(abs(tmp_min), abs(tmp_max)) + abs(tmp_min - tmp_max))" ]
false
0.044575
0.045934
0.970418
[ "s515785795", "s866351109" ]
u416011173
p02623
python
s046112971
s221877862
309
229
47,484
47,152
Accepted
Accepted
25.89
# -*- coding: utf-8 -*- # 標準入力を取得 N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) # 求解処理 a, b = [0], [0] for i in range(N): a.append(a[i] + A[i]) for j in range(M): b.append(b[j] + B[j]) ans, j = 0, M for i in range(N + 1): i...
# -*- coding: utf-8 -*- def get_input() -> tuple: """ 標準入力を取得する. Returns:\n tuple: 標準入力 """ N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) return N, M, K, A, B def main(N: int, M: int, K: int,...
23
52
440
1,053
# -*- coding: utf-8 -*- # 標準入力を取得 N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) # 求解処理 a, b = [0], [0] for i in range(N): a.append(a[i] + A[i]) for j in range(M): b.append(b[j] + B[j]) ans, j = 0, M for i in range(N + 1): if a[i] > K: ...
# -*- coding: utf-8 -*- def get_input() -> tuple: """ 標準入力を取得する. Returns:\n tuple: 標準入力 """ N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) return N, M, K, A, B def main(N: int, M: int, K: int, A: list, B: list) ...
false
55.769231
[ "-# 標準入力を取得", "-N, M, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-B = list(map(int, input().split()))", "-# 求解処理", "-a, b = [0], [0]", "-for i in range(N):", "- a.append(a[i] + A[i])", "-for j in range(M):", "- b.append(b[j] + B[j])", "-ans, j = 0, M", ...
false
0.041343
0.046747
0.884395
[ "s046112971", "s221877862" ]
u609061751
p03213
python
s388755563
s997534996
171
22
38,384
3,316
Accepted
Accepted
87.13
import sys input = sys.stdin.readline n = int(eval(input())) def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1)) + 1): if temp%i==0: cnt = 0 while temp%i==0: cnt += 1 temp //= i arr.append([i...
import sys input = lambda: sys.stdin.readline().rstrip() n = int(eval(input())) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += ...
57
61
1,073
1,259
import sys input = sys.stdin.readline n = int(eval(input())) def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i,...
import sys input = lambda: sys.stdin.readline().rstrip() n = int(eval(input())) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != ...
false
6.557377
[ "-input = sys.stdin.readline", "+input = lambda: sys.stdin.readline().rstrip()", "-def factorization(n):", "- arr = []", "- temp = n", "- for i in range(2, int(-(-(n**0.5) // 1)) + 1):", "- if temp % i == 0:", "- cnt = 0", "- while temp % i == 0:", "- ...
false
0.06311
0.044047
1.432787
[ "s388755563", "s997534996" ]
u875291233
p03175
python
s529705327
s982544975
761
533
100,528
99,760
Accepted
Accepted
29.96
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**7) MOD=10**9+7 n=int(eval(input())) edge=[[] for _ in range(n)] for _ in range(n-1): p,q = [int(i)-1 for i in input().split()] edge[p].append(q) edge[q].append(p) used = [0]*n def dfs(x): used[x] = 1 cb=...
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline n = int(eval(input())) #n,q = [int(i) for i in readline().split()] g = [[] for _ in range(n)] for i in range(n-1): a,b = [int(i) for i in readline().split()] g[a-1].append(b-1) g[b-1].app...
30
29
527
591
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**7) MOD = 10**9 + 7 n = int(eval(input())) edge = [[] for _ in range(n)] for _ in range(n - 1): p, q = [int(i) - 1 for i in input().split()] edge[p].append(q) edge[q].append(p) used = [0] * n def dfs(x): used[x] = 1 cb = 1 ...
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline n = int(eval(input())) # n,q = [int(i) for i in readline().split()] g = [[] for _ in range(n)] for i in range(n - 1): a, b = [int(i) for i in readline().split()] g[a - 1].append(b - 1) g[b - 1].append(a ...
false
3.333333
[ "-sys.setrecursionlimit(10**7)", "+sys.setrecursionlimit(10**6)", "+readline = sys.stdin.readline", "+n = int(eval(input()))", "+# n,q = [int(i) for i in readline().split()]", "+g = [[] for _ in range(n)]", "+for i in range(n - 1):", "+ a, b = [int(i) for i in readline().split()]", "+ g[a - 1]...
false
0.046729
0.078221
0.597394
[ "s529705327", "s982544975" ]
u301624971
p02713
python
s563366418
s481400917
1,843
693
9,176
9,200
Accepted
Accepted
62.4
from math import gcd K = int(eval(input())) total = 0 for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): total+=gcd(gcd(a,b),c) print(total)
import sys from math import gcd input = sys.stdin.readline def main(): K = int(eval(input())) total = 0 for a in range(1,K+1): for b in range(1,K+1): tmp = gcd(a,b) for c in range(1,K+1): total+=gcd(tmp,c) print(total) if __name__ == '__main__'...
8
14
183
327
from math import gcd K = int(eval(input())) total = 0 for a in range(1, K + 1): for b in range(1, K + 1): for c in range(1, K + 1): total += gcd(gcd(a, b), c) print(total)
import sys from math import gcd input = sys.stdin.readline def main(): K = int(eval(input())) total = 0 for a in range(1, K + 1): for b in range(1, K + 1): tmp = gcd(a, b) for c in range(1, K + 1): total += gcd(tmp, c) print(total) if __name__ == "__m...
false
42.857143
[ "+import sys", "-K = int(eval(input()))", "-total = 0", "-for a in range(1, K + 1):", "- for b in range(1, K + 1):", "- for c in range(1, K + 1):", "- total += gcd(gcd(a, b), c)", "-print(total)", "+input = sys.stdin.readline", "+", "+", "+def main():", "+ K = int(eva...
false
0.053617
0.085173
0.629508
[ "s563366418", "s481400917" ]
u599547273
p03457
python
s047314617
s789039521
434
251
3,188
3,188
Accepted
Accepted
42.17
import sys n = int(eval(input())) before_t, before_x, before_y = 0, 0, 0 for i in range(n): txy_strs = input().split() t, x, y = tuple(map(int, txy_strs)) movable = t - before_t min_move = abs(x - before_x) + abs(y - before_y) remaining = movable - min_move if 0 <= remaining and remaining % 2 == 0...
import sys n = int(sys.stdin.readline()) before_t, before_x, before_y = 0, 0, 0 for i in range(n): txy_strs = sys.stdin.readline().split() t, x, y = tuple(map(int, txy_strs)) movable = t - before_t min_move = abs(x - before_x) + abs(y - before_y) remaining = movable - min_move if 0 <= remaining a...
18
19
408
435
import sys n = int(eval(input())) before_t, before_x, before_y = 0, 0, 0 for i in range(n): txy_strs = input().split() t, x, y = tuple(map(int, txy_strs)) movable = t - before_t min_move = abs(x - before_x) + abs(y - before_y) remaining = movable - min_move if 0 <= remaining and remaining % 2 =...
import sys n = int(sys.stdin.readline()) before_t, before_x, before_y = 0, 0, 0 for i in range(n): txy_strs = sys.stdin.readline().split() t, x, y = tuple(map(int, txy_strs)) movable = t - before_t min_move = abs(x - before_x) + abs(y - before_y) remaining = movable - min_move if 0 <= remaining...
false
5.263158
[ "-n = int(eval(input()))", "+n = int(sys.stdin.readline())", "- txy_strs = input().split()", "+ txy_strs = sys.stdin.readline().split()" ]
false
0.082153
0.04275
1.921684
[ "s047314617", "s789039521" ]
u371763408
p03698
python
s309005904
s048290815
24
18
3,316
2,940
Accepted
Accepted
25
from collections import Counter s=Counter(eval(input())).most_common() for _,i in s: if i !=1: print('no') exit() print('yes')
s=eval(input()) if len(s) ==len(set(s)): print('yes') else: print('no')
7
5
137
73
from collections import Counter s = Counter(eval(input())).most_common() for _, i in s: if i != 1: print("no") exit() print("yes")
s = eval(input()) if len(s) == len(set(s)): print("yes") else: print("no")
false
28.571429
[ "-from collections import Counter", "-", "-s = Counter(eval(input())).most_common()", "-for _, i in s:", "- if i != 1:", "- print(\"no\")", "- exit()", "-print(\"yes\")", "+s = eval(input())", "+if len(s) == len(set(s)):", "+ print(\"yes\")", "+else:", "+ print(\"no\")...
false
0.06285
0.046217
1.359888
[ "s309005904", "s048290815" ]
u977389981
p03244
python
s580750132
s087484121
104
92
20,828
20,700
Accepted
Accepted
11.54
from collections import Counter n = int(eval(input())) num = list(map(int, input().split())) num1 = [] num2 = [] ans = 0 for i in range(0, n, 2): num1.append(num[i]) for i in range(1, n, 2): num2.append(num[i]) num1 = Counter(num1).most_common() num2 = Counter(num2).most_common() if ...
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) X = Counter([V[i] for i in range(0, n, 2)]).most_common() Y = Counter([V[i] for i in range(1, n, 2)]).most_common() ans = 0 if X[0][0] != Y[0][0]: ans = n - X[0][1] - Y[0][1] else: if len(X) == 1 and len(Y)...
32
24
764
612
from collections import Counter n = int(eval(input())) num = list(map(int, input().split())) num1 = [] num2 = [] ans = 0 for i in range(0, n, 2): num1.append(num[i]) for i in range(1, n, 2): num2.append(num[i]) num1 = Counter(num1).most_common() num2 = Counter(num2).most_common() if num1[0][0] != num2[0][0]: ...
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) X = Counter([V[i] for i in range(0, n, 2)]).most_common() Y = Counter([V[i] for i in range(1, n, 2)]).most_common() ans = 0 if X[0][0] != Y[0][0]: ans = n - X[0][1] - Y[0][1] else: if len(X) == 1 and len(Y) == 1: ...
false
25
[ "-num = list(map(int, input().split()))", "-num1 = []", "-num2 = []", "+V = list(map(int, input().split()))", "+X = Counter([V[i] for i in range(0, n, 2)]).most_common()", "+Y = Counter([V[i] for i in range(1, n, 2)]).most_common()", "-for i in range(0, n, 2):", "- num1.append(num[i])", "-for i i...
false
0.045169
0.045339
0.996257
[ "s580750132", "s087484121" ]
u867826040
p03262
python
s500748466
s689790251
73
67
20,612
20,416
Accepted
Accepted
8.22
from functools import reduce from math import gcd n,x = list(map(int,input().split())) a = list(map(int,input().split())) b = [] for ai in a: b.append(abs(ai-x)) print((reduce(gcd,b)))
from functools import reduce from math import gcd n,x = list(map(int,input().split())) a = list(map(int,input().split())) print((reduce(gcd,(abs(ai-x) for ai in a))))
8
5
187
162
from functools import reduce from math import gcd n, x = list(map(int, input().split())) a = list(map(int, input().split())) b = [] for ai in a: b.append(abs(ai - x)) print((reduce(gcd, b)))
from functools import reduce from math import gcd n, x = list(map(int, input().split())) a = list(map(int, input().split())) print((reduce(gcd, (abs(ai - x) for ai in a))))
false
37.5
[ "-b = []", "-for ai in a:", "- b.append(abs(ai - x))", "-print((reduce(gcd, b)))", "+print((reduce(gcd, (abs(ai - x) for ai in a))))" ]
false
0.086296
0.088192
0.978495
[ "s500748466", "s689790251" ]
u919730120
p02852
python
s189746695
s399580798
1,085
124
3,736
6,384
Accepted
Accepted
88.57
N,M=list(map(int,input().split())) S=eval(input()) ans='' i=N flg=0 while i>0: j=M if i-M<0: ans=str(i)+' '+ans i=0 else: while j>=0: if j>0 and S[i-j] == '0': ans=str(j)+' '+ans i-=j j=0 elif j==0: flg=1 i=0 j-=1 if flg==1:...
N,M=list(map(int,input().split())) S=eval(input()) i=N flg=0 ans=[] while i>0: j=M if i-M<0: ans.append(i) i=0 else: while j>=0: if j>0 and S[i-j] == '0': ans.append(j) i-=j j=0 elif j==0: flg=1 i=0 j-=1 if flg==1: print(...
24
24
342
343
N, M = list(map(int, input().split())) S = eval(input()) ans = "" i = N flg = 0 while i > 0: j = M if i - M < 0: ans = str(i) + " " + ans i = 0 else: while j >= 0: if j > 0 and S[i - j] == "0": ans = str(j) + " " + ans i -= j ...
N, M = list(map(int, input().split())) S = eval(input()) i = N flg = 0 ans = [] while i > 0: j = M if i - M < 0: ans.append(i) i = 0 else: while j >= 0: if j > 0 and S[i - j] == "0": ans.append(j) i -= j j = 0 el...
false
0
[ "-ans = \"\"", "+ans = []", "- ans = str(i) + \" \" + ans", "+ ans.append(i)", "- ans = str(j) + \" \" + ans", "+ ans.append(j)", "- print(ans)", "+ print((*reversed(ans)))" ]
false
0.054334
0.043783
1.241002
[ "s189746695", "s399580798" ]
u254871849
p02837
python
s229488869
s321478391
442
232
29,688
20,196
Accepted
Accepted
47.51
import sys import numpy as np n = int(sys.stdin.readline().rstrip()) xy = [[] for _ in range(n)] for i in range(n): a = int(sys.stdin.readline().rstrip()) for _ in range(a): x, y = list(map(int, sys.stdin.readline().split())) xy[i].append((x - 1, y)) def main(): comb = (np.aran...
import sys import numpy as np n = int(sys.stdin.readline().rstrip()) graph = [None] * n for i in range(n): a = int(sys.stdin.readline().rstrip()) if not a: continue graph[i] = np.array([sys.stdin.readline().split() for _ in range(a)], dtype=np.int16).T def main(): comb = (np.arange(1 << n)...
28
22
823
667
import sys import numpy as np n = int(sys.stdin.readline().rstrip()) xy = [[] for _ in range(n)] for i in range(n): a = int(sys.stdin.readline().rstrip()) for _ in range(a): x, y = list(map(int, sys.stdin.readline().split())) xy[i].append((x - 1, y)) def main(): comb = (np.arange(2**n).re...
import sys import numpy as np n = int(sys.stdin.readline().rstrip()) graph = [None] * n for i in range(n): a = int(sys.stdin.readline().rstrip()) if not a: continue graph[i] = np.array( [sys.stdin.readline().split() for _ in range(a)], dtype=np.int16 ).T def main(): comb = (np.ara...
false
21.428571
[ "-xy = [[] for _ in range(n)]", "+graph = [None] * n", "- for _ in range(a):", "- x, y = list(map(int, sys.stdin.readline().split()))", "- xy[i].append((x - 1, y))", "+ if not a:", "+ continue", "+ graph[i] = np.array(", "+ [sys.stdin.readline().split() for _ in ...
false
0.306158
1.167287
0.262282
[ "s229488869", "s321478391" ]
u562935282
p03576
python
s311859939
s285147126
915
289
44,380
45,032
Accepted
Accepted
68.42
def solve(): res = float('inf') for i in range(n): r_top = coordinates[i][1] for j in range(n): r_bottom = coordinates[j][1] if r_bottom < r_top: continue for k in range(n): c_left = coordinates[k][0] f...
# 二次元累積和 # 写経 # https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1014_abc075 from collections import namedtuple from operator import attrgetter Coordinates = namedtuple('Coordinates', ('ind', 'x', 'y')) n, k = list(map(int, input().split())) e = [] for ind in range(n): x,...
33
35
1,096
1,206
def solve(): res = float("inf") for i in range(n): r_top = coordinates[i][1] for j in range(n): r_bottom = coordinates[j][1] if r_bottom < r_top: continue for k in range(n): c_left = coordinates[k][0] for l in ra...
# 二次元累積和 # 写経 # https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1014_abc075 from collections import namedtuple from operator import attrgetter Coordinates = namedtuple("Coordinates", ("ind", "x", "y")) n, k = list(map(int, input().split())) e = [] for ind in range(n): x, y = list(map(in...
false
5.714286
[ "-def solve():", "- res = float(\"inf\")", "- for i in range(n):", "- r_top = coordinates[i][1]", "- for j in range(n):", "- r_bottom = coordinates[j][1]", "- if r_bottom < r_top:", "- continue", "- for k in range(n):", "- ...
false
0.034776
0.053341
0.651966
[ "s311859939", "s285147126" ]
u388323466
p03160
python
s568118233
s227779374
192
130
13,900
13,928
Accepted
Accepted
32.29
n = int(eval(input())) arr = list(map(int,input().split())) tmp = [float('inf') for i in range(n)] tmp[0] = 0 tmp[1] = abs(arr[0] - arr[1]) for j in range(2,n): tmp[j] = min(tmp[j],tmp[j-2]+abs(arr[j-2]-arr[j])) tmp[j] = min(tmp[j],tmp[j-1]+abs(arr[j-1]-arr[j])) print((tmp[-1]))
n = int(eval(input())) arr = list(map(int,input().split())) dp = [float('inf')] * n dp[0] = 0 dp[1] = abs(arr[0] - arr[1]) for i in range(2,n): dp[i] = min(abs(arr[i-1] - arr[i]) + dp[i -1],abs(arr[i-2]-arr[i])+dp[i-2]) print((dp[-1]))
13
16
290
254
n = int(eval(input())) arr = list(map(int, input().split())) tmp = [float("inf") for i in range(n)] tmp[0] = 0 tmp[1] = abs(arr[0] - arr[1]) for j in range(2, n): tmp[j] = min(tmp[j], tmp[j - 2] + abs(arr[j - 2] - arr[j])) tmp[j] = min(tmp[j], tmp[j - 1] + abs(arr[j - 1] - arr[j])) print((tmp[-1]))
n = int(eval(input())) arr = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 dp[1] = abs(arr[0] - arr[1]) for i in range(2, n): dp[i] = min( abs(arr[i - 1] - arr[i]) + dp[i - 1], abs(arr[i - 2] - arr[i]) + dp[i - 2] ) print((dp[-1]))
false
18.75
[ "-tmp = [float(\"inf\") for i in range(n)]", "-tmp[0] = 0", "-tmp[1] = abs(arr[0] - arr[1])", "-for j in range(2, n):", "- tmp[j] = min(tmp[j], tmp[j - 2] + abs(arr[j - 2] - arr[j]))", "- tmp[j] = min(tmp[j], tmp[j - 1] + abs(arr[j - 1] - arr[j]))", "-print((tmp[-1]))", "+dp = [float(\"inf\")] *...
false
0.076266
0.035046
2.176166
[ "s568118233", "s227779374" ]
u170761365
p02702
python
s820287767
s598830058
126
109
9,384
9,224
Accepted
Accepted
13.49
number = str(eval(input()))[::-1] remainderDictionary = {0: 1} sum = 0 x = 1 for i in number: x = (x * 10) % 2019 sum = (sum + int(i) * x) % 2019 remainderValue = remainderDictionary.get(sum,0) + 1 remainderDictionary[sum] = remainderValue ans = 0 for i in remainderDictionary: value =...
number = str(eval(input()))[::-1] remainderDictionary = {0: 1} digitDictionary = {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9} sum = 0 x = 1 for i in number: x = (x * 10) % 2019 sum = (sum + digitDictionary[i] * x) % 2019 remainderValue = remainderDictionary.get(sum,0) + 1 ...
16
18
392
492
number = str(eval(input()))[::-1] remainderDictionary = {0: 1} sum = 0 x = 1 for i in number: x = (x * 10) % 2019 sum = (sum + int(i) * x) % 2019 remainderValue = remainderDictionary.get(sum, 0) + 1 remainderDictionary[sum] = remainderValue ans = 0 for i in remainderDictionary: value = remainderDict...
number = str(eval(input()))[::-1] remainderDictionary = {0: 1} digitDictionary = { "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, } sum = 0 x = 1 for i in number: x = (x * 10) % 2019 sum = (sum + digitDictionary[i] * x) % 2019 remainde...
false
11.111111
[ "+digitDictionary = {", "+ \"0\": 0,", "+ \"1\": 1,", "+ \"2\": 2,", "+ \"3\": 3,", "+ \"4\": 4,", "+ \"5\": 5,", "+ \"6\": 6,", "+ \"7\": 7,", "+ \"8\": 8,", "+ \"9\": 9,", "+}", "- sum = (sum + int(i) * x) % 2019", "+ sum = (sum + digitDictionary[i] * ...
false
0.123618
0.079722
1.550612
[ "s820287767", "s598830058" ]
u347640436
p02632
python
s122109231
s430108128
1,880
551
10,896
71,180
Accepted
Accepted
70.69
K = int(eval(input())) S = eval(input()) m = 1000000007 result = 0 t = pow(26, K, m) u = pow(26, -1, m) * 25 % m l = len(S) for i in range(K + 1): # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m) result = (result + t) % m t = (t * u) % m * (l + i) % m * pow(i + 1, -1, m...
K = int(eval(input())) S = eval(input()) m = 1000000007 result = 0 t = pow(26, K, m) u = pow(26, m - 2, m) * 25 % m l = len(S) for i in range(K + 1): # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m) result = (result + t) % m t = (t * u) % m * (l + i) % m * pow(i + 1, m ...
14
14
329
335
K = int(eval(input())) S = eval(input()) m = 1000000007 result = 0 t = pow(26, K, m) u = pow(26, -1, m) * 25 % m l = len(S) for i in range(K + 1): # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m) result = (result + t) % m t = (t * u) % m * (l + i) % m * pow(i + 1, -1, m) % m print(re...
K = int(eval(input())) S = eval(input()) m = 1000000007 result = 0 t = pow(26, K, m) u = pow(26, m - 2, m) * 25 % m l = len(S) for i in range(K + 1): # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m) result = (result + t) % m t = (t * u) % m * (l + i) % m * pow(i + 1, m - 2, m) % m pr...
false
0
[ "-u = pow(26, -1, m) * 25 % m", "+u = pow(26, m - 2, m) * 25 % m", "- t = (t * u) % m * (l + i) % m * pow(i + 1, -1, m) % m", "+ t = (t * u) % m * (l + i) % m * pow(i + 1, m - 2, m) % m" ]
false
0.038519
0.09074
0.424498
[ "s122109231", "s430108128" ]
u077291787
p02773
python
s739914036
s550787307
383
278
45,300
38,392
Accepted
Accepted
27.42
# C - Poll from collections import Counter def main(): _, *S = open(0).read().split() cnt = Counter(S).most_common() max_votes = cnt[0][1] ans = [] for a, i in cnt: if i < max_votes: break ans.append(a) ans.sort() print(("\n".join(map(str, ans)))) ...
# C - Poll from collections import Counter def main(): _, *S = open(0).read().split() cnt = Counter(S) max_votes = max(cnt.values()) ans = [k for k, v in list(cnt.items()) if v == max_votes] ans.sort() print(("\n".join(ans))) if __name__ == "__main__": main()
19
15
362
298
# C - Poll from collections import Counter def main(): _, *S = open(0).read().split() cnt = Counter(S).most_common() max_votes = cnt[0][1] ans = [] for a, i in cnt: if i < max_votes: break ans.append(a) ans.sort() print(("\n".join(map(str, ans)))) if __name__ ...
# C - Poll from collections import Counter def main(): _, *S = open(0).read().split() cnt = Counter(S) max_votes = max(cnt.values()) ans = [k for k, v in list(cnt.items()) if v == max_votes] ans.sort() print(("\n".join(ans))) if __name__ == "__main__": main()
false
21.052632
[ "- cnt = Counter(S).most_common()", "- max_votes = cnt[0][1]", "- ans = []", "- for a, i in cnt:", "- if i < max_votes:", "- break", "- ans.append(a)", "+ cnt = Counter(S)", "+ max_votes = max(cnt.values())", "+ ans = [k for k, v in list(cnt.items()) i...
false
0.064885
0.035091
1.849032
[ "s739914036", "s550787307" ]
u098012509
p03127
python
s150706748
s398151310
96
67
85,308
20,380
Accepted
Accepted
30.21
import math N = int(eval(input())) A = [int(x) for x in input().split()] x = A[0] for a in A: x = math.gcd(x, a) print(x)
import math N = int(eval(input())) A = [int(x) for x in input().split()] ans = A[0] for a in A[1:]: ans = math.gcd(a, ans) print(ans)
12
12
136
148
import math N = int(eval(input())) A = [int(x) for x in input().split()] x = A[0] for a in A: x = math.gcd(x, a) print(x)
import math N = int(eval(input())) A = [int(x) for x in input().split()] ans = A[0] for a in A[1:]: ans = math.gcd(a, ans) print(ans)
false
0
[ "-x = A[0]", "-for a in A:", "- x = math.gcd(x, a)", "-print(x)", "+ans = A[0]", "+for a in A[1:]:", "+ ans = math.gcd(a, ans)", "+print(ans)" ]
false
0.03992
0.037169
1.074001
[ "s150706748", "s398151310" ]
u525065967
p02616
python
s712871416
s410661020
275
233
34,156
32,548
Accepted
Accepted
15.27
from logging import * basicConfig(level=DEBUG, format='%(levelname)s: %(message)s') disable(CRITICAL) def solve(): can_positive = False if len(P) > 0: if k < n: can_positive = True else: can_positive = len(M)%2 == 0 else: can_positive = k%2 == 0 if not can_positive: return s...
def solve(): can_positive = False if len(P) > 0: if k < n: can_positive = True else: can_positive = len(M)%2 == 0 else: can_positive = k%2 == 0 if not can_positive: return sorted(P+M, key=lambda x:abs(x))[:k] P.sort() M.sort(reverse = True) p, m = [], [] whi...
57
44
1,630
1,309
from logging import * basicConfig(level=DEBUG, format="%(levelname)s: %(message)s") disable(CRITICAL) def solve(): can_positive = False if len(P) > 0: if k < n: can_positive = True else: can_positive = len(M) % 2 == 0 else: can_positive = k % 2 == 0 if ...
def solve(): can_positive = False if len(P) > 0: if k < n: can_positive = True else: can_positive = len(M) % 2 == 0 else: can_positive = k % 2 == 0 if not can_positive: return sorted(P + M, key=lambda x: abs(x))[:k] P.sort() M.sort(reverse=...
false
22.807018
[ "-from logging import *", "-", "-basicConfig(level=DEBUG, format=\"%(levelname)s: %(message)s\")", "-disable(CRITICAL)", "-", "-", "- debug(\"k {} n {}\".format(k, n))", "- debug(\"P {}\".format(P))", "- debug(\"M {}\".format(M))", "- debug(\"p {}\".format(p))", "- debug(\"m {}\"....
false
0.061358
0.048761
1.258347
[ "s712871416", "s410661020" ]
u539281377
p02881
python
s669047514
s625688182
145
129
3,060
3,060
Accepted
Accepted
11.03
N=int(eval(input())) L=float("inf") for i in range(1,int(N**0.5)+1): if N%i==0: x,y=i,N//i l=x+y-2 L=min(L,l) print(L)
N=int(eval(input())) ans=min(i-1+N//i-1 for i in range(1,int(N**0.5)+1) if N%i==0) print(ans)
8
3
147
89
N = int(eval(input())) L = float("inf") for i in range(1, int(N**0.5) + 1): if N % i == 0: x, y = i, N // i l = x + y - 2 L = min(L, l) print(L)
N = int(eval(input())) ans = min(i - 1 + N // i - 1 for i in range(1, int(N**0.5) + 1) if N % i == 0) print(ans)
false
62.5
[ "-L = float(\"inf\")", "-for i in range(1, int(N**0.5) + 1):", "- if N % i == 0:", "- x, y = i, N // i", "- l = x + y - 2", "- L = min(L, l)", "-print(L)", "+ans = min(i - 1 + N // i - 1 for i in range(1, int(N**0.5) + 1) if N % i == 0)", "+print(ans)" ]
false
0.105137
0.090507
1.161642
[ "s669047514", "s625688182" ]
u186838327
p03032
python
s843530659
s213311484
1,063
101
60,252
75,004
Accepted
Accepted
90.5
from collections import deque n, k = list(map(int, input().split())) vs_ = deque(list(map(int, input().split()))) max_v = 0 import copy for a in range(k+1): for b in range(k+1-a): for c in range(k+1-a-b): vs = copy.copy(vs_) us = [] for x in range(a): if vs: ...
n, k = list(map(int, input().split())) V = list(map(int, input().split())) from collections import deque V = deque(V) import copy ans = -10**18 for i in range(k+1): for j in range(k+1): if i+j > k: continue if i+j > n: continue V_ = copy.copy(V) ...
38
29
712
664
from collections import deque n, k = list(map(int, input().split())) vs_ = deque(list(map(int, input().split()))) max_v = 0 import copy for a in range(k + 1): for b in range(k + 1 - a): for c in range(k + 1 - a - b): vs = copy.copy(vs_) us = [] for x in range(a): ...
n, k = list(map(int, input().split())) V = list(map(int, input().split())) from collections import deque V = deque(V) import copy ans = -(10**18) for i in range(k + 1): for j in range(k + 1): if i + j > k: continue if i + j > n: continue V_ = copy.copy(V) te...
false
23.684211
[ "+n, k = list(map(int, input().split()))", "+V = list(map(int, input().split()))", "-n, k = list(map(int, input().split()))", "-vs_ = deque(list(map(int, input().split())))", "-max_v = 0", "+V = deque(V)", "-for a in range(k + 1):", "- for b in range(k + 1 - a):", "- for c in range(k + 1 -...
false
0.07593
0.039907
1.902661
[ "s843530659", "s213311484" ]
u323680411
p03821
python
s106007807
s063762840
743
185
14,836
14,836
Accepted
Accepted
75.1
import sys def next_str() -> str: result = "" while True: tmp = sys.stdin.read(1) if tmp.strip() != "": result += tmp elif tmp != '\r': break return result def next_int() -> int: return int(next_str()) def main() -> None: n = n...
import sys def main() -> None: n = int(sys.stdin.readline()) a = [0] * n b = [0] * n ans = 0 for i in range(n): a[i], b[i] = list(map(int, sys.stdin.readline().split())) for i in range(n - 1, -1, -1): a[i] += ans if a[i] % b[i] != 0: ans += ...
38
22
651
399
import sys def next_str() -> str: result = "" while True: tmp = sys.stdin.read(1) if tmp.strip() != "": result += tmp elif tmp != "\r": break return result def next_int() -> int: return int(next_str()) def main() -> None: n = next_int() a = [...
import sys def main() -> None: n = int(sys.stdin.readline()) a = [0] * n b = [0] * n ans = 0 for i in range(n): a[i], b[i] = list(map(int, sys.stdin.readline().split())) for i in range(n - 1, -1, -1): a[i] += ans if a[i] % b[i] != 0: ans += abs(a[i] % b[i] -...
false
42.105263
[ "-def next_str() -> str:", "- result = \"\"", "- while True:", "- tmp = sys.stdin.read(1)", "- if tmp.strip() != \"\":", "- result += tmp", "- elif tmp != \"\\r\":", "- break", "- return result", "-", "-", "-def next_int() -> int:", "- r...
false
0.090995
0.087133
1.044318
[ "s106007807", "s063762840" ]
u969190727
p02798
python
s307319057
s739386044
607
518
50,140
49,884
Accepted
Accepted
14.66
import itertools n=int(eval(input())) A=[int(i) for i in input().split()] B=[int(i) for i in input().split()] def bitsum(BIT,i): s=0 while i>0: s+=BIT[i] i-=i&(-i) return s def bitadd(BIT,i,x): while i<=64: BIT[i]+=x i+=i&(-i) return BIT def tentou(X): ret=0 BIT=[0]*64...
import itertools n=int(eval(input())) A=[int(i) for i in input().split()] B=[int(i) for i in input().split()] N=[int(i) for i in range(n)] nn=2**n ans=float("inf") for _ in range(n//2+1): for com in itertools.combinations(N,2*_): i=0 for ura in com: i+=2**ura E,O=[],[] for j in ra...
76
60
1,498
1,288
import itertools n = int(eval(input())) A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] def bitsum(BIT, i): s = 0 while i > 0: s += BIT[i] i -= i & (-i) return s def bitadd(BIT, i, x): while i <= 64: BIT[i] += x i += i & (-i) return BI...
import itertools n = int(eval(input())) A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] N = [int(i) for i in range(n)] nn = 2**n ans = float("inf") for _ in range(n // 2 + 1): for com in itertools.combinations(N, 2 * _): i = 0 for ura in com: i += 2**ura ...
false
21.052632
[ "-", "-", "-def bitsum(BIT, i):", "- s = 0", "- while i > 0:", "- s += BIT[i]", "- i -= i & (-i)", "- return s", "-", "-", "-def bitadd(BIT, i, x):", "- while i <= 64:", "- BIT[i] += x", "- i += i & (-i)", "- return BIT", "-", "-", "-def t...
false
0.035286
0.036308
0.971862
[ "s307319057", "s739386044" ]
u852690916
p03361
python
s219701619
s174845844
202
175
41,328
39,280
Accepted
Accepted
13.37
import sys def main(): input = sys.stdin.readline H,W = list(map(int, input().split())) s = [list(input().rstrip()) for _ in range(H)] c = lambda i,j: i*W+j used = [False] * (H*W+1) def dfs(si, sj): depth = 0 stack = [(si, sj, 0)] while stack: i, ...
import sys def main(): input = sys.stdin.readline H,W = list(map(int, input().split())) s = [list(input().rstrip()) for _ in range(H)] def check(i, j): for di, dj in [(0,1),(0,-1),(1,0),(-1,0)]: ni, nj = i+di, j+dj if ni < 0 or ni >= H or nj < 0 or nj >= W: cont...
32
21
1,009
611
import sys def main(): input = sys.stdin.readline H, W = list(map(int, input().split())) s = [list(input().rstrip()) for _ in range(H)] c = lambda i, j: i * W + j used = [False] * (H * W + 1) def dfs(si, sj): depth = 0 stack = [(si, sj, 0)] while stack: i, ...
import sys def main(): input = sys.stdin.readline H, W = list(map(int, input().split())) s = [list(input().rstrip()) for _ in range(H)] def check(i, j): for di, dj in [(0, 1), (0, -1), (1, 0), (-1, 0)]: ni, nj = i + di, j + dj if ni < 0 or ni >= H or nj < 0 or nj >= W:...
false
34.375
[ "- c = lambda i, j: i * W + j", "- used = [False] * (H * W + 1)", "- def dfs(si, sj):", "- depth = 0", "- stack = [(si, sj, 0)]", "- while stack:", "- i, j, d = stack.pop()", "- for di, dj in [(0, 1), (0, -1), (1, 0), (-1, 0)]:", "- ...
false
0.042639
0.042642
0.999916
[ "s219701619", "s174845844" ]
u670567845
p03379
python
s574541659
s733791104
318
195
25,556
30,908
Accepted
Accepted
38.68
n = int(eval(input())) X = list(map(int,input().split())) medIndex = int((n-1)/2) Z = sorted(X[:]) c1 = Z[int(n/2-1)] c2 = Z[int(n/2)] for i in range(n) : if (X[i] <= c1) : print(c2) else : print(c1)
N = int(eval(input())) A = list(map(int, input().split())) AA = sorted(A) X = AA[N//2 - 1] Y = AA[N//2] for i in range(N): if A[i] < Y: print(Y) if A[i] >= Y: print(X)
11
10
216
182
n = int(eval(input())) X = list(map(int, input().split())) medIndex = int((n - 1) / 2) Z = sorted(X[:]) c1 = Z[int(n / 2 - 1)] c2 = Z[int(n / 2)] for i in range(n): if X[i] <= c1: print(c2) else: print(c1)
N = int(eval(input())) A = list(map(int, input().split())) AA = sorted(A) X = AA[N // 2 - 1] Y = AA[N // 2] for i in range(N): if A[i] < Y: print(Y) if A[i] >= Y: print(X)
false
9.090909
[ "-n = int(eval(input()))", "-X = list(map(int, input().split()))", "-medIndex = int((n - 1) / 2)", "-Z = sorted(X[:])", "-c1 = Z[int(n / 2 - 1)]", "-c2 = Z[int(n / 2)]", "-for i in range(n):", "- if X[i] <= c1:", "- print(c2)", "- else:", "- print(c1)", "+N = int(eval(input...
false
0.064519
0.065095
0.991144
[ "s574541659", "s733791104" ]
u017810624
p03231
python
s550845884
s250462076
167
48
5,988
5,340
Accepted
Accepted
71.26
from fractions import gcd def lcm(x,y): return (x*y)//gcd(x,y) n,m=list(map(int,input().split())) s=eval(input()) t=eval(input()) c=0 a=lcm(n,m)//n b=lcm(n,m)//m for i in range(n): if int(i*a)%b==0: if s[i]==t[int(i*a/b)]:c+=1 else: break if c==(int(lcm(n,m)/lcm(a,b))):print((lcm...
from fractions import gcd def lcm(x,y): return (x*y)//gcd(x,y) n,m=list(map(int,input().split())) s=eval(input()) t=eval(input()) c=0 a=lcm(n,m)//n b=lcm(n,m)//m for i in range(n): if (i*a)%b==0: if s[i]==t[int(i*a/b)]:c+=1 else: break if c==(int(lcm(n,m)/lcm(a,b))):print((lcm(n,m)))...
19
18
323
316
from fractions import gcd def lcm(x, y): return (x * y) // gcd(x, y) n, m = list(map(int, input().split())) s = eval(input()) t = eval(input()) c = 0 a = lcm(n, m) // n b = lcm(n, m) // m for i in range(n): if int(i * a) % b == 0: if s[i] == t[int(i * a / b)]: c += 1 else: ...
from fractions import gcd def lcm(x, y): return (x * y) // gcd(x, y) n, m = list(map(int, input().split())) s = eval(input()) t = eval(input()) c = 0 a = lcm(n, m) // n b = lcm(n, m) // m for i in range(n): if (i * a) % b == 0: if s[i] == t[int(i * a / b)]: c += 1 else: ...
false
5.263158
[ "- if int(i * a) % b == 0:", "+ if (i * a) % b == 0:" ]
false
0.044482
0.062936
0.706773
[ "s550845884", "s250462076" ]
u508732591
p02257
python
s758716279
s547950947
70
60
7,764
7,716
Accepted
Accepted
14.29
def maybe_prime(d,s,n): for a in (2,3,5,7): p = False x = pow(a,d,n) if x==1 or x==n-1: continue for i in range(1,s): x = x*x%n if x==1: return False elif x == n-1: p = True break if n...
def maybe_prime(d,s,n): for a in (2,3,5,7): p = False x = pow(a,d,n) if x==1 or x==n-1: continue for i in range(1,s): x = x*x%n if x==1: return False elif x == n-1: p = True break if n...
30
30
669
685
def maybe_prime(d, s, n): for a in (2, 3, 5, 7): p = False x = pow(a, d, n) if x == 1 or x == n - 1: continue for i in range(1, s): x = x * x % n if x == 1: return False elif x == n - 1: p = True ...
def maybe_prime(d, s, n): for a in (2, 3, 5, 7): p = False x = pow(a, d, n) if x == 1 or x == n - 1: continue for i in range(1, s): x = x * x % n if x == 1: return False elif x == n - 1: p = True ...
false
0
[ "- elif n % 2 == 0:", "+ elif 0 in (n % 2, n % 3, n % 5, n % 7):" ]
false
0.048188
0.048744
0.988591
[ "s758716279", "s547950947" ]
u094191970
p03220
python
s614077706
s343729620
1,289
18
21,400
3,064
Accepted
Accepted
98.6
import numpy as np N = eval(input()) T, A = list(map(int, input().split())) H_list = [] H_list = list(map(int, input().split())) T_list = list([T - (x * 0.006) for x in H_list]) T_list_2 = np.array(list([abs(x - A) for x in T_list])) index = np.argmin(T_list_2) print((index + 1))
n=int(eval(input())) t,a=list(map(int,input().split())) h=list(map(int,input().split())) h2=[] for hh in h: h2.append(t-0.006*hh) v=10**9 for i in range(n): if abs(v-a)>abs(h2[i]-a): v=h2[i] inx=i+1 print(inx)
10
14
288
218
import numpy as np N = eval(input()) T, A = list(map(int, input().split())) H_list = [] H_list = list(map(int, input().split())) T_list = list([T - (x * 0.006) for x in H_list]) T_list_2 = np.array(list([abs(x - A) for x in T_list])) index = np.argmin(T_list_2) print((index + 1))
n = int(eval(input())) t, a = list(map(int, input().split())) h = list(map(int, input().split())) h2 = [] for hh in h: h2.append(t - 0.006 * hh) v = 10**9 for i in range(n): if abs(v - a) > abs(h2[i] - a): v = h2[i] inx = i + 1 print(inx)
false
28.571429
[ "-import numpy as np", "-", "-N = eval(input())", "-T, A = list(map(int, input().split()))", "-H_list = []", "-H_list = list(map(int, input().split()))", "-T_list = list([T - (x * 0.006) for x in H_list])", "-T_list_2 = np.array(list([abs(x - A) for x in T_list]))", "-index = np.argmin(T_list_2)", ...
false
0.456594
0.046463
9.827075
[ "s614077706", "s343729620" ]
u992910889
p03086
python
s551547413
s132027738
19
17
3,060
3,060
Accepted
Accepted
10.53
S = eval(input()) N = len(S) ans = 0 for i in range(N): for j in range(i, N): if all('ACGT'.count(c) == 1 for c in S[i : j + 1]): ans = max(ans, j - i + 1) print(ans)
S=list(eval(input())) maxlen=0 for i in range(len(S)): for j in range(i,len(S)): for k in range(i,j+1): #cnt=0 if S[k]!='A' and S[k]!='C' and S[k]!='G' and S[k]!='T': break if k==j and j-i+1>maxlen: maxlen=j-i+1 print(maxlen)
9
12
181
312
S = eval(input()) N = len(S) ans = 0 for i in range(N): for j in range(i, N): if all("ACGT".count(c) == 1 for c in S[i : j + 1]): ans = max(ans, j - i + 1) print(ans)
S = list(eval(input())) maxlen = 0 for i in range(len(S)): for j in range(i, len(S)): for k in range(i, j + 1): # cnt=0 if S[k] != "A" and S[k] != "C" and S[k] != "G" and S[k] != "T": break if k == j and j - i + 1 > maxlen: maxlen = j - i +...
false
25
[ "-S = eval(input())", "-N = len(S)", "-ans = 0", "-for i in range(N):", "- for j in range(i, N):", "- if all(\"ACGT\".count(c) == 1 for c in S[i : j + 1]):", "- ans = max(ans, j - i + 1)", "-print(ans)", "+S = list(eval(input()))", "+maxlen = 0", "+for i in range(len(S)):", ...
false
0.040835
0.040423
1.010203
[ "s551547413", "s132027738" ]
u629540524
p03316
python
s071455014
s268039500
72
61
61,500
61,804
Accepted
Accepted
15.28
n = int(eval(input())) a = list(str(n)) s = sum([int(a[i]) for i in range(len(a))]) if n%s==0: print('Yes') else: print('No')
n = int(eval(input())) a = list(str(n)) c = 0 for i in range(len(a)): c+=int(a[i]) if n%c==0: print('Yes') else: print('No')
7
9
133
138
n = int(eval(input())) a = list(str(n)) s = sum([int(a[i]) for i in range(len(a))]) if n % s == 0: print("Yes") else: print("No")
n = int(eval(input())) a = list(str(n)) c = 0 for i in range(len(a)): c += int(a[i]) if n % c == 0: print("Yes") else: print("No")
false
22.222222
[ "-s = sum([int(a[i]) for i in range(len(a))])", "-if n % s == 0:", "+c = 0", "+for i in range(len(a)):", "+ c += int(a[i])", "+if n % c == 0:" ]
false
0.033988
0.040083
0.847947
[ "s071455014", "s268039500" ]
u477977638
p02775
python
s183154970
s531659284
367
156
116,132
126,688
Accepted
Accepted
57.49
import sys #read = sys.stdin.buffer.read #input = sys.stdin.buffer.readline #inputs = sys.stdin.buffer.readlines from collections import defaultdict # mod=10**9+7 # rstrip().decode('utf-8') # map(int,input().split()) # import numpy as np def main(): li=[0]+list(map(int,eval(input()))) n=len(li) ...
import sys input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(eval(input())) def FI(): return int(eval(input())) def MI(): return list(map(int,input().split())) def MF(): return list(map(float,input...
36
49
578
818
import sys # read = sys.stdin.buffer.read # input = sys.stdin.buffer.readline # inputs = sys.stdin.buffer.readlines from collections import defaultdict # mod=10**9+7 # rstrip().decode('utf-8') # map(int,input().split()) # import numpy as np def main(): li = [0] + list(map(int, eval(input()))) n = len(li) ...
import sys input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**9) # from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(eval(input())) def FI(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MF(): return ...
false
26.530612
[ "-# read = sys.stdin.buffer.read", "-# input = sys.stdin.buffer.readline", "-# inputs = sys.stdin.buffer.readlines", "-from collections import defaultdict", "+input = sys.stdin.buffer.readline", "+# sys.setrecursionlimit(10**9)", "+# from functools import lru_cache", "+def RD():", "+ return input...
false
0.06532
0.064233
1.016921
[ "s183154970", "s531659284" ]
u329143273
p02971
python
s058502619
s432418894
537
474
14,112
12,520
Accepted
Accepted
11.73
n=int(eval(input())) a=[int(eval(input())) for _ in range(n)] a_max=max(a) x=a.index(a_max) a_sort=sorted(a) y=a_sort[-2] for i in range(n): if i==x: print(y) else: print(a_max)
n=int(eval(input())) a=[int(eval(input())) for i in range(n)] s=max(a) t=a.index(s) for i in range(n): if i==t: del a[t] print((max(a))) else: print(s)
11
12
187
166
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] a_max = max(a) x = a.index(a_max) a_sort = sorted(a) y = a_sort[-2] for i in range(n): if i == x: print(y) else: print(a_max)
n = int(eval(input())) a = [int(eval(input())) for i in range(n)] s = max(a) t = a.index(s) for i in range(n): if i == t: del a[t] print((max(a))) else: print(s)
false
8.333333
[ "-a = [int(eval(input())) for _ in range(n)]", "-a_max = max(a)", "-x = a.index(a_max)", "-a_sort = sorted(a)", "-y = a_sort[-2]", "+a = [int(eval(input())) for i in range(n)]", "+s = max(a)", "+t = a.index(s)", "- if i == x:", "- print(y)", "+ if i == t:", "+ del a[t]", ...
false
0.07467
0.102806
0.726321
[ "s058502619", "s432418894" ]
u312025627
p03473
python
s476150765
s536584062
174
70
38,256
61,776
Accepted
Accepted
59.77
m = int(eval(input())) print((48 - m))
def main(): M = int(eval(input())) print((24 - M + 24)) if __name__ == '__main__': main()
2
7
31
102
m = int(eval(input())) print((48 - m))
def main(): M = int(eval(input())) print((24 - M + 24)) if __name__ == "__main__": main()
false
71.428571
[ "-m = int(eval(input()))", "-print((48 - m))", "+def main():", "+ M = int(eval(input()))", "+ print((24 - M + 24))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.037577
0.037488
1.00236
[ "s476150765", "s536584062" ]
u860002137
p03986
python
s109343224
s039936481
77
53
5,092
9,200
Accepted
Accepted
31.17
x = list(map(str, input().rstrip())) stock = 0 rest = 0 for i in x: if i == "S": stock += 1 elif i == "T" and stock >= 1: stock -= 1 else: rest += 1 print((stock + rest))
x = eval(input()) stock = 0 rest = len(x) for a in x: if a == "S": stock += 1 else: if stock > 0: stock -= 1 rest -= 2 else: stock = 0 print(rest)
13
16
218
226
x = list(map(str, input().rstrip())) stock = 0 rest = 0 for i in x: if i == "S": stock += 1 elif i == "T" and stock >= 1: stock -= 1 else: rest += 1 print((stock + rest))
x = eval(input()) stock = 0 rest = len(x) for a in x: if a == "S": stock += 1 else: if stock > 0: stock -= 1 rest -= 2 else: stock = 0 print(rest)
false
18.75
[ "-x = list(map(str, input().rstrip()))", "+x = eval(input())", "-rest = 0", "-for i in x:", "- if i == \"S\":", "+rest = len(x)", "+for a in x:", "+ if a == \"S\":", "- elif i == \"T\" and stock >= 1:", "- stock -= 1", "- rest += 1", "-print((stock + rest))", "+ ...
false
0.007542
0.040195
0.18764
[ "s109343224", "s039936481" ]
u476604182
p03700
python
s754339164
s265773832
1,431
1,003
16,524
14,092
Accepted
Accepted
29.91
N, A, B , *h = list(map(int, open(0).read().split())) C = A-B l = -1 r = 10**20 while l+1<r: s = (l+r)//2 M = [c-s*B for c in h] cnt = sum((c+C-1)//C if c>0 else 0 for c in M) if cnt>s: l = s else: r = s print(r)
N, A, B , *h = list(map(int, open(0).read().split())) C = A-B l = -1 r = 10**12 while l+1<r: s = (l+r)//2 cnt = sum((c-s*B+C-1)//C if c-s*B>0 else 0 for c in h) if cnt>s: l = s else: r = s print(r)
13
12
236
218
N, A, B, *h = list(map(int, open(0).read().split())) C = A - B l = -1 r = 10**20 while l + 1 < r: s = (l + r) // 2 M = [c - s * B for c in h] cnt = sum((c + C - 1) // C if c > 0 else 0 for c in M) if cnt > s: l = s else: r = s print(r)
N, A, B, *h = list(map(int, open(0).read().split())) C = A - B l = -1 r = 10**12 while l + 1 < r: s = (l + r) // 2 cnt = sum((c - s * B + C - 1) // C if c - s * B > 0 else 0 for c in h) if cnt > s: l = s else: r = s print(r)
false
7.692308
[ "-r = 10**20", "+r = 10**12", "- M = [c - s * B for c in h]", "- cnt = sum((c + C - 1) // C if c > 0 else 0 for c in M)", "+ cnt = sum((c - s * B + C - 1) // C if c - s * B > 0 else 0 for c in h)" ]
false
0.080848
0.074207
1.089498
[ "s754339164", "s265773832" ]
u073549161
p02792
python
s953420074
s034708911
310
227
41,692
40,504
Accepted
Accepted
26.77
n = int(eval(input())) # else以下は10以上の時のみ適応できるので10未満は埋め込み if n < 10: print(n) else: # 説明中のiを求めるため10でわる(切り捨て) x = n // 10 # 公式による計算。x^2+8 basenum = x * x + 8 addnum = 0 # ここ以下で(10*i から n, 1 から n)と(1 から n, 10*i から n)の数え上げを行うが、 # 重複した数え上げがないか確認するフラグ hassame = False # 数え上...
n = int(eval(input())) dat = [[0] * 10 for _ in range(10)] for i in range(1, n+1): dat[int(str(i)[0])][int(str(i)[-1])] += 1 res = sum([dat[a][b] * dat[b][a] for a in range(10) for b in range(10)]) print(res)
23
6
742
211
n = int(eval(input())) # else以下は10以上の時のみ適応できるので10未満は埋め込み if n < 10: print(n) else: # 説明中のiを求めるため10でわる(切り捨て) x = n // 10 # 公式による計算。x^2+8 basenum = x * x + 8 addnum = 0 # ここ以下で(10*i から n, 1 から n)と(1 から n, 10*i から n)の数え上げを行うが、 # 重複した数え上げがないか確認するフラグ hassame = False # 数え上げ(ここでは、(10*i ...
n = int(eval(input())) dat = [[0] * 10 for _ in range(10)] for i in range(1, n + 1): dat[int(str(i)[0])][int(str(i)[-1])] += 1 res = sum([dat[a][b] * dat[b][a] for a in range(10) for b in range(10)]) print(res)
false
73.913043
[ "-# else以下は10以上の時のみ適応できるので10未満は埋め込み", "-if n < 10:", "- print(n)", "-else:", "- # 説明中のiを求めるため10でわる(切り捨て)", "- x = n // 10", "- # 公式による計算。x^2+8", "- basenum = x * x + 8", "- addnum = 0", "- # ここ以下で(10*i から n, 1 から n)と(1 から n, 10*i から n)の数え上げを行うが、", "- # 重複した数え上げがないか確認するフラグ...
false
0.041279
0.102064
0.404438
[ "s953420074", "s034708911" ]
u624475441
p03353
python
s261425691
s727543789
50
17
4,476
3,064
Accepted
Accepted
66
s = eval(input()) l_s = list(s) K = int(eval(input())) if K == 1:print((min(l_s)));exit() elif K == 2: idx = s.index(min(l_s)) if idx < len(s)-1: print((s[idx:idx+2])) else: print((sorted(l_s)[1])) exit() sub = {s} for d in range(1,6): for i in range(len(s)-d+1): ...
s = eval(input()) n = len(s) K = int(eval(input())) chars = sorted(set(s)) lexicon = [] def next_word(cur): lexicon.append(cur) if len(lexicon) < K: for next_c in chars: next_w = cur + next_c if next_w in s: return next_word(next_w) for char in c...
22
19
492
357
s = eval(input()) l_s = list(s) K = int(eval(input())) if K == 1: print((min(l_s))) exit() elif K == 2: idx = s.index(min(l_s)) if idx < len(s) - 1: print((s[idx : idx + 2])) else: print((sorted(l_s)[1])) exit() sub = {s} for d in range(1, 6): for i in range(len(s) - d + 1): ...
s = eval(input()) n = len(s) K = int(eval(input())) chars = sorted(set(s)) lexicon = [] def next_word(cur): lexicon.append(cur) if len(lexicon) < K: for next_c in chars: next_w = cur + next_c if next_w in s: return next_word(next_w) for char in chars: next...
false
13.636364
[ "-l_s = list(s)", "+n = len(s)", "-if K == 1:", "- print((min(l_s)))", "- exit()", "-elif K == 2:", "- idx = s.index(min(l_s))", "- if idx < len(s) - 1:", "- print((s[idx : idx + 2]))", "- else:", "- print((sorted(l_s)[1]))", "- exit()", "-sub = {s}", "-for ...
false
0.057276
0.078547
0.729196
[ "s261425691", "s727543789" ]
u657913472
p02716
python
s545351935
s819217766
226
194
39,576
39,500
Accepted
Accepted
14.16
n,*l=list(map(int,open(0).read().split()));p=[0]*n;d=p[:] for i,l in enumerate(l):p[i]+=l+p[i-2];d[i]=max(l+d[i-2],[d,p][i&1][i-1]) print((d[-1]))
n,*l=list(map(int,open(0).read().split()));p=[0]*n;d=p[:] for i,l in enumerate(l):p[i]=l+p[i-2];d[i]=max(l+d[i-2],[d,p][i&1][i-1]) print((d[-1]))
3
3
140
139
n, *l = list(map(int, open(0).read().split())) p = [0] * n d = p[:] for i, l in enumerate(l): p[i] += l + p[i - 2] d[i] = max(l + d[i - 2], [d, p][i & 1][i - 1]) print((d[-1]))
n, *l = list(map(int, open(0).read().split())) p = [0] * n d = p[:] for i, l in enumerate(l): p[i] = l + p[i - 2] d[i] = max(l + d[i - 2], [d, p][i & 1][i - 1]) print((d[-1]))
false
0
[ "- p[i] += l + p[i - 2]", "+ p[i] = l + p[i - 2]" ]
false
0.040317
0.047251
0.853257
[ "s545351935", "s819217766" ]
u912237403
p00170
python
s344201583
s942123926
220
190
4,280
4,296
Accepted
Accepted
13.64
def solve(placed, w1, w2): global ans n = len(N) - len(placed) if n==0: ans = min(ans, [w1, placed]) return for e in N: if e in placed: continue w, lim, s = Food[e] if w2 > lim: return a = w1 + w * n if a > ans[0]: return solve(placed+[e], a, w2 + w) return w...
def solve(G1, G2, w1, w2): global ans n = len(G2) for e in G2: w, lim, s = Food[e] a = w1 + w * n if w2 > lim or a > ans[0]: return b = G1 + [e] if n == 1: ans = min(ans, [a, b]) else: x = G2[:] x.remove(e) solve(b, x, a, w2 + w) return while 1: ...
26
26
555
550
def solve(placed, w1, w2): global ans n = len(N) - len(placed) if n == 0: ans = min(ans, [w1, placed]) return for e in N: if e in placed: continue w, lim, s = Food[e] if w2 > lim: return a = w1 + w * n if a > ans[0]: ...
def solve(G1, G2, w1, w2): global ans n = len(G2) for e in G2: w, lim, s = Food[e] a = w1 + w * n if w2 > lim or a > ans[0]: return b = G1 + [e] if n == 1: ans = min(ans, [a, b]) else: x = G2[:] x.remove(e) ...
false
0
[ "-def solve(placed, w1, w2):", "+def solve(G1, G2, w1, w2):", "- n = len(N) - len(placed)", "- if n == 0:", "- ans = min(ans, [w1, placed])", "- return", "- for e in N:", "- if e in placed:", "- continue", "+ n = len(G2)", "+ for e in G2:", "- ...
false
0.099793
0.050205
1.987689
[ "s344201583", "s942123926" ]
u525065967
p02536
python
s486865114
s979052360
374
323
17,988
10,748
Accepted
Accepted
13.64
# union-find class UnionFind: def __init__(self, n): self.prsz = [-1] * n # parent & size def find(self, v): # root if self.prsz[v] < 0: return v self.prsz[v] = self.find(self.prsz[v]) return self.prsz[v] def union(self, v, u): # unite v = self.find(v); u = s...
# union-find class UnionFind: def __init__(self, n): self.prsz = [-1] * n # parent & size def find(self, v): # root if self.prsz[v] < 0: return v self.prsz[v] = self.find(self.prsz[v]) return self.prsz[v] def union(self, v, u): # unite v = self.find(v); u = s...
25
25
750
736
# union-find class UnionFind: def __init__(self, n): self.prsz = [-1] * n # parent & size def find(self, v): # root if self.prsz[v] < 0: return v self.prsz[v] = self.find(self.prsz[v]) return self.prsz[v] def union(self, v, u): # unite v = self.find(v...
# union-find class UnionFind: def __init__(self, n): self.prsz = [-1] * n # parent & size def find(self, v): # root if self.prsz[v] < 0: return v self.prsz[v] = self.find(self.prsz[v]) return self.prsz[v] def union(self, v, u): # unite v = self.find(v...
false
0
[ "-ans = set()", "-for i in range(n):", "- ans.add(uf.find(i))", "-print((len(ans) - 1))", "+ans = -1", "+for a in uf.prsz:", "+ if a < 0:", "+ ans += 1", "+print(ans)" ]
false
0.102041
0.044473
2.294426
[ "s486865114", "s979052360" ]
u847467233
p00461
python
s551084165
s484119272
450
410
7,296
7,308
Accepted
Accepted
8.89
# AOJ 0538: IOIOI # Python3 2018.7.1 bal4u while True: n = int(eval(input())) if n == 0: break m = int(eval(input())) s = input().strip() ans = cnt = i = 0 while i < m: if i+1 < m and s[i:i+2] == 'IO': cnt += 1 i += 1 elif cnt > 0: if s[i] == 'O': cnt -= 1 if cnt >= n: ans += cnt-n...
# AOJ 0538: IOIOI # Python3 2018.7.1 bal4u import sys from sys import stdin input = stdin.readline while True: n = int(eval(input())) if n == 0: break m = int(eval(input())) s = input().strip() ans = cnt = i = 0 while i < m: if i+1 < m and s[i:i+2] == 'IO': cnt += 1 i += 1 elif cnt > ...
20
24
348
409
# AOJ 0538: IOIOI # Python3 2018.7.1 bal4u while True: n = int(eval(input())) if n == 0: break m = int(eval(input())) s = input().strip() ans = cnt = i = 0 while i < m: if i + 1 < m and s[i : i + 2] == "IO": cnt += 1 i += 1 elif cnt > 0: ...
# AOJ 0538: IOIOI # Python3 2018.7.1 bal4u import sys from sys import stdin input = stdin.readline while True: n = int(eval(input())) if n == 0: break m = int(eval(input())) s = input().strip() ans = cnt = i = 0 while i < m: if i + 1 < m and s[i : i + 2] == "IO": cnt...
false
16.666667
[ "+import sys", "+from sys import stdin", "+", "+input = stdin.readline" ]
false
0.040689
0.043111
0.943811
[ "s551084165", "s484119272" ]
u312025627
p03588
python
s936833806
s072691309
701
311
64,472
21,172
Accepted
Accepted
55.63
def main(): N = int(eval(input())) A = [[int(i) for i in input().split()] for j in range(N)] A.sort(key=lambda p: p[1]) print((sum(A[0]))) if __name__ == '__main__': main()
def main(): N = int(eval(input())) A = [[int(i) for i in input().split()] for j in range(N)] mi = 0 idx = 0 for a, b in A: if mi < a: mi = a idx = b print((mi + idx)) if __name__ == '__main__': main()
9
14
195
268
def main(): N = int(eval(input())) A = [[int(i) for i in input().split()] for j in range(N)] A.sort(key=lambda p: p[1]) print((sum(A[0]))) if __name__ == "__main__": main()
def main(): N = int(eval(input())) A = [[int(i) for i in input().split()] for j in range(N)] mi = 0 idx = 0 for a, b in A: if mi < a: mi = a idx = b print((mi + idx)) if __name__ == "__main__": main()
false
35.714286
[ "- A.sort(key=lambda p: p[1])", "- print((sum(A[0])))", "+ mi = 0", "+ idx = 0", "+ for a, b in A:", "+ if mi < a:", "+ mi = a", "+ idx = b", "+ print((mi + idx))" ]
false
0.036568
0.007278
5.024485
[ "s936833806", "s072691309" ]
u299599133
p02996
python
s138144196
s431207652
1,288
960
71,700
55,256
Accepted
Accepted
25.47
# 131 D - Megalomania N = int(eval(input())) AB = [list(map( int,input().split() )) for i in range(N)] from operator import itemgetter AB = sorted(AB, key=itemgetter(1)) rt = 'Yes' X = [] val = 0 for i in range(N): val += AB[i][0] X.append( [val, AB[i][1]] ) if val > AB[i][1] : rt = ...
# 131 D - Megalomania N = int(eval(input())) AB = [list(map( int,input().split() )) for i in range(N)] from operator import itemgetter AB = sorted(AB, key=itemgetter(1)) rt = 'Yes' val = 0 for i in range(N): val += AB[i][0] if val > AB[i][1] : rt = 'No' break print(rt)
17
15
344
304
# 131 D - Megalomania N = int(eval(input())) AB = [list(map(int, input().split())) for i in range(N)] from operator import itemgetter AB = sorted(AB, key=itemgetter(1)) rt = "Yes" X = [] val = 0 for i in range(N): val += AB[i][0] X.append([val, AB[i][1]]) if val > AB[i][1]: rt = "No" break ...
# 131 D - Megalomania N = int(eval(input())) AB = [list(map(int, input().split())) for i in range(N)] from operator import itemgetter AB = sorted(AB, key=itemgetter(1)) rt = "Yes" val = 0 for i in range(N): val += AB[i][0] if val > AB[i][1]: rt = "No" break print(rt)
false
11.764706
[ "-X = []", "- X.append([val, AB[i][1]])" ]
false
0.077253
0.040943
1.88684
[ "s138144196", "s431207652" ]
u462053731
p03073
python
s688168124
s011433217
92
81
3,956
3,956
Accepted
Accepted
11.96
S = list(map(int, eval(input()))) ans1 = 0 ans2 = 0 for i in range (len(S)): if i % 2 == 0 and S[i] == 0: ans1 += 1 elif i %2 ==1 and S[i] == 1: ans1 += 1 for i in range(len(S)): if i % 2 == 0 and S[i] == 1: ans2 += 1 elif i % 2 ==1 and S[i] == 0: ans2 += 1 print((min(ans1, ...
S = list(map(int, eval(input()))) ans1 = 0 ans2 = 0 for i in range (len(S)): if i % 2 == 0: if S[i] == 0: ans1 += 1 else: if S[i] == 1: ans1 += 1 for i in range(len(S)): if i % 2 == 0: if S[i] == 1: ans2 += 1 else: if S[i] == 0: ans2 += 1 print((min(ans1,...
15
18
322
320
S = list(map(int, eval(input()))) ans1 = 0 ans2 = 0 for i in range(len(S)): if i % 2 == 0 and S[i] == 0: ans1 += 1 elif i % 2 == 1 and S[i] == 1: ans1 += 1 for i in range(len(S)): if i % 2 == 0 and S[i] == 1: ans2 += 1 elif i % 2 == 1 and S[i] == 0: ans2 += 1 print((min(a...
S = list(map(int, eval(input()))) ans1 = 0 ans2 = 0 for i in range(len(S)): if i % 2 == 0: if S[i] == 0: ans1 += 1 else: if S[i] == 1: ans1 += 1 for i in range(len(S)): if i % 2 == 0: if S[i] == 1: ans2 += 1 else: if S[i] == 0: ...
false
16.666667
[ "- if i % 2 == 0 and S[i] == 0:", "- ans1 += 1", "- elif i % 2 == 1 and S[i] == 1:", "- ans1 += 1", "+ if i % 2 == 0:", "+ if S[i] == 0:", "+ ans1 += 1", "+ else:", "+ if S[i] == 1:", "+ ans1 += 1", "- if i % 2 == 0 and S[i] == 1:"...
false
0.048432
0.044924
1.078073
[ "s688168124", "s011433217" ]
u057109575
p02867
python
s379640999
s498348657
510
332
101,096
112,372
Accepted
Accepted
34.9
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 0 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count A, B = list(zip(*sorted(zip(A...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 0 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count A, B = list(zip(*sorted...
22
29
606
634
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 0 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count A, B = list(zip(*sorted(zip(A, B), key=la...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 0 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count A, B = list(zip(*sorted(zip(A, B), key=la...
false
24.137931
[ "-print((\"Yes\" if check_1 and (check_2 or check_3) else \"No\"))", "+if check_1 and (check_2 or check_3):", "+ print(\"Yes\")", "+else:", "+ print(\"No\")" ]
false
0.103657
0.044064
2.352429
[ "s379640999", "s498348657" ]
u798818115
p03163
python
s837402432
s446351798
439
321
92,240
41,708
Accepted
Accepted
26.88
# coding: utf-8 # Your code here! N,W=list(map(int,input().split())) l=[-1]*(W+1) l[0]=0 dp=l[:] for i in range(N): w,v=list(map(int,input().split())) for index,item in enumerate(l): if item!=-1 and W>=index+w: dp[index+w]=max(item+v,l[index+w]) l=dp[:] print((max(l)))
# coding: utf-8 # Your code here! N,W=list(map(int,input().split())) jwels=[] for _ in range(N): jwels.append(list(map(int,input().split()))) dp=[-1]*(W+1) dp[0]=0 for w,v in jwels: for i in range(W+1)[::-1]: if dp[i]!=-1 and i+w<=W: dp[i+w]=max(dp[i]+v,dp[i+w]) ...
15
19
304
336
# coding: utf-8 # Your code here! N, W = list(map(int, input().split())) l = [-1] * (W + 1) l[0] = 0 dp = l[:] for i in range(N): w, v = list(map(int, input().split())) for index, item in enumerate(l): if item != -1 and W >= index + w: dp[index + w] = max(item + v, l[index + w]) l = dp[:...
# coding: utf-8 # Your code here! N, W = list(map(int, input().split())) jwels = [] for _ in range(N): jwels.append(list(map(int, input().split()))) dp = [-1] * (W + 1) dp[0] = 0 for w, v in jwels: for i in range(W + 1)[::-1]: if dp[i] != -1 and i + w <= W: dp[i + w] = max(dp[i] + v, dp[i + ...
false
21.052632
[ "-l = [-1] * (W + 1)", "-l[0] = 0", "-dp = l[:]", "-for i in range(N):", "- w, v = list(map(int, input().split()))", "- for index, item in enumerate(l):", "- if item != -1 and W >= index + w:", "- dp[index + w] = max(item + v, l[index + w])", "- l = dp[:]", "-print((max(...
false
0.038022
0.104628
0.363397
[ "s837402432", "s446351798" ]
u321035578
p02768
python
s375293612
s410541713
144
101
3,064
3,064
Accepted
Accepted
29.86
def main(): n,a,b = list(map(int,input().split())) MOD = 10**9 +7 s = pow(2,n,MOD)-1 P_ni = 1 F_i = 1 s = s - comb_mod(n,a,MOD) s = s - comb_mod(n,b,MOD) print((s%MOD)) def comb_mod(n, k, mod): numerator = 1 denominator = 1 for i in range(k): numera...
def main(): n,a,b = list(map(int,input().split())) MOD = 10**9 +7 s = pow(2,n,MOD)-1 print((comb_mod(n,MOD,a,b,s))) def comb_mod(n, mod,a,b,s): numerator = 1 denominator = 1 for i in range(b): numerator = (numerator * (n - i)) % mod denominator = (denominato...
24
20
506
497
def main(): n, a, b = list(map(int, input().split())) MOD = 10**9 + 7 s = pow(2, n, MOD) - 1 P_ni = 1 F_i = 1 s = s - comb_mod(n, a, MOD) s = s - comb_mod(n, b, MOD) print((s % MOD)) def comb_mod(n, k, mod): numerator = 1 denominator = 1 for i in range(k): numerator...
def main(): n, a, b = list(map(int, input().split())) MOD = 10**9 + 7 s = pow(2, n, MOD) - 1 print((comb_mod(n, MOD, a, b, s))) def comb_mod(n, mod, a, b, s): numerator = 1 denominator = 1 for i in range(b): numerator = (numerator * (n - i)) % mod denominator = (denominator...
false
16.666667
[ "- P_ni = 1", "- F_i = 1", "- s = s - comb_mod(n, a, MOD)", "- s = s - comb_mod(n, b, MOD)", "- print((s % MOD))", "+ print((comb_mod(n, MOD, a, b, s)))", "-def comb_mod(n, k, mod):", "+def comb_mod(n, mod, a, b, s):", "- for i in range(k):", "+ for i in range(b):", "- ...
false
0.089106
0.093318
0.954868
[ "s375293612", "s410541713" ]
u145231176
p02863
python
s446097798
s972811456
879
531
226,816
227,232
Accepted
Accepted
39.59
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
87
97
2,603
2,545
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
false
10.309278
[ "-N, A = getNM()", "+N, M = getNM()", "+query = [getList() for i in range(N)]", "+w_rev = []", "+v_rev = []", "- a, b = getNM()", "- w.append(a)", "- v.append(b)", "-# limit回までコストカットできる", "-def knapsack_6(N, upper, limit, weight, value):", "- dp = [[[0] * (upper + 1) for i in range(l...
false
0.038013
0.048337
0.786418
[ "s446097798", "s972811456" ]
u171276253
p03478
python
s087598134
s892540725
38
35
3,060
3,060
Accepted
Accepted
7.89
x, min, max = input().rstrip().split() ans = 0 i = int(x) while i > 0: num = sum(list(map(int, str(i)))) if int(min) <= num <=int(max): ans += i i = i - 1 print(ans)
x, min, max = input().rstrip().split() ans = 0 i = int(x) while i > 0: num = sum(map(int, str(i))) if int(min) <= num <=int(max): ans += i i = i - 1 print(ans)
10
9
196
187
x, min, max = input().rstrip().split() ans = 0 i = int(x) while i > 0: num = sum(list(map(int, str(i)))) if int(min) <= num <= int(max): ans += i i = i - 1 print(ans)
x, min, max = input().rstrip().split() ans = 0 i = int(x) while i > 0: num = sum(map(int, str(i))) if int(min) <= num <= int(max): ans += i i = i - 1 print(ans)
false
10
[ "- num = sum(list(map(int, str(i))))", "+ num = sum(map(int, str(i)))" ]
false
0.046562
0.109932
0.423555
[ "s087598134", "s892540725" ]
u043048943
p02585
python
s533930807
s797737188
673
544
75,220
70,548
Accepted
Accepted
19.17
def main(): from sys import setrecursionlimit, stdin, stderr from os import environ from collections import defaultdict, deque, Counter from math import ceil, floor from itertools import accumulate, combinations, combinations_with_replacement setrecursionlimit(10**6) dbg = (lambda *so...
def main(): from sys import setrecursionlimit, stdin, stderr from os import environ from collections import defaultdict, deque, Counter from math import ceil, floor from itertools import accumulate, combinations, combinations_with_replacement setrecursionlimit(10**6) dbg = (lambda *so...
67
72
2,110
2,272
def main(): from sys import setrecursionlimit, stdin, stderr from os import environ from collections import defaultdict, deque, Counter from math import ceil, floor from itertools import accumulate, combinations, combinations_with_replacement setrecursionlimit(10**6) dbg = ( ( ...
def main(): from sys import setrecursionlimit, stdin, stderr from os import environ from collections import defaultdict, deque, Counter from math import ceil, floor from itertools import accumulate, combinations, combinations_with_replacement setrecursionlimit(10**6) dbg = ( ( ...
false
6.944444
[ "- sum_score_set = max(0, sum_score_set_real)", "+ # sum_score_set = max(0,sum_score_set_real)", "- tmp_max = cum_sum_1 + (K - num_move) // len_set * sum_score_set", "+ tmp_max = cum_sum_1", "+ if sum_score_set_real > 0:", "+ tm...
false
0.100468
0.042541
2.36165
[ "s533930807", "s797737188" ]
u537962130
p03474
python
s699353260
s226275570
187
101
38,384
61,396
Accepted
Accepted
45.99
a,b=list(map(int,input().split())) s=eval(input()) print(('Yes' if s[a]=='-' and s.count('-')==1 and len(s)==a+b+1 else 'No'))
a,b=list(map(int,input().split())) s=eval(input()) if s.count('-')!=1: r='No' else: t,u=s.split('-') if len(t)==a and len(u)==b and (t+u).isdecimal(): r='Yes' else: r='No' print(r)
3
11
114
186
a, b = list(map(int, input().split())) s = eval(input()) print(("Yes" if s[a] == "-" and s.count("-") == 1 and len(s) == a + b + 1 else "No"))
a, b = list(map(int, input().split())) s = eval(input()) if s.count("-") != 1: r = "No" else: t, u = s.split("-") if len(t) == a and len(u) == b and (t + u).isdecimal(): r = "Yes" else: r = "No" print(r)
false
72.727273
[ "-print((\"Yes\" if s[a] == \"-\" and s.count(\"-\") == 1 and len(s) == a + b + 1 else \"No\"))", "+if s.count(\"-\") != 1:", "+ r = \"No\"", "+else:", "+ t, u = s.split(\"-\")", "+ if len(t) == a and len(u) == b and (t + u).isdecimal():", "+ r = \"Yes\"", "+ else:", "+ r =...
false
0.045307
0.03815
1.187605
[ "s699353260", "s226275570" ]
u525065967
p02756
python
s618852474
s774551152
690
602
12,272
8,436
Accepted
Accepted
12.75
# D - String Formation from collections import deque s = deque(input()) q = int(input()) odd = 0 for i in range(q): t,*fc = input().split() if t=='1': odd ^= 1 #t1 else: #t2 if odd ^ (int(fc[0])-1): s.append(fc[1]) else: s.appendleft(fc[1]) if odd: deque.reverse(s) print(*s, sep=...
# D - String Formation from collections import deque s = deque(eval(input())) q = int(eval(input())) odd = 0 for i in range(q): t,*fc = input().split() if t=='1': odd ^= 1 #t1 else: #t2 if odd ^ (int(fc[0])-1): s.append(fc[1]) else: s.appendleft(fc[1]) if odd: deque.reverse(s) pr...
13
13
323
323
# D - String Formation from collections import deque s = deque(input()) q = int(input()) odd = 0 for i in range(q): t, *fc = input().split() if t == "1": odd ^= 1 # t1 else: # t2 if odd ^ (int(fc[0]) - 1): s.append(fc[1]) else: s.appendleft(fc[1]) if odd: ...
# D - String Formation from collections import deque s = deque(eval(input())) q = int(eval(input())) odd = 0 for i in range(q): t, *fc = input().split() if t == "1": odd ^= 1 # t1 else: # t2 if odd ^ (int(fc[0]) - 1): s.append(fc[1]) else: s.appendleft(fc[1...
false
0
[ "-s = deque(input())", "-q = int(input())", "+s = deque(eval(input()))", "+q = int(eval(input()))", "-print(*s, sep=\"\")", "+print((\"\".join(s)))" ]
false
0.091274
0.045369
2.011814
[ "s618852474", "s774551152" ]
u006880673
p02900
python
s254119157
s436544996
1,327
83
108,444
63,456
Accepted
Accepted
93.75
from math import sqrt A, B = list(map(int, input().split())) def divisor(a, b): max_num = int(sqrt(a)) divisor_list = [] for i in range(1, max_num + 1): if a % i == 0 and b % i == 0: divisor_list.append(i) # for j in divisor_list: # if a % (i*j) =...
A, B = list(map(int, input().split())) def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: ...
46
37
1,150
689
from math import sqrt A, B = list(map(int, input().split())) def divisor(a, b): max_num = int(sqrt(a)) divisor_list = [] for i in range(1, max_num + 1): if a % i == 0 and b % i == 0: divisor_list.append(i) # for j in divisor_list: # if a % (i*j) == 0 and b ...
A, B = list(map(int, input().split())) def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1...
false
19.565217
[ "-from math import sqrt", "-", "-def divisor(a, b):", "- max_num = int(sqrt(a))", "- divisor_list = []", "- for i in range(1, max_num + 1):", "- if a % i == 0 and b % i == 0:", "- divisor_list.append(i)", "- # for j in divisor_list:", "- # if a ...
false
0.040953
0.037106
1.103689
[ "s254119157", "s436544996" ]
u073549161
p03485
python
s222398577
s176100953
170
17
38,384
2,940
Accepted
Accepted
90
import math a,b = list(map(int, input().split())) print((math.ceil( (a+b) / 2) ))
import math a,b = list(map(int, input().split())) print((int(math.ceil((a+b)/2))))
3
3
75
76
import math a, b = list(map(int, input().split())) print((math.ceil((a + b) / 2)))
import math a, b = list(map(int, input().split())) print((int(math.ceil((a + b) / 2))))
false
0
[ "-print((math.ceil((a + b) / 2)))", "+print((int(math.ceil((a + b) / 2))))" ]
false
0.127857
0.047512
2.691053
[ "s222398577", "s176100953" ]
u183422236
p03290
python
s429397940
s757557144
25
20
3,188
3,064
Accepted
Accepted
20
d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for i in range(d)] min_ac1 = 1000 min_ac2 = 1000 for i in range(2 ** d): points = 0 ac = 0 for j in range(d): if ((i >> j) & 1) == 1: points += pc[j][0] * 100 * (j + 1) + pc[j][1] ac += p...
def dfs(i, sum, cnt, memo): if i == d + 1: if sum >= g: tmp.append(cnt) else: cnt += min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100))) if sum + min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100))) * max(memo) * 100 >= g: ...
29
25
893
699
d, g = list(map(int, input().split())) pc = [list(map(int, input().split())) for i in range(d)] min_ac1 = 1000 min_ac2 = 1000 for i in range(2**d): points = 0 ac = 0 for j in range(d): if ((i >> j) & 1) == 1: points += pc[j][0] * 100 * (j + 1) + pc[j][1] ac += pc[j][0] if...
def dfs(i, sum, cnt, memo): if i == d + 1: if sum >= g: tmp.append(cnt) else: cnt += min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100))) if ( sum + min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100))) ...
false
13.793103
[ "+def dfs(i, sum, cnt, memo):", "+ if i == d + 1:", "+ if sum >= g:", "+ tmp.append(cnt)", "+ else:", "+ cnt += min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100)))", "+ if (", "+ sum", "+ + min(p_lst[max(memo) ...
false
0.039608
0.076735
0.516163
[ "s429397940", "s757557144" ]
u020390084
p02953
python
s676372528
s420203988
92
85
14,396
15,288
Accepted
Accepted
7.61
n = int(eval(input())) h = list(map(int, input().split())) current_max = 0 for i in range(n): if current_max > h[i] + 1: print("No") break else: current_max = max(current_max, h[i]) if i == n-1: print("Yes")
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, H: "List[int]"): ## 右側に2以上低いものがあったら不可能 cur_max = 0 for i in range(N): if cur_max - H[i] >= 2: print(NO) return cur_max = max(cur_max,H[i]) prin...
11
32
241
680
n = int(eval(input())) h = list(map(int, input().split())) current_max = 0 for i in range(n): if current_max > h[i] + 1: print("No") break else: current_max = max(current_max, h[i]) if i == n - 1: print("Yes")
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, H: "List[int]"): ## 右側に2以上低いものがあったら不可能 cur_max = 0 for i in range(N): if cur_max - H[i] >= 2: print(NO) return cur_max = max(cur_max, H[i]) print(YES) return...
false
65.625
[ "-n = int(eval(input()))", "-h = list(map(int, input().split()))", "-current_max = 0", "-for i in range(n):", "- if current_max > h[i] + 1:", "- print(\"No\")", "- break", "- else:", "- current_max = max(current_max, h[i])", "- if i == n - 1:", "- pri...
false
0.038552
0.072971
0.528327
[ "s676372528", "s420203988" ]
u017810624
p02793
python
s089563429
s554321054
488
328
119,144
115,056
Accepted
Accepted
32.79
from fractions import gcd import collections def lcm(x, y): return (x*y)//gcd(x, y) def extgcd(a,b): r = [1,0,a] w = [0,1,b] while w[2]!=1: q = r[2]//w[2] r2 = w w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]] r = r2 w = w2 return [w[0],w[1]] def mod_...
def extgcd(a,b): r=[1,0,a] w=[0,1,b] while w[2]!=1: q=r[2]//w[2] r2=w w2=[r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]] r=r2 w=w2 return [w[0],w[1]] def mod_inv(a,m): x=extgcd(a,m)[0] return (m+x%m)%m def primes(n): is_prime=[True]*(n+1) is_prime[0]=False is_prime[1]=False...
50
60
1,039
1,114
from fractions import gcd import collections def lcm(x, y): return (x * y) // gcd(x, y) def extgcd(a, b): r = [1, 0, a] w = [0, 1, b] while w[2] != 1: q = r[2] // w[2] r2 = w w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]] r = r2 w = w2 return [w[...
def extgcd(a, b): r = [1, 0, a] w = [0, 1, b] while w[2] != 1: q = r[2] // w[2] r2 = w w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]] r = r2 w = w2 return [w[0], w[1]] def mod_inv(a, m): x = extgcd(a, m)[0] return (m + x % m) % m def primes(n...
false
16.666667
[ "-from fractions import gcd", "-import collections", "-", "-", "-def lcm(x, y):", "- return (x * y) // gcd(x, y)", "-", "-", "-def factorize(n):", "- fct = [] # prime factor", "- b, e = 2, 0 # base, exponent", "- while b * b <= n:", "- while n % b == 0:", "- ...
false
0.510508
0.654128
0.78044
[ "s089563429", "s554321054" ]
u644907318
p03331
python
s389609752
s849817651
277
105
41,580
73,444
Accepted
Accepted
62.09
N = int(eval(input())) cmin = 10**5 for x in range(1,N): y = str(N-x) x = str(x) cnt = 0 for i in range(len(x)): cnt += int(x[i]) for j in range(len(y)): cnt += int(y[j]) cmin = min(cmin,cnt) print(cmin)
N = int(eval(input())) cmin = 1000 for i in range(1,N): a = str(i) cnt = 0 for j in range(len(a)): cnt += int(a[j]) b = str(N-i) for j in range(len(b)): cnt += int(b[j]) cmin = min(cmin,cnt) print(cmin)
12
12
248
247
N = int(eval(input())) cmin = 10**5 for x in range(1, N): y = str(N - x) x = str(x) cnt = 0 for i in range(len(x)): cnt += int(x[i]) for j in range(len(y)): cnt += int(y[j]) cmin = min(cmin, cnt) print(cmin)
N = int(eval(input())) cmin = 1000 for i in range(1, N): a = str(i) cnt = 0 for j in range(len(a)): cnt += int(a[j]) b = str(N - i) for j in range(len(b)): cnt += int(b[j]) cmin = min(cmin, cnt) print(cmin)
false
0
[ "-cmin = 10**5", "-for x in range(1, N):", "- y = str(N - x)", "- x = str(x)", "+cmin = 1000", "+for i in range(1, N):", "+ a = str(i)", "- for i in range(len(x)):", "- cnt += int(x[i])", "- for j in range(len(y)):", "- cnt += int(y[j])", "+ for j in range(len(a...
false
0.117122
0.165293
0.70857
[ "s389609752", "s849817651" ]
u112364985
p03474
python
s566317529
s358847168
29
26
9,172
9,128
Accepted
Accepted
10.34
a,b=list(map(int,input().split())) num_list=[i for i in range(10)] num_list=[str(i) for i in num_list] s=eval(input()) if s[a]=="-": s=s[:a]+s[a+1:] for i in range(len(s)): if s[i] not in num_list: print("No") exit() print("Yes") exit() print("No")
a,b=list(map(int,input().split())) num_list=[str(i) for i in range(10)] s=eval(input()) if s[a]=="-": s=s[:a]+s[a+1:] for i in range(len(s)): if s[i] not in num_list: print("No") exit() print("Yes") exit() print("No")
13
12
296
264
a, b = list(map(int, input().split())) num_list = [i for i in range(10)] num_list = [str(i) for i in num_list] s = eval(input()) if s[a] == "-": s = s[:a] + s[a + 1 :] for i in range(len(s)): if s[i] not in num_list: print("No") exit() print("Yes") exit() print("No")
a, b = list(map(int, input().split())) num_list = [str(i) for i in range(10)] s = eval(input()) if s[a] == "-": s = s[:a] + s[a + 1 :] for i in range(len(s)): if s[i] not in num_list: print("No") exit() print("Yes") exit() print("No")
false
7.692308
[ "-num_list = [i for i in range(10)]", "-num_list = [str(i) for i in num_list]", "+num_list = [str(i) for i in range(10)]" ]
false
0.119887
0.047204
2.539747
[ "s566317529", "s358847168" ]
u075012704
p03488
python
s675660329
s412407887
1,716
1,493
3,816
3,816
Accepted
Accepted
13
S = list(input().split("T")) x, y = list(map(int, input().split())) X_act = [len(i) for i in S[::2]] Y_act = [len(i) for i in S[1::2]] X_reached = {X_act[0]} del X_act[0] for xa in X_act: tmp = set() for xr in X_reached: tmp.add(xr+xa) tmp.add(xr-xa) X_reached = tmp Y_reach...
S = [len(s) for s in input().split("T")] X, Y = list(map(int, input().split())) # X方向・Y方向の移動成分 X_move = S[2::2] Y_move = S[1::2] # X方向・Y方法の到達可能な場所 X_reached = {S[0]} Y_reached = {0} # 到達可能な場所を計算 for xm in X_move: tmp = set() for xr in X_reached: tmp.add(xr + xm) tmp.add(xr - x...
27
27
535
540
S = list(input().split("T")) x, y = list(map(int, input().split())) X_act = [len(i) for i in S[::2]] Y_act = [len(i) for i in S[1::2]] X_reached = {X_act[0]} del X_act[0] for xa in X_act: tmp = set() for xr in X_reached: tmp.add(xr + xa) tmp.add(xr - xa) X_reached = tmp Y_reached = {0} for y...
S = [len(s) for s in input().split("T")] X, Y = list(map(int, input().split())) # X方向・Y方向の移動成分 X_move = S[2::2] Y_move = S[1::2] # X方向・Y方法の到達可能な場所 X_reached = {S[0]} Y_reached = {0} # 到達可能な場所を計算 for xm in X_move: tmp = set() for xr in X_reached: tmp.add(xr + xm) tmp.add(xr - xm) X_reached = ...
false
0
[ "-S = list(input().split(\"T\"))", "-x, y = list(map(int, input().split()))", "-X_act = [len(i) for i in S[::2]]", "-Y_act = [len(i) for i in S[1::2]]", "-X_reached = {X_act[0]}", "-del X_act[0]", "-for xa in X_act:", "+S = [len(s) for s in input().split(\"T\")]", "+X, Y = list(map(int, input().spli...
false
0.064833
0.038456
1.685886
[ "s675660329", "s412407887" ]
u677705680
p03107
python
s615331030
s065729126
36
18
3,188
3,188
Accepted
Accepted
50
S = str(eval(input())) zero_num = 0 for i in range(len(S)): if S[i] == "0": zero_num += 1 print((2*min(zero_num, len(S) - zero_num)))
S = str(eval(input())) zero_num = S.count("0") print((2*min(zero_num, len(S) - zero_num)))
9
5
148
88
S = str(eval(input())) zero_num = 0 for i in range(len(S)): if S[i] == "0": zero_num += 1 print((2 * min(zero_num, len(S) - zero_num)))
S = str(eval(input())) zero_num = S.count("0") print((2 * min(zero_num, len(S) - zero_num)))
false
44.444444
[ "-zero_num = 0", "-for i in range(len(S)):", "- if S[i] == \"0\":", "- zero_num += 1", "+zero_num = S.count(\"0\")" ]
false
0.047352
0.047391
0.999169
[ "s615331030", "s065729126" ]
u069838609
p03283
python
s131538646
s642257979
1,892
1,468
114,648
116,568
Accepted
Accepted
22.41
from copy import deepcopy N, M, Q = [int(elem) for elem in input().split(' ')] lines = [[int(elem) for elem in input().split(' ')] for _ in range(M)] queries = [[int(elem) for elem in input().split(' ')] for _ in range(Q)] def cuml_1d(N, lines, queries): coords = [[0] * N for _ in range(N)] for l, r...
from copy import deepcopy N, M, Q = [int(elem) for elem in input().split(' ')] lines = [[int(elem) for elem in input().split(' ')] for _ in range(M)] queries = [[int(elem) for elem in input().split(' ')] for _ in range(Q)] def cuml_1d(N, lines, queries): coords = [[0] * N for _ in range(N)] for l, r...
28
52
886
1,621
from copy import deepcopy N, M, Q = [int(elem) for elem in input().split(" ")] lines = [[int(elem) for elem in input().split(" ")] for _ in range(M)] queries = [[int(elem) for elem in input().split(" ")] for _ in range(Q)] def cuml_1d(N, lines, queries): coords = [[0] * N for _ in range(N)] for l, r in lines...
from copy import deepcopy N, M, Q = [int(elem) for elem in input().split(" ")] lines = [[int(elem) for elem in input().split(" ")] for _ in range(M)] queries = [[int(elem) for elem in input().split(" ")] for _ in range(Q)] def cuml_1d(N, lines, queries): coords = [[0] * N for _ in range(N)] for l, r in lines...
false
46.153846
[ "-cuml_1d(N, lines, queries)", "+# cuml_1d(N, lines, queries)", "+def cuml_2d(N, lines, queries):", "+ coords = [[0] * N for _ in range(N)]", "+ for l, r in lines:", "+ coords[l - 1][r - 1] += 1", "+ cuml_l = deepcopy(coords)", "+ for r in range(N):", "+ for l in range(1, N...
false
0.045041
0.040881
1.101784
[ "s131538646", "s642257979" ]
u997521090
p03107
python
s922558136
s620094484
48
13
4,228
2,692
Accepted
Accepted
72.92
P=list(map(int,list(input())));print(min(sum(P),len(P)-sum(P))*2)
P=input();print(min(P.count('0'),P.count('1'))*2)
1
1
62
52
P = list(map(int, list(input()))) print(min(sum(P), len(P) - sum(P)) * 2)
P = input() print(min(P.count("0"), P.count("1")) * 2)
false
0
[ "-P = list(map(int, list(input())))", "-print(min(sum(P), len(P) - sum(P)) * 2)", "+P = input()", "+print(min(P.count(\"0\"), P.count(\"1\")) * 2)" ]
false
0.063295
0.08318
0.760939
[ "s922558136", "s620094484" ]
u223904637
p03216
python
s070524488
s681069466
2,503
1,960
54,108
60,012
Accepted
Accepted
21.69
import sys input=sys.stdin.readline n=int(eval(input())) l=eval(input()) q=int(eval(input())) kl=tuple(map(int,input().split())) for k in kl: d=0 m=0 dm=0 ans=0 for j in range(n): if l[j]=='D': d+=1 elif l[j]=='M': m+=1 dm+=d ...
import sys input=sys.stdin.readline def main(): n=int(eval(input())) l=eval(input()) q=int(eval(input())) kl=tuple(map(int,input().split())) for k in kl: d=0 m=0 dm=0 ans=0 for j in range(n): if l[j]=='D': d+=1 ...
26
30
509
657
import sys input = sys.stdin.readline n = int(eval(input())) l = eval(input()) q = int(eval(input())) kl = tuple(map(int, input().split())) for k in kl: d = 0 m = 0 dm = 0 ans = 0 for j in range(n): if l[j] == "D": d += 1 elif l[j] == "M": m += 1 ...
import sys input = sys.stdin.readline def main(): n = int(eval(input())) l = eval(input()) q = int(eval(input())) kl = tuple(map(int, input().split())) for k in kl: d = 0 m = 0 dm = 0 ans = 0 for j in range(n): if l[j] == "D": d ...
false
13.333333
[ "-n = int(eval(input()))", "-l = eval(input())", "-q = int(eval(input()))", "-kl = tuple(map(int, input().split()))", "-for k in kl:", "- d = 0", "- m = 0", "- dm = 0", "- ans = 0", "- for j in range(n):", "- if l[j] == \"D\":", "- d += 1", "- elif l[j...
false
0.033105
0.032501
1.018583
[ "s070524488", "s681069466" ]
u750838232
p02714
python
s646882316
s610011928
1,788
151
9,196
68,296
Accepted
Accepted
91.55
n = int(eval(input())) s = eval(input()) r = s.count("R") g = s.count("G") b = s.count("B") ans = r * g * b for i in range(n): for j in range(1, n // 2 + 1): if i-j < 0 or i+j > n-1: break if s[i] != s[i-j] and s[i] != s[i+j] and s[i-j] != s[i+j]: ans -= ...
n = int(eval(input())) s = eval(input()) r = s.count("R") g = s.count("G") b = s.count("B") ans = r * g * b for i in range(n): for j in range(1, n // 2 + 1): if i-j < 0 or i+j > n-1: continue if s[i] != s[i-j] and s[i] != s[i+j] and s[i-j] != s[i+j]: ans -=...
19
18
324
325
n = int(eval(input())) s = eval(input()) r = s.count("R") g = s.count("G") b = s.count("B") ans = r * g * b for i in range(n): for j in range(1, n // 2 + 1): if i - j < 0 or i + j > n - 1: break if s[i] != s[i - j] and s[i] != s[i + j] and s[i - j] != s[i + j]: ans -= 1 print...
n = int(eval(input())) s = eval(input()) r = s.count("R") g = s.count("G") b = s.count("B") ans = r * g * b for i in range(n): for j in range(1, n // 2 + 1): if i - j < 0 or i + j > n - 1: continue if s[i] != s[i - j] and s[i] != s[i + j] and s[i - j] != s[i + j]: ans -= 1 pr...
false
5.263158
[ "- break", "+ continue" ]
false
0.079338
0.041171
1.927046
[ "s646882316", "s610011928" ]
u972731768
p02258
python
s653970244
s499761037
470
120
13,592
19,828
Accepted
Accepted
74.47
i=input r=range N=int(i()) A=[int(i()) for _ in r(N)] mp=A[1]-A[0] mn=A[0] for a in r(1,N): x=A[a] b=x-mn if mp<(b): mp=b if 0>b:mn=x if x<mn:mn=x print(mp)
import sys i=input n = int(i()) r0 = int(i()) r1 = int(i()) mx = r1-r0 mn = min(r1,r0) for i in map(int,sys.stdin.readlines()): a=i-mn if mx<a: mx=a if 0>a:mn=i elif mn>i:mn=i print(mx)
14
14
201
226
i = input r = range N = int(i()) A = [int(i()) for _ in r(N)] mp = A[1] - A[0] mn = A[0] for a in r(1, N): x = A[a] b = x - mn if mp < (b): mp = b if 0 > b: mn = x if x < mn: mn = x print(mp)
import sys i = input n = int(i()) r0 = int(i()) r1 = int(i()) mx = r1 - r0 mn = min(r1, r0) for i in map(int, sys.stdin.readlines()): a = i - mn if mx < a: mx = a if 0 > a: mn = i elif mn > i: mn = i print(mx)
false
0
[ "+import sys", "+", "-r = range", "-N = int(i())", "-A = [int(i()) for _ in r(N)]", "-mp = A[1] - A[0]", "-mn = A[0]", "-for a in r(1, N):", "- x = A[a]", "- b = x - mn", "- if mp < (b):", "- mp = b", "- if 0 > b:", "- mn = x", "- if x < mn:", "- ...
false
0.075518
0.069441
1.087511
[ "s653970244", "s499761037" ]
u028973125
p02760
python
s279599845
s678057528
88
26
3,700
9,084
Accepted
Accepted
70.45
import sys from pprint import pprint bingo = [[] for _ in range(3)] for i in range(3): bingo[i] = list(map(int, sys.stdin.readline().strip().split())) N = int(sys.stdin.readline().strip()) B = set() for _ in range(N): B.add(int(sys.stdin.readline().strip())) bingo_flag = False for i in range(3):...
import sys input = sys.stdin.readline bingo = [] for _ in range(3): bingo.append(list(map(int, input().split()))) N = int(eval(input())) nums = [] for _ in range(N): nums.append(int(eval(input()))) for num in nums: for i in range(3): for j in range(3): if bingo[i][j] ...
45
37
844
785
import sys from pprint import pprint bingo = [[] for _ in range(3)] for i in range(3): bingo[i] = list(map(int, sys.stdin.readline().strip().split())) N = int(sys.stdin.readline().strip()) B = set() for _ in range(N): B.add(int(sys.stdin.readline().strip())) bingo_flag = False for i in range(3): tmp = [] ...
import sys input = sys.stdin.readline bingo = [] for _ in range(3): bingo.append(list(map(int, input().split()))) N = int(eval(input())) nums = [] for _ in range(N): nums.append(int(eval(input()))) for num in nums: for i in range(3): for j in range(3): if bingo[i][j] == num: ...
false
17.777778
[ "-from pprint import pprint", "-bingo = [[] for _ in range(3)]", "+input = sys.stdin.readline", "+bingo = []", "+for _ in range(3):", "+ bingo.append(list(map(int, input().split())))", "+N = int(eval(input()))", "+nums = []", "+for _ in range(N):", "+ nums.append(int(eval(input())))", "+fo...
false
0.037997
0.039022
0.973724
[ "s279599845", "s678057528" ]
u077127204
p03632
python
s405365201
s003367654
320
17
21,532
2,940
Accepted
Accepted
94.69
import numpy as np A, B, C, D = list(map(int, input().split())) x = sorted(zip([A, B, C, D], [1, -1, 1, -1])) if x[1][1] == 1: print((x[2][0] - x[1][0])) else: print((0))
x = list(map(int, input().split())) x = sorted(zip(x, [1, -1, 1, -1])) if x[1][1] == 1: print((x[2][0] - x[1][0])) else: print((0))
8
6
173
131
import numpy as np A, B, C, D = list(map(int, input().split())) x = sorted(zip([A, B, C, D], [1, -1, 1, -1])) if x[1][1] == 1: print((x[2][0] - x[1][0])) else: print((0))
x = list(map(int, input().split())) x = sorted(zip(x, [1, -1, 1, -1])) if x[1][1] == 1: print((x[2][0] - x[1][0])) else: print((0))
false
25
[ "-import numpy as np", "-", "-A, B, C, D = list(map(int, input().split()))", "-x = sorted(zip([A, B, C, D], [1, -1, 1, -1]))", "+x = list(map(int, input().split()))", "+x = sorted(zip(x, [1, -1, 1, -1]))" ]
false
0.041314
0.036425
1.134233
[ "s405365201", "s003367654" ]
u965436898
p03993
python
s159286274
s474448274
133
66
22,500
14,008
Accepted
Accepted
50.38
n = int(eval(input())) a = list(map(int,input().split())) # ペアの数だけsetで消されるからn-len(s)で差を取るとペアの数がとってこれる # sortedとset({}で表される)がキーになっている s = {tuple(sorted([a[i],i+1]))for i in range(n)} print((n-len(s)))
n = int(eval(input())) a = list(map(int,input().split())) ans = 0 for key_i, i in enumerate(a): if a[i - 1] == key_i + 1: ans += 1 print((ans//2))
6
7
196
150
n = int(eval(input())) a = list(map(int, input().split())) # ペアの数だけsetで消されるからn-len(s)で差を取るとペアの数がとってこれる # sortedとset({}で表される)がキーになっている s = {tuple(sorted([a[i], i + 1])) for i in range(n)} print((n - len(s)))
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for key_i, i in enumerate(a): if a[i - 1] == key_i + 1: ans += 1 print((ans // 2))
false
14.285714
[ "-# ペアの数だけsetで消されるからn-len(s)で差を取るとペアの数がとってこれる", "-# sortedとset({}で表される)がキーになっている", "-s = {tuple(sorted([a[i], i + 1])) for i in range(n)}", "-print((n - len(s)))", "+ans = 0", "+for key_i, i in enumerate(a):", "+ if a[i - 1] == key_i + 1:", "+ ans += 1", "+print((ans // 2))" ]
false
0.045428
0.045829
0.991263
[ "s159286274", "s474448274" ]
u301624971
p02695
python
s076059629
s351595069
505
151
9,480
67,204
Accepted
Accepted
70.1
import math import itertools import sys import collections def solve(N,M,Q,ABCD): ans = 0 A = [i for i in range(1,M+1)] for p in itertools.combinations_with_replacement(A,N): tmp = 0 for a,b,c,d in ABCD: if(p[b-1] - p [a-1] == c): tmp+=d an...
import math import itertools def solve(N:int,M:int,Q:int,ABCD:list) -> int: ans = 0 elements = [i for i in range(1,M+1)] # 数列Aにあり得る要素 # 条件を満たす数列Aを作成 for A in itertools.combinations_with_replacement(elements,N): total = 0 # 現在の数列の得点を格納する変数 for a,b,c,d in ABCD: if(...
28
27
586
677
import math import itertools import sys import collections def solve(N, M, Q, ABCD): ans = 0 A = [i for i in range(1, M + 1)] for p in itertools.combinations_with_replacement(A, N): tmp = 0 for a, b, c, d in ABCD: if p[b - 1] - p[a - 1] == c: tmp += d an...
import math import itertools def solve(N: int, M: int, Q: int, ABCD: list) -> int: ans = 0 elements = [i for i in range(1, M + 1)] # 数列Aにあり得る要素 # 条件を満たす数列Aを作成 for A in itertools.combinations_with_replacement(elements, N): total = 0 # 現在の数列の得点を格納する変数 for a, b, c, d in ABCD: ...
false
3.571429
[ "-import sys", "-import collections", "-def solve(N, M, Q, ABCD):", "+def solve(N: int, M: int, Q: int, ABCD: list) -> int:", "- A = [i for i in range(1, M + 1)]", "- for p in itertools.combinations_with_replacement(A, N):", "- tmp = 0", "+ elements = [i for i in range(1, M + 1)] # 数列...
false
0.179605
0.043149
4.162408
[ "s076059629", "s351595069" ]
u079022693
p02714
python
s024394065
s178039549
600
497
110,176
106,408
Accepted
Accepted
17.17
from sys import stdin import numpy as np from numba import njit def main(): #入力 readline=stdin.readline n=int(readline()) s=readline().strip() ans=s.count("R")*s.count("G")*s.count("B") s=np.array([0 if s[i]=="R" else 1 if s[i]=="G" else 2 for i in range(n)],dtype=np.int64) print...
from sys import stdin import numpy as np from numba import njit def main(): #入力 readline=stdin.readline n=int(readline()) s=readline().strip() ans=s.count("R")*s.count("G")*s.count("B") s=np.array([0 if s[i]=="R" else 1 if s[i]=="G" else 2 for i in range(n)],dtype=np.int64) print...
25
25
613
631
from sys import stdin import numpy as np from numba import njit def main(): # 入力 readline = stdin.readline n = int(readline()) s = readline().strip() ans = s.count("R") * s.count("G") * s.count("B") s = np.array( [0 if s[i] == "R" else 1 if s[i] == "G" else 2 for i in range(n)], ...
from sys import stdin import numpy as np from numba import njit def main(): # 入力 readline = stdin.readline n = int(readline()) s = readline().strip() ans = s.count("R") * s.count("G") * s.count("B") s = np.array( [0 if s[i] == "R" else 1 if s[i] == "G" else 2 for i in range(n)], ...
false
0
[ "-@njit(cache=True)", "+@njit(\"i8(i8,i8,i8[:])\", cache=True)" ]
false
0.304291
0.25611
1.188125
[ "s024394065", "s178039549" ]
u546285759
p00478
python
s869231072
s559509560
30
20
7,644
7,652
Accepted
Accepted
33.33
s=eval(input()) print((sum(s in 2*eval(input())for _ in[0]*int(eval(input())))))
s=eval(input()) print((sum(len((2*eval(input())).split(s))>1 for _ in range(int(eval(input()))))))
2
2
61
79
s = eval(input()) print((sum(s in 2 * eval(input()) for _ in [0] * int(eval(input())))))
s = eval(input()) print((sum(len((2 * eval(input())).split(s)) > 1 for _ in range(int(eval(input()))))))
false
0
[ "-print((sum(s in 2 * eval(input()) for _ in [0] * int(eval(input())))))", "+print((sum(len((2 * eval(input())).split(s)) > 1 for _ in range(int(eval(input()))))))" ]
false
0.039315
0.037729
1.042038
[ "s869231072", "s559509560" ]
u600402037
p02959
python
s392245964
s673370552
293
190
76,416
19,172
Accepted
Accepted
35.15
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = lr() B = lr() answer = 0 for i in range(N): a, b = A[i], B[i] answer += min(a, b) if a < b: remain = b - a add = min(A[i+1], remain) a...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = lr() B = lr() remain = 0 answer = 0 for i in range(N): attack = min(A[i], remain) answer += attack A[i] -= attack if A[i] > 0: at...
20
24
373
458
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = lr() B = lr() answer = 0 for i in range(N): a, b = A[i], B[i] answer += min(a, b) if a < b: remain = b - a add = min(A[i + 1], remain) answer += add ...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() A = lr() B = lr() remain = 0 answer = 0 for i in range(N): attack = min(A[i], remain) answer += attack A[i] -= attack if A[i] > 0: attack = min(A[i], B...
false
16.666667
[ "+# coding: utf-8", "+remain = 0", "- a, b = A[i], B[i]", "- answer += min(a, b)", "- if a < b:", "- remain = b - a", "- add = min(A[i + 1], remain)", "- answer += add", "- A[i + 1] -= add", "+ attack = min(A[i], remain)", "+ answer += attack", "+ ...
false
0.042503
0.041064
1.035042
[ "s392245964", "s673370552" ]
u379959788
p02983
python
s211178790
s061294189
999
351
147,604
3,060
Accepted
Accepted
64.86
L, R = list(map(int, input().split())) l = L % 2019 r = R % 2019 ans = [] if R - L >= 2019: print((0)) else: if l >= r: print((0)) else: for i in range(l, r): for k in range(l+1, r+1): ans.append(i * k % 2019) print((min(ans))) ...
L, R = list(map(int, input().split())) if R - L > 2019: print((0)) else: l = L % 2019 r = R % 2019 ans = 10000000 if r > l: for i in range(l, r): for k in range(i+1, r+1): if ans > (i * k) % 2019: ans = (i * k) % 2019 prin...
14
16
320
347
L, R = list(map(int, input().split())) l = L % 2019 r = R % 2019 ans = [] if R - L >= 2019: print((0)) else: if l >= r: print((0)) else: for i in range(l, r): for k in range(l + 1, r + 1): ans.append(i * k % 2019) print((min(ans)))
L, R = list(map(int, input().split())) if R - L > 2019: print((0)) else: l = L % 2019 r = R % 2019 ans = 10000000 if r > l: for i in range(l, r): for k in range(i + 1, r + 1): if ans > (i * k) % 2019: ans = (i * k) % 2019 print(ans) ...
false
12.5
[ "-l = L % 2019", "-r = R % 2019", "-ans = []", "-if R - L >= 2019:", "+if R - L > 2019:", "- if l >= r:", "+ l = L % 2019", "+ r = R % 2019", "+ ans = 10000000", "+ if r > l:", "+ for i in range(l, r):", "+ for k in range(i + 1, r + 1):", "+ if...
false
0.085352
0.039632
2.153642
[ "s211178790", "s061294189" ]
u201234972
p02658
python
s232542895
s103063314
79
61
21,788
24,328
Accepted
Accepted
22.78
def main(): N = int( eval(input())) t = 10**18 A = list( map( int, input().split())) ans = 1 # if Counter(A)[0] > 0: # print(0) # return A.sort() for a in A: ans *= a if ans > t: print((-1)) return print(ans) if __nam...
from collections import Counter def main(): N = int( eval(input())) t = 10**18 A = list( map( int, input().split())) ans = 1 if Counter(A)[0] > 0: print((0)) return for a in A: ans *= a if ans > t: print((-1)) return print...
17
17
343
356
def main(): N = int(eval(input())) t = 10**18 A = list(map(int, input().split())) ans = 1 # if Counter(A)[0] > 0: # print(0) # return A.sort() for a in A: ans *= a if ans > t: print((-1)) return print(ans) if __name__ == "__main__...
from collections import Counter def main(): N = int(eval(input())) t = 10**18 A = list(map(int, input().split())) ans = 1 if Counter(A)[0] > 0: print((0)) return for a in A: ans *= a if ans > t: print((-1)) return print(ans) if __na...
false
0
[ "+from collections import Counter", "+", "+", "- # if Counter(A)[0] > 0:", "- # print(0)", "- # return", "- A.sort()", "+ if Counter(A)[0] > 0:", "+ print((0))", "+ return" ]
false
0.046786
0.045116
1.037019
[ "s232542895", "s103063314" ]