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. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Init...
instruction
0
85,103
14
170,206
Tags: implementation Correct Solution: ``` n, k=map(int, input().split()) l=list(map(int, input().split())) d=dict() ids=[] count=0 for i in l: if(count<k): if i in d: continue else: d[i]=True ids.append(i) count+=1 elif(count==k): if i in ...
output
1
85,103
14
170,207
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Init...
instruction
0
85,104
14
170,208
Tags: implementation Correct Solution: ``` n, k = [int(x) for x in input().split()] ms = [int(x) for x in input().split()] s = [] for m in ms: if m not in s[-k:]: s.append(m) print(min(k, len(s))) print(*reversed(s[-k:])) ```
output
1
85,104
14
170,209
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Init...
instruction
0
85,105
14
170,210
Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) A = list(map(int, input().split())) msgs = [] for a in A: if a not in msgs: if len(msgs) == k: msgs.pop(0) msgs.append(a) print(len(msgs)) print(*msgs[::-1]) ```
output
1
85,105
14
170,211
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Init...
instruction
0
85,106
14
170,212
Tags: implementation Correct Solution: ``` n,k=input().strip().split(" ") n,k=[int(n),int(k)] a=list(map(int,input().strip().split(" "))) cnt=0 d={} ans=[] for i in a: if cnt<k and (i not in d): ans.append(i) cnt+=1 d[i]=1 elif cnt==k and ((i not in d)): del d[ans[0]] ...
output
1
85,106
14
170,213
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Init...
instruction
0
85,107
14
170,214
Tags: implementation Correct Solution: ``` specs = input().split() for i in range(len(specs)): specs[i]=int(specs[i]) k = specs[1] order = input().split() for i in range(len(order)): order[i]=int(order[i]) from collections import deque queue = deque() for i in range(len(order)): flag = 0 for j in range...
output
1
85,107
14
170,215
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most recent conversations with your friends. Init...
instruction
0
85,108
14
170,216
Tags: implementation Correct Solution: ``` n,k = list(map(int, input().split())) ar = list(map(int, input().split())) res = [] count = 0 for x in ar: if count < k: if x in res: continue else: res.insert(0,x) count += 1 else: if x in res: co...
output
1
85,108
14
170,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,109
14
170,218
Yes
output
1
85,109
14
170,219
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,110
14
170,220
Yes
output
1
85,110
14
170,221
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,111
14
170,222
Yes
output
1
85,111
14
170,223
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,112
14
170,224
Yes
output
1
85,112
14
170,225
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,113
14
170,226
No
output
1
85,113
14
170,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,114
14
170,228
No
output
1
85,114
14
170,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,115
14
170,230
No
output
1
85,115
14
170,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k mo...
instruction
0
85,116
14
170,232
No
output
1
85,116
14
170,233
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,239
14
170,478
Tags: sortings Correct Solution: ``` # import math # import collections # from itertools import permutations # from itertools import combinations # import sys # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') '''def is_prime(n): j=2 while j*j<=n: if n%j==0: return...
output
1
85,239
14
170,479
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,240
14
170,480
Tags: sortings Correct Solution: ``` from collections import Counter import string import math import bisect #import random import sys # sys.setrecursionlimit(10**6) from fractions import Fraction def array_int(): return [int(i) for i in sys.stdin.readline().split()] def vary(arrber_of_variables): if arrber_of...
output
1
85,240
14
170,481
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,241
14
170,482
Tags: sortings Correct Solution: ``` t = int(input()) for _ in range(t): n = int(input()) a = [] cache = [] for q in range(10 ** 5): cache.append([0, 0]) ind = 0 for i in input().split(): i = int(i) if ind % 2 == 0: cache[i - 1][0] += 1 else: ...
output
1
85,241
14
170,483
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,242
14
170,484
Tags: sortings Correct Solution: ``` for _ in range(int(input())): n = int(input()) zoz = [int(x) for x in input().split()] l1 = sorted([zoz[i] for i in range(n) if (i%2 == 0)]) l2 = sorted([zoz[i] for i in range(n) if (i%2 == 1)]) new_zoz = [] x = y = 0 while(x<len(l1) or y<len(l2)): ...
output
1
85,242
14
170,485
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,243
14
170,486
Tags: sortings Correct Solution: ``` # ____ _ _ _ _ _ # / ___| __ _ _ __ __ _ | | | | __ _ _ __ ___| |__ (_) |_ # | | _ / _` | '__/ _` |_____| |_| |/ _` | '__/ __| '_ \| | __| # | |_| | (_| | | | (_| |_____| _ | (_| | | \__ \ | | | | |_ # \____|\__,_|_| ...
output
1
85,243
14
170,487
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,244
14
170,488
Tags: sortings Correct Solution: ``` #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase import io from fractions import Fraction import collections from itertools import permutations from collections import defaultdi...
output
1
85,244
14
170,489
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,245
14
170,490
Tags: sortings Correct Solution: ``` import sys from collections import Counter input = sys.stdin.readline for nt in range(int(input())): n = int(input()) a = list(map(int,input().split())) b = sorted(a) d = {} ans = "YES" for i in range(n): if a[i] in d: d[a[i]][i%2] += 1 else: d[a[i]] = [0, 0] d[...
output
1
85,245
14
170,491
Provide tags and a correct Python 3 solution for this coding contest problem. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is...
instruction
0
85,246
14
170,492
Tags: sortings Correct Solution: ``` import io,os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline T = int(input()) t = 1 while t<=T: n = int(input()) arr = list(map(int,input().split())) dic = {} for i in range(n): if arr[i] not in dic: dic[arr[i]] = [] dic[arr[i]].ap...
output
1
85,246
14
170,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,247
14
170,494
Yes
output
1
85,247
14
170,495
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,248
14
170,496
Yes
output
1
85,248
14
170,497
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,249
14
170,498
Yes
output
1
85,249
14
170,499
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,250
14
170,500
Yes
output
1
85,250
14
170,501
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,251
14
170,502
No
output
1
85,251
14
170,503
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,252
14
170,504
No
output
1
85,252
14
170,505
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,253
14
170,506
No
output
1
85,253
14
170,507
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In...
instruction
0
85,254
14
170,508
No
output
1
85,254
14
170,509
Provide tags and a correct Python 3 solution for this coding contest problem. There are n students living in the campus. Every morning all students wake up at the same time and go to wash. There are m rooms with wash basins. The i-th of these rooms contains ai wash basins. Every student independently select one the ro...
instruction
0
85,281
14
170,562
Tags: combinatorics, dp, probabilities Correct Solution: ``` n, m = map(int, input().split()) a = list(map(int, input().split())) prob = [(n+1)*[None] for _ in range(m+1)] for k in range(1, m+1): prob[k][0] = [1.0] for i in range(1, n+1): prob[k][i] = (i+1)*[0.0] for j in range(i): ...
output
1
85,281
14
170,563
Provide tags and a correct Python 3 solution for this coding contest problem. There are n students living in the campus. Every morning all students wake up at the same time and go to wash. There are m rooms with wash basins. The i-th of these rooms contains ai wash basins. Every student independently select one the ro...
instruction
0
85,282
14
170,564
Tags: combinatorics, dp, probabilities Correct Solution: ``` import sys MAX_N = 55 line = list(map(int, sys.stdin.readline().split(" "))) studc = line[0] roomc = line[1] arr = list(map(int, sys.stdin.readline().split(" "))) ncr = [[0 for i in range(MAX_N)] for j in range(MAX_N)] ncr[0][0] = 1 for i in range(1, MAX_...
output
1
85,282
14
170,565
Provide tags and a correct Python 3 solution for this coding contest problem. There are n students living in the campus. Every morning all students wake up at the same time and go to wash. There are m rooms with wash basins. The i-th of these rooms contains ai wash basins. Every student independently select one the ro...
instruction
0
85,283
14
170,566
Tags: combinatorics, dp, probabilities Correct Solution: ``` from sys import stdin input = stdin.buffer.readline def c(n, k): if k > n: return 0 a = b = 1 for i in range(n - k + 1, n + 1): a *= i for i in range(1, k + 1): b *= i return a // b n, m = map(int, input().split()) *a, = map(int, input().split()...
output
1
85,283
14
170,567
Provide tags and a correct Python 3 solution for this coding contest problem. Little Artem is fond of dancing. Most of all dances Artem likes rueda β€” Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n pairs of boys and girls standing in a circle. In...
instruction
0
85,374
14
170,748
Tags: brute force, constructive algorithms, implementation Correct Solution: ``` import io, os, sys input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, q = map(int, input().split()) pos = [i for i in range(n)] cnt, temp, flag = 0, [0, 0], 0 for _ in range(q): p = list(map(int, input().split())) i...
output
1
85,374
14
170,749
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Artem is fond of dancing. Most of all dances Artem likes rueda β€” Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n p...
instruction
0
85,375
14
170,750
No
output
1
85,375
14
170,751
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,425
14
170,850
Tags: constructive algorithms, greedy, math Correct Solution: ``` n=int(input()) print(int(n/2)-1+int(n%2)) ```
output
1
85,425
14
170,851
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,426
14
170,852
Tags: constructive algorithms, greedy, math Correct Solution: ``` # Author Name: Ajay Meena # Codeforce : https://codeforces.com/profile/majay1638 # Codechef : https://www.codechef.com/users/majay1638 # import inbuilt standard input output import sys import math from sys import stdin, stdout def get_ints_in_variable...
output
1
85,426
14
170,853
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,427
14
170,854
Tags: constructive algorithms, greedy, math Correct Solution: ``` print((int(input())-1)//2) #etoi choto code je submit kora jacce na. tai comment add kore 50 character banate hocce :P ```
output
1
85,427
14
170,855
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,428
14
170,856
Tags: constructive algorithms, greedy, math Correct Solution: ``` n=int(input()) print(int((n+1)/2-1)) ```
output
1
85,428
14
170,857
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,429
14
170,858
Tags: constructive algorithms, greedy, math Correct Solution: ``` n=int(input()) if(n%2==0): print(n//2-1) else: print(n//2) ```
output
1
85,429
14
170,859
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,430
14
170,860
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) print((n // 2) - 1 + (n % 2)) ```
output
1
85,430
14
170,861
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,431
14
170,862
Tags: constructive algorithms, greedy, math Correct Solution: ``` from sys import stdout, stdin, setrecursionlimit from io import BytesIO, IOBase from collections import * from itertools import * # from random import * from bisect import * from string import * from queue import * from heapq import * from math import *...
output
1
85,431
14
170,863
Provide tags and a correct Python 3 solution for this coding contest problem. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of ...
instruction
0
85,432
14
170,864
Tags: constructive algorithms, greedy, math Correct Solution: ``` n = input() n = int(n) if n%2 == 0: print(n//2-1) else: print((n-1)//2) ```
output
1
85,432
14
170,865
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Allen, having graduated from the MOO Institute of Techcowlogy (MIT), has started a startup! Allen is the president of his startup. He also hires n-1 other employees, each of which is assigned a ...
instruction
0
85,503
14
171,006
No
output
1
85,503
14
171,007
Provide a correct Python 3 solution for this coding contest problem. Problem Den, the phone number of Ukunikia Co., Ltd., enters a very long phone number into the phone every day. One day, too tired, Den came up with a surprising idea. "Isn't it even a little easier if you rearrange the arrangement of the buttons on ...
instruction
0
85,687
14
171,374
"Correct Solution: ``` def inpl(): return list(map(int, input().split())) from collections import defaultdict from itertools import combinations, permutations N = int(input()) S = list(map(int, input())) move = defaultdict(int) b = S[0] for i in range(N-1): a, b = S[i], S[i+1] move[(a, b)] += 1 move[(b, a...
output
1
85,687
14
171,375
Provide tags and a correct Python 3 solution for this coding contest problem. There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each trip, you have to select a group of people that ...
instruction
0
85,720
14
171,440
Tags: graphs Correct Solution: ``` from collections import deque def solve(adj, m, k, uv): n = len(adj) nn = [len(a) for a in adj] q = deque() for i in range(n): if nn[i] < k: q.append(i) while q: v = q.popleft() for u in adj[v]: nn[u] -= 1 ...
output
1
85,720
14
171,441
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each t...
instruction
0
85,721
14
171,442
No
output
1
85,721
14
171,443
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each t...
instruction
0
85,722
14
171,444
No
output
1
85,722
14
171,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each t...
instruction
0
85,723
14
171,446
No
output
1
85,723
14
171,447
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each t...
instruction
0
85,724
14
171,448
No
output
1
85,724
14
171,449