source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
exec_outcome
stringclasses
1 value
#include<stdio.h> #include<string.h> #include<ctype.h> #include<math.h> #include<iostream> #include<string> #include<set> #include<map> #include<vector> #include<queue> #include<bitset> #include<algorithm> #include<time.h> using namespace std; void fre(){freopen("c://test//input.in","r",stdi...
C++
5da1c96b88b4ac0b698a37e4d2437ccb
5f3330d3de118e7c5fa6a96258cb24ef
1,700
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define ii pair<ll,ll> #define vi vector<ll> #define N int(1e6) #define vii vector<ii> int ans[N]; int a[N]; bool is[N]; int main(){ // freopen("in.txt","r",stdin); // ios_base::sync_with_stdio(false); int n; scanf("%d",&n); for(int...
C++
5da1c96b88b4ac0b698a37e4d2437ccb
faf3c498a608a0ac7e020775143cde33
1,700
PASSED
#include <bits/stdc++.h> using namespace std; int n,a[501000]; void work(int l,int r) { if((l+r)%2) { for(int i=l;i<=(l+r-1)/2;i++) a[i]=a[l-1]; for(int i=(l+r-1)/2+1;i<=r;i++) a[i]=a[r+1]; } else { for(int i=l;i<=r;i++) a[i]=a[l-1]; }...
C++
5da1c96b88b4ac0b698a37e4d2437ccb
2d36d70f899ef8467756f0ca2b5a8f10
1,700
PASSED
#include <iostream> #include <vector> #include <string> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <cmath> #include <algorithm> #include <cassert> #include <tuple> #include <functional> #include <unordered_set> #include <unordered_map> #include <sstream> #include <stdio.h...
C++
5da1c96b88b4ac0b698a37e4d2437ccb
b63aa8589527364735ed5577d2d05d6b
1,700
PASSED
#include<iostream> using namespace std; const int maxn=500000+1000; int a[maxn],b[maxn],n; int main(){ cin >> n; for (int i=1;i<=n;i++) cin >> a[i]; b[1]=b[n]=0; for (int i=2;i<n;i++){ if (a[i]!=a[i-1] && a[i]!=a[i+1]) b[i]=1; else b[i]=0; } int s=0,e,cnt=0; for (int i=1;i<=n;i++){ if (!s && b[i]) s=i; ...
C++
5da1c96b88b4ac0b698a37e4d2437ccb
00bc045863fe94865c0a5ad5eb6f6544
1,700
PASSED
// Author : Naresh Bharasagar // Instt. : Indian Institute of Technology Guwahati //-------------------------------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; typedef long long int loo; typedef long double ld; #pragma ...
C++
a491be7d5883d594c3e907a22be607c9
a8a4a6a418d2a9799fe311e32c7dcaf9
1,500
PASSED
// Problem : A. Shifts // Contest : Codeforces Round #142 (Div. 1) // URL : https://codeforces.com/problemset/problem/229/A // Memory Limit : 256 MB // Time Limit : 2000 ms //kaushik.mv3 #include <climits> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitse...
C++
a491be7d5883d594c3e907a22be607c9
578db663f2e08f379be17527ee6b1167
1,500
PASSED
#include<bits/stdc++.h> using namespace std; #define int long long #define ull unsigned long long #define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define trace(x) clog<<#x<<": "<<x<<endl #define debug(x) cout << #x << ":" << x << ' '; #define debugg(x) cout << #x << ":" << x << ' ' << "\n";...
C++
a491be7d5883d594c3e907a22be607c9
6e0002845b12b52fa109bde33e094a12
1,500
PASSED
#include <bits/stdc++.h> #define ll long long int #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define vi vector<int> #define vvi vector<vector<int> > #define mii map<int,int> #define pb push_back #define pii pair<int,int> #define mkp make_pair #define scan(a,n) for(int i =0 ; i<n ; i++) cin>...
C++
a491be7d5883d594c3e907a22be607c9
0b306dbf6ccd1061703e7a2098c73d2e
1,500
PASSED
#include<bits/stdc++.h> using namespace std; #define db1(x) cout<<#x<<"="<<x<<'\n' #define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n' #define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n' #define repi(i,n) for(int i=0;i<(n);++i) //#define repA(i,a,n) for(int i=a;i<=(n);++i) //#define repD(i...
C++
a491be7d5883d594c3e907a22be607c9
b8744a0c5fec0e01c9cfe51ce1a22804
1,500
PASSED
#include <bits/stdc++.h> using namespace std; /******************************MACROS******************************/ #define int long long #define ld long double #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define yes cout<<"YES\n" #define no cout<<"NO\n" #define vt vector #define pb...
C++
a491be7d5883d594c3e907a22be607c9
1b16ee541816c4d77b24f4f0726193b3
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define vi vector<int> #define vb vector<bool> #define pii pair<int,int> #define mod 1000000007 #define ss second #define ff first #define vpii vector<pii> #define vvi vector<vi> #define pb push_back #define vs vector<string> #define ...
C++
a491be7d5883d594c3e907a22be607c9
0a397e362d07abc78430e43d93e5549d
1,500
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long vector<ll> v; ll n,m,c[105][10005],x,y,ans=1e9; string s; int main(){ cin>>n>>m; for(int i=1; i<=n; i++){ cin>>s; v.clear(); for(int j=0; j<s.size(); j++){ if(s[j]=='1'){ v.push_back(j); } } if(v.size()==0){ cout<<-1; exit(0);...
C++
a491be7d5883d594c3e907a22be607c9
f27e4cb6d153d0f7720e52a695c6840d
1,500
PASSED
#include <cstdio> #include <cmath> #include <algorithm> #include <vector> using namespace std; int n, m; char grid[105][10201]; vector <int> one[105]; int best[10201]; int dist (int i, int j) { return min (abs (i - j), m - abs (i - j)); } int main() { scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) ...
C++
a491be7d5883d594c3e907a22be607c9
2f0b4dfb6e9c1ef0eed0d0c4330c502a
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize ("Ofast") #define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define ull unsigned long long #define ll long long #define inf INT_MAX #define mninf INT_MIN #define infl 1e18+5 #define mninfl -1e18-5 #define Mod 1000000007 #define newm...
C++
a491be7d5883d594c3e907a22be607c9
7db6ae635e8e893ed562d3998dddb1a1
1,500
PASSED
#include <bits/stdc++.h> #ifdef LOCAL_TEST #pragma comment(linker, "/stack:16777216") #endif using namespace std; typedef long long int ll; typedef vector <ll> vll; typedef pair<ll, ll> pp; typedef vector<pp > vpp; typedef stack < pair<int, int> > sii; typedef queue < ll > qll; #define sz(a) (ll) ((a).size()) #de...
C++
5e055bad1da5bdc84599d6f2f89fbd12
8df632fa4072a2b8ac3c6c73e66c9739
1,500
PASSED
/* Name: Mohit Khare CSE - MNNIT Allahabad never give up!! */ #include<bits/stdc++.h> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define speed ios_base::sync_with_stdio(false); #define pb p...
C++
5e055bad1da5bdc84599d6f2f89fbd12
6b103d9f626863f297a8e17b88665f74
1,500
PASSED
#include <iostream> #include <cstring> #include <vector> #include <map> using namespace std; int n,a,b,ans; pair<int,int> arr[100001]; map<int,int> frn; map<int,int> bck; int main(int argc, const char * argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ans=1e5+1; cin >> n; for(int i=0; i<n; i++)...
C++
5e055bad1da5bdc84599d6f2f89fbd12
2c95e7bf885dc5b7c24e29210b9aaedf
1,500
PASSED
#include<iostream> #include<cstdio> #include<cstring> #include<map> #include<set> #include<algorithm> using namespace std; const int INF = 0x3f3f3f3f; typedef __int64 LL; int main() { int N; while (~scanf("%d",&N)) { LL x,y; map<LL,LL>m1,m2; map<LL,LL>::iterator itt; set<LL>...
C++
5e055bad1da5bdc84599d6f2f89fbd12
ac0c045f9d65febd6c0fbb066773a2b1
1,500
PASSED
/*siddharth goyal*/ #include<bits/stdc++.h> using namespace std; #define pb push_back #define REP(i,n) for(i=1;i<=n;i++) #define FOR(i,a,b) for(i=a;i<=b;i++) #define all(v) v.begin(),v.end() #define F first #define S second #define vl ...
C++
5e055bad1da5bdc84599d6f2f89fbd12
b62d2fe9a141fc2368f9bdd5d84be6e5
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define gold 0 #define fi first #define se second #define pb push_back #define mp make_pair #define sz(x) int(x.size()) #define all(x) x.begin(), x.end() #define freopen(x) freopen(x".in", "r", std...
C++
5e055bad1da5bdc84599d6f2f89fbd12
60ab7b8123d8518cb3cf91d307f12a4f
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define lli long long int #define mod 1000000007 #define MAX 300005 lli max(lli a,lli b) { if(a>b) { return a; } return b; } lli gcd(lli a,lli b) { if(a==0) { return b; } return gcd(b%a,a); } lli min(lli a,lli b) { if(a<b) {...
C++
5e055bad1da5bdc84599d6f2f89fbd12
a37a4bb745f8286d61ba7f53f748c1b1
1,500
PASSED
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <map> #include <queue> #include <stack> using namespace std; const int maxn=100001; #define INF 0x3f3f3f3f struct COLOR { int cl; int cnt; }; COLOR color1[maxn],color2[maxn],tcl; map<int,int...
C++
5e055bad1da5bdc84599d6f2f89fbd12
e0b79911b30cef6e30b392b9b115e3e6
1,500
PASSED
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define lld long long int typedef pair< lld, lld > pii; typedef map<lld,lld> mii; typedef map<char,lld>sii; typedef pair<lld,lld>pi...
C++
5e055bad1da5bdc84599d6f2f89fbd12
c73932051f105ced42ec13139fbd470f
1,500
PASSED
#include<bits/stdc++.h> using namespace std; #define pb push_back #define tr(it,ct) for(auto &(it) : ct) #define F first #define S second #define clr(a,b) memset((a), (b), sizeof(a)) #define lld long long int #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #defi...
C++
5e055bad1da5bdc84599d6f2f89fbd12
9e9ff5c8196cc4b169f338342853cabd
1,500
PASSED
import java.util.Scanner; public class jucier { public static void main(String[] args) { Scanner u = new Scanner (System.in); int num = u.nextInt(); int b = u.nextInt(); int d = u.nextInt(); int c = 0; int total = 0; int oranges[] = new int [num]; for (int i = 0; i < oranges.length; i++) { oranges...
Java
06e9649963715e56d97297c6104fbc00
1c48d3e0e044732deb6ae664eefd89a0
900
PASSED
import java.util.Arrays; import java.util.Scanner; public class JavaApplication1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int b = input.nextInt(); int d = input.nextInt(); ...
Java
06e9649963715e56d97297c6104fbc00
35cfc9e152693fa164dd4c0319a8a59c
900
PASSED
import java.util.Scanner; public class Juicer { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n= s.nextInt(); int maxSize = s.nextInt(); int empty = s.nextInt(); int count = 0; int result = 0; for (int i = 0; i < n; i++) { ...
Java
06e9649963715e56d97297c6104fbc00
0a8da9ecf616878e1ba0b8e3dd7da760
900
PASSED
import java.util.Scanner; public class Juicer { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n= s.nextInt(); int maxSize = s.nextInt(); int empty = s.nextInt(); int count = 0; long result = 0l; for (int i = 0; i < n; i++) {...
Java
06e9649963715e56d97297c6104fbc00
c5444048f08daa09ed3fa8e29afb8193
900
PASSED
import java.util.Scanner; public class Juicer { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long nborange=sc.nextLong(); long maxsizeorange=sc.nextLong(); long limitwastesection=sc.nextLong(); if((nborange==maxsizeorange) && (maxsizeorange==limitwastesection) && (...
Java
06e9649963715e56d97297c6104fbc00
95fec676732c75c8717727905976b62e
900
PASSED
import java.util.Scanner; public class CF709_D2_A { public static void main(String[] args) { Scanner scanner = new Scanner( System.in ); int iN = scanner.nextInt(); int iB = scanner.nextInt(); int iD = scanner.nextInt(); long iTotal = 0; int count = 0; for( int i = 1; i <= iN; i++ ) { long i...
Java
06e9649963715e56d97297c6104fbc00
238b35ea50718cfeb7b11887df109408
900
PASSED
import java.util.*; public class Ex21 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner console= new Scanner (System.in); int num = console.nextInt(); int size = console.nextInt(); int waste1 = console.nextInt(); int[] orange = new int[num]; for (int i = 0 ; i < num ...
Java
06e9649963715e56d97297c6104fbc00
5fa7563a5709c41996c24eecf6bfeafc
900
PASSED
import java.util.*; /** * @(#)juicer.java * * * @author * @version 1.00 2016/9/8 */ public class juicer { public static void main(String[] args) { Scanner kbd = new Scanner (System.in); int emp = 0; int sum = 0; int n = kbd.nextInt(); int[] list = new int[n]; int b = kb...
Java
06e9649963715e56d97297c6104fbc00
c436be140a4ea87bf74cb9b6844f58e0
900
PASSED
import java.util.Scanner; public class CF709_D2_A { public static void main(String[] args) { // time reading 4 min // think 5 min // implement time 4 min // debug 1 min Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int b = scanner.nextI...
Java
06e9649963715e56d97297c6104fbc00
9f3c8acd858c975e09d63ff10639cc05
900
PASSED
import java.util.Scanner; public class Juicer { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int maxSize = scanner.nextInt(); int wasteSize = scanner.nextInt(); int[] sizes = new int[n]; for (int i =...
Java
06e9649963715e56d97297c6104fbc00
68ec3182c72ecca64ea18d48b7b231a2
900
PASSED
def main(): q = int(input()) for _ in [0]*q: n = int(input()) nn = n res = [0]*50 p = pow(3,49) idx = 49 ma = -1 while n != 0: if n >= p: pr = n//p res[idx] = pr n -= pr*p if pr =...
Python
5953b898995a82edfbd42b6c0f7138af
699af83fb5e7dcd991f7e65beaa54eea
1,500
PASSED
""" Satwik_Tiwari ;) . 16 june , 2020 - Tuesday """ #=============================================================================================== #importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IO...
Python
5953b898995a82edfbd42b6c0f7138af
84e6357485d33130cca9e4698e371da0
1,500
PASSED
import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.wr...
Python
5953b898995a82edfbd42b6c0f7138af
6a842fe1076a8828c8d6985357c4158a
1,500
PASSED
def to_ternary(n): l = [] while n > 0: y = n % 3 l.append(y) n = n//3 return reversed(l) for _ in range(int(input())): a = int(input()) x = list(to_ternary(a)) tw = False pos2 = -1 pos0 = -1 for i in range(len(x)): if x[i]==2: tw = True ...
Python
5953b898995a82edfbd42b6c0f7138af
16abcc5e94d6ed3d8551f4079330d29d
1,500
PASSED
import sys import bisect as bi import math from collections import defaultdict as dd import heapq import itertools input=sys.stdin.readline from random import randint ##import numpy as np ##sys.setrecursionlimit(10**7) mo=10**9+7 def cin(): return map(int,sin().split()) def ain(): return list(map(in...
Python
5953b898995a82edfbd42b6c0f7138af
bb84e6f0846d95542f3b68b2e7007f6b
1,500
PASSED
import sys import bisect as bi import math from collections import defaultdict as dd import heapq import itertools input=sys.stdin.readline from random import randint ##import numpy as np ##sys.setrecursionlimit(10**7) mo=10**9+7 def cin(): return map(int,sin().split()) def ain(): return list(map(in...
Python
5953b898995a82edfbd42b6c0f7138af
bf97b47dcc1dd4d77339a59441365a4a
1,500
PASSED
import math import sys input=sys.stdin.readline nu=1 dic={1:0} for i in range(1,39): nu*=3 dic[nu]=i for _ in range(int(input())): n=int(input()) co=0 li=[60] flag=True while(n): if(n in dic): if(li[-1]==dic[n]): flag=False break ...
Python
5953b898995a82edfbd42b6c0f7138af
4b55fa46155090efc9b13c94b6fdd6ab
1,500
PASSED
for _ in range(int(input())): n = int(input()) s = [0] * 1000 cnt = 0 while(n > 0): s[cnt] = n % 3 cnt += 1 n //= 3 flag = False pos = -1 for i in range(cnt + 1): if(s[i] == 2) and (flag == False): flag = True pos = i if(flag): ...
Python
5953b898995a82edfbd42b6c0f7138af
5e7afb6a47c3094862a6e173645f2f31
1,500
PASSED
t = int(input()) while t: n = int(input()) orig = n l = [] pos = -1 while n > 0: l.append(n % 3) if l[-1] == 2: pos = len(l) - 1 n //= 3 # print(l) if pos == -1: print(orig) else: i = 0 # print(l) for i in range(pos, le...
Python
5953b898995a82edfbd42b6c0f7138af
19a48e1b1732adb6711decfe7074b332
1,500
PASSED
'''input 8 1 2 6 13 14 3620 10000 1000000000000000000 ''' # A coding delight from sys import stdin, stdout import sys from bisect import bisect_left, bisect_right import gc gc.disable() # def get_bin(l, num): # temp = str(bin(num)[2:]) # temp = (l - len(temp)) * '0' + temp # return temp # def get_subset(start, en...
Python
5953b898995a82edfbd42b6c0f7138af
fe1d92532ad552f8733fe6710d2d6dd9
1,500
PASSED
#include<bits/stdc++.h> using namespace std; int main() { string commed;//命令 int time,m;//次数..内存大小 scanf("%d%d",&time,&m); int line[m+1]; memset(line,0,sizeof(line));//初始化内存 int p1=1;//内存编号指针 for(int i=1;i<=time;i++) { cin>>commed;//输入命令 if(commed...
C++
a6cba17c5ddb93f6741e00280fb6c54c
ebd152382f7d4f23331c68356a5f1293
1,600
PASSED
#include<ios> #include<iostream> using namespace std; const int MAXN=100+3; int t,m; int d[MAXN]; int ans; int main(){ ios_base::sync_with_stdio(false); cin>>t>>m; for(int o=1;o<=t;o++){ string s; cin>>s; if(s=="alloc"){ int n; cin>>n; int i,j=-1; for(i=0;i<m;i++){ if(i-j==n&&!d[i]){ break...
C++
a6cba17c5ddb93f6741e00280fb6c54c
0d3d5dfb7c6b4c9a68fd62663ef696fe
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int d[101],t,m,c,b,i,j,k,l;string s; int main(){ cin>>t>>m; for(k=0;k<t;k++){ cin>>s; if(s[0]=='a'){ cin>>c; for(i=0,j=-1;i<m;i++)if(i-j==c&&!d[i])break;else if(d[i])j=i; if(i-j==c&&i<m){ cout<<++b<<endl; for(l=j+1;l<=i;l++)d[l]=b; } else cout<<"...
C++
a6cba17c5ddb93f6741e00280fb6c54c
28a11c3f26fccbaaf0764c7c388fe7f6
1,600
PASSED
#include <iostream> #include <string> #include <array> int main() { std::array<int, 100> Arr{ 0 }; int t, m; std::cin >> t >> m; int id = 1; // 标记着最远的编号,从1开始 std::string Command; while (t--) { std::cin >> Command; if (Command[0] == 'a') // "alloc" { int...
C++
a6cba17c5ddb93f6741e00280fb6c54c
01ed2751a6726db0895d685a757bc31c
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int t,m; vector < pair < pair < int , int > , int > > v; bool alloc(int x,int id) { int i,j; for (i=0;i<m-x+1;i++) { bool bad=false; for (j=0;j<v.size();j++) { int a=v[j].first.first; int b=v[j].first.second; if (a<i+x&&b>i) bad=true; } if (!bad) { ...
C++
a6cba17c5ddb93f6741e00280fb6c54c
19c8d83500b7b820fdc09ad71c2ea879
1,600
PASSED
#include <iostream> #include <string> #include <array> using namespace std; int main() { std::array<int, 100> Arr{ 0 }; int t, m; std::cin >> t >> m; int id = 1; // 标记着最远的编号,从1开始 std::string Command; while (t--) { std::cin >> Command; if (Command[0] == 'a') // "alloc" ...
C++
a6cba17c5ddb93f6741e00280fb6c54c
ef70868c4814a857be45c68d40262391
1,600
PASSED
#include <cstdio> const int N = 105; int t[N], tot, q, n; int alloc(int len) { bool ok = false; int l = 0; for (int i = 1; i <= n; i++) { if (t[i] == 0) l++; else l = 0; if (l == len) { tot++; ok = true; for (int j = 1; j <= l; j++) t[i - j + 1] = tot; break; } } if (ok) return tot; else retur...
C++
a6cba17c5ddb93f6741e00280fb6c54c
fb0089823348572868d5e018fa1e1add
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int t,m,n,x,blk,mem[120],beg[120],nmem[120]; string cmd; void al(){//内存分配:尽量靠左,O(n+m) if(n>m){ cout<<"NULL"<<endl; return; } int cnt=0; for(int i=1;i<=n;i++) cnt+=mem[i]; if(cnt==0){ cout<<++blk<<endl; for(int i=1;i<=n;i++){ mem[i]=blk; } beg[blk]=1; ...
C++
a6cba17c5ddb93f6741e00280fb6c54c
0acc408bf3bda889aa2a7143ab7348ea
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int t,m,n,x,blk,mem[120],beg[120],nmem[120]; string cmd; void al(){//内存分配:尽量靠左,O(n+m) if(n>m){ cout<<"NULL"<<endl; return; } int cnt=0; for(int i=1;i<=n;i++) cnt+=mem[i]; if(cnt==0){ cout<<++blk<<endl; for(int i=1;i<=n;i++){ mem[i]=blk; } beg[blk]=1; ...
C++
a6cba17c5ddb93f6741e00280fb6c54c
022b2e0b7b540c0bfe862d1a301aad27
1,600
PASSED
#include<bits/stdc++.h> /************************************************/ #define rep(i,n) for(int i=0;i<n;i++) #define mp make_pair #define pb push_back #define fr first #define se second #define forn(i,a,n) for(int i=a;i<n;i++) #define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++) #define pii p...
C++
a6cba17c5ddb93f6741e00280fb6c54c
0c4b0c6d173097c11739f53a1bc7df97
1,600
PASSED
import java.io.*; import java.util.*; public class Solution { static long gcd; static long x,y; public static void main(String ag[]) { Scanner sc=new Scanner(System.in); long A=sc.nextLong(); long B=sc.nextLong(); long C=sc.nextLong(); gcd(A,B); i...
Java
a01e1c545542c1641eca556439f0692e
29aa8c08a2729e75a66b1d937782d899
1,800
PASSED
import java.util.*; import java.io.*; public class hello { public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new...
Java
a01e1c545542c1641eca556439f0692e
004db46d27cedacd6fc57da0b8ad218e
1,800
PASSED
import java.util.*; public class Line { static long[] solution(long a, long b){ if(a==0) return new long[]{0,1,b}; long[] ans = solution(b%a,a); return new long[]{ans[1]-(b/a)*ans[0],ans[0],ans[2]}; } static void solve(){ Scanner sc = new Scanner(System.in); ...
Java
a01e1c545542c1641eca556439f0692e
cf019c38fba018587ef125ecd5311a0d
1,800
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; public class Main{ public static StreamTokenizer sc=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public static int nextint() throws I...
Java
a01e1c545542c1641eca556439f0692e
4df7f9336e06187e473669cb8b692801
1,800
PASSED
import java.io.*; import java.util.*; import java.math.*; // for bigInteger public class practice { private final static int M = (int)1e9+7; private static final InputReader scan = new InputReader(System.in); private static final PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWr...
Java
a01e1c545542c1641eca556439f0692e
fe373f688ba6dd04686bc6659f5e7c11
1,800
PASSED
#include <bits/stdc++.h> #define pb push_back #define int long long #define endl '\n' #define all(x) (x).begin(),(x).end() #define deb(x) cout<<#x<<"="<<x<<endl; #define test int T;cin>>T;while(T--) using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9 + 9; const int N = 500500; int mod(int a, int b) { ...
C++
a01e1c545542c1641eca556439f0692e
b6859494e9a9b8a457dba77a43a97c82
1,800
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcdExtended(ll a, ll b, ll *x, ll *y) { if (a == 0) { *x = 0; *y = 1; return b; } ll x1, y1; ll gcd = gcdExtended(b%a, a, &x1, &y1); *x = y1 - (b/a) * x1; *y = x1; return gcd; } int main() { i...
C++
a01e1c545542c1641eca556439f0692e
6a961b30f8a6172d28adf2c25fd4f592
1,800
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; int exgcd(int a, int b, int &x, int &y) { if (b == 0) { x = 1; y = 0; return a; } int d = exgcd(b, a % b, y, x); y -= (a / b) * x; return d; } signed main() { int a, b, c, d, x, y; cin >> a >> b >...
C++
a01e1c545542c1641eca556439f0692e
da80eee67a1bfbb86f46507d43f0b300
1,800
PASSED
/* 786 */ #include <bits/stdc++.h> using namespace std; //typedefs typedef long long LL; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<VI> VVI; typedef vector<VL> VVL; typedef pair<int,int> PII; typedef pair<double, double> PDD; typedef pair<LL, LL> PLL; typedef vector<PII> VII; typedef vector<P...
C++
a01e1c545542c1641eca556439f0692e
b3c3af265160a80c1a45efc3a709b6e4
1,800
PASSED
#include<stdio.h> #include<iostream> #include<cmath> #include<string> #include<map> #include<vector> #include<cstring> #include<algorithm> #include<set> using namespace std; long long x,y,c; long long exgcd(long long a,long long b) { if(b==0) { x=1; y=0; return a; } long long r=e...
C++
a01e1c545542c1641eca556439f0692e
e35bad8e429c5068401afab6ff6490ca
1,800
PASSED
//InHisName #include<bits/stdc++.h> using namespace std; const long long MOD=1000000007; long long dp1[2001][2001],dp2[2001][2001],n,m,tc,to,dif,madif; string s; int main(){ ios_base::sync_with_stdio(false); cin>>n>>m>>s; for(int i=0;i<s.size();i++){ if(s[i]=='(') to++, dif--; else tc++,dif++; madif=max(...
C++
ea6f55b3775076fcba6554b743b1a8ae
04dd81644e9bcff6b380b92a68e4715f
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define sz(x) ((int) (x.size())) //#define dbg cout //*********IMPORTANT*********: valid sequences are also valid when iterating from the end and changing opening and closing brackets into each other. const int...
C++
ea6f55b3775076fcba6554b743b1a8ae
54c5584f0acb8ce4f3adbc89549fb795
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define sz(x) ((int) (x.size())) //#define dbg cout const int N=2005; const ll M=(ll)1e9+7; ll dp[N][N], sum[N][N]; /*dp[i][j]: number of ways to build string p with i opening brackets and j closing bracketss w...
C++
ea6f55b3775076fcba6554b743b1a8ae
dd6e39bc66f65302300c0d3e485b92eb
2,000
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fr first #define sc second #define ARRS int(1e5+11) #define MOD ((long long)1000000007) ll i,j,l,k,n,p,d,mx,mn,x,y,ans,res,sum; deque<ll> q; ll m; string s; ll dp[4007][4007]; ll pas[4017][4017]; int main(){ #ifdef...
C++
ea6f55b3775076fcba6554b743b1a8ae
d088d79b1f8cf39c76278c11df55b5ae
2,000
PASSED
#include<iostream> using namespace std; #define int long long const int md=1e9+7; int dp[5000+5][5000+5]; main() { int n,m; cin>>n>>m; string s; cin>>s; int bal_min=0; int bal_max=0; for (int i=0; i<m; i++) { if (s[i]=='(') bal_max++; else bal_max--; bal_min=...
C++
ea6f55b3775076fcba6554b743b1a8ae
94f6f9321f88399d03ef3f5575048549
2,000
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long const ll mod = 1e9+7; int n, m; ll f[2005][2005], ans; string s; int main() { ios_base::sync_with_stdio(false); cin >> n >> m >> s; s = ' ' + s; f[0][0] = f[1][1] = 1; int lim; for(int i = 2;i <= 2000;i++) { //lim = m...
C++
ea6f55b3775076fcba6554b743b1a8ae
087581ba276295ea47319b5c85d46ddb
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define M 1000000007 #define pb push_back #define mp make_pair #define s second #define f first #define mod 998244353 #define sz(v) (int)(v).size() #define pii pair<int, int> #define vi vector<int> #define ll long long #define fastio ios_base::sync_with_stdio(false);cin...
C++
ea6f55b3775076fcba6554b743b1a8ae
1ddb343128557f28b918eb768ffae95f
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define M 1000000007 #define pb push_back #define mp make_pair #define s second #define f first #define mod 998244353 #define sz(v) (int)(v).size() #define pii pair<int, int> #define vi vector<int> #define ll long long #define fastio ios_base::sync_with_stdio(false);cin...
C++
ea6f55b3775076fcba6554b743b1a8ae
817606b4dea1eecfb041f76ab8fa7c2a
2,000
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 1; i <= n; i++) #define pb push_back const ll M = 6000; const ll inf=2e9+5; const ll MOD = 1e9+7; const double PI= 3.14159265358979323846; #define mp make_pair typedef pair<ll, ll> pi; typedef pair<ll, pi> pii; typedef pai...
C++
ea6f55b3775076fcba6554b743b1a8ae
56bbc6edffcf6200d43e0960ba8d1184
2,000
PASSED
/*input 4 1 ( */ #include <iostream> #include <iomanip> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <unordered_map> #include <set> #include <queue> #include <stack> #include <vector> #include <algorithm> using namespace std; typedef long long l...
C++
ea6f55b3775076fcba6554b743b1a8ae
eb1d3c20af181b9a242e2be9af52cf38
2,000
PASSED
#pragma GCC optimize("O3") // @author PraveenKumarRana #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define IOS std::ios_base::sync_with_stdio(false) #define all(x) x.begin(), x.end() #define f(i, a, n) for (int i = a; i < n; i++) #define fr(i, n, a) for (int i = n - 1; ...
C++
a608eda195166231d14fbeae9c8b31fa
9bc80e015804e9711395d9a0c9488796
1,500
PASSED
/* //////////////////////////////////////////////////////////////////////////////// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ******* ******* * * * * * * * ...
C++
a608eda195166231d14fbeae9c8b31fa
412844b82398f26cc9e83d664ad3e171
1,500
PASSED
/* //////////////////////////////////////////////////////////////////////////////// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ******* ******* * * * * * * * ...
C++
a608eda195166231d14fbeae9c8b31fa
37220018e58249f1773ffd8d12851bb7
1,500
PASSED
#include <iostream> #include <random> #include <chrono> #include <algorithm> #include <set> #define rep(i, x) for(int i = 0; i < x; i++) using namespace std; typedef long long ll; const ll MOD = (ll)1e9 + 7; const int N = 1e5+5, inf = 1e9+5; ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; } ll sub...
C++
a608eda195166231d14fbeae9c8b31fa
09a38d9d7a8468cab14d07170ae6e0a1
1,500
PASSED
#include <iostream> #include <random> #include <chrono> #include <algorithm> #include <set> #define rep(i, x) for(int i = 0; i < x; i++) using namespace std; typedef long long ll; const ll MOD = (ll)1e9 + 7; const int N = 1e5+5, inf = 1e9+5; ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; } ll sub...
C++
a608eda195166231d14fbeae9c8b31fa
8c2d712384114270045ff67d472d94d5
1,500
PASSED
#include <iostream> #include <random> #include <chrono> #include <algorithm> #include <set> #include <cstring> #define rep(i, x) for(int i = 0; i < x; i++) using namespace std; typedef long long ll; const ll MOD = (ll)1e9 + 7; const int N = 3e5+5, inf = 1e9+5; ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD;...
C++
a608eda195166231d14fbeae9c8b31fa
87756d3344dac921ffc3512fb50a61d9
1,500
PASSED
#include <bits/stdc++.h> #include <chrono> #include <unordered_map> #include <unordered_set> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i=a; i<=b; i++) #define FORD(i, a, b) for (int i=a; i<=b; i--) #define FOREACH(a, b) for (auto&(a) : (b)) #define MAX(a, b) a = max(a, b) #define MIN(a...
C++
a608eda195166231d14fbeae9c8b31fa
d260aad58774c6be9bc5d601e14d81dc
1,500
PASSED
#include <bits/stdc++.h> #include <chrono> #include <unordered_map> #include <unordered_set> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i=a; i<=b; i++) #define FORD(i, a, b) for (int i=a; i<=b; i--) #define FOREACH(a, b) for (auto&(a) : (b)) #define MAX(a, b) a = max(a, b) #define MIN(a...
C++
a608eda195166231d14fbeae9c8b31fa
7ec7ec11461f2f05f57a07f08d23b3b2
1,500
PASSED
#include <bits/stdc++.h> #include <chrono> #include <unordered_map> #include <unordered_set> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i=a; i<=b; i++) #define FORD(i, a, b) for (int i=a; i<=b; i--) #define FOREACH(a, b) for (auto&(a) : (b)) #define MAX(a, b) a = max(a, b) #define MIN(a...
C++
a608eda195166231d14fbeae9c8b31fa
a8068f5b0625d274aa38ca32d9f468f5
1,500
PASSED
#include <iostream> using namespace std; const int N = 3e5+2; int tree[4*N]; int arr[N]; void solve(int val,int l,int r) { for(l;l<=r;l++) if(l!=val && arr[l]==0) arr[l] = val; } void update(int node,int l,int r ,int Qleft, int Qright , int val) { if(l > Qright || r < Qleft )return; if(l >=...
C++
a608eda195166231d14fbeae9c8b31fa
35731cae6c82c6f77decd3aaebbb346a
1,500
PASSED
#include<bits/stdc++.h> using namespace std; const int MAXN = 2e5; long long int sweets[MAXN + 1], output[MAXN + 1], mSums[MAXN + 1]; int main() { ios::sync_with_stdio(0); cin.tie(NULL); long long int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> sweets[i]; sort(sweets, sweets+n); ...
C++
af8ac55aa2594350226653c8d5ff47e4
27340664a87dec064645854302ad6ef3
1,500
PASSED
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); long long n, m; std::cin >> n >> m; std::vector<long long> a(n); for (int i = 0; i < n; ++i) { std::cin >> a[i]; } std::sort(a.begin(), a.end()); std::vector<std::vector<long long>> level(m); for (int...
C++
af8ac55aa2594350226653c8d5ff47e4
2300afbe4cf14856c3d0424d061eb5ac
1,500
PASSED
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; std::vector<int> a(n); for (int i = 0; i < n; ++i) { std::cin >> a[i]; } std::sort(a.begin(), a.end()); std::vector<long long> sum(m); std::vector<long long> ans(n, 0); ...
C++
af8ac55aa2594350226653c8d5ff47e4
47c007af1c1cae61efcecfee92f3f34f
1,500
PASSED
#include<bits/stdc++.h> using namespace std; int main() {long long int n,m,truss; cin >> n>>m; long long int b[n+1]; b[0]=0; for(long long int i=1;i<n+1;++i) {cin >> b[i];} sort(b,b+n+1); truss=b[1]; long long int a[(n/m)+1][m]; for(long long int j=0;j<m;++j) {fo...
C++
af8ac55aa2594350226653c8d5ff47e4
0fa0bccc91ff45c46e62c9f73478e566
1,500
PASSED
#include <iostream> #include <vector> #include <algorithm> int main() { int n, m, k; std :: cin >> n >> m; std::vector<long long> sweets( n + 10, 0 ); std::vector<long long> res( n + 10, 0 ); for ( int i = 0; i < n; ++i ) { int x; std :: cin >> sweets[ i ]; } std::so...
C++
af8ac55aa2594350226653c8d5ff47e4
55197cdf235304006196c967e760fc21
1,500
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define mx 200005 ll a[mx]; ll cum[mx]; ll cmm[mx]; vector<ll>v; int main() { ll n,m,i,j,k,res,cc,ans,sum; cum[0]=0; scanf("%lld %lld",&n,&m); for(i=1;i<=n;i++) { scanf("%lld",&a[i]); // cum[i]=cum[i-1]+a[i]; ...
C++
af8ac55aa2594350226653c8d5ff47e4
ea54cbb83b34be102a5ec3f7113c70bd
1,500
PASSED
/* Author: Vo Quoc Thang Codeforces */ #include<iostream> #include<math.h> #include<algorithm> #include<vector> #include<map> #define FOR(i,a,b) for(int i=a;i<b;i++) #define RFOR(i,a,b) for(int i=b;i>a;i--) #define mp make_pair #define pb push_back #define X first #define Y second #define ll long long int c...
C++
af8ac55aa2594350226653c8d5ff47e4
e4f93817c402abe38859e80d2de37627
1,500
PASSED
#include<bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 99, MOD = 1e9 + 7, INF = 0x3f3f3f3f; long long n, m, ai[MAXN], ans[MAXN], pre[MAXN]; int main() { scanf("%lld%lld", &n, &m); for (int i = 1; i <=n; i++) scanf("%lld", &ai[i]); sort(ai+1, ai+1 + n); for (int i = 1; i <= n; i++)...
C++
af8ac55aa2594350226653c8d5ff47e4
46bc8e726cd73bdb34d6c4888fa0f6e6
1,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef string str; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<ld> vd; typedef vector<str> vs; typedef v...
C++
af8ac55aa2594350226653c8d5ff47e4
976e5da166c3213a7513ad2e5761164d
1,500
PASSED
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long int sweets[n], coefficients[n]; for (int i = 0; i < n; i++) cin >> sweets[i]; sort(sweets, sweets + n); for (int i = 0; i < n; i++) coefficients[i] = 0; long long answer = 0; ...
C++
af8ac55aa2594350226653c8d5ff47e4
93a9cc4083bb8b10ca50371c1d50b376
1,500
PASSED
import java.math.BigInteger; import java.util.Scanner; public class test { static boolean s[]; static int a[] ; static BigInteger dp[][] = new BigInteger[5005][2005]; static int N; static boolean vis[][] = new boolean [5005][2005]; /** * @param args */ static BigInteger val[] = new BigInteger[2005]; stat...
Java
217a3a48b927213f4d5e0a19048e2a32
ffd4c0ad29e54cfa52827892dbf00cb6
2,000
PASSED
import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; public class Main { static int n; static ArrayList<pair> values; static BigInteger[] sv; static BigInteger dp(int ind) { if (ind == n) return BigInteger.ZERO; if (!sv[ind].equals(BigInteger.v...
Java
217a3a48b927213f4d5e0a19048e2a32
60ea785ae0e3ad4a4f598125a1228151
2,000
PASSED
import java.util.Scanner; import java.math.*; public class Main{ public static void main(String[] args){ BigInteger mayor[] = new BigInteger[5001]; int arr[] = new int[5001]; boolean gano[] = new boolean[5001]; int donde, n; BigInteger tengo; Scanner in = new Scanner(...
Java
217a3a48b927213f4d5e0a19048e2a32
527618276eb0df95892a108d45a2bce3
2,000
PASSED
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ //InputStream inputStream = new File("input.txt"); //OutputStream outputStream = new File("output.txt"); //Scanner in = new Scanner(new Fi...
Java
217a3a48b927213f4d5e0a19048e2a32
1c27d1eef7029ba19d285094033edaae
2,000
PASSED
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ //InputStream inputStream = new File("input.txt"); //OutputStream outputStream = new File("output.txt"); //Scanner in = new Scanner(new Fi...
Java
217a3a48b927213f4d5e0a19048e2a32
c733077a86b310cf6ef1e0f042eb6ad2
2,000
PASSED