id stringlengths 6 117 | description stringlengths 29 13k | code stringlengths 9 465k | language class label 4
classes | test_samples dict | source class label 5
classes |
|---|---|---|---|---|---|
1216_D. Swords_1200 | There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swo... | #include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long z) {
long long ret = 1;
while (y > 0) {
if (y & 1) ret = (ret * x) % z;
x = (x * x) % z;
y >>= 1;
}
return ret;
}
const long long N = 2e5 + 5;
long long A[N];
long long __gcd(long long a, long long b) {... | 2C++ | {
"input": [
"2\n2 9\n",
"3\n3 12 6\n",
"7\n2 1000000000 4 6 8 4 2\n",
"6\n13 52 0 13 26 52\n",
"10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 1 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 0\n",
"10\n1000000000 1 2 3 4 5 6 7 8... | 2CODEFORCES |
1216_D. Swords_1201 | There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swo... | n= int(input())
s = list(map(int,input().split()))
s.sort()
maxm = s[n-1]
ans = 0
def computeGCD(x, y):
while(y):
x, y = y, x % y
return x
a = maxm-s[0]
for i in range(1,n-1):
a = computeGCD(a,maxm-s[i])
for i in range(0,n-1):
ans += maxm - s[i]
print(ans//a,a)
| 3Python3 | {
"input": [
"2\n2 9\n",
"3\n3 12 6\n",
"7\n2 1000000000 4 6 8 4 2\n",
"6\n13 52 0 13 26 52\n",
"10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 1 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 0\n",
"10\n1000000000 1 2 3 4 5 6 7 8... | 2CODEFORCES |
1216_D. Swords_1202 | There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swo... |
import java.io.*;
import java.util.*;
public class CodeForce{
static long gcd(long a,long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
// Function to find gcd of array of
// numbers
static long findGCD(long arr[],int n)
{
long res... | 4JAVA | {
"input": [
"2\n2 9\n",
"3\n3 12 6\n",
"7\n2 1000000000 4 6 8 4 2\n",
"6\n13 52 0 13 26 52\n",
"10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n",
"10\n1 1000000000 1 1 1 1 1 1 1 1\n",
"5\n0 0 1 0 0\n",
"10\n1000000000 1 2 3 4 5 6 7 8... | 2CODEFORCES |
1239_E. Turtle_1203 | Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right.
Suppose in each cell of the field there is a lettuce leaf. The energy value of lettuce leaf in row i and column j is equal to a_{i,j}. The turtle is i... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
using namespace std;
long long poww(long long a, long long b, long long md) {
return (!b ? 1
: (b & 1 ? a * poww(a * a % md, b / 2, md) % md
: poww(a * a % md, b / 2, md) % md));
}
const int maxn = 27;
con... | 2C++ | {
"input": [
"3\n1 0 1\n0 0 0\n",
"2\n1 4\n2 3\n",
"3\n0 0 0\n0 0 0\n",
"25\n11632 6805 12792 25513 4573 48789 42308 23247 17502 23125 43597 22173 45527 8637 33001 23532 16047 26169 49458 32012 44865 11178 34515 12381 2780\n21476 20495 26007 43987 19150 12922 29730 13310 19333 34685 25982 10775 25880 ... | 2CODEFORCES |
1257_G. Divisor Set_1204 | You are given an integer x represented as a product of n its prime divisors p_1 ⋅ p_2, ⋅ … ⋅ p_n. Let S be the set of all positive integer divisors of x (including 1 and x itself).
We call a set of integers D good if (and only if) there is no pair a ∈ D, b ∈ D such that a ≠ b and a divides b.
Find a good subset of S ... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1000000007;
long double EPS = 1e-9;
long long binpow(long long b, long long p, long long mod) {
long long ans =... | 2C++ | {
"input": [
"3\n2999999 43 2999957\n",
"6\n2 3 2 3 2 2\n",
"16\n2 2 2 2 2 3 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 3 3 5 7 11 13 17\n",
"1\n2999999\n",
"16\n2 2 2 2 2 2 2 2 2 3 3 5 7 11 ... | 2CODEFORCES |
1257_G. Divisor Set_1205 | You are given an integer x represented as a product of n its prime divisors p_1 ⋅ p_2, ⋅ … ⋅ p_n. Let S be the set of all positive integer divisors of x (including 1 and x itself).
We call a set of integers D good if (and only if) there is no pair a ∈ D, b ∈ D such that a ≠ b and a divides b.
Find a good subset of S ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
... | 4JAVA | {
"input": [
"3\n2999999 43 2999957\n",
"6\n2 3 2 3 2 2\n",
"16\n2 2 2 2 2 3 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 2 2 3 3 5 5 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 5 5 7 7 11 13 17\n",
"16\n2 2 2 2 2 2 3 3 3 3 3 5 7 11 13 17\n",
"1\n2999999\n",
"16\n2 2 2 2 2 2 2 2 2 3 3 5 7 11 ... | 2CODEFORCES |
1281_B. Azamon Web Services_1206 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ... | def solve(s, t):
mns = list(s)
for i in range(len(s)-2,-1,-1): mns[i] = min(mns[i], mns[i + 1])
for i in range(len(s)):
if s[i] != mns[i]:
j = max(j for j, v in enumerate(s[i:], i) if v == mns[i])
s = s[:i] + s[j] + s[i+1:j] + s[i] + s[j+1:]
break
return s if ... | 1Python2 | {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBAB... | 2CODEFORCES |
1281_B. Azamon Web Services_1207 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ... | #include <bits/stdc++.h>
using namespace std;
int caseno = 0;
void yesno(bool okk) { cout << (okk ? "YES" : "NO") << '\n'; }
const int primemod = 1000000007;
const long long maxsize = 1 * 1000000 + 9;
const double eps = 1e-10;
const int N = 210;
void solve() {
string t, s;
cin >> s >> t;
if (s < t) {
cout << ... | 2C++ | {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBAB... | 2CODEFORCES |
1281_B. Azamon Web Services_1208 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ... | for _ in range(int(input())):
a,c=input().split()
a=list(a)
b=sorted(a)
if a!=b:
for i,x in enumerate(b):
if a[i]!=x:
tmp=a[i]
a[i]=x
break
for i in range(len(a)-1,-1,-1):
if a[i]==x:
a[i]=tmp
... | 3Python3 | {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBAB... | 2CODEFORCES |
1281_B. Azamon Web Services_1209 | Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ... | import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main {
FastScanner in;
PrintWriter out;
int MOD = (int)1e9+7;
long ceil(long a, long b){return (a + b - 1) / b;}
long gcd(long a, long b){return b == 0 ? a : gcd(b, a % b);}
long lcm(long a, long b){return a / gcd(a,... | 4JAVA | {
"input": [
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n",
"3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBAB... | 2CODEFORCES |
1301_B. Motarack's Birthday_1210 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high... | import math
import heapq
import sys
num = int(raw_input())
for i in range(num):
n = int(raw_input())
a = [int(x) for x in raw_input().split(" ")]
nums_to_look = set()
for j in range(len(a)):
if a[j] == -1:
if j==0:
if a[j+1]!=-1:
nums_to_look.add(a... | 1Python2 | {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3... | 2CODEFORCES |
1301_B. Motarack's Birthday_1211 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high... | #include <bits/stdc++.h>
using namespace std;
int f(const vector<int>& a, int v, int cur_max) {
return max(cur_max, max(abs(a[0] - v), abs(a.back() - v)));
}
int main() {
srand(chrono::duration_cast<chrono::nanoseconds>(
chrono::high_resolution_clock::now().time_since_epoch())
.count());
i... | 2C++ | {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3... | 2CODEFORCES |
1301_B. Motarack's Birthday_1212 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high... | # import sys
# file = open('test1')
# sys.stdin = file
def ii(): return int(input())
def ai(): return list(map(int, input().split()))
def mi(): return map(int, input().split())
for _ in range(int(input())):
n = ii()
lst = ai()
nlst = []
for ind, ele in enumerate(lst):
if ele==-1:
if ind!=0 and lst[ind-1]!=-1:... | 3Python3 | {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3... | 2CODEFORCES |
1301_B. Motarack's Birthday_1213 | Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.
Dark created that array 1000 years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high... | import java.io.*;
import java.util.*;
public class sm {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
long arr[]=new long[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextLong();
}
... | 4JAVA | {
"input": [
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n",
"7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3... | 2CODEFORCES |
1325_B. CopyCopyCopyCopyCopy_1214 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (pos... | from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = xrange
t= int(read())
while t > 0:
n = int(read())
a = set(map(int,read().split()))
print len(a)
t -= 1 | 1Python2 | {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n... | 2CODEFORCES |
1325_B. CopyCopyCopyCopyCopy_1215 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (pos... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(const T &a) {
return a < 0 ? -a : a;
}
template <typename T>
inline T min(const T &b, const T &a) {
return a < b ? a : b;
}
template <typename T>
inline T max(const T &a, const T &b) {
return a < b ? b : a;
}
int read() {
int x = 0... | 2C++ | {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n... | 2CODEFORCES |
1325_B. CopyCopyCopyCopyCopy_1216 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (pos... | t = int(input())
for i in range(t):
n = int(input())
a = input().split()
s_a = set(a)
print(f"{len(s_a)}\n")
| 3Python3 | {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n... | 2CODEFORCES |
1325_B. CopyCopyCopyCopyCopy_1217 | Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (pos... | import java.util.HashSet;
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for(int i=0; i<t; i++) {
HashSet<Integer> numbers = new HashSet<>();
int n = input.ne... | 4JAVA | {
"input": [
"2\n3\n3 2 1\n6\n3 1 4 1 5 9\n",
"1\n5\n1 3 4 5 2\n",
"1\n3\n1 1 274005660\n",
"4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n",
"2\n3\n1 1 1\n2\n1 1\n",
"2\n2\n1 1\n1\n1\n",
"2\n5\n5 5 5 5 5\n3\n1 2 5\n",
"2\n5\n1 2 3 4 5\n4\n2 3 4 5\n",
"2\n4\n1 3 3 3\n... | 2CODEFORCES |
1344_A. Hilbert's Hotel_1218 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | from __future__ import division, print_function
_interactive = False
def main():
for _ in range(int(input())):
n = int(input())
ar = input_as_list()
exists = array_of(bool, n)
for i, e in enumerate(ar):
exists[(i+e)%n] = True
print("YES" if all(exists) else "NO... | 1Python2 | {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
... | 2CODEFORCES |
1344_A. Hilbert's Hotel_1219 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void input(vector<T>& v, T n) {
for (T i = 0; i < n; i++) {
cin >> v[i];
}
}
int main() {
int t;
long long n;
cin >> t;
int Case = 0;
while (t--) {
cin >> n;
map<long long, long long> mp1;
vector<long long> v(n), v2(n);
... | 2C++ | {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
... | 2CODEFORCES |
1344_A. Hilbert's Hotel_1220 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | # cook your dish here
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
d={}
f=0
for i in range(n):
l[i]=i+a[i%n]
d[l[i]]=d.get(l[i],0)+1
if d[l[i]]==2:
f=1
break
r={}
for i in range(n):
r[l[i... | 3Python3 | {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
... | 2CODEFORCES |
1344_A. Hilbert's Hotel_1221 | Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,... | import java.io.*;
import java.util.*;
public class Template {
static int mod = 1000000007;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int yo = sc.nextInt();
while (yo-- > 0) {
int n = sc.nextInt();
long[] a = new long[n]... | 4JAVA | {
"input": [
"6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n",
"10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n",
... | 2CODEFORCES |
1366_A. Shovels and Swords_1222 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many... | T = int(raw_input())
for _ in xrange(T):
a, b = map(int, raw_input().split())
print min(a, b, (a + b) / 3)
| 1Python2 | {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",... | 2CODEFORCES |
1366_A. Shovels and Swords_1223 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many... | #include <bits/stdc++.h>
using namespace std;
long long choice(long long a, long long b) {
long long opt1 = min(a / 2, b);
a -= 2 * opt1;
b -= opt1;
long long opt2 = min(a, b / 2);
return opt1 + opt2;
}
void solve() {
long long a, b;
cin >> a >> b;
if ((a + b) / 3 <= min(a, b)) {
cout << (a + b) / 3... | 2C++ | {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",... | 2CODEFORCES |
1366_A. Shovels and Swords_1224 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many... | import math
t=int(input())
for i in range(t):
a,b=map(int,input().split())
m=min(a,b,(a+b)/3)
print(math.floor(m))
| 3Python3 | {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",... | 2CODEFORCES |
1366_A. Shovels and Swords_1225 | Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.
Each tool can be sold for exactly one emerald. How many... |
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0)
{
long X = scan.nextInt(), Y= scan.nextInt();
long a = Math.max(X, Y), b = Math.min(X, Y);
if(a==b)System.out.println(Math.max((a-1-... | 4JAVA | {
"input": [
"4\n4 4\n1000000000 0\n7 15\n8 7\n",
"1\n656 656\n",
"1\n666 666\n",
"2\n7 4\n1 5\n",
"1\n33993 5\n",
"1\n1656 5\n",
"1\n1319 1777\n",
"1\n667 666\n",
"1\n656 281\n",
"1\n666 760\n",
"2\n10 4\n1 5\n",
"1\n33993 6\n",
"1\n1656 9\n",
"1\n1425 1777\n",... | 2CODEFORCES |
1386_A. Colors_1226 | Linda likes to change her hair color from time to time, and would be pleased if her boyfriend Archie would notice the difference between the previous and the new color. Archie always comments on Linda's hair color if and only if he notices a difference — so Linda always knows whether Archie has spotted the difference o... | #include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const long double inF = 11451419198101145141919810.1145141919810;
const long double pi = acosl(-1);
long long n;
int ask(long long x) {
printf("? %lld\n", x);
fflush(stdout);
int res;
scanf("%d"... | 2C++ | {
"input": [
"1\n\n7\n\n1\n\n1\n\n0\n\n0\n\n1\n",
"46\n63 1\n63 63\n123 1\n123 123\n63 2\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 5\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 4\n75 68\n108 26\n97 94\n... | 2CODEFORCES |
1408_A. Circle Coloring_1227 | You are given three sequences: a_1, a_2, …, a_n; b_1, b_2, …, b_n; c_1, c_2, …, c_n.
For each i, a_i ≠ b_i, a_i ≠ c_i, b_i ≠ c_i.
Find a sequence p_1, p_2, …, p_n, that satisfy the following conditions:
* p_i ∈ \\{a_i, b_i, c_i\}
* p_i ≠ p_{(i mod n) + 1}.
In other words, for each element, you need to choose ... | for _ in xrange(input()):
n = input()
a = map(int, raw_input().strip().split())
b = map(int, raw_input().strip().split())
c = map(int, raw_input().strip().split())
p = [0] * n
p[0] = a[0]
for i in xrange(1, n - 1):
if a[i] != p[i - 1]: p[i] = a[i]
elif b[i] != p[i - 1]: p[i... | 1Python2 | {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 ... | 2CODEFORCES |
1408_A. Circle Coloring_1228 | You are given three sequences: a_1, a_2, …, a_n; b_1, b_2, …, b_n; c_1, c_2, …, c_n.
For each i, a_i ≠ b_i, a_i ≠ c_i, b_i ≠ c_i.
Find a sequence p_1, p_2, …, p_n, that satisfy the following conditions:
* p_i ∈ \\{a_i, b_i, c_i\}
* p_i ≠ p_{(i mod n) + 1}.
In other words, for each element, you need to choose ... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void solve();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin >> t;
while (t--) {
solve();
cout << "\n";
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
... | 2C++ | {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 ... | 2CODEFORCES |
1408_A. Circle Coloring_1229 | You are given three sequences: a_1, a_2, …, a_n; b_1, b_2, …, b_n; c_1, c_2, …, c_n.
For each i, a_i ≠ b_i, a_i ≠ c_i, b_i ≠ c_i.
Find a sequence p_1, p_2, …, p_n, that satisfy the following conditions:
* p_i ∈ \\{a_i, b_i, c_i\}
* p_i ≠ p_{(i mod n) + 1}.
In other words, for each element, you need to choose ... | import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
for _ in range(int(input())):
n=int(... | 3Python3 | {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 ... | 2CODEFORCES |
1408_A. Circle Coloring_1230 | You are given three sequences: a_1, a_2, …, a_n; b_1, b_2, …, b_n; c_1, c_2, …, c_n.
For each i, a_i ≠ b_i, a_i ≠ c_i, b_i ≠ c_i.
Find a sequence p_1, p_2, …, p_n, that satisfy the following conditions:
* p_i ∈ \\{a_i, b_i, c_i\}
* p_i ≠ p_{(i mod n) + 1}.
In other words, for each element, you need to choose ... | import java.util.*;
public class S{
static int[][][] res = new int[21][21][21];
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int q = in.nextInt();
int a[] = new int[105];
int b[] = new int[105];
int c[] = new int[105];
int r[] = new int[105];
for(int t = 0; t... | 4JAVA | {
"input": [
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n",
"5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 ... | 2CODEFORCES |
1428_D. Bouncing Boomerangs_1231 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will t... | import atexit, io, sys
# A stream implementation using an in-memory bytes
# buffer. It inherits BufferedIOBase.
buffer = io.BytesIO()
sys.stdout = buffer
# print via here
@atexit.register
def write():
sys.__stdout__.write(buffer.getvalue())
for _ in range(1):
n=input()
a=map(int,raw_input().split())
... | 1Python2 | {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
... | 2CODEFORCES |
1428_D. Bouncing Boomerangs_1232 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will t... | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ii = pair<int, int>;
template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
bool done_something = false;
stringstream res;
res << "[";
for (; begin_iter != end_iter and cou... | 2C++ | {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
... | 2CODEFORCES |
1428_D. Bouncing Boomerangs_1233 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will t... | n, *a = map(int, open(0).read().split())
now = 1
heights = [[] for _ in range(n)]
st0 = []
st1 = []
failed = False
for i in range(n - 1, -1, -1):
if a[i] == 1:
heights[i].append(now)
st0.append((now, i))
now += 1
elif a[i] == 2:
if len(st0):
h, j = st0.pop()
... | 3Python3 | {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
... | 2CODEFORCES |
1428_D. Bouncing Boomerangs_1234 | To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right.
For each column, Zookeeper will t... | /*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking inter... | 4JAVA | {
"input": [
"1\n0\n",
"6\n2 0 3 0 1 1\n",
"6\n3 2 2 2 1 1\n",
"6\n0 1 3 2 1 2\n",
"4\n1 2 3 1\n",
"4\n1 1 1 2\n",
"4\n3 3 2 1\n",
"4\n1 2 1 1\n",
"4\n1 1 2 1\n",
"1\n3\n",
"6\n1 3 2 0 3 1\n",
"4\n1 3 2 1\n",
"4\n2 3 1 1\n",
"4\n3 1 1 1\n",
"4\n3 2 3 1\n",
... | 2CODEFORCES |
1451_D. Circle Game_1235 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the... | from __future__ import division
from sys import stdin, stdout
# from fractions import gcd
# from math import *
# from operator import mul
# from functools import reduce
# from copy import copy
from collections import deque, defaultdict, Counter
rstr = lambda: stdin.readline().strip()
rstrs = lambda: [str(x) for x in s... | 1Python2 | {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
... | 2CODEFORCES |
1451_D. Circle Game_1236 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the... | #include<iostream>
#include<cstdio>
#include<cmath>
#define int long long
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
signed main()
{
int t,d,k;
bool f... | 2C++ | {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
... | 2CODEFORCES |
1451_D. Circle Game_1237 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the... | import sys
input = lambda:sys.stdin.readline().strip()
t = int(input())
while t:
t-=1
d,k = map(int,input().split())
x = 0
y = 0
while 1:
if x<=y and (x+k)*(x+k)+y*y<=d*d:
x+=k
elif x>y and (y+k)*(y+k)+x*x<=d*d:
y+=k
else:
break
if ... | 3Python3 | {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
... | 2CODEFORCES |
1451_D. Circle Game_1238 | Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.
Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
public class A {
public static void main(String[] ar... | 4JAVA | {
"input": [
"5\n2 1\n5 2\n10 3\n25 4\n15441 33\n",
"5\n2 1\n5 2\n10 3\n25 4\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 33\n",
"5\n1 1\n9 1\n10 3\n46 4\n25479 33\n",
"5\n2 1\n5 1\n10 3\n25 3\n25479 33\n",
"5\n2 1\n9 1\n10 3\n25 4\n25479 57\n",
"5\n2 1\n9 1\n11 3\n25 4\n25479 57\n",
... | 2CODEFORCES |
1475_D. Cleaning the Phone_1239 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the fol... | #####################################
import atexit, io, sys, collections, math, heapq, fractions
buffer = io.BytesIO()
sys.stdout = buffer
@atexit.register
def write(): sys.__stdout__.write(buffer.getvalue())
#####################################
def g(m,ais, bis):
t = [(u,v) for u,v in zip(ais,bis)]
if... | 1Python2 | {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 ... | 2CODEFORCES |
1475_D. Cleaning the Phone_1240 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the fol... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void solve() {
int n, m;
cin >> n >> m;
vector<int> a, b;
vector<int> v(n);
for (int &e : v) {
cin >> e;
}
for (int &e : v) {
int x;
cin >> x;
if (x == 1) {
a.push_back(e);
} else {
... | 2C++ | {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 ... | 2CODEFORCES |
1475_D. Cleaning the Phone_1241 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the fol... | #lösningsmängd är nedåtbegränsad och ordnad. -> optimal minsta existerar i kontext.
#Vet att det är sant att lösning består av x stna 1-cost x tillhör [0..all(1-cost)]
#för x stna 1-cost bestäms y stna 2-cost entydligt.
#itererar alla x, försök i varje steg reducera y från mx(2-cost)
#same hold tru if conv points 1 an... | 3Python3 | {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 ... | 2CODEFORCES |
1475_D. Cleaning the Phone_1242 | Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.
Polycarp wants to free at least m units of memory (by removing some applications).
Of course, some applications are more important to Polycarp than others. He came up with the fol... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class D {
private static FastReader fr = new FastReader();
private static PrintWriter out=new PrintWriter(System.out);
private static Random random = new Rando... | 4JAVA | {
"input": [
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n",
"1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n",
"5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 ... | 2CODEFORCES |
1500_B. Two chandeliers_1243 | Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r... | #define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#inc... | 2C++ | {
"input": [
"3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n",
"1 2 31\n1\n1 2\n",
"4 2 4\n4 2 3 1\n2 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 ... | 2CODEFORCES |
1500_B. Two chandeliers_1244 | Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r... | def main():
n, m, k = list(map(lambda x: int(x), str(input()).split(' ')))
a = list(map(lambda x: int(x), str(input()).split(' ')))
b = list(map(lambda x: int(x), str(input()).split(' ')))
if n < m:
print(solve(m, n, k, b, a))
return
print(solve(n, m, k, a, b))
def solve(n, m, k, a,... | 3Python3 | {
"input": [
"3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n",
"1 2 31\n1\n1 2\n",
"4 2 4\n4 2 3 1\n2 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 ... | 2CODEFORCES |
1500_B. Two chandeliers_1245 | Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
public class TwoChandeliers {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedRea... | 4JAVA | {
"input": [
"3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n",
"1 2 31\n1\n1 2\n",
"4 2 4\n4 2 3 1\n2 1\n",
"20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 ... | 2CODEFORCES |
1525_D. Armchairs_1246 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th ... | from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat, permutations
import math
def inp(force_list=False):
re = map(int, raw_input().split())
if len(re) == 1 and not force_list:
return re[0]
return re
def inst():
return ra... | 1Python2 | {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
"2\n1 0\n",
... | 2CODEFORCES |
1525_D. Armchairs_1247 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th ... |
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
#define fr(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define ... | 2C++ | {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
"2\n1 0\n",
... | 2CODEFORCES |
1525_D. Armchairs_1248 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th ... | import sys
input = sys.stdin.buffer.readline
import math
n=int(input())
arr=[int(x) for x in input().split()]
h=[]
v=[]
for i in range(n):
if arr[i]:
v.append(i)
else:
h.append(i)
hh=len(h)
vv=len(v)
dp=[[0 for j in range(hh+1)] for i in range(vv+1)]
for i in range(1,vv+1):
dp[i][0]=mat... | 3Python3 | {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
"2\n1 0\n",
... | 2CODEFORCES |
1525_D. Armchairs_1249 | There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.
For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th ... | import javax.print.DocFlavor;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution {
static int N = 5005;
static int[] arr = new int[N];
static long[][] memo = new long[N][N];
static List<Integer> occupiedSeats = new ArrayList<>();
static List<Integer> emptySeats = new Ar... | 4JAVA | {
"input": [
"6\n1 1 1 0 0 0\n",
"5\n0 0 0 0 0\n",
"7\n1 0 0 1 0 0 1\n",
"100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n",
"2\n1 0\n",
... | 2CODEFORCES |
157_A. Game Outcome_1250 | Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | z=map(lambda x:map(int,raw_input().split()), ' '*input())
h=[sum(s) for s in z]
v=[sum(s) for s in zip(*z)]
print sum([i>j for i in v for j in h]) | 1Python2 | {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14... | 2CODEFORCES |
157_A. Game Outcome_1251 | Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | #include <bits/stdc++.h>
int main() {
int A[31][31];
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) scanf("%d", &A[i][j]);
int result = 0;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) {
int column = 0;
int c = 0;
for (; c < n; c++) column += A[c][j... | 2C++ | {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14... | 2CODEFORCES |
157_A. Game Outcome_1252 | Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... | n = int(input())
r = lambda : list(map(int, input().split()))
arr = []
for i in range(n):
a = r()
arr.append(a)
row = [sum(i) for i in arr]
col = []
for i in range(n):
c = 0
for j in range(n): c+=arr[j][i]
col.append(c)
ans = 0
for i in range(n):
for j in range(n):
if row[i] < col[j... | 3Python3 | {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14... | 2CODEFORCES |
157_A. Game Outcome_1253 | Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number... |
import java.util.Scanner;
public class cf1 {
static boolean winning(int[][] mat, int i, int j){
int col = 0;
int row = 0;
for(int k = 0; k < mat.length; k++){
row += mat[i][k];
col += mat[k][j];
}
return col > row;
}
... | 4JAVA | {
"input": [
"1\n1\n",
"2\n1 2\n3 4\n",
"4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n",
"9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14... | 2CODEFORCES |
178_A1. Educational Game_1254 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequenc... | import sys
import math
n = int(sys.stdin.readline())
avec = map(int, sys.stdin.readline().split())
stepstowin = [0]*(n-1)
for i in range(n-1):
avec[i + int(2**math.floor(math.log(n - 1 - i, 2)))] += avec[i]
stepstowin[i] = stepstowin[i-1] + avec[i]
for v in stepstowin:
print(v) | 1Python2 | {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"8... | 2CODEFORCES |
178_A1. Educational Game_1255 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
long long ans = 0;
for (int i = 0; i < n - 1; ++i) {
int j = 0;
while (i + (1 << (j + 1)) < n) ++j;
a[i + (1 << j)] += a[i];
ans += a[i];
cout << ans << ... | 2C++ | {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"8... | 2CODEFORCES |
178_A1. Educational Game_1256 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequenc... | n = int(input())
a = [int(t) for t in input().split()]
c = 0
for i in range(n - 1):
if a[i] > 0:
c += a[i]
print(c)
j = 0
while 2 ** j + i < n:
j += 1
a[2 ** (j - 1) + i] += a[i]
a[i] = 0
else:
print(c) | 3Python3 | {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"8... | 2CODEFORCES |
178_A1. Educational Game_1257 | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequenc... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CodeC
{
static class Scanner
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new String... | 4JAVA | {
"input": [
"8\n1 2 3 4 5 6 7 8\n",
"4\n1 0 1 2\n",
"80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n",
"8... | 2CODEFORCES |
19_B. Checkout Assistant_1258 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. ... | n=input()
t=[0]
a=[0]
for i in range(n):
v1,v2=map(int,raw_input().split(" "))
v1+=1
t.append(v1)
a.append(v2)
ans=[10**15 for j in range(n+1)]
#print ans
ans[0]=0
for i in range(1,n+1):
for j in range(n,0,-1):
ans[j]=min(ans[j],ans[max(0,j-t[i])]+a[i])
print ans[n]
| 1Python2 | {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\... | 2CODEFORCES |
19_B. Checkout Assistant_1259 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. ... | #include <bits/stdc++.h>
using namespace std;
const long long INFL = 1152921504606846976ll;
int n;
int t[(1 << 11)], c[(1 << 11)];
long long dp[(1 << 11)];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
dp[i] = INFL;
}
dp[0] = 0ll;
for (int i = 0; i < n; i++) {
scanf("%d%d", &t[i], &c[i]... | 2C++ | {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\... | 2CODEFORCES |
19_B. Checkout Assistant_1260 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. ... | n=int(input())
ar=[float('inf')]*(n+1)
ar[0]=0
for i in range(n):
t,c=map(int,input().split())
for j in range(n-1,-1,-1):
w=min(j+t+1,n)
ar[w]=min(ar[w],ar[j]+c)
print(ar[n])
| 3Python3 | {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\... | 2CODEFORCES |
19_B. Checkout Assistant_1261 | Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. ... | import java.io.*;
import java.util.*;
public class Answer19B{
public static void main(String[] args){
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
new Kai(reader).solve();
}
}
class Kai{
BufferedReader reader;
public Kai(BufferedReader reader){
this.reader=reader;
}... | 4JAVA | {
"input": [
"4\n2 10\n0 20\n1 5\n1 3\n",
"3\n0 1\n0 10\n0 100\n",
"5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n",
"5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n",
"5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n",
"2\n2 87623264\... | 2CODEFORCES |
223_C. Partial Sums_1262 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The operation x mod y means that ... | M=10**9+7
I=lambda:map(int,raw_input().split())
n,k=I()
a=I()
l=[1]
for i in range(n):print sum(i*j for i,j in zip(l[::-1],a))%M,;l.append(l[-1]*(i+k)*pow(i+1,M-2,M)%M);
| 1Python2 | {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42... | 2CODEFORCES |
223_C. Partial Sums_1263 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The operation x mod y means that ... | #include <bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;
int const maxn = 2005;
inline void safe_mul(int& a, int b) { a = (a * 1LL * b) % mod; }
inline int mypow(int a, int b) {
int ans = 1;
int tmp = a;
while (b) {
if (b & 1) safe_mul(ans, tmp);
safe_mul(tmp, tmp);
b >>= 1;
}
return... | 2C++ | {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42... | 2CODEFORCES |
223_C. Partial Sums_1264 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The operation x mod y means that ... | n, k = map(int, input().split())
num = list(map(int, input().split()))
MOD = 10 ** 9 + 7
cf = [1]
for i in range(1, 2020):
cf.append((cf[-1] * (k + i - 1) * pow(i, MOD - 2, MOD)) % MOD)
ans = [0 for i in range(n)]
for i in range(n):
for j in range(i + 1):
ans[i] = (ans[i] + cf[i - j] * num[j]) % MOD
... | 3Python3 | {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42... | 2CODEFORCES |
223_C. Partial Sums_1265 | You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:
1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The operation x mod y means that ... | //package round138;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
public class C {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni(), K = ni();
int mod = 1000000007;
int[] v = ... | 4JAVA | {
"input": [
"5 0\n3 14 15 92 6\n",
"3 1\n1 2 3\n",
"10 1000000\n1 2 3 4 84 5 6 7 8 9\n",
"1 1\n3\n",
"13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n",
"1 0\n0\n",
"42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42... | 2CODEFORCES |
248_A. Cupboards_1266 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden ... | n=input()
A=0
B=0
for i in range(n):
a,b = map(int, raw_input().split())
if(a==1):
A+=1
if(b==1):
B+=1
ans = 0
ans = A + (n-B)
ans = min(ans, (n-A) + B)
ans = min(ans, A + B)
ans = min(ans, (n-A) + (n-B))
print ans
| 1Python2 | {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n... | 2CODEFORCES |
248_A. Cupboards_1267 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j, a, b, k, p;
pair<int, int> cell[1001];
cin >> n;
k = 0;
p = 0;
for ((i) = (0); (i) < (int)(n); (i)++) {
cin >> a >> b;
if (a == 0) k++;
if (b == 0) p++;
}
int sum;
sum = 0;
sum += min(k, n - k);
sum += min(p, n - p... | 2C++ | {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n... | 2CODEFORCES |
248_A. Cupboards_1268 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden ... | k = int(input())
lo=ro=rc=lc=0
for _ in range(k):
n , m = map(int,input().split())
if(n==0):
lo+=1
else:
lc=lc+1
if(m==0):
ro+=1
else :
rc=rc+1
print(min(lo,lc)+min(ro,rc))
| 3Python3 | {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n... | 2CODEFORCES |
248_A. Cupboards_1269 | One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.
Karlsson's gaze immediately fell on n wooden ... | import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Timer;
public class Main {
static int d[][];
static int N;
static boolean used[];
... | 4JAVA | {
"input": [
"5\n0 1\n1 0\n0 1\n1 1\n0 1\n",
"8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n",
"8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n",
"2\n0 0\n0 0\n",
"3\n0 1\n1 1\n1 1\n",
"5\n1 0\n1 0\n1 0\n0 1\n0 1\n",
"15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n... | 2CODEFORCES |
272_B. Dima and Sequence_1270 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2·x) = f(x);
* f(2·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤... | import collections
raw_input()
d = [int(x) for x in raw_input().split()]
def bitcount(x):
if x == 0:
return 0
r = 0
while x:
r += x & 1
x //= 2
return r
assert bitcount(5) == bitcount(3)
assert bitcount(15) == 4
h = collections.defaultdict(lambda:0)
for x in d:
h[bitcount(x)] += 1
s = 0
for v in h.itervalues... | 1Python2 | {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1... | 2CODEFORCES |
272_B. Dima and Sequence_1271 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2·x) = f(x);
* f(2·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤... | #include <bits/stdc++.h>
using namespace std;
vector<int> f(100001);
int comp(int i) {
int b = 0, d = 0;
while (i > 0) {
if (i & 1 == 1) b++;
i = i >> 1;
}
return b;
}
int main() {
int m, i, n;
int h[65];
long long j, s;
for (i = 0; i < 65; i += 2) {
h[i] = 0;
h[i + 1] = 0;
}
cin >> ... | 2C++ | {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1... | 2CODEFORCES |
272_B. Dima and Sequence_1272 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2·x) = f(x);
* f(2·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤... | def f(x):
return str(bin(x)).count('1')
n = int(input())
a = list(map(int, input().split()))
ans = [f(x) for x in a]
s = set(ans)
counts = {x:ans.count(x) for x in s}
ans = 0
for i in counts:
ans += (counts[i]*(counts[i]-1))//2
print(ans) | 3Python3 | {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1... | 2CODEFORCES |
272_B. Dima and Sequence_1273 | Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
* f(0) = 0;
* f(2·x) = f(x);
* f(2·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤... | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Sequence {
public static void main(String[] args) throws NumberFormatException, IOException {
int[] dp = new int[100];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine(... | 4JAVA | {
"input": [
"3\n1 2 4\n",
"3\n5 3 1\n",
"6\n396640239 62005863 473635171 329666981 510631133 207643327\n",
"4\n363034183 741262741 657823174 453546052\n",
"2\n7 1\n",
"1\n1\n",
"2\n1 1\n",
"8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n",
"8\n7 1... | 2CODEFORCES |
295_D. Greg and Caves_1274 | Greg has a pad. The pad's screen is an n × m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right.
Greg thinks that the pad's screen displays a c... | #include <bits/stdc++.h>
using namespace std;
int n, m;
long long res, c[2005][2005];
int main() {
cin >> n >> m;
long long p, q, s;
for (int i = 1; i <= n; i++) {
p = 1, q = 0;
for (int j = 2; j <= m; j++) {
q = (q + c[i - 1][j]) % 1000000007;
p = (p + q) % 1000000007;
c[i][j] = p;
... | 2C++ | {
"input": [
"3 5\n",
"1 1\n",
"4 4\n",
"5 3\n",
"1500 2000\n",
"500 1000\n",
"1000 1000\n",
"5 5\n",
"2000 2\n",
"1000 500\n",
"3 1000\n",
"2000 1\n",
"1 2\n",
"3 1999\n",
"100 100\n",
"1 1000\n",
"1000 3\n",
"7 8\n",
"9 8\n",
"10 10\n",... | 2CODEFORCES |
295_D. Greg and Caves_1275 | Greg has a pad. The pad's screen is an n × m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right.
Greg thinks that the pad's screen displays a c... | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Reader;
import java.io.Writer;
impor... | 4JAVA | {
"input": [
"3 5\n",
"1 1\n",
"4 4\n",
"5 3\n",
"1500 2000\n",
"500 1000\n",
"1000 1000\n",
"5 5\n",
"2000 2\n",
"1000 500\n",
"3 1000\n",
"2000 1\n",
"1 2\n",
"3 1999\n",
"100 100\n",
"1 1000\n",
"1000 3\n",
"7 8\n",
"9 8\n",
"10 10\n",... | 2CODEFORCES |
319_B. Psychos in a Line_1276 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangeme... | n, t = int(raw_input()), map(int, raw_input().split())
p, s, r = [0] * n, [0] * n, t[0]
for i in range(n - 1):
j = i + 1
x = t[j]
if x > r: r = x
else:
d = 0
while t[i] < x: d, i = max(d, s[i]), p[i]
p[j], s[j] = i, d + 1
print max(s) | 1Python2 | {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85... | 2CODEFORCES |
319_B. Psychos in a Line_1277 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangeme... | #include <bits/stdc++.h>
using namespace std;
int n, m[100005], x, k[100005], res, last;
stack<int> s;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
if (s.empty() || x > s.top()) {
s.push(x);
} else {
if (last > x) {
m[x] = 1;
k[x] = last;
} else {
... | 2C++ | {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85... | 2CODEFORCES |
319_B. Psychos in a Line_1278 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangeme... | n, t = int(input()), list(map(int, input().split()))
p, s, r = [0] * n, [0] * n, t[0]
for i in range(n - 1):
j = i + 1
x = t[j]
if x > r: r = x
else:
while t[i] < x: s[j], i = max(s[j], s[i]), p[i]
p[j] = i
s[j] += 1
print(max(s))
# Made By Mostafa_Khaled | 3Python3 | {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85... | 2CODEFORCES |
319_B. Psychos in a Line_1279 | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangeme... | import java.util.*;
import java.io.*;
import java.math.*;
public class D {
public static Scanner scan = new Scanner(System.in);
public static boolean bg = true;
public static void main(String[] args) throws Exception {
int n1 = Integer.parseInt(scan.next());
int[] data = new int[n... | 4JAVA | {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85... | 2CODEFORCES |
343_B. Alternating Current_1280 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u... |
inp = raw_input()
stack = []
for i in inp:
if len(stack) == 0:
stack.append(i)
continue
cur = stack.pop()
if cur == i:
continue
stack.append(cur)
stack.append(i)
if len(stack) == 0:
print 'Yes'
else:
print 'No'
| 1Python2 | {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
... | 2CODEFORCES |
343_B. Alternating Current_1281 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u... | #include <bits/stdc++.h>
using namespace std;
const int INF = ~(1 << 31);
const double eps = 1e-6;
const long double PI = 3.1415926535;
const int MOD = 1e9 + 7;
int n, m;
int main() {
string s;
cin >> s;
stack<int> st;
for (int(i) = 0; (i) < (s.size()); ++(i)) {
int g = s[i] == '+';
if (st.size() && st.... | 2C++ | {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
... | 2CODEFORCES |
343_B. Alternating Current_1282 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u... | list_inp=input()
stack_jud=[]
for i in list_inp:
if len(stack_jud)>0:
if stack_jud[-1]==i:stack_jud.pop()
else: stack_jud.append(i)
else: stack_jud.append(i)
if stack_jud==[]:print ('Yes')
else:print ('No')
| 3Python3 | {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
... | 2CODEFORCES |
343_B. Alternating Current_1283 | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
public class alternating {
public static void main(String[] args) throws Throwable {
BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
PrintWrit... | 4JAVA | {
"input": [
"-++-\n",
"++\n",
"+-\n",
"-\n",
"+-+--+-+\n",
"+-+--+\n",
"+-+++-\n",
"+++-\n",
"-++-+--++--+-++-\n",
"-+++--\n",
"-+--+-\n",
"+-++-+\n",
"+++---+++---\n",
"+-+-\n",
"-+-+-+\n",
"+++---\n",
"++--++\n",
"+---+\n",
"--++-+\n",
... | 2CODEFORCES |
366_D. Dima and Trap Graph_1284 | Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...
Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate inter... |
import sys
sys.setrecursionlimit(100000)
def dfs(v, l, r, mark):
if v == n - 1:
return True
mark[v] = True
for u, e in graph[v]:
if not mark[u] and edges[e][0] <= l <= r <= edges[e][1]:
if dfs(u, l, r, mark):
return True
return False
n, m = map(int, raw_i... | 1Python2 | {
"input": [
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"2 1\n1 2 1 1\n",
"1000 0\n",
"10 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n... | 2CODEFORCES |
366_D. Dima and Trap Graph_1285 | Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...
Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate inter... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int maxm = 3000 + 10;
struct Edge {
int v, l, r, next;
Edge(int v = 0, int l = 0, int r = 0, int next = 0)
: v(v), l(l), r(r), next(next) {}
} edges[maxm << 1];
int head[maxn], nEdge, n, m;
int a[maxm], b[maxm];
int vis[maxn], cnt... | 2C++ | {
"input": [
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"2 1\n1 2 1 1\n",
"1000 0\n",
"10 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n... | 2CODEFORCES |
366_D. Dima and Trap Graph_1286 | Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...
Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate inter... |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
public class DimaAndTrapGraphFaster {
static List<Edge>[] edges;
static int N;
static int M;
static long[] lef... | 4JAVA | {
"input": [
"4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n",
"5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n",
"5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n",
"2 1\n1 2 1 1\n",
"1000 0\n",
"10 0\n",
"6 6\n1 2 1 10\n2 3 1 10\n... | 2CODEFORCES |
38_C. Blinds_1287 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they ma... | #!/usr/bin/env python
from sys import stdin
N, L = map(int, stdin.readline().split())
A = map(int, stdin.readline().split())
mx = max(A)
res = 0
for l in xrange(L, mx+1):
n = 0
for x in A:
n += int(x / l)
res = max(res, n * l)
print res
| 1Python2 | {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 8... | 2CODEFORCES |
38_C. Blinds_1288 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they ma... | #include <bits/stdc++.h>
using namespace std;
int n, l;
vector<int> v;
int main() {
scanf("%d %d", &n, &l);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
if (x >= l) v.push_back(x);
}
sort(v.begin(), v.end());
int ms = 0;
for (int i = 0; i < v.size(); i++) {
int count = 0;
for (i... | 2C++ | {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 8... | 2CODEFORCES |
38_C. Blinds_1289 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they ma... | m, l = map(int, input().split())
a = list(map(int, input().split()))
print(max(i * sum(ai // i for ai in a) for i in range(l, 101))) | 3Python3 | {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 8... | 2CODEFORCES |
38_C. Blinds_1290 | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they ma... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Blinds {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String temp[] = br.readLine().split... | 4JAVA | {
"input": [
"5 3\n5 5 7 3 1\n",
"4 2\n1 2 3 4\n",
"2 3\n1 2\n",
"93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 8... | 2CODEFORCES |
40_B. Repaintings_1291 | A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues a... | n, m = map(int, raw_input().split())
x = input()
def black(x1, y1, x2, y2):
if x1 > x2 or y1 > y2:
return 0
h, w = x2 - x1 + 1, y2 - y1 + 1
return ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2)
if min(n, m) >= x + x - 1:
print black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)
else:
... | 1Python2 | {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999... | 2CODEFORCES |
40_B. Repaintings_1292 | A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues a... | #include <bits/stdc++.h>
using namespace std;
int perimeter(int w, int h) {
if (w == 1) return h;
if (h == 1) return w;
return 2 * w + 2 * (h - 2);
}
int main() {
int n, m, x;
cin >> n >> m >> x;
int res = 0;
while (true) {
int border = (perimeter(n, m) + 1) / 2;
--x;
if (!x) {
res = bor... | 2C++ | {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999... | 2CODEFORCES |
40_B. Repaintings_1293 | A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues a... | import itertools
import math
n, m = [int(k) for k in input().split()]
x = int(input())
if n-2*(x-1) < 1 or m-2*(x-1) < 1:
print(0)
elif n-2*(x-1) == 1 or m-2*(x-1) == 1:
print((n+m-4*(x-1))//2)
else: print(n+m-2 - 4*(x-1))
| 3Python3 | {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999... | 2CODEFORCES |
40_B. Repaintings_1294 | A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues a... |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Bit... | 4JAVA | {
"input": [
"1 1\n1\n",
"3 3\n2\n",
"3 3\n1\n",
"2016 4549\n433\n",
"5000 1\n3\n",
"4035 369\n26\n",
"1595 2881\n710\n",
"3762 3914\n1073\n",
"4583 2774\n1206\n",
"10 10\n1\n",
"1812 240\n9\n",
"991 2301\n291\n",
"3154 527\n112\n",
"1353 2988\n589\n",
"4999... | 2CODEFORCES |
438_A. The Child and Toy_1295 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The... | n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 0
for i in xrange(m):
x, y = map(int, raw_input().split())
ans += min(a[x-1], a[y-1])
print ans
| 1Python2 | {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6... | 2CODEFORCES |
438_A. The Child and Toy_1296 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int cost[MAXN];
char used[MAXN];
vector<int> g[MAXN];
int main() {
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> cost[i];
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
x--;... | 2C++ | {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6... | 2CODEFORCES |
438_A. The Child and Toy_1297 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readline().sp... | 3Python3 | {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6... | 2CODEFORCES |
438_A. The Child and Toy_1298 | On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.
The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The... | import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelp... | 4JAVA | {
"input": [
"4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n10 20 30 40\n1 4\n1 2\n2 3\n",
"7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n",
"1 0\n23333\n",
"3 3\n1 1 1\n1 2\n2 3\n3 1\n",
"5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n",
"10 30\n3 6 17 15 13 15 6... | 2CODEFORCES |
45_H. Road Problem_1299 | The Berland capital (as you very well know) contains n junctions, some pairs of which are connected by two-way roads. Unfortunately, the number of traffic jams in the capital has increased dramatically, that's why it was decided to build several new roads. Every road should connect two junctions.
The city administrat... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 20;
struct DSU {
int par[901];
vector<int> vec[901];
DSU() {
for (int i = ... | 2C++ | {
"input": [
"4 4\n1 2\n2 3\n2 4\n3 4\n",
"4 3\n1 2\n2 3\n3 4\n",
"10 9\n7 9\n8 9\n8 2\n10 6\n8 3\n9 4\n2 6\n8 5\n9 1\n",
"2 1\n1 2\n",
"20 20\n1 9\n11 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 4\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n",
"20 20\n2 17\n5 17\n14 ... | 2CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.