s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s373380643
p04047
u258375111
1544232430
Python
Python (3.4.3)
py
Runtime Error
18
2940
122
n=int(input()) x=list(map(int, input().split())) x.sort() ans = 0 for i range(n): ans = ans + x[i*2] print(ans)
s712750022
p04047
u258375111
1544232385
Python
Python (3.4.3)
py
Runtime Error
18
2940
120
n=int(input()) x=list(map(int, input().split())) x.sort() ans=0 for i range(n): ans = ans + x[i*2] print(ans)
s739326319
p04047
u258375111
1544232295
Python
Python (3.4.3)
py
Runtime Error
17
2940
116
n=int(input()) x=list(map(int, input().split())) x.sort() ans=0 for i range(n): ans=ans+x[i*2] print(ans)
s881546734
p04047
u258375111
1544232080
Python
Python (3.4.3)
py
Runtime Error
20
2940
115
n=int(input()) x=list(map(int, input().split())) x.sort() ans=0 for i range(n): ans=ans+x[i*2] print(ans)
s634476725
p04047
u258375111
1544231888
Python
Python (3.4.3)
py
Runtime Error
18
2940
114
n=int(input()) x=list(map(int,input().split())) x.sort() ans=0 for i range(n): ans=ans+x[i*2] print(ans)
s333585563
p04047
u258375111
1544231854
Python
Python (3.4.3)
py
Runtime Error
17
2940
111
n=int(input()) x=list(map(int,input().split())) x.sort() ans=0 for i range(n): ans=+x[i*2] print(ans)
s529235642
p04047
u258375111
1544231823
Python
Python (3.4.3)
py
Runtime Error
18
2940
111
n=int(input()) x=list(map(int,input().split())) x.sort() ans=0 for i range(n): ans+=x[i*2] print(ans)
s028269684
p04047
u258375111
1544231680
Python
Python (3.4.3)
py
Runtime Error
17
2940
152
n=int(input()) x=list(map(int,input().split())) x.sort() ans=0 for i range(n): if i%2==1: pass else: ans+=min(x[i],x[i+1]) print(ans)
s568274783
p04047
u258375111
1544230900
Python
Python (3.4.3)
py
Runtime Error
17
2940
138
n=int(input()) a=[] cou=0 for i in range(n*2): a[i]=int(input()) a.sort() for i*2 in range(n): cou+=min(a[i],a[i+1]) print(cou)
s382251638
p04047
u173374079
1541225123
Python
Python (3.4.3)
py
Runtime Error
17
2940
144
n = input l = map(int, input().split()) l = sorted(l) ans = 0 for i in range(len(n)): a = l[2*i] b = l[2*i+1] ans =+ min(a,b) print(ans)
s928614242
p04047
u845333844
1539462793
Python
Python (3.4.3)
py
Runtime Error
19
2940
82
n=int(input()) l=list(map(int,input().split())) l.sort() k=l[::2] print(k.sum())
s595342593
p04047
u333139319
1539110409
Python
Python (3.4.3)
py
Runtime Error
17
2940
127
n = int(input()) l = [int(i) for i in input().split()] a = 0 for i in len(l): if i % 2 == 0: a = a + l[i] print(a)
s620457516
p04047
u361841553
1538666213
Python
Python (3.4.3)
py
Runtime Error
17
2940
99
N = int(raw_input()) list_input = sorted(map(int, raw_input().split())) print(sum(list_input[::2]))
s272670636
p04047
u361841553
1538666105
Python
Python (3.4.3)
py
Runtime Error
17
2940
202
N = int(raw_input()) list_input = map(int, raw_input().split()) list_input = sorted(list_input) sums = 0 for i in range(0,2*N,2): print(i) sums += min(list_input[i],list_input[i+1]) print(sums)
s974009912
p04047
u361841553
1538665624
Python
Python (3.4.3)
py
Runtime Error
17
2940
191
N = int(raw_input()) list_input = map(int, raw_input().split()) list_input = sorted(list_input) sums = 0 for i in range(0,2*N,2): sums += min(list_input[i],list_input[i+1]) print(sums)
s122802468
p04047
u361841553
1538665369
Python
Python (3.4.3)
py
Runtime Error
17
2940
187
N = int(input()) list_input = map(int, raw_input().split()) list_input = sorted(list_input) sums = 0 for i in range(0,2*N,2): sums += min(list_input[i],list_input[i+1]) print(sums)
s373040472
p04047
u361841553
1538665249
Python
Python (3.4.3)
py
Runtime Error
17
3060
181
N = input() list_input = map(int, raw_input().split()) list_input = sorted(list_input) sums = 0 for i in range(0,2*N,2): sums += min(list_input[i],list_input[i+1]) print(sums)
s565058803
p04047
u361841553
1538665079
Python
Python (3.4.3)
py
Runtime Error
17
2940
158
N = input() list_input = map(int, raw_input().split()) list_input = sorted(list_input) sums = 0 for i in range(N,2*N): sums += list_input[i] print(sums)
s868836591
p04047
u111421568
1537405488
Python
Python (3.4.3)
py
Runtime Error
18
3064
763
n, k = map(int, input().split()) import sys sys.setrecursionlimit(20000) l = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) l[a-1].append(b-1) l[b-1].append(a-1) def first_search(first, depth): record = 0 for i in l[first]: temp = search(first, i, depth-1) if record < temp: record = temp return record + 1 def search(before, now, depth): if depth <= 0: return 1 else: ans = 1 for i in l[now]: if before != i: ans += search(now, i, depth-1) return ans ret = 0 for i in range(n): temp = first_search(i, k) if temp > ret: ret = temp if ret > n: print(0) else: print(n-ret)
s331366516
p04047
u807772568
1534258525
Python
Python (3.4.3)
py
Runtime Error
17
2940
109
a = int(input()) b = list(map(int,input().split())) b.sorted() su = 0 for i in range(a-1): su += b[2*i]
s571583433
p04047
u807772568
1534258465
Python
Python (3.4.3)
py
Runtime Error
17
2940
107
a = int(input()) b = list(map(int,input().split())) b.sorted() su = 0 for i in range(a): su += b[2*i]
s590942362
p04047
u224119305
1533123595
Python
Python (3.4.3)
py
Runtime Error
149
12508
721
import numpy as np N, K = map(int, input().split()) E = np.zeros((N, N), dtype=int) exit(0) Elist = [] for e in range(N-1): i, o = map(int, input().split()) Elist.append((i-1, o-1)) E[i-1][o-1] = 1 E[o-1][i-1] = 1 # print("N, K=", N, K) # for e in Elist: # print(e[0], e[1]) I = np.eye(N, dtype=int) # print("I=", I) ie = I for k in range(K): ie = ie + np.matmul(I, E) # print("I + IE =", ie) # withinK = np.count_nonzero(ie, axis=0) withinK = np.zeros(N, dtype=int) for i in range(N): for j in range(N): if ie[i][j] > 0: withinK[i] += 1 # print("withinK=", withinK) maxBall = np.amax(withinK) # print("maxBall=", maxBall) solution = N - maxBall print(solution)
s439685767
p04047
u075012704
1531432460
Python
Python (3.4.3)
py
Runtime Error
23
3316
1010
from collections import deque N, K = map(int, input().split()) T = [[] for i in range(N)] E = [] for i in range(N-1): a, b = map(int, input().split()) a, b = a-1, b-1 T[a].append(b) T[b].append(a) E.append((a, b)) def bfs(n): visited = [False] * N dist = [0] * N queue = deque([n]) while queue: node = queue.pop() if visited[node]: continue visited[node] = True for n in T[node]: if not visited[n]: dist[n] = dist[node] + 1 queue.appendleft(n) return dist dist = [] for i in range(N): dist.append(bfs(i)) ans = float('inf') if K % 2 == 0: # 全ての頂点について全探索 for i in range(N): ans = min(ans, len([d for d in dist[i] if d > K / 2])) else: # 全ての辺について全探索 for a, b in E: adist = [(1 if min(d1, d2) > (K-1) / 2 else 0) for d1, d2 in zip(dist[a], dist[b])] ans = min(ans, sum(adist)) print(ans)
s036529572
p04047
u272266919
1529603853
Python
Python (3.4.3)
py
Runtime Error
17
2940
112
N = input() Li = map(int, input().split(" ")) Li.sort() total = 0 for i in Li[0::2] total += i print(total)
s408828323
p04047
u828847847
1526493488
Python
Python (2.7.6)
py
Runtime Error
11
2568
226
n = int(input()) arr = [map(int,raw_input().split()) for i in range(n)] count = 0 for i in range(n-1): for j in range(i+1,n): s = sum(arr[i]) + sum(arr[j]) comb = s*(s-1)/2 count += comb print count%(1000000000+7)
s830242700
p04047
u671395265
1519893017
Python
Python (3.4.3)
py
Runtime Error
17
2940
59
n = int(input()) print(sum(sorted(map(int, input()))[::2]))
s617678939
p04047
u433184056
1508626074
Python
Python (3.4.3)
py
Runtime Error
18
2940
166
N, X = map(int, intpu().split()) if X <= N / 3: result = 3 * (N - X) if N / 3 < X and X < N /2: result = 6 * X if N / 2 <= X: result = 3 * X print(result)
s742049259
p04047
u269390702
1508390658
Python
Python (3.4.3)
py
Runtime Error
18
2940
124
n=int(input()) l=list(map(int,input().split())) l.sort() sum=0 for x in range(0,n*2+1,2): sum+=min(l[x:x+2]) print(sum)
s853478988
p04047
u375536288
1499653060
Python
Python (2.7.6)
py
Runtime Error
10
2568
195
def gcd(a,b): if b == 0: return a return gcd(b,a%b) N,k = map(int,raw_input().split()) #k = int(raw_input()) #A = map(int, raw_input().split()) ans = gcd(N,k) print 3*(N - ans)
s866647203
p04047
u375536288
1499651248
Python
Python (2.7.6)
py
Runtime Error
10
2568
96
N = int(raw_input()) A = map(int, raw_input().split()) sum = 0 A.sort() A = A[::2] print sum(A)
s786927693
p04047
u430478288
1487448408
Python
Python (3.4.3)
py
Runtime Error
17
2940
94
N = input() kushi = sorted(list(map(int, input().split()))) even = kushi[0::2] print(sum(even)
s862646417
p04047
u486232694
1484412076
Python
Python (3.4.3)
py
Runtime Error
23
3064
222
n = int(input()) L = map(int, input().split(" ")) L_sorted = sorted(L) pairs = [] for index in range(0, len(L_sorted)/2, 2): pairs.append(L_sorted[index : index +2]) answer = sum( min(x) for x in pairs) print(answer)
s233463928
p04047
u132291455
1478315732
Python
PyPy2 (5.6.0)
py
Runtime Error
41
9200
586
ii=lambda:map(int,raw_input().split()) n,k=ii() T,F=True,False e=[[] for _ in range(n)] for _ in range(n-1): a,b=ii() e[a-1]+=[b-1];e[b-1]+=[a-1] cost=[0]*n ans=10**5 def dfs(x,f): if f>=0:vis[f]=T q=[(x,0)] while len(q): v,c=q.pop(0) if c>k/2:break cost[v]=c;vis[v]=T for w in e[v]: if not vis[w]:q+=[(w,c+1)] return n-vis.count(T) if k%2: for i in range(n): for j in e[i]: if i<j:vis=[F]*n;dfs(i,j);ans=min(ans,dfs(j,i)) else: for i in range(n):vis=[F]*n;ans=min(ans,dfs(i,-1)) print ans
s524941267
p04047
u464852639
1473802239
Python
Python (3.4.3)
py
Runtime Error
40
3064
114
N = int(input()) L = map(int, input().split()) sort(L) sum = 0 for i in range(0,len(L),2): sum += L[i] print(sum)
s046243738
p04047
u464852639
1473802154
Python
Python (3.4.3)
py
Runtime Error
41
3188
112
N = int(input()) L = map(int, input().split()) sort(L) sum = 0 for i in range(0,N): sum += L[i*2] print(sum)
s203588797
p04047
u464852639
1473802043
Python
Python (3.4.3)
py
Runtime Error
41
3188
117
N = int(input()) L = map(int, input().split()) sort(L) sum = 0 for i in range(0,len(L),2): sum += L[i] print(sum)
s546655394
p04047
u354504094
1473632610
Python
Python (2.7.6)
py
Runtime Error
26
2568
140
n, x = map(int, raw_input().split()) def cal(n): return n + 1 + (n - 2)*2 if n % x == 0: l = cal(n) - cal(x) else: l = cal(n) print l
s421375316
p04047
u670859236
1472862466
Python
Python (2.7.6)
py
Runtime Error
26
2568
81
n = raw_input() l = raw_input().split() print(sum(sorted(l, reverse=True)[1::2]))
s457272852
p04047
u914627967
1472755228
Python
Python (3.4.3)
py
Runtime Error
39
3064
408
NX = input() NX = "".join(NX).split(" ") NX = [int(s) for s in NX] D = NX[0]-NX[1] if NX[0] ==0 or NX[1]==0: print(str(0)) if NX[1]<D: Mod = D%NX[1] if Mod!=0: print(int(2*NX[1]+NX[1]+(D-NX[1]/2)*3)) else: print(int(NX[1]*4+D)) elif NX[1]==D: print(int(3*NX[1])) elif NX[1]>D: Mod = NX[1]%D if Mod!=0: print(int(NX[1]+(Mod*3)+D+(D*2*int(NX[1]/D)))) else: print(int(NX[1]+int((NX[1]/D))*2*D))
s078375409
p04047
u579875569
1469306617
Python
Python (3.4.3)
py
Runtime Error
39
3064
296
#!/usr/bin/python3 import sys sys.setrecursionlimit(100000) N, X = list(map(int, input().split())) def f(a,b): if a > b: a,b = b,a if a==0 or b==0: return 0 if b%a is 0: return int(a*(2*(b/a)-1)) return int(2*a*int(b/a) + f(a,b%a)) print(N+f(N-X, X))
s894827450
p04047
u579875569
1469265423
Python
Python (2.7.3)
py
Runtime Error
27
2568
103
#!/usr/bin/python3 N = int(input()) L = list(map(int, input().split())) L.sort() print(sum(L[0::2]))
s259640156
p04047
u579875569
1469265388
Python
Python (2.7.3)
py
Runtime Error
28
2688
103
#!/usr/bin/python3 N = int(input()) L = list(map(int, input().split())) L.sort() print(sum(L[0::2]))
s170659470
p04047
u742897895
1468816666
Python
PyPy3 (2.4.0)
py
Runtime Error
398
43376
281
n, x = map(int,input().split()) if x > n // 2: x = n - x xx = x yy = n - x ans = n i = 0 while True: ans += 2 * (yy // xx) * xx yy %= xx if yy == 0: ans -= xx break if yy < xx: tmp = xx xx = yy yy = tmp print(ans)
s849507092
p04047
u357487020
1468776050
Python
PyPy2 (5.6.0)
py
Runtime Error
64
9072
1017
import sys sys.setrecursionlimit(10**6) def dfs1(s,c): visited[s]=1 for i in v[s]: if visited[i]==0: d[c][i]=d[c][s]+1 dfs1(i,c) return def dfs2(c1,c2): visited[c2]=1 dfs1(c1,c1) dfs1(c2,c2) return n,k=map(int,raw_input().split()) d=[[0]*n for _ in xrange(n)] v=[[] for _ in xrange(n)] e=[] for i in xrange(n-1): a,b=map(int,raw_input().split()) a-=1 b-=1 v[a].append(b) v[b].append(a) e.append([a,b]) if k%2==0: min_del=1000000 for i in xrange(n): cnt=0 visited=[0]*n dfs1(i,i) for j in xrange(n): if d[i][j]>k/2: cnt+=1 min_del=min(min_del,cnt) print(min_del) else: min_del=1000000 for i,j in e: cnt=0 visited=[0]*n d=[[0]*n for _ in xrange(n)] dfs2(i,j) for l in xrange(n): if d[i][l]>(k-1)/2 or d[j][l]>(k-1)/2: cnt+=1 min_del=min(min_del,cnt) print(min_del)
s226244380
p04047
u352021237
1468749474
Python
PyPy2 (5.6.0)
py
Runtime Error
61
8816
135
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) n,x=map(int,raw_input().split()) print 3*(n-gcd(n,x))
s704341736
p04047
u352021237
1468749372
Python
PyPy2 (5.6.0)
py
Runtime Error
63
8816
136
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) n,x=map(int,raw_input().split()) print 3*(n-gcd(n,x))
s006997741
p04047
u187945597
1468736828
Python
Python (2.7.6)
py
Runtime Error
27
2568
79
n,x = map(int,raw_input().split()) print '%d' %(n + ((n/x) - 1)*2*x + 3*(n%x))
s512345524
p04047
u187945597
1468736260
Python
Python (2.7.6)
py
Runtime Error
26
2568
131
n,x = map(int,raw_input().split()) if n > 2*x : print '%d' %(n + (n/x - 1)*2*x + 3*(n-(n/x)*x)) else : print '%d' %(n + x)
s502251886
p04047
u821262411
1468728322
Python
PyPy3 (2.4.0)
py
Runtime Error
380
43120
357
import scipy.misc as scm def combi(p,q): return scm.comb(p,q,1) ans=0 n=int(input()) k=[] for i in range(n): a,b=map(int,input().split()) k.append([a,b]) for i in range(n-1): for j in range(i+1,n): p=k[i][0]+k[i][1]+k[j][0]+k[j][1] q=k[i][0]+k[j][0] ans += combi(p,q) % (10**9+7) ans = ans % (10**9+7) print(ans)
s852666915
p04047
u750436322
1468725753
Python
Python (3.4.3)
py
Runtime Error
38
3064
176
def f(a, b): if b%a==0: return b//a*2-1 else: return b//a*a*2+f(b%a,a) N, X = map(int, input().split()) ans = N + f(min(N-X,X), max(N-X,X)) print(ans)
s415818222
p04047
u163377571
1468724046
Python
Python (3.4.3)
py
Runtime Error
39
3064
234
N = input() L = input() i = 0 array = [] anser = 0 while i < len(L): if L[i] != ' ': array.append(int(L[i])) i+=1 i = 1 array.sort(reverse=True) for i in range(array): if i // 2 == 0: anser+=i print(anser)
s282052365
p04047
u216545111
1468723917
Python
Python (2.7.6)
py
Runtime Error
28
2568
195
import sys; n,x=map(int,raw_input().split()); if(2*x<n): print x+(n-x)+x+x+(n-2*x)*(2*x-1); elif(2*x==n): print x+(n-x)+x; else: print x+(n-x)+x+(n-x)+x+(n-x);
s680582353
p04047
u023220201
1468722419
Python
Python (2.7.6)
py
Runtime Error
29
2568
126
# encoding: utf-8 n, x = map(int, raw_input().split()) ac_bc = n - x s = ac_bc / 3 l = ac_bc - s print ac_bc + s * 3 + l * 3
s911514871
p04047
u248145581
1468722047
Python
Python (3.4.3)
py
Runtime Error
38
3064
437
#!/usr/bin/env python3 # -*- coding: utf-8 -*- N, X = list(map(int, input().split())) sum_ = X prev = X next = N - X i = 0 while True: num = prev // next if i == 0: sum_ += 2 * num * next elif i % 2 == 1: sum_ += 2 * num * next - next else: sum_ += 2 * num * next - next mod_ = prev % next if mod_ == 0: break sum_ += next prev = next next = mod_ i += 1 print(sum_)
s280459736
p04047
u900223807
1468720667
Python
Python (2.7.6)
py
Runtime Error
1565
7168
130
N, X = map(int, raw_input().split()) ans = 0 if N%2 ==0: d = min(X, N-X) ans = (N-d)*3 else: ans = (N-1)*3 print(ans)
s646624473
p04047
u724409710
1468720058
Python
Python (2.7.6)
py
Runtime Error
31
2568
65
N, X = map(int, raw_input().strip().split()) print N + (N-X)*2 -1
s529211517
p04047
u714578774
1468719985
Python
Python (2.7.6)
py
Runtime Error
1759
7164
78
N, x = map(long, raw_input().split()) print (N - x) + 3 * x + 3 * (N - x - x)
s948258491
p04047
u966695411
1468719234
Python
Python (3.4.3)
py
Runtime Error
46
3064
143
#! /usr/bin/env python3 N, X = map(int, input().split()) if X*2 == N: print(X*3) else: print(X*3*((N-X)//X + (1 if (N-X)%X>0 else 0)))
s902533382
p04047
u342321365
1468719005
Python
Python (3.4.3)
py
Runtime Error
1621
7272
230
def bbq(): n = int(input()) a = input() tmp = a.split() l = [int(x) for x in tmp] l.sort() n = 0 i = 0 while(i<n: n += l[i] i += 2 print (n) if __name__ == "__main__": bbq()
s820627721
p04047
u667190633
1468718271
Python
Python (2.7.6)
py
Runtime Error
28
2568
126
N=raw_input() up=raw_input() up=up.split() up=map(int,up) up.sort() count=0 for i in range(N): count+=up[i*2] print count
s777010165
p04047
u667190633
1468718176
Python
Python (2.7.6)
py
Runtime Error
1286
3588
120
N=raw_input() up=raw_input().split() up=map(int,up) up.sort() count=0 for i in range(N): count+=up[i*2] print count
s090382957
p04047
u667190633
1468717830
Python
Python (2.7.6)
py
Runtime Error
270
2952
113
N=raw_input() up=raw_input().split() up=up.sort() count=0 for i in range(N): count+=int(up[i*2]) print count
s555175969
p04048
u468972478
1599700295
Python
Python (3.8.2)
py
Runtime Error
22
9132
117
n = int(input()) a = sorted(map(int, input().split())) s = 0 for i in range(2*n-1): s += min(a[i], a[i+1]) print(s)
s313668169
p04048
u629540524
1599260745
Python
Python (3.8.2)
py
Runtime Error
23
9080
79
import sympy n,x = map(int,input().split()) print(n-x+sum(sympy.divisors(x))*3)
s297220978
p04048
u697658632
1598423644
Python
Python (3.8.2)
py
Runtime Error
23
9116
72
import math n, x = map(int, input().split()) print(3 * (n - gcd(n, x)))
s361058051
p04048
u761154175
1596587907
Python
PyPy3 (7.3.0)
py
Runtime Error
112
76816
255
def milor(a,b): if a == b: return a if a > b: a,b = b,a return milor(b-a,a) + 2*a def solve(n,x): res = n + milor(x,n-x) return res if __name__ == '__main__': n,x = map(int,input().split()) print(solve(n,x))
s311100241
p04048
u856671164
1592768464
Python
Python (3.8.2)
py
Runtime Error
25
8880
391
N,X = input().split() N,X = int(N), int(X) answer = X+ (N-X) def rhombus(N,X): if N<X: temp = N N = X X = temp if X==1: return N+1 if X==0: return 0 if N%X == 0: return X*(N//X)*2-X else: k = N//X return k*2*X + rhombus(X,N-(k*X)) answer = answer + rhombus(N-X,X) print(answer)
s264994960
p04048
u501278784
1587997693
Python
PyPy3 (2.4.0)
py
Runtime Error
185
38640
81
n,x=map(int,input().split()) k=(x/(n-2*x))*(n-2*x) ans=2*x+n+k print(int(ans+1))
s634847381
p04048
u255673886
1587146148
Python
PyPy3 (2.4.0)
py
Runtime Error
182
38460
886
from collections import deque from heapq import heapify,heappop,heappush,heappushpop from copy import copy,deepcopy from itertools import permutations,combinations from collections import defaultdict,Counter from math import gcd # from fractions import gcd from functools import reduce from pprint import pprint def myinput(): return map(int,input().split()) def mylistinput(n): return [ list(myinput()) for _ in range(n) ] def mycol(data,col): return [ row[col] for row in data ] def mysort(data,col): data.sort(key=lambda x:x[col],reverse=False) return data def mymax(data): M = -1*float("inf") for i in range(len(data)): m = max(data[i]) M = max(M,m) return M def mymin(data): m = float("inf") for i in range(len(data)): M = min(data[i]) m = min(m,M) return m n,x = myinput() ans = (n-1)*3 print(ans)
s365925693
p04048
u808664337
1583795742
Python
Python (3.4.3)
py
Runtime Error
75
4032
279
def move(mode, N, X, total): tmp = total if mode == 0: tmp += (N-X) return move(1, N-X, X, tmp) if mode == 1: tmp += X next = 0 if N-X == 0: return tmp return move(next, N, N-X, tmp) N, X = map(int, input().split(" ")) print(move(0, N, X, X))
s669053810
p04048
u998008108
1582333523
Python
Python (3.4.3)
py
Runtime Error
17
2940
67
import math n,x=map(int,input().split()) print(3*(n-math.gcd(n,x)))
s482047447
p04048
u998008108
1582333458
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
67
import math n,x=map(int,input().split()) print(3*(n-math.gcd(n,x)))
s867439284
p04048
u039864635
1580449905
Python
Python (3.4.3)
py
Runtime Error
17
2940
82
from math import gcd n, x = map(int, input().split()) print(3 * (n - gcd(n, x)))
s876123929
p04048
u301298600
1577946957
Python
Python (3.4.3)
py
Runtime Error
18
2940
77
from math import gcd n, x = map(int, input().split()) print(3*(n-gcd(n, x)))
s963740881
p04048
u301298600
1577946871
Python
PyPy3 (2.4.0)
py
Runtime Error
164
38256
77
from math import gcd n, x = map(int, input().split()) print(3*(n-gcd(n, x)))
s257332778
p04048
u580070121
1577585399
Python
Python (3.4.3)
py
Runtime Error
17
2940
87
N = int(input()) X = int(input()) Total_Length = 2*X + N + 3*(X//2) print(Total_Length)
s298220524
p04048
u365375535
1577168275
Python
Python (3.4.3)
py
Runtime Error
17
3056
228
def run(): N, X = map(int, input().split()) y = N-X ans = y+X while True: a = y//X ans += a*X*2 if y%X == 0: break y, X = max(X, a), min(X, a) print(ans-X) if __name__ == '__main__': run()
s438951925
p04048
u365375535
1577168085
Python
Python (3.4.3)
py
Runtime Error
17
2940
212
def run(): N, X = map(int, input().split()) y = N-X ans = y+X while True: a = y//X ans += a*X*2 if y%X == 0: break y, X = X, a print(ans-X) if __name__ == '__main__': run()
s108536014
p04048
u649172849
1569569574
Python
Python (3.4.3)
py
Runtime Error
75
3984
230
import sys import math sys.setrecursionlimit(1000) def f(x, y): if y < x: (y, x) = (x, y) if x == 0: return y return x + y + f(x, y - x) n, x = map(int, input().split()) print(x + f(x, n - x) - math.gcd(n, x))
s821995801
p04048
u649172849
1569568673
Python
Python (3.4.3)
py
Runtime Error
73
3964
207
import sys sys.setrecursionlimit(1000) def f(x, y): if y < x: (y, x) = (x, y) if x == 0: return y return x + y + f(x, y - x) n, x = map(int, input().split()) print(x + f(x, n - x) - 1)
s564518548
p04048
u649172849
1569568597
Python
Python (3.4.3)
py
Runtime Error
75
3968
164
def f(x, y): if y < x: (y, x) = (x, y) if x == 0: return y return x + y + f(x, y - x) n, x = map(int, input().split()) print(x + f(x, n - x) - 1)
s738614827
p04048
u649172849
1569568387
Python
Python (3.4.3)
py
Runtime Error
17
2940
163
def f(x, y): if y < x: y, x = x, y if y == 0: return x return x + y + f(x, y - x) n, x = map(int, input().split()) print(x + f(x, n - x))
s753370104
p04048
u649172849
1569567786
Python
Python (3.4.3)
py
Runtime Error
18
2940
85
import math n, x = map(int, input().split()) print(n * x // math.gcd(n, x) + x)
s635919951
p04048
u649172849
1569567708
Python
Python (3.4.3)
py
Runtime Error
17
2940
79
import math n, x = map(int, input().split()) print(n * x / math.gcd(n, x) + x)
s871397787
p04048
u588341295
1569041493
Python
Python (3.4.3)
py
Runtime Error
1842
715380
825
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 N, X = MAP() def rec(a, b): if a == b: return a a, b = min(a, b), max(a, b) return a*2 + rec(a, b-a) print(N+rec(X, N-X))
s015771046
p04048
u588341295
1568956707
Python
Python (3.4.3)
py
Runtime Error
18
3064
785
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 N, X = MAP() if N%2 == 1: print((N-1)*3) else: raise Exception print(N*3//2+abs(X-N//2)*3)
s486035428
p04048
u787059958
1568587516
Python
Python (3.4.3)
py
Runtime Error
18
3064
893
n, x = map(int, input().split()) if (n%2 == 1): print((n-1)*3) elif (n==2): print(3) else: k=n/2 if (x<k): if((n/2)%2==0): l = [] for i in range(1,k-2): l.append(((n-1)*3)-3*(x-1)) last = l[0] l.append(last) print(l[x-1]) else: if (x%2==0): print((n-2)*3) else: print((n-1)*3) elif(x==k): print(int(k*3)) else: p = n-x if (p<k): if((n/2)%2==0): l = [] for i in range(1,k-2): l.append(((n-1)*3)-3*(p-1)) last = l[0] l.append(last) print(l[p-1]) else: if (p%2==0): print((n-2)*3) else: print((n-1)*3)
s163593323
p04048
u263830634
1563742209
Python
Python (3.4.3)
py
Runtime Error
1395
715252
270
import sys sys.setrecursionlimit(10 ** 9) N, X = map(int, input().split()) def f(a, b): if a == b: return a if a >= b: a, b = b, a if b%a != 0: return 2 * a * (b//a) + f(a, b%a) return 2 * a + f(a, b - a) print (N + f(N - X, X))
s970175330
p04048
u263830634
1563741175
Python
Python (3.4.3)
py
Runtime Error
1411
715252
211
import sys sys.setrecursionlimit(10 ** 9) N, X = map(int, input().split()) def f(a, b): if a == b: return a if a >= b: a, b = b, a return 2 * a + f(a, b - a) print (N + f(N - X, X))
s798673727
p04048
u263830634
1563741118
Python
Python (3.4.3)
py
Runtime Error
81
3980
169
N, X = map(int, input().split()) def f(a, b): if a == b: return a if a >= b: a, b = b, a return 2 * a + f(a, b - a) print (N + f(N - X, X))
s438101089
p04048
u263830634
1563739800
Python
Python (3.4.3)
py
Runtime Error
183
12660
2341
#座標平面に落とし込んで再帰関数で無理やり計算 # import numpy as np import sys sys.setrecursionlimit(10 ** 5) N, X = map(int, input().split()) if 2 * X > N: #対称性 X = N - X #座標の作成 dp = [[-1] * (N+3)] for i in range(N+1): tmp = [-1] for j in range(N+1): if i <= j: tmp.append(0) #到達していないマス else: tmp.append(-1) #壁(範囲外) tmp.append(-1) tmp.reverse() dp.append(tmp) dp.append([-1] * (N+3)) # print (np.array(dp)) #m: 0:右へ, 1:左下へ, 2:左上へ def moving(x, y, total, m): if x == X and y == 1 and dp[x][y] == 1: #一周回ってもとの座標に戻ってきた時 # print ('D') return total if m == 0: #右に動く時 tmp = 0 while dp[x-1][y+1] == 0: #右に進める時 dp[x-1][y+1] = 1 #右進んだマスを到達したことにする tmp += 1 x -= 1 y += 1 if dp[x-1][y+1] == -1: #右側が壁の時-->左下に進む # print ('1-B') return moving(x, y, total + tmp, 1) if dp[x-1][y+1] == 1: #右側が光の線の時-->左上へ進む tmp += 1 # print ('1-C') return moving(x-1, y+1, total + tmp, 2) if m == 1: #左下へ動く時 tmp = 0 while dp[x+1][y] == 0: #左下に進める時 dp[x+1][y] = 1 tmp += 1 x += 1 if dp[x+1][y] == -1: #左下が壁の時-->左上に進む # print ('2-C') return moving(x, y, total + tmp, 2) if dp[x+1][y] == 1: #左下が光の線の時-->左上に進む tmp += 1 # print ('2-C') return moving(x+1, y, total + tmp, 2) if m == 2: #左上に動く時 tmp = 0 while dp[x][y-1] == 0: #左上に進める時 dp[x][y-1] = 1 tmp += 1 y -= 1 if dp[x][y-1] == -1: #左上が壁の時-->右に進む # print ('3-A') return moving(x, y, total + tmp, 0) if dp[x][y-1] == 1: #左上が光の線の時-->左下に進む tmp += 1 # print ('3-B') return moving(x, y-1, total + tmp, 1) X += 1 print (moving(X, 1, 0, 0)) # print (np.array(dp))
s836050967
p04048
u263830634
1563739503
Python
Python (3.4.3)
py
Runtime Error
248
11996
2233
# import numpy as np # import sys # sys.setrecursionlimit(100) N, X = map(int, input().split()) if N > 1000: exit() if 2 * X > N: X = N - X #座標の作成 dp = [[-1] * (N+3)] for i in range(N+1): tmp = [-1] for j in range(N+1): if i <= j: tmp.append(0) #到達していないマス else: tmp.append(-1) #壁(範囲外) tmp.append(-1) tmp.reverse() dp.append(tmp) dp.append([-1] * (N+3)) # print (np.array(dp)) #m: 0:右へ, 1:左下へ, 2:左上へ def moving(x, y, total, m): if x == X and y == 1 and dp[x][y] == 1: # print ('D') return total if m == 0: #右に動く時 tmp = 0 while dp[x-1][y+1] == 0: #右に進める時 dp[x-1][y+1] = 1 #右進んだマスを到達したことにする tmp += 1 x -= 1 y += 1 if dp[x-1][y+1] == -1: #右側が壁の時-->左下に進む # print ('1-B') return moving(x, y, total + tmp, 1) if dp[x-1][y+1] == 1: #右側が光の線の時-->左上へ進む tmp += 1 # print ('1-C') return moving(x-1, y+1, total + tmp, 2) if m == 1: #左下へ動く時 tmp = 0 while dp[x+1][y] == 0: #左下に進める時 dp[x+1][y] = 1 tmp += 1 x += 1 if dp[x+1][y] == -1: #左下が壁の時-->左上に進む # print ('2-C') return moving(x, y, total + tmp, 2) if dp[x+1][y] == 1: #左下が光の線の時-->左上に進む tmp += 1 # print ('2-C') return moving(x+1, y, total + tmp, 2) if m == 2: #左上に動く時 tmp = 0 while dp[x][y-1] == 0: #左上に進める時 dp[x][y-1] = 1 tmp += 1 y -= 1 if dp[x][y-1] == -1: #左上が壁の時-->右に進む # print ('3-A') return moving(x, y, total + tmp, 0) if dp[x][y-1] == 1: #左上が光の線の時-->左下に進む tmp += 1 # print ('3-B') return moving(x, y-1, total + tmp, 1) X += 1 print (moving(X, 1, 0, 0)) # print (np.array(dp))
s223030371
p04048
u305052967
1559310443
Python
Python (3.4.3)
py
Runtime Error
75
3980
196
N,X = map(int, input().split()) def para(a,b): if a == b: return a if a > b: return 2*b + para(b,a-b) if a < b: return 2*a + para(a,b-a) print(N+para(X,N-X))
s736998737
p04048
u305052967
1559309905
Python
Python (3.4.3)
py
Runtime Error
73
3984
198
N,X = map(int, input().split()) def para(a,b): if b == 0: return a if a >= b: return a+b + para(b,a-b) if a < b: return 2*a + para(a,b-a) print(X+para(X,N-X))
s761842807
p04048
u305052967
1559309063
Python
Python (3.4.3)
py
Runtime Error
74
3976
197
N,X = map(int, input().split()) def para(a,b): if a > b: return a+b + para(b,a-b) if a < b: return 2*a + para(a,b-a) if a == b: return 3*a print(X+para(X,N-X))
s296000499
p04048
u305052967
1559308855
Python
Python (3.4.3)
py
Runtime Error
75
3988
214
N,X = map(int, input().split()) print(N) print(X) def para(a,b): if a > b: return a+b + para(b,a-b) if a < b: return 2*a + para(a,b-a) if a == b: return 3*a print(X+para(X,N-X))
s248720864
p04048
u305052967
1559255143
Python
Python (3.4.3)
py
Runtime Error
74
3980
212
N,X = map(int, input().split()) print(N) print(X) def para(a,b): if a > b: return 2*b + para(b,a-b) if a < b: return 2*a + para(b-a,a) if a == b: return a print(N+para(X,N-X))
s663748375
p04048
u095426154
1556933882
Python
Python (3.4.3)
py
Runtime Error
17
2940
489
n,x=map(int,input().split()) ans=0 if x<n/2: a=x b=n-x ans+=x+n while True: if b%a==0: ans+=a*2*(b/a) break else: ans+=a*2*(b//a) a,b=b%a,a elif x=n/2: ans=3*x elif x>n/2: a=n-x b=x ans+=x while True: if b%a==0: ans+=a*2*(b/a) break else: ans+=a*2*(b//a) a,b=b%a,a print(ans)
s171165520
p04048
u095426154
1556933820
Python
Python (3.4.3)
py
Runtime Error
17
2940
487
n,x=map(int,input().split()) ans=0 if x<n/2: a=x b=n-x ans+=x+n while True: if b%a=0: ans+=a*2*(b/a) break else: ans+=a*2*(b//a) a,b=b%a,a elif x=n/2: ans=3*x elif x>n/2: a=n-x b=x ans+=x while True: if b%a=0: ans+=a*2*(b/a) break else: ans+=a*2*(b//a) a,b=b%a,a print(ans)
s824369964
p04048
u346194435
1556036048
Python
Python (3.4.3)
py
Runtime Error
18
3060
231
N,X = map(int, input().split()) if N/2 == X: print(X*3) elif N/2 > X: # 上側 l = X + N - X l += ((N-X)//X)*2 n = (N-X)%X l += (X//n)*2*n l += n else: l = X n = X-N l += (N//n)*2*n print(l)