id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_1101 | a,b,c,d,e,f,x=map(int,input().split())
ta=(x//(a+c))*a*b+min(x%(a+c),a)*b
ao=(x//(d+f))*d*e+min(x%(d+f),d)*e
if ta>ao:
print("takahashi")
elif ao>ta:
print("Aoki")
else:
print("Draw")
a,b,c,d,e,f,x=map(int,input().split())
ta=(x//(a+c))*a*b+min(x%(a+c),a)*b
ao=(x//(d+f))*d*e+min(x%(d+f),d)*e
if ta>ao:
print("T... | ConDefects/ConDefects/Code/abc249_a/Python/45229228 |
condefects-python_data_1102 | a,b,c,d,e,f,x = map(int, input().split())
xbk = x
y, z = 0, 0
y += x // (a + c) * a * b
x -= x // (a + c) * (a + c)
if x - a >= 0:
y += a * b
else:
y += x * b
x = xbk
z += x // (d + f) * d * e
z -= x // (d + f) * (d + f)
if x - d >= 0:
z += d * e
else:
z += x * e
print("Takahashi" if y > z else "Aoki"... | ConDefects/ConDefects/Code/abc249_a/Python/45778141 |
condefects-python_data_1103 | import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd, sin ,cos
from copy import deepcopy
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bis... | ConDefects/ConDefects/Code/abc249_a/Python/45104462 |
condefects-python_data_1104 | def d(a, b, c, x):
t = x // (a + c)
return t * (a * b) + (x - ((a + c) * t)) * b
A, B, C, D, E, F, X = map(int, input().split())
if d(A, B, C, X) > d(D, E, F, X):
print("Takahashi")
elif d(A, B, C, X) < d(D, E, F, X):
print("Aoki")
else:
print("Draw")
def d(a, b, c, x):
t = x // (a + c)
... | ConDefects/ConDefects/Code/abc249_a/Python/44441991 |
condefects-python_data_1105 | #https://atcoder.jp/contests/ARC173/tasks/ARC173_d
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd, lcm
from itertools import permutations
n =... | ConDefects/ConDefects/Code/arc173_c/Python/51460321 |
condefects-python_data_1106 | from operator import add, eq
class SegmentTreeInjectable:
"""
単位元生成関数 identity_factory と二項演算関数 func を外部注入するセグメント木
[生成]
SegmentTreeInjectable(n, identity_factory, func)
SegmentTreeInjectable.from_array(array, identity_factory, func) # 既存の配列より作成
[関数]
add(i, x) Aiにxを加算
up... | ConDefects/ConDefects/Code/arc173_c/Python/51137292 |
condefects-python_data_1107 | n,m=map(int,input().split())
cps=[]
for i in range(n):
tmp=list(map(int,input().split()))
cps.append(tmp)
INF=1001001001001
dp=[INF]*(m+1)
dp[0]=0
for i in range(1,m+1):
for lst in cps:
c=lst[0]
p=lst[1]
s=lst[2:]
zr=0
now=0
for j in s:
if j==0:
zr+=1
num=p-zr
for... | ConDefects/ConDefects/Code/abc314_e/Python/45808089 |
condefects-python_data_1108 | N, M = map(int, input().split())
S = input()
C = list(map(int, input().split()))
ans = list(S)
Cs = [[] for _ in range(M+1)]
for i in range(N):
Cs[C[i]].append(i)
for i in range(M):
for j in range(len(Cs[i])):
ans[Cs[i][j]] = S[Cs[i][j-1]]
print(*ans, sep="")
N, M = map(int, input().split())
S = input()
C ... | ConDefects/ConDefects/Code/abc314_c/Python/55161312 |
condefects-python_data_1109 | n,m=map(int,input().split())
s=input()
c=list(map(int,input().split()))
color=[[] for i in range(n+1)]
for i in range(n):
color[c[i]].append(i)
ans=[0]*n
for i in range(1,n+1):
l=len(color[i])
for j in range(l):
ans[color[i][j]]=color[i][(j+1)%l]
for i in range(n):
ans[i]=s[ans[i]]
print(*ans,se... | ConDefects/ConDefects/Code/abc314_c/Python/54238800 |
condefects-python_data_1110 | n,m=map(int,input().split())
s=input()
c=list(map(int,input().split()))
color=[[] for i in range(m+1)]
for i in range(n):
color[c[i]].append(i)
ans=[0]*n
for i in range(1,m+1):
l=len(color[i])
for j in range(l):
ans[color[i][j]]=color[i][(j+1)%l]
for i in range(n):
ans[i]=s[ans[i]]
print(*ans,se... | ConDefects/ConDefects/Code/abc314_c/Python/54938051 |
condefects-python_data_1111 | # ABC-314-C-Rotate_Colored_Subsequence_2
N, M = map(int, input().split())
S = input()
S = list(S)
C = list(map(int, input().split()))
# 連想配列のlist版
from collections import defaultdict
m = defaultdict(list)
for i in range(N):
m[C[i]].append([S[i], i])
print(m)
# 8 3
# apzbqrcs
# 1 2 3 1 2 2 1 2
# ↓
# {1: [['a', 0]... | ConDefects/ConDefects/Code/abc314_c/Python/54038840 |
condefects-python_data_1112 | n=int(input())
l=list(input())
lacnt=[]
lbcnt=[]
a=0
b=0
for i in l:
if i == "A":
a += 1
if i == "B":
b += 1
lacnt.append(a)
lbcnt.append(b)
for i in range(1,n+1):
if lacnt[i] >= lbcnt[i]:
print("Arice")
else:
print("Bob")
n=int(input())
l=list(input())
lacnt=[]
lbcnt=[]
a=0
b=0
for i i... | ConDefects/ConDefects/Code/agc063_a/Python/44148214 |
condefects-python_data_1113 | n,m,k = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
e = list(map(int,input().split()))
dp = [float('inf')] * (n+1)
dp[1] = 0
for i in range(k):
a,b,c = l[e[i]-1]
if dp[a] != float('inf'):
dp[b] = min(dp[b],dp[a]+c)
print(dp[n])
n,m,k = map(int,input().split())
l = [list(map... | ConDefects/ConDefects/Code/abc271_e/Python/45981596 |
condefects-python_data_1114 | import sys
input = sys.stdin.readline
def ii(): return int(input())
def fi(): return float(input())
def si(): return input().rstrip()
def mii(): return map(int, input().split())
def fii(): return map(float, input().split())
def mii1(): return map(lambda x: int(x)-1, input().split())
def lii(): return list(map(int, inp... | ConDefects/ConDefects/Code/arc170_c/Python/51377709 |
condefects-python_data_1115 | '''2023年12月17日14:57:16, ac上抄的'''
'''cf的 py3.8 没有cache'''
# from sortedcontainers import * #cf没有
# from math import * #pow出现问题 math.pow里没有mod
from heapq import *
from collections import *
from bisect import *
from itertools import *
from functools import lru_cache
from copy import *
import sys
# sys.setrecursionlim... | ConDefects/ConDefects/Code/arc170_c/Python/50130200 |
condefects-python_data_1116 | # import io
# import sys
# _INPUT = """\
# 10 1000000000
# 0 0 1 0 0 0 1 0 1 0
# """
# sys.stdin = io.StringIO(_INPUT)
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
from collections import defaultdict, deque
import heapq
import bisect
import math
n, m = map(int, input().split())
A = list(map(... | ConDefects/ConDefects/Code/arc170_c/Python/52698796 |
condefects-python_data_1117 | MOD = 998244353
n,m = map(int, input().split())
s = list(map(int, input().split()))
if m == 0:
ok = True
for i in range(n):
if i == 0:
if s[i] == 0:
ok = False
break
else:
if s[i] == 1:
ok = False
break
... | ConDefects/ConDefects/Code/arc170_c/Python/49600906 |
condefects-python_data_1118 | ############################################################################################
import bisect,collections,copy,heapq,itertools,math,string,sys,queue,time,random
from decimal import Decimal
def I(): return input()
def IS(): return input().split()
def II(): return int(input())
def IIS(): return list(map(int,... | ConDefects/ConDefects/Code/abc260_e/Python/44419168 |
condefects-python_data_1119 | import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def f(u, v, w):
return u << 40 ^ v << 20 ^ w
def get_segment0(s, t):
s, t = s ^ l1, t ^ l1
while s <= t:
if s & 1:
yield s
s += 1
s >>= 1
if not t & 1:
yield t
... | ConDefects/ConDefects/Code/abc322_f/Python/52703822 |
condefects-python_data_1120 | import os
import sys
import numpy as np
def solve(inp):
def mod_pow(x, a, MOD):
ret = 1
cur = x
while a > 0:
if a & 1:
ret = ret * cur % MOD
cur = cur * cur % MOD
a >>= 1
return ret
def prepare_factorials(n, MOD):
fa... | ConDefects/ConDefects/Code/abc327_g/Python/47668625 |
condefects-python_data_1121 | class FenwickTreeInjectable:
def __init__(self, n, identity_factory, func):
self.size = n
self.tree = [identity_factory() for _ in range(n + 1)]
self.func = func
self.idf = identity_factory
self.depth = n.bit_length()
def add(self, i, x):
i += 1
tree = se... | ConDefects/ConDefects/Code/abc279_g/Python/37231890 |
condefects-python_data_1122 | n, k, c = list(map(int, input().split()))
MOD = 998244353
# DP[i] = A[i] 以降まで決まった数列で、最後の色の連続の左端indexが i であるものの個数
dp = [0]
# 0→i の遷移: iに限らず c*(c-1) (特殊なのでDF配列では管理せず外側で持つ)
# (j=1~i-k+1)→i の遷移: DP[j]*(c-1)
# (j=i-k+2~i-1)→i の遷移: DP[j]*1
for i in range(1, n):
s = dp[-1]
t = dp[i - k + 1] if i - k + 1 > 0 else 0
... | ConDefects/ConDefects/Code/abc279_g/Python/37231957 |
condefects-python_data_1123 | from sortedcontainers import SortedList
N, K, Q = map(int, input().split())
XY = [tuple(map(int, input().split())) for _ in range(Q)]
A = [0] * N
lows = SortedList([0] * (N - K))
highs = SortedList([0] * K)
high_sum = 0
answers = []
for x, y in XY:
x -= 1
prev = A[x]
A[x] = y
if prev in lows:
... | ConDefects/ConDefects/Code/abc306_e/Python/46138524 |
condefects-python_data_1124 | MOD = 998244353
N = int(input())
A = list(map(lambda x:int(x)-1, input().split()))
memo = [[] for _ in range(N)]
#print(A)
for i in range(N):
if A[i] < i:
exit(print(0))
memo[A[i]].append(i)
#print(memo)
st = set(range(N))
y = []
for i in range(N):
if len(memo[i]):
y.append(i)
for j in range(1,len(memo[i])):... | ConDefects/ConDefects/Code/arc171_b/Python/50136893 |
condefects-python_data_1125 | #!/usr/bin/env python3
import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from fractions import Fraction
from itertools import accumulate, combinations, permutations, product
from sortedcontainers import S... | ConDefects/ConDefects/Code/arc171_b/Python/50078211 |
condefects-python_data_1126 | def main():
# write code here.
N = II()
A = LM()
#最終的に i になる数字たち group[i]
group = [[] for _ in range(N+1)]
for i in range(N):
if A[i] < i+1:
print(0)
exit()
group[A[i]].append(i+1)
bigs = []
smalls = []
for i in range(1,N+1):
if group... | ConDefects/ConDefects/Code/arc171_b/Python/51120581 |
condefects-python_data_1127 | n = int(input())
for i in range(n+1):
for j in range(n+1):
for k in range(n+1):
if i + j + k <= 3:
print(i,j,k)
n = int(input())
for i in range(n+1):
for j in range(n+1):
for k in range(n+1):
if i + j + k <= n:
print(i,j,k) | ConDefects/ConDefects/Code/abc335_b/Python/54952141 |
condefects-python_data_1128 | n = int(input())
for x in range(n+1):
for y in range(n+1):
for z in range(n+1):
if x + y + z == n:
print(x, y, z)
n = int(input())
for x in range(n+1):
for y in range(n+1):
for z in range(n+1):
if x + y + z <= n:
print(x, y, z) | ConDefects/ConDefects/Code/abc335_b/Python/54708241 |
condefects-python_data_1129 | N = int(input())
for x in range(N+1):
for y in range(N+1):
for z in range(N+1):
if x + y + z == N:
print(x,y,z)
N = int(input())
for x in range(N+1):
for y in range(N+1):
for z in range(N+1):
if x + y + z <= N:
print(x,y,z) | ConDefects/ConDefects/Code/abc335_b/Python/54517250 |
condefects-python_data_1130 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
print(2 * N)
ans = '4' * (N // 4)
if N % 4:
ans += str(N % 4)
print(ans)
if __name__ == '__main__':
main()
import sys
read = sys.stdin.read
readl... | ConDefects/ConDefects/Code/arc144_a/Python/42090105 |
condefects-python_data_1131 | N=int(input())
M=2*N
print(M)
tmp=M
X=[]
tmp1=M//8
tmp2=M%8
for i in range(tmp1):
X.append(8)
tmp3=tmp2//6
tmp4=tmp2%6
for i in range(tmp3):
X.append(6)
tmp5=tmp4//4
tmp6=tmp4%4
for i in range(tmp5):
X.append(4)
tmp7=tmp6//2
for i in range(tmp7):
X.append(1)
X.sort()
ans2=str()
for i in X:
ans2+=s... | ConDefects/ConDefects/Code/arc144_a/Python/39176273 |
condefects-python_data_1132 | N = int(input())
M = 2 * N
xstr = str(((N - 1) % 4) + 1) + "4" * ((N - 1) // 4)
N = int(input())
M = 2 * N
xstr = str(((N - 1) % 4) + 1) + "4" * ((N - 1) // 4)
print(M)
print(xstr) | ConDefects/ConDefects/Code/arc144_a/Python/41487232 |
condefects-python_data_1133 | n = int(input())
m = 2*n
x = []
while n > 4:
x.append('4')
n -= 4
if n == 3:
x.append('3')
if n == 2:
x.append('2')
if n == 1:
x.append('1')
x.sort()
x = ''.join(x)
print(m)
print(x)
n = int(input())
m = 2*n
x = []
while n > 4:
x.append('4')
n -= 4
if n == 4:
x.append('4')
if n == 3:
x.app... | ConDefects/ConDefects/Code/arc144_a/Python/39069759 |
condefects-python_data_1134 | white,black = map(int,input().split())
sum = white + black
part_list = []
str_S = 'wbwbwwbwbwbw' #12
S_list = list(str_S)
S_list_sum = 12
while sum > S_list_sum:
S_list.extend(str_S)
S_list_sum += 12
S_list.extend(str_S)
S_list_sum += 12
for x in range(S_list_sum):
part_list = S_list[x:x+sum + 1]
... | ConDefects/ConDefects/Code/abc346_b/Python/54925895 |
condefects-python_data_1135 | W,B = map(int,input().split())
wb = 'wbwbwwbwbwbw'
wball = wb*(200//len(wb)+4)
n = len(wball)
for i in range(n-(W+B)):
if wball[i:(W+B+1)].count('w') == W and wball[i:(W+B+1)].count('b') == B:
print('Yes')
exit()
print('No')
W,B = map(int,input().split())
wb = 'wbwbwwbwbwbw'
wball = wb*(200//len(w... | ConDefects/ConDefects/Code/abc346_b/Python/54883700 |
condefects-python_data_1136 | white, black = map(int,input().split())
while white > 6 and black > 4 :
white -= 7
black -= 5
#print(white, black)
if abs(white - black) >= 4:
print("No")
exit()
#print(white,black)
s = "wbwbwwbwbwbwwbwbwwbwbwbw"
S = list(s)
S_dict = {"w":0, "b":0}
for wb in range(white + black):
S_dict[S[wb]] += ... | ConDefects/ConDefects/Code/abc346_b/Python/55019091 |
condefects-python_data_1137 | W,B=map(int,input().split())
can_l=[]
Ans="No"
piano="wbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbwwbwbwwbwbwbw"
piano=list(... | ConDefects/ConDefects/Code/abc346_b/Python/55138933 |
condefects-python_data_1138 | M=998244353
n,m,k=map(int,input().split())
q=[0]*(k+1)
q[0]=1
for i in range(n):
nq=[0]*(k+1)
for j in range(k):
nq[j+1]+=q[j]
for j in range(k):
nq[j+1]+=nq[j]
nq[j+1]%=M
q=nq
print(sum(q)%M)
M=998244353
n,m,k=map(int,input().split())
q=[0]*(k+1)
q[0]=1
for i in range(n):
nq=[0]*(k+1)
for j in... | ConDefects/ConDefects/Code/abc248_c/Python/45110543 |
condefects-python_data_1139 | import math
import sys
sys.setrecursionlimit(500_000)
from collections import defaultdict
N, Q = map(int, input().split())
g = [[] for _ in range(N + 1)]
for _ in range(Q):
l, r = map(int, input().split())
l -= 1
g[l].append(r)
g[r].append(l)
visited = [False] * (N + 1)
q = [0]
visited[0] = True
while ... | ConDefects/ConDefects/Code/abc238_e/Python/52795863 |
condefects-python_data_1140 | N,M=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
sumlist=[]
nolist=[]
result=[]
for i in range(N):
temp=input()
sum=0
nokai=[]
for index,e in enumerate(temp):
if e=="o":
sum+=A[index]
else:
nokai.append(A[index])
sort_nokai =sorted(nok... | ConDefects/ConDefects/Code/abc323_c/Python/54680187 |
condefects-python_data_1141 | n, m = map(int, input().split())
A = list(map(int, input().split()))
S = [input() for i in range(n)]
score = [i+1 for i in range(n)]
B = [(i,j) for i,j in zip(range(m), A)]
B.sort(key=lambda x:x[1], reverse=True)
C = [i for i,j in B]
# print(C)
for i in range(n):
for j in range(m):
if S[i][j] == "o":
scor... | ConDefects/ConDefects/Code/abc323_c/Python/54745257 |
condefects-python_data_1142 | n, m = map(int, input().split())
a = list(map(int, input().split()))
s = [input() for _ in range(n)]
score = [i+1 for i in range(n)]
for i in range(n):
for j in range(m):
if s[i][j] == "o":
score[i] += a[j]
top = max(score)
for i in range(n):
need = top - score[i]
rest = []
for j i... | ConDefects/ConDefects/Code/abc323_c/Python/54930796 |
condefects-python_data_1143 | n, m = map(int, input().split())
l = list(map(int, input().split()))
player = []
for i in range(n):
player.append([input(), 0])
hi = [0, 0]
for i in range(n):
score = 0
for j, c in enumerate(player[i][0]):
if c == 'o':
score += l[j]
score += 1
player[i][1] = score
... | ConDefects/ConDefects/Code/abc323_c/Python/54308429 |
condefects-python_data_1144 | # セグ木のノードに長さを持たせる必要あり
class LazySegTree:
def _update(self, k):
# _d[k]を更新
self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])
def _all_apply(self, k, f):
# _d[k] <- f(_d[k])
self._d[k] = self._mapping(f, self._d[k])
# kが葉でないとき, fを_lz[k]に貯める
if k < self.... | ConDefects/ConDefects/Code/abc357_f/Python/54543446 |
condefects-python_data_1145 | import sys
import io, os
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
mod = 998244353
n, q = map(int, input().split())
x = 0
par = [-1]*n
sz = [1]*n
root = list(range(n))
g = [[] for _ in range(n)]
for i in range(q):
A, B, C = map(int, input().split())
t = (A*(x+1)%mod)%2 + 1
a = (B*(x+1)%mod... | ConDefects/ConDefects/Code/abc350_g/Python/52999831 |
condefects-python_data_1146 | from collections import deque
N, X = map(int, input().split())
ans = []
Q = deque()
for i in range(N):
if i + 1 != X:
Q.append(i + 1)
for i in range(N - 1):
if i % 2 != (X - N // 2) % 2:
ans.append(Q.pop())
else:
ans.append(Q.popleft())
ans.append(X)
print(*ans[::-1])
from colle... | ConDefects/ConDefects/Code/arc140_c/Python/38250831 |
condefects-python_data_1147 | from bisect import bisect_left
import sys
input = sys.stdin.readline
inf = float('inf')
def getInt():
return int(input())
def getStr():
return input().strip()
def getList(dtype=int, split=True):
s = getStr()
if split:
s = s.split()
return list(map(dtype, s))
t = 1
def lis(a):
h... | ConDefects/ConDefects/Code/arc140_c/Python/39550972 |
condefects-python_data_1148 | import collections
import math
import os
import random
import sys
from functools import reduce
from heapq import heappop, heappush
from io import BytesIO, IOBase
# Sample Inputs/Output
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()... | ConDefects/ConDefects/Code/arc140_c/Python/37080781 |
condefects-python_data_1149 | def ip():return int(input())
def mp():return map(int, input().split())
def lmp():return list(map(int, input().split()))
# ABC241 D 1177 - Sequence Query
# 空の数列 A があります。
# クエリが Q 個与えられるので、与えられた順番に処理してください。
# クエリは次の 3 種類のいずれかです。
# ・1 x : A に x を追加する。
# ・2 x k : A の x 以下の要素のうち、大きい方から k 番目の値を出力する。(k は 5 以下)
# ただし、A に x ... | ConDefects/ConDefects/Code/abc241_d/Python/45806316 |
condefects-python_data_1150 | import math
from bisect import bisect_left, bisect_right, insort
from typing import Generic, Iterable, Iterator, TypeVar, Union, List
T = TypeVar('T')
class SortedMultiset(Generic[T]):
BUCKET_RATIO = 50
REBUILD_RATIO = 170
def _build(self, a=None) -> None:
"Evenly divide `a` into buckets."
... | ConDefects/ConDefects/Code/abc241_d/Python/45777353 |
condefects-python_data_1151 | from collections import *
import heapq
import bisect
INF = float("inf")
MOD = 998244353
mod = 998244353
import bisect
class BIT:
def __init__(self, n):
self.n = len(n) if isinstance(n, list) else n
self.size = 1 << (self.n - 1).bit_length()
if isinstance(n, list): # nは1-indexedなリスト
... | ConDefects/ConDefects/Code/abc241_d/Python/45284602 |
condefects-python_data_1152 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
T = int(readline())
mod = 998_244_353
for _ in range(T):
N = int(readline())
S = readline()
dp = [[0, 0] for _ in range((N - 1) // 2 + 1 + 1)]
dp[0][0] = 1
for i in range((N - 1) // 2 + 1):
s ... | ConDefects/ConDefects/Code/abc242_e/Python/45535167 |
condefects-python_data_1153 | N,Q=map(int,input().split())
connects=[[-1,-1] for _ in range(N)]
for _ in range(Q):
query=list(map(int,input().split()))
t=query[0]
x=query[1]-1
if t==1:
y=query[2]-1
connects[x][1]=y
connects[y][0]=x
elif t==2:
y=query[2]-1
connects[x][1]=-1
connect... | ConDefects/ConDefects/Code/abc225_d/Python/45240176 |
condefects-python_data_1154 | a,b = map(int, input().split())
ct=[[0],[1],[2],[1,2],[4],[1,4],[2,4],[1,2,7]]
taka=ct[a]
ao=ct[b]
su=taka+ao
ans=set(su)
sim=sum(ans)
print(sim)
a,b = map(int, input().split())
ct=[[0],[1],[2],[1,2],[4],[1,4],[2,4],[1,2,4]]
taka=ct[a]
ao=ct[b]
su=taka+ao
ans=set(su)
sim=sum(ans)
print(sim) | ConDefects/ConDefects/Code/abc270_a/Python/46202213 |
condefects-python_data_1155 | a,b = map(int,input().split())
ans = a ^ b
print(ans)
a,b = map(int,input().split())
ans = a | b
print(ans) | ConDefects/ConDefects/Code/abc270_a/Python/44921373 |
condefects-python_data_1156 | def getIntMap():
return map(int, input().split())
def getIntList():
return list(map(int, input().split()))
def main():
n, p, q = getIntMap()
a = getIntList()
b = min([p - q + a[i] for i in range(n)])
print(b if b < p else p)
if __name__ == "__main__":
main()
def getIntMap():
ret... | ConDefects/ConDefects/Code/abc310_a/Python/45785883 |
condefects-python_data_1157 | N, P, Q = map(int, input().split())
D = list(map(int, input().split()))
ans = P
for i in range(N):
ret = P - Q + D[i]
ans = min(ans, ret)
print(ans)
N, P, Q = map(int, input().split())
D = list(map(int, input().split()))
ans = P
for i in range(N):
ret = Q + D[i]
ans = min(ans, ret)
print(ans)
| ConDefects/ConDefects/Code/abc310_a/Python/45951629 |
condefects-python_data_1158 | n, p, q = map(int, input().split(' '))
d = list(map(int, input().split(' ')))
print(min(p, p - q + min(d)))
n, p, q = map(int, input().split(' '))
d = list(map(int, input().split(' ')))
print(min(p, q + min(d)))
| ConDefects/ConDefects/Code/abc310_a/Python/46023025 |
condefects-python_data_1159 | N, P, Q = map(int, input().split())
D = list(map(int, input().split()))
res = P
for d in D:
if (p := P - Q + d) < res:
res = p
print(res)
N, P, Q = map(int, input().split())
D = list(map(int, input().split()))
res = P
for d in D:
if (p := Q + d) < res:
res = p
print(res)
| ConDefects/ConDefects/Code/abc310_a/Python/45739812 |
condefects-python_data_1160 | n, p, q = map(int,input().split())
d_list = [int(e) for e in input().split()]
a = min(d_list)
print(min(p-q+a,p))
n, p, q = map(int,input().split())
d_list = [int(e) for e in input().split()]
a = min(d_list)
print(min(q+a,p)) | ConDefects/ConDefects/Code/abc310_a/Python/46010909 |
condefects-python_data_1161 | import sys
# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n", end="\n\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, ... | ConDefects/ConDefects/Code/abc230_g/Python/27770752 |
condefects-python_data_1162 | from atcoder.segtree import SegTree
N=int(input())
S={0}
P=[None]*N
for i in range(N):
h,w,d=map(int,input().split())
S.add(h); S.add(w); S.add(d)
P[i]=(h,w,d)
D={v:i for i,v in enumerate(sorted(S))}
points=[]
for i in range(N):
a,b,c=list(sorted(P[i]))
a=D[a]; b=D[b]; c=D[c]
points.append((a,b,c))
points... | ConDefects/ConDefects/Code/abc309_f/Python/55142933 |
condefects-python_data_1163 | class SegmentTree:
def __init__(self, n, identity_e, combine_f):
"""
配列を 2 * n 個のノードで初期化する(0-indexed, 頂点は1から)
n: 列の長さ
identity_e: 単位元
combine_f: 2つのデータから値を合成するための関数
node: 各頂点の中身
"""
self._n = n
self._size = 1
while self._size < self._n:... | ConDefects/ConDefects/Code/abc309_f/Python/51733804 |
condefects-python_data_1164 | #N,M=map(int, input().split())
N=int(input())
D={};E=[];F=[]
for i in range(N):
B=list(map(int, input().split()))
B=sorted(B)
a,b,c=B
F.append(b)
if a not in D:
D[a]=[];E.append(a)
D[a].append((b,c))
#print(D,E)
E=sorted(E)
FF={}
F=sorted(list(set(F)))
for i in range(len(F)):
FF[F[i]]=i
#print(FF)
#... | ConDefects/ConDefects/Code/abc309_f/Python/52944581 |
condefects-python_data_1165 | from collections import defaultdict
from math import inf
from sys import stdin
class FastIO:
def __init__(self):
self.random_seed = 0
self.flush = False
self.inf = 1 << 32
return
@staticmethod
def read_int():
return int(stdin.readline().rstrip())
@staticmethod... | ConDefects/ConDefects/Code/abc309_f/Python/51247653 |
condefects-python_data_1166 | class SegTree:
def __init__(self, op, e, seq):
if type(seq) is int:
seq = [e]*seq
self.N = len(seq)
self.e = e
self.op = op
self.X = [e]*(self.N * 2)
self._build(seq)
def _build(self, seq):
X = self.X
op = self.op
for i, x in enumerate(seq, self.N)... | ConDefects/ConDefects/Code/abc309_f/Python/52283209 |
condefects-python_data_1167 | import math
import re
import functools
import random
import sys
import os
import typing
from math import gcd,comb
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from itertools import accumulate, combinations, permutations
from heapq import nsmallest, nlargest, heappushpop, h... | ConDefects/ConDefects/Code/abc309_f/Python/52190693 |
condefects-python_data_1168 | from collections import defaultdict
import heapq
N,M = map(int, input().split())
in_edges = [0]*(N+1)
G = defaultdict(list)
for _ in range(M):
A,B = map(int, input().split())
G[A].append(B)
in_edges[B] += 1
H = []
for i in range(1,N+1):
if in_edges[i] == 0:
heapq.heappush(H, i)
heapq.heapify(... | ConDefects/ConDefects/Code/abc223_d/Python/45783590 |
condefects-python_data_1169 | import heapq
N,M=map(int,input().split())
graph=[[] for _ in range(N)]
reversed_graph=[set() for _ in range(N)]
pairs=set()
que=set(range(N))
for _ in range(M):
u,v=map(int,input().split())
pair=(u-1,v-1)
if pair in pairs:
continue
graph[u-1].append(v-1)
reversed_graph[v-1].add(u-1)
if ... | ConDefects/ConDefects/Code/abc223_d/Python/45718110 |
condefects-python_data_1170 | # Python3/Pypy3テンプレート集
#ライブラリ-------------------------------------------------------------------
from bisect import *
import heapq
import collections
from collections import deque
from queue import Queue
from itertools import groupby
import itertools
import math
import array
import string
import copy
from decimal impo... | ConDefects/ConDefects/Code/abc304_c/Python/45117916 |
condefects-python_data_1171 | string = input()
start = string.find("|", 0)
end = string.find("|", start + 1) + 1
if not(start == (end - 2)): string = string.replace(string[start:end+1], "")
else: string = string.replace("|", "")
print(string)
string = input()
start = string.find("|", 0)
end = string.find("|", start + 1) + 1
if not(start == (end - ... | ConDefects/ConDefects/Code/abc344_a/Python/54865781 |
condefects-python_data_1172 | import math
from bisect import bisect_left, bisect_right, insort
from typing import Generic, Iterable, Iterator, TypeVar, Union, List
T = TypeVar('T')
class SortedMultiset(Generic[T]):
BUCKET_RATIO = 50
REBUILD_RATIO = 170
def _build(self, a=None) -> None:
"Evenly divide `a` into buckets."
... | ConDefects/ConDefects/Code/abc239_e/Python/45522067 |
condefects-python_data_1173 | n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[0]*n
for i in range(n):
p[i]-=1
q[p[i]]=i
e=[]
for i in range(n):
r=[j for j in range(i) if q[j]-q[i]>=k]
s=i
for t in r[::-1]:
q[s],q[t]=q[s],q[t]
e+=[(q[s],q[t])]
s=t
print(len(e))
for i,j in e:
print(i+1,j+1)
n,k=map(int,input(... | ConDefects/ConDefects/Code/arc180_b/Python/55029920 |
condefects-python_data_1174 | # ﷽
from collections import deque
import sys
input = lambda: sys.stdin.readline().strip()
def inlst():return [int(i) for i in input().split()]
oo=float('inf')
def solve():
n,k=inlst()
lst=inlst()
q=[0]*n
for i,e in enumerate(lst):
q[e-1]=i
ans=deque()
for i in range(n):
cur=... | ConDefects/ConDefects/Code/arc180_b/Python/55028160 |
condefects-python_data_1175 | from fractions import Fraction
inf = float("inf")
N = int(input())
X = []
for _ in range(N):
x, y = map(int, input().split())
a1 = x
b1 = y - 1
t1 = Fraction(b1, a1)
a2 = x-1
b2 = y
if a2 == 0:
t2 = inf
else:
t2 = Fraction(b2, a2)
X.append((t1, t2))
X.sort... | ConDefects/ConDefects/Code/abc225_e/Python/45312408 |
condefects-python_data_1176 | n = int(input())
A = list(map(int, input().split()))
for i in range(2000):
if i not in A:
print(i)
break
n = int(input())
A = list(map(int, input().split()))
for i in range(2001):
if i not in A:
print(i)
break | ConDefects/ConDefects/Code/abc245_b/Python/45497244 |
condefects-python_data_1177 | N = int(input())
A = set(map(int, input().split()))
for i in range(2000):
if i not in A:
print(i)
break
N = int(input())
A = set(map(int, input().split()))
for i in range(2001):
if i not in A:
print(i)
break | ConDefects/ConDefects/Code/abc245_b/Python/45513233 |
condefects-python_data_1178 | N = int(input())
A = list(map(int,input().split()))
for i in range(N):
if i not in A:
print(i)
break
N = int(input())
A = list(map(int,input().split()))
for i in range(2001):
if i not in A:
print(i)
break | ConDefects/ConDefects/Code/abc245_b/Python/45550937 |
condefects-python_data_1179 | n=int(input())
a=list(map(int,input().split()))
a.sort()
if(n>=2):
a=a[1:]
cnt=0
ans='Yes'
for i in range(max(1,n-1)):
if(i>=1 and a[i]==a[i-1]):
cnt+=1
else:
cnt=1
if(cnt>=(n+1)//2):
ans='No'
break
print(ans)
n=int(input())
a=list(map(int,input().split()))
a.sort()
if(n>=2):
a=a[1:]
cnt=0
an... | ConDefects/ConDefects/Code/arc161_a/Python/44901264 |
condefects-python_data_1180 | N=int(input())
A=list(map(int,input().split()))
A.sort()
if N==1:
print("Yes")
exit()
B=[0]*N
for i in range(N):
if i<=N//2:
B[2*i]=A[i]
else:
B[2*i-N]=A[i]
for i in range(N):
if i%2!=0:
continue
if B[i-1]<B[i] and B[i]>B[i+1]:
continue
else:
print("No... | ConDefects/ConDefects/Code/arc161_a/Python/45669630 |
condefects-python_data_1181 | n=int(input())
a=[]
a=list(map(int,input().split()))
a.sort()
c1=0
c2=0
for i in range(n//2,-1,-1):
if a[i]==a[n//2]:
c1+=1
else:
break
for i in range(n//2+1,n):
if a[i]==a[n//2]:
c2+=1
else:
break
if (n+1)//2-c1>c2:
print("Yes")
else:
print("No")
n=int(input())
... | ConDefects/ConDefects/Code/arc161_a/Python/46209025 |
condefects-python_data_1182 | n = int(input())
A = list(map(int,input().split()))
if n==1:
print("")
exit()
for i in range(n-1):
if A[i] > A[i+1]:
x = A[i]
break
else:
x = A[i]
print(*[a for a in A if a!=x])
n = int(input())
A = list(map(int,input().split()))
if n==1:
print("")
exit()
for i in range(n-1):... | ConDefects/ConDefects/Code/arc133_a/Python/46026088 |
condefects-python_data_1183 | import sys
input = sys.stdin.buffer.readline
# def input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(10 ** 7)
N = int(input())
A = list(map(int, (input().split())))
def f(x):
a = []
for i in range(N):
if A[i]!=x:
a.append(A[i])
return a
x = A[-1]
for i in range(N-1... | ConDefects/ConDefects/Code/arc133_a/Python/42717104 |
condefects-python_data_1184 | N = int(input())
A = list(map(int, input().split()))
tmp = A[0]
for i in range(1, N):
if tmp > A[i]: continue
tmp = A[i]
for i in A:
if i != tmp:
print(i, end=" ")
print()
N = int(input())
A = list(map(int, input().split()))
tmp = A[0]
for i in range(1, N):
if tmp > A[i]: break
tmp = A... | ConDefects/ConDefects/Code/arc133_a/Python/42236836 |
condefects-python_data_1185 | n=int(input())
a=list(map(int,input().split()))
if a.count(a[0])==n:
print()
exit()
ind=0
pre=0
d=dict()
while ind!=n:
cnt=0
pre=ind-1
while ind!=n-1 and a[ind]==a[ind+1]:ind+=1
if ind==n-1:break
# print(pre,ind)
if pre!=-1 and a[pre]>a[ind] and d.get(a[pre],0)<=1:
ans=[]
... | ConDefects/ConDefects/Code/arc133_a/Python/41861434 |
condefects-python_data_1186 | n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
for a,b in ab:
graph[a].append(b)
graph[b].append(a)
conn = [len(graph[i]) for i in range(n+1)]
leaf = []
for i in range(1,n+1):
if conn[i] == 1:
leaf.append(i)
ans = [0 for i in range(n+1)]
while le... | ConDefects/ConDefects/Code/arc156_c/Python/38986255 |
condefects-python_data_1187 | n = int(input())
ans = []
import collections
suu = collections.deque(range(1,n+1))
for i in range(n):
if i % 2 == 0:
ans.append(suu.popleft())
else:
ans.append(suu.pop())
#print(ans)
for i in range(n):
print(*ans)
for j in range(n):
ans[j] += 5
n = int(input())
ans = []
import c... | ConDefects/ConDefects/Code/arc142_b/Python/36923533 |
condefects-python_data_1188 | n=int(input())
a=[[i*n+j+1 for j in range(n)]for i in range(n)]
# for i in a:print(i)
for i in range(n):
if i%2==0:continue
for j in range(n//2):
a[i][2*j],a[i][2*j+1]=a[i][2*j+1],a[i][2*j]
for i in a:print(*i)
n=int(input())
a=[[i*n+j+1 for j in range(n)]for i in range(n)]
# for i in a:print(i)
for i ... | ConDefects/ConDefects/Code/arc142_b/Python/43401988 |
condefects-python_data_1189 | N=int(input())
A=[]
for i in range(N):
C,D=[],[]
for j in range(1,N+1):
n=3*i+j
if len(C)<(N+1)//2:
C.append(n)
else:
D.append(n)
ans=''
for j in range(1,N+1):
if j%2==1:
ans+=str(C[j//2])
else:
ans+=str(D[(j-1)//2])... | ConDefects/ConDefects/Code/arc142_b/Python/43257604 |
condefects-python_data_1190 | N = int(input())
S,T = [], []
for i in range(N):
if i % 2 == 1:
S.append([i*N+x+1 for x in range(N)])
else:
T.append([i*N+x+1 for x in range(N)])
for s, t in zip(S,T):
print(*s)
print(*t)
N = int(input())
S,T = [], []
for i in range(N):
if i % 2 == 1:
S.append([i*N+x+1 for... | ConDefects/ConDefects/Code/arc142_b/Python/44212876 |
condefects-python_data_1191 | n=int(input())
k=list(range(n))
x=[0]*n
x[0::2]=k[n//2:]
x[1::2]=k[:n//2]
for i in x:
print(*list(range(i*n,(i+1)*n)))
n=int(input())
k=list(range(n))
x=[0]*n
x[0::2]=k[n//2:]
x[1::2]=k[:n//2]
for i in x:
print(*list(range(i*n+1,(i+1)*n+1))) | ConDefects/ConDefects/Code/arc142_b/Python/43475268 |
condefects-python_data_1192 | from math import ceil
n=int(input())
l=[*range(1,n*n+1)]
idx=0
hlf=ceil(n*n/2)
for i in range(n//2):
print(*l[idx:idx+n])
print(*l[idx+hlf:hlf+idx+n])
idx+=n
if n//2!=n/2:
print(*l[idx:idx+n])
from math import ceil
n=int(input())
l=[*range(1,n*n+1)]
idx=0
hlf=n*ceil(n/2)
for i in range(n//2):
print... | ConDefects/ConDefects/Code/arc142_b/Python/43208367 |
condefects-python_data_1193 | n = int(input())
n-=1
"""
九桁で、
1 2
5 6
7 9 が同じ数字でないといけない。
"""
# 1,2 5,6 7,9
#3 4 8は何でもいい
l = 100000
while n != 0:
l += 1
l %= 1000000
n -= 1
print(l)
ans = ["" for i in range(9)]
l_s = list(str(l))
ans[0] = l_s[0]
ans[1] = l_s[0]
ans[4] = l_s[3]
ans[5] = l_s[3]
ans[6] = l_s[4]
ans[8] = l_s[4]
ans[2] = ... | ConDefects/ConDefects/Code/arc153_a/Python/45913281 |
condefects-python_data_1194 | N=int(input())
cnt=0
#AABCDDEFE
for i in range(100000,999999):
cnt+=1
if cnt==N:
print(int(str(i)[0]+str(i)[0]+str(i)[1]+str(i)[2]+str(i)[3]+str(i)[3]+str(i)[4]+str(i)[5]+str(i)[4]))
exit()
N=int(input())
cnt=0
#AABCDDEFE
for i in range(100000,1000000):
cnt+=1
if cnt==N:
print... | ConDefects/ConDefects/Code/arc153_a/Python/41006180 |
condefects-python_data_1195 | N = int(input())
n = N + 100000 - 1
a, b, c, d, e, f = str(n)
P = f"{a}{a}{b}{b}{c}{d}{d}{e}{f}{e}"
print(P)
N = int(input())
n = N + 100000 - 1
a, b, c, d, e, f = str(n)
P = f"{a}{a}{b}{c}{d}{d}{e}{f}{e}"
print(P)
| ConDefects/ConDefects/Code/arc153_a/Python/44669278 |
condefects-python_data_1196 | #https://atcoder.jp/contests/arc153/tasks/arc153_a
N = int(input())
A, B, C, D, E, F = str(100_000 + (N - 1))
ANS = "".join((A, A, B, C, D, D, E, F, E))
print(str(100_000 + (N - 1)))
#https://atcoder.jp/contests/arc153/tasks/arc153_a
N = int(input())
A, B, C, D, E, F = str(100_000 + (N - 1))
ANS = "".join((A, A... | ConDefects/ConDefects/Code/arc153_a/Python/40626179 |
condefects-python_data_1197 | x = int(input())
if x % 10 == 0:
print(x)
else:
print(x // 10 + 1)
x = int(input())
if x % 10 == 0:
print(x // 10)
else:
print(x // 10 + 1) | ConDefects/ConDefects/Code/abc345_b/Python/54913953 |
condefects-python_data_1198 | X = int(input())
if X < 0:
result = int(X//10)
else:
result = int(X//10 + 1)
print(result)
X = int(input())
if X % 10 == 0:
result = int(X//10)
else:
result = int(X//10 + 1)
print(result) | ConDefects/ConDefects/Code/abc345_b/Python/54914858 |
condefects-python_data_1199 | def main():
n = int(input())
print(n // 10)
if __name__ == '__main__':
main()
def main():
n = int(input())
print(-(-n // 10))
if __name__ == '__main__':
main() | ConDefects/ConDefects/Code/abc345_b/Python/54904819 |
condefects-python_data_1200 | x = int(input())
if x % 10 == 0:
print(int(x / 10))
else:
print(int(x // 10 + 1))
x = int(input())
if x % 10 == 0:
print(int(x // 10))
else:
print(int(x // 10 + 1)) | ConDefects/ConDefects/Code/abc345_b/Python/54787477 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.