Dataset Viewer
Auto-converted to Parquet Duplicate
code1
stringlengths
17
427k
code2
stringlengths
17
427k
similar
int64
0
1
pair_id
int64
2
181,637B
question_pair_id
float64
3.7M
180,677B
code1_group
int64
1
299
code2_group
int64
1
299
n, m, l = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] b = [list(map(int, input().split())) for _ in range(m)] c = [[0 for i in range(l)] for j in range(n)] for i in range(n): for j in range(l): for k in range(m): c[i][j] += a[i][k] * b[k][j] for i in range(...
def main(): N, D = map(int, input().split()) ans = 0 for _ in range(N): x, y = map(int, input().split()) if x*x + y* y <= D*D: ans += 1 return ans if __name__ == '__main__': print(main())
0
null
3,686,761,737,148
60
96
import math alpha = [] while True: n = float(raw_input()) if n == 0: break nums_str = raw_input().split() nums = [] for s in nums_str: nums.append(float(s)) ave = sum(nums)/n n_sum = 0.0 for num in nums: n_sum += (num-ave)**2 alpha.append(n_sum/n) for a in alp...
import math def main(): while True: n = int(input()) if n == 0: break nums = list(map(int, input().split())) mean = sum(nums) / n var = sum((s - mean) ** 2 for s in nums) / n sd = math.sqrt(var) print(sd) if __name__ == "__main__": main()
1
186,722,358,146
null
31
31
H = int(input()) def attack(h): if h == 1: return 0 r = 2 h //= 2 ans = 2 while h > 1: h //= 2 r *= 2 ans += r return ans print(1 + attack(H))
h = int(input()) ans = 0 n_enemy = 1 while h > 1: h //= 2 ans += n_enemy n_enemy *= 2 if h == 1: ans += n_enemy print(ans)
1
79,884,355,433,062
null
228
228
def lcm(a, b): from fractions import gcd return a // gcd(a, b) * b def main(): _ = int(input()) a = list(map(int, input().split())) x = 1 for e in a: x = lcm(x, e) ans = 0 for e in a: ans += x // e print(ans % int(1e9 + 7)) main()
suits = ['S', 'H', 'C', 'D'] table = [[False] * 14 for i in range(4)] N = int(input()) for _i in range(N): mark, num = input().split() num = int(num) if mark == 'S': table[0][num] = True if mark == 'H': table[1][num] = True if mark == 'C': table[2][num] = True if mark =...
0
null
44,165,090,264,310
235
54
a1, a2, a3 = map(int, input().split(" ")) tmp = a1 + a2 + a3 if tmp >= 22: print("bust") else: print("win")
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collection...
1
118,802,437,548,900
null
260
260
import sys import fractions input = sys.stdin.readline mod = 10 ** 9 + 7 N = int(input().strip()) A = list(map(int, input().strip().split(" "))) lcm = 1 for a in A: lcm = a // fractions.gcd(a, lcm) * lcm print(sum([lcm // a for a in A]) % mod)
def gcd (a, b): while b != 0: a, b = b, a%b return a def lcm(a, b,mod): return a*b//gcd(a,b) N = int(input()) A = list(map(int,input().split())) mod = 10**9+7 b = 1 for i in range(N): a = A[i] b = lcm(a,b,mod) ans = 0 for a in A: ans += b//a print(ans%mod)
1
87,563,487,084,220
null
235
235
n = int(input()) xlist = list(map(int,input().split())) sum = 0 for i in range(n): for j in range(i+1,n): sum+=xlist[i]*xlist[j] print(sum)
import sys import time import random import math from collections import deque import heapq import itertools from decimal import Decimal import bisect from operator import itemgetter MAX_INT = int(10e18) MIN_INT = -MAX_INT mod = 1000000000+7 sys.setrecursionlimit(1000000) def IL(): return list(map(int,input().split()))...
0
null
89,068,863,544,192
292
113
INF=1000000000+7 s=int(input()) dp=[0]*(2000+1); dp[0]=dp[1]=dp[2]=0 dp[3]=1 for i in range(4,s+1): temp=1 for j in range(3,i-2): temp+=dp[j]%INF; temp%=INF; dp[i]=temp print(dp[s])
from sys import stdin,stdout l,r,d=list(map(int,stdin.readline().strip().split())) c=0 if l%d==0 and r%d==0: stdout.write(str(int(r/d)-int(l/d)+1)+'\n') else: stdout.write(str(int(r/d)-int(l/d))+'\n')
0
null
5,409,983,469,248
79
104
ans = [] while True: arr = map(int, raw_input().split()) if arr[0] == 0 and arr[1] == 0: break else: arr.sort() ans.append(arr) for x in ans: print(" ".join(map(str, x)))
while 1: x,y=map(int,raw_input().split()) if x==y==0: exit() else: print min(x,y),max(x,y)
1
516,632,768,038
null
43
43
N, K = map(int, input().split()) LR = [tuple(map(int, input().split())) for _ in range(K)] MOD = 998244353 class Mint: __slots__ = ('value') def __init__(self, value=0): self.value = value % MOD if self.value < 0: self.value += MOD @staticmethod def get_value(x): return x.value if isi...
n, k = map(int, input().split()) lr = [list(map(int, input().split())) for _ in range(k)] mod = 998244353 dp = [0] * n dp[0] = 1 acc = 0 for i in range(1, n): # 例4のi=13, lr=[[5, 8], [1, 3], [10, 15]]の場合を想像すると書きやすい for li, ri in lr: if i - li >= 0: acc += dp[i - li] acc %= mod ...
1
2,682,864,198,224
null
74
74
s=input() print(s+'es' if s[-1]=='s' else s+'s')
days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] S = input() for i in range(7): if S == days[i]: print(7 - i) exit()
0
null
67,711,913,267,040
71
270
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n,m,k = map(int, readline().split()) a = list(map(int, readline().split())) b = list(map(int, readline().split())) sa = [0]*(n+1) sb = [0]*(m+1) for i in range(n): sa[i+1] = sa[i]+a[i] for i in ran...
def main(): N, X, Y = (int(i) for i in input().split()) cnt = [0]*N for i in range(1, N+1): for j in range(i+1, N+1): d = min(abs(i-j), abs(i-X)+1+abs(j-Y), abs(i-X)+abs(X-Y)+abs(j-Y)) cnt[d] += 1 for d in cnt[1:]: print(d) if __name__ == '__main__': main()
0
null
27,528,250,529,792
117
187
arr = map(int,raw_input().split()) if arr[0] < arr[1] and arr[1] < arr[2] : print "Yes" else : print "No"
# -*- coding: utf-8 -*- import sys X = int(input().strip()) #----- calc = {} for i in range(-118,120): calc[i] = i**5 for a in range(-118,120): for b in range(-118,120): if (calc[a] - calc[b]) == X: print(a,b) sys.exit()
0
null
12,884,101,466,308
39
156
N = int(input()) X = str(input()) F = [0] * N def calc_f(n:int)->int: global F x = n res = 0 while 0 < x: if F[x] != 0: res += F[x] break pop = bin(n).count('1') x %= pop res += 1 F[n] = res # 前処理 N以下のF値テーブル for i in range(1, N): calc_f(i...
#!python3 import sys iim = lambda: map(int, sys.stdin.readline().rstrip().split()) from functools import lru_cache @lru_cache(maxsize=2*10**5) def f2(x): if x == 0: return 0 y = bin(x).count("1") return 1 + f2(x % y) def resolve(): N = int(input()) S = input() cnt0 = S.count("1") if cnt...
1
8,176,700,382,240
null
107
107
import sys N , K = map(int,input().split()) A = list(map(int,input().split())) for i in range(K, N): if A[i-K] < A[i]: print("Yes") else: print("No")
printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 def ddprint(x): if DBG: print(x) n = inn() a = inl() if n<=3: print(m...
0
null
22,299,536,611,450
102
177
for i in range(int(input())): temp = [int(x) for x in input().split()] stemp = sorted(temp) if stemp[2]**2 == stemp[1]**2 + stemp[0]**2: print('YES') else: print('NO')
n, m = map(int, input().split()) listAC = [0] * n listWAAC = [0] * n listWA = [0] * n for i in range(m): p, s = map(str, input().split()) p = int(p) - 1 if listAC[p] == 1: continue if s == 'AC': listAC[p] += 1 listWAAC[p] += listWA[p] continue listWA[p] += 1 print(su...
0
null
46,991,344,945,032
4
240
n, m = map(int,input().split()) A = tuple(map(int,input().split())) days = 0 for i in A: days += i if n < days: print(-1) else: print(n-days)
import sys import math import time readline = sys.stdin.readline def main(): listSum = [1, 3, 6] k = int(input()) sumGCD = 0 for a in range(1, k + 1): for b in range(a, k + 1): for c in range(b, k + 1): sumGCD += gcd(a, b, c) * listSum[len(set([a, b, c])) - 1] p...
0
null
33,661,837,663,578
168
174
n,k = list(map(int,input().split())) r,s,p = list(map(int,input().split())) t = str(input()) t_list = [] for i in range(k): t_list.append(t[i]) for i in range(k,n): if t[i] != t_list[i-k] or t_list[i-k] == 'all': t_list.append(t[i]) else: t_list.append('all') print(t_list.count('r') * p + t_list.count...
# import sys # import math #sqrt,gcd,pi # import decimal # import queue # queue # import bisect # import heapq # priolity-queue # import time # from itertools import product,permutations,\ # combinations,combinations_with_replacement # 重複あり順列、順列、組み合わせ、重複あり組み合わせ # import collections # deque # from operator import it...
1
106,689,032,383,512
null
251
251
import math N, K = map(int, input().split()) A = list(map(int, input().split())) left = 0 right = max(A) while right - left > 1: mid = (left + right) // 2 jk = 0 for i in range(N): jk += A[i] // mid - 1 if A[i] % mid != 0: jk += 1 if jk <= K: right = mid else: left...
import math n,k=map(int,input().split()) A=list(map(int,input().split())) low=1 high=max(A) while low!=high: mid=(low+high)//2 s=0 for i in range(n): s+=math.ceil(A[i]/mid)-1 if s>k: low=mid+1 else: high=mid print(low)
1
6,535,065,743,932
null
99
99
N, X, Y = map(int, input().split()) count = [0]*(N+1) for i in range(1, N+1): for k in range(i+1, N+1): distik = min(k-i, abs(k-X) + abs(i - Y)+1, abs(k-Y) + abs(i-X)+1) count[distik] += 1 for i in range(1, N): print(count[i])
N = str(input()) if N[-1] == '3': print('bon') elif (N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8'): print('pon') else: print('hon')
0
null
31,667,791,602,070
187
142
import collections N = int(input()) a = list(map(int,input().split())) c = collections.Counter(a) if c.most_common()[0][1]==1: print("YES") else: print("NO")
#coding:utf-8 import sys,os from collections import defaultdict, deque from fractions import gcd from math import ceil, floor sys.setrecursionlimit(10**6) write = sys.stdout.write dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0 def main(given=sys.stdin.readline): input...
1
74,028,960,284,770
null
222
222
import sys input = sys.stdin.readline n = int(input()) a = [int(i) for i in input().split()] if n <= 3: print(max(a)) exit() a = tuple(a) dp = [[-10**15]*3 for i in range(n)] dp[0][2] = a[0] dp[1][2] = a[1] dp[2][2] = a[0]+a[2] dp[3][2] = max(a[0],a[1])+a[3] dp[3][1] = a[0]+a[3] for i in range(2,n-2): if i%2 ==...
n=int(input()) a=list(map(int,input().split())) if n//2==1: print(max(a)) exit() if n%2==0: #iは桁数、jはそれまでに余計に飛ばした数 #dp[i][j] dp=[[-10**9]*2 for _ in range(n)] for i in range(n): if i<2: dp[i][0]=a[i] if i>=2: dp[i][0]=dp[i-2][0]+a[i] ...
1
37,436,688,352,650
null
177
177
n, m, x = map(int, input().split()) c = [] algo = [] for _ in range(n): l = list(map(int, input().split())) c.append(l[0]) algo.append(l[1:]) cost = [] for i in range(2**n): c_sum = 0 u_sum = [0]*m for j in range(n): if (i>>j) & 1: c_sum += c[j] for k in range(m)...
H = int(input()) W = int(input()) N = int(input()) print(int((N+max(H,W)-1)/max(H,W)))
0
null
55,361,901,045,792
149
236
S = input() N = len(S) ans = 0 for k in range(N//2): if S[k] != S[-k-1]: ans += 1 print(ans)
a = input() b = a[::-1] c = 0 for i in range(int(len(a)/2)): if a[i] != b[i]: c += 1 print(c)
1
120,348,355,710,962
null
261
261
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 collection...
from collections import defaultdict INF = -1000000000000001 n = int(input()) l = list(map(int, input().split())) a = int(n/2) dpa = defaultdict(lambda: -INF) #dpa = [[0 for j in range(a+1)] for i in range(n+1)] dpa[(0,0)] = 0 dpa[(1,0)] = 0 dpa[(1,1)] = l[0] j = 1 for i in range(2,n+1): if i == j*2: dpa[(i,j)] =...
1
37,282,672,242,820
null
177
177
# 隣接リスト n = int(input()) graph = [] for _ in range(n): tmp = list(map(int, input().split())) if tmp[1] == 0: graph.append([]) else: graph.append(tmp[2:]) #print(graph) check = [0]*n count = 0 go = [0]*n back = [0]*n def dfs(v): #print(v) global count if check[v] == 0: ...
a,b=(int(x) for x in input().split()) print(a//b,a%b,"{0:.5f}".format(a/b))
0
null
294,205,523,740
8
45
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x ...
import collections h,w=map(int,input().split()) board=[list(input()) for _ in range(h)] q=collections.deque() if board[0][0]=='#': q.append((0,0,1,1)) else: q.append((0,0,0,0)) dp=[[10**18]*w for _ in range(h)] ans=10**18 while len(q)!=0: x,y,cnt,flag=q.popleft() if x==w-1 and y==h-1: ans=min(ans,cnt) el...
0
null
55,580,099,065,360
209
194
mod = 1000000007 N = int(input()) A = list(map(int, input().split())) C = [0,0,0] ans = 1 i = 0 while i < N: a = A[i] cnt = sum([1 if C[j] == a else 0 for j in range(3)]) ans = (ans*cnt)%mod if C[0] == a: C[0] += 1 elif C[1] == a: C[1] += 1 else: C[2] += 1 i += 1 print(ans)
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e n = int(input()) nums = map(int, input().split()) MOD = 1000000007 ans = 1 cnt = [3 if i == 0 else 0 for i in range(n + 1)] for num in nums: ans = ans * cnt[num] % MOD if ans == 0: break cnt[num] -= 1 cnt[num+1] += 1 print(ans)
1
129,793,940,101,684
null
268
268
def main(): n, d = map(int, input().split()) count = 0 for _ in range(n): x, y = map(int, input().split()) if (x**2 + y**2) ** 0.5 <= d: count += 1 print(count) if __name__ == '__main__': main()
def resolve(): import sys input = sys.stdin.readline # 整数 1 つ n = int(input()) s = input() # 整数複数個 # a, b = map(int, input().split()) # 整数 N 個 (改行区切り) # N = [int(input()) for i in range(N)] # 整数 N 個 (スペース区切り) # N = list(map(int, input().split())) # 整数 (縦 H 横 W の行列) # ...
0
null
52,747,020,339,120
96
245
N=int(input()) xy = [tuple(map(int,input().split())) for _ in range(N)] ans = 0 def dist(tpl1, tpl2): return abs(tpl1[0] - tpl2[0]) + abs(tpl1[1] - tpl2[1]) f0 = [] f1 = [] for i in range(N): x, y = xy[i] f0.append(x-y) f1.append(x+y) ans = max(ans, max(f0) - min(f0), max(f1) - min(f1)...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) X = [] for _ in range(n): x, l = map(int, input().split()) X.append([x - l, x + l]) X = sorted(X, key=lambda x: x[1]) remove = 0 prev = ...
0
null
46,521,213,891,138
80
237
x,y,z= map(str, input().split()) print(z,x,y, sep=' ')
a, b, c = map(int, input().split()) a, b = b, a a, c = c, a print(a, b, c, sep = " ")
1
38,053,850,717,122
null
178
178
import time as ti class MyQueue(object): """ My Queue class Attributes: queue: queue head tail """ def __init__(self): """Constructor """ self.length = 50010 self.queue = [0] * self.length # counter = 0 # while counter < sel...
import sys from collections import deque n,q = map(int,input().split()) f = lambda n,t: (n,int(t)) queue = deque(f(*l.split()) for l in sys.stdin) t = 0 while queue: name,time = queue.popleft() t += min(q, time) if time > q: queue.append((name, time-q)) else: print(name,t)
1
43,927,735,638
null
19
19
import sys data_list = sys.stdin.readlines() data_length = int(data_list.pop(0)) for x in xrange(data_length): lines = map(int, data_list[x].strip().split()) lines.sort(reverse = True) if lines[0]**2 == (lines[1]**2 + lines[2]**2): print "YES" else: print "NO"
delta = int(input()) tri_all = [] for i in range(delta): tri = list(map(int, input().split(' '))) tri.sort() tri_all.append(tri) for i in range(len(tri_all)): if tri_all[i][0]**2 + tri_all[i][1]**2 == tri_all[i][2]**2: print('YES') else: print('NO')
1
399,926,590
null
4
4
import copy class Dice2: def __init__(self, nums): self.nums = nums self.dic = \ {(1,2):3, (1,3):5, (1,4):2, (1,5):4, (2,3):1, (2,4):6, (2,6):3, (3,5):1, (3,6):5, (4,5):6, (4,6):2, (5,6):4} def output_right(self, x): x[0] = self.nums.index(x[0]) + 1 x[1] = self.nu...
from sys import stdin from copy import deepcopy import queue class Dice: def __init__(self, nums): self.labels = [None] + [ nums[i] for i in range(6) ] self.pos = { "E" : 3, "W" : 4, "S" : 2, "N" : 5, "T" : 1, "B" : 6 }...
1
256,023,497,366
null
34
34
import sys readline = sys.stdin.readline N,K = map(int,readline().split()) DIV = 998244353 L = [None] * K R = [None] * K for i in range(K): L[i],R[i] = map(int,readline().split()) dp = [0] * (N + 1) sdp = [0] * (N + 1) dp[1] = 1 sdp[1] = 1 for i in range(2, len(dp)): for j in range(K): li = max(i - R[j], ...
S=str(input()) a=S.count('hi') if a*2==len(S): print('Yes') else: print("No")
0
null
28,051,947,549,078
74
199
n, k, s = map(int, input().split()) ans = [] for i in range(n): if i < k: ans.append(s) else: if s != 10**9: ans.append(s+1) else: ans.append(1) print(*ans)
n = int(input()) a = list(map(int, input().split())) a = [(a[i], i) for i in range(n)] a.sort(key=lambda x: -x[0]) dp = [[0 for _ in range(n+1)] for _ in range(n+1)] for x in range(n+1): for y in range(n+1): if x + y > n: break active, idx = a[x+y-1] if x > 0: dp[x][...
0
null
62,417,286,383,748
238
171
x = int(input()); h = x // 3600; m = x % 3600 // 60; s = x % 60; print(h,m,s,sep=':');
N,K=map(int,input().split()) R,S,P=map(int,input().split()) T=input()+'*'*K h=['']*N f,n='','' ans=0 for i in range(N): if K<=i:f=h[i-K] n=T[i+K] if T[i]=='r': if f=='p':h[i]=n else:ans+=P;h[i]='p' if T[i]=='p': if f=='s':h[i]=n else:ans+=S;h[i]='s' if T[i]=='s': ...
0
null
53,452,785,408,048
37
251
s,t = map(int,input().split()) print('Yes' if s*2 <= t <= s*4 and t%2 == 0 else 'No')
x, y = list(map(int, input().split())) if y % 2 == 0 and 2 * x <= y and y <= 4 * x: print("Yes") else: print("No")
1
13,775,578,478,642
null
127
127
a=[] for i in range(10): a.append(input()) a.sort() a=a[::-1] a=a[:3] print(a[0]) print(a[1]) print(a[2])
a=[int(input()) for i in range(10)] a.sort(reverse=True) for i, iv in enumerate(a): print(iv) if i >= 2: break
1
37,887,772
null
2
2
import sys sys.setrecursionlimit(10**9) def mi(): return map(int,input().split()) def ii(): return int(input()) def isp(): return input().split() def deb(text): print("-------\n{}\n-------".format(text)) INF=10**20 def main(): a,b,c=mi() a,b = b,a a,c = c,a print(a,b,c) if __name__ == "__main__": ...
X,Y,Z = map(int,input().split()) A,B,C = X,Y,Z A,B = B,A A,C = C,A print('{} {} {}'.format(A,B,C))
1
38,062,006,558,488
null
178
178
lst = list(input()) v_lakes = [] idx_stack = [] for i, c in enumerate(lst): if (c == '\\'): idx_stack.append(i) elif (idx_stack and c == '/'): # 対応する'\\'の位置 j = idx_stack.pop() v = i - j while (v_lakes and v_lakes[-1][0] > j): v += v_lakes.pop()[1] v_l...
from sys import stdin from collections import deque sect = stdin.readline().lstrip("/_").rstrip("\n\\_") stack = deque() res = deque() for i in range(len(sect)): if sect[i] == "\\": stack.append(i) elif sect[i] == "/": if len(stack) != 0: b = stack.pop() if len(res) == ...
1
60,932,740,572
null
21
21
n,k = map(int,input().split()) keta = 1 while k ** keta <= n: keta += 1 print(keta)
[n, k] = [int(i) for i in input().split()] for i in range(40): if n < k**i: print(i) break
1
64,405,973,767,590
null
212
212
#!/usr/bin/env python # -*- coding: utf-8 -*- a, b, c = map(int, input().split()) ret = [i for i in range(a, b+1) if c%i == 0] print(len(ret))
import sys data = sys.stdin.readline().strip().split(' ') a = int(data[0]) b = int(data[1]) c = int(data[2]) cnt = 0 for i in range(a, b+1): if c % i == 0: cnt += 1 print(cnt)
1
574,482,278,092
null
44
44
def sum_dict(d): num = 0 for k, v in d.items(): num += k * v return num def create_dict(A): d = {} for a in A: if d.get(a) is None: d[a] = 1 else: d[a] += 1 return d if __name__ == "__main__": N = int(input()) A = list(map(int, input()...
import math , sys N = int( input() ) A = list( map( int, input().split() ) ) Q = int( input() ) count = [0 for _ in range( 10**5 + 1)] for each in A: count[each]+=1 ans = sum(A) for _ in range(Q): B , C = list( map( int , input().split() ) ) D = count[B] ans += (C-B) * D count[B] = 0 count[C]...
1
12,179,827,731,710
null
122
122
import math def main(): a, b, C = map(int, input().split()) C /= 180 C *= math.pi S = 1 / 2 * a * b * math.sin(C) L = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(C)) + a + b h = 2 * S / a print(S) print(L) print(h) if __name__ == "__main__": main()
n = int(input()) n3 = n**3 print(n3)
0
null
218,454,876,288
30
35
def popcnt(n): return bin(n).count("1") def f(n): cnt = 0 while n>0: n = n%popcnt(n) cnt += 1 return cnt def solve(X): Y = int(X, 2) c = X.count("1") m, p = c-1, c+1 Ym, Yp = Y%m if m else -1, Y%p for i in range(N): if X[i] == "1": Y = (Ym - pow(...
import sys import math import heapq from collections import defaultdict, deque from decimal import * def r(): return int(input()) def rm(): return map(int,input().split()) def rl(): return list(map(int,input().split())) '''D Anything Goes to zero''' twoPowM1=[0]*(300000) twoPowM2=[0]*(300000) stepsSmall=[0...
1
8,119,260,461,520
null
107
107
# -*- coding: utf-8 -*- class dice_class: def __init__(self, top, front, right, left, back, bottom): self.top = top self.front = front self.right = right self.left = left self.back = back self.bottom = bottom def sut(self, t): #set_up_top ...
import sys n=sys.stdin.readline().rstrip()[::-1] to=0 m=0 n+="0" num=len(n) for i in range(num): k=int(n[i]) k+=m if k==5: if int(n[i+1])>=5: to+=10-k m=1 else: to+=k m=0 if k<5: to+=k m=0 elif k>5: to+=10-k ...
0
null
35,594,620,211,008
34
219
n, m = map(int, input().split()) ab = [] for i in range (m): ab.append(list(map(int, input().split()))) par = [-1] * (n+1) #Union Find #xの根を求める def find(x): if par[x] < 0: return x else: tank = [] while par[x] >= 0: tank.append(x) x = par[x] for elt ...
class UnionFindTree(): def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) ...
1
3,968,016,773,610
null
84
84
N, M = map(int, input().split()) A = list(map(int, input().split())) if N - sum(A) <= 0: result = "Yes" else: result = "No" print(result)
H, N = list(map(int, input().split())) A = list(map(int, input().split())) AS = sum(A) if AS >= H: print('Yes') else: print('No')
1
77,957,976,444,468
null
226
226
n = int(input()) a,b = divmod(n,2) if b == 0: a -= 1 print(a)
from sys import stdin H = int(stdin.readline().rstrip()) W = int(stdin.readline().rstrip()) N = int(stdin.readline().rstrip()) if N%(max(H,W))==0: print(N//(max(H,W))) else: print(N//(max(H,W))+1)
0
null
121,168,559,998,532
283
236
N = int(input()) L = list(map(int, input().split())) #リストで複数行作るには? count = 0 for i in range(2, N): for j in range(1, i): for k in range(0, j): if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]: continue elif L[k] < L[i] + L[j] and L[i] < L[j] + L[k] and L[j] < L[i] + ...
N = list(input()) inN = [int(s) for s in N] if sum(inN) % 9 == 0: print('Yes') else: print('No')
0
null
4,719,893,097,500
91
87
n,k = map(int,input().split()) r,s,p = map(int,input().split()) t = input() ans = [] a,b,c = 0,0,0 for i in range(n): if i>=k: if t[i]==ans[i-k]: ans.append('X') continue if t[i] =='r': ans.append('r') c += 1 elif t[i]=='s': ans.append('s') a +...
from copy import copy C,R,K=map(int,input().split()) dp=[[0]*(R+1) for i1 in range(4)] M=[[0]*R for i in range(C)] for i in range(K): r,c,v=map(int,input().split()) M[r-1][c-1]=v for i,l in enumerate(M): for num in range(1,4): for j in range(R): if num==1: dp[num][j]= ma...
0
null
56,301,733,946,656
251
94
N = int(input()) root = int(N**0.5) for i in range(root,-1,-1): if N % i ==0: break print(int(N/i + i -2))
ls = ["SUN","MON","TUE","WED","THU","FRI","SAT"] print(7 - ls.index(str(input())))
0
null
147,211,138,795,742
288
270
def main(): # n=int(input()) n,k= map(int, input().split()) p=n-2*k print(p) if p>0 else print(0) return main()
inp = list(map(int, input().split())) a, b = inp[0], inp[1] if a > b*2: print(a-b*2) else: print(0)
1
166,277,568,248,260
null
291
291
n, q = list(map(int, input().split())) que = [] for _ in range(n): name, time = input().split() que.append([name, int(time)]) elapsed_time = 0 while que: name, time = que.pop(0) dt = min(q, time) time -= dt elapsed_time += dt if time > 0: que.append([name, time]) else: ...
from collections import deque n, q = map(int, input().split()) Q = deque() for i in range(n): name,time = input().split() Q.append([name, int(time)]) sum =0 while Q: qt = Q.popleft() if qt[1] <= q: sum += qt[1] print(qt[0], sum) else: sum += q qt[1] -= q Q.a...
1
42,399,860,130
null
19
19
K = int(input()) a = 0 for i in range(K): a = (10 * a + 7) % K if a % K == 0: print(i+1) exit() else: a %= K print(-1)
k = int(input()) a = [0]*k a[0] = 7%k for i in range(1, k): a[i] = (a[i-1] * 10 + 7)%k for i in range(k): if a[i] == 0: print(i+1) exit() print(-1)
1
6,089,692,856,956
null
97
97
cards=input() new=cards.split() a=int(new[0]) b=int(new[1]) c=int(new[2]) k=int(new[3]) if a>k: print(k) else: if a+b>k: print(a) else: sum=a+(k-(a+b))*(-1) print(sum)
h,w,m=map(int,input().split()) HH=[] WW=[] HW=set() lh=[0]*(h+1) lw=[0]*(w+1) for _ in range(m): h1,w1=map(int,input().split()) lh[h1]+=1 lw[w1]+=1 HW.add((h1,w1)) lhmax=max(lh) lwmax=max(lw) maxh=[] maxw=[] for i in range(1,h+1): if lh[i]==lhmax: maxh.append(i) for i in range(1,w+1): if...
0
null
13,260,345,683,740
148
89
def main(): n, m = map(int, input().split()) print('Yes') if n <= m else print('No') if __name__ == '__main__': main()
a,b,m = input().split() a = list(map(int,input().split())) b = list(map(int,input().split())) xyc =[] for i in range(int(m)): xyc.append(input()) min = min(a) + min(b) for i in xyc: x,y,c = map(int, i.split()) if min > a[x-1] + b[y-1] - c : min = a[x-1] + b[y-1] - c print(min)
0
null
68,773,045,524,862
231
200
N = int(input()) A = [int(x) for x in input().split()] print(*A) for i in range(1, len(A)): key = A[i] j = i-1 while j >= 0 and A[j] > key: A[j+1] = A[j] j += -1 A[j+1] = key print(*A)
def insertion_sort(array): '''?????????????´?????????????????????¨??????????????????????????¨???????????????????????§?????\?????????????????°???????????? 1. ??????????????¨??????????????????????´?????????????????????? v ????¨????????????? 2. ????????????????????¨??????????????????v ????????§??????????´?????...
1
5,839,026,312
null
10
10
from collections import defaultdict d=defaultdict(int) n=int(input()) a=list(map(int,input().split())) ans=1 mod=10**9+7 d[-1]=3 for i in a: ans*=d[i-1] ans%=mod d[i-1]-=1 d[i]+=1 print(ans)
#ABC162-E Sum of gcd of Tuples(Hard) """ 問題を「1~kまでの数字を用いた長さnの数列において、gcdがDになる数列はいくつあるか」 というふうに置き換える。(1<=D<=k) 更に制約を替えて、gcdが"Dの倍数"(但し,k以下)でも良いのでそれを全て求めよ、 というふうになった場合、全ての要素はD*n(nは整数,D*n<=k)となる。 この制約によって、そのような数列の数は(k/D)^nとして表せる。(これが大事) 例: n = 3,k = 4の場合で、D(gcd)=2について求める (4//2)**3 = 8※ そこで、大きい方からgcdがDになる数列の個数(これをメモ化)を求めていっ...
0
null
83,701,167,185,120
268
176
from sys import stdin import numpy as np n, k = map(int, stdin.buffer.readline().split()) a = np.fromstring(stdin.buffer.read(), dtype=np.int, sep=' ') ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(np.ceil(a / mid) - 1) <= k: ok = mid else: ng = mid print(ok)
import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 1 M = max(A) while(M-m>0): mm = 0 mid = (M+m)//2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid+1 else: M = mid print(math.ceil(m))
1
6,452,093,479,360
null
99
99
s = input() if s.count('A') > 0 and s.count('B') > 0 : print('Yes') else: print('No')
n = int(input()) a = list(map(int, input().split())) #print(a) a.reverse() print(*a)
0
null
27,713,333,136,480
201
53
s = input() ans = '' for i in range(len(s)): ans = ans + 'x' print(ans)
def main(): S = input() print("x"*len(S)) if __name__ == "__main__": main()
1
72,769,864,927,596
null
221
221
n=int(input()) if n==2: count=1 else: count=2 for i in range(2,int(n**0.5)+1): if n%i==0: k=n//i while k>0: if k%i==0: k=k//i else: if k%i==1: count+=1 break elif (n-1)%i==0: count+=1 ...
def bubblesort(N, A): C, flag = [] + A, True while flag: flag = False for j in range(N-1, 0, -1): if int(C[j][1]) < int(C[j-1][1]): C[j], C[j-1] = C[j- 1], C[j] flag = True return C def selectionSort(N, A): C = [] + A for i in range(N): ...
0
null
20,583,166,435,942
183
16
from math import sqrt n = int(input()) p = 0 for i in range(n): x = int(input()) ad = 1 if x>2 and x%2==0: ad = 0 else: j=3 while j < (int(sqrt(x))+1): if x%j == 0: ad = 0 break else: j += 2 p += ad p...
N_str, q_str = raw_input().split() N = int(N_str) q = int(q_str) A =[] B =[] total =0 for i in range(N): t = raw_input().split() A.append([t[0],int(t[1])]) while A: name, time = A.pop(0) if time <= q: total += time B.append(name+" "+ str(total)) else: time -= q ...
0
null
27,382,805,298
12
19
S=input() Q=int(input()) inst=[] for i in range(Q): array=input().split() inst.append(tuple(array)) rev=True front_str=[] back_str=[] for i in range(Q): if int(inst[i][0])==1: rev=not rev elif rev: if int(inst[i][1])==1: front_str.append(inst[i][2]) else: ...
def main(): s = input() q = int(input()) is_fwd = True before = '' after = '' for i in range(q): fields = [i for i in input().split()] t = int(fields[0]) if t == 1: is_fwd = not is_fwd elif t == 2: f = int(fields[1]) c = fields...
1
57,595,067,815,010
null
204
204
x = input().strip() if x[-1] == 's': x += "es" else: x += 's' print(x)
[S,T] = input().split() print(T+S)
0
null
52,596,135,916,352
71
248
import sys N = int(input()) S = [str(s) for s in sys.stdin.read().split()] print(len(set(S)))
N = int(input()) T = [input() for i in range(N)] T.sort() c = 1 pre = T[0] for i in range(1,N): if T[i] == pre: pass else: c += 1 pre = T[i] print(c)
1
30,269,039,227,142
null
165
165
n,m=map(int,input().split()) s=list(input()) s.reverse() ansl=[] now=0 while now<n: f=1 for i in range(m,0,-1): if now+i<n+1 and s[now+i]=="0": ansl.append(i) now+=i f=0 break if f: print(-1) exit() ansl.reverse() print(*ansl)
def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,M=MI() S=list(input()) S2=S[::-1] now=0 ans=[] while now!=N: nxt=now+M if nxt>N: nxt=N while S2[nxt]==...
1
139,158,230,284,260
null
274
274
import os, sys, re, math S = input() count = 0 for i in range(len(S) // 2): if S[i] != S[-i - 1]: count += 1 print(count)
# This code is generated by [Atcoder_base64](https://github.com/kyomukyomupurin/AtCoder_base64) import base64 import subprocess import zlib exe_bin = "c$~dk4Rlo1wLW)dk_;i48#N#xNVH>36vm7MOlr_fn1nlaf(XP?3%!QPgiOufOKuR5r;tf_T*pzKcD1ZlEA{6srCO2KMS<tzB?ber=tEnn6@RD|oH2^=hY$oZZ|`%@nYnW_)1SBAdY3iX_k3sXefHVsoPB=o;l3(wwMh^Nf6...
0
null
61,707,712,095,918
261
84
import sys def ISI(): return map(int, sys.stdin.readline().rstrip().split()) n, m=ISI() if(n==m):print("Yes") else:print("No")
from collections import deque H, W, M = map(int, input().split()) bomb = [] counth = [0 for k in range(H)] countw = [0 for k in range(W)] for k in range(M): h, w = map(int, input().split()) h -= 1 w -= 1 bomb.append(h+ w*H) counth[h] += 1 countw[w] += 1 counth = deque(counth) countw = deque(countw) maxh ...
0
null
43,866,467,306,430
231
89
d,t,s = [float(x) for x in input().split()] if d/s > t: print("No") else: print("Yes")
#: Author - Soumya Saurav import sys,io,os,time from collections import defaultdict from collections import Counter from collections import deque from itertools import combinations from itertools import permutations import bisect,math,heapq alphabet = "abcdefghijklmnopqrstuvwxyz" input = sys.stdin.readline ##########...
0
null
3,052,330,526,530
81
73
print((lambda x:(1/2 if (x%2 == 0) else (x//2+1)/x))(int(input())))
a,b,c,k=map(int,input().split()) if k<=a: ans=k elif k>a and k<=a+b: ans=a else: ans=a-(k-(a+b)) print(ans)
0
null
99,196,441,840,256
297
148
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" N = int(input()) S = input() ans = [] for c in S: print(abc[(abc.index(c) + N) % len(abc)], end = "")
def resolve(): n = int(input()) s = input() ans = '' for i in s: ans += chr(ord('A')+(ord(i)-ord('A')+n)%26) print(ans) resolve()
1
134,490,792,753,690
null
271
271
r = input() print(r[0:3])
import itertools N, M, Q = map(int, input().split()) q = [list(map(int, input().split())) for _ in range(Q)] a = [0] * N max_score = 0 for v in itertools.combinations(range(N + M - 1), N): tmp_score = 0 for n in range(N): a[n] = v[n] + 1 - n for query in q: if (a[query[1] - 1] - a[query[0] ...
0
null
21,333,692,203,040
130
160
A = map(int, input().split()) print('bust' if(sum(A) >= 22) else 'win')
a = list(map(int, input().split())) s = a[0] + a[1] + a[2] if s >= 22: print('bust') else: print('win')
1
118,528,692,304,032
null
260
260
s = input() n = len(s) mod = 2019 t = [0]*n dp = [0]*2020 t[0] = int(s[-1]) dp[t[0]] += 1 for i in range(n-1): t[i+1] = t[i] + int(s[-2-i])*pow(10, i+1, mod) t[i+1] %= mod dp[t[i+1]] += 1 ans = 0 for D in dp[1:]: ans += D*(D-1)//2 print(ans+(dp[0]+1)*(dp[0])//2)
rooms = [0] * (4*3*10) n = input(); for i in xrange(n): b,f,r,v = map(int, raw_input().split()) rooms[(b-1)*30+(f-1)*10+(r-1)] += v sep = "#" * 20 for b in xrange(4): for f in xrange(3): t = 30*b + 10*f print ""," ".join(map(str, rooms[t:t+10])) if b < 3: print sep
0
null
15,998,089,247,950
166
55
import sys def gcd(a,b): a,b=max(a,b),min(a,b) while a%b: a,b=b,a%b return b def lcm(a,b): return a//gcd(a,b)*b for i in sys.stdin: a,b=map(int,i.split()) print(gcd(a,b),lcm(a,b))
import math while True: try: a, b = [int(x) for x in input().split()] print(math.gcd(a,b), a*b // math.gcd(a,b)) except EOFError: break
1
576,270,468
null
5
5
from math import ceil from bisect import bisect_right n, d, a = map(int, input().split()) l = [] l2 = [] l3 = [] l4 = [0 for i in range(n+1)] l5 = [0 for i in range(n+1)] ans = 0 for i in range(n): x, h = map(int, input().split()) l.append([x, h]) l2.append(x + 2 * d) l3.append(x) l.sort(key=lambda x: x[0]) l2...
from fractions import gcd n, m = map(int, input().split()) aa = list(map(int, input().split())) lcm = 1 def p2(m): cnt = 0 n = m while 1: if n%2 == 0: cnt += 1 n = n//2 else: break return cnt pp = p2(aa[0]) for a in aa: lcm = a * lcm // gcd(a, lc...
0
null
91,940,534,493,532
230
247
x,y,k=map(int,input().split()) if(k<=x): x=x-k k=0 else: k-=x x=0 if(k<=y): y-=k k=0 else: k-=y y=0 print(x,y)
#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) #l = list(map(int, input().split())) #l = [list(map(int,input().split())) for i in range(n)] #a = [input() for _ in range(n)] N = int(input()) seq = list(map(int, input().split())) s = 0 for i in range(N): s += seq...
0
null
54,116,934,877,282
249
83
N = int(raw_input()) num_list = map(int, raw_input().split()) c = 0 for i in range(0,N,1): flag =0 minj =i for j in range(i,N,1): if num_list[j] < num_list[minj]: minj = j flag = 1 c += flag num_list[i], num_list[minj] = num_list[minj], num_list[i] print " ".join(map...
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) count = 0 flag = 0 for i in range(N): if N == 1: break minj = i for j in range(i, N): if A[j] < A[minj]: minj = j flag = 1 if flag == 1: A[i], A[minj] = A[minj], A[i] ...
1
21,238,821,212
null
15
15
import math import collections def main(): S, T = input().split() A, B = map(int, input().split()) U = input() if U == S: print(A-1, B) else: print(A, B-1) main()
import sys n = int(raw_input()) building_a = [[0 for j in range(11)] for i in range(4)] building_b = [[0 for j in range(11)] for i in range(4)] building_c = [[0 for j in range(11)] for i in range(4)] building_d = [[0 for j in range(11)] for i in range(4)] for i in range(n): b, f, r, v = map(int, raw_input().split...
0
null
36,452,191,560,320
220
55
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 998244353 n, k = map(int, input().split()) s = list() for i in range(k): s.append(tuple(map(int, input().split()))) dp = [0] + [0] * n diff = [0] + [0] * n dp[1] = 1 for i in range(1, n): for j, k in s: if i + j > n: ...
MOD = 998244353 N, K = map(int, input().split()) rl = [list(map(int, input().split())) for _ in range(K)] dp = [0] * (N + 1) sdp = [0] * (N + 1) dp[1] = 1 sdp[1] = 1 for i in range(2, N + 1): for j in range(K): l, r = rl[j][0], rl[j][1] tl = max(1, i - r) tr = max(0, i - l) dp[i] +=...
1
2,680,930,199,668
null
74
74
import math class MergeSort: cnt = 0 def merge(self, a, n, left, mid, right): n1 = mid - left n2 = right - mid l = a[left:(left+n1)] r = a[mid:(mid+n2)] l.append(2000000000) r.append(2000000000) i = 0 j = 0 for k in range(left, right): ...
n = int(input()) nums = [int(i) for i in input().split(" ")] count = 0 def merge(nums, left, mid, right): i = 0 j = 0 nums_l = nums[left:mid] nums_r = nums[mid:right] nums_l.append(10 ** 9 + 1) nums_r.append(10 ** 9 + 1) for x in range(0, right - left): global count count =...
1
107,810,892,590
null
26
26
X,K,D=map(int,input().split()) X=abs(X) if X<=K*D: if (K-X//D)%2==0:X=X%D else:X=abs(X%D-D) else: X=X-K*D print(X)
for i in range(1,10): for s in range(1,10): result = str(i) + "x" + str(s) + "=" + str(int(i)*int(s)) print(result)
0
null
2,569,665,203,972
92
1
# DPL_1_A - コイン問題  import sys N, M = map(int, sys.stdin.readline().strip().split()) # N払う コイン種類M 枚 c = list(map(int, sys.stdin.readline().strip().split())) # dp 初期化 dp = [[float('inf')] * (N + 1) for _ in range(M + 1)] for i in range(len(dp)): dp[i][0] = 0 for m in range(M): for n in range(N + 1): ...
S = input() S1 = S[:len(S) // 2] S2 = S[-1:(len(S)-1) // 2:-1] ans = 0 for s1, s2 in zip(S1, S2): ans += s1!=s2 print(ans)
0
null
60,253,133,094,770
28
261
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): A, B = map(int, readline().split()) if A < 10 and B < 10: print(A * B) else: print(-1) return if __name__ == '__m...
S = int(input()) a = S//(60*60) b = (S-(a*60*60))//60 c = S-(a*60*60 + b*60) print(a, ':', b, ':', c, sep='')
0
null
79,666,952,863,692
286
37
n,inc,dec=int(input()),[],[] for _ in range(n): s,d,r=input(),0,0 for c in s: d=d+(1 if c=='(' else -1) r=max(r,-d) (dec if d<0 else inc).append((d,r)) inc.sort(key=lambda x:x[1]) dec.sort(key=lambda x:x[0]+x[1]) p1,p2,ok=0,0,True for s in inc: ok&=s[1]<=p1 p1+=s[0] for s in dec: ok&=p2>=s[0]+s[1] ...
def encode(s): val = 0 min_val = 0 for c in s: if c == '(': val += 1 else: val -= 1 min_val = min(min_val, val) return [min_val, val] def check(s): h = 0 for p in s: b = h + p[0] if b < 0: return False h += ...
1
23,556,859,758,470
null
152
152
N, M = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A) A = A[::-1] X = sum(A) Y = 1/4/M ans = 'Yes' for i in range(M): if A[i]/X < Y: ans = 'No' print(ans)
n,m = map(int,input().split()) a = list(map(int,input().split())) sum = 0 cnt = 0 for i in a: sum += i for i in a: if(sum <= 4*m*i): cnt += 1 if(cnt >= m): print("Yes") else: print("No")
1
38,679,109,250,308
null
179
179
N, K = map(int, input().split()) H = list(map(int, input().split())) if N <= K: print(0) exit() H.sort(reverse=True) print(sum(H[K:]))
N, K = [int(s) for s in input().split()] H = sorted([int(s) for s in input().split()])[::-1] print(sum(H[K:]) if N > K else 0)
1
78,760,720,220,348
null
227
227
import math N = int(input()) # A = list(map(int, input().split())) A = [int(x) for x in input().split(' ')] a_max = [0] * (N+1) a_min = [0] * (N+1) a = [0] * (N+1) #1.可・不可の判定 # 最下段からとりうる個数の範囲を考える #0段目の範囲に1が含まれないならば”不可”(根=1) for i in range(N+1): if i == 0: a_max[N-i] = A[N-i] a_min[N-i] = A[N-i]...
n = int(input()) tmp = 0 import sys for i in range(n): d = list(map(int,input().split())) if d[0] == d[1]: tmp += 1 #check if tmp == 3: print('Yes') sys.exit() else: tmp = 0 print('No')
0
null
10,702,822,355,292
141
72
h, w, k = map(int, input().split()) s = [] for _ in range(h): s.append(input()) sum = [[0] * (w+1) for _ in range(h+1)] for i in range(h): for j in range(w): sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0) ans = h + w - 2 for ptn in range(1<<h-1): cand = 0 ...
''' ''' INF = float('inf') def main(): H, W, K = map(int, input().split()) S = [input() for _ in range(H)] S = [''.join(S[row][col] for row in range(H)) for col in range(W)] ans = INF for b in range(0, 2**H, 2): sections = [(0, H)] for shift in range(1, H): if (1<<shif...
1
48,798,197,979,672
null
193
193
N = int(input()) if N % 2 == 1: print(0) else: ans = 0 div = 10 for _ in range(100): ans += N // div div *= 5 print(ans)
from math import pi r = float(input()) print('{:.5f} {:.5f}'.format(r*r*pi,r*2*pi))
0
null
58,533,671,511,740
258
46
class Node(object): def __init__(self, V): self.V = V self.d = -1 n = int(input()) nodes = [0] * 101 for i in range(n): data = input().split() V = list(map(int, data[2:])) V.sort(reverse = True) nodes[int(data[0])] = Node(V) l = [1,] l_old = [] cnt = 0 while len(l) > 0: l...
from collections import deque def bfs(adj_mat, d): Q = deque() N = len(d) color = ["W" for n in range(N)] Q.append(0) d[0] = 0 while len(Q) != 0: u = Q.popleft() for i in range(N): if adj_mat[u][i] == 1 and color[i] == "W": color[i] = "G" ...
1
4,437,784,220
null
9
9
n=int(input()) al='ABCDEFGHIJKLMNOPQRSTUVWXYZ' ans=[] s=input() for i in range(len(s)): ans.append(al[(ord(s[i])-65+n)%26]) print(''.join(ans))
def main(): x = int(input()) grade = 0 for i in range(8): if (400 + 200 * i) <= x < (400 + 200 * (i + 1)): grade = 8 - i print(grade) if __name__ == "__main__": main()
0
null
70,318,910,074,592
271
100
X, Y, Z = map(str, input().split()) print(Z+" "+X+" "+Y)
X = input().split() print(X[2], X[0], X[1])
1
38,119,677,365,952
null
178
178
def search(start, N, X, Y): dist = [0 for _ in range(N)] if start <= X: for i in range(X): dist[i] = abs(start - i) for i in range(Y, N): dist[i] = (X - start) + 1 + (i - Y) for i in range(X, (Y - X) // 2 + X + 1): dist[i] = (i - start) for i ...
while True: x = [] x = input().split( ) y = [int(s) for s in x] if sum(y) == -3: break if y[0] == -1 or y[1] == -1: print("F") elif y[0] + y[1] < 30: print("F") elif y[0] + y[1] >= 30 and y[0] + y[1] <50: if y[2] >= 50: print("C") else: ...
0
null
22,629,583,579,148
187
57
# -*- coding: utf-8 -*- modelmap = list(input()) S1 = [] S2 = [] A = 0 for i, l in enumerate(modelmap): if l == "\\": S1.append(i) elif l == "/" and len(S1) > 0: ip = S1.pop() A += i - ip L = i - ip while len(S2) > 0 and S2[-1][0] > ip: L += S2.pop()[1] ...
# -*- coding: utf-8 -*- """ stackの応用(水たまりの面積) """ from collections import deque S = list(input()) # 総合面積 ans = 0 # 総合面積用スタック(直近の\の位置) stack1 = deque() # 個別用スタック(その水たまりを開始する\の位置, その時点での面積) stack2 = deque() for i in range(len(S)): if S[i] == '\\': stack1.append(i) # 一番最近いれた\を取り出せば、今回の/と対になる(同じ高さ) ...
1
60,638,570,908
null
21
21
import math x = int(input()) def lcm(a, b): return (a * b) // math.gcd(a, b) rad = lcm(360, x) print(rad//x)
x=int(input()) ans=1 now=x while now%360!=0: now+=x ans+=1 print(ans)
1
13,121,569,565,192
null
125
125
N, M = map(int, input().split()) if M%2 != 0: center = M + 1 else: center = M c = center//2 d = (center + 1 + 2*M + 1) // 2 i = 0 while i < c: print(c-i, c+1+i) i += 1 j = 0 while i < M: print(d-(j+1), d+(j+1)) i += 1 j += 1
import sys input = sys.stdin.readline h, w, kk = map(int, input().split()) ss = [[0 for _ in range(h)] for _ in range(w)] for i in range(h): for j, c in enumerate(list(input().strip())): if c == '1': ss[j][i] = 1 ans = 100000 for i in range(2 ** (h - 1)): end = [] for j in range(h - 1)...
0
null
38,687,607,574,688
162
193
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
97