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. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,789
12
3,578
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` """ 3 41 -41 41 """ def solve(n, a): d = {0: -1} s = 0 # ε‰ηΌ€ε’Œ res = 0 j = -1 for i in range(n): s += a[i] if (d.get(s) != None): j = max(d[s] + 1, j) d[s] = i res += ...
output
1
1,789
12
3,579
Provide tags and a correct Python 3 solution for this coding contest problem. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,790
12
3,580
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` def sumoflength(arr, n): # For maintaining distinct elements. s = set() # Initialize ending point and result j = 0 ans = 0 # Fix starting point for i in range(n): # Find ending point for cu...
output
1
1,790
12
3,581
Provide tags and a correct Python 3 solution for this coding contest problem. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,791
12
3,582
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` n=int(input()) a=[int(x) for x in input().split()] for i in range(1,n): a[i]+=a[i-1] dic={} dic[0]=0 ans=0 maximum=-1 for i in range(n): val=dic.get(a[i],-1) maximum=max(maximum,val) ans+=i-maximum dic[a[i]]=i+1...
output
1
1,791
12
3,583
Provide tags and a correct Python 3 solution for this coding contest problem. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,792
12
3,584
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` n = int(input()) last = 0 o = {0: -1} t = 0 rs = 0 a = [int(x) for x in input().split()] for i, ai in enumerate(a): rs += ai if rs in o: last = max(last, o[rs] + 2) o[rs] = i t += i - last + 1 print(t) ...
output
1
1,792
12
3,585
Provide tags and a correct Python 3 solution for this coding contest problem. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,793
12
3,586
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` n=int(input()) d={} ar=list(map(int,input().split())) pref=[0]*(n) ans=0 d={} uk=-1 pref[0]=ar[0] d[0]=-1 for i in range(1,n): pref[i]=pref[i-1]+ar[i] for i in range(n): if pref[i] in d: uk=max(uk,d.get(pref[i])+1) ans+=(i-uk)...
output
1
1,793
12
3,587
Provide tags and a correct Python 3 solution for this coding contest problem. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,794
12
3,588
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` def I(): return(list(map(int,input().split()))) def sieve(n): a=[1]*n for i in range(2,n): if a[i]: for j in range(i*i,n,i): a[j]=0 return a n=int(input()) arr=I() l=-1 d={0:-1} prefix=[0]*(n+1) pref...
output
1
1,794
12
3,589
Provide tags and a correct Python 3 solution for this coding contest problem. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning an...
instruction
0
1,795
12
3,590
Tags: binary search, data structures, implementation, two pointers Correct Solution: ``` from itertools import accumulate n = int(input()) a = [int(x) for x in input().split()] sums = [0] + list(accumulate(a)) s = {0} i, j = 0, 0 ans = 0 while i < n: while j < n and sums[j+1] not in s: s.add(sums[j+1]) ...
output
1
1,795
12
3,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,796
12
3,592
Yes
output
1
1,796
12
3,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,797
12
3,594
Yes
output
1
1,797
12
3,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,798
12
3,596
Yes
output
1
1,798
12
3,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,799
12
3,598
Yes
output
1
1,799
12
3,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,800
12
3,600
No
output
1
1,800
12
3,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,801
12
3,602
No
output
1
1,801
12
3,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,802
12
3,604
No
output
1
1,802
12
3,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array c is a subarray of an array b if c can be obtained from b by deletion of several (possib...
instruction
0
1,803
12
3,606
No
output
1
1,803
12
3,607
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,853
12
3,706
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` def main(): n, k = map(int, input().split()) p = [int(x)-1 for x in input().split()] isHead = [True]*n follower = [None]*n for i in range(k): x, y = map(int, input().split()) ...
output
1
1,853
12
3,707
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,854
12
3,708
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` mod = 1000000007 eps = 10**-9 def main(): import sys from collections import deque input = sys.stdin.buffer.readline N, K = map(int, input().split()) P = list(map(int, input().split(...
output
1
1,854
12
3,709
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,855
12
3,710
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` from collections import defaultdict def topological_sort(digraph): n = len(digraph) indegree = defaultdict(int) for k in digraph: for nxt_v in digraph[k]: indegree[nxt_v] +...
output
1
1,855
12
3,711
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,856
12
3,712
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` class Node: def __init__(self, value): self.value = value self.next = None self.prev = None def __repr__(self): if not self: return "{}()".format(self._...
output
1
1,856
12
3,713
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,857
12
3,714
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` from sys import stdin, gettrace if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() ...
output
1
1,857
12
3,715
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,858
12
3,716
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` import sys from collections import deque input = sys.stdin.readline N,K = map(int,input().split()) p = list(map(int,input().split())) p = [p[i]-1 for i in range(N)] next = [-1 for i in range(N)] deg = [0...
output
1
1,858
12
3,717
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,859
12
3,718
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` import sys from array import array # noqa: F401 import typing as Tp # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') def output(*args): sys.stdout.buffer.write( ...
output
1
1,859
12
3,719
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan is a programming teacher. During the academic year, he plans to give n lectures on n different topics. Each topic should be used in exactly one lecture. Ivan wants to choose which topic will he explain during the 1-st, 2-nd, ..., n-th l...
instruction
0
1,860
12
3,720
Tags: constructive algorithms, dfs and similar, dsu, graphs, implementation, sortings, trees Correct Solution: ``` from collections import defaultdict def topological_sort(digraph): n = len(digraph) indegree = defaultdict(int) for k in digraph: for nxt_v in digraph[k]: indegree[nxt_v] +...
output
1
1,860
12
3,721
Provide tags and a correct Python 3 solution for this coding contest problem. Valera has array a, consisting of n integers a0, a1, ..., an - 1, and function f(x), taking an integer from 0 to 2n - 1 as its single argument. Value f(x) is calculated by formula <image>, where value bit(i) equals one if the binary represen...
instruction
0
1,940
12
3,880
Tags: implementation, math, number theory Correct Solution: ``` from sys import stdin from itertools import accumulate def arr_enu(): return [[i, int(x)] for i, x in enumerate(stdin.readline().split())] def get_col(arr, i): return [row[i] for row in arr] def arr_sum(arr): arr.insert(0, 0) return l...
output
1
1,940
12
3,881
Provide tags and a correct Python 3 solution for this coding contest problem. Valera has array a, consisting of n integers a0, a1, ..., an - 1, and function f(x), taking an integer from 0 to 2n - 1 as its single argument. Value f(x) is calculated by formula <image>, where value bit(i) equals one if the binary represen...
instruction
0
1,941
12
3,882
Tags: implementation, math, number theory Correct Solution: ``` import sys from math import gcd,sqrt,ceil,log2 from collections import defaultdict,Counter,deque from bisect import bisect_left,bisect_right import math import heapq from itertools import permutations # input=sys.stdin.readline # def print(x): # sys.s...
output
1
1,941
12
3,883
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,073
12
4,146
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) s = {} #dic d = {} #dic p = set() #set mx = - 10**15 mi = -mx ans = 2 for i in range(n) : if a[i] in s : s[a[i]] += 1 else : s[a[i]] = 1 mx = max(mx,a[i]) mi = min(mi,a[i]) if 0 in...
output
1
2,073
12
4,147
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,074
12
4,148
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` n = int(input()) a = [int(x) for x in input().split()] D = {} for x in a: if x in D: D[x] += 1 else: D[x] = 1 maxans = 0 def check(x, y): num = 2 D[x] -= 1 D[y] -= 1 while x+y in D and D[x+y] > 0: ...
output
1
2,074
12
4,149
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,075
12
4,150
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` def rec(a, b): res, c = 0, a + b if d.get(c) and d[c] > 0: d[c] -= 1 res = rec(b, c) + 1 d[c] += 1 return res input() d = {} for i in map(int, input().split()): if d.get(i): d[i] += 1 else: ...
output
1
2,075
12
4,151
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,076
12
4,152
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` def go(a, b): res, c = 0, a + b if d.get(c) and d[c] > 0: d[c] -= 1 res = go(b, c) + 1 d[c] += 1 return res input() d = {} for i in map(int, input().split()): if d.get(i): d[i] += 1 else: d[i] = 1 ans...
output
1
2,076
12
4,153
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,077
12
4,154
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` from collections import Counter input() s = Counter(map(int, input().split())) n = 0 for q in s: s[q] -= 1 for a in s: if not s[a]: continue t = [a] s[a] -= 1 b = q + a while s.get(b, 0): ...
output
1
2,077
12
4,155
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,078
12
4,156
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) ans = a.count(0) d = {} for i in a: if i not in d: d[i] = 1 else: d[i] += 1 ans = max(ans, 2) for i in range(n): for j in range(n): if(i != j and (a[i] != 0 or a[j] != 0)): fi...
output
1
2,078
12
4,157
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,079
12
4,158
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` from copy import * length=int(input()) arr=list(map(int,input().split())) d=dict() for i in arr: d[i]=d.get(i,0)+1 ans=0 for i in range(len(arr)): for j in range(len(arr)): if i!=j: if arr[i]==0 and arr[j]==0: ...
output
1
2,079
12
4,159
Provide tags and a correct Python 3 solution for this coding contest problem. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are arbitrary 3. fn + 2 = fn + 1 + fn for all n...
instruction
0
2,080
12
4,160
Tags: brute force, dp, hashing, implementation, math Correct Solution: ``` # ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction import sys import th...
output
1
2,080
12
4,161
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,081
12
4,162
Yes
output
1
2,081
12
4,163
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,082
12
4,164
Yes
output
1
2,082
12
4,165
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,083
12
4,166
Yes
output
1
2,083
12
4,167
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,084
12
4,168
Yes
output
1
2,084
12
4,169
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,085
12
4,170
Yes
output
1
2,085
12
4,171
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,086
12
4,172
No
output
1
2,086
12
4,173
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,087
12
4,174
No
output
1
2,087
12
4,175
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,088
12
4,176
No
output
1
2,088
12
4,177
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,089
12
4,178
No
output
1
2,089
12
4,179
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 1. the sequence consists of at least two elements 2. f0 and f1 are...
instruction
0
2,090
12
4,180
No
output
1
2,090
12
4,181
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,467
12
4,934
Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) ks = [] for k in range(1,n+1): x = [None]*k curr = 0 test_fail=False for i in range(n): xi = a[i] - curr if x[ i%k ] != None and x[i%k] != xi: test_fail=True break ...
output
1
2,467
12
4,935
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,468
12
4,936
Tags: implementation Correct Solution: ``` import sys n = int(input()) a = [0] + [int(i) for i in input().split()] a = [a[i+1] - a[i] for i in range(len(a)-1)] ans = '' cnt = 0 k = 1 while k<=n: good = True for j in range(k): # print(k, j, set(a[j::k])) if len(set(a[j::k]))>1: good = False break if good:...
output
1
2,468
12
4,937
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,469
12
4,938
Tags: implementation Correct Solution: ``` n = int(input()) a = [0] + [int(i) for i in input().split()] x = [] for ind, a_i in enumerate(a[1:]): x.append(a_i - a[ind]) # print(x) ans = [] for i in range(1, n + 1): flag = 0 for ind, j in enumerate(x): if x[ind % i] == j: continue ...
output
1
2,469
12
4,939
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,470
12
4,940
Tags: implementation Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) l1=[l[0]] for i in range(1,n) : l1.append(l[i]-l[i-1]) otv=[] for i in range(1,n+1) : for j in range(n-1,-1,-1) : if j-i<0 : otv.append(i) break if l1[j]!=l1[j-i] : bre...
output
1
2,470
12
4,941
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,471
12
4,942
Tags: implementation Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) a=[l[0]] for i in range(1,n): a.append(l[i]-l[i-1]) lens=[] for i in range(n): flag=False for j in range(i+1,n): if(a[j%(i+1)]!=a[j]): flag=True break if flag==False: lens....
output
1
2,471
12
4,943
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,472
12
4,944
Tags: implementation Correct Solution: ``` n = int(input()) a = [*map(int,input().split())] for i in range(n-1,0,-1): a[i] -= a[i-1]; r = [i for i in range(1,n+1) if a[i:] == a[:-i]] print(len(r)) print(*r) ```
output
1
2,472
12
4,945
Provide tags and a correct Python 3 solution for this coding contest problem. Bajtek, known for his unusual gifts, recently got an integer array x_0, x_1, …, x_{k-1}. Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Ba...
instruction
0
2,473
12
4,946
Tags: implementation Correct Solution: ``` n = int(input()) x = 0 a = [] for y in map(int, input().split()): a += y - x, x = y f = [-1] * (n + 1) for i in range(1, n + 1): f[i] = f[i - 1] + 1 while f[i] > 0 and a[i - 1] != a[f[i] - 1]: f[i] = f[f[i] - 1] + 1 b = [] i = n while i > 0: b += n ...
output
1
2,473
12
4,947