message
stringlengths
2
433k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
113
108k
cluster
float64
12
12
__index_level_0__
int64
226
217k
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,125
12
30,250
Tags: implementation Correct Solution: ``` n = int(input()) m_list = list(map(int, input().split())) m_min = min(m_list) m_max = max(m_list) m_list.remove(m_min) m_list.remove(m_max) if len(m_list) == 0: print(0) else: new_min = min(m_list) new_max = max(m_list) print(min(m_max - new_min, new_max - m_mi...
output
1
15,125
12
30,251
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,126
12
30,252
Tags: implementation Correct Solution: ``` n=int(input()) lis=list(map(int,input().split())) lis.sort() ans=min(lis[n-2]-lis[0],lis[n-1]-lis[1]) print(ans) ```
output
1
15,126
12
30,253
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,127
12
30,254
Tags: implementation Correct Solution: ``` def stabilizirovanie(lst): if len(lst) == 2: return 0 a = sorted(lst) return min(a[len(lst) - 1] - a[1], a[len(lst) - 2] - a[0]) n = int(input()) b = [int(i) for i in input().split()] print(stabilizirovanie(b)) ```
output
1
15,127
12
30,255
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,128
12
30,256
Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) b = a.copy() c = a.copy() b.remove(max(b)) c.remove(min(c)) print(min(max(b)-min(b),max(c)-min(c))) ```
output
1
15,128
12
30,257
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,129
12
30,258
Tags: implementation Correct Solution: ``` from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def main(): pass # region fas...
output
1
15,129
12
30,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,130
12
30,260
Yes
output
1
15,130
12
30,261
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,131
12
30,262
Yes
output
1
15,131
12
30,263
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,132
12
30,264
Yes
output
1
15,132
12
30,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,133
12
30,266
Yes
output
1
15,133
12
30,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,134
12
30,268
No
output
1
15,134
12
30,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,135
12
30,270
No
output
1
15,135
12
30,271
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,136
12
30,272
No
output
1
15,136
12
30,273
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element...
instruction
0
15,137
12
30,274
No
output
1
15,137
12
30,275
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,214
12
30,428
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` import sys input = sys.stdin.readline print = sys.stdout.write MAX = 2*(10**5) + 1 def divisors(a, ans): div = [] t1 = int(a**.5) for i in range(1, min(t1+1,ans)): if a % i == 0: div.append(i) div.append(int(a/i)) div.sort...
output
1
15,214
12
30,429
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,215
12
30,430
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` import sys def bestval(pp, cc): # print("BESTVAL:") # print(pp) # print(cc) k = len(pp) k_2 = k//2+1 for f in range(1, k_2): if k % f == 0: for offs in range(f): ...
output
1
15,215
12
30,431
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,216
12
30,432
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` def uoc(x): i=1 arr=[] while i*i<=x: if x%i==0: arr.append(i) if i*i!=x: arr.append(x//i) i+=1 return sorted(arr) def is_ok(arr, n, u): #ass...
output
1
15,216
12
30,433
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,217
12
30,434
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` from itertools import combinations from collections import Counter MOD = 998244353 def divs(cnt): res = set() firstdiv = -1 lastdiv = cnt for i in range(2, int(cnt ** 0.5 + 1)): if i > lastdiv: b...
output
1
15,217
12
30,435
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,218
12
30,436
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from math import sqrt t=int(input()) for tests in range(t): n=int(input()) P=list(map(int,input().split())) C=list(map(int,input().split())) f...
output
1
15,218
12
30,437
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,219
12
30,438
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` from sys import stdin input = stdin.readline q = int(input()) for rwerew in range(q): n = int(input()) p = list(map(int,input().split())) c = list(map(int,input().split())) for i in range(n): p[i] -= 1 przyn = [0] * n grupa = ...
output
1
15,219
12
30,439
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,220
12
30,440
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` import sys readline = sys.stdin.readline readlines = sys.stdin.readlines int1 = lambda x: int(x) - 1 ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(m...
output
1
15,220
12
30,441
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... where all elements have same color (c[i] = c[p[i]...
instruction
0
15,221
12
30,442
Tags: brute force, dfs and similar, graphs, math, number theory Correct Solution: ``` import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline import sys print = sys.stdout.write def divisors(a, ans): div = [] t1 = int(a**.5) for i in range(1, min(t1+1,ans)): if a % i == 0: div.append(i) div...
output
1
15,221
12
30,443
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,222
12
30,444
Yes
output
1
15,222
12
30,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,223
12
30,446
Yes
output
1
15,223
12
30,447
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,224
12
30,448
Yes
output
1
15,224
12
30,449
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,225
12
30,450
Yes
output
1
15,225
12
30,451
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,226
12
30,452
No
output
1
15,226
12
30,453
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,227
12
30,454
No
output
1
15,227
12
30,455
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,228
12
30,456
No
output
1
15,228
12
30,457
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a colored permutation p_1, p_2, ..., p_n. The i-th element of the permutation has color c_i. Let's define an infinite path as infinite sequence i, p[i], p[p[i]], p[p[p[i]]] ... wh...
instruction
0
15,229
12
30,458
No
output
1
15,229
12
30,459
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n segments [l_1, r_1], [l_2, r_2], ..., [l_n, r_n]. Each segment has one of two colors: the i-th segment's color is t_i. Let's call a pair of segments i and j bad if the following two conditions are met: * t_i β‰  t_j; * t...
instruction
0
15,246
12
30,492
Tags: data structures, dp, graph matchings, sortings Correct Solution: ``` class LazySegmentTree(): def __init__(self,n,init,merge_func=max,ide_ele=-10**18): self.n=(n-1).bit_length() self.merge_func=merge_func self.ide_ele=ide_ele self.data=[0 for i in range(1<<(self.n+1))] ...
output
1
15,246
12
30,493
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n segments [l_1, r_1], [l_2, r_2], ..., [l_n, r_n]. Each segment has one of two colors: the i-th segment's color is t_i. Let's call a pair of segments i and j bad if the following two conditions are met: * t_i β‰  t_j; * t...
instruction
0
15,247
12
30,494
Tags: data structures, dp, graph matchings, sortings Correct Solution: ``` from operator import add class LazySegmentTree(): def __init__(self,n,init,merge=max,merge_unit=-10**18,operate=add,operate_unit=0): self.merge=merge self.merge_unit=merge_unit self.operate=operate self.opera...
output
1
15,247
12
30,495
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,273
12
30,546
Tags: greedy, implementation Correct Solution: ``` for _ in range(int(input())): n = int(input()) a = [*map(int,input().split())] d = dict() if(len(set(a))==1): print(0) continue elif(len(set(a))==n): print(1) continue t = [] for i in range(n): if(i==0...
output
1
15,273
12
30,547
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,274
12
30,548
Tags: greedy, implementation Correct Solution: ``` for _ in range(int(input())): n=int(input()) arr=list(map(int,input().split())) mp={} if len(set(arr))==1: print(0) else: for i in range(n): if arr[i] in mp: mp[arr[i]]=mp[arr[i]]+[i] else: ...
output
1
15,274
12
30,549
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,275
12
30,550
Tags: greedy, implementation Correct Solution: ``` t = int(input()) def solve(): n = int(input()) arr = list(map(int, input().split())) d = dict() for i in range(n): el = arr[i] if not (el in d.keys()): d[el] = [] d[el].append(i) ans = 2 ** 31 for i in d.keys(...
output
1
15,275
12
30,551
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,276
12
30,552
Tags: greedy, implementation Correct Solution: ``` T = int(input()) for t in range(T): n = int(input()) l = list(map(int, input().split())) new_l = [l[0]] prev = l[0] counts = {l[0]: 1} for i in range(1, n): cur = l[i] if cur != prev: new_l.append(cur) r =...
output
1
15,276
12
30,553
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,277
12
30,554
Tags: greedy, implementation Correct Solution: ``` from collections import Counter def unique(lis): prev = -1 res = [] for i in lis: if i != prev: res.append(i) prev = i return res for _ in range(int(input())): n = int(input()) lis = list(map(int, input().split())...
output
1
15,277
12
30,555
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,278
12
30,556
Tags: greedy, implementation Correct Solution: ``` import sys import math import collections t=int(input()) for w in range(t): n=int(input()) l=[int(i) for i in input().split()] d={} for i in range(n): if(l[i] in d): d[l[i]]+=[i] else: d[l[i]]=[-1,i] for i in ...
output
1
15,278
12
30,557
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,279
12
30,558
Tags: greedy, implementation Correct Solution: ``` #import sys, math #input = sys.stdin.readline import os import sys from io import BytesIO, IOBase import heapq as h import bisect from types import GeneratorType BUFSIZE = 8192 class SortedList: def __init__(self, iterable=[], _load=200): "...
output
1
15,279
12
30,559
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer ...
instruction
0
15,280
12
30,560
Tags: greedy, implementation Correct Solution: ``` from collections import Counter def main(xs): xs2 = [xs[0]] # remove consequtive for i in range(1, len(xs)): if xs2[-1] != xs[i]: xs2.append(xs[i]) counter = Counter(xs2) for k, v in counter.items(): counter[k] += 1 ...
output
1
15,280
12
30,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,281
12
30,562
Yes
output
1
15,281
12
30,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,282
12
30,564
Yes
output
1
15,282
12
30,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,283
12
30,566
Yes
output
1
15,283
12
30,567
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,284
12
30,568
Yes
output
1
15,284
12
30,569
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,285
12
30,570
No
output
1
15,285
12
30,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,286
12
30,572
No
output
1
15,286
12
30,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,287
12
30,574
No
output
1
15,287
12
30,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same eleme...
instruction
0
15,288
12
30,576
No
output
1
15,288
12
30,577
Provide tags and a correct Python 3 solution for this coding contest problem. The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two conditions are satisfied: * ti < ti + 1 for each odd i < n; * ti > ti + 1 for each even i < n. For example, sequence...
instruction
0
15,509
12
31,018
Tags: brute force, implementation Correct Solution: ``` #!/usr/bin/python3 def needs_rep(t, i): if i % 2 == 0: return t[i] >= t[i+1] else: return t[i] <= t[i+1] def would_need_rep(t, i, j1, j2): n = len(t) if i < 0: return False if i >= n-1: return False tj1 = t[j2] tj2 = t[j1] ti = t[i] if i == j...
output
1
15,509
12
31,019
Provide tags and a correct Python 3 solution for this coding contest problem. The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two conditions are satisfied: * ti < ti + 1 for each odd i < n; * ti > ti + 1 for each even i < n. For example, sequence...
instruction
0
15,510
12
31,020
Tags: brute force, implementation Correct Solution: ``` n = int(input()) t = list(map(int, input().split())) t = [-1] + t badIdx = [] nice = [] def getBadIdx(): for i in range(1,n): if ((i%2 == 0) and (t[i] <= t[i+1])) or ((i%2 == 1) and (t[i] >= t[i+1])): badIdx.append((i,i+1)) def checkBad(k...
output
1
15,510
12
31,021
Provide tags and a correct Python 3 solution for this coding contest problem. The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two conditions are satisfied: * ti < ti + 1 for each odd i < n; * ti > ti + 1 for each even i < n. For example, sequence...
instruction
0
15,511
12
31,022
Tags: brute force, implementation Correct Solution: ``` def main(): n, l = int(input()), list(map(int, input().split())) if not (n & 1): l.append(0) l.append(150001) a, i, j, fails = l[0], 0, 1, set() try: while True: b = l[j] if a >= b: fails....
output
1
15,511
12
31,023