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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i...
instruction
0
97,900
12
195,800
Yes
output
1
97,900
12
195,801
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i...
instruction
0
97,901
12
195,802
Yes
output
1
97,901
12
195,803
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i...
instruction
0
97,902
12
195,804
No
output
1
97,902
12
195,805
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i...
instruction
0
97,903
12
195,806
No
output
1
97,903
12
195,807
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i...
instruction
0
97,904
12
195,808
No
output
1
97,904
12
195,809
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call an array of non-negative integers a_1, a_2, …, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 ≤ i, j ≤ n the inequality k ⋅ |i - j| ≤ min(a_i...
instruction
0
97,905
12
195,810
No
output
1
97,905
12
195,811
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. Th...
instruction
0
97,938
12
195,876
Tags: binary search, math Correct Solution: ``` import sys input = sys.stdin.readline def binary_search(c1, c2): m = (c1 + c2 + 1) // 2 if abs(c1 - c2) <= 1: return m else: if ok(m): c1 = m else: c2 = m return binary_search(c1, c2) def f(m): c = ...
output
1
97,938
12
195,877
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. Th...
instruction
0
97,940
12
195,880
Tags: binary search, math Correct Solution: ``` q = int(input()) def f(n): take = 0 ret = 0 while True: if n - take <= 0: break ret += (n - take) * (n - take + 1) // 2 take = take * 10 + 9 return ret def g(n): take = 0 ret = 0 while True: if n - take <= 0: break ret += n - take ...
output
1
97,940
12
195,881
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. Th...
instruction
0
97,941
12
195,882
Tags: binary search, math Correct Solution: ``` # ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.wri...
output
1
97,941
12
195,883
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. Th...
instruction
0
97,942
12
195,884
Tags: binary search, math Correct Solution: ``` dp, cnt = [0], 1 dp2 = [0] while dp[-1] <= int(1e18): ans = dp2[-1] + (10 ** cnt - 10 ** (cnt - 1)) * cnt dp2.append(ans) ans = dp[-1] + dp2[-2] * (10 ** cnt - 10 ** (cnt - 1)) + cnt * int((10 ** cnt - 10 ** (cnt - 1) + 1) * (10 ** cnt - 10 ** (cnt - 1)) / 2) ...
output
1
97,942
12
195,885
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. Th...
instruction
0
97,943
12
195,886
Tags: binary search, math Correct Solution: ``` import sys input = sys.stdin.readline # 1keta : 1,2,3,4,5,6,7,8,9 : 45 # 2keta : 11,13,15,... # 9 : 9 , sum = 45 # 99 : 9+(2*90) = 189, sum =((9+2)+(9+2*90))*90//2 +45 = 9045 LIST=[9] for i in range(1,20): LIST.append(LIST[-1]+9*(10**i)*(i+1)) SUM=[45] for i in ra...
output
1
97,943
12
195,887
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. Th...
instruction
0
97,944
12
195,888
Tags: binary search, math Correct Solution: ``` l = [0] t = int(input()) def count(level): nums = 10**level - 10**(level - 1) first = l[level - 1] + level last = l[level - 1] + nums*level if len(l) <= level: l.append(last) return (nums*(first+last))//2 def search(min_size,val,level): c...
output
1
97,944
12
195,889
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive ...
instruction
0
97,947
12
195,894
Yes
output
1
97,947
12
195,895
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,018
12
196,036
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` u,v=map(int,input().split()) if v<u or ((v%2)!=(u%2)): print(-1) elif v==u : if u!=0: print(1) print(u) else: print(0) else: x=(v-u)//2 if not u&x: print(2) print(u+x,x) e...
output
1
98,018
12
196,037
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,019
12
196,038
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` import math from bisect import bisect_left, bisect_right from sys import stdin, stdout, setrecursionlimit from collections import Counter input = lambda: stdin.readline().strip() print = stdout.write u, v = map(int, input().split()) x...
output
1
98,019
12
196,039
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,020
12
196,040
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` u, v = list(map(int, input().split())) rem = v-u out = [u] if rem < 0: print(-1) elif v == u == 0: print(0) elif rem == 0: print(1) print(u) elif rem%2 == 0: add = rem//2 if add+u == add^u: print(2) ...
output
1
98,020
12
196,041
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,021
12
196,042
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` xor,sm=map(int,input().split()) if(xor>sm): print("-1") elif(xor%2 != sm%2): print("-1") elif(xor==0 and sm==0): print("0") elif(xor==0): print("2") v=sm//2 print(v,v) elif(xor==1 and sm==1): print("1") ...
output
1
98,021
12
196,043
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,022
12
196,044
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` """ NTC here """ import sys inp = sys.stdin.readline def input(): return inp().strip() # flush= sys.stdout.flush # import threading # sys.setrecursionlimit(10**6) # threading.stack_size(2**26) def iin(): return int(input()) def li...
output
1
98,022
12
196,045
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,023
12
196,046
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` u, v = map(int, input().split()) if u%2 != v%2 or u > v: print(-1) exit() if u == 0 and v == 0: print(0) exit() if u == v: print(1) print(u) exit() x = (v-u)//2 if u&x == 0: print(2) print(*[u+x, ...
output
1
98,023
12
196,047
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,024
12
196,048
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` import statistics import math import datetime import collections def identity(*args): if len(args) == 1: return args[0] return args def parsin(*, l=1, vpl=1, cf=identity, s=" "): if l == 1: if vpl == 1: ...
output
1
98,024
12
196,049
Provide tags and a correct Python 3 solution for this coding contest problem. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0 ≤ u,v...
instruction
0
98,025
12
196,050
Tags: bitmasks, constructive algorithms, greedy, number theory Correct Solution: ``` from sys import stdin # input=stdin.buffer.readline input=lambda : stdin.readline().strip() lin=lambda :list(map(int,input().split())) iin=lambda :int(input()) main=lambda :map(int,input().split()) from math import ceil,sqrt,factorial,...
output
1
98,025
12
196,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The...
instruction
0
98,026
12
196,052
Yes
output
1
98,026
12
196,053
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given 2 integers u and v, find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is u, and the sum of its elements is v. Input The...
instruction
0
98,029
12
196,058
Yes
output
1
98,029
12
196,059
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,115
12
196,230
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` import sys #input = sys.stdin.readline for _ in range(int(input())): n=int(input()) a=[] for i in range(n): temp=input() a.append([]) for k in temp: a[-1].append(int(k)) input() b=[] for i...
output
1
98,115
12
196,231
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,116
12
196,232
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` def check(r, i, j): return r[i][j]^r[i+1][j+1] == r[i+1][j]^r[i][j+1] for _ in range(int(input())): n = int(input()) a = [list(map(int, list(input()))) for i in range(n)] input() b = [list(map(int, list(input()))) for i in ...
output
1
98,116
12
196,233
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,117
12
196,234
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` t=int(input()) for i in range(t): n=int(input()) a=[] for j in range(n): s=input() c=[] for k in s: c.append(int(k)) a.append(c) p=input() b = [] for j in range(n): s = i...
output
1
98,117
12
196,235
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,118
12
196,236
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` import sys from bisect import bisect_left input = sys.stdin.readline def solve(): n = int(input()) a = [None]*n for i in range(n): a[i] = list(map(int,input().strip())) input() for i in range(n): j = 0 for c in map(int,input().strip())...
output
1
98,118
12
196,237
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,119
12
196,238
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` import sys input = sys.stdin.readline from collections import * from bisect import * for _ in range(int(input())): n = int(input()) a = [list(map(int, input()[:-1])) for _ in range(n)] input() b = [list(map(int, input()[:-1])) for ...
output
1
98,119
12
196,239
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,120
12
196,240
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` import sys input = lambda: sys.stdin.readline().rstrip() T = int(input()) for _ in range(T): N = int(input()) A = [[int(a) for a in input()] for _ in range(N)] input() for i in range(N): for j, a in enumerate([int(a) for a ...
output
1
98,120
12
196,241
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,121
12
196,242
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` # ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = By...
output
1
98,121
12
196,243
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more): * vertical x...
instruction
0
98,122
12
196,244
Tags: 2-sat, brute force, constructive algorithms Correct Solution: ``` import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) mat_a = [] mat_b = [] for i in range(n): row = list(input()) mat_a.append(row) extra = input() for i in range(n): ...
output
1
98,122
12
196,245
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,123
12
196,246
Yes
output
1
98,123
12
196,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,124
12
196,248
Yes
output
1
98,124
12
196,249
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,125
12
196,250
Yes
output
1
98,125
12
196,251
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,126
12
196,252
Yes
output
1
98,126
12
196,253
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,127
12
196,254
No
output
1
98,127
12
196,255
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,128
12
196,256
No
output
1
98,128
12
196,257
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,129
12
196,258
No
output
1
98,129
12
196,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrar...
instruction
0
98,130
12
196,260
No
output
1
98,130
12
196,261
Provide tags and a correct Python 3 solution for this coding contest problem. Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can...
instruction
0
98,162
12
196,324
Tags: combinatorics, math, sortings Correct Solution: ``` n = input() c_n = {} d_n = {} for a_i, b_i in zip(input().split(), input().split()): if a_i == b_i: d_n[a_i] = d_n.get(a_i,0) + 2 c_n[a_i] = c_n.get(a_i,0) + 1 c_n[b_i] = c_n.get(b_i,0) + 1 result = 1 k = int(input()) for a_i, ca...
output
1
98,162
12
196,325
Provide tags and a correct Python 3 solution for this coding contest problem. Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can...
instruction
0
98,163
12
196,326
Tags: combinatorics, math, sortings Correct Solution: ``` n = int(input()) c, d = {}, {} for x, y in zip(input().split(), input().split()): c[x] = c.get(x, 1) + 1 c[y] = c.get(y, 1) + 1 if x == y: d[x] = d.get(x, 0) + 2 s, m = 1, int(input()) for k, v in c.items(): u = d.get(k, 0) for i in range(v -...
output
1
98,163
12
196,327
Provide tags and a correct Python 3 solution for this coding contest problem. Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can...
instruction
0
98,164
12
196,328
Tags: combinatorics, math, sortings Correct Solution: ``` from collections import defaultdict def factorial(n, m, rep): r = 1 for i in range(2, n + 1): j = i while j % 2 == 0 and rep > 0: j = j// 2 rep -= 1 r *= j r %= m return r n=int(input(...
output
1
98,164
12
196,329
Provide tags and a correct Python 3 solution for this coding contest problem. Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can...
instruction
0
98,165
12
196,330
Tags: combinatorics, math, sortings Correct Solution: ``` n=int(input()) y=list(map(int,input().split())) z=list(map(int,input().split())) a=sorted([[y[i],i] for i in range(n)]+[[z[i],i] for i in range(n)]) f=0 for i in range(n): if y[i]==z[i]: f+=1 m=int(input()) d=0 e=1 for i in range(1,2*n): if a[i][...
output
1
98,165
12
196,331
Provide tags and a correct Python 3 solution for this coding contest problem. Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n). Now Dima wants to count the number of distinct sequences of points of length 2·n that can...
instruction
0
98,166
12
196,332
Tags: combinatorics, math, sortings Correct Solution: ``` from math import sqrt,ceil,gcd from collections import defaultdict def modInverse(b,m): g = gcd(b, m) if (g != 1): # print("Inverse doesn't exist") return -1 else: # If b and m are relatively prime, # then modulo i...
output
1
98,166
12
196,333
Provide tags and a correct Python 3 solution for this coding contest problem. Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. He...
instruction
0
98,171
12
196,342
Tags: greedy, math Correct Solution: ``` import math n = int(input()) arr = list(map(int, input().split())) req = 0 if n == 1: print("YES") else: for k in set(arr): req = max(req, arr.count(k)) if n - req >= req - 1: print("YES") else: print("NO") ```
output
1
98,171
12
196,343
Provide tags and a correct Python 3 solution for this coding contest problem. Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. He...
instruction
0
98,172
12
196,344
Tags: greedy, math Correct Solution: ``` a = int(input()) l = list(map(int, input().split())) d = dict() s = set() for i in l: if i not in d: d[i] = 1 else: d[i] += 1 s.add(i) flag = False for i in s: sum = 0 for j in d: sum += d[j] sum -= d[i] if d[i] - sum > 1: ...
output
1
98,172
12
196,345
Provide tags and a correct Python 3 solution for this coding contest problem. Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. He...
instruction
0
98,173
12
196,346
Tags: greedy, math Correct Solution: ``` import math import collections n=int(input()) A=[int(x) for x in input().split()] D=collections.Counter(A) m=math.ceil(n/2) for v in D.values(): if v>m: print("NO") exit() print("YES") ```
output
1
98,173
12
196,347
Provide tags and a correct Python 3 solution for this coding contest problem. Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. He...
instruction
0
98,174
12
196,348
Tags: greedy, math Correct Solution: ``` import sys,math from collections import deque,defaultdict import operator as op from functools import reduce from itertools import permutations #sys.setrecursionlimit(10**6) I=sys.stdin.readline #s="abcdefghijklmnopqrstuvwxyz" """ x_move=[-1,0,1,0,-1,1,1,-1] y_move=[0,1,0,...
output
1
98,174
12
196,349
Provide tags and a correct Python 3 solution for this coding contest problem. Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. He...
instruction
0
98,175
12
196,350
Tags: greedy, math Correct Solution: ``` import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) n=iinput() h=((n+1)/2) a=list...
output
1
98,175
12
196,351
Provide tags and a correct Python 3 solution for this coding contest problem. Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. He...
instruction
0
98,176
12
196,352
Tags: greedy, math Correct Solution: ``` import math N = int(input()) numbers = list(map(int, input().split())) set_of_numbers = list(set(numbers)) countr = [None] * len(set_of_numbers) for i in range(len(set_of_numbers)): countr[i] = numbers.count(set_of_numbers[i]) if max(countr) > math.ceil(N/2): print...
output
1
98,176
12
196,353