input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
a = int(eval(input()))
if a%2 == 0:
print((a//2))
else:
print((a//2+1)) | n = int(eval(input()))
if n % 2 == 0:
print((n//2))
else:
print(((n+1)//2)) | p02759 |
import math
n = int(eval(input()))
print((math.floor((n+1)/2)))
| import math
N = int(eval(input()))
print((math.ceil(N/2))) | p02759 |
def main():
N = int(eval(input()))
print(((N + 1) // 2))
return
main()
| def main():
N = int(eval(input()))
print((-(-N // 2)))
return
main()
| p02759 |
print((int((int(eval(input()))+1)/2))) | print(((int(eval(input()))+1)//2)) | p02759 |
N = int(eval(input()))
ans = N // 2 + N % 2
print(ans)
| N = int(eval(input()))
ans = (N + 1) // 2
print(ans)
| p02759 |
import math
N = int(eval(input()))
print((math.ceil(N/2))) | n = int(eval(input()))
if n % 2 <= 0 :
print((n//2))
elif n % 2 >= 1 :
print((n//2 +1))
| p02759 |
N = int(eval(input()))
if N % 2 == 0:
print((N//2))
else:
print((N//2+1)) | N = int(eval(input()))
output = 0
for i in range(1, N+1, 2):
output += 1
print(output) | p02759 |
import sys
sys.setrecursionlimit(10**9)
INF = 10**12
N = int(eval(input()))
D = dict()
for _ in range(N):
s, c = input().split()
if s in list(D.keys()):
D[s] = min(D[s], int(c))
else:
D[s] = int(c)
def check_kaibun(s):
n = len(s)
return all(s[i] == s[-i-1] for i in r... | import sys
sys.setrecursionlimit(10**9)
INF = 10**12
LIM = 20
N = int(eval(input()))
D = dict()
for _ in range(N):
s, c = input().split()
if s in list(D.keys()):
D[s] = min(D[s], int(c))
else:
D[s] = int(c)
def check_kaibun(s):
n = len(s)
return all(s[i] == s[-i-1] ... | p02587 |
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#imp... | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#imp... | p02587 |
import sys
sys.setrecursionlimit(2*10**9)
from collections import defaultdict
inf = 10**18
def main():
N = int(eval(input()))
S1 = []
S2 = []
C = []
for i in range(N):
s,c = input().split()
S1.append(s)
S2.append(s[::-1])
C.append(int(c))
... | from heapq import heappush, heappop
inf = float('inf')
def dijkstra(graph:list, node:int, start:int) -> list:
dist = [inf]*node
dist[start] = 0
heap = [(0,start)]
while heap:
cost,thisNode = heappop(heap)
for NextCost,NextNode in graph[thisNode]:
dist_cand = dist[t... | p02587 |
# -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
###... | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
###... | p02587 |
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [lis... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [lis... | p02587 |
from collections import deque
def isPalindrome(s):
L = len(s)
return all(s[i] == s[L - 1 - i] for i in range(L // 2))
N = int(eval(input()))
S = []
for _ in range(N):
s, c = input().split()
S.append((s, int(c)))
path = [dict() for _ in range(2)]
q = deque()
# S.sort(key=lambda x: x[... | from collections import deque
def isPalindrome(s):
L = len(s)
return all(s[i] == s[L - 1 - i] for i in range(L // 2))
N = int(eval(input()))
S = []
for _ in range(N):
s, c = input().split()
S.append((s, int(c)))
path = [dict() for _ in range(2)]
q = deque()
S.sort(key=lambda x: x[1]... | p02587 |
from collections import deque
def isPalindrome(s):
L = len(s)
return all(s[i] == s[L - 1 - i] for i in range(L // 2))
N = int(eval(input()))
S = []
for _ in range(N):
s, c = input().split()
S.append((s, int(c)))
path = [dict() for _ in range(2)]
q = deque()
S.sort(key=lambda x: x[1]... | from collections import deque
def isPalindrome(s):
''' s: string が回文か判定する. 回文 -> True, 回文でない -> False.
'''
L = len(s)
return all(s[i] == s[L - 1 - i] for i in range(L // 2))
N = int(eval(input()))
S = []
for _ in range(N):
s, c = input().split()
S.append((s, int(c)))
path = ... | p02587 |
n = int(eval(input()))
def stairs(n):
if (n == 1):
return 1
elif(n == 2):
return 2
elif(n == 3):
return 4
return stairs(n-1) + stairs(n-2) + stairs(n-3)
while (n != 0):
pn = stairs(n)
if (pn%10 == 0):
pn //= 10
else:
pn = pn//10 + 1
... | n = int(eval(input()))
st = [1,2,4]
for i in range(n-3):
s = st[-1] + st[-2] + st[-3]
st.append(s)
while (n != 0):
pn = st[n-1]
if (pn%10 == 0):
pn //= 10
else:
pn = pn//10 + 1
if (pn%365 == 0):
pn //= 365
else:
pn = pn//365 + 1
print(pn)
... | p00168 |
import functools
#@functools.lru_cache(maxsize=None)
def rec(i):
if i <= 0:
return i == 0
return rec(i-1) + rec(i-2) + rec(i-3)
while True:
N = int(eval(input()))
if not N:
break
print((((rec(N)-1)//10)//365+1)) | import functools
@functools.lru_cache(maxsize=None)
def rec(i):
if i <= 0:
return i == 0
return rec(i-1) + rec(i-2) + rec(i-3)
while True:
N = int(eval(input()))
if not N:
break
print((rec(N)//3650+1)) | p00168 |
def up(n):
if n == 0: return 1
if n < 0: return 0
return up(n-1)+up(n-2)+up(n-3)
while True:
n = int(input())
if n == 0: break
print((up(n)//10+1)//365+1) | def up(n):
goal = [0 for i in range(n)]
goal[:3] = [1,2,4]
for i in range(3,n):
goal[i] = sum(goal[i-3:i])
return goal[-1]
while True:
n = int(input())
if n == 0: break
print((up(n)//10+1)//365+1) | p00168 |
from math import ceil
dp = [1] + [0 for i in range(30)]
for i in range(1,31):
for step in [1,2,3]:
if step <= i:
dp[i] += dp[i-step]
unit = 3650.
while 1:
n = int(input())
if n == 0:
break
print(int(ceil(dp[n] / unit))) | from math import ceil
dp = [1] + [0 for i in range(33)]
for i in range(0,30):
for step in [1,2,3]:
dp[i+step] += dp[i]
unit = 3650.
while 1:
n = int(input())
if n == 0:
break
print(int(ceil(dp[n] / unit))) | p00168 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, ... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, ... | p02893 |
N=int(eval(input()))
for _ in[0]*int(eval(input())):
a,b=list(map(int,input().split()))
print((min(a-1,N-a,b-1,N-b)%3+1))
| import sys
N=int(eval(input()))
eval(input())
for e in sys.stdin:
a,b=list(map(int,e.split()))
print((min(a-1,N-a,b-1,N-b)%3+1))
| p00479 |
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n,k = list(map(int... | import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n,k = list(map(int... | p02964 |
import bisect
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
ind = [[] for _ in range(2*10**5 + 1)]
for i,num in enumerate(a):
ind[num].append(i)
for i in range(1,2*10**5 + 1):
if(ind[i]):
ind[i].append(ind[i][0] + n)
cnt = 0
now = a[0]
while(True):
right... | import bisect
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
ind = [[] for _ in range(2*10**5 + 1)]
for i,num in enumerate(a):
ind[num].append(i)
for i in range(1,2*10**5 + 1):
if(ind[i]):
ind[i].append(ind[i][0] + n)
before = []
cnt = 0
now = a[0]
while(True... | p02964 |
import sys
input = sys.stdin.readline
'''
9 4
1 8 6 6 8 7 8 1 9
'''
N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
last = dict()
v = [-1] * N
for i, a in enumerate(A + A) :
if a in last and last[a] < N :
v[last[a]] = i + 1
last[a] = i
dist = [-... | import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
last = dict()
v = [-1] * N
for i, a in enumerate(A + A) :
if a in last and last[a] < N :
v[last[a]] = i + 1
last[a] = i
dist = [-1] * N
cur = 0
cycle = 0
while di... | p02964 |
def examA():
N = DI()/dec(7)
ans = N
print(N)
return
def examB():
N, K = LI()
A = LI()
maxA = max(A)
def function(s):
stack = deque()
num = [0]*(maxA+1)
for i in range(s,N):
a = A[i]
if num[a]==0:
stack.ap... | def examA():
N = DI()/dec(7)
ans = N
print(N)
return
def examB():
N, K = LI()
A = LI()
maxA = max(A)
def function(s):
stack = deque()
num = [0]*(maxA+1)
for i in range(s,N):
a = A[i]
if num[a]==0:
stack.ap... | p02964 |
from bisect import bisect
from collections import defaultdict
def main():
n, k = list(map(int, input().split()))
*a, = list(map(int, input().split()))
idx = defaultdict(list)
for i, x in enumerate(a):
idx[x].append(i)
m = (k * n).bit_length()
dub = [[0] * n for _ in range(m)]
for i, x in enumerate(a)... | from bisect import bisect
from collections import defaultdict
def main():
n, k = list(map(int, input().split()))
*a, = list(map(int, input().split()))
idx = defaultdict(list)
for i, x in enumerate(a):
idx[x].append(i)
m = (k * n).bit_length()
dub = [[-1] * n for _ in range(m)]
for i, x in enumerate(a... | p02964 |
N, K = list(map(int, input().split()))
As = list(map(int, input().split()))
M = [[] for i in range(200001)]
for i, a in enumerate(As):
M[a].append(i)
S = []
for i, a in enumerate(As):
l = M[a]
index = l.index(i)
if index+1 == len(l):
n = l[0]+N
else:
n = l[index+1]
S.append(n+1-i)
#pri... | N, K = list(map(int, input().split()))
As = list(map(int, input().split()))
M = [[] for i in range(200001)]
for i, a in enumerate(As):
M[a].append(i)
S = []
for i, a in enumerate(As):
l = M[a]
index = l.index(i)
if index+1 == len(l):
n = l[0]+N
else:
n = l[index+1]
S.append(n+1-i)
#pri... | p02964 |
import math
# input
#
# n = 5
# k = 10
# a = [1, 2, 3, 2, 3]
n, k = list(map(int, input().split()))
a = [int(ai) for ai in input().split()]
# make jumpto
#
# 0 -> 6 (6)
# 1 -> 4 (3)
# 2 -> 5 (3)
# 3 -> 7 (4)
# 4 -> 8 (4)
jumpto = [[-1] * n]
la = -1
li = -1
for (ca, ci) in sorted(zip(a, list(ra... | import math
# input
#
# n = 5
# k = 10
# a = [1, 2, 3, 2, 3]
n, k = list(map(int, input().split()))
a = [int(ai) for ai in input().split()]
# make jumpto
#
# 0 -> 6 (6)
# 1 -> 4 (3)
# 2 -> 5 (3)
# 3 -> 7 (4)
# 4 -> 8 (4)
jumpto = [[-1] * n]
la = -1
li = -1
for (ca, ci) in sorted(zip(a, list(ra... | p02964 |
import sys
sys.setrecursionlimit(1000000)
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
count = 0
j = 0
def f(s,j,count):
cho = False
for t in range(j+1,n):
if a[s] == a[t]:
cho == True
if t+1==n:
return count
... | import sys
sys.setrecursionlimit(1000000)
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = []
for i in range(0,n):
p = a[i]
chou = False
for j in range(i+1,n):
if a[i] == a[j]:
chou = True
b.append(j)
break
if not ch... | p02964 |
n=int(eval(input()))
a=list(map(int,input().split()))
print((max(a)-min(a))) | n=int(eval(input()))
a=sorted(list(map(int,input().split())))
print((a[-1]-a[0])) | p03694 |
N = eval(input())
a = list(map(int, input().split()))
print((max(a)-min(a))) | total_house = int(eval(input()))
house_coordinate = sorted(list(map(int, input().split())))
print((house_coordinate[total_house - 1]- house_coordinate[0])) | p03694 |
eval(input())
a=list(map(int,input().split()))
print((max(a)-min(a))) | eval(input())
a = sorted(map(int, input().split()))
print((a[-1]-a[0])) | p03694 |
_,*a=list(map(int,open(0).read().split()));print((max(a)-min(a))) | _,t=open(0);*a,=list(map(int,t.split()));print((max(a)-min(a))) | p03694 |
N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(1, len(a)):
ans += a[i] - a[i-1]
print(ans) | N = int(eval(input()))
a = list(map(int, input().split()))
print((max(a) - min(a))) | p03694 |
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
print((A[-1]-A[0])) | N = int(eval(input()))
A = list(map(int,input().split()))
print((max(A)-min(A))) | p03694 |
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
dis = 0
for i in range(N-1):
dis += abs(A[i] - A[i+1])
print(dis) | N = int(eval(input()))
A = list(map(int,input().split()))
print((max(A)-min(A))) | p03694 |
eval(input())
a=list(map(int,input().split()))
print((max(a)-min(a))) | eval(input())
a=sorted(map(int,input().split()))
print((a[-1]-a[0])) | p03694 |
times = int(eval(input()))
count = 0
li = [list(map(int, input().split())) for i in range(times)]
for item in li:
count += 1 + item[1] - item[0]
print(count) | n = int(eval(input()))
lr = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n):
ans += lr[i][1]-lr[i][0]+1
print(ans) | p03606 |
n = int(eval(input()))
sum = 0
for i in range(n):
l, r = list(map(int, input().split()))
sum += (r-l) + 1
print(sum) | n = int(eval(input()))
res = 0
for i in range(n):
l, r = list(map(int, input().split()))
res += (r-l + 1)
print(res) | p03606 |
china = int(eval(input()))
kazu = 0
for i in range(china):
a, b = [int(i) for i in input().split()]
kazu = kazu + (b - a + 1)
print(kazu) | num = int(eval(input()))
InA = [input().split() for i in range(num)]
seki_total = 0
for seki in InA:
seki_total += int(seki[1]) - int(seki[0]) + 1
print (seki_total) | p03606 |
N = int(eval(input()))
people = 0
for i in range(N):
l, r = list(map(int, input().split()))
people += r-l+1
print(people) | p = 0
for i in range(int(eval(input()))):
l, r = list(map(int, input().split()))
p += r-l+1
print(p) | p03606 |
print((sum([1-eval(input().replace(' ','-')) for _ in [0]*int(eval(input()))]))) | N = int(eval(input()))
S = 0
for i in range(N):
l,r = list(map(int,input().split()))
S += r - l + 1
print(S) | p03606 |
def resolve():
record =[]
for i in range(int(eval(input()))):
l,r = list(map(int,input().split()))
record+=list(range(l,r+1))
print((len(set(record))))
resolve() | print((sum(1-eval(input().replace(" ","-")) for _ in range(int(eval(input())))))) | p03606 |
N=int(eval(input()))
ans=0
for i in range(N):
l,r=list(map(int,input().split()))
ans+=r-l+1
print(ans) | import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
LR = [list(map(int, input().split())) for _ in range(N)]
answer = 0
for l, r in LR:
answer += r - l + 1
print(answer) | p03606 |
N = int(eval(input()))
ans = 0
for i in range(N):
lr = list(map(int, input().split()))
ans += lr[1] - lr[0] +1
print(ans) | N = int(eval(input()))
ans = 0
for i in range(N):
l, r = list(map(int, input().split()))
ans += r-l+1
print(ans) | p03606 |
N = int(eval(input()))
a = []
for i in range(N):
a.append(list(map(int, input().split())))
number = 0
for i in range(N):
abc = a[i-1]
first = abc[0]
last = abc[1]
abc_number = last - first + 1
number += abc_number
print((int(number))) | n = int(eval(input()))
ans = 0
for i in range(n):
l, r = list(map(int, input().split()))
ans += r - l + 1
print(ans) | p03606 |
print((sum(1-eval(input().replace(" ","-")) for _ in range(int(eval(input())))))) | N=int(eval(input()))
people=0
for i in range(N):
l,r=list(map(int,input().split()))
people+=r-l+1
print(people) | p03606 |
n = int(eval(input()))
seat = [0] * 10 ** 6
for i in range(n):
l, r = list(map(int, input().split()))
for j in range(l, r + 1):
seat[j - 1] = 1
res = 0
for i in range(10 ** 6):
if seat[i] == 1:
res += 1
print(res)
| n = int(eval(input()))
seat = [0] * (10 ** 5 + 1)
for i in range(n):
l, r = list(map(int, input().split()))
seat[l - 1] += 1
seat[r] -= 1
for i in range(1, 10 ** 5):
seat[i] += seat[i - 1]
res = 0
for i in range(10 ** 5):
if seat[i] == 1:
res += 1
print(res)
| p03606 |
n = int(eval(input()))
seat = [0] * (10 ** 5 + 1)
for i in range(n):
l, r = list(map(int, input().split()))
seat[l - 1] += 1
seat[r] -= 1
for i in range(1, 10 ** 5):
seat[i] += seat[i - 1]
res = 0
for i in range(10 ** 5):
if seat[i] == 1:
res += 1
print(res)
| n = int(eval(input()))
# seat = [0] * 10 ** 6
seat = [0] * 10 ** 5
for i in range(n):
l, r = list(map(int, input().split()))
for j in range(l, r + 1):
seat[j - 1] = 1
res = 0
# for i in range(10 ** 6):
for i in range(10 ** 5):
if seat[i] == 1:
res += 1
print(res)
| p03606 |
n = int(eval(input()))
# seat = [0] * 10 ** 6
seat = [0] * 10 ** 5
for i in range(n):
l, r = list(map(int, input().split()))
for j in range(l, r + 1):
seat[j - 1] = 1
res = 0
# for i in range(10 ** 6):
for i in range(10 ** 5):
if seat[i] == 1:
res += 1
print(res)
| n = int(eval(input()))
res = 0
for i in range(n):
r, l = list(map(int, input().split()))
res += l - r + 1
print(res)
| p03606 |
print((sum(1-eval(s.replace(' ','-'))for s in open(0).readlines()[1:]))) | _,*t=open(0);print((sum(1-eval(s.replace(' ','-'))for s in t))) | p03606 |
import collections
n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
d = {}
for i in range(len(l)):
for j in range(l[i][0], l[i][1] + 1):
d[j] = 1
print((len(d)))
| n = int(eval(input()))
t = 0
for i in range(n):
l, r = list(map(int, input().split()))
t += (r - l + 1)
print(t)
| p03606 |
n = int(eval(input()))
l = [tuple(map(int, input().split())) for i in range(n)]
cnt = 0
for i in l:
cnt += (i[1] - i[0] + 1)
print(cnt)
| N = int(eval(input()))
ans = 0
for i in range(N):
l,r = list(map(int, input().split()))
ans += r - l + 1
print(ans)
| p03606 |
n = int(eval(input()))
count = 0
for i in range(n):
l,r = list(map(int,input().split()))
count += r-l+1
print(count) | n = int(eval(input()))
count = 0
for i in range(n):
li,ri = list(map(int,input().split()))
count += ri-li+1
print(count) | p03606 |
print((sum(s[1] - s[0] + 1 for s in [list(map(int, input().split())) for _ in range(int(eval(input())))])))
| import sys
stdin = sys.stdin
def input():
return stdin.readline().strip()
print((sum(s[1] - s[0] + 1 for s in [list(map(int, input().split())) for _ in range(int(eval(input())))]))) | p03606 |
n=int(eval(input()))
c=0
for i in range(n):
l,r=input().split()
c+=(int(r)-int(l)+1)
print(c)
| c=0
n=int(eval(input()))
for i in range(n):
l,r=list(map(int,input().split()))
c+=(r-l+1)
print(c)
| p03606 |
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product
def resolve():
N=int(eval(input()))
cnt=0
for i in range(N):
l... | import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
cnt=0
N=int(eval(input()))
for i in range(N):
l,r=list(map(int,input().split()))
cnt+=r-l+1
print(cnt)
resolve() | p03606 |
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# ... | # 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
... | p03086 |
#ABC122B
def main():
import sys
S = sys.stdin.readline().rstrip()
#print(S)
L = ['A', 'C', 'G', 'T']
cnt, ans = 0, 0
for s in S:
if s in L:
cnt+=1
else:
if ans < cnt:
ans = cnt
#print(ans)
cnt=0
el... | #ABC122B
def main():
import sys
S = sys.stdin.readline().rstrip()
#print(S)
cnt = 0
ans = 0
for s in S:
if s in ['A', 'G', 'C', 'T']:
cnt +=1
else:
ans = max(ans, cnt)
cnt=0
ans = max(ans, cnt)
print(ans)
... | p03086 |
import sys
from collections import deque
from itertools import *
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
... | import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
temp = 0
ans = 0
for char in s:
if char in 'ACGT':
... | p03086 |
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
temp = 0
ans = 0
for char in s:
if char in 'ACGT':
... | import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = 0
temp = 0
for i in s:
if i in 'ACGT':
te... | p03086 |
from collections import deque
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# check reachability B -> A ?
# 隣接和table
P = [B[(i-1)%N] + B[(i+1)%N] for i in range(N)]
D = deque(i for i in range(N) if B[i] - P[i] >= A[i])
ans = 0
nmatch = [B[i] == A[i] for i in r... | from collections import deque
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# check reachability B -> A ?
# 隣接和table
P = [B[(i-1)%N] + B[(i+1)%N] for i in range(N)]
D = deque(i for i in range(N) if B[i] - P[i] >= A[i])
ans = 0
nmatch = [B[i] == A[i] for i in r... | p02941 |
from pprint import pprint
import queue
def solve(n, a, b):
state = queue.Queue()
state.put((0, b[:]))
while not state.empty():
count, b_tmp = state.get()
# print("next:" + str(count))
# pprint(b_tmp)
for i, b_i in enumerate(b_tmp):
i_a = (i -... | from pprint import pprint
import queue
def solve(n, a, b):
a_pq = queue.PriorityQueue()
for i, a_i in enumerate(a):
a_pq.put((a_i, i))
b_pq = queue.PriorityQueue()
for i, b_i in enumerate(b):
b_pq.put((b_i, i))
state = queue.Queue()
state.put((0, b[:]))
while n... | p02941 |
from pprint import pprint
import queue
def solve(n, a, b):
a_pq = queue.PriorityQueue()
for i, a_i in enumerate(a):
a_pq.put((a_i, i))
b_pq = queue.PriorityQueue()
for i, b_i in enumerate(b):
b_pq.put((b_i, i))
state = queue.Queue()
state.put((0, b[:]))
while n... | from pprint import pprint
import queue
def solve(n, a, b):
a_pq = queue.PriorityQueue()
for i, a_i in enumerate(a):
a_pq.put((a_i, i))
b_pq = queue.PriorityQueue()
for i, b_i in enumerate(b):
b_pq.put((b_i, i))
state = queue.Queue()
state.put((0, b[:]))
while n... | p02941 |
from pprint import pprint
import heapq
def solve(n, a, b):
b_pq = []
b_rev = {}
for i, b_i in enumerate(b):
heapq.heappush(b_pq, (-1 * b_i, i))
count = 0
while b_pq:
tmp = heapq.heappop(b_pq)
# pprint(tmp)
b_i = tmp[0] * -1
i_b = tmp[1]
... | from pprint import pprint
import heapq
def solve(n, a, b):
b_pq = []
b_rev = {}
delete = []
for i, b_i in enumerate(b):
if b_i == a[i]:
continue
heapq.heappush(b_pq, (-1 * b_i, i))
count = 0
while b_pq:
tmp = heapq.heappop(b_pq)
# ppri... | p02941 |
from pprint import pprint
import heapq
def solve(n, a, b):
b_pq = []
b_rev = {}
delete = []
for i, b_i in enumerate(b):
if b_i == a[i]:
continue
heapq.heappush(b_pq, (-1 * b_i, i))
count = 0
while b_pq:
tmp = heapq.heappop(b_pq)
# ppri... | from pprint import pprint
import heapq
def solve(n, a, b):
b_pq = []
b_rev = {}
delete = []
for i, b_i in enumerate(b):
if b_i == a[i]:
continue
heapq.heappush(b_pq, (-1 * b_i, i))
count = 0
while b_pq:
tmp = heapq.heappop(b_pq)
# ppri... | p02941 |
def main():
n=int(eval(input()))
# for i in range(n):
src = [int(item) for item in input().split()]
dst = [int(item) for item in input().split()]
q=set()
s=set()
ans=0
def SandQ(i):
ri=i+1
li=i-1
if i==0:li=n-1
if i==n-1:ri=0
x=0
if dst[i]-src[i]>=dst[ri]+dst[li]:
x=(dst[i]-src[i])/... | def main():
n=int(eval(input()))
src = [int(item) for item in input().split()]
dst = [int(item) for item in input().split()]
q=set()
ans=0
def SandQ(i):
ri=i+1
li=i-1
if i==0:li=n-1
if i==n-1:ri=0
x=0
if dst[i]-src[i]>=dst[ri]+dst[li]:
x=(dst[i]-src[i])//(dst[ri]+dst[li])
dst[i]-=(... | p02941 |
def main():
n=int(eval(input()))
src = [int(item) for item in input().split()]
dst = [int(item) for item in input().split()]
q=set()
ans=0
def SandQ(i):
ri=i+1
li=i-1
if i==0:li=n-1
if i==n-1:ri=0
x=0
if dst[i]-src[i]>=dst[ri]+dst[li]:
x=(dst[i]-src[i])//(dst[ri]+dst[li])
dst[i]-=(... | def main():
n=int(eval(input()))
src = [int(item) for item in input().split()]
dst = [int(item) for item in input().split()]
ans=0
def SandQ(i):
ri=i+1
li=i-1
if i==0:li=n-1
if i==n-1:ri=0
x=0
if dst[i]-src[i]>=dst[ri]+dst[li]:
x=(dst[i]-src[i])//(dst[ri]+dst[li])
dst[i]-=(dst[ri]+ds... | p02941 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
q = []
push = lambda x,i: heappush(q, (-x,i))
def pop():
x,i = heappop(q)
return -x,i
fo... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
q = []
push = lambda x,i: heappush(q, (-x,i))
for i,x in enumerate(B):
push(x,i)
answer = 0
... | p02941 |
import sys
from heapq import heappush as hpu
from heapq import heappop as hpo
input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
base = 10 ** 10
sb = [(-b[i], i) for i in range(N) if a[i] != b[i]]
h = []
for t in sb: hpu(h, t)
res = 0
... | import sys
from heapq import heappush as hpu
from heapq import heappop as hpo
input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
base = 10 ** 6
sb = [-(b[i] * base + i) for i in range(N) if a[i] != b[i]]
h = []
for t in sb: hpu(h, t)
re... | p02941 |
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pq = []
for i, b in enumerate(B):
if A[i] != b:
heappush(pq, (-b, i))
ans = 0
while pq:
_, i = heappop(pq)
B[i] -= B... | from heapq import heappush, heappop
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pq = []
for i, b in enumerate(B):
if A[i] != b:
heappush(pq, (-b, i))
ans = 0
while pq:
_, i = heappop(pq)
s = B[(i-... | p02941 |
from collections import deque
def resolve():
n = int(eval(input()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
q = deque()
diffs = set()
for i in range(n):
if bb[i] != aa[i]:
diffs.add(i)
bef_i = i-1 if i > 0 else n-1
... | from collections import deque
def resolve():
n = int(eval(input()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
q = deque()
diffs = set()
for i in range(n):
if bb[i] != aa[i]:
diffs.add(i)
bef_i = i-1 if i > 0 else n-1
... | p02941 |
import heapq
n=int(eval(input()))
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
for i in range(n):
if arr2[i]!=arr1[i]:
heapq.heappush(q,(-arr2[i],i))
cnt=0
while q:
val,pos=heapq.heappop(q)
val*=-1
diff=arr2[pos-1]+arr2[(pos+1)%n]
move,tmp=divmod(val-arr1[pos... | import heapq
n=int(eval(input()))
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
for i in range(n):
if arr2[i]!=arr1[i]:
heapq.heappush(q,(-arr2[i],i))
cnt=0
while q:
val,pos=heapq.heappop(q)
val*=-1
diff=arr2[pos-1]+arr2[(pos+1)%n]
move=(val-arr1[pos])//diff
... | p02941 |
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
a = [... | import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
a = [... | p02941 |
#!/usr/bin/env python3
#AGC37 C
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop,heapify
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator imp... | #!/usr/bin/env python3
#AGC37 C
import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop,heapify
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator imp... | p02941 |
"""
演算子は要素とセットでモノイドを形成するようなものでなければならない。
すなわち、結合律が成り立ち単位元が存在する必要がある。
equalityはsetを高速化するために使う。めんどい場合はNoneにしてもOK
"""
class SegmentTree:
@classmethod
def all_identity(cls, operator, equality, identity, size):
return cls(operator, equality, identity, [identity]*(2 << (size-1).bit_length()))
... |
"""
演算子は要素とセットでモノイドを形成するようなものでなければならない。
すなわち、結合律が成り立ち単位元が存在する必要がある。
equalityはsetを高速化するために使う。めんどい場合はNoneにしてもOK
"""
class SegmentTree:
@classmethod
def all_identity(cls, operator, equality, identity, size):
return cls(operator, equality, identity, [identity]*(2 << (size-1).bit_length()))
... | p02941 |
def main():
from sys import exit
n = int(eval(input()))
a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]
result = 0
q = [i for i in range(n) if b[i] != a[i]]
while len(q) != 0:
nq = []
c = 0
for i in q:
if i == 0 or i ... | def main():
from sys import exit
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
result = 0
q = [i for i in range(N) if B[i] != A[i]]
while len(q) != 0:
nq = []
c = 0
for i in q:
if i == 0 or i ... | p02941 |
n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
cnt, prev_cnt = 0, -1
while cnt != prev_cnt:
prev_cnt = cnt
for i in range(n):
adj_sum = b[i - 1] + b[(i + 1) % n]
k = (b[i] - a[i]) // adj_sum
if k > 0:
... | #import sys
#input = sys.stdin.readline
n = int(eval(input()))
a = [0]*n
b = [0]*n
a =[int(xi) for xi in input().split()]
b =[int(yi) for yi in input().split()]
cnt, prev_cnt = 0, -1
while cnt != prev_cnt:
prev_cnt = cnt
for i in range(n):
adj_sum = b[i - 1] + b[(i + 1) % n]
... | p02941 |
import sys
from heapq import heappop as hpp, heappush as hp
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
geta = 10**6
Q = [-(B[i]*geta+i) for i in range(N)] + [0]
Q.sort()
ans = 0
cnt = 0
inf = 10**9+7
while cnt... | import sys
from heapq import heappop as hpp, heappush as hp
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
geta = 10**6
Q = [-(B[i]*geta+i) for i in range(N)] + [0]
Q.sort()
ans = 0
cnt = 0
inf = 10**9+7
while cnt... | p02941 |
import sys
import heapq
def main():
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
h=[]
for i in range(n):
if b[i]>a[i]:
heapq.heappush(h,[b[i]*-1,i])
loop=0
idx=0
while(1):
#print(b)
if not h:
... | import sys
import heapq
def main():
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
h=[]
for i in range(n):
if b[i]>a[i]:
heapq.heappush(h,(b[i]*-1,i))
loop=0
idx=0
while(1):
#print(b)
if not h:
... | p02941 |
N=int(eval(input()))
A=tuple(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
a=0
for i,b in enumerate(B):
heappush(q,(-b,i))
while len(q)>0:
b,i=heappop(q)
ba=-b-A[i]
bb=B[i-1]+B[i+1-N]
if ba<0:
a=-1
break
elif ba=... | N=int(eval(input()))
A=tuple(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
a=0
for i,b in enumerate(B):
heappush(q,(-b,i))
while len(q)>0:
b,i=heappop(q)
ba=-b-A[i]
bb=B[i-1]+B[i+1-N]
if ba<0:
a=-1
break
elif ba=... | p02941 |
from heapq import heappush, heappop
N = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
def solve() :
h = []
for i in range(N) :
if A[i] == B[i] :
continue
heappush(h, (-B[i], i))
ret = 0
while len(h) > 1 :
... | from heapq import heappush, heappop
N = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
def solve() :
h = []
for i in range(N) :
if A[i] == B[i] :
continue
heappush(h, (-B[i], i))
ret = 0
while h :
_, i ... | p02941 |
n=int(eval(input()))
A=list(map(int,input().split( )))
B=list(map(int,input().split( )))
count=0
prv_count=-1#人の見て追加
#flag=True
while count!=prv_count:
prv_count=count
for i in range(-1,n-1):
tonari=B[i-1]+B[i+1]
tmp=(B[i]-A[i])//tonari
if tmp>0:
B[i]-=tonari*tm... | ###test
n=int(eval(input()))
A=list(map(int,input().split( )))
B=list(map(int,input().split( )))
count=0
flag=True
while flag:
flag=False
for i in range(-1,n-1):
tonari=B[i-1]+B[i+1]
tmp=(B[i]-A[i])//tonari
if tmp>0:
B[i]-=tonari*tmp
count+=tmp
... | p02941 |
###test
n=int(eval(input()))
A=list(map(int,input().split( )))
B=list(map(int,input().split( )))
count=0
flag=True
while flag:
flag=False
for i in range(-1,n-1):
tonari=B[i-1]+B[i+1]
tmp=(B[i]-A[i])//tonari
if tmp>0:
B[i]-=tonari*tmp
count+=tmp
... | n=int(eval(input()))
A=list(map(int,input().split( )))
B=list(map(int,input().split( )))
count=0
flag=True
while flag:
flag=False
for i in range(-1,n-1):
tonari=B[i-1]+B[i+1]
tmp=(B[i]-A[i])//tonari
if tmp>0:
B[i]-=tonari*tmp
count+=tmp
fl... | p02941 |
def main():
from heapq import heappop as hpop
from heapq import heappush as hpush
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
visit = [False]*n
h = []
for i in range(n):
hpush(h, (-b[i], i))
cnt = 0
while h:
... | def main():
from heapq import heappop as hpop
from heapq import heappush as hpush
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
h = []
for i in range(n):
hpush(h, (-b[i], i))
cnt = 0
while h:
i, j = hpop(h)
... | p02941 |
import heapq
q = []
heapq.heapify(q)
n = int(eval(input()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
zeros = [False]*n
Cs = [Bs[(i-1)%n]+Bs[(i+1)%n] for i in range(n)]
Ds = [b-(c+a) for b,c,a in zip(Bs,Cs,As)]
# Dが大きい順に操作していく?
# 初期値
for i,d in enumerate(Ds):
if d < 0... | import heapq
q = []
heapq.heapify(q)
n = int(eval(input()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
zeros = [False]*n
Cs = [Bs[(i-1)%n]+Bs[(i+1)%n] for i in range(n)]
# Dが大きい順に操作していく
for i, (b,c,a) in enumerate(zip(Bs,Cs,As)):
d = b-(c+a)
if d < 0: continue
... | p02941 |
words = lambda t : list(map(t, input().split()))
n = int(eval(input()))
a = words(int)
b = words(int)
def getNext(i):
if i == n-1:
return 0
else:
return i+1
def getPrev(i):
if i == 0:
return n-1
else:
return i-1
import queue
q = queue.Queue()
... | words = lambda t : list(map(t, input().split()))
n = int(eval(input()))
a = words(int)
b = words(int)
def getNext(i):
if i == n-1:
return 0
else:
return i+1
def getPrev(i):
if i == 0:
return n-1
else:
return i-1
from collections import deque
q =... | p02941 |
from heapq import heappush,heappop
n,*t=list(map(int,open(0).read().split()))
a=t[:n]
b=t[n:]
B=[]
for i,j in enumerate(b):heappush(B,(-j,i))
c=0
d=0
while B and d<2*10**6:
d+=1
y,i=heappop(B)
x,z=b[(i-1)%n],b[(i+1)%n]
t=(b[i]-a[i])//(x+z)
b[i]-=t*(x+z)
c+=t
if b[i]>a[i]:
... | n,*t=list(map(int,open(0).read().split()));A=t[:n];B=t[n:];r=0
while True:
c=0
for i in range(n):
b=B[(i-1)%n]+B[(i+1)%n]
if 0<b<B[i] and A[i]<B[i]:
t=(B[i]-A[i])//b
c+=t
B[i]-=t*b
r+=c
if c==0:break
print(([-1,r][A==B]))
| p02941 |
n,*t=list(map(int,open(0).read().split()));A=t[:n];B=t[n:];r=0
while 1:
c=0
for i in range(n):
b=B[~-i%n]+B[-~i%n]
if b<B[i]and A[i]<B[i]:t=(B[i]-A[i])//b;c+=t;B[i]-=t*b
r+=c
if c==0:break
print(([-1,r][A==B])) | n,*t=list(map(int,open(0).read().split()));A=t[:n];B=t[n:];r=0
while 1:
c=0
for i in range(n):
b=B[~-i%n]+B[-~i%n]
if A[i]<B[i]>b:t=(B[i]-A[i])//b;c+=t;B[i]-=t*b
r+=c
if c==0:break
print(([-1,r][A==B])) | p02941 |
def examA():
S = SI(); N = len(S)
prev = S[0]; cur = ""
k = 0; ans = 1
while(k<N-1):
k +=1
cur += S[k]
if cur==prev:
continue
prev = cur
cur = ""
ans +=1
print(ans)
return
def examB():
N = I()
S = SI()
ret... | def examA():
S = SI(); N = len(S)
prev = S[0]; cur = ""
k = 0; ans = 1
while(k<N-1):
k +=1
cur += S[k]
if cur==prev:
continue
prev = cur
cur = ""
ans +=1
print(ans)
return
def examB():
N = I()
S = SI()
ret... | p02941 |
import sys
input = sys.stdin.readline
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
BI=[(b,i) for i,b in enumerate(B)]
# Segment tree(1-indexed,再帰を使わないもの)
seg_el=1<<(N.bit_length())# Segment treeの台の要素数
SEG=[(0,0)]*(2*seg_el)# 1-indexedなので、要素数2*seg_el.Segment treeの初... | import sys
input = sys.stdin.readline
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
BI=[(b,i) for i,b in enumerate(B)]
# Segment tree(1-indexed,再帰を使わないもの)
seg_el=1<<(N.bit_length())# Segment treeの台の要素数
SEG=[(0,0)]*(2*seg_el)# 1-indexedなので、要素数2*seg_el.Segment treeの初... | p02941 |
from heapq import heappop,heappush
def main(a,b):
for i in range(n):
if b[i]<=a[i]:
pass
else:
print((-1))
exit()
pq=[]
[heappush(pq,[-x,i]) for i,x in enumerate(a)]
ans=0
while pq:
v,i=heappop(pq)
v=-v
vv=v
... | def main(n,a,b):
ans=0
while True:
cnt=0
for i in range(n):
m=a[(i-1)%n]+a[(i+1)%n]
if m<a[i] and b[i]<a[i]:
a[i]-=b[i]
cnt+=a[i]//m
a[i]%=m
a[i]+=b[i]
if cnt==0:break
ans+=cnt
... | p02941 |
def p_c():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
l = [-1] * N
idx = set(range(N))
for i in range(N):
l[i] = B[i - 1] + B[(i + 1) % N]
ans = 0
while 1:
f = False
for i in list(idx):
... | def p_c():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
l = [-1] * N
for i in range(N):
l[i] = B[i - 1] + B[(i + 1) % N]
ans = 0
while 1:
f = False
for i in range(N):
if A[i] <= B[i] - l[i]... | p02941 |
import heapq
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if any(a>b for a,b in zip(A,B)):
print((-1))
exit()
hq = [(-a,i) for i,a in enumerate(B)]
heapq.heapify(hq)
ans = 0
while hq:
_,i = heapq.heappop(hq)
if B[i] == A[i]: continue
... | import heapq
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if any(a>b for a,b in zip(A,B)):
print((-1))
exit()
hq = []
for i,(a,b) in enumerate(zip(A,B)):
if a <= b - B[(i-1)%N] - B[(i+1)%N]:
hq.append((-b,i))
heapq.heapify(hq)
ans = 0... | p02941 |
import heapq
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if any(a>b for a,b in zip(A,B)):
print((-1))
exit()
def pb(i):
return i-1 if i-1 >= 0 else N-1
def nx(i):
return i+1 if i+1 < N else 0
hq = []
for i,(a,b) in enumerate(zip(A,B)):
... | import heapq
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if any(a>b for a,b in zip(A,B)):
print((-1))
exit()
def pb(i):
return i-1 if i-1 >= 0 else N-1
def nx(i):
return i+1 if i+1 < N else 0
hq = []
for i,(a,b) in enumerate(zip(A,B)):
... | p02941 |
from collections import deque
def main():
N=int(eval(input()))
A=list(map(int, input().split()))
B=list(map(int, input().split()))
q = deque()
cq = deque()
q.appendleft(B)
cq.appendleft(0)
while len(q) > 0:
b = q.pop()
c = cq.pop()
if b == A:
... | def main():
N=int(eval(input()))
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
while A!=B:
b = True
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
if B[i] > d > 0:
b = False
... | p02941 |
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def unable():
print((-1))
exit()
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
from heapq import heappop, heappush
done = set()
heap = []
for i in range(n):
if a[i]... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def unable():
print((-1))
exit()
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
from heapq import heappush, heappop
h = []
for i in range(n):
if a[i]>b[i]:
u... | p02941 |
import sys,heapq as hq
mod = 10**9+7
def l(): #intのlist
return list(map(int,input().split()))
def m(): #複数文字
return list(map(int,input().split()))
def onem(): #Nとかの取得
return int(eval(input()))
n = onem()
a = l()
b = l()
t = []
for i in range(n):
if b[i] != a[i]:
hq.heap... | import heapq as hq
mod = 10**9+7
def l(): #intのlist
return list(map(int,input().split()))
def m(): #複数文字
return list(map(int,input().split()))
def onem(): #Nとかの取得
return int(eval(input()))
def onon():
n = onem()
a = l()
b = l()
t = []
for i in range(n):
if... | p02941 |
from heapq import heappush,heappop
import sys
input=sys.stdin.readline
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(N):
heappush(lst,[-B[i],i])
count=0
while lst:
h,i=heappop(lst)
h=-h
x,z=B[i-1],B[(i+1)%N]
if (h-A[i])... | from heapq import heappush,heappop
import sys
input=sys.stdin.readline
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(N):
heappush(lst,(-B[i],i))
count=0
while lst:
h,i=heappop(lst)
h=-h
x,z=B[i-1],B[(i+1)%N]
kkk=x+z
... | p02941 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def getN():
return int(eval(input()))
def getList():
return list(map(int, input().split()))
import math
n = getN()
anums = getList()
bnums = getList()
ans = 0
update = True
while(update):
update = False
for i in r... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def getN():
return int(eval(input()))
def getList():
return list(map(int, input().split()))
import math
n = getN()
anums = getList()
bnums = getList()
ans = 0
okay = [0 for i in range(n)]
update = True
while(update):
up... | p02941 |
from heapq import *
N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
h = []
for i in range(N):
heappush(h, (-B[i], i))
ans = 0
while h:
b, i = heappop(h)
b = -b
if b == A[i]:
continue
k = - (-(B[i] - max(B[i-1], B[(i+1)%N],... | N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
if N > 10000:
A = A[5050:] + A[:5050]
B = B[5050:] + B[:5050]
ans = -1
D = [0] * N
L = [i-1 for i in range(N)]
R = [i+1 for i in range(N)]
def calc():
i = 0
c = 0
ans = 0
while c ... | p02941 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.