input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
from math import floor,ceil H,W = list(map(int,input().split())) if H%3==0 or W%3==0: print((0)) exit() ans = min(H,W) for i in range(1,W): M = max(i*H,floor(H/2)*(W-i),ceil(H/2)*(W-i)) m = min(i*H,floor(H/2)*(W-i),ceil(H/2)*(W-i)) if M-m<ans: ans = M-m for i in range(1,H): M...
H,W = list(map(int,input().split())) def split2(h,w): if h%2==0 or w%2==0: return h*w//2,h*w//2 else: h,w = max(h,w),min(h,w) return h//2*w,(h+1)//2*w ans = H*W for i in range(1,H): h = H-i w = W s1 = W*i s2,s3 = split2(h,w) ans = min(max(s1,s2,s3)-mi...
p03713
H, W = list(map( int, input().split())) if H%3 == 0 or W%3 == 0: ans = 0 else: ans = min( max((H//3+1)*W, (H//3)*W)- min((H//3+1)*W, (H//3)*W), max((W//3+1)*H, (W//3)*H)- min((W//3+1)*H, (W//3)*H)) for i in range(H+1): ans = min( ans, max(W*i, (H-i)*(W//2), (H-i)*(W - W//2)) - min(W*i, (H-i)*...
#import sys #input = sys.stdin.readline def main(): H, W = list(map( int, input().split())) ans = min(H,W) if H%3 == 0 or W%3 == 0: ans = 0 for i in range(1,H): L = [W*i] L.append(W//2*(H-i)) if W%2 == 1: L.append((W//2+1)*(H-i)) if max(L) ...
p03713
H, W = list(map(int, input().split())) def get_ans(A, B): ans = A * B for A1 in range(1, A): A2 = (A - A1) // 2 A3 = A - A1 - A2 S = [A1 * B, A2 * B, A3 * B] ans = min(ans, max(S) - min(S)) for A1 in range(1, A): B2 = B // 2 B3 = B - B2 ...
H, W = list(map(int, input().split())) def getMinDiff(A, B): if A % 3 == 0: return 0 elif B % 2 == 0: return B // 2 else: ans = B # 横3段に分ける場合の値 # T字型に分ける場合 for i in range(A % 3 + 1): A1 = A // 3 + i # 上半分の縦幅 B1, B2 = B // 2, (B +...
p03713
H, W = list(map(int, input().split())) result = [] for h in range(1, H): Sa = W * h remain = H - h h2 = (remain + 1) // 2 Sb1 = W * h2 Sc1 = W * (remain - h2) result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1)) w = (W + 1) // 2 Sb2 = w * remain Sc2 = (W - w) * remai...
H, W = list(map(int, input().split())) result = [] for h in range(1, H//2+1): Sa = W * h remain = H - h h2 = (remain + 1) // 2 Sb1 = W * h2 Sc1 = W * (remain - h2) result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1)) w = (W + 1) // 2 Sb2 = w * remain Sc2 = (W - w) * ...
p03713
H,W = list(map(int,input().split())) #l = sorted([int(input()) for i in range(N)],reverse=True) def three(h,w): ans = h*w for i in range(1,h): A = w*i B = w*((h-i)//2) C = w*((h-i+1)//2) ans = min(ans,max(A,B,C)-min(A,B,C)) return ans def onetwo(h,w): ans = h*w...
H,W = list(map(int,input().split())) #l = sorted([int(input()) for i in range(N)],reverse=True) def three(h,w): ans = h*w for i in range(h//3,h//3+2): A = w*i B = w*((h-i)//2) C = w*((h-i+1)//2) ans = min(ans,max(A,B,C)-min(A,B,C)) return ans def onetwo(h,w): a...
p03713
def solve(h, w): res = float('inf') for hh in range(h + 1): s1 = hh * w ww = w // 2 s2 = (h - hh) * ww s3 = (h - hh) * (w - ww) res = min(res, max(s1, s2, s3) - min(s1, s2, s3)) return res H, W = list(map(int, input().split())) ans = H * W if H % 3 ==...
def calc(h, w): w_1_1 = w // 3 w_1_2 = w_1_1 + 1 ans = inf for w_1 in w_1_1, w_1_2: s_1 = w_1 * h # 縦に割る w_2 = (w - w_1) // 2 s_2 = w_2 * h w_3 = w - w_1 - w_2 s_3 = w_3 * h ss = [s_1, s_2, s_3] # print(h, w, ss) ...
p03713
def main(): high, width = list(map(int, input().split())) ans = high * width for i in range(1, high): a = i * width b1 = (high - i) * (width // 2) c1 = high * width - a - b1 b2 = ((high - i) // 2) * width c2 = high * width - a - b2 kari = mi...
from collections import Counter, defaultdict import sys sys.setrecursionlimit(10 ** 5 + 10) # input = sys.stdin.readline from math import factorial import heapq, bisect import math import itertools def main(): high, width = list(map(int, input().split())) sum_s = high * width ans = sum_s ...
p03713
# -*- coding: utf-8 -*- H,W = list(map(int, input().split())) # # どちらかの辺が3の倍数なら確実に3等分できる # if H % 3 == 0 or W % 3 == 0: # print(0) # exit() # T字で区切るパターンを縦横それぞれ試す mnval = float("inf") for i in range(1,H): tmpA = i * W tmpB = (H-i) * (W // 2) tmpC = (H-i) * (W // 2 + W % 2) mnval...
# -*- coding: utf-8 -*- H,W = list(map(int, input().split())) # T字で区切るパターンを縦横それぞれ試す mnval = float("inf") for i in range(1,H): # Tの横棒に当たる方 tmpA = i * W # 縦2等分 tmpB = (H-i) * (W // 2) # 残り tmpC = H*W - tmpA - tmpB mnval = min(mnval, abs(max(tmpA,tmpB,tmpC) - min(tmpA,tmpB,tmpC))...
p03713
# -*- coding: utf-8 -*- H,W = list(map(int, input().split())) # T字で区切るパターンを縦横それぞれ試す mnval = float("inf") for i in range(1,H): # Tの横棒に当たる方 tmpA = i * W # 縦2等分 tmpB = (H-i) * (W // 2) # 残り tmpC = H*W - tmpA - tmpB mnval = min(mnval, abs(max(tmpA,tmpB,tmpC) - min(tmpA,tmpB,tmpC))...
# -*- 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 ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): r...
p03713
def calc(H, W, ans): w0 = W // 2 w1 = W - w0 for h0 in range(1, H): Sa = h0 * W h1 = H - h0 h2 = h1 // 2 h3 = h1 - h2 Sb1, Sc1 = h1 * w0, h1 * w1 Sb2, Sc2 = h2 * W, h3 * W m1, _, M1 = sorted([Sa, Sb1, Sc1]) m2, _, M2 = sorted([Sa, Sb...
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: a = (h // 3 + 1) * w - (h - 1 - h // 3) * (w // 2) b = (h - h // 3) * (w - w // 2) - h // 3 * w c = min(h, w) h, w = w, h d = (h // 3 + 1) * w - (h - 1 - h // 3) * (w // 2) e = (h - h // 3) * (w - w...
p03713
H,W = [int(i) for i in input().split()] ans = H * W for x in range(1,W): y1 = H // 2 Sa1 = H * x Sb1 = (W - x) * y1 Sc1 = (W - x) * (H - y1) M = max(Sa1,Sb1,Sc1) m = min(Sa1,Sb1,Sc1) y2 = (W - x) // 2 Sa2 = H * x Sb2 = H * y2 Sc2 = H * (W - x - y2) M2 = max(S...
def answer(H,W,ans_kari): for x in range(1,W): y1 = H // 2 Sa1 = H * x Sb1 = (W - x) * y1 Sc1 = (W - x) * (H - y1) M = max(Sa1,Sb1,Sc1) m = min(Sa1,Sb1,Sc1) y2 = (W - x) // 2 Sa2 = H * x Sb2 = H * y2 Sc2 = H * (W - x - y2...
p03713
def answer(H,W,ans): for x in range(1,W): y1 = H // 2 Sa1 = H * x Sb1 = (W - x) * y1 Sc1 = (W - x) * (H - y1) M = max(Sa1,Sb1,Sc1) m = min(Sa1,Sb1,Sc1) y2 = (W - x) // 2 Sa2 = H * x Sb2 = H * y2 Sc2 = H * (W - x - y2) ...
def answer(H,W,ans): global ans_list for x in range(1,W): y1 = H // 2 S1 = [H * x,(W - x) * y1,(W - x) * (H - y1)] ans_list.append(max(S1)-min(S1)) y2 = (W - x) // 2 S2 = [H * x,H * y2,H * (W - x - y2)] ans_list.append(max(S2)-min(S2)) if __name__ == ...
p03713
import sys, os, math, bisect, itertools, collections, heapq, queue # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict, deque sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: li...
h,w=list(map(int,input().split())) pattern=[h//2+w//3+1,h//3+w//2+1,h,w] if h%3==0 or w%3==0: pattern+=[0] if h%2==0: pattern+=[h//2] if w%2==0: pattern+=[w//2] print((min(pattern)))
p03713
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: min_diff = h * w h1 = h // 2 h2 = h - h1 for w3 in range(w // 3, w // 3 + 3): s = [h * w3, h1 * (w - w3), h2 * (w - w3)] min_diff = min(min_diff, max(s) - min(s)) w1 = w // 2 w...
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: min_diff = h * w h1 = h // 2 h2 = h - h1 for w3 in range(w // 3, w // 3 + 2): s = [h * w3, h1 * (w - w3), h2 * (w - w3)] min_diff = min(min_diff, max(s) - min(s)) w1 = w // 2 w...
p03713
def main(): a, b = list(map(int, input().split())) if (a % 3 ==0) | (b % 3 ==0): ans = 0 else: anss = [] s1 = (b // 3 + 1) * a s2 = (b - (b // 3 + 1)) * (a // 2) s3 = a * b - s1 - s2 anss.append(max(s1, s2, s3) - min(s1, s2, s3)) s1 = (b //...
a, b = list(map(int, input().split())) if (a % 3 ==0) | (b % 3 ==0): ans = 0 else: anss = [] s1 = (b // 3 + 1) * a s2 = (b - (b // 3 + 1)) * (a // 2) s3 = a * b - s1 - s2 anss.append(max(s1, s2, s3) - min(s1, s2, s3)) s1 = (b // 3) * a s2 = (b - (b // 3)) * (a // 2) s3 =...
p03713
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: if h > w: h, w = w, h ans = h for w1 in range(w//3-2, w//3+3): s1 = w1 * h w2 = w-w1 for h1 in range(h//2 + 1): s2 = w2 * h1 s3 = w2 * (h-h1) ...
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: ans = min(w, h) for w1 in range(w//3, w//3+3): s1 = w1 * h w2 = w-w1 for h1 in range(h//2, h//2+2): s2 = w2 * h1 s3 = w2 * (h-h1) ans = min(ans, max(s1,...
p03713
# #    ⋀_⋀  #   (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input=sys.stdin.readline from math import floor,ceil,sqrt,factorial,log #log2ないyp from heapq import heappop, heappush, heappushpop from collections import ...
# #    ⋀_⋀  #   (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input=sys.stdin.readline from math import floor,ceil,sqrt,factorial,log #log2ないyp from heapq import heappop, heappush, heappushpop from collections import ...
p03713
h,w = list(map(int,input().split())) res = float('inf') # H for i in range(1,h): s_h = [i * w] s_w = [i * w] # のこりは(h-i)*w # H s_h.append(((h-i)//2) * w) s_h.append(((h-i)-(h-i)//2) * w) if 0 in ((h-i)//2,((h-i)-(h-i)//2),w): s_h.append(float('inf')) #print((h-i)//2...
h,w=list(map(int,input().split())) r=1e9 f=lambda x:max(x)-min(x) for _ in 'aa': for i in range(1,h): p=[j if j else -1e9for j in[i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]] q=[j if j else -1e9for j in[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]] r=min(min(r,f(p)),f(q)) h,w=w,h print(r)
p03713
h,w=list(map(int,input().split())) r=1e9 f=lambda x:max(x)-min(x) for _ in 'aa': for i in range(1,h): p=[j if j else -1e9for j in[i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]] q=[j if j else -1e9for j in[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]] r=min(min(r,f(p)),f(q)) h,w=w,h print(r)
h,w=list(map(int,input().split())) r=1e9 f=lambda x:max(x)-min(x) for _ in 'aa': for i in range(1,h):r=min(min(r,f([j if j else -1e9for j in[i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]])),f([j if j else -1e9for j in[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]])) h,w=w,h print(r)
p03713
h,w=list(map(int,input().split())) r=1e9 f=lambda x:max(x)-min(x) for _ in 'aa': for i in range(1,h):r=min(min(r,f([j if j else -1e9for j in[i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]])),f([j if j else -1e9for j in[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]])) h,w=w,h print(r)
h,w=list(map(int,input().split()));f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([j if j else -1e9for j in[i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]]),f([j if j else -1e9for j in[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]]))for i in range(1,h)]);print((min(g(h,w),g(w,h))))
p03713
h,w=list(map(int,input().split()));f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([j if j else -1e9for j in[i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]]),f([j if j else -1e9for j in[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]]))for i in range(1,h)]);print((min(g(h,w),g(w,h))))
h,w=list(map(int,input().split()));f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]),f([i*w,(h-i)*(w//2),(h-i)*(w-w//2)]))for i in range(1,h)]);print((min(g(h,w),g(w,h))))
p03713
h,w=list(map(int,input().split()));f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([i*w,((h-i)//2)*w,((h-i)-(h-i)//2)*w]),f([i*w,(h-i)*(w//2),(h-i)*(w-w//2)]))for i in range(1,h)]);print((min(g(h,w),g(w,h))))
h,w=list(map(int,input().split()));f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([i,((h-i)//2),(h-i-(h-i)//2)])*w,f([i*w,(h-i)*(w//2),(h-i)*(w-w//2)]))for i in range(1,h)]);print((min(g(h,w),g(w,h))))
p03713
h,w=list(map(int,input().split()));f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([i,((h-i)//2),(h-i-(h-i)//2)])*w,f([i*w,(h-i)*(w//2),(h-i)*(w-w//2)]))for i in range(1,h)]);print((min(g(h,w),g(w,h))))
h,w = list(map(int,input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) exit() res = 10**1000 for _ in range(2): a,b = h // 3 + 1, h // 3 + 1 c = h - a - b if c < 0: h,w = w,h continue mx = max(a,b,c) mn = min(a,b,c) res = min(res, mx*w-mn*w) h,...
p03713
H, W = list(map(int, input().split())) if (H%3) * (W%3) == 0: print((0)) quit() ans = H * W w1 = W // 2 w2 = W - w1 S1 = (H - 1) * w1; T1 = W * ((H-1)//2) S2 = (H - 1) * w2; T2 = W * (H-1) - T1 S3 = W h = H - 1 for i in range(H-1): diff1 = max(S1, S2, S3) - min(S1, S2, S3) diff2 = max(T1, T2, S3)...
H, W = list(map(int, input().split())) if (H%3) * (W%3) == 0: print((0)) quit() ans = min(H, W) w1 = W // 2 w2 = W - w1 S1 = (H - 1) * w1 S2 = (H - 1) * w2 S3 = W for i in range(H-1): diff = max(S1, S2, S3) - min(S1, S2, S3) ans = min(ans, diff) S1 -= w1; S2 -= w2; S3 += W h1 = H // 2 h2 = ...
p03713
def func(H,W): area = H * W half_H = int(H/2) half_W = int(W/2) res = 10000000 # よこ # T for x in range(1,W): S1 = H * x S2_T = (W - x) * half_H S3_T = area - S1 - S2_T S2_2 = H * int((W - x)/2) S3_2 = area - S1 - S...
def func(H,W): if H % 3 == 0: return 0 H_3 = int(H/3) S1 = H_3 * W S2 = (H - H_3) * int(W/2) S3 = H * W - S1 - S2 res1 = max(S1, S2, S3) - min(S1, S2, S3) H_3_1 = int(H/3) + 1 S1 = H_3_1 * W S2 = (H - H_3_1) * int(W/2) S3 = H * W - S1 - S2 ...
p03713
def c_ChocolateBar(H, W): ans = float('inf') # for文の順は解説における矩形の分け方の図の左からの順と一致 for h in range(1, H): S_A = h * W hh = (H - h) // 2 S_B = hh * W S_C = (H - h - hh) * W ans = min(ans, max([S_A, S_B, S_C]) - min([S_A, S_B, S_C])) for h in range(1, H): ...
def c_chocolate_bar(H, W): # 変数a, b, cはeditorialの図のA, B, Cに対応する ans = float('inf') for _ in range(2): for i in range(1, H): a = i * W # 領域Aの面積 # 横に2つ切り込みを入れる(図の左から1番目の分け方) b = ((H - i) // 2) * W c = ((H - i + 1) // 2) * W ans = ...
p03713
import sys readline = sys.stdin.readline from math import floor, ceil def main(): H, W = list(map(int, readline().rstrip().split())) ans = H * W if H >= 3: ans = min(ans, abs(W*(H//3) - W*(H-H//3*2))) if W >= 3: ans = min(ans, abs(H*(W//3) - H*(W-W//3*2))) # 縦にスライス ...
import sys readline = sys.stdin.readline from math import floor, ceil from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN def round(f, r=0): return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP) def main(): H, W = list(map(int, readline().rstrip().split())) ans = H * W ...
p03713
import sys readline = sys.stdin.readline from math import floor, ceil from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN def round(f, r=0): return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP) def main(): H, W = list(map(int, readline().rstrip().split())) ans = H * W ...
import sys readline = sys.stdin.readline from math import floor, ceil from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN def round(f, r=0): return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP) def main(): H, W = list(map(int, readline().rstrip().split())) ans = H * W...
p03713
h,w=list(map(int,input().split())) if h%3==0 or w%3==0: print((0)) else: x=[] for i in range(1,w): sub=[] sub.append([h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]) sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)]) sub.append([h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]) ...
h,w=list(map(int,input().split())) if h%3==0 or w%3==0: print((0)) else: x=[] for i in range(1,w): sub=[] sub.append([h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]) #sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)]) sub.append([h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]) ...
p03713
h,w=list(map(int,input().split())) if h%3==0 or w%3==0: print((0)) else: x=[] for i in range(1,w): sub=[] sub.append([h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]) #sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)]) sub.append([h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]) ...
h,w=list(map(int,input().split())) x=[] for i in range(1,w): x1=[h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)] x1.sort() x.append(x1[-1]-x1[0]) x2=[h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)] x2.sort() x.append(x2[-1]-x2[0]) for i in range(1,h): x1=[w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)] ...
p03713
from collections import defaultdict import sys input = sys.stdin.readline N = int(eval(input())) S = [input().rstrip() for _ in range(N)] S.sort(key=lambda s: -len(s)) dic = [defaultdict(int) for _ in range(26)] cnt1 = [0] * 26 ans = 0 for s in S: if len(s) == 1: ans += cnt1[ord(s[0]) - ord('a'...
import sys input = sys.stdin.readline base = 1999849216943526259 mod = (1 << 61) - 1 N = int(eval(input())) S = [input().rstrip()[::-1] for _ in range(N)] S.sort(key=lambda s: -len(s)) cnt = {} ans = 0 one = [0] * 26 for s in S: n = len(s) if n == 1: ans += one[ord(s[0]) - ord('a')] ...
p02589
import sys input = sys.stdin.readline base = 1000 mod = 10**23 + 117 N = int(eval(input())) S = [input().rstrip()[::-1] for _ in range(N)] S.sort(key=lambda s: -len(s)) cnt = {} ans = 0 one = [0] * 26 for s in S: n = len(s) if n == 1: ans += one[ord(s[0]) - ord('a')] continue ...
import sys input = sys.stdin.readline base = 30 mod = 10**17 + 3 N = int(eval(input())) S = [input().rstrip()[::-1] for _ in range(N)] S.sort(key=lambda s: -len(s)) cnt = {} ans = 0 one = [0] * 26 for s in S: n = len(s) if n == 1: ans += one[ord(s[0]) - ord('a')] continue ...
p02589
import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) def solve(): ordA = ord('a') N = int(eval(input())) Sss = [input().rstrip() for _ in range(N)] Sss.sort(key=lambda x: len(x)) fsss = [] Ass = [] for Ss in Sss: As = [ord(S)-ordA for S in Ss[::-1]] ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) def solve(): ordA = ord('a') N = int(eval(input())) Ass = [] for _ in range(N): Ss = input().rstrip() As = [ord(S)-ordA for S in Ss[::-1]] Ass.append(As) Ass.sort(key=lambda x: len(x)) ...
p02589
import sys sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python import math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from co...
import sys sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python import math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from co...
p02589
# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) # from collections import defaultdict ALPHABET_SIZE = 26 def getlist(): return list(map(int, input().split())) class Node(object): def __init__(self, char, ALPHABET_SIZE): self.char = char self.children = [-1] * ALPHABET_S...
# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) # from collections import defaultdict ALPHABET_SIZE = 26 def getlist(): return list(map(int, input().split())) class Node(object): def __init__(self, char): self.char = char self.children = {} self.flag = [0] * ALPHABET...
p02589
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): MOD = 2 ** 61 - 1 NI = lambda : int(sys.stdin.readline()) SI = lambda : sys.stdin.readline().rstrip() N = NI() cnt = collections.defaultdict(int) ans = 0 S = [SI() for _ in range(N)] for s in S: ...
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): MOD = 2 ** 61 - 1 NI = lambda : int(sys.stdin.readline()) SI = lambda : sys.stdin.readline().rstrip() N = NI() cnt = collections.defaultdict(int) ans = 0 S = [SI() for _ in range(N)] for s in S: ...
p02589
import sys input = sys.stdin.readline N = int(eval(input())) S = [input().rstrip()[::-1] for i in range(N)] S.sort(key=lambda x:-len(x)) P = 2**61 - 1 from collections import defaultdict,Counter D = defaultdict(lambda: Counter()) ans = 0 for s in S: sets = [set()] for c in s[::-1]: i =...
import sys input = sys.stdin.readline N = int(eval(input())) S = [input().rstrip()[::-1] for i in range(N)] S.sort(key=len) P = 2**61 - 1 from collections import defaultdict D = defaultdict(lambda: [0]*26) ans = 0 for s in S: l = ord(s[-1]) - ord('a') a = 0 tmp = [0] * 26 for c in s[:...
p02589
import sys input = sys.stdin.readline class RollingHash: def __init__(self, string): self.n = len(string) self.BASE = 1234 self.MOD = (1 << 61) - 1 self.hash = [0] * (self.n + 1) self.pow = [1] * (self.n + 1) for i, char in enumerate(string): ...
import sys input = sys.stdin.readline class RollingHash: def __init__(self, string): self.n = len(string) self.BASE = 1234 self.MOD = (1 << 45) - 1 self.hash = [0] * (self.n + 1) self.pow = [1] * (self.n + 1) for i, char in enumerate(string): ...
p02589
import sys input = sys.stdin.readline class RollingHash: def __init__(self, string): self.n = len(string) self.BASE = 1234 self.MOD = (1 << 61) - 1 self.hash = [0] * (self.n + 1) self.pow = [1] * (self.n + 1) for i, char in enumerate(string): ...
import sys input = sys.stdin.readline class RollingHash: def __init__(self, string): self.n = len(string) self.BASE = 1234 self.MOD = 92709568269121 self.hash = [0] * (self.n + 1) self.pow = [1] * (self.n + 1) for i, char in enumerate(string): ...
p02589
import sys input = sys.stdin.readline class RollingHash: def __init__(self, string): self.n = len(string) self.BASE = 1234 self.MASK30 = (1 << 30) - 1 self.MASK31 = (1 << 31) - 1 self.MASK61 = (1 << 61) - 1 self.MOD = self.MASK61 self.hash = [0] ...
import sys input = sys.stdin.readline class RollingHash: """文字列stringsの部分文字列のハッシュを構築する。O(N)""" def __init__(self, string): self.n = len(string) self.BASE = 1234 self.MASK30 = (1 << 30) - 1 self.MASK31 = (1 << 31) - 1 self.MASK61 = (1 << 61) - 1 self....
p02589
import sys input = lambda: sys.stdin.readline().rstrip() P = 10 ** 40 + 121 N = int(eval(input())) X = sorted([input()[::-1] for _ in range(N)], key = len) D = {} ans = 0 for x in X: L = [0] * 26 T, a = x[:-1], ord(x[-1]) - 97 h = 0 for t in T: if h in D: for i in rang...
import sys input = lambda: sys.stdin.readline().rstrip() m = 2 ** 150 - 1 N = int(eval(input())) X = sorted([input()[::-1] for _ in range(N)], key = len) D = {} ans = 0 for x in X: L = [0] * 26 T, a = x[:-1], ord(x[-1]) - 97 h = 0 for t in T: if h in D: for i in range(...
p02589
mod1 = 1000000007 mod2 = 1000000009 base1 = 2009 base2 = 1007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(eval(input())) S = [] for _ in range(N): s = input().rstrip('\n') S.append(s[::-1]) S.sort(key=lambda s: len(s), reverse=True)...
mod1 = 1000000007 mod2 = 1000000009 base1 = 2009 base2 = 1007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(eval(input())) S = [] for _ in range(N): s = input().rstrip('\n') S.append(s[::-1]) S.sort(key=lambda s: len(s), reverse=True)...
p02589
import sys;input=sys.stdin.readline from collections import defaultdict N, = list(map(int, input().split())) S = [] for _ in range(N): s = input().strip() S.append(s) S.sort(key=lambda x:len(x)) D = defaultdict(set) R = 0 for s in S: l = len(s) d = defaultdict(int) for c in D[""]: ...
import sys;input=sys.stdin.readline N, = list(map(int, input().split())) S = [] for _ in range(N): s = input().strip() S.append(s) S.sort(key=lambda x:len(x)) D = dict() dd = set() R = 0 for s in S: l = len(s) d = [0]*26 for c in dd: d[c] += 1 mm = 0 for i in range(l-...
p02589
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 0 1 2 1 2 1 1 3 3 output: 5 """ import sys from collections import deque from math import isinf def generate_adj_table(v_table): for each in v_table: source, target, cost = list(map(int, each)) init_adj_table[sourc...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 0 1 2 1 2 1 1 3 3 output: 5 """ import sys from math import isinf from collections import deque def generate_adj_table(v_table, init_adj_table): for each in v_table: source, target, cost = list(map(int, each)) init...
p02371
# Acceptance of input import sys f_i = sys.stdin n = int(f_i.readline()) edges = [[None] * n for i in range(n)] for l_i in f_i: s, t, w = list(map(int, l_i.split())) edges[s][t] = w edges[t][s] = w # dfs tree walk 1 import collections path = collections.deque() path.append(0) ...
# Acceptance of input import sys f_i = sys.stdin n = int(f_i.readline()) edges = [[] for i in range(n)] for l_i in f_i: s, t, w = list(map(int, l_i.split())) edges[s].append((t, w)) edges[t].append((s, w)) # Tree Walk function import collections def tree_walk(start, switch = 0): ...
p02371
from heapq import heappop, heappush INF = 10 ** 20 n = int(eval(input())) edges = [[] for _ in range(n)] for _ in range(n - 1): s, t, w = list(map(int, input().split())) edges[s].append((w, t)) edges[t].append((w, s)) cost = [INF] * n que = [(0, 0)] cost[0] = 0 while que: acc, num = heappop(...
from heapq import heappop, heappush INF = 10 ** 20 def main(): n = int(eval(input())) edges = [[] for _ in range(n)] for _ in range(n - 1): s, t, w = list(map(int, input().split())) edges[s].append((w, t)) edges[t].append((w, s)) def func(start): cost = [INF] * n que = [(0...
p02371
import sys readline = sys.stdin.readline from collections import deque from math import isinf INF = float("inf") sys.setrecursionlimit(200000) n = int(readline()) G = [[] for _ in range(n)] D = [INF] * n for _ in [0] * (n - 1): s, t, w = list(map(int, readline().split())) G[s].append([t, w]) G[t...
import sys readline = sys.stdin.readline def dfs(root): visited = [False] * n queue = [(0, root)] longest = (-1, -1) while queue: total_weight, node = queue.pop() if visited[node]: continue visited[node] = True longest = max(longest, (total_weight, ...
p02371
# -*- coding: utf-8 -*- from collections import deque if __name__ == '__main__': n = int(eval(input())) A = [[float("inf") for j in range(n)] for i in range(n)] for i in range(n - 1): A[i][i] = 0 s, t, d = list(map(int, input().split())) A[s][t] = d A[t][s]...
# -*- coding: utf-8 -*- from collections import deque if __name__ == '__main__': n = int(eval(input())) E = [set() for _ in range(n)] for _ in range(n - 1): s, t, d = list(map(int, input().split())) E[s].add((t, d)) E[t].add((s, d)) Q = deque() def bfs(s...
p02371
while True: a=[int(num)for num in input().split(' ')] n=a[0] if n==0:break hanafuda=[i+1 for i in range(n)] for i in range(a[1]): b=[int(num)for num in input().split(' ')] for j in range(b[1]):hanafuda.append(hanafuda.pop(n-(b[0]+b[1])+1)) print((hanafuda.pop()))
while True: n,r=[int(s)for s in input().split(" ")] if n==r==0:break ops=[[int(s)for s in input().split(" ")]for i in range(r)] cd=[n-i for i in range(n)] for op in ops: p,c=op l=cd[p-1:p+c-1] del cd[p-1:p+c-1] cd=l+cd print((cd[0]))
p00710
cond = [int(n) for n in input().split(" ")] while True: case = [] cards = [n for n in range(1,cond[0] + 1)] cards.sort(reverse = True) for c in range(cond[1]): case = [int(n) for n in input().split(" ")] case[0] -= 1 #print(cards[case[0]:case[0]+case[1]],cards[case[1]:c...
cards,trial = (int(n) for n in input().split(" ")) while True: cards = list(reversed([int(n) for n in range(1,(cards)+1)])) for n in range(trial): num,change = (int(n) for n in input().split(" ")) num -= 1 disp = cards[num:num+change] cards[change:change+num] = cards[:num]...
p00710
import sys from collections import Counter from collections import deque import heapq import math import fractions import bisect import itertools def input(): return sys.stdin.readline().strip() def mp(): return list(map(int,input().split())) def lmp(): return list(map(int,input().split())) a,b=mp() print...
a,b=list(map(int,input().split())) print((a*b))
p02657
num = [int(i) for i in input().split() ] print((num[0] * num[1]))
A,B = [int(i) for i in input().split()] print((A*B))
p02657
a,b = list(map(int, input().split())) ans = a * b print(ans)
import math a,b = input().split() a = int(a) b = float(b) print((int(math.floor(a * b))))
p02657
s = list(map(int, input().split())) print((s[0]*s[1]))
s = list(map(int, input().split())) S = list(s) print((S[0]*S[1]))
p02657
import sys def input(): return sys.stdin.readline().strip() def resolve(): a,b=list(map(int, input().split())) print((a*b)) resolve()
import sys def input(): return sys.stdin.readline().strip() def resolve(): a,b=list(map(float, input().split())) b100=b*100 print((int(a*b100/100))) resolve()
p02657
def iput(): return int(eval(input())) def mput(): return list(map(int, input().split())) def lput(): return list(map(int, input().split())) def solve(): a, b = mput() print((a*b)) return 0 if __name__ == "__main__": solve()
import math def solve(): a, b = input().split() a = int(a) b = float(b) print((int(a*b))) return 0 if __name__ == "__main__": solve()
p02657
# 169A # 値 A × B を整数として出力せよ。 # 1.標準入力をプログラムで扱えるように受け取る a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って、適切に処理(計算)する answer = a * b # 3.計算結果を出力する print(answer)
# A × B を求めてください。 # 制約 # 1 ≤ A ≤ 100 # 1 ≤ B ≤ 100 # 入力は全て整数である。 # 標準入力からA、Bを取得する a, b = list(map(int, input().split())) # A x B を計算し、出力する result = a * b print(result)
p02657
A, B = list(map(int, input().split())) C = A * B print(C)
A, B = input().split() A = int(A) B = float(B) B = int(B * 1000) C = A * B C //= 1000 print(C)
p02657
a,b=list(map(int,input().split())) print((a*b))
def resolve(): a,b=list(map(int,input().split())) print((a*b)) resolve()
p02657
# 169a # A×Bを整数として出力せよ。 # 1. 入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2. 受け取った入力値を使って、適切に処理(計算)すること answer = a * b # 3. 計算した結果を出力すること print(answer)
A, B = list(map(int, input().split())) answer = A * B print(answer)
p02657
def LI():return list(map(int,input().split())) def yes():return print("Yes") def no():return print("No") from collections import deque, defaultdict, Counter from heapq import heappop, heappush # import math # pi=math.pi # print(pi) # yes() # no() # n=int(input()) # s=input() a,b=LI() print(a*b)
print((eval(input().replace(" ","*"))))
p02657
lis = list(map(int,input().split(" "))) print((lis[0] * lis[1]))
N,M = list(map(int,input().split())) print((N*M))
p02657
a, b = list(map(int, input().split())) print((a*b))
#!/usr/bin/env python3 import sys def solve(A: int, B: int): print((A*B)) return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): f...
p02657
# -*- coding: utf-8 -*- """ Created on Sun May 31 20:59:05 2020 @author: NEC-PCuser """ A, B = list(map(int, input().split())) print((A * B))
A, B = list(map(int, input().split())) print((str(A * B)))
p02657
#169A #A*Bを整数として出力せよ。 #1.入力を受け取ること a,b=list(map(int,input().split())) # print(a, b) #2.受け取った入力値を使って、適切に処理すること answer=a*b #3.計算した結果を出力すること print(answer)
a, b = list(map(int, input().split())) print((a*b))
p02657
A, B = list(map(int, input().split())) print((A*B))
A, B = list(map(float, (input().split()))) print((round(A*B)))
p02657
A,B = list(map(int,input().split(" "))) print((A*B))
if __name__ == "__main__": A,B = list(map(float,input().split(" "))) print((int((int(A)*(int((B)*100)))/100)))
p02657
A,B = list(map(int,input().split())) print((A * B))
A,B = list(map(float,input().split())) A = int(A) print((int(A * B)))
p02657
# 169A # A × B を整数として出力せよ # 1.入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って、適切に処理(計算)すること answer = a * b; # 3.計算した結果を出力すること print(answer)
a, b = list(map(int, input().split())) print((a * b))
p02657
#169A #A*Bを整数として出力せよ #1.入力をプログラムで扱えるように受け取ること a,b = list(map(int, input().split())) #2.受け取った入力値を使って適切に処理(計算)すること print((a * b))
#aとbをスペースを空けて入力 a,b = list(map(int,input().split())) print((a*b))
p02657
#!/usr/bin/env python3 # from typing import * import sys import math input = sys.stdin.readline sys.setrecursionlimit(10**6) def solve(A, B): print((A*B)) def main(): A, B = list(map(int, input().split())) solve(A, B) if __name__ == '__main__': main() ''' cd ~/Desktop/Programming...
#!/usr/bin/env python3 # from typing import * import sys import math input = sys.stdin.readline sys.setrecursionlimit(10**6) def solve(A, B): print((A*B)) def main(): A, B = list(map(int, input().split())) solve(A, B) if __name__ == '__main__': main() ''' cd ~/Deskt...
p02657
# 169A # A × B を整数として出力せよ # 1. 入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2. 受け取った入力値を使って、適切に処理(計算)すること answer = a * b # 3. 計算した結果を出力すること print(answer)
a, b = list(map(int, input().split())) answer = a * b print(answer)
p02657
A,B = list(map(int, input().split())) print((A*B))
A,B = input().split() import math A=int(A) B=float(B) print((math.floor(A*B)))
p02657
# Problem A - Multiplication 1 # input a, b = list(map(int, input().split())) # output print((a * b))
# Problem a - Multiplication 1 # input A, B = list(map(int, input().split())) # initialization ans = A * B # output print(ans)
p02657
a,b = list(map(int,input().split())) c = a*b print(c)
a,b = list(map(float,input().split())) A = int(a) B = 100*b c = int(A*B//100) print(c)
p02657
#169A #A×Bを整数として出力せよ。 #やること①入力を受け取ること a, b = list(map(int, input().split())) # print(a, b) #やること②受け取った値を使って、適切に処理する answer = a * b #やること③計算した結果を出力すること print(answer)
A, B = list(map(int, input().split())) print((A * B))
p02657
# 入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 受け取った入力値を使い、適切に処理(計算)する anser = a * b # 計算した結果を出力する print(anser)
a, b = list(map(int, input().split())) anser = a * b print(anser)
p02657
a, b = list(map(int, input().split())) anser = a * b print(anser)
# 入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 受け取った入力値を使い、適切に処理(計算)する answer = a * b # 計算した結果を出力する print(answer)
p02657
# 169A # A × B を整数として出力せよ。 # 1. 入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2. 受け取った入力値を使って、適切に処理(計算)すること answer = a * b # 3. 計算した結果を出力すること print(answer)
# 入力 a, b = list(map(int, input().split())) # 計算 answer = a * b # 出力 print(answer)
p02657
A, B = list(map(int, input().split())) print((A * B))
print((eval(input().replace(" ","*"))))
p02657
a, b = list(map(int, input().split())) answer = a * b print(answer)
A, B = list(map(int,input().split())) print((A * B))
p02657
from sys import stdin def main(): read = stdin.readline A, B = list(map(int,read().split(" "))) print((A*B)) if __name__ == "__main__": main()
from sys import stdin def main(): read = stdin.readline A,B = list(read().split(" ")) B = int(B)*100 c = int(A) * B print((c//100)) if __name__ == "__main__": main()
p02657
# 169A # A × B を整数として出力せよ # 1. 入力をプログラミングで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2. 受け取った入力値を使って、適切に処理(計算)すること answer = a * b # 3.計算した結果を出力すること print(answer)
# 169A # A × Bを求めてください。 A, B = list(map(int, input().split())) # print(A, B) answer = A * B print(answer)
p02657
a, b = list(map(int, input().split())) answer = a * b print(answer)
# A-Multiplication 1 # A×Bを求める # 1≤A≤100 # 1≤B≤100 a, b = list(map(int, input().split())) answer = a * b print(answer)
p02657
N, M = list(map(int, input().split())) print((N*M))
a,b = list(map(float,input().split())) a = int(a) b = int(b*1000) print((int(a*b)//1000))
p02657
a, b = list(map(int, input().split())) answer = a * b print(answer)
a, b = list(map (int, input().split())) print((a * b))
p02657
#169A a, b = list(map(int, input().split())) # print(a) # print(b) answer=a*b print(answer)
A,B=input().split() A=int(A) B=int(B) print((A*B))
p02657
a,b=list(map(int,input().split())) print((a*b))
a,b=input().split() a=int(a) b=int(float(b)*100) print((int(a*b/100)))
p02657
a, b = list(map(int, input().split())) answer = a * b print(answer)
a,b = list(map(int,input().split())) print((a * b))
p02657
import math from collections import deque from collections import defaultdict import time #自作関数群 def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() def factorization(n): res =...
a,b = list(map(int, input().split())) print((a*b))
p02657
import math from collections import deque from collections import defaultdict import itertools as it #自作関数群 def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() def factorizatio...
a,b = list(map(int,input().split())) #print(a+b) print((a*b))
p02657
a,b = list(map(int,input().split())) #print(a+b) print((a*b))
a,b = list(map(int,input().split())) print((a*b))
p02657
""" ~~ Author : Bhaskar ~~ Dated : 31~05~2020 """ import sys from bisect import * from math import floor,sqrt,ceil,factorial as F,gcd,pi from itertools import chain,combinations,permutations,accumulate from collections import Counter,defaultdict,OrderedDict,deque from array import array INT_MAX = sys.maxsiz...
""" ~~ Author : Bhaskar ~~ Dated : 13~06~2020 """ import sys from bisect import * from math import floor, sqrt, ceil, factorial as F, gcd, pi from itertools import chain, combinations, permutations, accumulate from collections import Counter, defaultdict, OrderedDict, deque INT_MAX = sys.maxsize INT_MIN =...
p02657
A, B = list(map(int, input().split())) print((A * B))
import math A, B = list(map(float, input().split())) B *= 100 mul = math.floor(A * B) print((int(mul/100)))
p02657
# 1.入力を受け取ること # スペース区切りの入力を整数として受け取れる「2 5」 -> 「a=2, B=5」となる a, b = list(map(int, input().split())) # print(a) # print(b) # 2.受け取った結果を使って目的の計算をすること answer = a * b # 3.出力すること print(answer)
A, B = list(map(int,input().split())) print((A * B))
p02657
a, b = list(map(int, input().split())) print((a * b))
a, b = list(map(str, input().split())) A = int(a) B = round(float(b) * 100) print((A * B // 100))
p02657
def resolve(): A, B = list(map(int, input().split())) print((A*B)) resolve()
A, B = list(map(int, input().split())) print((A*B))
p02657
import sys input = sys.stdin.readline a, b = [int(x) for x in input().split()] print((a*b))
import sys input = lambda: sys.stdin.readline().rstrip() a, b = list(map(int, input().split())) print((a*b))
p02657
A, B = list(map(int, input().split())) print((A*B))
A, B = list(map(float, input().split())) mod = 10000 a = int(A // mod) a2 = int(A % mod) B = int(100 * B) ans = a * B * mod + a2 * B print((ans // 100))
p02657
A,B = list(map(int,input().split())) print((A*B))
A,B = list(map(float,input().split())) tmp = A*B*100 print((int(tmp/100)))
p02657