id stringlengths 24 27 | content stringlengths 37 384k | max_stars_repo_path stringlengths 51 51 |
|---|---|---|
condefects-python_data_2101 | S = list(input())
num = [0]*1000
for s in S:
num[S.count(s)] += 1
for n in num:
if n % 2 != 0:
print('No')
exit()
print('Yes')
S = list(input())
num = [0]*1000
for s in S:
num[S.count(s)] += 1
for n in num:
if 2 * num.index(n) != n:
print('No')
exit()
print('Yes') | ConDefects/ConDefects/Code/abc349_b/Python/54751980 |
condefects-python_data_2102 | S = input()
lst, element, rest, cnt_lst = [], [], [], []
now = ""
for a in S:
lst.append(a)
lst = sorted(lst)
for a in lst:
if now != a:
element.append(a)
now = a
for m in element:
rest.append(lst.count(m))
for n in range(len(S)):
cnt_element = rest.count(n)
if cnt_element == 0 or cn... | ConDefects/ConDefects/Code/abc349_b/Python/54918141 |
condefects-python_data_2103 | from collections import defaultdict
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return ... | ConDefects/ConDefects/Code/abc349_g/Python/52509388 |
condefects-python_data_2104 | from math import gcd
l, r = map(int, input().split())
x = r - l
for i in range(x):
for j in range(i + 1):
gcd(l + j, x - i) == 1 or exit(print(x - i))
from math import gcd
l, r = map(int, input().split())
x = r - l
for i in range(x):
for j in range(i + 1):
gcd(l + j, x - i) == 1 and exit(print(x - i)) | ConDefects/ConDefects/Code/arc137_a/Python/44383228 |
condefects-python_data_2105 | import math
l,r=map(int,input().split())
k=0
while True:
flag=False
for i in range(k):
r2=r-i
l2=l+k-i
if math.gcd(l2,r2)==1:
flag=True
if flag:
print (r-l-k)
exit()
k+=1
import math
l,r=map(int,input().split())
k=0
while True:
flag=False
for i in range(k+1):
r2=r-i
l2=l+... | ConDefects/ConDefects/Code/arc137_a/Python/45348542 |
condefects-python_data_2106 | N = int(input())
A,B=[],[]
for i in range(N):
A.append(input())
for i in range(N):
B.append(input())
for i in range(N):
if A[i] != B[i]:
for j in range(N):
if A[i][j] != B[i][j]:
print(i,j)
N = int(input())
A,B=[],[]
for i in range(N):
A.append(input())
for i in range(N):
B.append(input(... | ConDefects/ConDefects/Code/abc351_b/Python/54891565 |
condefects-python_data_2107 | def find_differing_cell(N, A, B):
for i in range(N):
for j in range(N):
if A[i][j] != B[i][j]:
#print(i+1, j+1)
return (i + 1, j + 1)
N=int(input())
A = [['a' for x in range(N)] for y in range(N)]
B = [['a' for x in range(N)] for y in range(N)]
for i in range(N):
ch = str(... | ConDefects/ConDefects/Code/abc351_b/Python/54978591 |
condefects-python_data_2108 | N, M = map(int, input().split())
if M == 0:
for i in range(N, 0, -1):
print(i)
exit()
from collections import defaultdict, deque
AB = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
AB[i] = sorted(AB[i], reverse=True)
AB.sort(key = lambda x: (x[1], x[0]), reverse=True)
class... | ConDefects/ConDefects/Code/abc229_e/Python/44646979 |
condefects-python_data_2109 | def main():
n, m = map(int,input().split())
h = list(map(int,input().split()))
hand = 0
for i in range(len(h)):
hand = hand + h[i]
if hand > m:
print(i)
break
elif hand == m:
print(i+1)
break
if __name__ == "__main__":
main(... | ConDefects/ConDefects/Code/abc357_a/Python/55021619 |
condefects-python_data_2110 | N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
sum = 0
i = 0
while i < N:
sum += H[i]
if sum > M:
print(i)
break
i += 1
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
sum = 0
i = 0
while i < N:
sum += H[i]
if sum > M:
break
i += 1
prin... | ConDefects/ConDefects/Code/abc357_a/Python/55033452 |
condefects-python_data_2111 | N,M=map(int,input().split())
H = list(map(int,input().split()))
cnt=0
for i in range(len(H)):
if M-H[i] <= 0:
break
M = M - H[i]
cnt += 1
print(cnt)
N,M=map(int,input().split())
H = list(map(int,input().split()))
cnt=0
for i in range(len(H)):
if M-H[i] < 0:
break
M = M - H[i]
cn... | ConDefects/ConDefects/Code/abc357_a/Python/55135395 |
condefects-python_data_2112 | N,M = map(int,input().split())
H = list(map(int,input().split()))
s = 0
for i in range(N):
if H[i] > M:
break
else:
M -= (i + 1)
s += 1
print(s)
N,M = map(int,input().split())
H = list(map(int,input().split()))
s = 0
for i in range(N):
if H[i] > M:
break
else:
M ... | ConDefects/ConDefects/Code/abc357_a/Python/55022235 |
condefects-python_data_2113 | N, M = map(int, input().split())
H = list(map(int, input().split()))
total = M
for i in range(N):
total -= H[i]
if total < 0:
print(i + 1)
break
else:
print(N)
N, M = map(int, input().split())
H = list(map(int, input().split()))
total = M
for i in range(N):
total -= H[i]
if total ... | ConDefects/ConDefects/Code/abc357_a/Python/54997913 |
condefects-python_data_2114 | N,M = map(int, input().split())
H = list(map(int, input().split()))
for i in range(N):
M = M-H[i]
if M == 0:
print(i+1)
break
if M < H[i]:
print(i)
break
if M > 0:
print(N)
N,M = map(int, input().split())
H = list(map(int, input().split()))
for i in range(N):
M = ... | ConDefects/ConDefects/Code/abc357_a/Python/55131574 |
condefects-python_data_2115 | n = list(map(int, input().split()))
a = list(map(int, input().split()))
c = 0
b = 0
for i in range(n[0]):
c = c + a[i]
b = b + 1
if c >= n[1]:
break
if c == n[1]:
print(b)
elif c < n[1]:
print(1)
else:
print(b - 1)
n = list(map(int, input().split()))
a = list(map(int, input().split()))... | ConDefects/ConDefects/Code/abc357_a/Python/54987751 |
condefects-python_data_2116 | ' %s'%[*open(0)][1].find('ABC')
print(f' {[*open(0)][1]}'.find('ABC')) | ConDefects/ConDefects/Code/abc322_a/Python/46216926 |
condefects-python_data_2117 | N,S=[*open(0)];print(S.find('ABC'))
N,S=[*open(0)];print(('a'+S).find('ABC')) | ConDefects/ConDefects/Code/abc322_a/Python/46216512 |
condefects-python_data_2118 | (' '+list(open(0))[1]).find('ABC')
print((' '+[*open(0)][1]).find('ABC')) | ConDefects/ConDefects/Code/abc322_a/Python/46216252 |
condefects-python_data_2119 | N = int(input())
S = input()
for i in range(N-3):
if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
print(i+1)
exit()
else:
print(-1)
N = int(input())
S = input()
for i in range(N-2):
if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
print(i+1)
exit()
else:
print(-1) | ConDefects/ConDefects/Code/abc322_a/Python/54895050 |
condefects-python_data_2120 | s = input()
ret = -1
for i in range(0, len(s)-2):
if s[i:i + 3] == 'ABC':
ret = i + 1
break
n = input()
s = input()
ret = -1
for i in range(0, len(s)-2):
if s[i:i + 3] == 'ABC':
ret = i + 1
break
print(ret) | ConDefects/ConDefects/Code/abc322_a/Python/46196055 |
condefects-python_data_2121 | n = int(input())
s = input()
if "ABC" in s:
print(s.find("ABC"))
else:
print(-1)
n = int(input())
s = input()
if "ABC" in s:
print(s.find("ABC") + 1)
else:
print(-1) | ConDefects/ConDefects/Code/abc322_a/Python/54685843 |
condefects-python_data_2122 | N, S = open(0)
print(S.find("ABC") if "ABC" in S else -1)
N, S = open(0)
print(S.find("ABC") + 1 if "ABC" in S else -1) | ConDefects/ConDefects/Code/abc322_a/Python/46192605 |
condefects-python_data_2123 | print([*open(0)][1].find('ABC')+1)
print(('x'+[*open(0)][1]).find('ABC')) | ConDefects/ConDefects/Code/abc322_a/Python/46216132 |
condefects-python_data_2124 | input()
idx = input().find('ABC')
print(idx + 1 if idx > 0 else idx)
input()
idx = input().find('ABC')
print(idx + 1 if idx >= 0 else idx) | ConDefects/ConDefects/Code/abc322_a/Python/46209873 |
condefects-python_data_2125 | N = int(input())
S = input()
def check():
for i in range(N-3):
if S[i] + S[i+1] + S[i+2] == "ABC":
return i+1
return -1
print(check())
N = int(input())
S = input()
def check():
for i in range(N-2):
if S[i] + S[i+1] + S[i+2] == "ABC":
return i+1
return -1
print(check()) | ConDefects/ConDefects/Code/abc322_a/Python/55169673 |
condefects-python_data_2126 | N = int(input())
S = input()
ans = S.find("ABC")
if ans > 0:
print(ans+1)
else:
print(ans)
N = int(input())
S = input()
ans = S.find("ABC")
if ans >= 0:
print(ans+1)
else:
print(ans) | ConDefects/ConDefects/Code/abc322_a/Python/46206505 |
condefects-python_data_2127 | n,s = input(),'k'+input()
a = s.find('ABC') + 1
print(a)
n,s = input(),'k'+input()
a = s.find('ABC')
print(a) | ConDefects/ConDefects/Code/abc322_a/Python/46197070 |
condefects-python_data_2128 | N = int(input())
S = list(input())
count = 0
check = False
for i in range(len(S)-2):
count += 1
if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
check == True
break
if check == True:
print(count)
else:
print(-1)
N = int(input())
S = list(input())
count = 0
check = False
for i in range(len(S)-2):
... | ConDefects/ConDefects/Code/abc322_a/Python/46206584 |
condefects-python_data_2129 | c = "atcorder"
x, y = map(int, input().split())
print(c[x-1:y])
c = "atcoder"
x, y = map(int, input().split())
print(c[x-1:y]) | ConDefects/ConDefects/Code/abc264_a/Python/46142360 |
condefects-python_data_2130 | st, en = map(int, input().split())
print("atcoder"[st+1: en])
st, en = map(int, input().split())
print("atcoder"[st-1: en])
| ConDefects/ConDefects/Code/abc264_a/Python/46014113 |
condefects-python_data_2131 | def func():
# 入力を取得
L, R = list(map(int, input().split()))
s = "atcoder"
print(s[L+1:R+1])
if __name__ == '__main__':
func()
def func():
# 入力を取得
L, R = list(map(int, input().split()))
s = "atcoder"
print(s[L-1:R])
if __name__ == '__main__':
func() | ConDefects/ConDefects/Code/abc264_a/Python/45803747 |
condefects-python_data_2132 | S = input()
T = input()
k = ord(S[0]) - ord(T[0])
for i in range(1, len(S)):
if chr(ord(S[i]) - k) != T[i]:
print('No')
exit()
print('Yes')
S = input()
T = input()
k = ord(S[0]) - ord(T[0])
for i in range(1, len(S)):
if ((ord(S[i]) - k) - ord('a')) % 26 != ord(T[i]) - ord('a'):
pri... | ConDefects/ConDefects/Code/abc232_b/Python/44895571 |
condefects-python_data_2133 | S=input()
T=input()
W='abcdefghijklmnopqrstuvwxyz'
ans=True
N=W.find(T[0])-W.find(S[0])
for i in range(len(S)):
n=W.find(T[i])-W.find(S[i])
if n!=N:
if abs(n)!=26+N:
ans=False
if ans==True:
print('Yes')
else:
print('No')
S=input()
T=input()
W='abcdefghijklmnopqrstuvwxyz'
ans=True
N=W.find(... | ConDefects/ConDefects/Code/abc232_b/Python/45532739 |
condefects-python_data_2134 | S = input()
T = input()
k = ord(T[0]) - ord(S[0]) if ord(T[0]) - ord(S[0]) >= 0 else ord(T[0]) - ord(S[0])+26
print(ord(S[0]))
print(ord(T[0]))
for i in range(len(S)-1):
l = ord(T[i+1]) - ord(S[i+1]) if ord(T[i+1]) - ord(S[i+1]) >= 0 else ord(T[i+1]) - ord(S[i+1])+26
if not (k==l):
print('No')
... | ConDefects/ConDefects/Code/abc232_b/Python/45719934 |
condefects-python_data_2135 | S=input()
T=input()
cnt=set()
N=len(S)
for i in range(N):
cnt.add(ord(S[i])-ord(T[i]))
if len(cnt)==1:
print("Yes")
else:
print("No")
S=input()
T=input()
cnt=set()
N=len(S)
for i in range(N):
cnt.add((ord(S[i])-ord(T[i]))%26)
if len(cnt)==1:
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc232_b/Python/45920866 |
condefects-python_data_2136 | from collections import deque
import sys
N, M = map(int, input().split())
relations = [[] for _ in range(N)]
color = ["u"] * N
for _ in range(M):
u, v = map(int, input().split())
relations[u-1].append(v-1)
relations[v-1].append(u-1)
K = int(input())
infos = [None] * K
for i in range(K):
infos[i] = list(... | ConDefects/ConDefects/Code/abc299_e/Python/45347612 |
condefects-python_data_2137 | standard_input, packages, output_together = 1, 1, 1
dfs, hashing, read_from_file = 1, 1, 0
de = 1
class SortedList:
def __init__(self, iterable=None, _load=200):
"""Initialize sorted list instance."""
if iterable is None:
iterable = []
values = sorted(iterable)
self._len ... | ConDefects/ConDefects/Code/abc358_d/Python/54977408 |
condefects-python_data_2138 | # 入力
num_item, num_friend = input().split()
num_item, num_friend = int(num_item), int(num_friend)
item_data = sorted(list(map(int, input().split())))
friend_data = sorted(list(map(int, input().split())))
cost = 0
buy_flg = True
item_idx = 0
friend_idx=0
if item_data[-1] < friend_data[-1]:
buy_flg=False
while friend_i... | ConDefects/ConDefects/Code/abc358_d/Python/55035534 |
condefects-python_data_2139 | N = int(input())
while N % 2 == 0:
N //= 2
print(N)
while N % 3 == 0:
N //= 3
print(N)
print("Yes" if N == 1 else "No")
N = int(input())
while N % 2 == 0:
N //= 2
while N % 3 == 0:
N //= 3
print("Yes" if N == 1 else "No") | ConDefects/ConDefects/Code/abc324_b/Python/54985902 |
condefects-python_data_2140 | import sympy
N = int(input())
A = set(sympy.factorint(N).keys())
print("Yes" if A == set([2, 3]) or A == set([2]) or A == set([3]) else "No")
import sympy
N = int(input())
A = set(sympy.factorint(N).keys())
print("Yes" if A == set([2, 3]) or A == set([2]) or A == set([3]) or A == set() else "No") | ConDefects/ConDefects/Code/abc324_b/Python/54981446 |
condefects-python_data_2141 | n = int(input())
while n % 3 == 0:
n //= 3
while n % 2 == 0:
n //= 2
print("Yes" if n == 0 else "No")
n = int(input())
while n % 3 == 0:
n //= 3
while n % 2 == 0:
n //= 2
print("Yes" if n == 1 else "No")
| ConDefects/ConDefects/Code/abc324_b/Python/54903435 |
condefects-python_data_2142 | from sys import setrecursionlimit, exit, stdin
from math import ceil, floor, sqrt, pi, factorial, gcd, log
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from bisect import bisect, bisect_left, bisect_right
def iinput(): return int(input())
def imap(): return map(int, i... | ConDefects/ConDefects/Code/abc235_e/Python/44788391 |
condefects-python_data_2143 | import sys, math, bisect, heapq, copy, decimal, random, fractions
from itertools import permutations, combinations, product, accumulate, groupby
from collections import defaultdict, deque, Counter
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 8)
"""
n = int(input())
n, m = map(int, input().s... | ConDefects/ConDefects/Code/abc235_e/Python/45321024 |
condefects-python_data_2144 | # import系 ---
from heapq import heappush, heappop
from math import factorial
# 入力用 ---
INT = lambda: int(input())
MI = lambda: map(int, input().split())
MI_DEC = lambda: map(lambda x: int(x) - 1, input().split())
LI = lambda: list(map(int, input().split()))
LI_DEC = lambda: list(map(lambda x: int(x) - 1, input().split... | ConDefects/ConDefects/Code/abc291_b/Python/45669598 |
condefects-python_data_2145 | n, l, r = map(int, input().split())
start_lis = [i for i in range(1, l)]
middle_lis = list(reversed([i for i in range(l, r+1)]))
final_lis = [i for i in range(r+1, n + 1)]
# 各リストをフラット化して1つのリストに結合
combined_lis = start_lis + middle_lis + final_lis
print(tuple(combined_lis))
n, l, r = map(int, input().split())
start... | ConDefects/ConDefects/Code/abc356_a/Python/55030560 |
condefects-python_data_2146 |
N, L, R = list(map(int, input().split()))
A = list(range(1, N+1))
L-=1
A[L:R] = A[L:R][::-1]
print(A)
N, L, R = list(map(int, input().split()))
A = list(range(1, N+1))
L-=1
A[L:R] = A[L:R][::-1]
print(" ".join(map(str, A)))
| ConDefects/ConDefects/Code/abc356_a/Python/55140373 |
condefects-python_data_2147 | N,L,R=map(int,input().split())
num=[]
for x in range(1,N+1):
if x<L:
num.append(x)
elif x>=L:
for y in range(R,L-1,-1):
num.append(y)
break
for z in range(R+1,N+1):
num.append(z)
print(num)
N,L,R=map(int,input().split())
num=[]
for x in range(1,N+1):
if x<L:
... | ConDefects/ConDefects/Code/abc356_a/Python/54990500 |
condefects-python_data_2148 | N,L,R = map(int,input().split())
L-=1
A=list(range(1,N+1))
A[L:R] = reversed(A[L:R])
result = ' '.join(map(str, A))
print(f"A' = ({result})")
N,L,R = map(int,input().split())
L-=1
A=list(range(1,N+1))
A[L:R] = reversed(A[L:R])
result = ' '.join(map(str, A))
print(result)
| ConDefects/ConDefects/Code/abc356_a/Python/54989904 |
condefects-python_data_2149 | n,l,r=map(int,input().split())
a=[]
for k in range(1,l):
a.append(k+1)
for R in range(r,l-1,-1):
a.append(R)
for x in range(r+1,n+1):
a.append(x)
print(*a)
n,l,r=map(int,input().split())
a=[]
for k in range(1,l):
a.append(k)
for R in range(r,l-1,-1):
a.append(R)
for x in range(r+1,n+1):
a.append(x)
print... | ConDefects/ConDefects/Code/abc356_a/Python/54976789 |
condefects-python_data_2150 | N, L, R = map(int, input().split())
A = [0] + [i for i in range(1, N+1)]
Larr = A[:L]
center = reversed(A[L:R+1])
Rarr = A[R+1:]
ans = Larr + list(center) + Rarr
ans = ans[1:]
print(ans)
N, L, R = map(int, input().split())
A = [0] + [i for i in range(1, N+1)]
Larr = A[:L]
center = reversed(A[L:R+1])
Rarr = A[R+... | ConDefects/ConDefects/Code/abc356_a/Python/55107232 |
condefects-python_data_2151 | n, l , r = map(int, input().split())
result = []
for i in range(1, l):
result.append(i)
for i in range(r, l - 1, -1):
result.append(i)
for i in range(r + 1, n + 1):
result.append(i)
print(result)
n, l , r = map(int, input().split())
result = []
for i in range(1, l):
result.append(i)
for i in range(r, l... | ConDefects/ConDefects/Code/abc356_a/Python/55041853 |
condefects-python_data_2152 | import sys
from collections import defaultdict
ipt = sys.stdin.readline
MOD = 998244353
def iin():
return int(ipt())
def lmin():
return list(map(int,ipt().split()))
def floor_sum_unsigned(n, m, a, b):
mod = MOD # 必要なら
ans = 0
while True:
# 領域①
if a >= m:
ans += n * (n -... | ConDefects/ConDefects/Code/abc313_g/Python/46134579 |
condefects-python_data_2153 | print(int(input())%100)
print(input()[1:]) | ConDefects/ConDefects/Code/abc254_a/Python/45547154 |
condefects-python_data_2154 | print(int(input()) % 100)
print('%02d' % (int(input()) % 100)) | ConDefects/ConDefects/Code/abc254_a/Python/45462198 |
condefects-python_data_2155 | # import sys
# sys.setrecursionlimit(10**6)
import re
import copy
import bisect
import math
from collections import deque
from collections import defaultdict
from collections import Counter
from heapq import heapify, heappush, heappop, heappushpop, heapreplace
from functools import cmp_to_key as cmpk
import functools
a... | ConDefects/ConDefects/Code/abc257_f/Python/45055612 |
condefects-python_data_2156 | import collections
N, M = map(int, input().split())
links = [[] for _ in range(N+1)]
for _ in range(M):
u, v = map(int, input().split())
links[u].append(v)
links[v].append(u)
inf = float("inf")
def bfs(s):
visited = [inf] * (N+1)
visited[s] = 0
que = collections.deque([s])
while que:
... | ConDefects/ConDefects/Code/abc257_f/Python/45331235 |
condefects-python_data_2157 | n,m = map(int, input().split())
from collections import deque
tele = []
g = [[] for _ in range(n)]
for _ in range(m):
u,v = map(int, input().split())
u-=1
v-=1
if u == -1:
tele.append(v)
else:
g[u].append(v)
g[v].append(u)
inf = 10**18
#0からn-1への最短距離
d = deque()
d.append(0)
dist1 = [inf]*n
dist1... | ConDefects/ConDefects/Code/abc257_f/Python/45698858 |
condefects-python_data_2158 | # 0を超頂点として持つ
# 考えられる経路としては、
# 0を経由しない状態での経路、0経由する経路の2つ
# 0を経由しない場合は、1を始点としてBFSすれば良い
# 0を経由する場合を考える
# any -> 0へ行く場合をコスト1として、0->anyをコスト0と考える
# 0 -> iを考える。
# iが最短経路上に行くときは、1 -> 0 -> iのときのコストと1 -> iのときのコストを比べる
# このときにcost(1 -> i) > cost(1 -> 0 -> i)だったらcost(1->0->i->N)にすればいい
# そうでなければcost(1 -> i)を採用する
# 1 -> Nへいけない場合
# この場... | ConDefects/ConDefects/Code/abc257_f/Python/45897088 |
condefects-python_data_2159 | from collections import deque
import sys
INF = 10**9
def main():
input = sys.stdin.readline
N, M = map(int, input().split())
G = [[] for _ in range(N + 1)]
T = []
for _ in range(M):
u, v = map(int, input().split())
u = u - 1 if u > 0 else N
v = v - 1
G[u].append(v)
... | ConDefects/ConDefects/Code/abc257_f/Python/45053747 |
condefects-python_data_2160 | a,b,c,d=map(int,input().split())
print((a+b)*(c-d))
print('takahashi')# coding: utf-8
# Your code here!
a,b,c,d=map(int,input().split())
print((a+b)*(c-d))
print('Takahashi')# coding: utf-8
# Your code here! | ConDefects/ConDefects/Code/abc269_a/Python/45960652 |
condefects-python_data_2161 | a,b,c,d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
print((a+b)*(c-d))
print('takahashi')
a,b,c,d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
print((a+b)*(c-d))
print('Takahashi') | ConDefects/ConDefects/Code/abc269_a/Python/45960382 |
condefects-python_data_2162 | a, b, c, d = map(int, input().split())
print(((a + b) * (a - d)))
print("Takahashi")
a, b, c, d = map(int, input().split())
print(((a + b) * (c - d)))
print("Takahashi") | ConDefects/ConDefects/Code/abc269_a/Python/45960449 |
condefects-python_data_2163 | import bisect, collections, copy, heapq, itertools, math, string
import random
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip... | ConDefects/ConDefects/Code/abc260_g/Python/33361937 |
condefects-python_data_2164 | def main():
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
X = sorted(A)
Y = sorted(B)
if X != Y:
print("No")
return
if len(set(A)) == len(A):
print("Yes")
return
ct = 0
for b in B:
x = A.index(b)
ct +=... | ConDefects/ConDefects/Code/arc136_b/Python/35227817 |
condefects-python_data_2165 | def update(index, val):
# val 是增量, 如果是修改值记得计算增量
# val = val - query_lr(index,index)
while index <= n:
tree[index] += val
index += index & (-index)
def query(r):
res = 0
while r > 0:
res += tree[r]
r -= r & (-r)
return res
from collections import Counter
n = int(... | ConDefects/ConDefects/Code/arc136_b/Python/36890038 |
condefects-python_data_2166 | INF = 1 << 64
mod1 = 10**9 + 7
mod2 = 998244353
dir = [(1, 0), (0, 1), (-1, 0), (0, -1)]
import sys
from collections import defaultdict, deque
#from functools import lru_cache
#@lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
def ni(): return int(input())
def na(): return map(int, input().split())
def... | ConDefects/ConDefects/Code/arc136_b/Python/37078962 |
condefects-python_data_2167 | # import sys
# sys.setrecursionlimit(10**7)
import re
import copy
import bisect
import math
import itertools
import more_itertools
from collections import deque
from collections import defaultdict
from collections import Counter
from heapq import heapify, heappush, heappop, heappushpop, heapreplace
from functools impor... | ConDefects/ConDefects/Code/abc267_d/Python/45812454 |
condefects-python_data_2168 | N,M = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0]*N for i in range(M)]
dp[0][0]=A[0]
for i in range(1,N):
dp[0][i]=max(A[i],dp[0][i-1])
for i in range(1,M):
for j in range(i,N):
dp[i][j]=max(dp[i-1][j-1]+A[j]*(i+1),dp[i][j-1])
print(dp[-1][-1])
N,M = map(int,input().split()... | ConDefects/ConDefects/Code/abc267_d/Python/45231504 |
condefects-python_data_2169 | N, M = map(int, input().split())
A_L = list(map(int, input().split()))
inf = -10**18
dp = [[inf] * (M + 10) for i in range(N + 10)]
dp[0][0] = 0
for i in range(N):
for j in range(M):
if dp[i][j] == inf:
continue
dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (j + 1) * A_L[i])
... | ConDefects/ConDefects/Code/abc267_d/Python/45469454 |
condefects-python_data_2170 | N,M = map(int,input().split())
a = [*map(int,input().split())]
dp = [[None]*(M+1) for n in range(N+1)]
dp[0][0]=0
for n in range(N):
for m in range(M+1):
if dp[n][m] is not None:
dp[n+1][m] = max(dp[n+1][m],dp[n][m]) if dp[n+1][m] is not None else dp[n][m]
if m<M : dp[n+1][m+1] = max... | ConDefects/ConDefects/Code/abc267_d/Python/45515271 |
condefects-python_data_2171 | n,m=map(int,input().split())
A=list(map(int,input().split()))
dp=[[-(10**10) for i in range(m+1)]for j in range(n+1)]
nowmax=2
for i in range(1,n+1):
a=A[i-1]
before=dp[i-1]
for j in range(1,nowmax):
if j==1:
if before[j]<a:
dp[i][j]=a
else:
dp[i][j]=before[j]
else:
if be... | ConDefects/ConDefects/Code/abc267_d/Python/45019438 |
condefects-python_data_2172 | INT = lambda : int(input())
MI = lambda : map(int, input().split())
MI_DEC = lambda : map(lambda x : int(x)-1, input().split())
LI = lambda : list(map(int, input().split()))
LI_DEC = lambda : list(map(lambda x : int(x)-1, input().split()))
N, M = MI()
A = LI()
dp = [[-float('inf')]*(M+1) for i in range(N+1)]
dp[0][0]... | ConDefects/ConDefects/Code/abc267_d/Python/45550363 |
condefects-python_data_2173 | N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
inf = 10**18
dp = [ [-inf] * (M + 1) for _ in range(N + 1) ]
for i in range(N + 1):
dp[i][0] = 0
for j in range(M + 1):
dp[0][j] = 0
for i in range(1, N + 1):
a = A[i - 1]
maxm = min(M, i)
for j in range(1, maxm + 1):
... | ConDefects/ConDefects/Code/abc267_d/Python/45032308 |
condefects-python_data_2174 | a,b = map(int, input().split())
print(a**3)
a,b = map(int, input().split())
print(a**b) | ConDefects/ConDefects/Code/abc283_a/Python/44590701 |
condefects-python_data_2175 | A, B = map(int, input().split())
print(A^B)
A, B = map(int, input().split())
print(A**B) | ConDefects/ConDefects/Code/abc283_a/Python/44656811 |
condefects-python_data_2176 | def getIntMap():
return map(int, input().split())
def main():
a, b = getIntMap()
print(a*b)
main()
def getIntMap():
return map(int, input().split())
def main():
a, b = getIntMap()
print(a**b)
main()
| ConDefects/ConDefects/Code/abc283_a/Python/44652899 |
condefects-python_data_2177 | n, q = map(int, input().split())
idx = list(range(n+1))
num = list(range(n+1))
for i in range(q):
x = int(input())
y = idx[x]
if y == n:
y = n-1
num[y], num[y+1] = num[y+1], num[y]
idx[num[y]] = y
idx[num[y+1]] = y+1
print(*idx[1:])
n, q = map(int, input().split())
idx = list(r... | ConDefects/ConDefects/Code/abc250_c/Python/44890242 |
condefects-python_data_2178 | import sys
import copy
from collections import deque,defaultdict
import math
import heapq
from itertools import accumulate
import itertools
from functools import reduce
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = math.inf
input = lambda: sys.stdin.re... | ConDefects/ConDefects/Code/abc250_c/Python/45205318 |
condefects-python_data_2179 | N, Q = map(int, input().split())
X = []
for i in range(Q):
x = int(input())
X.append(x)
pos = [i for i in range(N + 1)] #pos[i] := i番目の要素の値
val = [i for i in range(N + 1)] #val[i] := iは何番目 - 1にあるか
for i in range(Q):
p0 = pos[X[i]]
p1 = p0
if p0 != N:
p1 += 1
else:
p1 -= 1
v0 = val[p0]
v1 = val... | ConDefects/ConDefects/Code/abc250_c/Python/44899033 |
condefects-python_data_2180 | N,Q = map(int,input().split())
li = [i for i in range(N+1)]
ind = [i for i in range(N+1)]
for i in range(Q):
A = int(input())
B = ind[A]
if B != N:
temp = li[B]
li[B] = li[B+1]
li[B+1] = temp
ind[A] = B+1
ind[li[B]] = B
else:
temp = li[B]
li[B... | ConDefects/ConDefects/Code/abc250_c/Python/44862385 |
condefects-python_data_2181 | n,m=map(int,input().split())
for _ in range(n):
a=list(input())
for i in range(m-1):
if a[i]=='T' and a[i+1]=='T':
a[i],a[i+1]='P','T'
print(''.join(a))
n,m=map(int,input().split())
for _ in range(n):
a=list(input())
for i in range(m-1):
if a[i]=='T' and a[i+1]=='T':
a[i],a[i+1]='P','C... | ConDefects/ConDefects/Code/abc297_c/Python/46194170 |
condefects-python_data_2182 | n=int(input())
s=input()
if "ab" or "ba" in s:
print("Yes")
else:
print("No")
n=int(input())
s=input()
if "ab" in s or "ba" in s:
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc327_a/Python/54966208 |
condefects-python_data_2183 | N = int(input())
S = input()
if "a" in S and "b" in S:
print("Yes")
else:
print("No")
N = int(input())
S = input()
if "ab" in S or "ba" in S:
print("Yes")
else:
print("No") | ConDefects/ConDefects/Code/abc327_a/Python/54982866 |
condefects-python_data_2184 | N = int(input())
S = input()
ok = ["a", "b"]
for i in range(N-1):
if S[i] in ok and S[i+1] in ok:
print("Yes")
exit()
print("No")
N = int(input())
S = input()
ok = ["a", "b"]
for i in range(N-1):
if S[i] in ok and S[i+1] in ok and S[i] != S[i+1]:
print("Yes")
exit()
print("No") | ConDefects/ConDefects/Code/abc327_a/Python/54666524 |
condefects-python_data_2185 | N = int(input())
S = input()
f = False
for i in range(N - 1):
if S[i] == "a" and S[i + 1] == "b":
f = True
if f:
print("Yes")
else:
print("No")
N = int(input())
S = input()
f = False
for i in range(N - 1):
if (S[i] == "a" and S[i + 1] == "b") or (S[i] == "b" and S[i + 1] == "a"):
f =... | ConDefects/ConDefects/Code/abc327_a/Python/54677762 |
condefects-python_data_2186 | n = int(input())
s = input()
for i in range(n-1):
if s[i]+s[i+1] == "ab":
print("Yes")
break
else:
print("No")
n = int(input())
s = input()
for i in range(n-1):
if s[i]+s[i+1] == "ab" or s[i]+s[i+1] == "ba":
print("Yes")
break
else:
print("No") | ConDefects/ConDefects/Code/abc327_a/Python/54767724 |
condefects-python_data_2187 | s = input()
t = input()
ls = []
lt = []
c = 1
for i in range(len(s)):
if i != len(s)-1 and s[i] == s[i+1]:
c += 1
else:
ls.append([s[i],c])
c = 1
c = 1
for i in range(len(t)):
if i != len(t)-1 and t[i] == t[i+1]:
c += 1
else:
lt.append([t[i],c])
c = 1
if l... | ConDefects/ConDefects/Code/abc259_c/Python/46054515 |
condefects-python_data_2188 | import itertools
S = list(input())
T = list(input())
s = [[key , len(list(group))] for key , group in itertools.groupby(S)]
t = [[key , len(list(group))] for key , group in itertools.groupby(T)]
if len(s) != len(s) :
print('No')
exit()
for i in range(len(s)) :
if s[i][0] != t[i][0] :
print('No')
e... | ConDefects/ConDefects/Code/abc259_c/Python/45537510 |
condefects-python_data_2189 | from itertools import groupby
S = input()
T = input()
def runLengthEncode(S: str) -> "list[tuple(str, int)]":
grouped = groupby(S)
res = []
for k, v in grouped:
res.append((k, int(len(list(v)))))
return res
SS = runLengthEncode(S)
TT = runLengthEncode(T)
if len(SS) != len(TT):
print('No')... | ConDefects/ConDefects/Code/abc259_c/Python/44929141 |
condefects-python_data_2190 | S=input()
T=input()
lis=[]
lit=[]
i=0
kari="A"
cnt=0
while i<=len(S)-1:
if i==0:
kari=S[i]
cnt+=1
else:
if S[i-1]==S[i]:
cnt+=1
else:
lis.append((kari,cnt))
kari=S[i]
cnt=1
i+=1
lis.append((kari,cnt))
i=0
kari="A"
cnt=0
whi... | ConDefects/ConDefects/Code/abc259_c/Python/45103556 |
condefects-python_data_2191 | def f(s):
n = len(s)
ans = []
l = 0
while l < n:
r = l + 1
while r < n and s[l] == s[r]:
r += 1
ans.append((s[l], r - l))
l = r
return ans
s = input()
t = input()
s_l = f(s)
t_l = f(t)
if len(s_l) != len(t_l):
exit(print('No'))
flg = 1
for i in ran... | ConDefects/ConDefects/Code/abc259_c/Python/44774986 |
condefects-python_data_2192 | S = list(input())
T = list(input())
S_count = []
T_count = []
sf = S[0]
S_count.append([sf, 1])
for i in range(1, len(S)):
if sf == S[i]:
S_count[-1][1] += 1
else:
sf = S[i]
S_count.append([sf, 1])
tf = T[0]
T_count.append([tf, 1])
for i in range(1, len(T)):
if tf == T[i]:
... | ConDefects/ConDefects/Code/abc259_c/Python/44859677 |
condefects-python_data_2193 | S = input()
T = input()
A = list()
B = list()
cnt = 0
c = ''
for s in S:
if (cnt == 0):
c = s
cnt += 1
elif (s == c):
cnt += 1
else:
A.append((c,str(cnt)))
c = s
cnt = 1
A.append((c,str(cnt)))
cnt = 0
c = ''
for t in T:
if (cnt == 0):
c = t
... | ConDefects/ConDefects/Code/abc259_c/Python/44826067 |
condefects-python_data_2194 | s = input()
t = input()
k = 0
l = []
m = []
for i in range(1,len(s)):
if s[i-1]!=s[i]:
l.append(s[k:i])
k = i
l.append(s[k:])
k = 0
for j in range(1,len(t)):
if t[j-1]!=t[j]:
m.append(t[k:j])
k = j
m.append(t[k:])
if len(m)!=len(l):
print("No")
exit()
for o in range(len(l)):
if l[o]==m[o]:
... | ConDefects/ConDefects/Code/abc259_c/Python/45350488 |
condefects-python_data_2195 | N, K = map(int, input().split())
A = list(map(int, input().split()))
if K % 2 != 0:
now = 0
for i in range(1, K-1, 2):
now += A[i+1] - A[i]
ans = now
for i in range(2, K-1, 2):
now += A[i-1] - A[i-2]
now -= A[i] - A[i-1]
ans = min(ans, now)
print(ans)
exit()
ans ... | ConDefects/ConDefects/Code/abc334_c/Python/54507811 |
condefects-python_data_2196 | import math
import sys
import random
from collections import deque
from itertools import product
debug = lambda name, value, *args, **kwargs: print( f"{name}: {value}", *args, file=sys.stderr, **kwargs)
mod = 1000000007
m = random.randint(1,1000000)
iinf = 100000000000000005 #1e18 + 5
input = lambda: sys.stdin.read... | ConDefects/ConDefects/Code/abc334_c/Python/54724339 |
condefects-python_data_2197 | n,k=map(int,input().split())
a=list(map(int,input().split()))
if(k%2==0):
ans=0
for i in range(1,k,2):
ans+=(a[i]-a[i-1])
print(ans)
else:
pre=[0]*(k+1)
after=[0]*(k+1)
for i in range(1,k+1):
pre[i]=pre[i-1]
if(i%2==0):
pre[i]+=a[i]-a[i-1]
for i in range(k-2,-1,-1):
after[i]=a... | ConDefects/ConDefects/Code/abc334_c/Python/55003175 |
condefects-python_data_2198 | n, k = map(int, input().split())
a = list(map(int, input().split()))
l = [a[i + 1] - a[i] for i in range(0, k - 1, 2)]
if k % 2 == 0:
print(sum(l))
exit()
r = [a[i + 1] - a[i] for i in reversed(range(1, k - 1, 2))]
l = [0] + l
r = [0] + r
for i in reversed(range(k // 2)):
l[i + 1] += l[i]
r[i + 1] += r[... | ConDefects/ConDefects/Code/abc334_c/Python/54936414 |
condefects-python_data_2199 | N, X = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
if P[i] == X:
print(i)
break
N, X = map(int, input().split())
P = list(map(int, input().split()))
for i in range(N):
if P[i] == X:
print(i+1)
break | ConDefects/ConDefects/Code/abc277_a/Python/45949578 |
condefects-python_data_2200 | n, x = map(int, input().split())
p = list(map(int, input().split()))
print(p.index(x))
n, x = map(int, input().split())
p = list(map(int, input().split()))
print(p.index(x)+1)
| ConDefects/ConDefects/Code/abc277_a/Python/45114990 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.