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
s314182461
p03713
u603234915
1542162179
Python
Python (3.4.3)
py
Runtime Error
494
18984
652
H, W = map(int, input().split()) S_list = [] for h in range(1, H-1): w = W//2 S_A = h*W S_B = (H-h)*w S_C = (H-h)*(W-w) S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C)) for h in range(1, H-1): S_A = h*W S_B = ((H-h)//2)*W S_C = -(-(H-h)//2)*W S_list.append(max(S_A,S_B,S_C) -min(S_A...
s101394478
p03713
u603234915
1542161521
Python
Python (3.4.3)
py
Runtime Error
241
11032
360
H, W = map(int, input().split()) S_list = [] for i in range(1, H-1): w = W//2 S_A = i*W S_B = (H-i)*w S_C = (H-i)*(W-w) S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C)) for i in range(1, W-1): h = H//2 S_A = i*H S_B = (W-i)*h S_C = (W-i)*(H-h) S_list.append(max(S_A,S_B,S_C) -mi...
s223179963
p03713
u603234915
1542161324
Python
Python (3.4.3)
py
Runtime Error
236
11032
464
H, W = map(int, input().split()) if H % 3 == 0 or W % 3 == 0: print(0) else: S_list = [] for i in range(1, H-1): w = W//2 S_A = i*W S_B = (H-i)*w S_C = (H-i)*(W-w) S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C)) for i in range(1, W-1): h = H//2 ...
s183622986
p03713
u255280439
1535583912
Python
Python (3.4.3)
py
Runtime Error
107
4720
3491
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = { id(v): k for k, v in inspect.currentframe().f_back.f_locals.items() } print(', '.join( name...
s033706170
p03713
u594859393
1531180610
Python
Python (3.4.3)
py
Runtime Error
194
3064
384
from itertools import chain h, w = map(int, input().split()) def f(x, h, w): h2 = h // 2 h3 = h - h2 a,b,c = sorted((x,w*h2,w*h3)) w2 = w // 2 w3 = w - w2 d,e,f = sorted((x,w2*h,w3*h)) return min(c-a, f-d) ss = ((w2*h, h, w-w2) for w2 in range(1, (w+1)//2)) ts = ((w*h2, h-h2, w) for h2 in...
s473917523
p03713
u143492911
1525229675
Python
Python (3.4.3)
py
Runtime Error
487
19012
1248
h,w=map(int,input().split()) ans=[] ans_2=[] ans_3=[] ans_4=[] for i in range(1,w-1): a=h*i res=w-i if res%2==0: b=h*(res//2) c=h*(res//2) else: b=h*(res//2) c=h*(res//2+1) ans.append(max(a,b,c)-min(a,b,c)) for i in range(1,h-1): a_2=i*w res_2=h-i if res_2...
s525509277
p03713
u143492911
1525227571
Python
Python (3.4.3)
py
Runtime Error
486
18920
1026
h,w=map(int,input().split()) ans=[] ans_2=[] ans_3=[] ans_4=[] for i in range(1,w-1): a=h*i res=w-i if res%2==0: b=h*(res//2) c=b*(res//2) else: b=h*(res//2) c=h*(res//2+1) ans.append(max(a,b,c)-min(a,b,c)) for i in range(1,h-1): a_2=i*w res_2=h-i if res_2...
s068617686
p03713
u503901534
1524665890
Python
Python (3.4.3)
py
Runtime Error
17
3064
326
h, w = map(int,input()) sss = [] for i in range(h): for j in range(w): p = i * j q = i * (w - j) r = w * (h-i) sss.append(max(p,q,r) - min(p,q,r)) s = i * j t = (h-i) * j u = j * (w-j) sss.append((max(s,t,u) - min(s,t,u))) print(max...
s208133085
p03713
u858136677
1510857926
Python
Python (3.4.3)
py
Runtime Error
17
3192
1043
h,w = map(int,input().split()) l = (h+w)*2 if h%3 == 0 or w%3 == 0: print('0') else: a = h s = [] if a%2 == 0: d = a/2 if w%3 == 1: b = (w-1)/3 c = w - b s.append(a*b) s.append(c*d) else: b = (w+1)/3 c = w-b s.append(a*b) s.append(c*d) else: d = (a-1)/2 if w%3 == 1: b = (w-1)/3...
s996826474
p03713
u858136677
1510856543
Python
Python (3.4.3)
py
Runtime Error
18
3192
998
h,w = map(int,input().split()) l = (h+w)*2 if h%3 == 0 or w%3 == 0: print('0') else: a = h s = [] if a%2 == 0: d = a/2 if w%3 == 1: b = (w-1)/3 c = w - b s.append(a*b) s.append(c*d) else: b = (w+1)/3 c = w-b s.append(a*b) s.append(c*d) else: d = (a-1)/2 if w%3 == 1: b = (w-1)/3...
s293223203
p03713
u160414758
1506415229
Python
Python (3.4.3)
py
Runtime Error
18
3188
520
import math H,W = map(int,input().split()) if H%3==0 or W%3==0: print(0) elif H==2 and W==2: print(1) else: def cal2(h,w): x1,x2 = math.floor(w/2),math.ceil(w/2) y1,y2 = math.floor((2*h)/3),math.ceil((2*h)/3) return min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2)) def cal(x,...
s114709716
p03713
u160414758
1506410823
Python
Python (3.4.3)
py
Runtime Error
17
3064
427
import math H,W = map(int,input().split()) if H%3==0 or W%3==0: print(0) elif H==2 and W==2: print(1) else: def cal(x,y): return max(x*y,(W-x)*y,(H-y)*W) - min(x*y,(W-x)*y,(H-y)*W) def cal2(H,W): x1,x2 = math.floor(W/2),math.ceil(W/2) y1,y2 = math.floor((2*H)/3),math.ceil((2*H)...
s060530328
p03713
u370413678
1504264307
Python
Python (3.4.3)
py
Runtime Error
2151
617076
568
choco=[int(i) for i in input().split()] size_list01=[[a1*choco[0], (choco[1]-a1)*a0, (choco[1]-a1)*(choco[0]-a0)] for a1 in range(1,choco[1]) for a0 in range(1,choco[0])] size_list1=[[a10,a11,choco[1]-a10-a11] for a11 in range(1,choco[1]) for a10 in range(1,choco[1]-a11)] size_list0=[[a00,a01,choco[0]-a00-a01] for a01 ...
s628550086
p03713
u343437894
1499614182
Python
Python (3.4.3)
py
Runtime Error
17
3064
420
(h, w) = map(int, input().split(" ")) ans=[] ### case1 000 ans.append(0 if h%3==0 else w) ###case 2 tate 000 ans.append(0 if w%3==0 else h) def getmin(h, w): area=9999999999999 for i in range(h): for j in range(w): areas=[ i * w, j * (h-i), (w-j)*(h-i)] area = min(areas) if ar...
s048006799
p03713
u061916079
1498742869
Python
Python (3.4.3)
py
Runtime Error
163
13088
367
# -*- coding: utf-8 -*- import math import sys import itertools import numpy as np h, w = map(int, input().split()) m = math.inf m = min(m, (1 if h % 3 else 0) * w) m = min(m, (1 if w % 3 else 0) * h) for _ in range(2): for i in range(1, h+1): v = np.array([i*w, w//2*(h-i), (w-w//2)*(h-i)]) m = mi...
s139162051
p03713
u865604924
1496788540
Python
Python (3.4.3)
py
Runtime Error
17
3064
297
N = sys.stdin.readline().replace('\n','') N = int(N) def Func(a,b): if a > b: return digit(a) else: return digit(b) def digit(num): d = len(str(num)) return d ans = 10 for i in range(1,N): if i*i > N: break if N % i == 0: dum = Func(N//i,i) if ans > dum: ans = dum print(ans)
s466102053
p03713
u780709476
1496248295
Python
Python (3.4.3)
py
Runtime Error
17
3064
421
def calc(ox, oy): if(ox % 3 == 0): return 0 s1 = s2 = s3 = 10 ** 10 ans = 10 * 10 for i in range(0,ox): s1 = i * oy s2 = (ox - i) * (oy // 2) s3 = (ox - i) * (oy - oy // 2) ans_ = max(s1, s2, s3) - min(s1, s2, s3) if(ans < ans_): return ans ...
s077348574
p03713
u780709476
1496248028
Python
Python (3.4.3)
py
Runtime Error
18
3064
383
def calc(ox, oy): s1 = s2 = s3 = 10 ** 10 ans = 10 * 10 for i in range(0,ox): s1 = i * oy s2 = (ox - i) * (oy // 2) s3 = (ox - i) * (oy - oy // 2) ans_ = max(s1, s2, s3) - min(s1, s2, s3) if(ans < ans_): return ans else: ans = ans_ H, W...
s112750510
p03713
u676264453
1496113205
Python
Python (3.4.3)
py
Runtime Error
17
3064
1685
import math import sys T = list(map(int, input().split())) S = T[0] * T[1] if ((T[0] % 3 == 0) or (T[1] % 3 == 0)): print(0) sys.exit() minS = 100000000 #T[0]からせめる for i in range(1, math.ceil(T[0]/2)): A = i * T[1] F = math.floor(T[1] / 2) * (T[0] - i) C = S - (A + F) if (F == C): min...
s722605487
p03713
u976162616
1496100601
Python
Python (3.4.3)
py
Runtime Error
18
3188
1498
def check_s(tmp1, tmp2, tmp3): S_min = 2 ** 50 S_max = 0 S_min = min(S_min, tmp1, tmp2, tmp3) S_max = max(S_max, tmp1, tmp2, tmp3) return S_max - S_min if __name__ == "__main__": H,W = map(int, input().split()) if (H > W): H,W = W,H if (H % 3 == 0 or W % 3 == 0): print (...
s704154747
p03713
u976162616
1496099465
Python
Python (3.4.3)
py
Runtime Error
18
3192
1994
def check1(H1, H2, W1, W2): S_min = 2 ** 50 S_max = 0 res1 = H1 * W1 res2 = H1 * W2 res3 = H2 * (W1 + W2) S_min = min(S_min, res1) S_min = min(S_min, res2) S_min = min(S_min, res3) S_max = max(S_max, res1) S_max = max(S_max, res2) S_max = max(S_max, res3) return S_max - S...
s567528069
p03713
u119303585
1495989348
Python
Python (3.4.3)
py
Runtime Error
17
3064
696
h, w = [int(n) for n in input().split()] i = min(h, w) j = max(h, w) area = i * j if i % 3 == 0 or j % 3 == 0: print(0) else: p = j // 3 + 1 pp = i // 3 + 1 q = j // 3 - 1 qq = i // 3 - 1 a1 = i * p aa1 = j * p a2 = i * q aa2 = j * q b1 = i // 2 * (j - p) bb1 = j // 2 * (i - ...
s973008630
p03713
u119303585
1495989058
Python
Python (3.4.3)
py
Runtime Error
17
3064
1103
h, w = [int(n) for n in input().split()] i = min(h, w) j = max(h, w) area = i * j if i % 3 == 0 or j % 3 == 0: print(0) else: p = j // 3 + 1 pp = i // 3 + 1 q = j // 3 - 1 qq = i // 3 - 1 a1 = i * p aa1 = j * p a2 = i * q aa2 = j * q b1 = i // 2 * (j - p) bb1 = j // 2 * (i - ...
s993632683
p03713
u119303585
1495988577
Python
Python (3.4.3)
py
Runtime Error
17
3064
638
h, w = [int(n) for n in input().split()] i = min(h, w) j = max(h, w) area = i * j if i % 3 == 0 or j % 3 == 0: print(0) else: p = j // 3 + 1 pp = i // 3 + 1 q = j // 3 - 1 qq = i // 3 - 1 a1 = i * p aa1 = j * p a2 = i * q aa2 = j * q b1 = i // 2 * (j - p) bb1 = j // 2 * (i - ...
s558217817
p03713
u119303585
1495988006
Python
Python (3.4.3)
py
Runtime Error
18
3064
276
h, w = [int(n) for n in input().split()] i = min(h, w) j = max(h, w) area = i * j if i % 3 == 0 or j % 3 == 0: print(0) else: p = j // 3 + 1 q = j // 3 - 1 a = i * p b = i // 2 * (j - p) c = i * q - (i // 2 * (j - q)) print(min(abs(a - b), abs(c))
s362522882
p03713
u119303585
1495987595
Python
Python (3.4.3)
py
Runtime Error
17
3060
178
h, w = [int(n) for n in input().split()] i,j = [h,w].sort() area = i*j if i % 3 == 0 or j % 3: print(0) else: p=j//3+1 a = i*(p) b= i//2*(j-p) print(abs(a-b))
s700967876
p03713
u119303585
1495987520
Python
Python (3.4.3)
py
Runtime Error
17
3060
170
h, w = [int(n) for n in ipt[:1]] i,j = [h,w].sort() area = i*j if i % 3 == 0 or j % 3: print(0) else: p=j//3+1 a = i*(p) b= i//2*(j-p) print(abs(a-b))
s066785704
p03713
u780709476
1495946650
Python
Python (3.4.3)
py
Runtime Error
19
2940
289
y, x = map(int, input().split()) if(x % 3 == 0 or y % 3 == 0): print(0) else: if(x < y): x1 = x % 3 x2 = x - x1 y1 = y // 2 print(x1 * y - x2 * y1) else: y1 = y % 3 y2 = y - y1 x1 = x // 2 print(y1 * x - y2 * x1)
s405136426
p03713
u780709476
1495946572
Python
Python (3.4.3)
py
Runtime Error
17
2940
344
y, x = map(int, input().split()) if(x % 3 == 0 or y % 3 == 0): print(0) else: if(x < y): x1 = x % 3 x2 = x - x1 y1 = y // 2 print(x1 * y - x2 * y1) else: y1 = y % 3 y2 = y - y1 x1 = x // 2 ...
s499856277
p03713
u612516335
1495581208
Python
Python (3.4.3)
py
Runtime Error
18
3064
454
def paralell_divide(H, W): return 0 if W % 3 == 0 else H def perpendicular_divide(H, W): if W % 2 == 0: return W / 2 a = (H - 1) / 3 if H % 3 == 1 else (H + 1) / 3 b = (W + 1) / 2 * (H - a) c = (W - 1) / 2 * (H - a) a = a * W return max(a, b, c) - min(a, b, c) H, W = map(int, input...
s414687182
p03713
u820351940
1495549682
Python
Python (3.4.3)
py
Runtime Error
17
2940
375
//h w //abc //arc #include <iostream> #include <string> using namespace std; int main(){ int h, w; cin >> h >> w; string result = ""; for(int i = 0; i < w + 2; i++) result += "#"; result += "\n"; for(int i = 0; i < h; i++){ string s; cin >> s; result += "#" + s + "#\n"; } for(int i = 0; i < w + 2; i++) resu...
s791377179
p03713
u019578976
1495498032
Python
Python (3.4.3)
py
Runtime Error
17
3064
1354
H,W = map(int,input().split()) min_tmp=1000000 if H%3 == 0 or W%3 == 0: print(0) else: for i in range(W):#縦方向に可変なバーを作成 a1 = i*H #左側面積 a2 = (W-i)*H #右側面積 if a1 > a2: #左側面積のほうが大きいとき for j in range(i):#さらに縦割り a3 = i*H #左側面積 a4 = (i-j)...
s901800436
p03713
u817142576
1495385998
Python
Python (2.7.6)
py
Runtime Error
11
2568
367
h, w = map(int, raw_input().split()) longer = max(h, w) shorter = min(h, w) ans = float("inf") for x in range(1, longer: y = shorter / 2 s1 = x * shorter s2 = (longer - x) * y s3 = (shorter - y) * (longer - x) smax = max(s1, s2, s3) smin = min(s1, s2, s3) diff = smax - smin if diff < ans...
s849216623
p03713
u276192130
1495346674
Python
Python (3.4.3)
py
Runtime Error
17
3064
365
h, w = map(int, input().split()) if h%3 == 0 or w%3 == 0: ans = 0 else: s = [] high = max(h, w) low = min(h, w) s.append(round(high/3)*low) high2 = max(high-round(high/3), low) low2 = min(high-round(high/3), low) s.append(round(high2/2)*low2) s.append((high2-round(high2/2))*low2) ...
s284703630
p03713
u706884679
1495337634
Python
Python (3.4.3)
py
Runtime Error
17
2940
682
H, W = map(int, input().split()) for h in range(1, H-1) A = h * W B = int((H - h)//2) * W C = H * W - (A + B) D = max(A, B ,C) - min(A, B, C) a1 = [] a1.append(D) A1 = min(a1) for h in range(1, H-1) A = h * W B = int(W//2) * (H - h) C = H * W - (A + B) D = max(A, B ,C) - min(A, B, C) a2 = [] a2.append(D)...
s489440080
p03713
u638552534
1495335294
Python
Python (2.7.6)
py
Runtime Error
13
5872
653
H, W = map(int, raw_input().split()) best = H * W for h in range(H): S[0] = h * W S[1] = (H - h) * (W / 2) S[2] = (H - h) * (W - W / 2) if best > max(S) - min(S): best = max(S) - min(S) S[1] = (H - h) / 2 * W S[2] = (H - h - (H - h) / 2) * W if best > max(S) - min(S): bes...
s756396891
p03713
u502149531
1495334926
Python
Python (3.4.3)
py
Runtime Error
17
2940
509
x, y = map(int,input().split()) if x % 3 == 0 : print (0) elif y % 3 == 0 : print (0) else : if y > x : z = y y = x x = z a = int(x / 3) + 1 if y % 2 == 0 : a = a - 1 s = a * y #print (s) t = int((x - a) * y / 2) #print (t) if t > s : print (t - s) else p...
s383368434
p03713
u839857256
1495334489
Python
Python (3.4.3)
py
Runtime Error
19
3188
1449
n = input() tmp_n = n.split(" ") h = int(tmp_n[0]) w = int(tmp_n[1]) if h%3==0 or w%3==0: print("0") else: len_area1 = int(max(h,w)/3)+1 len_area2 = int(max(h,w)/3) tmp_area_a1 = min(h,w)*len_area1 tmp_area_a111 = (max(h,w)-len_area1) * int(min(h,w)/2) tmp_area_a112 = (max(h,w)-len_area1) * i...
s556583426
p03713
u768816323
1495334344
Python
Python (3.4.3)
py
Runtime Error
17
2940
141
H,W=(int(i) for i in input (). split ()) if H%3==0 or W%3==0: print (0) else: if H<W: T=H H=W W=H W1=W//3
s000898412
p03713
u256260242
1495334257
Python
Python (3.4.3)
py
Runtime Error
477
9600
1109
n,m=list(map(int, input().split())) lll = [] a = n b = m if (n * m) % 3 == 0: print(0) else: for i in range(1, a): p = b * i if b % 2 == 1: q = (a - i) * (int(b / 2) + 1) elif b % 2 == 0: q = (a - i) * (int(b / 2)) r = (a - i) * (int(b / 2)) if a...
s237611546
p03713
u276192130
1495334239
Python
Python (3.4.3)
py
Runtime Error
17
2940
368
import math h, w = map(int, input().split()) low = min(h, w) high = max(h, w) if h%3 == 0 or w%3 == 0: print (0) elif (high/3) > low: print ((high % 3)*low else: a = math.ceil(high/3)*low b = (high-math.ceil(high/3))*int(low/2) c = abs(a-b) a = round(high/3)*low b = (high-round(high/3))*in...
s333952168
p03713
u276192130
1495334211
Python
Python (3.4.3)
py
Runtime Error
17
2940
368
import math h, w = map(int, input().split()) low = min(h, w) high = max(h, w) if h%3 == 0 or w%3 == 0: print (0) elif (high/3) > low: print ((high % 3)*low else: a = math.ceil(high/3)*low b = (high-math.ceil(high/3))*int(low/2) c = abs(a-b) a = round(high/3)*low b = (high-round(high/3))*in...
s143355809
p03713
u256260242
1495334133
Python
Python (3.4.3)
py
Runtime Error
564
8880
1124
n,m=list(map(int, input().split())) lll = [] a = n b = m if (n * m) % 3 == 0: print(0) else: for i in range(1, a): p = b * i if b % 2 == 1: q = (a - i) * (int(b / 2) + 1) elif b % 2 == 0: q = (a - i) * (int(b / 2)) r = (a - i) * (int(b / 2)) ...
s322417911
p03713
u019578976
1495333804
Python
Python (3.4.3)
py
Runtime Error
17
3064
361
H,W = map(int,input().split()) if H%3==0 or W%3==0: print(0) elif H%3==W%3: if H <= W: a = (H*(W/2)) - (H/2*(W/2+1)) b = ((W/3+1) - (W/3))*H if a > b: print(int(b)) else: print(int(a)) else: a = (W*(H/2)) - (W/2*(H/2+1)) b = ((H/3+1) - (H/3))*W if a > b: print(int(...
s709323334
p03713
u859491652
1495333037
Python
Python (3.4.3)
py
Runtime Error
34
3064
838
H, W = map(int, input().split()) #一回目 BS = H * W // 3 for i in range(W): if H * i >= BS: BW = i break for i in range(H): if W * i >= BS: BH = i break if BH * W - BS > BW * H - BS: S1 = BW * H BS2 = (H * W - BW * H) // 2 for i in range(W - BW): if H * i >= BS2: BH2 = i break for i in range(H): ...
s426072216
p03713
u677421794
1495332937
Python
Python (2.7.6)
py
Runtime Error
91
4228
480
# -*- coding: utf-8 -*- h,w = map(int, raw_input().split()) area = [0,0,0] ans = 999999999999 if(h%3 == 0 or w%3 == 0): print('0') exit(1) for i in range(1,h/2+1): area[0] = i*w area[1] = (w/2)*(h-i) area[2] = (w-w/2)*(h-i) S = max(area)-min(area) if(S<ans): ans = S for i in ra...
s388184594
p03713
u192908410
1495332747
Python
Python (3.4.3)
py
Runtime Error
17
2940
243
h,w = sorted(list(map(int,input().split()))) if h % 3 == 0 or w % 3 == 0: ret = 0 else: c1 = ((w//3+1)*h)-((w-1-w//3)*(h//2) c2 = ((w-w//3)*(h-h//2))-(w//3*h) c3 = ((w-w//3)*(h-h//2))-((w-w//3)*(h//2)) ret = min(c1,c2,c3) print(ret)
s862052665
p03713
u351527281
1495332623
Python
Python (3.4.3)
py
Runtime Error
17
3064
290
H,W=map(int, input().split()) if H%3==0 or W%3==0: print(0) else: a = int(W/2)*H b = int(H/2)*(W-int(W/2)) c = H*W-a-b d1 = max([a,b,c])-min([a,b,c]) e = int(H/2)*W f = int(W/2)*(H-int(H/2)) g = H*W-a-b d2 = max([e,f,g])-min([e,f,g]) print(min([d1,d2]))
s159862666
p03713
u677421794
1495331584
Python
Python (2.7.6)
py
Runtime Error
114
4228
541
# -*- coding: utf-8 -*- h,w = map(int, raw_input().split()) a,b,c = 0,0,0 diff =[0,0,0] ans = 999999999999 if(h%3 == 0 or w%3 == 0): print('0') exit(1) for i in range(1,h/2+1): a = i*w b = (w/2)*(h-i) c = (w-w/2)*(h-i) diff = abs(a-b),abs(a-c),abs(b-c) S = max(diff)-min(diff) if(S<an...
s208196048
p03713
u926678805
1495329842
Python
Python (3.4.3)
py
Runtime Error
201
7032
394
# coding: utf-8 x,y=map(int,input().split()) data=[] if (x*y)%3==0: print(0) else: for i in range(1,max(x,y)): a=i*min(x,y) if (x*y-a)%2==0: data.append(max(a,(x*y-a)//2)-min(a,(x*y-a)//2)) else: b=((x*y-a)/2)-0.5*(max(x,y)-i) c=((x*y-a)/2)+0.5*(max(x,...
s253241064
p03714
u378691508
1599955283
Python
PyPy3 (7.3.0)
py
Runtime Error
159
129848
933
N=int(input()) A=list(map(int, input().split())) A_rev = [-x for x in A[::-1]] #逆順にして各要素を-1倍する left, right = A[:N], A_rev[:N] sum_left_list, sum_right_list = [0]*(N+1), [0]*(N+1) sum_left, sum_right = sum(left), sum(right) sum_left_list[0], sum_right_list[0]=sum_left, sum_right #left: k=N, N+1,..., 2N-1まで動かして大きい方からN個の...
s424613338
p03714
u892487306
1588315082
Python
Python (3.4.3)
py
Runtime Error
92
38932
924
N = int(input()) tmp = list(map(int, input().split(' '))) former_A = deque(tmp) latter_A = deque(tmp.copy()) former_heap = list() latter_heap = list() for _ in range(N): former_heap.append(former_A.popleft()) latter_heap.append(- latter_A.pop()) heapify(former_heap) heapify(latter_heap) former_sum = sum(former...
s913532840
p03714
u892487306
1588314754
Python
Python (3.4.3)
py
Runtime Error
139
37468
973
from collections import deque from heapq import heapify, heappop, heappush N = int(input()) A = deque(map(int, input().split(' '))) former_heap = list() latter_heap = list() for _ in range(N): former_heap.append(A.popleft()) latter_heap.append(- A.pop()) heapify(former_heap) heapify(latter_heap) former_sum = s...
s050979886
p03714
u390193191
1586097409
Python
PyPy3 (2.4.0)
py
Runtime Error
324
118816
613
n = int(input()) A = list(map(int, input().split())) pre = [0]*(n+1) pre_list = [e for e in A[:n]] heapq.heapify(pre_list) pre_sum = sum(pre_list) pre[0] = pre_sum for i in range(n, 2*n): small = heapq.heappushpop(pre_list, A[i]) pre_sum += A[i] - small pre[i-n+1] = pre_sum suf = [0]*(n+1) suf_list = [-e ...
s907509554
p03714
u223904637
1582345349
Python
Python (3.4.3)
py
Runtime Error
17
3064
492
import heapq n=int(input()) l=list(map(int,input().split())) q=[] for i in range(n): heapq.heappush(q,l[i]) a1=[0]*(n+1) a1[0]=sum(l[:n]) for i in range(n): p=heapq.heappop(q) a1[i+1]=a1[i]-p+max(p,l[i+n]) heapq.heappush(q,max(p,l[i+n])) q=[] l.reverse() for i in range(n): heapq.heappush(q,-l[i]) a1...
s382503192
p03714
u934978909
1578921572
Python
Python (3.4.3)
py
Runtime Error
38
12148
384
from random import choice N=int(input()) lista=[] total=0 for criando in range (0,3*N): a = int(input()) lista.append(a) for loop in range (0,N): escolhido=choice(lista) if escolhido in lista: lista.remove(escolhido) for conta in range (0,len(lista)): if conta<(len(lista))/2: total+=...
s246603916
p03714
u780962115
1576737938
Python
PyPy3 (2.4.0)
py
Runtime Error
312
119100
794
#3N numbers n=int(input()) lists=list(map(int,input().split())) second=lists.copy() second=second[::-1] for i in range(3*n): second[i]=-second[i] MAX=sum(lists[:n]) MIN=-sum(second[:n]) MAXlist=[0 for i in range(n+1)] MINlist=[0 for i in range(n+1)] MAXlist[0]=MAX MINlist[0]=MIN ANS=-10**100 import heapq a=list...
s998100942
p03714
u716530146
1573949449
Python
PyPy3 (2.4.0)
py
Runtime Error
311
112240
841
#!/usr/bin/env python3 import sys, math, heapq input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**8) inf = float('inf') ans=count=0 ans = -inf n = int(input()) A = list(map(int, input().split())) AL, AR = A[:n], A[2*n:] al,ar=AL.copy(),AR.copy() AN = A[n:2*n] LS, RS = sum(A...
s201191164
p03714
u284854859
1570033648
Python
PyPy3 (2.4.0)
py
Runtime Error
163
38416
89
import sys input = sys.stdin.readlin n = int(input()) a = list(map(int,input().split()))
s642452333
p03714
u778814286
1561088154
Python
PyPy3 (2.4.0)
py
Runtime Error
907
148140
2635
###template### import sys def input(): return sys.stdin.readline().rstrip() from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt, ceil, floor from collections import deque from bisect import bisect, bisect_left, bisect_right fro...
s824501353
p03714
u391731808
1557460047
Python
Python (3.4.3)
py
Runtime Error
93
37364
502
N = int(input()) *A, = map(int,input().split()) q = [] for a in A[:N]: heapq.heappush(q,a) S1 = [sum(q)] for a in A[N:N*2]: if a>q[0]: S1.append(S1[-1] + a - q[0]) heapq.heapreplace(q,a) else: S1.append(S1[-1]) q = [] for a in A[2*N:]: heapq.heappush(q,-a) S2 = [sum(q)] for a in ...
s873264593
p03714
u952708174
1556513018
Python
Python (3.4.3)
py
Runtime Error
106
39280
1220
def d_3n_numbers(N, A): import heapq left = A[:N] heapq.heapify(left) # heappopはキューの最小値を取り出すが、rightからは最大値を取り出したいので-1を掛ける # 後にマイナスが付いているところは、それの帳尻を合わせている right = [-i for i in A[2 * N:]] heapq.heapify(right) # 最初、leftには数列の先頭N個が、rightには末尾N個が格納されている # 数列のN番目から2N番目まで順に、leftに格納して最小値を捨てること...
s834010856
p03714
u284854859
1554683392
Python
Python (3.4.3)
py
Runtime Error
17
2940
1310
ef d_3n_numbers(N, A): import heapq def _heappush_max(heap, item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap) - 1) def _heappop_max(heap): """Maxheap version of a heappop."""   lastelt = heap.pop() # raises appropriate IndexError if heap is empty   if heap: ...
s125703912
p03714
u952708174
1554566921
Python
Python (3.4.3)
py
Runtime Error
306
38676
971
def d_3n_numbers(N, A): import heapq def _heappush_max(heap, item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap) - 1) setattr(heapq, '_heappush_max', _heappush_max) left = A[:N] heapq.heapify(left) right = A[2 * N:] heapq._heapify_max(right) left_sum, right_...
s121194437
p03714
u794250528
1550597042
Python
Python (3.4.3)
py
Runtime Error
1107
66832
1068
import heapq n = int(input()) a = list(map(int, input().split())) sum1 = 0 sum2 = 0 left = [] used = set() unused = [] for i in range(n): sum1 += a[i] heapq.heappush(left, (a[i], i)) for v, i in sorted((a[i], i) for i in range(n, n * 3)): if len(used) < n: sum2 += v used.add((v, i)) ...
s843955367
p03714
u069838609
1541543729
Python
Python (3.4.3)
py
Runtime Error
18
3064
820
#import sys from heapq import heapify, heappushpop from heapq import _heapify_max as heapify_max, _siftup_max def heappushpop_max(heap, item): if heap and heap[0] > item: item, heap[0] = heap[0], item _siftup_max(heap, 0) return item fin = sys.stdin.readline N, *a_list = map(int, open(0).rea...
s843048588
p03714
u069838609
1541538859
Python
PyPy3 (2.4.0)
py
Runtime Error
2113
142540
15305
import sys fin = sys.stdin.readline from heapq import heappop, heappush, heapify class BSTNode(object): """A node in the vanilla BST tree.""" def __init__(self, parent, k): """Creates a node. Args: parent: The node's parent. k: key of the node. """...
s837738901
p03714
u334712262
1533895176
Python
Python (3.4.3)
py
Runtime Error
367
39600
2052
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from pprint import pprint from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_r...
s321187065
p03714
u334712262
1533895111
Python
PyPy3 (2.4.0)
py
Runtime Error
613
128108
2052
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from pprint import pprint from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_r...
s403583264
p03714
u467736898
1529457886
Python
Python (3.4.3)
py
Runtime Error
371
37212
753
import bisect N = int(input()) A = list(map(int, input().split())) L = sorted(A[:2*N]) sumL = sum(L[N:]) R = sorted(A[N:]) sumR = sum(R[:N]) AL = [sumL] p = N for a in reversed(A[N:2*N]): # sumLはだんだん減る ind = bisect.bisect_left(L, a) if ind >= p: sumL -= L[ind] p -= 1 while L[p] == Fal...
s010865007
p03714
u490724687
1501205811
Python
Python (3.4.3)
py
Runtime Error
113
40196
497
import heapq n = int(input()) a = list(map(int, input().split())) red, blue = a[:n], [-1*i for i in a[2*n:]] sr, sb = sum(red), sum(blue) results = [0] * (n + 1) results[0] = sr results[-1] = sb heapq.heapify(red) heapq.heapify(blue) for k in range(n, 2*n): v = a[k] p = heapq.heappushpop(red, v) sr += ...
s677962489
p03714
u410717334
1498407250
Python
Python (3.4.3)
py
Runtime Error
2109
40144
515
import queue N=int(input()) a=list(map(int,input().split())) sl=[0]*(N+1) ft=sum(a[:N]) st=sum(a[2*N:]) fa=queue.PriorityQueue(N+1) sa=queue.PriorityQueue(N+1) sl[0]=ft sl[N]=-st for i in range(N): fa.put(a[i]);sa.put((-1*a[i+2*N],a[i+2*N])) for k in range(N,2*N): fa.put(a[k],timeout=2) ft+=a[k] ft-=(fa...
s995112034
p03714
u119303585
1496158021
Python
Python (3.4.3)
py
Runtime Error
266
37212
823
N = int(input()) array = [int(n) for n in input().split()] import copy import heapq lst = [None for i in range(N + 1)] left_lst = copy.deepcopy(lst) right_lst = copy.deepcopy(lst) right_array = heapq.heapify(array[:N]) left_array = heapq.heapify([-n for n in array[-N:]]) l_sum = sum(left_array) r_sum = sum(right_array...
s867263171
p03714
u119303585
1496028681
Python
Python (3.4.3)
py
Runtime Error
17
2940
522
N = int(input()) array=[int(n) for n in input().split()] lst=[] left_array=array[:N] right_array=array[-N:] for i in range(N+1): for j in range(i): new_a=array[N+j+1] old_a=min(left_array) new_b=array[-N-j-1] old_b=min(right_array) left...
s881726760
p03714
u119303585
1496005387
Python
Python (3.4.3)
py
Runtime Error
2105
156400
359
N = int(input()) array=[int(n) for n in input().split()] lst=[] for i in range(N+1): left_array=array[:N+i] print(left_array) l = sorted(left_array)[-N:] print('l:',l) right_array=array[N+i:] print(right_array) r = sorted(right_array)[:N] print('r:',r) ans = sum(l)-sum(r) print(a...
s579733187
p03714
u119303585
1496005285
Python
Python (3.4.3)
py
Runtime Error
228
37236
258
N = int(input()) array=[int(n) for n in input().split()] lst=[] for i in range(N+1): left_array=array[:N+i] l = sorted(left_array)[-N:] right_array=array[N+i:] r = sorted(right_array)[:N] ans = sum(l)-sum(r) lst.extend(ans) print(lst)
s318033249
p03714
u119303585
1495994473
Python
Python (3.4.3)
py
Runtime Error
2105
156268
369
N = int(input()) array=[int(n) for n in input().split()] lst=0 for i in range(N+1): left_array=array[:N+i] print(left_array) l = sorted(left_array)[-N:] print('l:',l) right_array=array[N+i:] print(right_array) r = sorted(right_array)[:N] print('r:',r) ans = sum(l)-sum(r) print(a...
s372891859
p03714
u119303585
1495994301
Python
Python (3.4.3)
py
Runtime Error
2105
156252
377
N = int(input()) array=[int(n) for n in input().split()] lst=0 for i in range(N+1): left_array=array[:N+i] print(left_array) l = sorted(left_array)[-N:] print('l:',l) right_array=array[-int(N)+i-3:] print(right_array) r = sorted(right_array)[:N] print('r:',r) ans = sum(l)-sum(r) ...
s159229491
p03714
u119303585
1495992597
Python
Python (3.4.3)
py
Runtime Error
46
27612
373
N = input() array= input().split() left_array=array[:array/3+1] mid_array= array[array/3+1:-array/3] right_array= array[-array/3] lst=0 for i in N: left_array=array[:array/3+i+1] l = left_array.sort()[i+1:] right_array=array[-array/3+i+1:] r = right_array.sort(reverse=True)[N-i-1:] ans = sum(abs(l-r...
s685238472
p03714
u119303585
1495992544
Python
Python (3.4.3)
py
Runtime Error
48
27612
369
N = input() array= input().split() left_array=array[:array/3+1] mid_array= array[array/3+1:-array/3] right_array= array[-array/3] lst=[] for i in N: left_array=array[:array/3+i+1] l = left_array.sort()[i+1:] right_array=array[-array/3+i+1:] r = right_array.sort(reverse=True)[N-i-1:] ans = sum(abs(l-...
s882053124
p03714
u067983636
1495866225
Python
Python (3.4.3)
py
Runtime Error
2107
37188
876
N = int(input()) a = list(map(int,input().split())) S1 , S2 = {}, {} for i in range(N): S1[a[i]] = S1.get(a[i], 0) + 1 for i in range(2 * N, 3* N): S2[a[i]] = S2.get(a[i], 0) + 1 i = N j = 2 * N - 1 minS1 = min(S1) maxS2 = max(S2) while i <= j: delS1 = a[i] - minS1 delS2 = maxS2 - a[j] if delS...
s714498160
p03714
u280667879
1495463306
Python
PyPy3 (2.4.0)
py
Runtime Error
317
127704
222
def f(a): s=0;q=a[:n];s=sum(q);heapify(q);yield s for e in a[n:2*n]:s+=e-heappushpop(q,e);yield s from heapq import*;r=reversed;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),r(f([-e for e in r(a)]))))))
s356449139
p03714
u280667879
1495453975
Python
PyPy3 (2.4.0)
py
Runtime Error
386
127704
286
def f(a): s=0;q=[] for i in range(n):s+=a[i];heappush(q,a[i]) r=[s] for i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s] return r import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(x+y for x,y in zip(f(a),f(list(reversed(-e for e in a))))))
s255994497
p03714
u280667879
1495453824
Python
PyPy3 (2.4.0)
py
Runtime Error
389
127704
280
def f(a): s=0;q=[] for i in range(n):s+=a[i];heappush(q,a[i]) r=[s] for i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s] return r import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(x+y for x,y in zip(f(a),f(reversed(-e for e in a)))))
s224491140
p03714
u382748202
1495341471
Python
Python (3.4.3)
py
Runtime Error
94
37212
640
import heapq N = int(input()) a = list(map(int, input().split())) max_score = float('-inf') for i in range(N, 2 * N + 1): rm_count_1 = i - N rm_count_2 = N - rm_count_1 a_list_1 = [] a_list_2 = [] for k in a[0:i]: if len(a_list_1) >= N: heappushpop(a_list_1, k) else: ...
s053962049
p03714
u382748202
1495341030
Python
Python (3.4.3)
py
Runtime Error
25
3444
657
from collections import heapq N = int(input()) a = list(map(int, input().split())) max_score = float('-inf') for i in range(N, 2 * N + 1): rm_count_1 = i - N rm_count_2 = N - rm_count_1 a_list_1 = [] a_list_2 = [] for k in a[0:i]: if len(a_list_1) >= N: heappushpop(a_list_1, k)...
s674703771
p03714
u192908410
1495338527
Python
Python (3.4.3)
py
Runtime Error
2104
157268
397
n = int(input()) a = list(map(int,input().split())) r = [] b = a[:n] bs = sum(b) c = sorted(a[n:]) cs = sum(c[:n]) print(b,c,bs,cs,bs-cs) r.append(bs-cs) for k in range(n,2*n): b.append(a[k]) bm = min(b) b.remove(bm) bs = bs + a[k] - bm if n <= 1000: ci = c.index(a[k]) if ci < n: cs = cs - a[k] ...
s876968189
p03714
u205803237
1495336569
Python
Python (3.4.3)
py
Runtime Error
2106
38440
975
N = int(input()) l_ = input().split() a = [int(l_[i]) for i in range(N)] b = [int(l_[i]) for i in range(N, 2*N)] c = [int(l_[i]) for i in range(N*2, N*3)] while len(b) > 0: front = b[0] - min(a) behind = b[-1] - max(c) if abs(front) > abs(behind): a.remove(min(a)) a.append(b[0]) b....
s084332642
p03714
u205803237
1495336316
Python
Python (3.4.3)
py
Runtime Error
73
29612
961
N = int(input()) l_ = input().split() a = [l_[i] for i in range(N)] b = [l_[i] for i in range(N, 2*N)] c = [l_[i] for i in range(N*2, N*3)] while len(b) > 0: front = b[0] - min(a) behind = b[-1] - max(c) if abs(front) > abs(behind): a.remove(min(a)) a.append(b[0]) b.remove(b[0]) ...
s295985269
p03714
u205803237
1495334520
Python
Python (3.4.3)
py
Runtime Error
70
30812
961
N = int(input()) l_ = input().split() a = [l_[i] for i in range(N)] b = [l_[i] for i in range(N, 2*N)] c = [l_[i] for i in range(N*2, N*3)] while len(b) > 0: front = b[0] - min(a) behind = b[-1] - max(c) if abs(front) > abs(behind): a.remove(min(a)) a.append(b[0]) b.remove(b[0]) ...
s664620216
p03714
u087996506
1495334189
Python
Python (2.7.6)
py
Runtime Error
2109
36200
607
# -*- coding: utf-8 -*- import numpy as np N = int(raw_input()) a = map(int, raw_input().split()) flag = 0 while N > 1: l = len(a) if flag == 0: min = np.argmin(a[:(l//2)]) a.pop(min) N -= 1 flag = 1 elif flag == 1: max = np.argmax(a[(l//2):]) + l//2 a.pop(max) N...
s948587413
p03714
u532827876
1495330968
Python
Python (3.4.3)
py
Runtime Error
50
30812
790
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import math sets = [ set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2]) ] N = int(sys.stdin.readline().rstrip()) A = map(int, sys.stdin.readline().rstrip().split()) HEAD = list(sorted(A[:N])) TAIL = list(reversed(sorted(A[2*N:]))) MID_ASC = A[N:2*N] MID...
s958200970
p03715
u477320129
1592165587
Python
Python (3.4.3)
py
Runtime Error
18
3064
879
#!/usr/bin/env python3 import sys def f(H, W): mh = H // 2 mw = W // 2 return (mh*W, (H-mh)*W), (H*mw, H*(W-mw)) def solve_iter(H: int, W: int): for h in range(1, H): for s in ((h*W,*s) for s in f(H-h, W)): yield max(s) - min(s) for w in range(1, W): for s in ((H*w,*s)...
s071703468
p03715
u366541443
1591501360
Python
PyPy3 (2.4.0)
py
Runtime Error
209
40816
7550
import math #import sys #input = sys.stdin.readline def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors def ValueToBits(x,digit):...
s353634958
p03715
u219417113
1589061945
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38256
1065
def main(): import sys input = sys.stdin.readline a, b = map(int, input().split()) if a % 3 == 0 or b % 3 == 0: print(0) sys.exit() if a > b: a, b = b, a x = (b // 3) * a bb = b - b//3 aa = a if aa % 2 == 0 ...
s062770175
p03715
u041351774
1587937068
Python
Python (3.4.3)
py
Runtime Error
18
3064
415
import heapq n=int(input()) a=list(map(int,input().split())) q=a[0:n] sums=[0]*(n+1) sums[0]=sum(q) heapq.heapify(q) am=a[n:2*n] for i in range(0,n): heapq.heappush(q,am[i]) heapq.heappop(q) sums[i+1]=sum(q) p=a[2*n:3*n] p=list(map(lambda x: x*(-1),p)) sums[n]+=sum(p) heapq.heapify(p) for i in range(n-1,-1,...
s427840199
p03715
u203900263
1585864754
Python
Python (3.4.3)
py
Runtime Error
17
2940
130
N, T = map(int, input().split()) t = list(map(int, input().split())) o = T for i, j in zip(t, t[1:]): o += min(j-i, T) print(o)
s337554402
p03715
u170183831
1581275402
Python
PyPy3 (2.4.0)
py
Runtime Error
182
38384
732
def solve(h, w): if h % 3 == 0 or w % 3 == 0: return 0 if h == 1 or w == 1: return 1 min_diff = h * w vals = [0, 0, 0] def f(a, b): for i in range(1, a // 2 + 1): vals[0] = i * b vals[1] = (a - i) * (b // 2 + b % 2) vals[2] = (a - i) * (b /...
s916284355
p03715
u779455925
1581201484
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
762
H,W=map(int,input().split()) if H%3==0 or W%3==0: print(0) elif H%2==0 or W%2==0: if W%2==0: H,W=W,H A1=(H//2 )* W A3=0 value=A1-A3 for i in range(1,W//2 +): A3+=H A1-=H//2 value=min(int(abs(A1-A3)),value) print(value) else: A1=(H//2 +1)* W A2=(H//2)*...
s563701345
p03715
u600402037
1580405362
Python
Python (3.4.3)
py
Runtime Error
196
15508
550
import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) H, W = lr() if H%3==0 or W%3==0: answer = 0 else: answer = min(H, W) # さらに小さくするには縦と横で割る def cal(H, W): h = H // 3 area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]...