input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
X = int(eval(input())) ans = 0 for i in range(1, 10 ** 5): if X <= i * (i + 1) // 2: break print(i)
X = int(eval(input())) cnt = 0 for i in range(0, 10 ** 9 + 1): cnt += i if cnt >= X: ans = i break print(ans)
p03779
X = int(eval(input())) len = 0 flag = False for i in range(1,X+1): if flag: break for j in range(i): len += 1 if len >= X: flag = True ans = i break print(ans)
import math X = int(eval(input())) print((math.ceil((-1+(8*X+1)**(1/2))/2)))
p03779
num = int(eval(input())) i = 1 while True: bef = sum(range(1,i)) i += 1 aft = sum(range(1,i)) if bef < num <= aft: print((i-1)) break
num = int(eval(input())) i = 1 bef = 0 while True: bef += i-1 aft = bef + i if bef < num <= aft: print(i) break i += 1
p03779
from collections import deque N = int(eval(input())) Q = deque() Q.append(0) i = 1 f = False while Q: Q2 = Q Q = [] for t in Q2: if t+i == N or t-i == N: print (i) f = True break Q.append(t-i) Q.append(t) Q.append(t+i) if f: break i += 1
import math X = int(eval(input())) t = math.ceil((-1 + (1 + 8 * X) ** 0.5)/2) print (t)
p03779
x = int(eval(input())) d = {0: None} i = 0 while(True): flag = False i += 1 d_keys = list(d.keys()) for di in d_keys: xx = [di - i, di + i] if x in xx: flag = True break else: d[xx[0]] = None d[xx[1]] = None if fl...
x = int(eval(input())) xx = 0 i = 1 while(True): xx += i if xx >= x: print(i) break else: i += 1
p03779
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline X = int(eval(input())) ans = float('inf') def bfs(s, g): Q = [[s, 0]] while Q: p = Q.pop(0) time = p[1] cur = p[0] if abs(cur) > X: continue ...
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline X = int(eval(input())) ans = float('inf') pos = 0 time = 0 while pos < X: time += 1 pos = (time)*(time+1)//2 diff = pos - X print(time)
p03779
X = int(eval(input())) ans = pow(10, 9) for t in range(X + 1): if t*(t+1) / 2 >= X and t < ans: ans = t print(ans)
X = int(eval(input())) ans = pow(10, 9) for t in range(X + 1): if t*(t+1) / 2 >= X and t < ans: ans = t break print(ans)
p03779
def main(): x=int(eval(input())) ans=abs(x) L=[0] for i in range(1,10**9): P=L[:] for l in L: P.append(l+i) P.append(l-i) if x in P: print(i) break L=P[:] main()
def main(): x=int(eval(input())) for i in range(1,10**9): if x>i*(i+1)//2: continue print(i) break main()
p03779
import queue q = queue.Queue() x = int(eval(input())) start_position = 0 start_time = 0 def k(): while q.not_empty: position, time = q.get() if position == x: return time else: q.put((position - (time + 1), time + 1)) q.put((position + ...
x = int(eval(input())) podition_range = 0 time = 0 i = 0 while True: if - podition_range <= x <= podition_range: print(time) break else: i += 1 time += 1 podition_range += time
p03779
import queue x = int(eval(input())) q = queue.Queue() q.put((0,0)) d = dict() d[0] = 0 while not q.empty(): s,t = q.get() if s==x: break if not d.__contains__(s-(t+1)): q.put((s-(t+1),t+1)) d[s-(t+1)]=t+1 if not d.__contains__(s+t+1): q.put((s+t+1,t+1)) ...
x = int(eval(input())) s = 0 i = 0 for i in range(1,10**9): s += i if s>=x: break print(i)
p03779
from sys import stderr, setrecursionlimit from functools import reduce from operator import add from math import sqrt, ceil setrecursionlimit(2147483647) def f(): return [int(i) for i in input().split()] def debug(*x, sep=" ", end="\n"): for item in x: stderr.write(str(item)) stderr.write(s...
import math;print((math.ceil((-1+(1+8*int(eval(input())))**(1/2))/2)))
p03779
#!/usr/bin/env python3 n = int(eval(input())) for i in range(10**5): if n <= i*(i+1)/2: print(i) break
#!/usr/bin/env python3 n = int(eval(input())) #for i in range(10**5): for i in range(int((2*n)**(1/2))-1,int((2*n)**(1/2))+2) : if n <= i*(i+1)/2: print(i) break
p03779
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs= sys.stdin.buffer.readlines #rstrip().decode('utf-8') #import numpy as np #import operator import bisect #from heapq import heapify,heappop,heappush #from math import gcd #from fractions import gcd #from collections import deq...
import sys input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(eval(input())) def FI(): return int(eval(input())) def MI(): return list(map(int,input().split())) def MF(): return list(map(float,input...
p03779
import queue if __name__ == "__main__": X = int(eval(input())) q = queue.Queue() qq = queue.Queue() q.put((0, 0)) while True: x, t = q.get() if x == X : print(t) break t += 1 q.put((x, t)) q.put((x+t, t)) q.put((...
if __name__ == "__main__": X = int(eval(input())) s = 0 i = 0 while True: s += i if s >= X: print(i) break i += 1
p03779
# ABC 056 C X =int(eval(input())) L = [int(i) for i in range(X+1)] from itertools import accumulate for ind,val in enumerate(list(accumulate(L))): if val >=X: print(ind) exit()
# ABC 056 C X =int(eval(input())) for t in range(10**9): if t * (t+1)/2 >=X: print(t) exit()
p03779
X = int(eval(input())) ans = 0 loc = 0 while loc < X: ans += 1 for i in range(ans): loc += 1 print(ans)
X = int(eval(input())) ans, loc = 0, 0 while loc < X: ans += 1 loc = ans/2 * (ans+1) print(ans)
p03779
X = int(eval(input())) t = 1 max_t = (t* (t+1)) // 2 # t=1で1 t=2で 2,3 t= 3で 4, 5, 6 t=4で 7,8,9,10 t=5で 11,12,13,14,15までいける while max_t < X: t += 1 max_t = (t* (t+1)) // 2 print(t)
x = int(eval(input())) check = 0 for i in range(1, 1+x): check += i if check >= x: print(i) break
p03779
X = int(eval(input())) for i in range(1, 10**6): if X <= 0.5 * i * (i + 1): print(i) break
X = int(eval(input())) ans = 0 check = 0 for i in range(1, 10**7): ans += i check += 1 if X <= ans: print(check) break
p03779
X = int(input().strip()) states = {0} for i in range(1,X+1): next_set = {s+i for s in states} if X in next_set: print(i) break states |= next_set
X = int(input().strip()) now_max = 0 for i in range(1,X+1): now_max += i if X <= now_max: print(i) break
p03779
import sys input = sys.stdin.readline def main(): n = int(eval(input())) for i in range(n+1): if i * (i+1) / 2 >= n: print(i) return main()
import sys input = sys.stdin.readline def main(): n = int(eval(input())) for i in range(n+1): if i * (i+1) / 2 >= n: yield i print((next(main())))
p03779
x = int(eval(input())) for i in range(1, x+1): if (i*(i+1)>=2*x): print(i) exit()
def main(): x = int(eval(input())) t = 1 while t * (t + 1) < x * 2: t += 1 print(t) # [1,t]総和がXを超えるとき # 超過分に相当する距離のジャンプが区間に含まれる if __name__ == '__main__': main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for ...
p03779
x=int(eval(input())) i=0 isum=0 while isum<x: i=i+1 isum=isum+i print(i)
x=int(eval(input())) t=int(((-1+(8*x+1)**0.5)-10**(-10))/2)+1 print(t)
p03779
x=int(eval(input())) a=0 i=1 while a<x: a+=i if a>=x: print(i) exit() i+=1
x=int(eval(input())) a=0 for i in range(1,10**9): a+=i if a>=x: print(i) exit()
p03779
X = int(eval(input())) P = {0} i=1 while True: Q = {0} for p in P: Q.add(p+i) Q.add(p-i) P = P.union(Q) if X in P: print(i) break i = i+1
X = int(eval(input())) a = 0 while X >0: a += 1 X -= a print (a)
p03779
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on 2019/3/24 Solved on 2019/3/ @author: shinjisu """ # ABC 056 C - Go Home def getInt(): return int(input()) def zeros(n): return [0]*n def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替 class Debug(): def __i...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on 2019/3/24 Solved on 2019/3/ @author: shinjisu """ # ABC 056 C - Go Home def getInt(): return int(input()) def zeros(n): return [0]*n def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替 class Debug(): def __i...
p03779
X = int(eval(input())) i, x = 1, 0 while x < X: x += i i += 1 print((i - 1))
import math X = int(eval(input())) print((math.ceil((-1 + (1 + 8 * X) ** 0.5) / 2)))
p03779
X=int(eval(input())) count=0 x=[[0]] for k in range(0,1000000): if X in x[k]: print(k) break x.append(list(set(x[k]))) for j in range(len(x[k])): x[k+1].append(x[k][j]+k+1) x[k+1].append(x[k][j]-k-1) x[k+1]=list(set(x[k+1]))
X=int(eval(input())) N=int(-0.5+(0.25+2*X)**0.5) for k in range(N+2): if 0.5*N*(N-1)<X<=0.5*N*(N+1): print(N) break N+=1 ''' count=0 x=[[0]] for k in range(0,1000000): if X in x[k]: print(k) break x.append(list(set(x[k]))) for j in range(len(x[k])):...
p03779
X = int(eval(input())) t = 1 while True: if X<=((t+1)*t)//2: break t += 1 print(t)
X = int(eval(input())) k = 1 while (k*(k+1))//2<X: k += 1 print(k)
p03779
X = int(eval(input())) k = 1 while (k*(k+1))//2<X: k += 1 print(k)
X = int(eval(input())) t = 1 while X>(t*(t+1))//2: t += 1 print(t)
p03779
x=int(eval(input())) import queue q = queue.Queue() q.put(0) q.put("") count=1 while 1: now=q.get() if now=="": count+=1 q.put("") continue if now+count==x or now-count==x: print(count) break q.put(now+count) q.put(now) q.put(now-count...
x=int(eval(input())) # import queue # q = queue.Queue() # q.put(0) # q.put("") i=0 now=0 while 1: i+=1 now+=i if now>=x: print(i) break
p03779
a = int(eval(input())) i = 1 R = 0 while a > R: R = R+i i = i+1 print((i-1))
n = int(eval(input())) cou = 0 num = 0 while num < n: cou += 1 num += cou print(cou)
p03779
x = int(eval(input())) i=1 cum=[0] while cum[-1] < 10**9: cum+=[cum[-1]+i] i+=1 import bisect index = bisect.bisect_left(cum, x) print(index)
x = int(eval(input())) i=1 while i*(i+1)//2 < x: i+=1 print(i)
p03779
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) import itertools x = int(read()) cumsum = list(itertools.accumulate([i for i in range(45000)])) for i in range(45000): if cumsum[i] >= x: print(i) ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) x = int(read()) cnt = 0 for i in range(45000): cnt += i if cnt >= x: print(i) exit()
p03779
x = int(eval(input())) from collections import deque q = deque([[0, 0]]) while q: xi, i = q.popleft() if xi == x: print((i-1)) exit() q.append([xi, i+1]) q.append([xi+i, i+1]) q.append([xi-i, i+1])
x = int(eval(input())) ans = 0 cnt = 0 i = 0 while cnt < x: i+=1 cnt += i ans += 1 print(ans)
p03779
X = int(eval(input())) i = 1 while((i ** 2 + i) / 2 < X): i += 1 print(i)
from math import ceil x = int(eval(input())) print((ceil(((1 + 8 * x) ** 0.5 - 1) / 2)))
p03779
if __name__ == '__main__': x = abs(int(eval(input()))) s = 0 for i in range(0,10 ** 9): if s > x: print((i - 1)) break elif s == x: print((i - 1)) break s += i
if __name__ == '__main__': x = abs(int(eval(input()))) s = 0 for i in range(0,10 ** 9): if s >= x: print((i - 1)) break s += i
p03779
from collections import deque X = int(eval(input())) q = deque() q.append((0, 1)) while len(q) > 0: pos = q.popleft() if pos[0] + pos[1] == X or pos[0] - pos[1] == X: print((pos[1])) break q.append((pos[0] + pos[1], pos[1] + 1)) q.append((pos[0] - pos[1], pos[1] + 1)) ...
X = int(eval(input())) t = 1 while True: if t * (t + 1) / 2 >= X: print(t) break t += 1
p03779
X = int(eval(input())) a = 1 while a*(a+1)//2<X: a+=1 print(a)
print((round((2*int(eval(input())))**.5)))
p03779
X = int(eval(input())) queue = [(0,0)] while queue: time, location = queue.pop(0) if location == X: print(time) break time+=1 queue.append((time,location+time)) queue.append((time,location)) queue.append((time,location-time))
X = int(eval(input())) t = 1 for t in range(1,X+1): total = t*(t+1)/2 if total>=X: break print(t)
p03779
X = int(eval(input())) L = [sum(range(i+1)) for i in range(X+1) if sum(range(i+1))<X] print((len(L)))
X = int(eval(input())) for i in range(X+1): if (i*(i+1)/2) >= X: time = i break print(time)
p03779
def main(): X = int(eval(input())) ans = 1 while ans * (ans + 1) * 0.5 < X: ans += 1 print(ans) return main()
from operator import rshift def main(): X = int(eval(input())) ans = 1 while rshift(ans * (ans + 1), 1) < X: ans += 1 print(ans) return main()
p03779
# coding: utf-8 # Your code here! X=int(eval(input())) if X==1: print((1)) exit() elif X==2: print((2)) exit() l=[1] i=2 while True: temp=[] for item in l: temp.append(item+i) if X in temp: print(i) exit() else: l+=temp i+=1
# coding: utf-8 # Your code here! X=int(eval(input())) i=0 count=0 while True: i+=1 count+=i if count>=X: print(i) exit()
p03779
n = int(eval(input())) l = [] def f(n, l): for i in range(1, n+1): sum = 0 l.append(i) for j in range(len(l), 0, -1): if not sum + l[j-1] > n: sum += l[j-1] if sum == n: return i print((f(n, l)))
n = int(eval(input())) l = [] def f(n, l): sum = 0 for i in range(1, n+1): sum += i if sum >= n: return i print((f(n, l)))
p03779
X = int(eval(input())) dic = {} dic[0] = 1 time = 0 while True: time += 1 dicc = dic.copy() for i in dicc: dic[i + time] = 1 dic[i - time] = 1 if X in dic: break print (time)
X = int(eval(input())) ans = 0 cnt = 0 while ans < X: cnt += 1 ans += cnt print (cnt)
p03779
import queue t = int(eval(input())) queue = queue.Queue() queue.put([0,0]) while True : x = queue.get() if x[0] == t: print(x[1]) break else : queue.put([ x[0]+x[1]+1 , x[1]+1 ]) queue.put([ x[0] , x[1]+1]) if x[0] - (x[1]+1) > 0 : queue.put([x[0]-(x[1]+1),x[1]+1])
n = int(eval(input())) ans = 0 i = 1 while n > ans : ans += i i += 1 print(i-1)
p03779
X=int(eval(input())) A=[] for i in range(1,X+1): A.append(i) if sum(A)>=X: print(i) break
sum=0 X=int(eval(input())) for i in range(1,X+1): sum+=i if sum>=X: print(i) break
p03779
import collections ta = int(input()) vis = set([0]) q = collections.deque([(0,0)]) while(q): x,t = q.popleft() if x == ta: print(t) break for nt in [x-t-1,x,x+t+1]: q.append((nt, t + 1))
import collections target = int(input()) t = 0 while(target): target -= min(target, t + 1) t +=1 print(t)
p03779
import sys stdin = sys.stdin ns = lambda : stdin.readline().rstrip() na = lambda : list(map(int, stdin.readline().split())) ni = lambda : int(ns()) def main(): n = ni() f = lambda x: (x * (x+1)) // 2 for i in range(1, n+1): if (f(i) >= n): print(i) return main()
import sys stdin = sys.stdin ns = lambda : stdin.readline().rstrip() ni = lambda : int(ns()) na = lambda : list(map(int, stdin.readline().split())) def main(): n = ni() t = 0 for i in range(1, n + 1): t += i if t >= n: print(i) return main()
p03779
from collections import deque X = int(eval(input())) queue = deque() queue.appendleft((0, 0)) while queue: now = queue.pop() pos = now[0] time = now[1] if pos == X: print(time) exit() queue.appendleft((pos + time+1, time+1)) queue.appendleft((pos, time+1)) ...
X = int(eval(input())) time = 0 pos = 0 while pos < X: time += 1 pos += time print(time)
p03779
n = int(eval(input())) tot=0 dp = [0 for i in range(n+4)] for i in range(1, n+1): tot=tot+i if tot>=n: print(i) break
n = int(eval(input())) tot=0 for i in range(1, n+1): tot=tot+i if tot>=n: print(i) break
p03779
# -*- coding: utf-8 -*- import itertools def main(): X = int(input()) jumpTime = [ i for i in range(1,X+1) ] candidate = [] for i in range(1, len(jumpTime)+1): candidate.append(list(itertools.combinations(jumpTime, i))) correct = [] for can in candidate: for c in can...
# -*- coding: utf-8 -*- def main(): X = int(input()) step = 0 for i in range(1,X+1): step += i if step >= X: break print(i) if __name__ == '__main__': main()
p03779
X = int(eval(input())) pos = [0] for i in range(1,X+1): tmp = [] for j in pos: tmp.append(j + i) if j + i == X: print(i) exit(0) pos.extend(tmp) pos = list(set(pos))
X = int(eval(input())) sumval = 0 for i in range(1,X+1): sumval += i if sumval >= X: ans = i break print(ans)
p03779
# ABC056 C - Go Home X = int(eval(input())) T = [] total = 0 idx = 0 ans = 0 while total < 2500000000: idx += 1 total += idx T.append(total) for i in range(len(T)-1): if i == 0: if X == T[i]: ans = i+1 break if T[i-1]<X<=T[i]: ans = i+1 ...
x=int(eval(input())) if x==1: print((1)) exit(0) for i in range(1,100001): t=i*(i+1)//2 s=(i+1)*(i+2)//2 if t<x<=s: print((i+1)) exit(0)
p03779
from collections import deque x = int(eval(input())) que = deque() count = 0 que.append((count, 0, 0, 0)) while len(que) > 0: depth, v1, v2, v3 = que.popleft() if any([val == x for val in (v1, v2, v3)]): break depth += 1 for v in (v1, v2, v3): que.append((depth, v - depth,...
x = int(eval(input())) t = 0 s = 0 while s < x: t += 1 s += t print(t)
p03779
X = int(eval(input())) def bfs(position=[0],depth=1): queue = [] for p in position: for dx in [-depth,0,depth]: nextp = p + dx if nextp == X: return depth queue.append(nextp) position = queue[:] if depth == 10**5: return dept...
X = int(eval(input())) for t in range(1,X+1): if t*(t+1)//2 >= X: print(t) break
p03779
# import bisect from collections import Counter, deque # from copy import copy, deepcopy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np # from operator i...
def resolve(): X=int(eval(input())) cnt=1 while True: val=cnt*(cnt+1)//2 if val>=X: print(cnt) break else: cnt += 1 resolve()
p03779
#!/usr/bin/env python3 # BFS from collections import deque x = int(eval(input())) q = deque() q.append((0, 0)) visited = [] while q: u = q.popleft() if u[0] == x: print((u[1])) break visited.append(u) if ((u[0]-1, u[1]+1)) not in visited: q.append((u[0]-(u[1]+1)...
#!/usr/bin/env python3 x = int(eval(input())) t = 0 while True: if t*(t+1)/2 >= x: print(t) break t += 1
p03779
import sys from pprint import pprint def solve(n, a, b): ans = 0 if (b - a) % 2 == 0: ans = (b - a) // 2 else: # 両端で試合するパターン simple = min(b - 1, n - a) # 両端に一回残留してから端以外で試合するパターン mix_a = a + (b - a) // 2 mix_b = n - b + 1 + (b - a - 1) // 2 ...
import sys N, A, B = list(map(int, sys.stdin.readline().split())) if (B - A) % 2 == 0: print(((B - A) // 2)) else: print((min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2)))
p02823
N,A,B = list(map(int, input().split())) if (B-A) % 2 == 0: ans = (B-A) // 2 else: ans = min(A, N-B+1) + (B-A-1)//2 print(ans)
""" AtCoder Grand Contest 039 A - Connection and Disconnection Sの中で、隣り合う文字が同じ場合、連続しないよう書き換える ・abba -> abca ・abbba -> abcba:奇数個連続している場合、(連続してる個数)// 2 書き換える ・abbbba -> abcbca:偶数個連続している場合、(連続してる個数)// 2 書き換える。奇数個と同じ また、Sを並べていく中で、「Sの末尾の文字群」と「Sの先頭の文字群」が同じ場合も、書き換えが必要。 S = abcda SSSSS = abcda abcda abcda abcda a...
p02823
import sys temp=list(map(int, input().split())) N=temp[0] A=temp[1] B=temp[2] cnt=0 if (B-A)%2==1: if A-1<=N-B: cnt=A B-=A A=1 else: cnt=N-B+1 A+=(N-B)+1 B=N while A!=B: if B-A>=2: A+=1 B-=1 cnt+=1 print(cnt)
import sys temp=list(map(int, input().split())) N=temp[0] A=temp[1] B=temp[2] cnt=0 if (B-A)%2==1: if A-1<=N-B: cnt=A B-=A A=1 else: cnt=N-B+1 A+=(N-B)+1 B=N if A!=B: cnt+=(B-A)//2 print(cnt)
p02823
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,A,B = MI() print(((B-A)//2 if (B-A) % 2 == 0 else min((A+B-1)//2,N-(A+B-1)//2)))
p02823
#!/usr/bin/env python3 # -*- coding: utf-8 -*- n,a,b = list(map(int, input().split())) l = min(a, b) r = max(a, b) k = r - l if k % 2 == 1: count = min(l - 1, n - r) + 1 + ((k - 1) // 2) print((int(count))) else: print((int(k // 2)))
#!/usr/bin/env python3 # -*- coding: utf-8 -*- n,a,b = list(map(int, input().split())) k = abs(a - b) if k % 2 == 1: count = 0 if n - b > a - 1: count += a - 1 + 1 + ((k - 1) // 2) else: count += n - b + 1 + ((k - 1) // 2) print((int(count))) else: print((k // 2))
p02823
n, a, b = list(map(int, input().split())) if (b - a) % 2 == 0: print(((b - a) // 2)) else: print((min(a, n - b + 1) + (b - a - 1) // 2))
n, a, b = list(map(int, input().split())) if (b - a)%2 == 0: ans = (b - a)//2 print((int(ans))) else: ans = min(a - 1, n - b) + 1 + ((b - a - 1)//2) print((int(ans)))
p02823
N, A, B = list(map(int, input().split(" "))) if A % 2 == B % 2: print(((B - A) // 2)) else: print((min(N - B, A - 1) + 1 + (B - A - 1) // 2))
N, A, B = list(map(int, input().split(" "))) if (B - A) % 2 == 0: print(((B - A) // 2)) else: print((min(N - B, A - 1) + 1 + (B - A - 1) // 2))
p02823
nc, ac, bc = list(map(int, input().split())) n = nc - 1 a = ac - 1 b = bc - 1 if (b - a) % 2 == 0: print(((b - a) // 2)) else: left = a right = n - b if left <= right: ran = b - a flag = 0 ans = 0 while (ran % 2 != 0): b -= 1 if ...
n, a, b = list(map(int, input().split())) if (b - a) % 2 == 0: print(((b - a) // 2)) else: test = (b - a) // 2 left = a - 1 right = n - b if left >= right: print((n - a - test)) else: print((b - 1 - test))
p02823
n,a,b = list(map(int, input().split())) if abs(a-b)%2 == 0: print(((b-a)//2)) else: print((min(a-1, n-b) + 1 + (b-a-1)//2))
n,a,b = list(map(int, input().split())) if (b-a)%2==0: print(((b-a)//2)) else: print((min(a-1, n-b)+ 1 + (b-a-1)//2))
p02823
n,a,b = list(map(int, input().split())) if (b-a)%2==0: print(((b-a)//2)) else: print((min(a-1, n-b)+ 1 + (b-a-1)//2))
n,a,b = list(map(int, input().split())) print((min(a-1, n-b)+1+(b-a-1)//2 if (b-a)%2!=0 else (b-a)//2))
p02823
N, A, B = list(map(int, input().split())) distance =(B - A - 1 )//2 if( (A % 2 == 0 and B % 2 ==0) or (A%2==1 and B%2==1)): ans=(B - A)//2 else: ans = min(A-1,N - B) + 1 + distance print(ans)
def myAnswer(N:int,A:int,B:int) -> int: ans = 0 BN = N - B A1 = A - 1 while True: if((B - A) % 2== 0): ans += (B - A)//2 break elif(A == 1): ans += 1 B -= 1 elif(B == N): ans += 1 A += 1 else: if(BN > A1): ...
p02823
N, A, B = list(map(int, input().split())) if abs(A - B) % 2 == 0: print((abs(A - B) // 2)) else: ans = min(A - 1, N - B) + (B - A - 1) // 2 + 1 print(ans)
N, A, B = list(map(int, input().split())) if (B - A) % 2 == 0: print(((B - A) // 2)) else: # Aが左に到着 ans1 = 0 ans1 += A - 1 + 1 a = 1 b = B - A ans1 += (b - a) // 2 # Bが右に到着 ans2 = 0 ans2 += N - B + 1 a = A + (N - B + 1) b = N ans2 += (b - a) // 2 ...
p02823
n, a, b = list(map(int, input().split())) if (b-a)%2==0: print(((b-a)//2)) else: print((min(n-b+1+(b-a-1)//2,a+(b-a)//2)))
n,a,b=map(int,input().split()) x=b-a p=print if (b-a)%2==0:p((b-a)//2) else:p(min(n-b+1+(x-1)//2,a+x//2))
p02823
n, a, b = list(map(int, input().split())) if (b-a)%2 == 0 : print(((b-a)//2)) else : print(((b-a)//2 + min(a-1,n-b) + 1))
n, a, b = list(map(int, input().split())) print(((b-a)//2 + min(a-1,n-b) + 1 if (b-a)%2 else (b-a)//2))
p02823
N, A, B = list(map(int, input().split())) if (A - B) % 2 == 0: print((abs(A - B) // 2)) else: if A > B: A, B = B, A ret = abs(B - A - 1) // 2 + min(A, N - B + 1) print(ret)
n, a, b = list(map(int, input().split())) if (a - b) % 2 == 0: print((abs(a - b) // 2)) else: print((min((a - 1) + 1, (n - b) + 1) + abs(b - a - 1) // 2))
p02823
n, a, b = list(map(int, input().split())) if (a - 1) >= (n - b): count = (n-b) a = a + (n - b) b = n else: count = (a - 1) b = b - (a - 1) a = 1 #print(count) if ((b - a) % 2 == 0): print((min(min(b-1,n-a),(b-a)//2))) elif a == 1 and (b - a) % 2 != 0: print((min(min(b - 1, n...
n, a, b = list(map(int, input().split())) if (a - 1) >= (n - b): count = (n-b) a = a + (n - b) b = n else: count = (a - 1) b = b - (a - 1) a = 1 if ((b - a) % 2 == 0): print((min(min(b-1,n-a),(b-a)//2))) elif a == 1 and (b - a) % 2 != 0: print((min(min(b - 1, n - a), (b - 1...
p02823
N,A,B = list(map(int,input().split())) if (max(A,B)-min(A,B))%2==0: cnt = (max(A,B)-min(A,B))//2 else: cnt1 = min(max(A,B)-1,N-min(A,B)) cnt2 = min(A,B)+(max(A,B)-min(A,B)-1)//2 cnt3 = N-max(A,B)+1+(max(A,B)-min(A,B)-1)//2 cnt = min(cnt1,cnt2,cnt3) print(cnt)
N,A,B = list(map(int,input().split())) if (B-A)%2==0: print(((B-A)//2)) else: if (A-1)<=(N-B): print((A+(B-A-1)//2)) else: print((N-B+1+(B-A-1)//2))
p02823
N,A,B = list(map(int,input().split())) if abs(B-A)%2==0: print((abs(B-A)//2)) elif A<B: print((min(A-1,N-B)+1+(B-A-1)//2)) else: print((min(B-1,N-A)+1+(A-B-1)//2))
N,A,B = list(map(int,input().split())) if (B-A)%2==0: print(((B-A)//2)) else: print((min(A,N-B+1)+(B-A-1)//2))
p02823
N, A, B = list(map(int, input().split())) if ((B-A)%2 == 0): print(((B-A)//2)) else: print((min([A+(B-A-1)//2 ,N-B+ 1 +(B-A-1)//2])))
N, A, B = list(map(int,input().split())) if ((A-B)%2==0): ans = abs(A-B)//2 elif (N-B <= A-1): ans = (2*N -A-B+1)//2 elif (N-B > A-1): ans = (B+A-1)//2 print(ans)
p02823
n, a, b = list(map(int, input().split())) a = min(a, b) b = max(a, b) ret = 0 if (b - a) & 1: if n - a < b - 1: ret = n - b + 1 a += ret b = n else: ret = a a = 1 b -= ret print((ret + (b - a) // 2))
n, a, b = list(map(int, input().split())) if abs(b - a) & 1: l = (a - 1) + (b - 1) + 1 r = (n - a) + (n - b) + 1 x = min(l, r) else: x = abs(b - a) print((x // 2))
p02823
N, A, B = list(map(int, input().split())) round_count = 0 med = N / 2 + 0.5 maxAB = 10 ** 18 Max = max([A, B]) Min = min([A, B]) for i in range(maxAB): if (Max - Min) % 2 == 0: Max = Max - 1 Min = Min + 1 else: medAB = (Max + Min) / 2 if medAB > med: ...
N, A, B = list(map(int, input().split())) med = N / 2 + 0.5 Sub = B - A if (Sub) % 2 == 0: round_count = Sub // 2 else: round_count = min(A - 1, N - B) + 1 + (Sub - 1) // 2 print(round_count)
p02823
A = list(map(int, input().split())) A.sort() if A[0] == A[2]: print('No') elif A[0] == A[1] or A[1] == A[2]: print('Yes') else: print('No')
A = list(map(int, input().split())) if len(set(A)) == 2: print('Yes') else: print('No')
p02771
a = list(map(int, input().split())) if len(set(a)) == 2: print("Yes") else: print("No")
A,B,C = list(map(int,input().split())) if A == B and B == C: print("No") elif A != B and B!= C and A != C: print("No") else: print("Yes")
p02771
# A - Poor def main(): A, B, C = list(map(int, input().split())) is_poor = (A == B and A != C) or (A == C and A != B) or (B == C and A != B) print(("Yes" if is_poor else "No")) if __name__ == "__main__": main()
# A - Poor def main(): A, B, C = list(map(int, input().split())) is_poor = A == B != C or A == C != B or B == C != A print(("Yes" if is_poor else "No")) if __name__ == "__main__": main()
p02771
import math class Input(): def readInt(self): return int(eval(input())) def readIntArray(self): return [int(x) for x in input().split(" ")] def readString(self): return eval(input()) def readStringArray(self): return input().split(" ") def readFloat(self): return float(eval(input()))...
A,B,C = input().split() a = A b = B c = C if (a==b and a==c): print("No") elif (a==b or b==c or a==c): print("Yes") elif (a!=b or b!=c): print("No")
p02771
li=list(map(int,input().split())) if len(set(li))==2: print("Yes") else: print("No")
print(("Yes" if 2==len(set(list(map(int,input().split())))) else "No"))
p02771
print((['No','Yes'][len(set(map(int,input().split())))==2]))
print(('YNeos'[len(set(input().split()))!=2::2]))
p02771
a, b, c = list(map(int, input().split())) if a == c and a != b: print('Yes') elif a == b and a != c: print('Yes') elif b == c and a != b: print('Yes') else: print('No')
if len(set(input().split()))==2: print('Yes') else: print('No')
p02771
import sys *a, = list(map(int, sys.stdin.readline().split())) a.sort() a, b, c = a def main(): if a == b != c or a != b == c: return 'Yes' return 'No' if __name__ == '__main__': ans = main() print(ans)
import sys *a, = list(map(int, sys.stdin.readline().split())) def main(): ans = 'Yes' if len(set(a)) == 2 else 'No' print(ans) if __name__ == '__main__': main()
p02771
A,B,C = list(map(int,input().split())) if(A==B): if(A!=C): print('Yes') else: print('No') elif(A==C): if(A!=B): print('Yes') else: print('No') elif(B==C): if(A!=B): print('Yes') else: print('No') else: print('No')
def main(): A,B,C = list(map(int,input().split())) if(A == B and B != C): print("Yes") elif(B == C and A != B): print("Yes") elif(A == C and A != B): print("Yes") else: print("No") if __name__ == "__main__": main()
p02771
a, b, c = list(map(int, input().split())) if len(set([a, b, c])) == 2: print("Yes") else: print("No")
s = list(map(int,input().split())) if len(set(s)) == 2: print("Yes") else: print("No")
p02771
a,b,c = list(map(int,input().split())) if a == b and c != a: print("Yes") elif b == c and c != a: print("Yes") elif c == a and a != b: print("Yes") else: print('No')
a,b,c = list(map(int,input().split())) s = set() s.add(a) s.add(b) s.add(c) if len(s) == 2: print('Yes') else: print('No')
p02771
A, B, C = list(map(int,input().split())) if A ==B and B == C: print('No') elif B == C: print('Yes') elif A == C: print('Yes') elif A == B: print('Yes') else: print('No')
A, B, C = list(map(int,input().split())) if A == B == C: print('No') elif B == C: print('Yes') elif A == C: print('Yes') elif A == B: print('Yes') else: print('No')
p02771
n = input().split() for i in range (3) : n[i] = int(n[i]) a = sorted (n) fl = False if (a[0] == a[1] and a[1] != a[2]) : fl = True if (a[0] != a[1] and a[1] == a[2]) : fl = True print(('Yes' if fl else 'No'))
A,B,C=input().split() a,b,c=int(A),int(B),int(C) if a==b and b!=c: print("Yes") elif a==c and a!=b: print("Yes") elif b==c and a!=b: print("Yes") else: print("No")
p02771
import sys input = sys.stdin.readline A = [int(x) for x in input().split()] from collections import Counter c = Counter(A) for i in list(c.values()): if i == 2: print("Yes") sys.exit() print("No")
A = [int(x) for x in input().split()] from collections import Counter import sys c = Counter(A) for i in list(c.values()): if i == 2: print("Yes") sys.exit() print("No")
p02771
a,b,c=list(map(int,input().split())) if a==b and a!=c: print('Yes') elif a==c and a!=b: print('Yes') elif b==c and b!=a: print('Yes') else: print('No')
a,b,c=list(map(int,input().split())) if a==b: if a!=c : print('Yes') else: print('No') elif a==c: if a!=b : print('Yes') else: print('No') elif c==b: if a!=c : print('Yes') else: print('No') else: print('No')
p02771
import itertools import math import fractions import functools a, b, c = list(map(int, input().split())) if (a == b and a != c) or (b == c and b != a) or (a == c and a != b): print("Yes") else: print("No")
a, b, c = list(map(int, input().split())) if (a == b or a == c or b ==c) and not (a == b and a == c): print("Yes") else:print("No")
p02771
A = list(map(int,input().split())) newA = sorted(A) if newA[0]==newA[1]==newA[2]: print("No") elif newA[0] == newA[1] or newA[1] == newA[2]: print("Yes") else: print("No")
A,B,C = list(map(int, input().split())) if A == B == C: print("No") elif A == B or A == C or B == C: print("Yes") else: print("No")
p02771
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 a, b, c = list(map(int, readline().split())) if a == b != c or a != b == c or a == c != b: print("Yes") else: print("No") if __name__ == '__main__': solve()
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 a, b, c = list(map(int, readline().split())) if a == b != c or a == c != b or b == c != a: print("Yes") else: print("No") if __name__ == '__main__': solve()
p02771
A,B,C = sorted(list(map(int,input().split()))) if A==B and B==C: print("No") elif A==B or B==C: print("Yes") else: print("No")
if len(set(map(int,input().split())))==2: print("Yes") else: print("No")
p02771
def main(): a, b, c = list(map(int, input().split())) if (a == b and c != a) or (a == c and b != c) or (b == c and a != b): print("Yes") else: print("No") if __name__ == '__main__': main()
n = list(map(int,input().split())) n.sort() a,b,c = n flag = False if a == b and c != a: flag = True elif a == c and b != c: flag = True elif b == c and a != b: flag = True print(("Yes" if flag else "No"))
p02771
import collections A = list(map(int, input().split())) if len(collections.Counter(A)) == 2: print('Yes') else: print('No')
A = list(map(int, input().split())) if len(set(A)) == 2: print('Yes') else: print('No')
p02771
a, b, c = list(map(int, input().split())) if a == b and b != c: print("Yes") elif a == b and b == c: print("No") elif a != b and b == c: print("Yes") elif a != b and a == c: print("Yes") else: print("No")
a = list(map(int, input().split())) a = set(a) if len(a) == 2: print("Yes") else: print("No")
p02771