Dataset Viewer
Auto-converted to Parquet Duplicate
code1
stringlengths
16
427k
code2
stringlengths
16
427k
similar
int64
0
1
pair_id
int64
2
181,637B
question_pair_id
float64
3.71M
180,629B
code1_group
int64
1
299
code2_group
int64
1
299
def main(): while True: number_string = input() if number_string == '0': break print(sum(map(int, list(number_string)))) main()
''' ITP-1_8-B ??°????????? ?????????????????°???????????????????¨??????????????????°????????????????????????????????? ???Input ?????°??????????????????????????\?????¨??????????????????????????????????????????????????????????????´??° x ?????????????????§????????????????????? x ??? 1000 ?????\????????´??°??§?????? x ???...
1
1,592,700,519,410
null
62
62
station = input() print("Yes" if "AB" in station or "BA" in station else "No")
S = str(input()) if S[0] == S[1] == S[2]: print('No') else: print('Yes')
1
54,637,299,648,890
null
201
201
import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print('\n'.join(map(str, x))) n = ini() ans = 0 tmp = 1 while n > 0: n //= 2 ans += tmp tmp *= 2 pri...
import math h = int(input()) l = int(math.log(h, 2)) p = (2**l)*2-1 print(p)
1
80,077,148,875,830
null
228
228
from collections import deque n, m = map(int, input().split()) way = {} for i in range(m): a, b = map(int, input().split()) if a not in way: way[a] = [] if b not in way: way[b] = [] way[a].append(b) way[b].append(a) queue = deque([1]) ok = set([1]) ans = [0] * (n+1) while queue: ...
import queue q = queue.Queue() bool = True def bfs(): q.put(0) while not q.empty(): now = q.get() for i in nodes[now]: if dist[i] != -1: continue dist[i] = dist[now] + 1 q.put(i) ans[i] = now # bool = False N, M = map(int, ...
1
20,520,474,183,638
null
145
145
import math from collections import defaultdict,deque #from itertools import permutations ml=lambda:map(int,input().split()) ll=lambda:list(map(int,input().split())) ii=lambda:int(input()) ip=lambda:list(input()) ips=lambda:input().split() """========main code===============""" n=ii() s=ip() ans=1 for i in range(1,n)...
# -*- coding: utf-8 -*- n = int(input()) s = input() ans = 1 tmp = s[0] for c in s: if tmp != c: ans += 1 tmp = c print(ans)
1
169,881,176,255,072
null
293
293
A, B, C = input().split() S = A + B + C ans = 'No' for i in range(len(S)): if S.count(S[i]) == 2: ans = 'Yes' break print(ans)
a = [int(i) for i in input().split()] if (a[0] == a[1] and a[0] != a[2]) or (a[0] == a[2] and a[0] != a[1]) or (a[2] == a[1] and a[2] != a[0]): print('Yes') else: print('No')
1
68,346,187,534,020
null
216
216
def main(): S = input() if S[2] == S[3] and S[4] == S[5]: print("Yes") else: print("No") if __name__ == '__main__': main()
s = input() print('Yes') if s[2:3] == s[3:4] and s[4:5] == s[5:6] else print('No')
1
42,019,735,548,670
null
184
184
import math while(1): a=0 n=int(input()) if n==0: break; s=list(map(int,input().split())) m=sum(s)/len(s) for i in range(n): a=a+pow(s[i]-m,2) print(math.sqrt(a/n))
while True: n = int(input()) if n == 0: break else: data_set = [int(i) for i in input().split()] m = sum(data_set) / n v = 0 for i in data_set: diff = i - m v += diff ** 2 v /= n print(v ** 0.5)
1
190,271,007,740
null
31
31
N = [int(_) for _ in list(input())] a, b = 0, 1 for n in N: a, b = min(a+n, b+10-n), min(a+(n+1), b+10-(n+1)) print(a)
from math import * def distance (p,n,x,y): dis = 0.0 if p == "inf": for i in range(0,n) : if dis < abs(x[i]-y[i]): dis = abs(x[i]-y[i]) else : for i in range(0,n) : dis += abs(x[i]-y[i])**p dis = dis ** (1.0/p) return dis if __name__ =...
0
null
35,728,434,239,498
219
32
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(m)] class Union: def __init__(self, n): self.parents = [-1] * n def root(self, x): if self.parents[x] < 0: return x else: return self.root(self.parents[x]) def uni...
n = int(input()) data = [int(i) for i in input().split()] print(f'{min(data)} {max(data)} {sum(data)}')
0
null
2,364,626,783,872
84
48
s = input() INF = float('inf') dp = [[INF,INF] for _ in range(len(s)+1)] dp[0][0]=0 dp[0][1]=1 for i in range(len(s)): dp[i+1][0] = min(dp[i][0]+int(s[i]), dp[i][1]+10-int(s[i]), dp[i][1]+int(s[i])+1) dp[i+1][1] = min(dp[i][0]+int(s[i])+1,dp[i][1]+10-int(s[i])-1) print(dp[-1][0])
n = int(input()) p= [] AC = 0 WA = 0 TLE = 0 RE = 0 for i in range(n): p.append(input()) for j in p : if j == "AC": AC += 1 elif j == "WA": WA += 1 elif j == "TLE": TLE += 1 else: RE += 1 print("AC x " + str(AC)) print("WA x " + str(WA)) print("TLE x " + str(TLE)) print("RE x " + str...
0
null
40,008,436,055,588
219
109
from itertools import repeat from itertools import combinations def rec(s, i, total, m): if total == m: return 1 if len(s) == i or total > m: return 0 return rec(s, i + 1, total, m) + rec(s, i + 1, total + s[i], m) def makeCache(s): cache = {} for i in range(len(s)): com...
n = int(input()) A = list(map(int,input().split())) m = int(input()) B = list(input().split()) for i in range(m): B[i] = int(B[i]) def solve(x,y): if x==n: S[y] = 1 else: solve(x+1,y) if y+A[x] < 2001: solve(x+1,y+A[x]) S = [0 for i in range(2001)] solve(0,...
1
102,296,313,088
null
25
25
x = list(map(int , input().split())) s = set() for i in x: if i not in s: s.add(i) if len(s) == 2: print('Yes') else: print('No')
# -*- coding: utf-8 -*- ABC = input() ABC = ABC.replace(" ", "") if ABC.count(ABC[0]) == 2 or ABC.count(ABC[1]) == 2 or ABC.count(ABC[2]) == 2: print("Yes") else: print("No")
1
67,923,744,373,760
null
216
216
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)
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = min(a)+min(b) for i in range(M): x,y,z = map(int,input().split()) s = a[x-1]+b[y-1]-z ans = (s if s < ans else ans) print(ans)
1
53,937,924,986,504
null
200
200
K = int(input()) A, B = map(int, input().split()) i = A while (i % K != 0) and (i <= B): i += 1 if i == B+1: print("NG") else: print("OK")
x = int(input()) a, b = map(int, input().split()) ans=0 for i in range(a,b+1): if i%x==0: ans=1 break if ans==1: print('OK') else: print('NG')
1
26,496,247,232,128
null
158
158
def check(P): global k, T, n i = 0 for j in range(k): s = 0 while s + T[i] <= P: s += T[i] i += 1 if (i == n): return n return i def solve(): left = 0 right = 100000 * 10000 while right - left > 1: mid = (left + right) // 2 v = check(mid) if (v >= n): right = mid else: left = ...
import sys n, truck_num = map(int, input().split()) weights = [int(x) for x in map(int, sys.stdin)] def main(): # 最小値と最大値をもとに二分探索する print(binary_search(max(weights), sum(weights))) def binary_search(left, right): """二分探索 :param left: 最小値 :param right: 最大値 :return: """ while left <...
1
84,729,217,020
null
24
24
n = input() k = int(n[-1]) if k == 3: print("bon") elif k == 0 or k == 1 or k == 6 or k == 8: print("pon") else: print("hon")
n = input() x = list(n) length = len(x) if x[length-1] == "3": print("bon") elif x[length-1] == "0" or x[length-1] == "1" or x[length-1] == "6" or x[length-1] =="8": print("pon") else: print("hon")
1
19,381,761,660,560
null
142
142
n = int(input()) As = list(map(int, input().split())) internal_max = [1]*(n+1) internal_max[0] = 1-As[0] for i in range(1,n+1): internal_max[i] = 2*internal_max[i-1]-As[i] depth_sum = [0]*(n+1) depth_sum[n] = As[n] judge = False for i in range(n-1, -1, -1): if depth_sum[i+1] > internal_max[i]*2: jud...
N = int(input()) A = list(map(int, input().split())) A.reverse() min_max = [[] for _ in range(N+1)] def main(): min_max[0] = [A[0], A[0]] for i in range(1, N+1): a = A[i] pre_min, pre_max = min_max[i-1] min_max[i] = [(1+pre_min)//2 +a, pre_max +a] min_max.reverse() if min_max[0]...
1
18,783,855,721,870
null
141
141
S = input() print(chr(ord(S) + 1))
def solve(): c = input() print(chr(ord(c)+1)) if __name__ == '__main__': solve()
1
92,150,567,109,600
null
239
239
#Is it Right Triangre? n = int(input()) for i in range(n): set = input(). split() set = [int(a) for a in set] #int????????? set.sort() if set[0] ** 2 + set[1] ** 2 == set[2] ** 2: print("YES") else: print("NO")
def LI(): return list(map(int, input().split())) a, b, c = LI() if c-a-b < 0: ans = "No" elif 4*a*b < (c-a-b)**2: ans = "Yes" else: ans = "No" print(ans)
0
null
25,905,555,517,490
4
197
N = int(input()) dic = {} for i in range (N): s = input() if s in dic: dic[s] += 1 else: dic[s] = 1 sai = max(dic.values()) for j in sorted(k for k in dic if dic[k] == sai): print(j)
import collections N = int(input()) S = [input() for _ in range(N)] c = collections.Counter(S) d = c.most_common() cnt = 0 for i in range(len(c)-1): if d[i][1] == d[i+1][1]: cnt += 1 else: break e = [] for j in range(cnt+1): e.append(d[j][0]) e.sort() for k in range(len(e)): print(e[k])
1
70,050,929,104,508
null
218
218
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random,resource sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(in...
import numpy as np N = int(input()) X = str(input()) num_one = X.count("1") dp = [-1] * N dp[0] = 0 def dfs(n): if dp[n] == -1: dp[n] = 1 + dfs(n % bin(n).count('1')) return dp[n] num_one = X.count("1") bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)]) zero_ver = np.array([p...
1
8,128,447,293,180
null
107
107
def call(n): s = "" for i in range(1,n+1): if i%3 == 0: s += " {0}".format(i) else: x = i while x > 0: if x%10 == 3: s += " {0}".format(i) break x = x // 10 print(s) m = int(input()) call...
#!/usr/bin/env python3 import sys import numpy as np YES = "Yes" # type: str NO = "No" # type: str def solve(K: int, X: int): if 500*K>=X: print(YES) else: print(NO) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. Yo...
0
null
49,760,641,338,038
52
244
if __name__ == '__main__': N, M = map(int, input().split()) S = [] C = [] for i in range(M): s, c = map(int, input().split()) s -= 1 S.append(s) C.append(c) for num in range(0, pow(10, N)): st_num = str(num) if len(str(st_num))!=N: continue c...
def func(num, div): return num // div l, r, d = map(int, input().split()) print(func(r, d) - func(l - 1, d))
0
null
34,128,058,690,144
208
104
def main(): s = input() if s == 'ABC': print('ARC') else: print('ABC') if __name__ == "__main__": main()
S = input() if S[1] == 'R': T = 'ABC' else: T = 'ARC' print(T)
1
24,055,828,077,568
null
153
153
n = int(input()) a = list(map(int, input().split())) first_half = 0 latter_half = sum(a) min_diff = latter_half for i in range(n): first_half += a[i] latter_half -= a[i] diff = abs(first_half - latter_half) min_diff = min(min_diff, diff) print(min_diff)
n = int(input()) A = list(map(int, input().split())) for i in range(n - 1): A[i + 1] += A[i] minv = float('inf') for a in A[:-1]: minv = min(minv, abs(A[-1]/2 - a)) print(int(minv * 2))
1
142,266,495,377,092
null
276
276
# coding: utf-8 x = int(input()) ans = x // 500 x = x - ans * 500 ans = ans * 1000 ans += (x // 5 * 5) print(ans)
N, M = map(int, input().split()) An = [int(i) for i in input().split()] total = sum(An) if total > N: print('-1') else: print(N - total)
0
null
37,366,374,317,188
185
168
import math n=int(input()) while n != 0 : sums = 0.0 s = list(map(float,input().split())) m = sum(s)/n for i in range(n): sums += ((s[i]-m)**2)/n print(math.sqrt(sums)) n = int(input())
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines class UnionFind: def __init__(self, n): self.parents = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.length = [1 for _ in range(n)] def makeSet(self, n): ...
0
null
30,907,209,083,612
31
209
a = str(input()) if 'A'<=a and a<='Z': print('A') else: print('a')
if __name__ == '__main__': s = input() if s.islower(): print("a") else: print("A")
1
11,285,424,423,310
null
119
119
N, K, C = map(int, input().split()) S = list(input()) l = [0] * N r = [0] * N cnt = 1 yutori = 10 ** 10 for i, s in enumerate(S): if s == "o" and yutori > C: l[i] = cnt yutori = 0 cnt += 1 yutori += 1 S.reverse() yutori = 10 ** 10 cnt = K for i, s in enumerate(S): if s == "o" and y...
""" 入力例 1 11 3 2 ooxxxoxxxoo ->6 入力例 2 5 2 3 ooxoo ->1 ->5 入力例 3 5 1 0 ooooo -> 入力例 4 16 4 3 ooxxoxoxxxoxoxxo ->11 ->16 """ n,k,c = map(int,input().split()) s = input() r=[0]*n l=[0]*n ki=0 ci=100000 for i in range(n): ci += 1 if s[i]=='x': continue if ci > c: ci = 0 ki+=1 ...
1
40,396,188,142,114
null
182
182
s = list(input()) f1 = s == list(reversed(s)) f2 = s[:(len(s)-1)//2] == list(reversed(s[:(len(s)-1)//2])) f3 = s[(len(s)+2)//2:] == list(reversed(s[(len(s)+2)//2:])) print("Yes" if all([f1, f2, f3]) else "No")
A = input().split() a = A.count(A[0]) b = A.count(A[1]) c = A.count(A[2]) if a == 2 or b == 2 or c == 2: print("Yes") else: print("No")
0
null
56,989,265,925,482
190
216
N = int(input()) S = input() def alpha2num(alpha): num=0 for index, item in enumerate(list(alpha)): num += pow(26,len(alpha)-index-1)*(ord(item)-ord('A')+1) return num def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) ...
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) def main(): n,k = map(int,input().split()) a = list(map(int,input().split())) cum = [0] * (n + 1) dic = {0:1} ans = 0 for i in range(min(n,k - 1)): cum[i + 1] = (cum[i] + a[...
0
null
136,214,606,505,778
271
273
a = input(); print(int(a.split()[0])*int(a.split()[1]),int(a.split()[0]) * 2 + int(a.split()[1])*2, end="\n")
#coding:utf-8 import sys ab=sys.stdin.readline() rect=ab.split( ' ' ) for i in range(2): rect[i]=int( rect[i]) print( "{} {}".format( rect[0]*rect[1], rect[0]*2+rect[1]*2) )
1
308,958,388,662
null
36
36
a, b = map(int, input().split()) if 1<=a<=9 and 1<=b<=9: print(a*b) else: print(-1)
while 1: try:print input() except:break
0
null
79,476,940,341,348
286
47
a = int(input()) f = False for i in range(1,10): if a % i == 0 and a/i < 10: f = True break if f: print("Yes") else: print("No")
N = int(input()) A = [] for n in range(1,10): for m in range(1,10): A.append(n*m) if N in A: print("Yes") else: print("No")
1
159,402,627,136,830
null
287
287
n = int(input()) a = [int(s) for s in input().split()] if len(set(a)) == n: print("YES") else: print("NO")
def perm(n, k, p): ret = 1 for i in range(n, n-k, -1): ret = (ret * i)%p return ret def comb(n, k, p): a = perm(n, k, p) b = perm(k, k, p) return (a*pow(b, -1, p))%p S = int(input()) ans = 0 S -= 3 t = 0 while S >= 0: ans += comb(S+t,t, 10**9+7) S -= 3 t += 1 print(ans%(10**9+7))
0
null
38,851,887,629,622
222
79
b = [] while True: a = input() k = 0 if a != "0": for i in range(len(a)): k += int(a[i]) b.append(k) else: break for i in range(len(b)): print(b[i])
# ?????????????????°???????????????????¨??????????????????°?????? while 1: # ?¨??????\???????????°??????????????? input_num = list(input()) # ???????????????"0"??\?????§?????? if int(input_num[0]) == 0: break # print(input_num) # ??????????¨?????????????????????° digitTotal...
1
1,594,490,346,760
null
62
62
n, W = map(int, input().split()) ab = [tuple(map(int, input().split()))for _ in range(n)] ab.sort(reverse=True) dp = [0]*W for w, v in ab: for j in reversed(range(W)): if j-w < 0: break if dp[j] < dp[j-w]+v: dp[j] = dp[j-w]+v if dp[0] < v: dp[0] = v print(max(dp)...
N, K = [int(_) for _ in input().split()] P = [int(_) for _ in input().split()] ans = 0.0 k = 0 v = 0.0 for i in range(N): v += (P[i] + 1) / 2 k += 1 if k > K: v -= (P[i-K] + 1) / 2 k -= 1 ans = max(ans, v) print(ans)
0
null
112,930,541,135,270
282
223
def check(p): global k, wlist loadage = 0 num = 1 for w in wlist: loadage += w if loadage > p: num += 1 if num > k: return False loadage = w return True n, k = map(int, input().split()) wlist = [] for _ in range(n): wl...
n, k = map(int, input().split()) l = list(int(input()) for i in range(n)) left = max(l)-1; right = sum(l) while left+1 < right: #最大値と合計値の間のどこかに考えるべき値が存在する mid = (left + right) // 2 cnt = 1; cur = 0 #初期化 for a in l: if mid < cur + a: cur = a cnt += 1 else: ...
1
88,406,860,398
null
24
24
h1, m1, h2, m2, k = [int(_) for _ in input().split()] print((h2 - h1) * 60 + m2 - m1 - k)
from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) h1,m1,h2,m2,k=nii() minute=(h2-h1)*60 minute+=m2-m1 minute-=k print(minute)
1
18,138,435,704,860
null
139
139
S = input() f = S[0] if S.count(f) == 3 : print('No') else : print('Yes')
from decimal import Decimal X=int(input()) c =Decimal(100) C=0 while c<X: c=Decimal(c)*(Decimal(101))//Decimal(100) C+=1 print(C)
0
null
40,913,215,941,924
201
159
MAX = 2*10**6 MOD = 10**9+7 fac = [0] * (MAX) finv = [0] * (MAX) inv = [0] * (MAX) def comb_init(): fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 inv[1] = 1 for i in range(2, MAX): fac[i] = fac[i-1] * i % MOD inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD finv[i] = finv[i-1] * inv[i]...
K = int(input()) S = input() m = 1000000007 result = 0 t = pow(26, K, m) u = pow(26, m - 2, m) * 25 % m l = len(S) for i in range(K + 1): # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m) result = (result + t) % m t = (t * u) % m * (l + i) % m * pow(i + 1, m - 2, m) % m print(result...
1
12,718,782,609,788
null
124
124
from itertools import combinations while True: n,m=map(int,input().split()) if n==m==0: break print(sum(1 for p in combinations(range(1,n+1),3) if sum(p)==m))
import sys while True: n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ] if 0 == n and 0 == x: break cnt = 0 ave = x // 3 for i in range( 1, ave ): ave2 = (x-i) // 2 for j in range( i+1, ave2+1 ): k = x-i-j if j < k and k <= n: cnt += 1 print( cnt )
1
1,296,340,537,952
null
58
58
import sys from collections import deque import numpy as np import math sys.setrecursionlimit(10**6) def S(): return sys.stdin.readline().rstrip() def SL(): return map(str,sys.stdin.readline().rstrip().split()) def I(): return int(sys.stdin.readline().rstrip()) def IL(): return map(int,sys.stdin.readline().rstrip().spl...
n = int(input()) s = [input() for i in range(n)] c0 = 0 c1 = 0 c2 = 0 c3 = 0 for i in range(len(s)): if s[i] == "AC": c0 += 1 elif s[i] == "WA": c1 += 1 elif s[i] == "TLE": c2 += 1 else: c3 += 1 print("AC x ", str(c0)) print("WA x ", str(c1)) print("TLE x ", str(c2)) p...
0
null
94,779,768,121,532
299
109
a = range(1, 10) [print('{}x{}={}'.format(i, j, i * j)) for i in a for j in a]
from collections import defaultdict N = int(input()) *A,=map(int,input().split()) ''' 方針: - 各A_i,(i<h)ごとにf(h,j)=A_h+A_j-|h-j|の値がf(i,j)に比べてどれだけ変化するかを計算し、 リストに格納(①) - 各要素A_k,(j<k)ごとにf(i,k)=A_i+A_k-|i-k|の値がf(i,j)に比べてどれだけ変化するかを 計算し、カウントをとる(②) - 再度ループを回して①と②を照合し、値が一致する組数をansに加算 ''' ans=0 diff_list=[] #①照合用の差分リスト count=de...
0
null
13,029,302,144,992
1
157
import time n, k = map(int, input().split()) w = [0] * n for i in range(n): w[i] = int(input()) def check(p): remain_track = k - 1 remain_p = p for a in range(n): if w[a] > p: return False if remain_p >= w[a]: remain_p -= w[a] else: if remain...
def prime_factors(n): d = {} while n%2 == 0: d[2] = d.get(2, 0) + 1 n //= 2 i = 3 while i*i <= n: while n%i == 0: d[i] = d.get(i, 0) + 1 n //= i i += 2 if n > 2: d[n] = d.get(n, 0) + 1 return d MOD = 10**9+7 N = int(input()) A = li...
0
null
43,792,937,956,194
24
235
n,m=map(int,input().split()) h=list(map(int,input().split())) AB=[list(map(int,input().split())) for _ in range(m)] from math import gcd ans=[1 for _ in range(n)] for ab in AB: if h[ab[0]-1]>h[ab[1]-1]: ans[ab[1]-1]=0 elif h[ab[0]-1]<h[ab[1]-1]: ans[ab[0]-1]=0 else: ans[ab[0]-1]=0 ...
def insertionSort(arr,step): count = 0 for i in range(step, len(arr)): j = i while j >= step and arr[j] < arr[j-step]: count += 1 t = arr[j] arr[j] = arr[j-step] arr[j-step] = t j -= step return count def shellSort(arr): gaps ...
0
null
12,459,529,245,280
155
17
n = int(input()) s = input() cnt = 0 for i in range(1000): c = [i // 100, (i // 10) % 10, i % 10] f = 0 for j in range(n): if s[j] == str(c[f]): f+=1 if f == 3: break if f == 3: cnt += 1 print(cnt)
import re array = [] lines = [] count = 0 while True: n = input() if n == "-": break array.append(n) for i in range(len(array)): if re.compile("[a-z]").search(array[i]): fuck = i+1 if count > 0: lines.append(stt) count += 1 stt = array[i] else: ...
0
null
65,583,740,792,780
267
66
X=int(input()) a=int(X/500) s=1000*a X-=500*a b=int(X/5) s+=5*b print(s)
a,b,c = map(int, raw_input().split()) if a > b: temp = a a = b b = temp if b > c: temp = b b = c c = temp if a > b: temp = a a = b b = temp print a,b,c
0
null
21,698,147,894,610
185
40
x = list(input().split()) for i in range(5): # logging.debug("i = {},x[i] = {}".format(i, x[i])) # if x[i] == "0": print(i + 1) exit() # logging.debug("n = {},f = {},f**b = {}".format(n, f, f**b)) # #logging.debug("デバッグ終了")#
l = [int(x) for x in input().split()] anser = 0 for i in l: anser += 1 if i == 0: print(anser)
1
13,430,140,627,424
null
126
126
N=int(input()) A=list(map(int,input().split())) sumA=0 sumB=[0] for i in range(N): sumB.append(sumB[i]+A[i]) i=i+1 for j in range(N-1): sumA=sumA+(A[j]*(sumB[N]-sumB[j+1]))%(10**9+7) j=j+1 print(sumA%(10**9+7))
N=int(input()) A=list(map(int,input().split())) c=0 for i in range(N): c=c+A[i]**2 print((sum(A)**2-c)//2%(10**9+7))
1
3,834,044,225,680
null
83
83
l = int(input()) x = l/3 ans = x**3 print(str(ans))
def factorization(n): if n==1: return [[1,1]] temp=n ans=[] for i in range(2, int(n**0.5+1.01)): if temp % i ==0: ct=0 while temp % i == 0: temp //= i ct += 1 ans.append([i, ct]) if temp != 1: ans.append([tem...
0
null
31,782,773,358,820
191
136
input_line = input() a,b = input_line.strip().split(' ') a = int(a) b = int(b) if a < b: print("a < b") elif a > b: print("a > b") elif a == b: print("a == b")
import math n = int(input()) def koch(n, p1_x, p2_x, p1_y, p2_y): if n == 0: return s_x = (2*p1_x + p2_x) / 3 s_y = (2*p1_y + p2_y) / 3 t_x = (p1_x + 2*p2_x) / 3 t_y = (p1_y + 2*p2_y) / 3 u_x = (t_x - s_x)/2 - (t_y - s_y) * math.sqrt(3)/2 + s_x u_y = (t_x - s_x) * math.sqrt(3)/2 + (t_y - s_y)/2 ...
0
null
241,172,241,728
38
27
n = int(input()) A = list(map(int,input().split())) dp = [[[0,0,0] for i in range(2)] for i in range(n+1)] for i in range(1,n+1): if i%2 == 1: if i > 1: dp[i][0][1] = dp[i-1][1][0]+A[i-1] dp[i][0][2] = dp[i-1][1][1]+A[i-1] dp[i][1][0] = max(dp[i-1][0][0],dp[i-1][1][0]) ...
from math import * from collections import * N, D, A = list(map(int, input().split())) ans = 0 t = 0 q = deque() XH = sorted([list(map(int, input().split())) for i in range(N)]) for x, h in XH: if q: while q and q[0][0] < (x-D): _, c = q.popleft() t -= c h = h - t * A ...
0
null
59,582,512,410,850
177
230
def make_bit(n): bit = [] for i in range(2**n): bit.append(bin(i)[2::]) i = 0 while i < len(bit): while len(bit[i]) < len(bin(2**n-1)[2::]): bit[i] = "0" + bit[i] i += 1 return bit h, w, k = map(int, input().split()) c = [list(input()) for _ in range(h)] h_pat...
def trans(l): return [list(x) for x in list(zip(*l))] from itertools import product import copy h, w, k = map(int, input().split()) c = [] for _ in range(h): c.append([c for c in input()]) A = [i for i in product([1,0], repeat=h)] B = [i for i in product([1,0], repeat=w)] ans = 0 for a in A: temp1 = cop...
1
8,834,000,927,960
null
110
110
def divisor(n): ret=[] for i in range(1,int(n**0.5)+1): if n%i==0: a,b=i,n//i if a!=b: ret+=a, ret+=b, else: ret+=a, return sorted(ret) def f(n): return divisor(n)[1:] def solve(n): ans=f(n-1) for k in f(n): N=n while N>=k: if N%k==0:N=N//k ...
n = int(input()) print(pow(n, 3))
0
null
20,693,592,161,240
183
35
n = input() friendliness = [int(item) for item in input().split()] friendliness.sort() def of_ans(): sum_ = 0 idx = 1 while idx < len(friendliness): sum_ += friendliness[len(friendliness) - (idx // 2) - 1] idx += 1 return sum_ print(of_ans())
n, k = map(int, input().split()) nums = list(map(int, input().split())) # (sums[j] - sums[i]) % K = j - i # (sums[j] - j) % K = (sums[i] - i) % K # 1, 4, 2, 3, 5 # 0, 1, 5, 7, 10, 15 # 0, 0, 3, 0, 2, 2 sums = [0] for x in nums: sums.append(sums[-1] + x) a = [(sums[i] - i) % k for i in range(len(sums))] res = 0 m...
0
null
73,458,347,923,440
111
273
a,b=map(int,input().split()) print("Yes" if (a*500>=b) else "No")
a, b = map(int, input().split()) if a < b: print('a < b') elif a == b: print('a == b') else: print('a > b')
0
null
49,482,266,529,588
244
38
a = range(1, 10) [print('{}x{}={}'.format(i, j, i * j)) for i in a for j in a]
case = 1 x = input() while(x!=0): print "Case %d: %d" % (case, x) x = input() case += 1
0
null
240,758,029,252
1
42
N, *AB = map(int, open(0).read().split()) A = sorted(a for a in AB[::2]) B = sorted(b for b in AB[1::2]) if N % 2: print(B[N // 2] - A[N // 2] + 1) else: print(B[N // 2 - 1] + B[N // 2] - A[N // 2 - 1] - A[N // 2] + 1)
import sys readline = sys.stdin.readline N = int(readline()) A = [] B = [] for _ in range(N): a, b = map(int, readline().split()) A.append(a) B.append(b) A.sort() B.sort() if N % 2 == 0: mi = A[N//2-1]+A[N//2] ma = B[N//2-1]+B[N//2] else: mi = A[N//2] ma = B[N//2] print(ma-mi+1)
1
17,398,490,635,560
null
137
137
n,k = map(int,input().split()) a = list(map(int,input().split())) si = [0 for i in range(n+1)] p = [1 for i in range(n)] import copy for q in range(min(k,50)): v = 0 s = copy.deepcopy(si) for i in range(n): if a[i] != 0: s[max(i-a[i],0)] += 1 s[min(i+a[i]+1,n)] -= 1 ...
n,k=map(int,input().split()) a=list(map(int,input().split())) for l in range(k): if a==[n]*n: break imos = [0]*(n+1) for i in range(n): imos[max(0,i-a[i]) ]+=1 imos[min(n-1,i+a[i])+1 ]-=1 a=[0]*n a[0]=imos[0] for i in range(1,n): a[i] = a[i-1]+imos[i] print(*a...
1
15,470,751,154,858
null
132
132
input() A = list(map(int, input().split())) sum_list = sum(A) sum_of_product = 0 for i in A: sum_list -= i sum_of_product = ((sum_list * i) % (10 ** 9 + 7) + sum_of_product) % (10 ** 9 + 7) print(sum_of_product)
N = int(input()) def kccv(a, b, c, d): return [a*2/3 + c/3, b*2/3 + d/3, a/2 + b*(3**0.5)/6 + c/2 - d*(3**0.5)/6, -a*(3**0.5)/6 + b/2 + c*(3**0.5)/6 + d/2, a/3 + c*2/3, b/3 + d*2/3] ans = [[[0,0],[100,0]]] for i in range(1,N+1): m = len(ans[i-1]) newset = [] for j in range(m-1): newset.append...
0
null
1,988,464,660,100
83
27
from itertools import permutations as perm N = int(input()) XYS = [list(map(int, input().split())) for _ in range(N)] s = 0 for indexes in perm(list(range(N))): xys = [XYS[i] for i in indexes] x0, y0 = xys[0] for x1, y1 in xys: s += ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5 x0 = x1 y0 = ...
import sys sys.setrecursionlimit(10 ** 9) 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 = s...
0
null
105,159,293,152,228
280
209
h, n = map(int, input().split()) a = list(map(int, input().split())) a_sum = sum(a) if h <= a_sum: print('Yes') else: print('No')
n = int(input()) A = list(map(int,input().split())) b = 1 B=[0]*(n+1) count = 0 t=len(A)-1 for i in range(t): B[i] = b if 2*(b - A[i]) < A[i+1]: count += 1 break b = 2*(b - A[i]) B[n] = b if n == 0 and A[0] > 1: count += 1 j = 0 while count == 0 and A[t] > B[j]: if j == n: ...
0
null
48,630,908,412,610
226
141
from collections import defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue, copy, time from fractions import gcd import numpy as np sys.setrecursionlimit(10**8) INF = float('inf') MOD = 10**9+7 EPS = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin....
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): N = int(readline()) L = [int(i) for i in readline().split()] #まず三角形ができる組みを考える #三重ループでも間に合うので三重ループを回す L.sort() cnt = 0 for i in range(N): for j in range(i+...
1
5,067,655,760,740
null
91
91
import math from math import gcd INF = float("inf") import sys input=sys.stdin.readline import itertools from collections import Counter def main(): n = int(input()) p = list(map(int, input().split())) min = p[0] cnt = 0 for i in p: if i <= min: cnt += 1 min = i ...
import numpy as np def divisors(N): return sorted(sum((list({n, N // n}) for n in range(1, int(N ** 0.5) + 1) if not N % n), [])) def prime_factorize_dict(n): d = dict() while not n & 1: d[2] = d.get(2, 0) + 1 n >>= 1 f = 3 while f * f <= n: if not n % f: d[f] =...
0
null
63,564,329,838,780
233
183
n,m,X=map(int,input().split()) c=[list(map(int,input().split())) for i in range(n)] ans=float('inf') from itertools import combinations as com for l in range(1,n+1): for i in com(list(range(n)),r=l): cnt=[0]*m p=0 for j in i: p+=c[j][0] for x in range(m): ...
N = int(input()) a = list(map(int, input().split())) print(sum((i + 1) % 2 == 1 and a[i] % 2 == 1 for i in range(N)))
0
null
15,041,620,324,060
149
105
N, L = int(input()), [int(v) for v in input().split()] L.sort() ans = 0 for i in range(N): for j in range(i): for k in range(j): if L[k] != L[j] and L[j] != L[i] and L[k] + L[j] > L[i]: ans += 1 print(ans)
import itertools n = int(input()) l = list(map(int, input().split())) c = list(itertools.combinations(l, 3)) ans = 0 for i in c: j = sorted(i) if j[0] != j[1] != j[2] != j[0]: if j[2] < j[0]+j[1]: ans += 1 print(ans)
1
5,046,582,618,012
null
91
91
x = [int(x) for x in input().split()] if (x[1]<x[0]): print("safe") else: print("unsafe")
N, M = [int(n) for n in input().split()] solved = {} result = {} for i in range(M): p, S = input().split() status = result.setdefault(p, []) if len(status)==0: result[p] = [] solved[p] = False if S == 'AC': solved[p] = True result[p].append(S) ans = 0 wa = 0 for k, v in sol...
0
null
61,137,403,422,020
163
240
import math n = int(input()) f = list(map(int,input().split())) f.sort() ans = 0 for i in range(1,n): ans += f[n-math.floor(i/2)-1] print(ans)
from sys import stdin N = int(stdin.readline().rstrip()) A = [int(x) for x in stdin.readline().rstrip().split()] max_node = [0] * (N+1) for i in range(N-1,-1,-1): max_node[i] = max_node[i+1]+A[i+1] ans = 1 node = 1 for i in range(N+1): node -= A[i] if (i < N and node <= 0) or node < 0: print(-1) ...
0
null
13,988,591,826,468
111
141
n = int(input()) maxv = -20000000000 minv = int(input()) for i in range(n-1): R = int(input()) maxv = max(maxv, R - minv) minv = min(minv, R) print(maxv)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: map(int, readline().split()) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: map(int, read().split()) in_s = lambda: readline().rstrip().decode('utf-8') def main(): N = ...
0
null
77,174,289,960,740
13
284
while True: n, x = map(int, input().split()) if n == 0 and x == 0: break else: counter = 0 for a in range(1,(x // 3)): for c in range ((x//3)+1,n+1): b = x - a - c if a < b < c: counter += 1 print(counter)
while True: n, x = map(int, raw_input().split(" ")) if n==x==0: break ans = 0 for a in range(1, n-1): for b in range(a+1, n): for c in range(b+1, n+1): if a+b+c == x: ans += 1 break print ans
1
1,261,933,015,068
null
58
58
n, r = [int(i) for i in input().split()] ans = r if n >= 10 else r + 100 *(10 - n) print(ans)
import math def abs(num): if num < 0: return -num return num def main(): abhm = [int(_x) for _x in input().split()] HL = abhm[0] ML = abhm[1] H = abhm[2] M = abhm[3] radian = 2.0 * math.pi * abs(M / 60.0 - (H + M / 60.0) / 12.0) length = math.sqrt(HL * HL + ML * ML - 2 ...
0
null
42,025,267,432,710
211
144
def print_chessboard(h, w): """ h: int w: int outputs chessboard using '#' and '.' >>> print_chessboard(3, 4) #.#. .#.# #.#. >>> print_chessboard(5, 6) #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. >>> print_chessboard(2, 2) #. .# """ for i in range(h): ...
from numpy import cumsum n,m=map(int,input().split()) a=list(map(int,input().split())) result=cumsum(a)[-1] mi=result/(4*m) ans=0 for i in range(n): if a[i]>=mi: ans+=1 if ans>=m: print('Yes') else: print('No')
0
null
19,684,366,274,840
51
179
#!/usr/bin/env python3 N = int(input()) if N % 2 == 1: print(0) else: ret = 0 for i in range(1, 27): ret += N // (2*5**i) print(ret)
# 23-Structure_and_Class-Dice_I.py # ???????????? I # ?¬?????±??????????????????????????????????????????¢??????????????\??¬????????§????????????????????°???????????????????????????????????? # ????????????????????¢??????????????¨????????? 1 ?????? 6 ???????????????????????????????????????????????? # ??\?????¨?????????...
0
null
58,403,724,293,562
258
33
import sys # import re # import math # import collections # import decimal # import bisect # import itertools # import fractions # import functools # import copy # import heapq # import decimal # import statistics import queue sys.setrecursionlimit(10000001) INF = 10 ** 16 MOD = 10 ** 9 + 7 ni = lambda: int(sys.stdi...
import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline N = int(input()) graph = [[] for _ in range(N)] ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N-1)] d = {} for a, b in ab: graph[a] += [b] graph[b] += [a] def dfs(u, pre, c): color = 0 for v in graph[u]: if v != p...
1
135,704,858,768,348
null
272
272
h, a = list(map(int, input().split(' '))) ans = 0 while h > 0: h -= a ans += 1 print(ans)
import math print reduce(lambda a, b: int(math.ceil(a * 1.05 / 1000)) * 1000, range(input()), 100000)
0
null
38,673,301,171,470
225
6
i=list(map(int,input().split())) x=[[0,1],[0,2],[1,2]] for a in range(3): if( i[ x[a][0] ] > i[ x[a][1] ]): swap=i[ x[a][0] ] i[ x[a][0] ]= i[ x[a][1] ] i[ x[a][1] ]=swap print(i[0],end=' ') print(i[1],end=' ') print(i[2],end='\n')
a = list(map(int, input().split())) a.sort() print(a[0], a[1], a[2])
1
424,805,850,250
null
40
40
S = input() flag = 0 for i in range(0,len(S)//2): if S[i] == S[-1-i]: continue else: flag = 1 print("No") break if flag == 0: S = S[:((len(S)-1)//2)] for i in range(0,len(S)//2): if S[i] == S[-1-i]: continue else: flag = 1 ...
import sys from functools import reduce from math import gcd read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines mod = 10 ** 9 + 7 N = int(readline()) A = list(map(int,readline().split())) lcm = reduce(lambda x,y:x*y//gcd(x,y),A) ans = 0 coef = sum(pow(x,mod-2,mod) ...
0
null
67,188,864,935,700
190
235
S = input() N = len(S) ans = 'No' # 文字列strの反転は、str[::-1] if S == S[::-1] and S[:(N-1)//2] == S[:(N-1)//2][::-1] and S[(N+1)//2:] == S[(N+1)//2:][::-1]: ans = 'Yes' print(ans)
n=int(input()) a=list(map(int,input().split())) sum_a=sum(a) x=0 i=0 while x<sum_a/2: x+=a[i] i+=1 if n%2==0: print(min(x-(sum_a-x),sum_a-(x-a[i-1])*2)) else: print(x-(sum_a-x))
0
null
94,484,824,525,478
190
276
while True: H,W = map(int,input().split()) if H == 0 and W == 0 : break line = ['#.'*(W // 2)+'#'*(W % 2),'.#'*(W // 2)+'.'*(W % 2)] for i in range(H) : print(line[i % 2]) print()
target = input() now_height = [] now_area = [0] answer = [] continued = 0 depth = 0 depth_list = [] for t in target: # print(now_height,depth_list,now_area,answer,continued) if t == '\\': now_height.append(continued) depth_list.append(depth) now_area.append(0) depth -= 1 elif...
0
null
474,249,274,772
51
21
import sys n=int(input()) ans=[0]*(n+1) MOD=998244353 a=list(map(int,input().split())) if a[0]!=0: print(0) sys.exit() for i in range(n): ans[a[i]]+=1 if ans[0]!=1: print(0) sys.exit() fin=1 for i in range(1,max(a)+1): fin=(fin*pow(ans[i-1],ans[i],MOD))%MOD print(fin)
#入力 n, u, v = map(int, input().split()) mapdata = [list(map(int,input().split())) for _ in range(n-1)] #グラフ作成 graph = [[] for _ in range(n+1)] for i, j in mapdata: graph[i].append(j) graph[j].append(i) #探索 def dfs(v): dist = [-1] * (n + 1) stack = [v] dist[v] = 0 while stack: v = stack.pop() dw = ...
0
null
136,343,929,509,172
284
259
n,a,b=map(int,input().split()) if a%2==b%2: c=(b-a)//2 if (c+1)*2<=b-a: c+=1 print(c) else: t=min(b-1+a,n-a+n-b+1) c=t//2 if (c+1)*2<=t: c+=1 print(c)
a = [] for i in range(10): a.append(int(raw_input())) a.sort() a.reverse() for i in range(3): print a[i]
0
null
54,452,876,621,180
253
2
# A**5 = X + B**5 X = int(input()) l = [] for i in range(-300, 300): l.append(i**5) for b, b_5 in enumerate(l, start=-300): # print(b, b_5, X) if X+b_5 in l: a_5 = X+b_5 a = l.index(a_5)-300 print(a, b) break
import sys x = int(input()) box = [a**5 for a in range(0,200)] for i in range(200): for j in range(200): if box[i] - box[j] == x: print(i,j) sys.exit() for k in range(200): for l in range(200): if (-1)*box[k] + box[l] == x: print(-(k),-(l)) sys.exi...
1
25,649,122,683,478
null
156
156
import numpy as np def check_pali(S): for i in range(0, len(S)): if S[i] != S[-1 * i + -1]: return False elif i > (len(S) / 2) + 1: break return True S = input() N = len(S) short_N = (N - 1) // 2 long_N = (N + 3) // 2 if check_pali(S) & check_pali(S[0:short_N]) ...
S=input() N=len(S) s=''.join(list(reversed(S))) T=S[0:int((N-1)/2)] NT=len(T) t=''.join(list(reversed(T))) U=S[int((N+1)/2):N] NU=len(U) u=''.join(list(reversed(U))) if S[0:int((N-1)/2)] == s[0:int((N-1)/2)] and T == t and U == u: print('Yes') else: print('No')
1
46,593,726,622,862
null
190
190
K = int(input()) import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) ans = 0 for i in range(1,K+1): for j in range(1,K+1): for k in range(1,K+1): ans += (gcd(i,j,k)) print(ans)
k = int(input()) ans = 0 def gcd(a,b): if a % b == 0: return b c = a % b return gcd(b,c) for l in range(1,k+1): for m in range(l,k+1): for n in range(m,k+1): tmp1 = gcd(l,n) tmp2= gcd(tmp1,m) if (l==m==n): ans+=tmp2 elif(l=...
1
35,393,986,423,548
null
174
174
while 1: a, b = [int(x) for x in input().split()] if a == 0 and b == 0: break if a > b: a, b = b, a print(a, b)
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def isprime(n): if n == 2: return True elif n < 2 or n % 2 == 0: return False else: for i in range(3, math.floor(math.sqrt(n)) + 1, 2): if n % i == 0: return False else: retur...
0
null
274,301,961,520
43
12
n = int(input()) l = list(map(int, input().split())) ans=0 for i in range(n): for j in range(i+1,n): for k in range(j+1,n): li = [l[i], l[j], l[k]] m = max(li) if 2*m < sum(li) and len(set(li)) == 3: ans += 1 print(ans)
N = int(input()) L = [int(i) for i in input().split()] count = 0 L.sort() for i in range(N) : for j in range(i+1,N) : for k in range(j+1,N) : if L[i]!=L[j]!=L[k]: if ((L[i]+L[j]>L[k]) and (L[j]+L[k]>L[i]) and (L[i]+L[k]>L[j])) : count += 1 pr...
1
4,981,706,219,532
null
91
91
k = int(input()) a,b = map(int, input().split()) if (int(b/k)*k >= a): print("OK") else: print("NG")
def main(): K = int(input()) A, B = map(int, input().split()) for i in range(A, B+1): if i % K == 0: print("OK") return print("NG") main()
1
26,554,033,569,222
null
158
158
a, b, k = map(int, input().split()) print(a - min(a, k), b - min(b, k - min(a, k)))
n= int(input()) arr = [int(x) for x in input().strip().split()] def Greedy(arr): curr = 1000 for i in range(len(arr)-1): if arr[i+1]>arr[i]: stocks = curr // arr[i] curr += (arr[i+1] - arr[i])*stocks return curr print(Greedy(arr))
0
null
55,649,843,749,072
249
103
n = input() str_n = list(n) if str_n[-1] == "3": print("bon") elif str_n[-1] == "0" or str_n[-1] == "1" or str_n[-1] == "6" or str_n[-1] == "8": print("pon") else: print("hon")
n, k = map(int, input().split()) t = n // k re = n - t * k if abs(re - k) < re: re = abs(re - k) i = True print(re)
0
null
29,466,294,110,110
142
180
for num1 in range(1,10): for num2 in range(1,10): i = num1 * num2 print(str(num1) + "x" + str(num2) + "=" + str(i))
def run(): for i in range(1,10): for j in range(1,10): print('{0}x{1}={2}'.format(i,j,i*j)) if __name__ == '__main__': run()
1
1,203,470
null
1
1
a, b = map(int, input().split()) if a < b: a, b = b, a while a % b != 0: a, b = b, a % b print(b)
# C - Sqrt Inequality import decimal a,b,c = input().split() a,b,c = map(decimal.Decimal,[a,b,c]) sqrt = decimal.Decimal(0.5) if a**sqrt + b**sqrt < c**sqrt: print('Yes') else: print('No')
0
null
25,825,870,328,960
11
197
def ex_euclid(a, b): x0, x1 = 1, 0 y0, y1 = 0, 1 z0, z1 = a, b while z1 != 0: q = z0 // z1 z0, z1 = z1, z0 % z1 x0, x1 = x1, x0 - q * x1 y0, y1 = y1, y0 - q * y1 return z0, x0, y0 def mod_inv(a, n): g, x, _ = ex_euclid(a, n) if g != 1: print("modular inverse does not exist") e...
import sys import itertools # import numpy as np import time import math sys.setrecursionlimit(10 ** 7) from collections import defaultdict read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X, Y = map(int, input().split()) if (X + Y) % 3 != 0: print(0) ...
1
149,849,834,063,160
null
281
281
def BubbleSort(C, N): for i in range(N): for j in range(N-1, i, -1): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def SelectionSort(C, N): for i in range(N): minj = i for j in range(i, N): if C[j][1] < C[minj][1]: ...
#coding:utf-8 from copy import deepcopy n = int(input()) A = list(input().split()) B = deepcopy(A) def BubbleSort(A,N): for i in range(N): for j in range(N-1,i,-1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] def SelectionSort(A,N): for i in range(N): min...
1
24,688,824,358
null
16
16
# encoding:utf-8 while True: a,op,b = map(str, input().split()) c = int(a) d = int(b) if op == '+': result = c + d if op == '-': result = c - d if op == '*': result = c * d if op == '/': result = int(c / d) if op == '?': break print("{0}".format(result))
while True: a,op,b=input().split(" ") a,b=[int(i) for i in (a,b)] if op=="+": print(a+b) elif op=="-": print(a-b) elif op=="*": print(a*b) elif op=="/": print(int(a/b)) else: break
1
676,863,422,158
null
47
47
import sys def log(s): # print("| " + str(s), file=sys.stderr) pass def output(x): print(x, flush=True) def input_ints(): return list(map(int, input().split())) def main(): f = input_ints() print(f[0] * f[1]) main()
A, B, N = map(int, input().split()) if N >= B - 1: print(int(A * (B - 1) / B)) else: print(int(A * N / B))
0
null
22,029,344,927,614
133
161
N, M = map(int, input().split()) A = list(map(int, input().split())) cnt = 0 total = sum(A) for a in A: if a >= total / (4*M): cnt += 1 ans = 'Yes' if cnt >= M else 'No' print(ans)
def f(s,n): res = 0 flg = False for i in range(1,n): if flg: flg = False continue if S[i] == S[i-1]: flg = True res += 1 return res S = input() K = int(input()) if len(set(list(S))) == 1: print(len(S)*K//2) exit() ans = f(S,len(S)) ...
0
null
107,202,644,616,848
179
296
n=input().rstrip().split(" ") w=int(n[0]) l=int(n[1]) print(w*l, 2*w+2*l)
inArray = input().split(' ') length = int(inArray[0]) width = int(inArray[-1]) area = str(length * width) circuit = str((length * 2) + (width * 2)) print(area + " " + circuit)
1
311,790,799,008
null
36
36
N,K = map(int,input().split()) A = list(map(int,input().split())) MOD = 10**9+7 if all(a>=0 for a in A): A.sort() ans = 1 for _ in range(K): ans *= A.pop() ans %= MOD print(ans) exit() if all(a<0 for a in A): A.sort(reverse=K%2==0) ans = 1 for _ in range(K): ans ...
val = input() if val[2:3] == val[3:4] and val[4:5] == val[5:6]: print("Yes") else: print("No")
0
null
25,643,272,869,188
112
184
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
24