code1
stringlengths 17
427k
| code2
stringlengths 17
427k
| similar
int64 0
1
| pair_id
int64 2
181,637B
⌀ | question_pair_id
float64 3.7M
180,677B
⌀ | code1_group
int64 1
299
| code2_group
int64 1
299
|
---|---|---|---|---|---|---|
S=input()
K=int(input())
import copy
num=1
liS=[]
for i in range(len(S)-1):
if S[i]==S[i+1]:
num+=1
else:
liS.append(num)
num=1
liS.append(num)
liSR=copy.copy(liS)
liSR[0]+=liSR[-1]
del liSR[-1]
if liSR!=[] and S[0]==S[-1]:
for j in range(len(liS)):
liS[j]=liS[j]//2
for k in range(len(liSR)):
liSR[k]=liSR[k]//2
print(sum(liSR)*(K-1)+sum(liS))
elif liSR!=[] and S[0]!=S[-1]:
for j in range(len(liS)):
liS[j]=liS[j]//2
print(sum(liS)*K)
else:
print((sum(liS)*K)//2)
| # A - Connection and Disconnection
def count(s, c):
count_ = s.count(c*2)
while c*3 in s:
s = s.replace(c*3, c+'_'+c)
while c*2 in s:
s = s.replace(c*2, c+'_')
return min(count_, s.count('_'))
def get_startswith(s, c):
key = c
while s.startswith(key+c):
key += c
return len(key)
def get_endswith(s, c):
key = c
while s.endswith(key+c):
key += c
return len(key)
import string
S = input()
K = int(input())
lower = string.ascii_lowercase
ans = 0
if S[0] == S[-1:]:
start = get_startswith(S, S[0])
end = get_endswith(S, S[0])
if start == end == len(S):
print(len(S) * K // 2)
else:
ans = 0
ans += start // 2
ans += end // 2
ans += ((start + end) // 2) * (K - 1)
for c in lower:
ans += count(S[start:len(S)-end], c) * K
print(ans)
else:
for c in lower:
ans += count(S, c)
print(ans * K) | 1 | 176,046,283,425,478 | null | 296 | 296 |
n = int(input())
s = "abcdefghij"
def func(a):
if len(a) == n:
print(a)
else:
for i in range(len(set(a))+1):
func(a+s[i])
func("a") | # パナソニック2020D
import sys
write = lambda x: sys.stdout.write(x+"\n")
from queue import deque
n = int(input())
q = deque([("a", "a")])
while True:
s, m = q.pop()
if len(s)==n:
write(s)
elif len(s)>=n+1:
break
for o in range(ord("a"), ord(m)+2):
if ord(m)<o:
m = chr(o)
q.appendleft((s + chr(o), m)) | 1 | 52,563,360,166,056 | null | 198 | 198 |
n = int(input())
ls = list(map(int, input().split()))
rsw = [0]*1005
for i in ls:
rsw[i] += 1
for i in range(1,1005):
rsw[i] = rsw[i-1] + rsw[i]
res = 0
for i in range(n):
for j in range(i+1,n):
a = ls[i]
b = ls[j]
low = abs(a-b)
high = a+b
tmp = rsw[min(high,1004)-1] - rsw[low]
if low < a < high:
tmp -= 1
if low < b < high:
tmp -= 1
res += tmp
print(res//3) | from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
k = l[i] + l[j]
pos = bisect_left(l, k)
ans += max(0, pos - j - 1)
print(ans) | 1 | 172,174,847,091,580 | null | 294 | 294 |
n=int(input())
a=[int(j) for j in input().split()]
p=[0]*n
d=[0]*n
for i in range(n):
p[i]=a[i]+p[i-2]
if (i&1):
d[i]=max(p[i-1],a[i]+d[i-2])
else:
d[i]=max(d[i-1],a[i]+d[i-2])
print(d[-1]) | import sys
import socket
from collections import deque
if socket.gethostname() in ['N551J', 'F551C']:
in_file = 'f1.in'
in_file = 'after_contest_01.in'
sys.stdin = open(in_file)
def read_int_list():
return list(map(int, input().split()))
def read_int():
return int(input())
def read_str_list():
return input().split()
def read_str():
return input()
def solve():
n, d, a = read_int_list()
pairs = [read_int_list() for _ in range(n)]
pairs.sort()
x, h = map(list, zip(*pairs))
res = 0
damage = 0
q = deque()
for i in range(n):
# print(i, damage, file=sys.stderr)
while len(q) > 0 and q[0][0] + d < x[i]:
y, m = q.popleft()
damage -= m * a
if damage < h[i]:
y = x[i] + d
quotient, rest = divmod(h[i] - damage, a)
m = quotient + (rest > 0)
q.append((y, m))
damage += m * a
res += m
return res
def main():
res = solve()
print(res)
if __name__ == '__main__':
main()
| 0 | null | 59,738,800,266,662 | 177 | 230 |
[[print("{}x{}={}".format(i,j,i*j))for j in range(1,10)]for i in range(1,10)]
| ## coding: UTF-8
mod = 998244353
N, S = map(int,input().split())
A = list(map(int,input().split()))
dp = []
for i in range(N+1):
#dp.append([0]*3010)
dp.append([0]*(S+1))
#print(dp)
dp[0][0] = 1
#print(dp)
#print('dpstart')
for i in range(N):
for j in range(S+1):
dp[i+1][j] += dp[i][j]
dp[i+1][j] %= mod
dp[i+1][j] += dp[i][j]
dp[i+1][j] %= mod
if(j >= A[i]):
dp[i+1][j] += dp[i][j-A[i]]
dp[i+1][j] %= mod
#print(dp)
print(dp[N][S]) | 0 | null | 8,846,625,206,772 | 1 | 138 |
# 入力
D, T, S = input().split()
# 以下に回答を記入
D = int(D)
T = int(T)
S = int(S)
if T * S >= D:
print('Yes')
else:
print('No') | d,t,s = [int(x) for x in input().split()]
if d/s <= t:
print("Yes")
else:
print("No") | 1 | 3,557,637,860,722 | null | 81 | 81 |
sec_in = int(input())
hour = sec_in // 3600
minute = (sec_in % 3600) // 60
sec = sec_in % 60
print('{0}:{1}:{2}'.format(hour,minute,sec))
| while True:
a, b = map(int, input().split())
if a or b:
for i in range(0, a):
for j in range(0, b):
print("#", end = '')
print()
print()
else:
break
| 0 | null | 556,529,927,648 | 37 | 49 |
n, m = map(int, input().split())
ps = [input().split() for i in range(m)]
b = [False] * n
wa = [0] * n
for i in ps:
if b[int(i[0])-1] == False and i[1] == "AC":
b[int(i[0])-1] = True
elif b[int(i[0])-1] == False and i[1] == "WA":
wa[int(i[0])-1] += 1
print(b.count(True),end=" ")
ans = 0
for i in range(n):
if b[i]:
ans += wa[i]
print(ans) | n = int(input())
mod = 10**9 + 7
per = [1] * (n+1)
for i in range(1, n+1):
per[i] = per[i-1] * i
per[i] %= mod
inv = [1] * (n+1)
inv[-1] = pow(per[-1], mod-2, mod)
for j in range(2, n+2):
inv[-j] = inv[-j+1] * (n-j+2)
inv[-j] %= mod
def C(n, k):
cmb = per[n] * inv[k] * inv[n-k]
cmb %= mod
return cmb
total = 0
for k in range(1, n+1):
if n < 3*k:
break
total += C(n-2*k-1, k-1)
total %= mod
print(total)
| 0 | null | 48,224,562,967,830 | 240 | 79 |
import sys
def sieve(N):
is_prime = [True] * (N + 1)
prime_list = []
is_prime[0] = is_prime[1] = False
prime_list.append(2)
for i in range(3, N + 1, 2):
if is_prime[i]:
prime_list.append(i)
for j in range(i * i, N, i):
is_prime[j] = False
return prime_list
primes = sieve(10001)
primes_set = set(primes)
def is_prime(num):
if num in primes_set:
return True
elif num <= 10000:
return False
else:
for prime in primes:
if num % prime == 0:
return False
return True
if __name__ == '__main__':
N = sys.stdin.readline()
N = int(N)
ans = 0
for i in range(N):
num = sys.stdin.readline()
num = int(num)
if is_prime(num): ans += 1
sys.stdout.write(str(ans) + '\n') | class dictionary:
def __init__(self):
self._d = set()
def insert(self, s):
self._d.add(s)
def find(self, s):
if s in self._d:
print("yes")
else:
print("no")
if __name__ == '__main__':
dd = dictionary()
n = int(input())
for _ in range(n):
args = input().split()
if args[0] == "insert":
dd.insert(args[1])
elif args[0] == "find":
dd.find(args[1])
| 0 | null | 43,925,222,110 | 12 | 23 |
def gcd(x, y):
if x < y:
x, y = y, x
while y > 0:
r = x%y
x = y
y = r
return x
x, y = map(int, raw_input().split())
print gcd(x, y) | n = int(input())
a = list(map(int, input().split()))
num = [0]*(10**6+1)
for x in a:
if num[x] != 0:
num[x] = 2
continue
for i in range(x, 10**6+1, x):
num[i] += 1
ans = 0
for x in a:
if num[x] == 1:
ans += 1
print(ans) | 0 | null | 7,137,812,108,348 | 11 | 129 |
user_input=input()
i=len(user_input)-1
number=0
while i>=0:
number+=int(user_input[i])
i=i-1
if number%9==0:
print("Yes")
else :
print("No")
| # coding: utf-8
N = list(map(int,list(input())))
sN = sum(N)
if sN%9 ==0:
print("Yes")
else:
print("No")
| 1 | 4,394,011,258,000 | null | 87 | 87 |
while 1:
m,f,r=map(int,input().split());s=m+f
if m==f==r==-1:break
if m==-1 or f==-1 or s<30:print('F')
elif s>79:print('A')
elif s>64:print('B')
elif s>49 or r>49:print('C')
else:print('D') | N = int(input())
data = [list(map(int,input().split())) for i in range(N-1)]
G = {}
for i in range(1,N+1):
G[i] = []
for i in range(N-1):
G[data[i][0]].append((data[i][1],i+1))
G[data[i][1]].append((data[i][0],i+1))
M = max(len(G[i]) for i in range(1,N+1))
print(M)
from collections import deque
E = [0]+[-1]*(N-1) #辺
E[1] = 1
q = deque([[data[0][0],1],[data[0][1],1]])
while q:
n,i = q.pop()
c = 1
for dn,di in G[n]:
if E[di] != -1:
continue
else:
if c == E[i]:
E[di] = M
c += 1
q.append([dn,di])
else:
E[di] = c
c += 1
q.append([dn,di])
for i in range(1,N):
print(E[i]) | 0 | null | 68,853,090,361,720 | 57 | 272 |
def easy_linear_programming():
A, B, C, K = map(int, input().split())
if K <= A:
print(K)
elif K - A <= B:
print(A)
else:
k = K - A - B
print(A - k)
easy_linear_programming() | N = int(input())
a = N // 500
N -= 500 * a
b = N // 5
print(a * 1000 + b * 5)
| 0 | null | 32,429,775,007,110 | 148 | 185 |
n,k=map(int,input().split())
h=[int(i) for i in input().split()]
h=[i for i in h if i>=k]
print(len(h)) | from collections import defaultdict
def main():
d = defaultdict(int)
d2 = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
d[i + 1 + A[i]] += 1
d2[max(0, (i + 1) - A[i])] += 1
ans = 0
for k,v in d.items():
if k == 0:continue
ans += v * d2[k]
print(ans)
if __name__ == '__main__':
main() | 0 | null | 102,920,833,749,680 | 298 | 157 |
def main():
import bisect
n = int(input())
s = input()
r,g,b = 0,0,0
for i in range(n):
if s[i]=='R':
r+=1
elif s[i]=='G':
g+=1
else:
b+=1
ans = r*g*b
for i in range(n-1):
for j in range(i+1,n):
k = 2*(j+1)-(i+1)-1
if k>n-1:
continue
if s[i]!=s[j] and s[i] != s[k] and s[j]!=s[k]:
ans -= 1
print(ans)
if __name__ == "__main__":
main()
| n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
res = r*g*b
for i in range(n):
for j in range(n):
jj = i+j
k = jj+j
if k >= n: break
if s[i]!=s[jj] and s[jj]!=s[k] and s[k]!=s[i]:
res-=1
print(res)
| 1 | 36,122,423,740,868 | null | 175 | 175 |
def solve(n):
return (n - 1) // 2
assert solve(4) == 1
assert solve(999999) == 499999
n = int(input())
print(solve(n)) | import sys
from collections import deque
H,W=map(int,input().split())
S=list(sys.stdin)
ans=0
for i in range(H):
for j in range(W):
if S[i][j]=='#':
continue
dist=[[-1]*W for _ in range(H)]
dist[i][j]=0
que=deque()
que.append((i,j))
while que:
i,j=que.popleft()
ans=max(ans,dist[i][j])
for ni,nj in (i-1,j),(i,j+1),(i+1,j),(i,j-1):
if not (0<=ni<H and 0<=nj<W):
continue
if S[ni][nj]=='#' or dist[ni][nj]!=-1:
continue
dist[ni][nj]=dist[i][j]+1
que.append((ni,nj))
print(ans)
| 0 | null | 124,033,435,525,020 | 283 | 241 |
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
for i in range(n-k):
if t[k+i] == t[i]:
t[k+i] = 0
x = t.count('r')*p+ t.count('s')*r+t.count('p')*s
print(x) | # -*- coding: utf-8 -*-
X = int(input())
# A**5 - (A-1)**5 = X = 10**9(Xの最大) となるAが
# Aの最大値となる(それ以上Aが大きくなると、Xは上限値を超える)
# → 最大となるAは120
for A in range(-120, 120 + 1):
for B in range(-120, 120):
if A**5 - B**5 == X:
print("{} {}".format(A, B))
exit() | 0 | null | 65,859,681,823,300 | 251 | 156 |
#!/usr/bin/env python
# coding: utf-8
# In[15]:
N = int(input())
xy_list = []
for _ in range(N):
A = int(input())
xy = []
for _ in range(A):
xy.append(list(map(int, input().split())))
xy_list.append(xy)
# In[16]:
ans = 0
for i in range(2**N):
for j,a_list in enumerate(xy_list):
if (i>>j)&1 == 1:
for k,(x,y) in enumerate(a_list):
if (i>>(x-1))&1 != y:
break
else:
continue
break
else:
ans = max(ans, bin(i)[2:].count("1"))
print(ans)
# In[ ]:
| N = int(input())
memberlist = []
testinomylist = []
for _ in range(N):
A = int(input())
tmpmemberlist = []
tmptestinomylist = []
for i in range(A):
x, y = map(int, input().split())
tmpmemberlist.append(x)
tmptestinomylist.append(y)
memberlist.append(tmpmemberlist) # [[2,3],[1,3],[1]] こんな感じで人が収容
testinomylist.append(tmptestinomylist) # [[0,1],[1],[0]]
ans = 0
for i in range(2 ** N):
honestlist = []
liarlist = []
for j in range(N):
if ((i >> j) & 1):
#if true 条件を満たした人を正直物として考える.
honestlist.append(j+1)
else:
# if false の人は嘘つきものだと考える。
liarlist.append(j+1)
#正直な人だけを見ればいい。
Flag = 0
for honestnumber in honestlist: #bit全探索で得た正直な人の番号
for X,Y in zip(memberlist[honestnumber-1] , testinomylist[honestnumber-1]): # 正直な人だけの証言
if (Y == 0):
if X in liarlist: #正直者の証言が食い違ってないか
pass
else:
Flag = 1
elif (Y == 1):
if X in honestlist:
pass
else:
Flag = 1
if Flag == 1:
pass
else:
ans = max(ans,len(honestlist))
print(ans)
| 1 | 121,777,414,703,420 | null | 262 | 262 |
N = int(input())
L = input().split()
n = int(input())
l = input().split()
dup = []
count = 0
for i in range(N):
for j in range(n):
if L[i] == l[j]:
dup.append(L[i])
break
dup = list(set(dup))
print(len(dup))
| N = int(input())
line = [int(i) for i in input().split()]
sum = 1
line.sort(reverse=True)
if line[len(line) -1]== 0:
print(0)
exit()
for num in line:
sum = sum * num
if sum > 10 ** 18:
print(-1)
exit()
print(sum) | 0 | null | 8,198,894,548,362 | 22 | 134 |
import collections
N=int(input())
A=[x for x in input().split()]
c = collections.Counter(A)
for i in range(N):
print(c["{}".format(str(i+1))]) | n = int(input())
a = list(map(int,input().split()))
d = {}
for i in range(1,n+1):
if i not in d:
d[i] = 0
for i in range(len(a)):
d[a[i]] += 1
for i in range(1,n+1):
print(d[i]) | 1 | 32,330,982,526,180 | null | 169 | 169 |
s = input()
if(s[0] == 'R' and s[1] == 'R' and s[2] == 'R'):
print(3)
elif(s[0] == 'R' and s[1] == 'R' and s[2] == 'S'):
print(2)
elif(s[0] == 'S' and s[1] == 'R' and s[2] == 'R'):
print(2)
elif(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
print(1)
else:
print(0)
| S = input()
if ("RRR" in S):
print("3")
elif ("RR" in S):
print("2")
elif ("R" in S):
print("1")
else:
print("0") | 1 | 4,870,190,731,974 | null | 90 | 90 |
N = int(input())
A = []
for _ in range(N):
a = int(input())
b = []
for _ in range(a):
b.append(list(map(int, input().split())))
A.append(b)
# 証言リスト A[i人目][j個目の証言] -> [誰が, bit(1は正、0は誤)]
# bitが1であれば正しい証言、0であれば間違った証言とする
# 正しい証言だけ確認して、[i, 1]と証言した i も1かどうか、[j,0]と証言したjが0かどうか
def F(i):
cnt = 0
B = [-1]*N #B = [-1,-1,-1]
r = 0
for j in range(N): # i=1, j=0,1,2
if (i>>j)&1: # 001 -> 1,0,0 j=0
r += 1 # r = 1
if B[j] == 0: #B[0] == -1
return 0
B[j]=1 # B = [1,-1,-1]
for p,q in A[j]: # A[0] = [[2, 1], [3, 0]]
if q == 0:
if B[p-1]==1: # B[2] == -1
return 0
B[p-1] = 0 # B = [1,1,0]
else:
if B[p-1]==0: # B[1] == -1
return 0
B[p-1] = 1 # B = [1,1,-1]
else:
cnt += 1 # cnt = 1
else: # j=1
if B[j]==1: #B[1] ==1
return 0
B[j]=0
if cnt == r:
return cnt
ans = 0
for i in range(1<<N):
ans = max(ans,F(i))
print(ans) | N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
for i in range(1, N+1):
A[i] += A[i-1]
i = N
total = 0
ans = 0
for j in range(M+1):
total += B[j]
while i >= 0 and A[i]+total > K:
i -= 1
if A[i]+total <= K:
ans = max(ans, i+j)
print(ans) | 0 | null | 66,006,878,151,358 | 262 | 117 |
s = input()
if s == 'RRR':
print(3)
elif s[:2] == 'RR' or s[1:] == 'RR':
print(2)
elif s.count('R') >= 1:
print(1)
else:
print(0) | days, num = map(int, input().split())
hw = list(map(int, input().split()))
hang = days - sum(hw)
if hang < 0:
print("-1")
else:
print(hang) | 0 | null | 18,285,082,417,170 | 90 | 168 |
print("ACL"*int(input()))
| N = int(input())
print("ACL"*N)
| 1 | 2,171,604,908,160 | null | 69 | 69 |
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque
N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()
# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)
# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)
# def dfs(tree, s):
# for l in tree[s]:
# if depth[l[0]] == -1:
# depth[l[0]] = depth[s] + l[1]
# dfs(tree, l[0])
# dfs(tree, 1)
# def factorization(n):
# arr = []
# temp = n
# for i in range(2, int(-(-n**0.5//1))+1):
# if temp%i==0:
# cnt=0
# while temp%i==0:
# cnt+=1
# temp //= i
# arr.append([i, cnt])
# if temp!=1:
# arr.append([temp, 1])
# if arr==[]:
# arr.append([n, 1])
# return arr
A.insert(0, 0)
cnt = [0] * (N + 1)
ans = 0
for i in range(1, N + 1):
if i - A[i] >= 0:
ans += cnt[i - A[i]]
if i + A[i] <= N:
cnt[i + A[i]] += 1
print(ans) | K = int(input())
S = input()
print(S[:K]+"..." if len(S) > K else S) | 0 | null | 22,978,748,769,372 | 157 | 143 |
s=int(input())
a=[0]*(s+1)
a[0]=1
mod=10**9+7
for i in range(3,s+1):
a[i]=a[i-3]+a[i-1]
print(a[s]%mod)
| mod = 1000000007
ans = 0
power = [0 for i in range(2005)]
power[0] = 1
for i in range(1,2001):
power[i] = power[i-1] * i
def C(x,y):
return 0 if x < y else power[x] // power[y] // power[x-y]
def H(x,y):
return C(x+y-1,y-1)
n = int(input())
for i in range(3,n+1,3):
ans += H(n-i,i//3)
ans = (ans % mod + mod) % mod
print(ans) | 1 | 3,315,050,743,102 | null | 79 | 79 |
a,b = input().split()
aa,bb = int(a),int(b)
print(a * bb if a * bb < b * aa else b * aa) | n, k, c = map(int, input().split())
s = input()
l_list, r_list = [], []
tmp = 0
b = 0
for i in range(len(s)):
if s[i] == 'o' and b == 0 and tmp < k:
l_list.append(i)
tmp += 1
b = c
elif b > 0:
b -= 1
tmp = 0
b = 0
for i in range(len(s) - 1, -1, -1):
if s[i] == 'o' and b == 0 and tmp < k:
r_list.append(i)
tmp += 1
b = c
elif b > 0:
b -= 1
for i in range(k):
if r_list[k - i - 1] == l_list[i]:
print(l_list[i] + 1) | 0 | null | 62,415,467,466,784 | 232 | 182 |
n,k=map(int,input().split())
a=0
b=n
while b>=k:
b=b//k
a+=1
print(a+1)
| from collections import defaultdict
n = int(input())
m = n//2
INF = 10**18
dp = [defaultdict(lambda: -INF)for _ in range(n+2)]
for i, a in enumerate(map(int, input().split()), 2):
for j in range(max(1, i//2-1), -(-i//2)+1):
if j-1 == 0:
dp[i-2][j-1] = 0
dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+a)
print(dp[n+1][m])
| 0 | null | 51,213,152,741,274 | 212 | 177 |
X,K,D = map(int,input().split())
X = abs(X)
if X - D * K >= 0:
print(X - D * K)
else:
n = X // D
X -= n * D
if (K - n) % 2 == 0:
print(X)
else:
print(abs(X - D)) | import math
X,K,D = map(int,input().split())
X = abs(X)
if X > K*D:
print(X-K*D)
else:
c=math.floor(X/D)
print( abs(X-D*c-((K-c)%2)*D) )
| 1 | 5,197,575,329,920 | null | 92 | 92 |
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
flag = 0
count = 0
for i in range(N):
if D[i][0] == D[i][1]:
count += 1
else:
count = 0
if count >= 3:
flag = 1
break
if flag == 1:
print('Yes')
else:
print('No') | N = int(input())
zoro_count = 0
zoro = False
for n in range(N):
dn1,dn2 = map(int, input().split())
if dn1 == dn2:
zoro_count += 1
else:
zoro_count = 0
if zoro_count >= 3:
zoro = True
if zoro:
print('Yes')
else:
print('No') | 1 | 2,516,287,858,488 | null | 72 | 72 |
# from pprint import pprint
n = int(input())
a = map(int, input().split())
a = sorted(((ax, x) for x, ax in enumerate(a)), reverse=True)
dp = [[-1] * (n+1) for _ in range(n+1)]
dp[0][0] = 0
for i, (ax, x) in enumerate(a):
for j in range(i+1):
dp[j+1][i-j] = max(dp[j+1][i-j], dp[j][i-j] + ax*abs(x-j))
dp[j][i-j+1] = max(dp[j][i-j+1], dp[j][i-j] + ax*abs(n-1-x-i+j))
# pprint(dp)
print(max(dp[i][n-i] for i in range(n+1)))
| import pprint
N = int(input())
A = list(map(int, input().split()))
def student_sorting(N, A):
student_list = [0] * N
for initial_pos, activity in enumerate(A):
student_list[initial_pos] = (activity, initial_pos)
return sorted(student_list, reverse = True)
def DP(N, student_list):
DP_map = list(list(0 for row in range(N + 1 - column)) for column in range(N + 1))
ans_list = []
ans = 0
for left in range(N): #初期値設定 right = 0
activity = student_list[left][0]
distance_l = abs(left - student_list[left][1])
DP_map[left + 1][0] = DP_map[left][0] + activity * distance_l
for right in range(N): #初期値設定 left = 0
activity = student_list[right][0]
distance_r = abs((N - 1 - right) - student_list[right][1])
DP_map[0][right + 1] = DP_map[0][right] + activity * distance_r
for left in range(1, N + 1):
for right in range(1, N - left + 1):
activity = student_list[left + right - 1][0]
distance_l = abs((left - 1) - student_list[left + right - 1][1])
distance_r = abs((N - right) - student_list[left + right - 1][1])
score_if_appended_to_left = DP_map[left - 1][right] + activity * distance_l
score_if_appended_to_right = DP_map[left][right - 1] + activity * distance_r
DP_map[left][right] = max(score_if_appended_to_left, score_if_appended_to_right)
for left in range(N + 1):
row = N - left
column = left
ans_list.append(DP_map[column][row])
ans = max(ans_list)
return ans
student_list = student_sorting(N, A)
ans = DP(N, student_list)
print(ans)
| 1 | 33,751,996,963,200 | null | 171 | 171 |
import numpy as np
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
A, B = map(int, input().split())
uf.union(A-1, B-1)
print(uf.group_count()-1) | # cook your dish here
import sys
def file():
sys.stdin = open('input.py', 'r')
sys.stdout = open('output.py', 'w')
def main(N, arr):
#initialising with positive infinity value
maxi=float("inf")
#initialising the answer variable
ans=0
#iterating linesrly
for i in range(N):
#finding minimum at each step
maxi=min(maxi,arr[i])
#increasing the final ans
ans+=maxi
print("dhh")
#returning the answer
return ans
#file()
if __name__ == '__main__':
#length of the array
'''N = 4
#Maximum size of each individual bucket
Arr = [4,3,2,1]
#passing the values to the main function
answer = main(N,Arr)
#printing the result
print(answer)'''
n=int(input())
s=input()
#l=list(map(int, input().split()))
ans=0
for i in range(1,n):
if(s[i]!=s[i-1]):
ans+=1
print(ans+1)
| 0 | null | 86,293,273,938,816 | 70 | 293 |
# -*- coding: utf-8 -*-
from scipy.sparse.csgraph import floyd_warshall
N, M, L = map(int,input().split())
d = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
x,y,z = map(int,input().split())
d[x-1][y-1] = z
d[y-1][x-1] = z
for i in range(N):
d[i][i] = 0
d = floyd_warshall(d, directed = False)
LN = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
for j in range(N):
if d[i][j] <= L:
LN[i][j] = 1
LN[j][i] = 1
LN = floyd_warshall(LN, directed = False)
s = []
t = []
Q = int(input())
for i in range(Q):
s1, t1 = map(int,input().split())
s.append(s1)
t.append(t1)
for i in range(Q):
if LN[s[i]-1][t[i]-1] == float("inf"):
print(-1)
else:
print(int(LN[s[i]-1][t[i]-1]-1)) | def Warshall_Floyd(dist,n,restoration=False):
next_point = [[j for j in range(n)] for _ in range(n)]
for i in range(n):
for j in range(n):
for k in range(n):
if dist[j][k] > dist[j][i] + dist[i][k]:
next_point[j][k] = next_point[j][i]
dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])
if restoration:
return dist,next_point
else:
return dist
n,m,l = map(int,input().split())
inf = 10**18
dist = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
dist[i][i] = 0
for i in range(m):
a,b,c = map(int,input().split())
a -= 1
b -= 1
if c <= l:
dist[a][b] = c
dist[b][a] = c
dist = Warshall_Floyd(dist,n)
route = [[inf for i in range(n)] for j in range(n)]
for i in range(n):
for j in range(n):
if i == j:
route[i][j] = 0
elif dist[i][j] <= l:
route[i][j] = 1
route = Warshall_Floyd(route,n)
q = int(input())
for i in range(q):
s,t = map(int,input().split())
s -= 1
t -= 1
print(route[s][t]-1 if route[s][t] < inf else -1) | 1 | 173,477,466,779,668 | null | 295 | 295 |
s,t = input().split()
a,b = map(int,input().split())
u = input()
print(a if u == t else a-1, end = " ")
print(b-1 if u == t else b) | def main():
s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())
if s == u:
print(a-1, b)
else:
print(a, b-1)
if __name__ == "__main__":
main()
| 1 | 71,753,424,356,182 | null | 220 | 220 |
from bisect import bisect_left
def calc(N, A, cumsum, x):
num = N ** 2
total = cumsum[N] * N * 2
for a in A:
idx = bisect_left(A, x - a)
num -= idx
total -= cumsum[idx] + idx * a
return num, total
def main():
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cumsum = [0] * (N+1)
for i in range(N):
cumsum[i+1] = cumsum[i] + A[i]
lo = 0
hi = int(2e5+1)
while lo < hi:
mid = (lo + hi) // 2
num, total = calc(N, A, cumsum, mid)
if num <= M:
hi = mid
else:
lo = mid + 1
num, total = calc(N, A, cumsum, lo)
ans = total - (num - M) * (lo - 1)
print(ans)
if __name__ == "__main__":
main()
| from collections import deque
s=input()[::-1]
l=[0]*2019
ten=1
sm=0
cnt=0
l[0]=1
for i in range(len(s)):
sm += int(s[i])*ten
sm %= 2019
cnt += l[sm]
l[sm] += 1
ten = ten *10 %2019
print(cnt) | 0 | null | 69,631,462,364,798 | 252 | 166 |
def main():
a,b,c = map(int,input().split(" "))
if (c-a-b)**2 > a*b*4 and c > a + b:
print("Yes")
else:
print("No")
main() | from decimal import Decimal
a,b,c = map(int, input().split())
def convert(x):
return Decimal(str(x)).sqrt()
if convert(a) + convert(b) < convert(c):
print('Yes')
else:
print('No') | 1 | 51,313,441,764,640 | null | 197 | 197 |
N = int(input())
f = []
for i in range(N):
x, l = map(int, input().split())
f.append([x - l, x + l])
f.sort(key=lambda x: x[1])
t = f[0][1]
ans = 1
for i in range(1, N):
if f[i][0] < t:
continue
ans += 1
t = f[i][1]
print(ans)
| from operator import itemgetter
n = int(input())
lis = []
for _ in range(n):
x,l = map(int,input().split())
lis.append([x-l,x+l])
lis.sort(key = itemgetter(1))
ans = 0
last = -float("inf")
for i in range(n):
if lis[i][0] >= last:
ans += 1
last = lis[i][1]
print(ans) | 1 | 90,220,879,284,108 | null | 237 | 237 |
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import heapq
def main():
A=[]
B=[]
M=[]
values=[]
a,b,m = map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
M=[list(map(int,input().split())) for _ in range(m)]
# #割引した組み合わせ
for m in M:
values.append(A[m[0]-1]+B[m[1]-1]-m[2])
heapq.heapify(A)
heapq.heapify(B)
#最も安い組み合わせ
cheap=heapq.heappop(A)+heapq.heappop(B)
print(min(cheap,min(values)))
if __name__=="__main__":
main() |
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = []
Y = []
C = []
for _ in range(M):
x,y,c = map(int,input().split())
X.append(x)
Y.append(y)
C.append(c)
ans = min(a) + min(b)
for i in range(M):
ans = min(ans,a[X[i]-1] + b[Y[i] - 1] - C[i])
print(ans)
| 1 | 53,795,090,251,648 | null | 200 | 200 |
A, B, C = map(int, input().split())
K = int(input())
while A >= B and K > 0:
B *= 2
K -= 1
while B >= C and K > 0:
C *= 2
K -= 1
# print(A, B, C, K)
if A < B and B < C:
print("Yes")
else:
print("No")
| A, B, C = map(int, input().split())
K = int(input())
yes = False
for i in range(0, 8):
for j in range(0, 8):
for k in range(0, 8):
if i + j + k == K:
new_A = A * (2 ** i)
new_B = B * (2 ** j)
new_C = C * (2 ** k)
if new_C > new_B and new_B > new_A:
yes = True
break
if yes:
break
if yes:
break
if yes:
print("Yes")
else:
print("No") | 1 | 6,923,805,740,070 | null | 101 | 101 |
def main():
L, R, d = map(int,input().split())
if L%d==0 and R%d==0:
print(int((R-L)/d) + 1)
return
else:
l = L - L % d
r = R - R % d
print(int((r - l)/d))
return
if __name__=='__main__':
main()
| input = input()
L, R, d = [int(n) for n in input.split()]
count = 0
for n in range(L, R+1):
if n % d == 0:
count += 1
print(count) | 1 | 7,592,145,239,812 | null | 104 | 104 |
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
n = int(input())
r = []
while n > 0:
n -= 1
t1 = n % 26
r.append(chr(t1+97))
n = n // 26
r2 = "".join(r[::-1])
print(r2)
if __name__ == '__main__':
main() | chars = [chr(i) for i in range(ord('a'), ord('z') + 1)]
arr = []
x = int(input())
def get_len(n):
length = 1
t = 26
while True:
if n <= t:
return length
t += 26 ** (length + 1)
length += 1
if length > 1000000000000001:
raise
def get_ord(n):
st = 1
end = 26
ind = 1
while True:
if st <= n <= end:
return x - st
st = end + 1
end += 26 ** (ind + 1)
ind += 1
length = get_len(x)
order = get_ord(x)
# print(length)
for i in range(length):
s = order % 26
order = order // 26
arr.append(s)
# print(arr)
ans = ""
for ai in arr[::-1]:
ans += chars[ai]
print(ans) | 1 | 11,958,076,099,200 | null | 121 | 121 |
n,k = map(int,input().split())
MOD = 10**9+7
FAC = [1]
INV = [1]
for i in range(1,2*n+1):
FAC.append((FAC[i-1]*i) % MOD)
INV.append(pow(FAC[-1],MOD-2,MOD))
def nCr(n,r):
return FAC[n]*INV[n-r]*INV[r]
ans = 0
for i in range(min(n-1,k)+1):
ans += nCr(n,i)*nCr(n-1,n-i-1)
ans %= MOD
print(ans)
| M=10**9+7;n,k=map(int,input().split());a=c=1
for i in range(1,min(n,k+1)):m=n-i;c=c*-~m*m*pow(i,M-2,M)**2%M;a+=c
print(a%M) | 1 | 67,302,833,431,460 | null | 215 | 215 |
N, R = map(int, input().split())
if N >= 10: print(R)
else: print(R + 100*(10-N)) | n = int(input())
if "7" in str(n):
print("Yes")
else:
print("No") | 0 | null | 48,843,794,539,914 | 211 | 172 |
def solve():
n, m = map(int, input().split())
s = list(map(int, input().split()))
if sum(s) >= n:
print("Yes")
else:
print("No")
solve() | import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue
# import numpy as np
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353
ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
# ===CODE===
def main():
n = ni()
s = list(input())
q = ni()
alphabet_idx = {}
for i in range(26):
alphabet_idx[i] = []
for i, si in enumerate(s):
alphabet_idx[ord(si) - ord("a")].append(i)
for _ in range(q):
qi, a, b = input().split()
qi, a = int(qi), int(a)
if qi == 1:
a -= 1
if s[a] == b:
continue
del_char = ord(s[a]) - ord("a")
del_idx = bisect.bisect_left(alphabet_idx[del_char], a)
del alphabet_idx[del_char][del_idx]
insert_char = ord(b) - ord("a")
insert_idx = bisect.bisect_left(alphabet_idx[insert_char], a)
alphabet_idx[insert_char].insert(insert_idx, a)
s[a] = b
if qi == 2:
b = int(b)
a -= 1
b -= 1
ans = 0
for i in range(26):
a_idx = bisect.bisect_left(alphabet_idx[i], a)
if a_idx < len(alphabet_idx[i]):
if alphabet_idx[i][a_idx] <= b:
ans += 1
print(ans)
if __name__ == '__main__':
main()
| 0 | null | 70,364,553,975,100 | 226 | 210 |
def main():
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
import itertools
sum_a = list(itertools.accumulate(a))
sum_b = list(itertools.accumulate(b))
if sum_a[-1] + sum_b[-1] <= k:
print(n+m)
return
if a[0] > k and b[0] > k:
print(0)
return
for i in range(n):
if sum_a[i] > k:
break
s_a = i - 1
if sum_a[-1] <= k:
s_a = n-1
now_sum = 0
if s_a >= 0:
now_sum = sum_a[s_a]
for i in range(m):
if now_sum + sum_b[i] > k:
break
s_b = i - 1
ans = s_a + 1 + s_b + 1
now_sum = 0
for a_i in range(s_a-1, -2, -1):
for b_i in range(s_b+1,m):
if a_i < 0:
now_sumtime = sum_b[b_i]
else:
now_sumtime = sum_a[a_i] + sum_b[b_i]
if b_i == m-1 and now_sumtime <= k:
now_sum = a_i + m + 1
break
if now_sumtime > k:
now_sum = a_i + b_i + 1
break
s_b = b_i-1
ans = max(ans, now_sum)
print(ans)
if __name__=='__main__':
main()
| (n, k), p, c = [[*map(int, i.split())] for i in open(0)]
def solve(x, t):
visit = [0] * n
visit[x] = 1
loop = [0] * n
count = 0
ans = c[p[x] - 1]
l = True
sub = 0
while True:
x = p[x] - 1
if l:
if visit[x]:
if loop[x]:
ln = sum(loop)
if t > ln:
sub += (t//ln -1)*count*(count>0)
t %= ln
t += ln
l = False
count += c[x]
loop[x] = 1
visit[x] = 1
sub += c[x]
t -= 1
ans = max(sub, ans)
if t < 1:
return ans
print(max(solve(i, k) for i in range(n))) | 0 | null | 7,989,533,081,128 | 117 | 93 |
def check(T, K, A, F):
# check whether all members finish by the time T
counts = [max(0, (a * f - T + f - 1) // f) for a, f in zip(A, F)] # math.ceil((a * f - T) / f)
return sum(counts) <= K
def main():
N, K = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
A.sort()
F = list(map(int, input().split(' ')))
F.sort(reverse=True)
ok = 10 ** 12
ng = - 1
while ok - ng > 1:
mid = (ok + ng) // 2
if check(mid, K, A, F):
ok = mid
else:
ng = mid
print(ok)
if __name__ == '__main__':
main()
| n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()
l=-1;r=max(a)*max(f)+1
sum=sum(a)
while abs(l-r)>1:
x=(l+r)//2
ct=0
for i in range(n):
ct+=max(a[i]-(x//f[i]),0)
if ct<=k:
r=x
else:
l=x
print(r) | 1 | 164,415,982,860,850 | null | 290 | 290 |
N = int(input())
A = [int(x) for x in input().split()]
L = dict(); R = dict()
for i in range(N):
l = i + A[i]
if l in L:
L[l] += 1
else:
L[l] = 1
r = i - A[i]
if r in R:
R[r] += 1
else:
R[r] = 1
ans = 0
for x in R:
if x in L:
ans += L[x] * R[x]
print(ans) | total, max, time=map(int, input().split())
print (time*int(total/max) if total%max==0 else time*(int(total/max)+1))
| 0 | null | 15,124,546,489,920 | 157 | 86 |
S,T=map(str,input().split())
a,b=map(int,input().split())
U=input()
if U == S:
a +=-1
elif U == T:
b += -1
print(a,b) | S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()
if U == S:
A -= 1
A = str(A)
B = str(B)
print(A+' '+B)
else :
B -= 1
A = str(A)
B = str(B)
print(A+' '+B) | 1 | 71,975,771,590,310 | null | 220 | 220 |
from math import gcd
n=int(input())
a=list(map(int,input().split()))
x=[-1]*(10**6+5)
x[0]=0
x[1]=1
i=2
while i<=10**6+1:
j=2*i
if x[i]==-1:
x[i]=i
while j<=10**6+1:
x[j]=i
j+=i
i+=1
z=[0]*(10**6+5)
g=gcd(a[0],a[0])
for i in range(n):
g=gcd(g,a[i])
if g!=1:
print("not coprime")
else:
f=0
for i in range(n):
p=1
while a[i]>=2:
if p==x[a[i]]:
a[i]=a[i]//p
continue
else:
p=x[a[i]]
z[p]+=1
a[i]=a[i]//p
for i in range(10**6+1):
if z[i]>=2:
f=1
print("pairwise coprime" if f==0 else "setwise coprime")
| import math
import collections
import copy
import sys
n = int(input())
a = list(map(int,input().split()))
limit = 10 ** 6
sCheck = math.gcd(a[0],a[1])
if n == 2:
if sCheck == 1:
print("pairwise coprime")
else:
print("not coprime")
sys.exit()
else:
for i in range(2,n):
sCheck = math.gcd(sCheck,a[i])
beforeQ = collections.deque([int(i) for i in range(3,(limit + 1))])
D = dict()
p = 2
D[2] = 2
D[1] = 1
while p < math.sqrt(limit):
afterQ = collections.deque()
while len(beforeQ) > 0:
k = beforeQ.popleft()
if k % p != 0:
afterQ.append(k)
else:
D[k] = p
beforeQ = copy.copy(afterQ)
p = beforeQ.popleft()
D[p] = p
while len(beforeQ) > 0:
k = beforeQ.popleft()
D[k] = k
ansSet = set()
count = 0
for i in a:
k = i
kSet = set()
while k != 1:
if D[k] in ansSet:
if not(D[k] in kSet):
count = 1
break
else:
ansSet.add(D[k])
kSet.add(D[k])
k = int(k // D[k])
if count == 1:
break
if count == 0:
print("pairwise coprime")
elif sCheck == 1:
print("setwise coprime")
else:
print("not coprime") | 1 | 4,110,860,073,848 | null | 85 | 85 |
moji = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
memo = {}
for i in range(len(moji)):
memo.setdefault(moji[i],i)
#print(memo)
n = int(input())
s = str(input())
ans = ''
for i in range(len(s)):
ans += moji[(memo[s[i]]+n)%26]
print(ans) | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
uf = UnionFind(N)
ans = -10**9
for i in range(N):
uf.union(i,P[i]-1)
for group in uf.all_group_members().values():
size = len(group)
SUM = 0
for i in group:
SUM += C[i]
if SUM < 0:
SUM = 0
for i in group:
cur = i
current_sum = 0
remain = K
for _ in range(size):
cur = P[cur]-1
current_sum += C[cur]
remain -= 1
if remain < 0:
break
ans = max(ans,current_sum+SUM*(remain//size))
print(ans) | 0 | null | 69,959,219,826,588 | 271 | 93 |
from math import pi
r = float(raw_input())
print '%f %f' % (pi * r ** 2, 2 * pi * r) | def calc_circle(r):
pi = 3.14159265359
area = round(r*r*pi, 6)
circ = round(2*r*pi, 6)
return (area, circ)
if __name__ == "__main__":
r = float(input())
area, circ = calc_circle(r)
print(f"{area:.6f} {circ:.6f}")
| 1 | 638,777,201,580 | null | 46 | 46 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# def
def int_mtx(N):
x = []
for _ in range(N):
x.append(list(map(int,input().split())))
return np.array(x)
def str_mtx(N):
x = []
for _ in range(N):
x.append(list(input()))
return np.array(x)
def int_map():
return map(int,input().split())
def int_list():
return list(map(int,input().split()))
def print_space(l):
return print(" ".join([str(x) for x in l]))
# import
import numpy as np
import collections as col
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
# main
N,M =int_map()
AB = int_mtx(M)
n, _ = connected_components(csr_matrix(([1]*M, (AB[:,0]-1, AB[:,1]-1)),(N,N)))
print(n-1) | class UnionFind():
def __init__(self,size):
self.table = [-1 for _ in range(size)]
self.member_num = [1 for _ in range(size)]
#representative
def find(self,x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self,x,y):
s1 = self.find(x)
s2 = self.find(y)
m1=self.member_num[s1]
m2=self.member_num[s2]
if s1 != s2:
if m1 != m2:
if m1 < m2:
self.table[s1] = s2
self.member_num[s2]=m1+m2
return [m1,m2]
else:
self.table[s2] = s1
self.member_num[s1]=m1+m2
return [m1,m2]
else:
self.table[s1] = -1
self.table[s2] = s1
self.member_num[s1] = m1+m2
return [m1,m2]
return [0,0]
N,M = list(map(int,input().split()))
uf = UnionFind(N)
count = 0
for i in range(M):
A,B = list(map(int,input().split()))
A,B = A-1,B-1
if uf.find(A)!=uf.find(B):
uf.union(A,B)
count+=1
B = set()
for i in range(N):
B.add(uf.find(i))
print(len(B)-1) | 1 | 2,277,607,785,430 | null | 70 | 70 |
import sys
n = int(input())
dic = {}
input_ = [x.split() for x in sys.stdin.readlines()]
for c, s in input_:
if c == 'insert':
dic[s] = 0
else:
if s in dic:
print('yes')
else:
print('no') | # coding: utf-8
# Here your code !
N=int(input())
dict={}
for i in range(N):
a,b=input().split()
if a=="insert":
dict[b]=i
else:
if b in dict:
print("yes")
else:
print("no") | 1 | 80,858,448,528 | null | 23 | 23 |
def readinput():
n=int(input())
sList=[]
for _ in range(n):
sList.append(input())
return n,sList
def main(n,sList):
hist={}
for s in sList:
if s in hist.keys():
hist[s]+=1
else:
hist[s]=1
hList=sorted(list(hist.items()), key=lambda x:x[1], reverse=True)
#print(hList)
hvalue=hList[0][1]
ss=[]
i=0
while(i<len(hList) and hList[i][1]==hvalue):
ss.append(hList[i][0])
i+=1
ss.sort()
for s in ss:
print(s)
if __name__=='__main__':
n,sList=readinput()
main(n,sList)
| from collections import Counter
def solve():
N = int(input())
c = Counter([input() for _ in range(N)])
cnt = -1
ans = []
for i in c.most_common():
if cnt == -1:
cnt = i[1]
ans.append(i[0])
elif cnt == i[1]:
ans.append(i[0])
else:
break
for a in sorted(ans):
print(a)
if __name__ == "__main__":
solve() | 1 | 70,063,330,669,078 | null | 218 | 218 |
word = input()
if word[-1] == 's':
word += 'es'
else:
word += 's'
print(word) | s = input()
suffix = ''
if s.endswith('s'):
suffix = 'es'
else:
suffix = 's'
print(s + suffix) | 1 | 2,403,698,465,472 | null | 71 | 71 |
n = int(input())
taro = 0
hana = 0
for c in range(0,n):
word = input().split(' ')
taro_w, hana_w = word[0], word[1]
word.sort()
if word[0] == word[1]:
taro += 1
hana += 1
elif taro_w == word[0]:
hana += 3
else:
taro += 3
print("%d %d" % (taro, hana)) |
class Card:
def __init__(self, data, i):
self.suit = data[0]
self.value = data[1]
self.initord = i
def BubbleSort(cards, N):
for i in range(N):
for j in range(N - 1, i, -1):
if cards[j].value < cards[j - 1].value:
cards[j], cards[j - 1] = cards[j - 1], cards[j]
def SelectionSort(cards, N):
for i in range(N):
min_j = i
for j in range(i + 1, N):
if cards[j].value < cards[min_j].value:
min_j = j
cards[i], cards[min_j] = cards[min_j], cards[i]
N = int(input())
cards = [Card(data, i) for i, data in enumerate(input().split())]
cards1 = cards.copy()
cards2 = cards.copy()
BubbleSort(cards1, N)
SelectionSort(cards2, N)
print(*[card.suit + card.value for card in cards1])
for i in range(N - 1):
if cards1[i].value == cards1[i + 1].value:
if cards1[i].initord > cards1[i + 1].initord:
print("Not stable")
break
else:
print("Stable")
print(*[card.suit + card.value for card in cards2])
for i in range(N - 1):
if cards2[i].value == cards2[i + 1].value:
if cards2[i].initord > cards2[i + 1].initord:
print("Not stable")
break
else:
print("Stable") | 0 | null | 1,003,193,535,260 | 67 | 16 |
A, B, C, D = map(int, input().split())
is_turn_of_takahashi = True
while A > 0 and C > 0:
if is_turn_of_takahashi:
C -= B
else:
A -= D
is_turn_of_takahashi = not is_turn_of_takahashi
print("Yes" if A > 0 else "No")
| lists = []
for i in range(10):
a = int(input())
lists.append(a)
f = sorted(lists, reverse = True)
for i in range(3):
print(f[i]) | 0 | null | 14,892,395,941,968 | 164 | 2 |
import sys
input = sys.stdin.readline
#道がない場合、infで初期化したい
inf = 10 ** 13 + 1
#input
n, m, l = list(map(int, input().split()))
way = [[inf for i in range(n)] for j in range(n)]
oil = [[400 for i in range(n)] for j in range(n)]
for i in range(m):
a, b, c, = list(map(int, input().split()))
way[a - 1][b - 1] = c
way[b - 1][a - 1] = c
q = int(input())
query = []
for i in range(q):
query.append(list(map(int, input().split())))
#ワーシャルフロイド法を使い、各道への最短経路を調べる。計算量はO(N**3)
for k in range(n):
for i in range(n):
for j in range(n):
if i == j:
way[i][j] = 0
continue
way[i][j] = min(way[i][j],way[i][k] + way[k][j])
#oilの補給できる回数もワーシャルフロイドで求める。まず、一補給でいけるところに辺を張る
for i in range(n):
for j in range(n):
if i == j:
oil[i][j] = 0
if way[i][j] <= l:
oil[i][j] = oil[j][i] = 1
#の後でワーシャルフロイド
for k in range(n):
for i in range(n):
for j in range(n):
if i == j:
oil[i][j] = 0
continue
oil[i][j] = min(oil[i][j],oil[i][k] + oil[k][j])
for i in range(q):
ans = oil[query[i][0] - 1][query[i][1] - 1] - 1
if way[query[i][0] - 1][query[i][1] - 1] == inf or oil[query[i][0] - 1][query[i][1] - 1] == 400:
ans = -1
print(ans)
| import sys
input = sys.stdin.buffer.readline
n, m, limit = map(int, input().split())
infi = 10 ** 15
graph = [[infi] * (n + 1) for _ in range(n + 1)]
step = [[infi] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
a, b, c = map(int, input().split())
graph[a][b] = c
graph[b][a] = c
for k in range(1, n + 1):
for i in range(1, n + 1):
for j in range(1, n + 1):
graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j])
for i in range(1, n + 1):
for j in range(1, n + 1):
if graph[i][j] <= limit:
graph[i][j] = 1
elif graph[i][j] == 0:
graph[i][j] = 0
else:
graph[i][j] = infi
for k in range(1, n + 1):
for i in range(1, n + 1):
for j in range(1, n + 1):
graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j])
q = int(input())
for _ in range(q):
a, b = map(int, input().split())
if graph[a][b] == infi:
graph[a][b] = 0
print(graph[a][b] - 1 if graph[a][b] != infi else -1) | 1 | 173,806,612,116,320 | null | 295 | 295 |
a = [x + 1 for x in range(9)]
for i in a:
for j in a:
print('{}x{}={}'.format(i, j, i * j)) | n = int(input())
ans = 0
if n >= 2 and n % 2 == 0:
j = 10
while n >= j:
ans += (n // j)
j *= 5
print(ans) | 0 | null | 58,140,511,698,710 | 1 | 258 |
N = int(input())
A = list(map(int,input().split()))
A.sort()
if N==2:
print(max(A))
exit()
ans = A.pop()
n = N-2
while A:
a = A.pop()
for _ in range(2):
n -= 1
ans += a
if n==0:
print(ans)
exit() | import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
while y: x,y = y,x%y
return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
"""Return a tuple list of divisor of n"""
return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
"""Return a list of prime numbers n or less"""
is_prime = [True]*(MAX_NUM+1)
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX_NUM**0.5)+1):
if not is_prime[i]: continue
for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
"""Return a list of prime factorization numbers of n"""
res = []
for i in range(2,int(n**0.5)+1):
while n%i==0: res.append(i); n //= i
if n != 1: res.append(n)
return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
n = II()
xl = [MII() for _ in range(n)]
lr_x = [[x-l, x+l] for x, l in xl]
lr_x.sort(key=lambda x: x[1])
now = -(10**9)
cnt = 0
for l, r in lr_x:
if now <= l:
cnt += 1
now = r
print(cnt)
if __name__ == '__main__':
main() | 0 | null | 49,315,069,393,482 | 111 | 237 |
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
n=int(input())
def divisore(n):
divisors=[]
for i in range(1,int(n**0.5)+1):
if n%i==0:
divisors.append(i)
if i!=n//i:
divisors.append(n//i)
divisors.sort()
return divisors
ans_l=divisore(n-1)[1:]
d=divisore(n)
for i in d[1:]:
nn=n
while nn%i==0:
nn//=i
if nn%i==1:
ans_l.append(i)
print(len(ans_l)) | # -*- coding: utf-8 -*-
class dice_class:
def __init__(self, list):
self.num = list
def sut(self, top): #set_up_top
while True:
if self.num[0] == top:
break
else:
self.roll('E')
if self.num[0] == top:
break
else:
self.roll('N')
def suf(self, front): #set_up_front
while True:
if self.num[1] == front:
break
else:
self.roll('SEN')
def roll(self, s):
for i in s:
if i == 'E':
self.rollE()
elif i == 'N':
self.rollN()
elif i == 'S':
self.rollS()
elif i == 'W':
self.rollW()
def rollE(self):
self.num = [self.num[3], self.num[1], self.num[0], self.num[5], self.num[4], self.num[2]]
def rollN(self):
self.num = [self.num[1], self.num[5], self.num[2], self.num[3], self.num[0], self.num[4]]
def rollS(self):
self.num = [self.num[4], self.num[0], self.num[2], self.num[3], self.num[5], self.num[1]]
def rollW(self):
self.num = [self.num[2], self.num[1], self.num[5], self.num[0], self.num[4], self.num[3]]
if __name__ == "__main__":
dice = dice_class(map(int, raw_input().split()))
n = int(raw_input())
for i in range(n):
top, front = map(int, raw_input().split())
dice.sut(top)
dice.suf(front)
print dice.num[2] | 0 | null | 20,763,928,793,710 | 183 | 34 |
text = input()
newText = ""
for x in text:
if x.isupper():
newText = newText + x.lower()
elif x.islower():
newText = newText + x.upper()
else:
newText = newText + x
print(newText) | n = int(input())
mod = 1000000007
if n < 2:
print(0)
else:
print((pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)) % mod) | 0 | null | 2,298,825,624,498 | 61 | 78 |
N, K = map(int, input().split())
ans = 0
lis = [0]*K
mod = 10**9 + 7
def modpow(a, n, mod):
ans = 1
while n > 0:
if n&1:
ans = ans * a % mod
a = a * a % mod
n = n >> 1
return ans
for x in range(K,0, -1):
a = int((K // x) % mod)
b = modpow(a, N, mod)
for i in range(2, K//x +1):
b = (b - lis[x*i-1]) %mod
if b < 0:
b += mod
lis[x-1] = b
ans = (ans + b*x%mod) % mod
print(int(ans))
| n, k = map(int, input().split())
MOD = 1000000007
ans = 0
c = {}
for i in range(k, 0, -1):
t = pow(k // i, n, MOD)
m = 2
while i * m <= k:
t -= c[i * m]
m += 1
c[i] = t % MOD
print(sum([k * v for k, v in c.items()]) % MOD)
| 1 | 36,852,142,365,950 | null | 176 | 176 |
n,k=map(int,input().split())
lr=[list(map(int,input().split())) for _ in range(k)]
mod=998244353
dp=[0]*(n+1)
csum=[0]*(n+2)
dp[0]=1
for i in range(n):
for j in range(k):
l,r=lr[j]
dp[i]+=csum[max(i+1-l,0)]-csum[max(i-r,0)]
dp[i]%=mod
csum[i+1]+=dp[i]+csum[i]
csum[i+1]%=mod
print(dp[n-1]) | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter
import sys
sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 1 << 60
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def ep(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
ep(e - s, 'sec')
return ret
return wrap
MOD = 998244353
class ModInt:
def __init__(self, x=0):
self.x = x % MOD
def __str__(self):
return str(self.x)
__repr__ = __str__
def __add__(self, other):
return (
ModInt(self.x + other.x) if isinstance(other, ModInt) else
ModInt(self.x + other)
)
def __sub__(self, other):
return (
ModInt(self.x - other.x) if isinstance(other, ModInt) else
ModInt(self.x - other)
)
def __mul__(self, other):
return (
ModInt(self.x * other.x) if isinstance(other, ModInt) else
ModInt(self.x * other)
)
def __truediv__(self, other):
return (
ModInt(self.x * pow(other.x, MOD - 2)) if isinstance(other, ModInt) else
ModInt(self.x * pow(other, MOD - 2))
)
def __pow__(self, other):
return (
ModInt(pow(self.x, other.x)) if isinstance(other, ModInt) else
ModInt(pow(self.x, other))
)
__radd__ = __add__
def __rsub__(self, other):
return (
ModInt(other.x - self.x) if isinstance(other, ModInt) else
ModInt(other - self.x)
)
__rmul__ = __mul__
def __rtruediv__(self, other):
return (
ModInt(other.x * pow(self.x, MOD - 2)) if isinstance(other, ModInt) else
ModInt(other * pow(self.x, MOD - 2))
)
def __rpow__(self, other):
return (
ModInt(pow(other.x, self.x)) if isinstance(other, ModInt) else
ModInt(pow(other, self.x))
)
@mt
def slv(N, K, LR):
memo = [ModInt(0)] * (N+2)
memo[1] = 1
memo[1+1] = -1
for i in range(1, N+1):
memo[i] += memo[i-1]
for l, r in LR:
ll = min(N+1, i+l)
rr = min(N+1, i+r+1)
memo[ll] += memo[i]
memo[rr] -= memo[i]
return memo[N]
def main():
N, K = read_int_n()
LR = [read_int_n() for _ in range(K)]
print(slv(N, K, LR))
if __name__ == '__main__':
main()
| 1 | 2,720,141,163,128 | null | 74 | 74 |
H, W, M = map(int, input().split())
hw = []
sh = [0] * H
sw = [0] * W
for i in range(M):
h, w = map(int, input().split())
hw.append((h - 1, w - 1))
sh[h - 1] += 1
sw[w - 1] += 1
mh = max(sh)
mw = max(sw)
count = 0
for i in range(M):
if sh[hw[i][0]] == mh and sw[hw[i][1]] == mw:
count += 1
if sh.count(mh) * sw.count(mw) > count:
print(mh + mw)
else:
print(mh + mw - 1) | a=int(input())
if 400<=a and a<=599:
print(8)
if 600<=a and a<=799:
print(7)
if 800<=a and a<=999:
print(6)
if 1000<=a and a<=1199:
print(5)
if 1200<=a and a<=1399:
print(4)
if 1400<=a and a<=1599:
print(3)
if 1600<=a and a<=1799:
print(2)
if 1800<=a and a<=1999:
print(1) | 0 | null | 5,706,368,299,580 | 89 | 100 |
from collections import deque
n, q = map(int, input().split())
dq = deque()
for _ in range(n):
name, time = input().split()
dq.append([name, int(time)])
cnt = 0
while dq:
qt = dq.popleft()
if qt[1] <= q:
cnt += qt[1]
print(qt[0], cnt)
else:
cnt += q
qt[1] -= q
dq.append(qt) | N, K = map(int, input().split())
sunukes = [0 for k in range(N)]
for k in range(K):
d = int(input())
A = list(map(int, input().split()))
for a in A:
sunukes[a-1] += 1
assert len(A) == d
print(len([k for k in sunukes if k == 0])) | 0 | null | 12,312,757,708,460 | 19 | 154 |
import math
R = int(input())
circum = R * 2 * math.pi
print(circum) | [N,K,S] = list(map(int,input().split()))
cnt = 0
output = []
if S != 10**9:
for i in range(K):
output.append(S)
for i in range(N-K):
output.append(S+1)
else:
for i in range(K):
output.append(S)
for i in range(N-K):
output.append(1)
print(*output) | 0 | null | 61,542,751,959,572 | 167 | 238 |
s=input()
n=len(s)//2
s1=s[:n]
s2=s[-n:]
s2=s2[::-1]
cnt=0
for i in range(len(s1)):
if s1[i]!=s2[i]:
cnt+=1
print(cnt)
| s=list(input())
ans=0
for i in range(len(s)//2):
if s[i]==s[len(s)-1-i]:
continue
ans+=1
print(ans) | 1 | 119,998,486,432,680 | null | 261 | 261 |
ans = []
def paint(h, w):
ans.append("\n".join(["#" * w] * h))
while True:
H, W = map(int, input().split())
if H == W == 0: break
paint(H, W)
print(("\n" * 2).join(ans), "\n", sep = "")
| while True:
H,W=map(int,raw_input().split())
if H==W==0:
break
elif H!=0 or W!=0:
print (('#'*W +'\n')*H) | 1 | 774,064,316,300 | null | 49 | 49 |
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
class Score:
def __init__(self,t):
self.x=[d*[0]for _ in range(26)]
self.scor=0
self.ans=[]
for i in range(d):
v=t[i]
self.scor+=s[i][v]
for j in range(26):
if j!=v:
self.x[j][i]+=1
if i!=0:self.x[j][i]+=self.x[j][i-1]
self.scor-=c[j]*self.x[j][i]
self.ans.append(self.scor)
def solve(self):
return [self.scor,self.ans]
t=[int(input())-1 for _ in range(d)]
x=Score(t)
_,ans=x.solve()
for i in ans:print(i) | D = int(input())
C = [int(T) for T in input().split()]
S = [[] for TD in range(0,D)]
for TD in range(0,D):
S[TD] = [int(T) for T in input().split()]
Type = 26
Last = [0]*Type
SatD = [0]*D
SatA = [0]*(D+1)
for TD in range(0,D):
Test = int(input())-1
Last[Test] = TD+1
SatD[TD] = S[TD][Test]
for TC in range(0,Type):
SatD[TD] -= C[TC]*(TD+1-Last[TC])
SatA[TD+1] = SatA[TD]+SatD[TD]
print('\n'.join(str(T) for T in SatA[1:])) | 1 | 9,903,369,516,612 | null | 114 | 114 |
def main():
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
Q=int(input())
d=[0]*(10**5 +1)#各数字の個数
ans=[]
for i in A:
d[i]+=1
for i in range(Q):
B,C=map(int,input().split())
s += (C-B)*d[B]
ans.append(s)
d[C]+=d[B]
d[B]=0
print("\n".join(map(str, ans)))
#BC入力ごとに出力するよりまとめて出力した方が倍くらい早い
if __name__ == "__main__":
main() | from collections import defaultdict
N=int(input())
count=defaultdict(int)
*A,=map(int,input().split())
for i in range(N):
count[A[i]] += 1
ans = 0
for k in count.keys():
ans += count[k]*k
Q=int(input())
for q in range(Q):
b,c = map(int,input().split())
ans += c*count[b] - b*count[b]
count[c] += count[b]
count[b] = 0
print(ans) | 1 | 12,268,074,885,712 | null | 122 | 122 |
import math
h,w = map(int,input().split())
if h == 1 or w == 1:
print(1)
else:
print(math.ceil(h/2*w))
| import math
a,b = map(int,input().split())
if a == 1 or b == 1:
print(1)
else:
print(math.ceil(a*b/2)) | 1 | 50,847,719,275,110 | null | 196 | 196 |
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)
R, C, K = rl()
I = [[0]*(C+2) for _ in range(R+2)]
for i in range(K):
r, c, v = rl()
I[r][c] = v
dp = [[0]*4 for _ in range(C+2)]
dp2 = [[0]*4 for _ in range(C+2)]
for i in range(R+1):
for j in range(C+1):
for m in range(4):
ni, nj = i, j+1
dp[nj][m] = max(dp[nj][m], dp[j][m])
if m < 3:
dp[nj][m+1] = max(dp[nj][m+1], dp[j][m]+I[ni][nj])
ni, nj = i+1, j
dp2[nj][0] = max(dp2[nj][0], dp[j][m])
dp2[nj][1] = max(dp2[nj][1], dp[j][m]+I[ni][nj])
dp = dp2
dp2 = [[0]*4 for _ in range(C+2)]
ans = 0
for m in range(4):
ans = max(ans, dp[C][m])
print(ans)
| R, C, K = map(int, input().split())
goods = [[0] * C for _ in range(R)]
for _ in range(K):
r, c, v = map(int, input().split())
goods[r-1][c-1] = v
dp = [[[0] * C for _ in range(4)] for _ in range(R)]
dp[0][1][0] = goods[0][0]
for i in range(R):
for j in range(4):
for k in range(C):
if i < R - 1:
dp[i+1][0][k] = max(dp[i+1][0][k], dp[i][j][k])
dp[i+1][1][k] = max(dp[i+1][1][k], dp[i][j][k] + goods[i+1][k])
if k < C - 1:
dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k])
if j < 3:
dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + goods[i][k+1])
res = 0
for i in range(4):
res = max(res, dp[R-1][i][C-1])
print(res) | 1 | 5,571,326,419,898 | null | 94 | 94 |
n = input()
if '7' in n :
print('Yes')
else :
print('No') | a,b = input().split()
c = [a*int(b), b*int(a)]
print(sorted(c)[0]) | 0 | null | 59,192,114,680,322 | 172 | 232 |
n,m = map(int, input().split())
pena=[0]*(n+1)
seitou=[0]*(n+1)
for i in range(m):
p,s = map(str,input().split())
p=int(p)
if s=="WA" and seitou[p]==0:
pena[p]+=1
if s=="AC":
seitou[p]=1
pena_kazu=0
for i in range(1,n+1):
if seitou[i]==1:
pena_kazu+=pena[i]
seitou_kazu=sum(seitou)
print(str(seitou_kazu)+" "+str(pena_kazu)) | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
class SWAG(object):
def __init__(self,dot):
self.__front=[]; self.__back=[]; self.__dot=dot
def __bool__(self):
return bool(self.__front or self.__back)
def __len__(self):
return len(self.__front)+len(self.__back)
def append(self,x):
back=self.__back
if(not back): back.append((x,x))
else: back.append((x,self.__dot(back[-1][1],x)))
def popleft(self):
assert(self)
front=self.__front; back=self.__back
if(not front):
front.append((back[-1][0],back[-1][0]))
back.pop()
while(back):
front.append((back[-1][0],self.__dot(back[-1][0],front[-1][1])))
back.pop()
return front.pop()[0]
def sum(self):
assert(self)
front=self.__front; back=self.__back
if(not front): return back[-1][1]
elif(not back): return front[-1][1]
else: return self.__dot(front[-1][1],back[-1][1])
def resolve():
n,m=map(int,input().split())
S=list(map(int,input()))
dp=[INF]*(n+1) # dp[i] : i から何手でゴールできるか
dp[-1]=0
swag=SWAG(min)
for i in range(n-1,-1,-1):
swag.append(dp[i+1])
if(len(swag)>m): swag.popleft()
if(S[i]==1): continue
dp[i]=swag.sum()+1
if(dp[0]==INF):
print(-1)
return
ans=[]
now=0
turn=dp[0]
for i in range(1,n+1):
if(dp[i]==INF): continue
if(turn>dp[i]):
ans.append(i-now)
now=i
turn=dp[i]
print(*ans)
resolve() | 0 | null | 116,240,920,850,560 | 240 | 274 |
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
print(max(a-b-b,0)) | s = list(input())
t = list(input())
lt = len(t)
ans = lt
for i in range(len(s) - lt + 1):
s_ = s[i: i + lt]
diff = 0
for x, y in zip(s_, t):
if x != y:
diff += 1
ans = min(ans, diff)
print(ans) | 0 | null | 85,123,435,862,752 | 291 | 82 |
A = int(input())
B = int(input())
ans = 6 - (A+B)
print(ans)
| from collections import deque
import math
import copy
#https://qiita.com/ophhdn/items/fb10c932d44b18d12656
def max_dist(input_maze,startx,starty,mazex,mazey):
input_maze[starty][startx]=0
que=deque([[starty,startx]])
# print(que)
while que:
# print(que,input_maze)
y,x=que.popleft()
for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
nexty,nextx=y+i,x+j
if (nexty>=0) & (nextx>=0) & (nextx<mazex) & (nexty<mazey):
dist=input_maze[nexty][nextx]
if dist!=-1:
if (dist>input_maze[y][x]+1) & (dist > 0):
input_maze[nexty][nextx]=input_maze[y][x]+1
que.append([nexty,nextx])
# print(que)
# print(max(list(map(lambda x: max(x),copy_maze))))
return max(list(map(lambda x: max(x),copy_maze)))
h,w =list(map(int,input().split()))
maze=[list(input()) for l in range(h)]
# Maze preprocess
for y in range(h):
for x in range(w):
if maze[y][x]=='.':
maze[y][x]=math.inf
elif maze[y][x] == '#':
maze[y][x]=int(-1)
results = []
for y in range(h):
for x in range(w):
if maze[y][x]==math.inf:
copy_maze = copy.deepcopy(maze)
max_dist_result = max_dist(copy_maze,x,y,w,h)
results.append(int(max_dist_result))
#print(max_dist_result)
print(max(results))
| 0 | null | 102,239,550,215,458 | 254 | 241 |
r, c = map(int, input().split())
args = []
for i in range(r):
args.append(list(map(int, input().split())))
r_sum = 0
for j in args[i]:
r_sum += j
args[i].append(r_sum)
l_row = []
for k in range(c + 1):
c_sum = 0
for l in range(r):
c_sum += args[l][k]
l_row.append(c_sum)
for m in range(r):
print(' '.join(map(str, args[m])))
print(' '.join(map(str, l_row)))
| import sys
import math
r, c = map(int, raw_input().split())
b = [0 for i in xrange(c+1)]
for i in xrange(r):
a = map(int, raw_input().split())
for j in xrange(c):
b[j] += a[j]
sys.stdout.write(str(a[j]) + " ")
print sum(a)
b[c] += sum(a)
for j in xrange(c+1):
sys.stdout.write(str(b[j]))
if j < c:
sys.stdout.write(" ")
print | 1 | 1,356,242,199,258 | null | 59 | 59 |
X=int(input())
count=8
for i in range(600,2001,200):
if X<i:
print(count)
exit()
count-=1 | a,s=0,input().lower()
while(True):
t = input().split()
if t[0] == "END_OF_TEXT":
print(a)
quit()
for i in t:
if i.lower() == s:
a += 1
| 0 | null | 4,236,486,140,370 | 100 | 65 |
from sys import stdin, stderr
from functools import lru_cache
@lru_cache(maxsize=None)
def rec(i, m):
if i == 0:
return m == 0 or A[i] == m
return rec(i - 1, m) or rec(i - 1, m - A[i])
n = int(input())
A = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
for m in M:
if rec(n - 1, m):
print('yes')
else:
print('no') | n = int(input())
A = list(map(int,input().split()))
m = int(input())
B = list(input().split())
for i in range(m):
B[i] = int(B[i])
def solve(x,y):
if x==n:
S[y] = 1
else:
solve(x+1,y)
if y+A[x] < 2001:
solve(x+1,y+A[x])
S = [0 for i in range(2001)]
solve(0,0)
for i in range(m):
if S[B[i]] == 1:
print("yes")
else:
print("no")
| 1 | 102,874,717,670 | null | 25 | 25 |
N,K=map(int,input().split())
h=list(map(int, input().split()))
A=0
for i in h:
if i>=K:
A=A+1
print(A) | n, k = map(int, input().split())
h = list(map(int, input().split()))
print(sum(hi >= k for hi in h)) | 1 | 178,671,475,407,230 | null | 298 | 298 |
class GCD:
def __init__(self, N, K, MOD):
self.N = N
self.K = K
self.MOD = MOD
self.gcd_count_list = []
self.gcd_count_list2 = [0]*self.K
for d in range(1,self.K+1):
self.gcd_count_list.append(self.gcd_count(d))
self.gcd_count2()
def gcd_count(self, d):
""" d, 2d, 3d,... の最大公約数を持つ K 以下の整数 N 個の組の数 """
return pow(self.K//d,self.N,self.MOD)
def gcd_count2(self):
""" dの最大公約数を持つ K 以下の整数 N 個の組の数 """
res = []
i = 1
while K//i > 0:
for j in range(K//(i+1)+1,K//i+1):
self.gcd_count_list2[j-1] = self.gcd_count_list[j-1] \
- sum(self.gcd_count_list2[j*k-1] for k in range(2, i+1))
i += 1
def solve(self):
return sum(d*self.gcd_count_list2[d-1] for d in range(1,K+1))%MOD
N, K = map(int, input().split())
MOD = 10**9 + 7
g = GCD(N, K, MOD)
print(g.solve()) | from collections import defaultdict
mod = 10**9 + 7
n, k = map(int, input().split())
l = defaultdict(int)
for i in reversed(range(1, k+1)):
l[i] = pow(k//i, n, mod)
a = 2
while a*i<=k:
l[i] -= l[a*i]
l[i] %= mod
a += 1
ans = 0
for j in l:
ans += j*l[j] % mod
ans %= mod
print(ans) | 1 | 36,741,037,780,084 | null | 176 | 176 |
n,r=map(int,input().split())
if n>=10:print(r)
else:print(r+100*(10-n)) | N, R = list(map(int, input().split(' ')))
i = R if N >= 10 else R+100*(10-N)
print(i) | 1 | 63,073,051,486,612 | null | 211 | 211 |
N=int(input())
import sys
l=[i.rstrip().split() for i in sys.stdin.readlines()]
l=[list(map(int,i)) for i in l]
l=[[i-j,i+j] for i,j in l]
from operator import itemgetter
l.sort(key=itemgetter(1))
ans=N
end=l[0][1]
for i in range(N-1):
if l[i+1][0] < end:
ans-=1
else:
end=l[i+1][1]
print(ans) | N, *XL = map(int, open(0).read().split())
XL = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))
curr = -float("inf")
ans = 0
for right, left in XL:
if left >= curr:
curr = right
ans += 1
print(ans)
| 1 | 89,515,570,565,340 | null | 237 | 237 |
r, c = map(int, input().split())
element = [list(map(int, input().split())) for i in range(r)]
for i in range(r):
element[i].append(sum(element[i]))
for i in range(r):
for j in range(c):
print(element[i][j],end="")
print(' ',end="")
print(element[i][c])
for i in range(c):
num = 0
for j in range(r):
num += element[j][i]
print(num, end="")
print(' ',end="")
b = 0
for i in range(r):
b += element[i][c]
print(b)
|
def main():
s = list(input())
k = int(input())
lst = []
cnt = 1
flg = 0
ans = 0
prev = s[0]
for i in range(1, len(s)):
if prev == s[i]:
cnt += 1
else:
lst.append(cnt)
cnt = 1
prev = s[i]
flg = 1
lst.append(cnt)
if len(lst) == 1:
ans = len(s) * k // 2
else:
ans += sum(map(lambda x: x // 2, lst[1:len(lst)-1])) * k
# for l in lst[1: len(lst) - 1]:
# ans += l // 2 * k
if s[-1] == s[0]:
ans += (lst[0] + lst[-1]) // 2 * (k - 1)
ans += lst[0] // 2 + lst[-1] // 2
else:
ans += (lst[0] // 2 + lst[-1] // 2) * k
print(ans)
if __name__ == "__main__":
main()
| 0 | null | 88,093,826,245,810 | 59 | 296 |
#d=日数, c=満足低下度, s=満足上昇度, t=コンテストの日程
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
t = [int(input()) for j in range(d)]
last = [0 for i in range(26)]
#print(c)
res = 0
count = 0
#while count != len(t):
for day in range(d):
res += s[day][t[day]-1]
last[t[day]-1] = day+1
#print(last)
#print(c[last[t[day]-1]])
for i in range(26):
#print(c[i] * (day + 1 - last[i]))
res -= c[i] * (day + 1 - last[i])
print(res)
| import copy
D = int(input())
c = list(map(int, input().split()))
s = []
for _ in range(D):
s.append(list(map(int, input().split())))
t = []
for _ in range(D):
t.append(int(input()))
u = [] # last(d,i)
x = [0] * 26
u.append(x)
for i in range(D):
v = copy.deepcopy(u)
y = v[-1]
y[t[i]-1] = i+1
u.append(y)
del u[0]
ans = 0
for i in range(D):
ans += s[i][t[i]-1]
for j in range(26):
ans -= c[j] * ((i+1) - u[i][j])
print(ans)
| 1 | 9,956,688,659,150 | null | 114 | 114 |
N,K=map(int,input().split())
R,S,P=map(int,input().split())
L=input()
T=[]
for i in range(N):
T.append(L[i])
for i in range(K,N):
if T[i]==T[i-K]:
T[i]="0"
p=0
for i in T:
if i=="r":
p+=P
elif i=="s":
p+=R
elif i=="p":
p+=S
print(p) | n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
cnt=0
for i in range(n-1):
for j in range(1, min(i+1, n-i)):
if (s[i] != s[i-j]) and (s[i] != s[i+j]) and (s[i-j] != s[i+j]):
cnt += 1
print(r*g*b-cnt) | 0 | null | 71,699,731,632,370 | 251 | 175 |
d = int(input())
c = list(map(int,input().split()))
s = []
for i in range(d):
si = list(map(int,input().split()))
s.append(si)
lastd = [-1 for _ in range(26)]
ans = 0
for i in range(d):
di = int(input())
lastd[di-1] = i
ans += s[i][di-1]
for j in range(26):
ans -= (i-lastd[j])*c[j]
print(ans) | import sys
import math
N = int(input())
def solve(num):
d = math.floor(num**(1/2))
for i in range(1,d+1):
if num % i == 0:
yield [i,num//i]
if N == 2:
print(1)
sys.exit()
cnt = 0
for a,b in solve(N-1):
if a == b:
cnt += 1
else:
cnt += 2
cnt -= 1
for s in solve(N):
if s[0] == s[1]:
s.pop()
for a in s:
if a == 1:
continue
tmp = N
while True:
tmp,m = divmod(tmp, a)
if m == 0:
continue
elif m == 1:
cnt += 1
break
print(cnt) | 0 | null | 25,639,952,534,434 | 114 | 183 |
N, K = map(int, input().split())
A = list(map(int, input().split()))
def is_cuttable(N):
n = 0
for a in A:
i = a // N
if a % N == 0:
i -= 1
n += int(i)
if n > K:
return False
return True
n_max = 10 ** 10
n_min = 0
while n_max - n_min > 1:
n = (n_max + n_min) // 2
if is_cuttable(n):
n_max = n
else:
n_min = n
print(n_max) | 2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
N = int(input())
testimony = [[] for _ in range(N)]
for i in range(N):
num = int(input())
for j in range(num):
person, state = map(int, input().split())
testimony[i].append([person-1, state])
honest = 0
for i in range(1, 2**N):
flag = 0
for j in range(N):
if (i>>j)&1 == 1: # j番目は正直と仮定
for x,y in testimony[j]:
if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
flag = 1
break
if flag == 0: # 矛盾がある場合はflag == 1になる
honest = max(honest, bin(i)[2:].count('1')) # 1の数をカウントし最大となるものを選択
print(honest) | 0 | null | 63,722,683,612,000 | 99 | 262 |
N = int(input())
if N%2==1:
print(0)
else:
ans = 0
judge = 10
while True:
if judge > N:
break
else:
ans += N//judge
judge *= 5
print(ans) | N = int(input())
if(N%2 != 0):
print(0)
else:
cnt = 0
n = 1
while n <= N:
n *= 5
if(n > N):
break
num = n*2
cnt += N//num
print(cnt) | 1 | 115,907,972,641,584 | null | 258 | 258 |
def main():
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if D2 == 1:
print(1)
else:
print(0)
if __name__ == "__main__":
main() | def transform(c):
if type(c) is str:
if c.isupper():
return c.lower()
else:
return c.upper()
else:
return c
print("".join(map(lambda c: transform(c), input()))) | 0 | null | 63,255,187,140,960 | 264 | 61 |
import sys
import numpy as np
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
n = Ii()
a = Li()
b = [0]*(n+1)
bm = [0]*(n+1)
b[0] = 1
if a[0] > 1:
print(-1)
exit(0)
bm[-1] = a[-1]
for i in range(1,n+1):
bm[-1-i] = bm[-i]+a[-i-1]
b[i] = (b[i-1]-a[i-1])*2
b = np.array(b)
bm = np.array(bm)
b = np.amin([[b],[bm]], axis=0)
if a[-1] != b[-1,-1]:
print(-1)
exit(0)
if np.any(b <= 0):
print(-1)
exit(0)
print(np.sum(b)) | import numpy as np
MOD = 10**9+7
N = int(input())
A = np.array(list(map(int, input().split())))
A = A % MOD
AS = []
s = 0
for a in range(len(A)):
s = (s + A[a]) % MOD
AS.append(s)
AS = np.array(AS)
s = 0
for i in range(len(A)-1):
s = (A[i] * ((AS[N-1]-AS[i])) % MOD + s) % MOD
print(s) | 0 | null | 11,378,115,722,304 | 141 | 83 |
from itertools import product
n = int(input())
test = []
for i in range(n):
a = int(input())
test.append([list(map(int, input().split())) for i in range(a)])
ans = 0
for i in product(range(2), repeat=n):
flag = True
for j in range(n):
if i[j] == 1:
for s in test[j]:
if i[s[0]-1] != s[1]:
flag = False
break
if flag == True:
cnt = i.count(1)
if cnt > ans:
ans = cnt
print(ans) | import copy
N = int(input())
testimony = []
for n in range(N):
A = int(input())
testimony.append({})
for a in range(A):
x, y = map(int, input().split())
testimony[n][x - 1] = y
def judge(truthy):
answer = True
for i in range(len(truthy)):
if truthy[i] == 1:
for t in testimony[i].keys():
if truthy[t] != testimony[i][t]:
answer = False
break
if not answer:
break
# print(answer, truthy)
return 0 if not answer else truthy.count(1)
def dfs(truthy, depth):
if N == depth:
return judge(truthy)
truth = copy.copy(truthy)
truth.append(1)
t = dfs(truth, depth + 1)
false = copy.copy(truthy)
false.append(0)
f = dfs(false, depth + 1)
return max(t, f)
print(dfs([], 0)) | 1 | 121,322,808,736,888 | null | 262 | 262 |
import sys
from itertools import accumulate
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
n, k = rm()
a = [(i+1)/2 for i in rl()]
a = [0] + list(accumulate(a))
ans = 0
for i in range(n-k+1):
ans = max(ans, a[i+k] - a[i])
print(ans) | def expect(n):
return (n+1)/2
nk = input().split()
N = int(nk[0])
K = int(nk[1])
p = input().split()
tmp = 0
for i in range (K):
tmp += expect(int(p[i]))
tmpMax = tmp
for i in range(N - K):
tmp -= expect(int(p[i]))
tmp += expect(int(p[i+K]))
tmpMax = max(tmpMax, tmp)
print(tmpMax)
| 1 | 75,066,341,957,490 | null | 223 | 223 |
from sys import stdin
n = int(input())
xs = [int(input()) for _ in range(n)]
ans = 0
for x in xs:
flg = True
for y in range(2, int(x**0.5+1)):
if x % y == 0:
flg = False
break
if flg:
ans += 1
print(ans) | from collections import defaultdict
def combination(a, b):
if b > a - b:
return combination(a, a - b)
return fact[a] * ifact[b] * ifact[a-b]
MOD = 10**9+7
n, k = map(int, input().split())
k = min(k, n-1)
# 階乗を前処理
fact = defaultdict(int)
fact[0] = 1
for i in range(1, n+1):
fact[i] = fact[i-1] * i
fact[i] %= MOD
# 階乗の逆元を前処理
ifact = defaultdict(int)
ifact[n] = pow(fact[n], MOD-2, MOD)
for i in reversed(range(1, n + 1)):
ifact[i-1] = ifact[i] * i
ifact[i-1] %= MOD
ans = 0
for i in range(k+1):
ans += combination(n, i) * combination((n-i-1)+i, i)
ans %= MOD
print(ans % MOD)
| 0 | null | 33,463,246,551,420 | 12 | 215 |
N, M = map(int, input().split())
if N == 1:
min_range = 0
max_range = 10
else:
min_range = 10 ** (N-1)
max_range = 10 ** N
digits_lis = ['not defined' for _ in range(N+1)]
for _ in range(M):
s, c = map(int, input().split())
if digits_lis[s] == 'not defined':
digits_lis[s] = c
else:
if digits_lis[s] != c:
print('-1')
break
if digits_lis[1] == 0 and N != 1:
print('-1')
break
else:
for i in range(min_range, max_range):
for idx, check in enumerate(digits_lis):
if check == 'not defined':
continue
if (i // 10 ** (N - idx)) % 10 != check:
break
else:
print(i)
break
| n, m = map(int, input().split())
ans = [0]*(n)
for i in range(m):
a = list(map(int, input().split()))
if n>=2:
if a[0] == 1:
if a[1] == 0:
print("-1")
exit()
a[0] -= 1
if ans[a[0]] == 0 or ans[a[0]] == a[1]:
ans[a[0]] = a[1]
else:
print("-1")
exit()
if n>=2:
for i in range(n):
if ans[0] == 0:
ans[0] = 1
print(ans[i],end="")
else:
print(ans[i],end="")
else:
print(ans[0])
| 1 | 60,745,728,484,838 | null | 208 | 208 |
#! /usr/bin/python3
k = int(input())
print('ACL'*k)
| print(''.join(map(str, ["ACL" for _ in range(int(input()))]))) | 1 | 2,185,602,402,400 | null | 69 | 69 |
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
import numpy as np
Q = np.cumsum(P)
R = np.pad(Q,K,'constant', constant_values=0)[:N]
a = np.argmax(Q-R)
ans = 0
for i in range(K):
ans += (1.00+P[a-i])/2.00
print(ans) | def resolve():
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
total = 0
ans = 0
for i in range(N):
if i < K:
total += (P[i]+1)/2
if i == K-1:
ans = max(ans, total)
else:
total -= (P[i-K]+1)/2
total += (P[i]+1)/2
ans = max(ans, total)
print(ans)
if '__main__' == __name__:
resolve()
| 1 | 75,013,164,459,328 | null | 223 | 223 |
import re
import sys
INF=10000000000000
sys.setrecursionlimit(10**6)
def merge(A,left,mid,right):
count=0
L=A[left:mid]
R=A[mid:right]
L.append(INF)
R.append(INF)
i=0
j=0
for k in range(left,right):
if(L[i] <= R[j]):
A[k] = L[i]
i+=1
count+=1
else:
A[k] = R[j]
j+=1
count+=1
return count
def mergeSort(A,left,right):
count=0
if(left+1<right):
mid=(left+right)//2
count+=mergeSort(A, left, mid)
count+=mergeSort(A, mid, right)
count+=merge(A, left, mid, right)
return count
count=0
n=int(input())
s=list(map(int,input().split()))
count=mergeSort(s, 0, n)
print(re.sub("[\[\]\,]","",str(s)))
print(count)
| count=0
def mg(S,left,right,mid):
global count
L=[]
L=S[left:mid]
L.append(9999999999)
R=[]
R=S[mid:right]
R.append(9999999999)
r=0
l=0
for i in range(left,right):
count=count+1
if L[l]<=R[r]:
S[i]=L[l]
l=l+1
else:
S[i]=R[r]
r=r+1
def ms(S,left,right):
if right>left+1:
mid=(right+left)//2
ms(S,left,mid)
ms(S,mid,right)
mg(S,left,right,mid)
n=int(input())
S=[]
S=input().split()
S=[int(u) for u in S]
ms(S,0,n)
for i in range(0,n-1):
print(S[i],end=" ")
print(S[n-1])
print(count)
| 1 | 115,746,132,568 | null | 26 | 26 |
X=int(input())
ans=1000*(X//500)+5*((X-(X//500*500))//5)
print(ans) | x = int(input())
yen_500 = 0
yen_5 = 0
amari = 0
happy = 0
if x>= 500:
yen_500 = x//500
amari = x - 500 * yen_500
yen_5 = amari//5
happy = 1000 * yen_500 + 5 * yen_5
print(happy)
else:
yen_5 = x//5
happy = 5 * yen_5
print(happy)
| 1 | 42,639,207,729,298 | null | 185 | 185 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.