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
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s325456948
p04048
u399560160
1468741169
Python
Python (3.4.3)
py
Accepted
41
3064
317
def sub(a, b): if (a%b == 0): return a//b-1 return a//b def mod(a, b): if a%b==0: return b return a%b n, x = map(int, input().split(' ')) ans = n c = [x, n-x] while (c[0] != c[1]): c = [min(c), max(c)] ans += 2*sub(c[1], c[0])*c[0] c[1] = mod(c[1], c[0]) print(ans+c[0])
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,717
s976467494
p04048
u477320129
1468729155
Python
Python (3.4.3)
py
Accepted
39
3064
243
import sys sys.setrecursionlimit(1500) def f(x, y): if x == 0: return 0 if y % x == 0: return 2 * (y // x) * x - x return 2 * (y // x) * x + f(y % x, x) N, X = list(map(int, input().split())) print(f(X, N-X) + N)
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,718
s472021971
p04048
u250209149
1468728968
Python
Python (2.7.6)
py
Accepted
34
3072
313
tmp = [int(x) for x in raw_input().split(' ')] N = tmp[0] X = tmp[1] if(X > 0.5 * N): X = N-X totaldist = N step = X dist = N-X while(1): totaldist += (dist/step) * 2 * step distnew = step stepnew = dist % step if(stepnew == 0): totaldist -= step break dist = distnew step = stepnew print totaldist
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,719
s655089067
p04048
u534783449
1468723523
Python
Python (2.7.6)
py
Accepted
26
2568
332
args = [ int(x) for x in raw_input().split() ] l0 = args[0] x0 = args[1] def get_length(l, x): if l % x == 0: part = l * 2 - x # print l, x, part return part part = int(l / x) * 2 * x # print l, x, part return part + get_length(x, l % x) length = l0 + get_length(l0 - x0, x0) p...
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,720
s936583900
p04048
u966695411
1468722792
Python
Python (3.4.3)
py
Accepted
44
3064
196
#! /usr/bin/env python3 def f(a, b): if a < b : b, a = a, b c = a // b r = b * 3 * c if a % b > 0 : r += f(b, a-c*b) return r N, X = map(int, input().split()) print(f(X, N-X))
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,721
s235812495
p04048
u725662235
1468722732
Python
Python (2.7.6)
py
Accepted
26
2568
333
n = map(int, raw_input().split()) x = n[1] n = n[0] tpl = x # print '55',tps, tpl if x < float(n)/2: tps = abs(n - 2*x) l = x + n - tps else: l = 0 tps = n - x while tps != 0: # print l # print "t", tps, tpl l += tpl/tps * 3*tps # tpl/tps * 3*tps ntps = tpl % tps tpl = tps tps =...
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,722
s825221067
p04048
u707500405
1468722384
Python
Python (2.7.6)
py
Accepted
27
2568
118
N,X = map(int,raw_input().split()) X = min(X,N-X) ans = 0 N -= X while X > 0: ans += N/X * X *3 N,X= X,N%X print ans
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,723
s767993794
p04048
u248145581
1468722067
Python
Python (3.4.3)
py
Accepted
37
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_ ...
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,724
s380250602
p04048
u601018334
1468721581
Python
Python (3.4.3)
py
Accepted
38
3064
211
def calc(N,X): if N%X ==0: return 3*N else: return 3*X*(int(N/X)) + calc(X,N-X*(int(N/X))) N,X = list(map(int, input().split())) X = min(X,N-X) ans = calc(N-X,X) print('%s' % str(ans))
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,725
s414580965
p04048
u786082266
1468721183
Python
Python (2.7.6)
py
Accepted
26
2568
144
n, x = map(int, raw_input().split()) s = 0 t = n - x while t % x != 0: m = t % x s += x * (t / x) t = x x = m s += x * (t / x) print s * 3
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,726
s051327110
p04048
u357487020
1468721025
Python
Python (2.7.6)
py
Accepted
27
2568
403
n,x=map(int,raw_input().split()) y=n-x ans=x+y if y>=x: while 1: if y%x==0: ans+=x+((y-x)/x)*x*2 print(ans) break else: ans+=((y)/x)*x*2 y,x=x,y%x else: while 1: if x%y==0: ans+=y+((x-y)/y)*y*2 print(ans)...
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,727
s757958726
p04048
u124139453
1468720989
Python
Python (2.7.6)
py
Accepted
25
2568
208
n, x = map(int,raw_input().split()) x = min(n-x,x) ans = 0 def cal(ans,l,s): ans += l/s*s*3 if l%s == 0: return ans else: return cal(ans,max(s,l%s),min(s,l%s)) print cal(ans,n-x,x)
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,728
s908649186
p04048
u024612773
1468720861
Python
Python (3.4.3)
py
Accepted
40
3064
202
n,x=map(int,input().split()) if x>n/2: x = n-x ans = n c = x d = n-x while c > 0: if d%c==0: ans += int(d/c)*(2*c) - c else: ans += int(d/c)*(2*c) c,d = d%c,c print(ans)
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,729
s240991215
p04048
u810735437
1468719592
Python
Python (3.4.3)
py
Accepted
65
4212
666
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import functools def gcd(a, b): while b: a, b = b, a % b return a # @functools.lru_cache(maxsize = None) # def func(N, X): # g = gcd(N, X) # if g == 1: # if X > N // 2: # return func(N, N - X) # if N == 2: # ...
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,730
s406843225
p04048
u202619899
1468719357
Python
Python (3.4.3)
py
Accepted
37
3064
266
def rec(a, b): mx = max(a, b) mn = min(a, b) #print(mn, mx//mn) if mx % mn == 0: return (2 * (mx // mn) - 1) * mn return (2 * mn * (mx // mn)) + rec(mn, mx % mn) N, X = list(map(int, input().split())) #print(N, X) print(rec(N-X, X) + N)
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,731
s047819608
p04048
u765237551
1468719065
Python
Python (3.4.3)
py
Accepted
39
3064
198
N, X = map(int, input().split()) def solve(a, b): d = a // b m = a % b if m==0: return (d * 2 - 1) * b else: return d * 2 * b + solve(b, m) print(N + solve(X, N-X))
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,732
s888053853
p04048
u207056619
1468718916
Python
Python (3.4.3)
py
Accepted
37
3064
212
#!/usr/bin/env python3 def f(n, x): if n % x == 0: return (n // x * 2 - 1) * x else: return (n // x * 2) * x + f(x, n % x) n, x = map(int,input().split()) ans = n + f(n - x, x) print(ans)
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,733
s609499278
p04048
u945080461
1468718829
Python
Python (2.7.6)
py
Accepted
60
4392
113
from fractions import gcd n, x = map(int, raw_input().split()) g = gcd(n, x) n /= g x /= g print 3 * (n - 1) * g
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,734
s998319904
p04048
u299869545
1468718133
Python
Python (2.7.6)
py
Accepted
27
2692
214
n, x = map(int, raw_input().split()) def solve(a, b): if a > b:return solve(b, a) if b % a == 0: return (2 * (b / a) - 1) * a return 2 * a * (b / a) + solve(a, b % a) print solve(x, n-x) + n
p04048
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
5 2
12
1,217,735
s292125822
p04050
u218843509
1592028903
Python
Python (3.4.3)
py
Accepted
18
3064
636
from sys import exit n, m = map(int, input().split()) a = list(map(int, input().split())) odd = [] even = [] for x in a: if x%2 == 0: even.append(x) else: odd.append(x) if n%2 == 0: if len(odd) > 2: print("Impossible") exit() if len(odd) == 2: a = [odd[0]] + even + [odd[1]] b = [odd[0]+1] + even + [od...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,736
s965943795
p04050
u340781749
1588795367
Python
Python (3.4.3)
py
Accepted
35
4980
928
import sys def solve(n, m, arr): odds = [] evens = [] for a in arr: if a % 2 == 0: evens.append(a) else: odds.append(a) if len(odds) > 2: print('Impossible') return if len(odds) == 2: o1, o2 = odds aaa = [o1] + evens + [o2] ...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,737
s571339864
p04050
u227082700
1577511744
Python
Python (3.4.3)
py
Accepted
18
3064
464
n,m=map(int,input().split()) a=list(map(int,input().split())) b=[] o=[] for i in a: if i%2:o.append(i) else:b.append(i) if len(o)>2:print("Impossible");exit() if len(o)==1:b=o+b elif len(o)==2:b=[o[0]]+b+[o[1]] ans=[] for i in range(len(b)): if i==0:ans.append(b[i]-1) elif i==len(b)-1:ans.append(b[i]+1) else:...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,738
s943528127
p04050
u211706121
1576375590
Python
Python (3.4.3)
py
Accepted
20
3188
867
n,m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] breakFlag = False for i in range(1,m-1): if a[i]%2==1: if a[0]%2==1: if a[len(a)-1]%2==1: print("Impossible") breakFlag = True break else: a[...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,739
s065079131
p04050
u102461423
1569523863
Python
Python (3.4.3)
py
Accepted
17
3064
662
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) N,M = map(int,readline().split()) A = [int(x) for x in readline().split()] OD = [x for x in A if x&1] EV = [x for x in A if not x&1] if len(OD) >= 3: print('Impossible') exit() if len(A) == 1: if N ==...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,740
s952339729
p04050
u816116805
1542178048
Python
Python (3.4.3)
py
Accepted
18
3064
826
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc001 D """ n, m = map(int, input().split()) ali = list(map(int, input().split())) if m == 1 and ali[0] == 1: print(1) print(1) print(1) exit() if m == 1: print(ali[0]) print(2) print(ali[0]-1, 1) exit() flag = 0...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,741
s213815438
p04050
u207056619
1504708476
Python
Python (3.4.3)
py
Accepted
17
3064
778
#!/usr/bin/env python3 def solve(n, m, a): odd = [] even = [] for a_i in a: if a_i % 2 == 0: even += [ a_i ] else: odd += [ a_i ] if len(odd) >= 3: return None a, b = [], [] if odd: x = odd.pop() a += [ x ] b += [ x - 1 ] ...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,742
s637050993
p04050
u804080968
1468806315
Python
Python (3.4.3)
py
Accepted
39
3064
388
S, N = map(int, input().split()) A = list(map(int, input().split())) O = [a for a in A if a % 2 == 1] E = [a for a in A if a % 2 == 0] if len(O) > 2: print("Impossible") else: A = O[:min(len(O), 1)] + E + O[1:] B = A[:] + ([0] if N == 1 else []) B[0] -= 1 B[-1] += 1 if B[0] == 0: B = B[...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,743
s709919279
p04050
u804080968
1468805506
Python
Python (3.4.3)
py
Accepted
42
3064
438
S, N = map(int, input().split()) A = list(map(int, input().split())) O = [a for a in A if a % 2 == 1] E = [a for a in A if a % 2 == 0] if len(O) > 2: print("Impossible") else: A = O[:min(len(O), 1)] + E + O[min(1, len(O)):] B = A[:] + ([0] if len(A) == 1 else []) B[0] -= 1 B[-1] += 1 if B[0] ==...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,744
s678667268
p04050
u945080461
1468721660
Python
Python (2.7.6)
py
Accepted
27
2696
659
from sys import stdout def main(): n, m = map(int, raw_input().split()) a = map(int, raw_input().split()) if m == 1: print a[0] if n == 1: print 1 print 1 else: print 2 print 1, n - 1 return if sum(x % 2 for x in a) > 2: ...
p04050
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
3 2 2 1
1 2 1 3
1,217,745