message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide tags and a correct Python 3 solution for this coding contest problem. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indices are Republicans. New parliament assembly h...
instruction
0
12,938
14
25,876
Tags: *special, constructive algorithms Correct Solution: ``` members, row, column = [int(a) for a in input().split(' ')] if members <= row * column: current_row = [] current_members_in_current_row = 0 flip = 1 for row_number in range(row): while current_members_in_current_row != column: ...
output
1
12,938
14
25,877
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,939
14
25,878
Yes
output
1
12,939
14
25,879
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,940
14
25,880
Yes
output
1
12,940
14
25,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,941
14
25,882
Yes
output
1
12,941
14
25,883
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,942
14
25,884
Yes
output
1
12,942
14
25,885
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,943
14
25,886
No
output
1
12,943
14
25,887
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,944
14
25,888
No
output
1
12,944
14
25,889
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,945
14
25,890
No
output
1
12,945
14
25,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indi...
instruction
0
12,946
14
25,892
No
output
1
12,946
14
25,893
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,092
14
26,184
Tags: constructive algorithms, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) if (n == 1) or (n == 2 and a[0] == a[1]): print(-1) else: print(1) print(a.index(min(a)) + 1) ```
output
1
13,092
14
26,185
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,093
14
26,186
Tags: constructive algorithms, implementation Correct Solution: ``` def read(): return int(input()) def rl(): return list(map(int, input().split())) n = read() a = rl() if n == 1: print("-1") elif n == 2: if a[0] == a[1]: print("-1") else: print(1) print(1) else: if a...
output
1
13,093
14
26,187
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,094
14
26,188
Tags: constructive algorithms, implementation Correct Solution: ``` n=int(input()) arr=[int(s) for s in input().split()] min_=min(arr) max_=max(arr) for i in range(0,n): if arr[i]==min_: a=i if n==1 or (n==2 and min_==max_): print(-1) else: print(1) print(a+1) ```
output
1
13,094
14
26,189
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,095
14
26,190
Tags: constructive algorithms, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) if n == 1: print(-1) else: if a[0] == sum(a[1:]): if n == 2: print(-1) else: print(2) print(1, 2) else: print(1) print...
output
1
13,095
14
26,191
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,096
14
26,192
Tags: constructive algorithms, implementation Correct Solution: ``` #code n,l = int(input()),list(map(int,input().split())) l1 = sorted(l) if len(l1)<2: print(-1) elif len(l1)==2: if l1[-1]==l1[0]: print(-1) else: print(1,1,sep='\n') else: print(1,l.index(l1[0])+1,sep='\n') ```
output
1
13,096
14
26,193
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,097
14
26,194
Tags: constructive algorithms, implementation Correct Solution: ``` sum=0;flag=0 m=[0]*2005 n=int(input()) a=list(map(int,input().split())) for i in range(n): sum+=a[i] m[a[i]]=i+1 a.sort(reverse=True) if n>1: for i in range(n): if a[i]<sum/2: print(1) print(m[a[i]]) ...
output
1
13,097
14
26,195
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,098
14
26,196
Tags: constructive algorithms, implementation Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) if n == 1: k = -1 elif n == 2 and arr[0] == arr[1]: k = -1 else: k = 1 ans = [1] if arr[0] == sum(arr[1:]): ans.append(2) k = 2 print(k) if k != -1: print(*a...
output
1
13,098
14
26,197
Provide tags and a correct Python 3 solution for this coding contest problem. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets w...
instruction
0
13,099
14
26,198
Tags: constructive algorithms, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) s = 0 for x in a: s += x if n == 1: print(-1) exit() for i in range(n): if 2 * a[i] != s: print(1) print(i + 1) break else: print(-1) ```
output
1
13,099
14
26,199
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,100
14
26,200
Yes
output
1
13,100
14
26,201
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,101
14
26,202
Yes
output
1
13,101
14
26,203
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,102
14
26,204
Yes
output
1
13,102
14
26,205
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,103
14
26,206
Yes
output
1
13,103
14
26,207
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,104
14
26,208
No
output
1
13,104
14
26,209
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,105
14
26,210
No
output
1
13,105
14
26,211
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,106
14
26,212
No
output
1
13,106
14
26,213
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a tim...
instruction
0
13,107
14
26,214
No
output
1
13,107
14
26,215
Provide tags and a correct Python 3 solution for this coding contest problem. During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesti...
instruction
0
13,484
14
26,968
Tags: data structures, sortings Correct Solution: ``` years = {} for k in range(int(input())): b, d = map(int, input().split()) if b in years: years[b] += 1 else: years[b] = 1 if d in years: years[d] -= 1 else: years[d] = -1 keys = sorted(years.keys()) maxLivingY...
output
1
13,484
14
26,969
Provide tags and a correct Python 3 solution for this coding contest problem. During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesti...
instruction
0
13,489
14
26,978
Tags: data structures, sortings Correct Solution: ``` import sys from collections import defaultdict def load_sys(): return sys.stdin.readlines() def load_local(): with open('input.txt','r') as f: input=f.readlines() return input def years(arr): events=[[x[0],'b'] for x in arr]+[[x[1],'d'] fo...
output
1
13,489
14
26,979
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,567
14
27,134
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` n,t = map(int,input().split()) seq = input().rstrip().lstrip() main = [i for i in seq] def find_boys(s): d = [] for i in range(len(s)) : if s[i] == "B": d.append(i) return d for i in range(t): li = find_boys(ma...
output
1
13,567
14
27,135
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,568
14
27,136
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` n,p=map(int,input().split()) queue=input() queue=list(queue) i=0 for t in range(p): while i<n-1: if queue[i]=="B" and queue[i+1]=="G": queue[i]="G" queue[i+1]="B" i+=2 ...
output
1
13,568
14
27,137
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,569
14
27,138
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` n,t = map(int,input().split(" ")) q = input() klist = list(i for i in q) for _ in range(t): i = 0 while i < n-1: if klist[i] == "B" and klist [i+1] == "G": klist[i],klist[i+1] = klist[i+1],kl...
output
1
13,569
14
27,139
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,570
14
27,140
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` import sys u = sys.stdin.read().split("\n") t = int(u[0].split()[1]) s = u[1] newS = "" for i in range(t): if newS != "": s = newS newS = "" switched = 0 for j in range(len(s)): if s[j] ...
output
1
13,570
14
27,141
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,571
14
27,142
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` from sys import stdin,stdout from collections import Counter def ai(): return list(map(int, stdin.readline().split())) def ei(): return map(int, stdin.readline().split()) def ip(): return int(stdin.readline().strip()) ...
output
1
13,571
14
27,143
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,572
14
27,144
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` n,k = map(int,input().split()) q = input() for i in range(k): q = q.replace('BG','GB') print(q) ```
output
1
13,572
14
27,145
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,573
14
27,146
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` b, c = map(int, input().split()) # a = [] # x = ['B'] y = [] # g = "" e = input() def swap(s, i, j): lst = list(s) # print("length of lst ", len(lst)) if i > len(lst)-1: return elif i < len(lst)...
output
1
13,573
14
27,147
Provide tags and a correct Python 3 solution for this coding contest problem. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front...
instruction
0
13,574
14
27,148
Tags: constructive algorithms, graph matchings, implementation, shortest paths Correct Solution: ``` seconds = [int(i) for i in input().split()][1] queue = [i for i in input()] for i in range(seconds): pointer = 0 while pointer < len(queue): try: if queue[pointer] == 'B' and queue[pointer + 1] == 'G': queue[...
output
1
13,574
14
27,149
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,575
14
27,150
Yes
output
1
13,575
14
27,151
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,576
14
27,152
Yes
output
1
13,576
14
27,153
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,577
14
27,154
Yes
output
1
13,577
14
27,155
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,578
14
27,156
Yes
output
1
13,578
14
27,157
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,579
14
27,158
No
output
1
13,579
14
27,159
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,580
14
27,160
No
output
1
13,580
14
27,161
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,581
14
27,162
No
output
1
13,581
14
27,163
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boy...
instruction
0
13,582
14
27,164
No
output
1
13,582
14
27,165
Provide tags and a correct Python 3 solution for this coding contest problem. Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m columns. For example,...
instruction
0
13,705
14
27,410
Tags: brute force, math Correct Solution: ``` p, q = int(input()), 1 t, n = [], 1 while p > n * q: if p % q == 0: t.append((p // q, n)) n += 1 q += n p += (n * n - n) // 2 t += [(m, n) for n, m in t] if p == n * q: t.append((n, n)) print(len(t)) for n, m in sorted(t): print(n, m) ```
output
1
13,705
14
27,411
Provide tags and a correct Python 3 solution for this coding contest problem. There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ...
instruction
0
13,722
14
27,444
Tags: greedy Correct Solution: ``` #### IMPORTANT LIBRARY #### ############################ ### DO NOT USE import random --> 250ms to load the library ############################ ### In case of extra libraries: https://github.com/cheran-senthil/PyRival ###################### ####### IMPORT ####### ##############...
output
1
13,722
14
27,445
Provide tags and a correct Python 3 solution for this coding contest problem. There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ...
instruction
0
13,723
14
27,446
Tags: greedy Correct Solution: ``` length = int(input()) gems = input().split() result = [] s = 0 dist = set() pend_e = 0 pend_s = 0 for i in range(0, length): cur = gems[i] if cur not in dist: dist.add(cur) else: if pend_e != 0: result.append([pend_s, pend_e]) pend_e = ...
output
1
13,723
14
27,447
Provide tags and a correct Python 3 solution for this coding contest problem. There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ...
instruction
0
13,724
14
27,448
Tags: greedy Correct Solution: ``` n = int(input()) li = list(map(int,input().split())) s=set() ans=[] l=0 r=-1 for i in range(n): if li[i] in s: ans.append([l+1,i+1]) s = set() l = i+1 r=1 else: s.add(li[i]) if r==-1: print(-1) else: print(len(ans)) ans[len(ans)-1][1]=n for i in ans: print(*i) ```
output
1
13,724
14
27,449
Provide tags and a correct Python 3 solution for this coding contest problem. There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ...
instruction
0
13,725
14
27,450
Tags: greedy Correct Solution: ``` n = int(input()) lis=[*map(int,input().split())] ans=[] k=0;s = set() for i in range(n): if lis[i] in s: ans.append([k+1,i+1]) k=i+1 s = set() else: s.add(lis[i]) c=len(ans) if c==0: print('-1') else: print(c) ans[-1][1]=n ...
output
1
13,725
14
27,451
Provide tags and a correct Python 3 solution for this coding contest problem. There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ...
instruction
0
13,726
14
27,452
Tags: greedy Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) z = []; p = set() k1 = 1 for i in range(n): if a[i] in p: z.append((k1, i+1)) k1 = i+2 p = set() else: p.add(a[i]) if len(z) > 0: z[len(z)-1] = (z[len(z)-1][0], n) print(len(z)) fo...
output
1
13,726
14
27,453
Provide tags and a correct Python 3 solution for this coding contest problem. There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type ai. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two ...
instruction
0
13,727
14
27,454
Tags: greedy Correct Solution: ``` def main(): n, res = int(input()), [] s, i, fmt = set(), 1, "{:n} {:n}".format for j, a in enumerate(input().split(), 1): if a in s: s = set() res.append(fmt(i, j)) i = j + 1 else: s.add(a) if res: ...
output
1
13,727
14
27,455