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<iostream> #include<vector> #include<set> #include<queue> #include<map> #include<algorithm> #include<cstring> #include<string> #include<cassert> #include<cmath> #include<climits> #include<iomanip> #include<stack> #include<unordered_map> #include<bitset> #include<limits> #include<complex> #include<array> #includ...
C++
83167aa49d0993f64a04003f97d03374
c45de4f18e67997c42f64df3b33f69f6
2,400
PASSED
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <unordered_map> #include <map> #include <set> #include <unordered_set> #include <vector> #include <cmath> #include <string> #include <queue> #include <stack> #include <ctime> #include <unordered_map> using namespace std; const...
C++
83167aa49d0993f64a04003f97d03374
2c3d5e5720e260ad8230709e057fac11
2,400
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; const int N = 1e6 + 5; int n, m, a[N], b[N], l[N], r[N << 1], X; bool mark[N]; vector <int> vec; inline void compress() { for (int i = 0; i < n; i++) { vec.push_back(a[i]); vec.push_back(b[i]); } sort(vec.beg...
C++
83167aa49d0993f64a04003f97d03374
ad98152edf070f0dbb0ad1a4d65378e1
2,400
PASSED
#include <cstdio> #include <map> #include <vector> #include <algorithm> using pii = std::pair<int, int>; const int max_n = 2 * 1000 * 1000; int n, a, b, pos = 0, rank[max_n], parent[max_n], edges[max_n], nodes[max_n]; pii largest[max_n]; std::map<int, int> M; std::vector< std::pair<int, int> > V; pii pair_max(co...
C++
83167aa49d0993f64a04003f97d03374
9bdcb2fa86823feebcd75f4ff0a393f7
2,400
PASSED
#include <algorithm> #include <functional> #include <cmath> #include <limits> #include <cfloat> #include <cstdio> #include <iomanip> #include <ios> #include <iostream> #include <fstream> #include <sstream> #include <string> #include <array> #include <list> #include <map> #include <queue> #include <set> #include <stack>...
C++
83167aa49d0993f64a04003f97d03374
e94e595a1d1b222fdff175b4b9689ebb
2,400
PASSED
#include <algorithm> #include <functional> #include <cmath> #include <limits> #include <cfloat> #include <cstdio> #include <iomanip> #include <ios> #include <iostream> #include <fstream> #include <sstream> #include <string> #include <array> #include <list> #include <map> #include <queue> #include <set> #include <stack>...
C++
83167aa49d0993f64a04003f97d03374
a3de748efe7dbb82565a4dcd53032a18
2,400
PASSED
#include<bits/stdc++.h> #pragma GCC optimize ("O2") using namespace std; #define pb emplace_back #define fi first #define se second #define all(x) x.begin(), x.end() #define vi vector #define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0) #define forn(i, l, r) for(int i = l; i <= r; i++) #define pii pair<int,i...
C++
83167aa49d0993f64a04003f97d03374
503d4f07ac34a0e03b2d947ef05cf4ac
2,400
PASSED
#include<bits/stdc++.h> using namespace std; #define pb emplace_back #define fi first #define se second #define all(x) x.begin(), x.end() #define vi vector #define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0) #define forn(i, l, r) for(int i = l; i <= r; i++) #define pii pair<int,int> #define f80 long double ...
C++
83167aa49d0993f64a04003f97d03374
956e9225f35b2fc2fca52fb48efe0fde
2,400
PASSED
#include<bits/stdc++.h> using namespace std; #define pb emplace_back #define fi first #define se second #define all(x) x.begin(), x.end() #define vi vector #define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0) #define forn(i, l, r) for(int i = l; i <= r; i++) #define pii pair<int,int> #define f80 long double ...
C++
83167aa49d0993f64a04003f97d03374
a039641e7b26312597ca55812a82e683
2,400
PASSED
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("O2") #define pb emplace_back #define fi first #define se second #define all(x) x.begin(), x.end() #define vi vector #define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0) #define forn(i, l, r) for(int i = l; i <= r; i++) #define pii pair<int,i...
C++
83167aa49d0993f64a04003f97d03374
d547d526fb1fea3d5df3c7a7aaee9310
2,400
PASSED
#include <stdio.h> #include <iostream> using namespace std; long n,m,i,j,mxm=-1,c,ganador,arr[120],mxn,k; int main() { cin>>n>>m; for(i=0;i<m;i++) { mxm=-1; for(j=0;j<n;j++) { cin>>c; if(c>mxm) { mxm=c; ganado...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
6ff9f6af33d13b3932750a71fcfed514
1,100
PASSED
//============================================================================ // Name : cf_round_316.cpp // Author : toma // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
6a22bdcdac2a232d08b385bcc49acecb
1,100
PASSED
#include<map> #include<set> #include<list> #include<cmath> #include<ctime> #include<deque> #include<queue> #include<stack> #include<bitset> #include<cctype> #include<cstdio> #include<string> #include<vector> #include<cstdlib> #include<cstdio> #include<cstring> #include<iomanip> #include<sstream> #include<iostream> #inc...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
7e9c178a54578e1360c9de4d2ae63c0a
1,100
PASSED
#include<stdio.h> int main() { int n,m; //n 為候選人數量 m 是城市數目 int i,j; while(scanf("%d%d",&n,&m)==2) { int v[n+5]; // 候選人勝利城市數目 for(i=1;i<=n;i++) { v[i]=0; } long int rmax=-1,rindex=101; //真勝利者的數據 for(i=1;i<=m;i++) { int m=-1,index=101; //紀錄最大值及其指標 ...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
96438f5323d9f2fd536735f0ee80f80d
1,100
PASSED
# include <bits/stdc++.h> using namespace std; //ifstream in ("n1.inp"); int a[200], n, k, m, vt; int main() { cin >> n >> m; for (int i=1; i<=m; i++) { int ln = -1; for (int j=1; j<=n; j++) { cin >> k; if (k > ln) { ln = k; ...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
8d758af9fb2f762bdd20313253bd3236
1,100
PASSED
# include <bits/stdc++.h> using namespace std; //ifstream in ("n1.inp"); int n, m, a[120], vt, t; int main() { cin >> n >> m; for (int i=1; i<=m; i++) { int ln = 0; vt =1; for (int j=1; j<=n; j++) { cin >> t; if (t>ln) { ln = t; ...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
ba993e2a45f38e4bc65d7ad65fbb9e27
1,100
PASSED
#include <algorithm> #include<iostream> using namespace std; int winners[1000]; int main(){ int n, m; cin>>n>> m; for(int i=1;i<=m;i++){ int maxn=-1,index=0,votes ; for(int j=1;j<=n;j++){ cin>>votes ; if(votes>maxn){ maxn=votes; index=...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
62fec6eef637a1d2badc49978180442a
1,100
PASSED
#include<iostream> using namespace std; int h[1000],a[1000],n,m; int main() { cin >> n >> m; for (int i=1;i<=m;i++) { for (int j=1;j<=n;j++) cin >> h[j]; int k=1; for (int j=2;j<=n;j++) if (h[k]<h[j]) k=j; a[k]++; } int ans=1; for (int i=2;i<=n;i++) if (a[i]>a[ans]) ans=i; cout << a...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
fa8e6d1afd93a74c4b99867426234c34
1,100
PASSED
#include <bits/stdc++.h> using namespace std; int main() { long int n,m; cin >>n>>m; long int ara[n+5][m+5]; long int counter=0,temp=0,mx=0; long int aray[n+1]; long int i,j; memset(aray,0,sizeof(aray)); for(i=1;i<=m;i++) { for(j=1;j<=n;j++) { ...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
9a7958d1375628ea80421b93bc177d63
1,100
PASSED
#include <stdio.h> int main() { int n, m, maxGolosovUGoroda = 0, kandidatGoroda = 0, winner = 0; scanf("%d%d", &n, &m); int a[100][100] = {0}, golosa[n] = {0}; for(int i=0;i<n;i++) golosa[i] = 0; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { scanf("%d", &a[i][j]); if (a[i][j] > maxGolosovUGoroda) { ka...
C++
b20e98f2ea0eb48f790dcc5dd39344d3
4f11618d6c56e357902e3de760c2868d
1,100
PASSED
#include<stdio.h> int main() { int t,i,a; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d",&a); if((360%(180-a))==0) printf("YES\n"); else printf("NO\n"); } }
C
9037f487a426ead347baa803955b2c00
20f39ec42c4d09a1257b2b609ac28a1f
1,100
PASSED
#include <stdio.h> int main() { int n,k,a[200],i; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { k=360%(180-a[i]); if(k==0&&a[i]>=60) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
C
9037f487a426ead347baa803955b2c00
be0fd919e682aa44b4652a52e7fbc38b
1,100
PASSED
main() { int T; scanf("%d",&T); while(T--) { int ang; scanf("%d",&ang); if(360%(180-ang)==0) printf("YES\n"); else printf("NO\n"); } return 0; }
C
9037f487a426ead347baa803955b2c00
1b764051e88fc95e39776ccf65e2f9ce
1,100
PASSED
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int a = scanner.nextInt(); if (a < 60) { System.out.println("NO");...
Java
9037f487a426ead347baa803955b2c00
8ba88a6ed3bb843e065a2444453e2eae
1,100
PASSED
import java.util.*; import java.lang.Math; public class hello { public static void main (String[] args) throws java.lang.Exception { Scanner scan = new Scanner(System.in); int ans = 0; int a = scan.nextInt(); ArrayList<Double> list = new ArrayList<Double>(); Str...
Java
9037f487a426ead347baa803955b2c00
71e59fe48b9af6011a0b75e5cf35e60d
1,100
PASSED
import java.util.*; public class _270A_Fancy_Fence { public static void main(String[] args) { Scanner input= new Scanner (System.in); int n= input.nextInt(),i; int a[]= new int[n]; for (i=0;i<n;i++) a[i]= input.nextInt(); for (i=0;i<n;i++) { ...
Java
9037f487a426ead347baa803955b2c00
4fc89b0d778f4f47471899a3b3aee9de
1,100
PASSED
import java.util.*; public class _270A_Fancy_Fence { public static void main(String[] args) { Scanner input= new Scanner (System.in); int n= input.nextInt(),i; int a[]= new int[n]; for (i=0;i<n;i++) { a[i]= input.nextInt(); if(360%(180-a[i])==0) ...
Java
9037f487a426ead347baa803955b2c00
7f1145fbff79056efd5e8f45072313d8
1,100
PASSED
import java.util.*; public class Solution{ public static void main (String args[]){ Scanner sc = new Scanner (System.in); int t = sc.nextInt(); while (t --> 0){ int a = sc.nextInt(); int s = a - 180; int ans = -360%s; ...
Java
9037f487a426ead347baa803955b2c00
d6f13ae8649d9dec1134c187bfc2c2e3
1,100
PASSED
import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.io.BufferedReader; import java.util.Map; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; import java.util.Arrays; import java.util.PriorityQueue; pub...
Java
9037f487a426ead347baa803955b2c00
7f7e0575295f984361423547fdd3044b
1,100
PASSED
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); for (int t = in.nextInt(); t --> 0 ;) { int a = in.nextInt(); boolean x = false; int c = a + a; for (int i = 3; i < 1000000; ++i) { ...
Java
9037f487a426ead347baa803955b2c00
3a49ac6107c3f40fc332014580d83563
1,100
PASSED
/* @resources: codeforces @date: 2017-2-26 @author: QuanQqqqq @algorithm: binary search */ #include <bits/stdc++.h> #define maxn 200005 using namespace std; int mark[maxn],a[maxn]; char str1[maxn],str2[maxn]; int n,m; bool check(int p){ memset(mark,0,sizeof(mark)); int i,j; for(i = 1;i <= p;i++){ mark[a[i] - 1...
C++
0aed14262c135d1624df9814078031ae
b86c20065f79be902a09ff0f23ebb6a2
1,700
PASSED
#include <stdio.h> #include <algorithm> #include <iostream> #include <vector> #include <map> #include <set> #include <stdlib.h> #include <math.h> #include <string> #include <time.h> #include <string.h> #include <queue> #include <stack> #include <cstring> #define MOD 1000000007 #define ll long long int #define rep(i,a,...
C++
0aed14262c135d1624df9814078031ae
938e1b29bfa8c3f08b37bee56fdb625d
1,700
PASSED
/* *********************************************************************** > File Name: wust.cpp > Author: Key > Mail: keyld777@gmail.com > Created Time: Sun 15 Jan 2017 09:55:25 PM CST ********************************************************************** */ #include <algorithm> #include <cstdio> #include <cstrin...
C++
0aed14262c135d1624df9814078031ae
f4a176ba36d753e9ee3b3cbb828cc358
1,700
PASSED
#include <iostream> #include <algorithm> #include <string> #include<queue> #include <vector> #include <set> #include<cmath> #include<cstring> #include <map> #include<stdio.h> #include<stack> #include<iomanip> #include<functional> #include<sstream> using namespace std; string s,ss,c; int main() { cin>>s>>ss; c=s; vec...
C++
0aed14262c135d1624df9814078031ae
52e02527f44d3f09e23c5b24e1feec84
1,700
PASSED
#include <bits/stdc++.h> #define fi first #define ll long long #define sec second using namespace std; const int MAXN=2e5+10; const ll INF=1e9+10; const int maxn=2e3+10; const int mx=2e2+10; int a[MAXN]; string s,p; string dp; string obtain(int u){ dp=s; for(int i=1;i<=u;i++){ dp[a[i]]='0'; } re...
C++
0aed14262c135d1624df9814078031ae
1aa2bf740e99f3d658f2dc84d771ab9d
1,700
PASSED
#include<bits/stdc++.h> using namespace std; string s1,s2; int p[200005]; bool exists(int mid) { mid++; char s[200005]; for(int i=0;i<s1.length();i++) s[i]='\0'; for(int i=mid;i<s1.length();i++) { s[p[i]-1]=s1[p[i]-1]; } int ind=s2.length()-1; int flag=1; for(int i=s1.length()-1;i>=0;i--) { ...
C++
0aed14262c135d1624df9814078031ae
e7be1de7cff959d864338efce986193f
1,700
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define pp pair<ll,ll> #define f first #define s second #define pb push_back int a[200005],n,k; string s1,s2; vector<int> v; bool solve(int val){ v.clear(); for(int i = val ; i < n ; i++ )v.pb(a[i]); sort(v.begin(),v.end()); int k = 0;...
C++
0aed14262c135d1624df9814078031ae
d8ec8cda8856aef96d89bc6626b45539
1,700
PASSED
#include<cstdio> #include<algorithm> #include<iostream> #include<map> #include<vector> #include<utility> using namespace std; string s,s1; int n,b[200000+100],a[200000+100],l,r; int moze(int x) { for (int i=0;i<=n;i++) b[i]=0; for (int i=1;i<=x;i++) b[a[i]-1]++; int pok=0; for (int i=...
C++
0aed14262c135d1624df9814078031ae
2c0d21e7f34e0c0c8c1ec63da01411f3
1,700
PASSED
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repp(i,a,b) for(ll i=a;i<=b;i++) #define reff(i,a,b) for(ll i=a;i>=b;i--) #define ll long long int #define pll pair<ll,ll> #define fill(a,x) memset(a,x,sizeof(a)) #define mb make_pair #define pb push_back #define F first #define S...
C++
0aed14262c135d1624df9814078031ae
c83a6cc7d9e42232acbb6d6e4151b7e2
1,700
PASSED
#include <bits/stdc++.h> #define ENDL '\n' using namespace std; typedef long long ulli; const int MAX = 2000007; string n, k; bool eliminados[MAX]; int arr[MAX]; bool funcion(int m) { for(int i=0; i<m; ++i) eliminados[arr[i]-1]=true; int aux=0, cont=0; while(cont<k.size()) { bool auxili...
C++
0aed14262c135d1624df9814078031ae
05bb8295b22bf0c7c0ac34480c904766
1,700
PASSED
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; constexpr int inf = 1e9; class union_find { public: union_find(int n) : par(n, -1) {} int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); } void unite(int x, int y) { x = root(x), y = root(y); if(x ==...
C++
1fdba13aaa1a417a229817b40af7225f
d0a3d030fd06c8188b9455fe1e32549f
1,900
PASSED
#include <cstdio> using namespace std; const int maxn = 200000 + 10; int n, q, par[maxn], next[maxn]; int seek(int x) { return par[x] == x ? x : par[x] = seek(par[x]); } int main() { scanf("%d %d", &n, &q); for (int i = 0; i <= n; i++) par[i] = i, next[i] = i + 1; while (q--) { int...
C++
1fdba13aaa1a417a229817b40af7225f
81c7e43f7d27897d7bfd5fe970f1ad89
1,900
PASSED
# include<iostream> # include <cstring> # include <cstdio> using namespace std; int fa[200005]; int nex[200005]; int fin(int k) { if(fa[k]==k) return k; return fa[k]= fin(fa[k]); } void Union(int p,int a,int b) { int p1,p2; if(p==1) { p1 = fin(a); p2 = fin(b); fa[p1] = p2; ...
C++
1fdba13aaa1a417a229817b40af7225f
a5ee6f65893b22b0a3d34c7db22f653c
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define maxn 200002 #define FOR(i, l, r) for (int i=l; i<=r; ++i) #define FORD(i, r, l) for (int i=r; i>=l; --i) #define REP(i, r) for (int i=0; i<(int)r; ++i) #define REPD(i, r) for (int i=(int)r-1; i>=0; --i) #define fi first #define se second #define mk make_pair #defin...
C++
1fdba13aaa1a417a229817b40af7225f
299602cf832bc42e92544309b0b7e514
1,900
PASSED
#include <iostream> #include <numeric> #include <algorithm> using namespace std; int const maxn = 2e6+9; int n, m, d[maxn], fa[maxn], upd[maxn]; int get (int a) { return fa[a] == -1 ? a : fa[a] = get(fa[a]); } int getrng (int a) { return upd[a] == a ? a : upd[a] = getrng(upd[a]); } void add (int a, int b) {...
C++
1fdba13aaa1a417a229817b40af7225f
2f5f5bc2ead458ac2eafaf45908de968
1,900
PASSED
#define ll long long int #include<stdio.h> #include<stdlib.h> ll nxt[200005]; struct subset { ll parent, rank; }; struct subset *subsets; ll find(ll i) { if (subsets[i].parent != i) { subsets[i].parent = find(subsets[i].parent); } return subsets[i].parent; } void unin(ll x, ll y) { ll xroot = find(x); ll yro...
C++
1fdba13aaa1a417a229817b40af7225f
8f848c3438fb6dfea9913cef79a16ae5
1,900
PASSED
// scanf() ^^ #include<bits/stdc++.h> using namespace std; const int N = 2e5+10; int parents[N], component[N], n, q, type, x, y; void make_set(){ for(int i = 1; i <= n; ++i){ parents[i] = i; component[i] = i; } } int find(int x){ if(parents[x] == x) return x; return parents[x] ...
C++
1fdba13aaa1a417a229817b40af7225f
7194365ed6e72da64bb73c1f0af8f9f5
1,900
PASSED
// Satyajit Tourani #include<bits/stdc++.h> using namespace std; #define LL long long int #define ULL unsigned long long #define lc idx * 2 #define rc lc | 1 #define pb push_back #define pf push_front #define S second #define F first #define m...
C++
1fdba13aaa1a417a229817b40af7225f
de4410d16f0601ca56ecfa5445f1d65f
1,900
PASSED
// Satyajit Tourani #include<bits/stdc++.h> using namespace std; #define LL long long int #define ULL unsigned long long #define lc idx * 2 #define rc lc | 1 #define pb push_back #define pf push_front #define S second #define F first #define m...
C++
1fdba13aaa1a417a229817b40af7225f
18d985e5da5a521b73c975449c5fe7b7
1,900
PASSED
// Satyajit Tourani #include<bits/stdc++.h> using namespace std; #define LL long long int #define ULL unsigned long long #define lc idx * 2 #define rc lc | 1 #define pb push_back #define pf push_front #define S second #define F first #define m...
C++
1fdba13aaa1a417a229817b40af7225f
ef845d10db3d5e5c860f82a1c25e17b7
1,900
PASSED
#include <iostream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring...
C++
edf394051c6b35f593abd4c34b091eae
086cf9a9816d96a968ec0b2eff7c5934
1,000
PASSED
#include <bits/stdc++.h> using namespace std; long long t,x,y,a,b,c; int main() { cin>>t; while(t--){ cin>>x>>y>>a>>b; c=0; if(x>=y) { if(2*a>b)c=y*b+(x-y)*a; else c=(x+y)*a; } if(y>x) { if(2*a>b) c=x*b+(y-x)*a; else c=(x+y)*a; } cout<<c<<endl; } }
C++
edf394051c6b35f593abd4c34b091eae
255a69546fca62c6e2d43896bcc3ee2f
1,000
PASSED
#include <bits/stdc++.h> #include <algorithm> using namespace std; int main() { int t; cin >> t; while (t--) { long long int x, y, a, b; cin >> x >> y >> a >> b; long long int sum = 0; if (x * y > 0) { if (b > 2 * a) { if (x > 0) { sum = (x + y) * a; } else { su...
C++
edf394051c6b35f593abd4c34b091eae
307b4e46f5e02539522469b53a21e769
1,000
PASSED
#include<bits/stdc++.h> using namespace std; main() { int t; cin>>t; while(t--) { long long x,y,a,b; cin>>x>>y>>a>>b; cout<<min(b*(min(y,x))+a*(max(y,x)-min(y,x)),a*(x+y))<<endl; } }
C++
edf394051c6b35f593abd4c34b091eae
c258c987f3155d0687b486c00983b029
1,000
PASSED
/// Author: Sarfaraz Alam # include <bits/stdc++.h> # define pb push_back # define ll long long # define fi first # define se second # define all(vc) vc.begin(),vc.end() # define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) # define DEBUG typedef unsigned long long int ull; using na...
C++
edf394051c6b35f593abd4c34b091eae
5de4a41a18f2a343cb013a391db494f4
1,000
PASSED
/// Author: Sarfaraz Alam # include <bits/stdc++.h> # define pb push_back # define ll long long # define fi first # define se second # define all(vc) vc.begin(),vc.end() # define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) # define DEBUG typedef unsigned long long int ull; using namespace std;...
C++
edf394051c6b35f593abd4c34b091eae
2d96a27b0474974d779558bfcb5583d2
1,000
PASSED
/// Author: Sarfaraz Alam # include <bits/stdc++.h> # define pb push_back # define ll long long # define fi first # define se second # define all(vc) vc.begin(),vc.end() # define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) # define DEBUG typedef unsigned long long int ull; using namespace std;...
C++
edf394051c6b35f593abd4c34b091eae
04d9c62a88356caf3e7ed638e68a6646
1,000
PASSED
/// Author: Sarfaraz Alam # include <bits/stdc++.h> # define pb push_back # define ll long long # define fi first # define se second # define all(vc) vc.begin(),vc.end() # define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) # define DEBUG typedef unsigned long long int ull; using namespace std;...
C++
edf394051c6b35f593abd4c34b091eae
ffe2e5159fea107b6096cb9692a4e099
1,000
PASSED
#include<bits/stdc++.h> #define Fast std::ios::sync_with_stdio(false); cin.tie(NULL); #define pb push_back #define mk make_pair #define fi first #define se second #define all(x) x.begin(),x.end() #define p pair<ll,ll> #define in insert #define endl '\n' #define PI (double)(3.14159265358979323846264338327950) u...
C++
edf394051c6b35f593abd4c34b091eae
82bab137e66bda7eaa6d96fd8a229710
1,000
PASSED
#include <iostream> using namespace std; int main() { int t; cin>>t; while(t--){ long long int x, y, a, b; cin>>x>>y; cin>>a>>b; long long int m = min(x,y); long long int M = max(x,y); long long int s1 = (m*b) + ((M-m)*a); long long int s2 = a*(x+y); ...
C++
edf394051c6b35f593abd4c34b091eae
83c1454bc878ab7db4360f6b28362604
1,000
PASSED
def ii(): return int(input()) def mi(): return map(int, input().split()) if __name__ == '__main__': for _ in range(ii()): n = ii() # if n == 3: # print("2\n3 1\n2 2") # continue if n == 2: print("2\n2 1") continue l = list(range(1, ...
Python
591372383cf3624f69793c41370022de
88084dde61bbebdebe163309a2bda179
1,000
PASSED
from math import sqrt,ceil,gcd from collections import defaultdict import heapq def modInverse(b,m): g = gcd(b, m) if (g != 1): # print("Inverse doesn't exist") return -1 else: # If b and m are relatively prime, # then modulo inverse is b^(m-2) mode m return pow(b, ...
Python
591372383cf3624f69793c41370022de
b6d15cabd6483ef598063080f0ccd584
1,000
PASSED
from sys import stdin import math t = int(stdin.readline().strip()) for _ in range(t): n = int(stdin.readline().strip()) base = n print(2) while n != 1: print(base, n - 1) base = math.ceil((base + (n - 1)) / 2) n -= 1
Python
591372383cf3624f69793c41370022de
870f33f3cbf6367171d4e1f5a9da2df3
1,000
PASSED
import math b=[] for i in range(int(input())): m = int(input()) a = (m + (m-1))/2 print(2) print(m,m-1) for t in range(m-2,0,-1): print(int(math.ceil(a)),t) a = (math.ceil(a) + t)/2
Python
591372383cf3624f69793c41370022de
6a7f7a21b22b811be823b34c1b0d77f0
1,000
PASSED
t = int(input()) for _ in range(0,t): n = int(input()) print(2) print(n,n-1) for i in range(0,n-2): print(n-i,n-i-2)
Python
591372383cf3624f69793c41370022de
aaa4f412d01a42aa1a2d9e654cf4fcae
1,000
PASSED
t = int(input()) for _ in range(0,t): n = int(input()) A = [int(x) for x in range(1,n+1)] k=n-1 last = n-1 p=[] while k >0 : k-=1 if (A[last]+A[last-1])%2 == 0: p.append([A[last],A[last-1]]) A[last-1] = (A[last-1]+A[last])//2 last-=1...
Python
591372383cf3624f69793c41370022de
ed0af19481829d7e43fd89dcf3cb42ee
1,000
PASSED
# cook your dish here from math import ceil for _ in range(int(input())): n=int(input()) # n,k=map(int,input().split()) # l=list(map(int,input().split())) # l.sort() l=[] print(2) x=n y=n-1 for i in range(n-1): print(x,y) ...
Python
591372383cf3624f69793c41370022de
6c4ff9cedebc5591d0e095c92f46307b
1,000
PASSED
from math import * t = int(input()) for _ in range(t): n = int(input()) l = list() ll = list() for i in range(1, n+1): l.append(i) while len(l) > 1: a = l.pop() b = l.pop() ll.append(a) ll.append(b) l.append(ceil((a+b)/2)) print(*l) j = 0 while j < len(ll): print(ll[j], ll[j...
Python
591372383cf3624f69793c41370022de
2ca8d5a2db267205120e086f97d46d2b
1,000
PASSED
for _ in range(int(input())): n=int(input()) if n==2: print(2) print(1,2) else: print(2) print(n,n-2) t=n-1 print(t,t) for i in range(n-3): print(t,t-2) t-=1
Python
591372383cf3624f69793c41370022de
cd8aa5f1a1d761f6006449cd4d5bce39
1,000
PASSED
for _ in range(int(input())): n=int(input()) print(2) if n>2: print(n-2,n) print(n-1,n-1) for i in range(n-3,0,-1): print(i+2,i) else: print(1,2)
Python
591372383cf3624f69793c41370022de
242ef3d3c1f0418079186d1f62fbf4fe
1,000
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=85; const int maxm=1e5+5; int dp[maxm]; int n,m; int a[maxn],s[maxn]; int l[maxn]; int r[maxn]; int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i],&s[i]); l[i]=max(0,a[i]-s[i]); r[i]=min(m,a[i]+s[i]); } dp[m]=0; for(int j=m-...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
c755e486c902584b812070ce9739ab0e
2,200
PASSED
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 80, MAXM = 100000, INF = INT_MAX / 2; pair<int, int> ant[MAXN + 2]; int dp[MAXM + 2]; int main() { int n, m; cin >> n >> m; for(int i = 0; i < n; i++) cin >> ant[i].first >> ant[i].second; sort(ant, ant + n); ant[n].first = INT_MAX; fill(dp,...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
875a9321790f11bcbc505841a4ac6fcf
2,200
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef pair<pll,ll> plll; typedef pair<pll,pll> ppll; typedef long double ld; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fst first #define snd second #define ins insert #define pb p...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
be16ccdc6a3e0da2a9265303d18264d9
2,200
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef pair<pll,ll> plll; typedef pair<pll,pll> ppll; typedef long double ld; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fst first #define snd second #define ins insert #define pb p...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
2a623fa050be2a5f0e1bc44baa659939
2,200
PASSED
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; pii p[81]; int dp[200101]; int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d%d",&p[i].first,&p[i].second),p[i].first-=p[i].second,p[i].second=p[i].second*2+p[i].first; sort(p+1,p+n+1); memset(dp,0x3f,sizeo...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
e5671875f78d92a89f502358e5808ca8
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn = 101; const int maxm = 1e5+7; pair<int,int>L[maxn]; int n,m,x[maxn],s[maxn]; int dp[maxm]; int main(){ cin>>n>>m; for(int i=0;i<n;i++){ cin>>x[i]>>s[i]; } for(int i=1;i<=m;i++){ dp[i]=100000000; for(int j=0;j<n;j++){ ...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
0b1bcb4e5eca887587c922e7592ffab8
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn = 101; const int maxm = 1e5+7; pair<int,int>L[maxn]; int n,m,x[maxn],s[maxn]; int dp[maxm]; int main(){ cin>>n>>m; for(int i=0;i<n;i++){ cin>>x[i]>>s[i]; } for(int i=1;i<=m;i++){ dp[i]=100000000; for(int j=0;j<n;j++){ ...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
c8c44352d7f5487505a528f3676d9eb6
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn = 101; const int maxm = 1e5+7; pair<int,int>L[maxn]; int n,m,x[maxn],s[maxn]; int dp[maxm]; int main(){ cin>>n>>m; for(int i=0;i<n;i++){ cin>>x[i]>>s[i]; } for(int i=1;i<=m;i++){ dp[i]=i; for(int j=0;j<n;j++){ ...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
1b69c5df3421d71116782666a1cd81fd
2,200
PASSED
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <algorithm> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #define PII pair<int,int> #define VI vector<int> #define VII vector<PII> #define PB push_back #define MP make_pair #define F first #define S se...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
eaab213a7625d9f5b397af5e304a99ea
2,200
PASSED
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <algorithm> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #define PII pair<int,int> #define VI vector<int> #define VII vector<PII> #define PB push_back #define MP make_pair #define F first #define S se...
C++
fccb8049e7b0f0bcd1dcd93620a86b5c
ccb897869bbcbbab32ac3b8368c24535
2,200
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL inf = 2e9; LL n, h, ans; bool judge(LL x){ LL us = 0, res = 0; if(x > h){ us = LL(1.0 * (x + h) * (x - h + 1) / 2 + 1.0 * (x + 1) * x / 2 - x); res = x + x - h; }else{ us = LL(1.0 * (x + 1) * x / 2); ...
C++
c35102fa418cbfdcb150b52d216040d9
b48389feb47aee4d815403bc84ae3ebb
2,100
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL inf = 1e18; LL n, h, ans; bool judge(LL x){ LL us = 0, res = 0; if(x > h){ us = (h + x) * (x - h + 1) / 2 + (x + 1) * x / 2 - x; res = x + x - h; }else{ us = (1 + x) * x / 2; res = x; } if...
C++
c35102fa418cbfdcb150b52d216040d9
828e3f5a5cc774ee7e5b9e3bd85aabd5
2,100
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL inf = 0x7f7f7f7f7f7f7f7f; LL n, h, ans; bool judge(LL x){ LL us = 0, res = 0; if(x > h){ us = LL(1.0 * (h + x) * (x - h + 1) / 2 + 1.0 * (x + 1) * x / 2 - x); res = x + x - h; }else{ us = LL(1.0 * (1 + x) ...
C++
c35102fa418cbfdcb150b52d216040d9
935ffc08cc7362004e844d15d7dc2b51
2,100
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long ll co(ll n) { double d=n; return (d*(d+1)>2e18); } int main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); ll n,h; cin>>n>>h; ll ind=-1,s=0,e=2*sqrtl(n); while(s<=e) { ll mid=(s+e>>1); if(mid*mid-(min(h,mid)*(min(h,mid)-1)/2)<...
C++
c35102fa418cbfdcb150b52d216040d9
a63be11cdb47e6abce2a99944754016b
2,100
PASSED
/* long long or int & the MAX_INT or MIN_INT */ /* the size of a[] & inline */ /* xx 396 */ #include<bits/stdc++.h> using namespace std; typedef long long ll; ll N,H,Min=1e18+10; inline bool solve_A(ll now){ ll x=(now+H-1)/2; ll A=x+1,B=x,C=H,D=H-1; if(A-C>0&&N*2/(A-C)<D) return true; if(D>0&&N*2/D<A-C) return ...
C++
c35102fa418cbfdcb150b52d216040d9
2205789f30f0f0898de8453ad46b8879
2,100
PASSED
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define pb push_back #define ls l,mid,rt<<1 #define rs mid+1,r,rt<<1|1 #define de(x) cout<< #x<<" = "<<x<<endl #define dd(x) cout<< #x<<" = "<<x<<" " #define sf scanf #define pf printf #define ...
C++
c35102fa418cbfdcb150b52d216040d9
0ef85285883c7645c938257e467bf651
2,100
PASSED
#include <bits/stdc++.h> using namespace std; long long ret(long long n) { unsigned long long x = (sqrt(8*n+1) -1)/2.0 ; unsigned long long y = (x*(x+1))/2; if(y>n) x--; return x; } long long n,h; long long solve(long long m) { long long t = m*m - (h*(h-1))/2; if(t>n) return 1...
C++
c35102fa418cbfdcb150b52d216040d9
09f2493b7d82cfa860131d3559a5b8f2
2,100
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define Db double int main() { ll n,h,top; cin>>n>>h; if((1.0+Db(h))*Db(h)>Db(n)*2.0) { top=ll(sqrt(Db(n<<1))); cout<<(top*(top+1)>=n<<1?top:top+1); exit(0); } n-=h*(h-1)>>1; top=ll(sqrt(Db(n)+Db(h)*(Db(h)-1.0))); n-=(h+top)*(top-h+1)-top;...
C++
c35102fa418cbfdcb150b52d216040d9
b3a11bca7f4922e6fd27d0b353f58be2
2,100
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define Db double int main() { ll n,h,top; cin>>n>>h; if((1.0+Db(h))*Db(h)>Db(n)*2.0) { top=ll(sqrt(Db(n<<1))); cout<<(top*(top+1)>=n<<1?top:top+1); exit(0); } n-=h*(h-1)>>1; top=ll(sqrt(Db(n)+Db(h)*(Db(h)-1))); n-=(h+top)*(top-h+1)-top; ...
C++
c35102fa418cbfdcb150b52d216040d9
e68e600e42a32048a351650f8eaa12e9
2,100
PASSED
/* *********************************************** Author :letter-song Created Time :2018/5/21 22:12:17 File Name :cfedu44.cpp ************************************************ */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <stack> #include <cmath...
C++
c35102fa418cbfdcb150b52d216040d9
dad5ba9942a46a666ad5b8c42df32a14
2,100
PASSED
#include<stdio.h> #define fr(i,n) for(i=0;i<n;i++) #define Fr(i,m,n) for(i=m;i<n;i++) int a[103],ans[103]; int main() { int n=0,x,k,i,flag=0; scanf("%d",&k); fr(i,k) {scanf("%d",&x); a[x]=1; } if(a[100]==1) ans[n++]=100; for(i=10;i<91;i+=10) { if(a[i]==1) { a...
C
6b7d6f5c07b313c57d52db6a48d3eeef
24b91e716ce27e08681332d0d4717313
1,600
PASSED
#include<stdio.h> #include<string.h> char a[105][5]; int hun=0,zero=0; void pf(void) { if(hun) { printf("100 "); } if(zero) { printf("0"); } } int main() { int n,i,eve=130,ten=130,one=130; int cont=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",a[i]); if(a[i][0]=='1'&&a[i][2]=='0') { hun=1; ...
C
6b7d6f5c07b313c57d52db6a48d3eeef
3cea4acbfacb4c22114d2394fb480b71
1,600
PASSED
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #define max(a,b) ((a)>(b))?(a):(b) #define min(a,b) ((a)<(b))?(a):(b) #define si(n) scanf("%d",&n) #define ss(s) scanf("%s",s) #define sort(a,n) qsort(a,n,sizeof(int),compare) #define pi(n) printf("%d ",n) #define ps(s) printf("%s",s) #define loop...
C
6b7d6f5c07b313c57d52db6a48d3eeef
15f14f3a036ecf887cbbc58470315180
1,600
PASSED
#include<stdio.h> #include<string.h> int aray[103], hold1[101], hold2[101]; int res[102]; int main() { int n ,i, j, k,l=0, three=0, two=0, one=0, zero=0, p; scanf("%d", &n); k=0; for(i=0;i<101;i++){ res[i]=-2; } for(i=0;i<n;i++){ scanf("%d", &aray[i]); if(aray[i]==100){ ...
C
6b7d6f5c07b313c57d52db6a48d3eeef
e2ba11d15f7a17dd60e7e963d37ed459
1,600
PASSED
#include<stdio.h> int main() { int k,ar[100],t=0,i,a[100],m=0,n=0,o=0,p=0,q=0,b,c,d,e; scanf("%d\n",&k); while(k--) { scanf("%d",&ar[t++]); } for(i=0;i<t;i++) { if(ar[i]==0) { a[m++]=ar[i]; } else if(ar[i]==100 && n==0) ...
C
6b7d6f5c07b313c57d52db6a48d3eeef
be79ad48a413e2eac16cf9e90f3f777e
1,600
PASSED
#include<stdio.h> int main() { int n,i,j=0,k=0,l=0,count=0,m=0,a=0,b=0,c=0; scanf("%d",&n); int arr[n],arr1[n]; for(i=0;i<n;i++) scanf("%d",&arr[i]); for(i=0;i<n;i++) { if(arr[i]==100) { if(a==0) { count++; a=1; arr1[j]=100; j++; } } else if(arr[i]%10==0&&arr[i]!=100&&arr[i]!=0) ...
C
6b7d6f5c07b313c57d52db6a48d3eeef
60745c38f2a9657eb96664b9b0d11e44
1,600
PASSED
#include<stdio.h> #include<string.h> int vis[110],b[110]; int main(){ int N,t; while(scanf("%d",&N)!=EOF){ memset(vis,0,sizeof(vis)); int i,j,ans=0,ca; for(i=0;i<N;i++){ scanf("%d",&t);ca=t; vis[t]++;} int ok1=0,ok2=0,ok3=0,t1,t2,t3,k=0; for(i=1;i<10;i++) if(vis[i]) {ok1=1;t1=i;break;} for(i=10;i<100;i+=10) if(vis[i]) ...
C
6b7d6f5c07b313c57d52db6a48d3eeef
708e4aa10db7fa5c89cd66b8fa416a3c
1,600
PASSED
#include <stdio.h> int main() { int n; int z=0, lt=0, lh1=0, lh2=0, h=0; int lts[9], lh1s[9], lh2s[80]; int i; int res[5]; scanf("%d\n",&n); for(i = 0; i<n; i++) { int d; scanf("%d",&d); if(d==0) { z++; } else if(d<10) { lts[lt++] = d; } else if...
C
6b7d6f5c07b313c57d52db6a48d3eeef
dfb898701f7f67c383cf4195e8400763
1,600
PASSED
#include <stdio.h> #include <stdlib.h> #include <string.h> struct node { int a; int b; int c; }; int main() { int n,i,flag=0,k=0,j,r,m,l=0,x,i1,min=0; struct node pr[1000]; char s[1000]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",s); r=0; flag=0; x...
C
6b7d6f5c07b313c57d52db6a48d3eeef
d1e49613e9a6607948fe75e2498b1fe1
1,600
PASSED
#include<stdio.h> #include<stdlib.h> int main() { int n; scanf("%d",&n); int x; int y=0; int ar[10]={0}; int i=0; int n2=n; int a=0,b=0,c=0,d=0; int arr[109]={0}; int u=0;; while(n>0) { scanf("%d",&x); arr[u]=x; u++; if(x==100 && a==0) { ar[i]=x; a++; y++; i++; } if(b==0) if(x==...
C
6b7d6f5c07b313c57d52db6a48d3eeef
491784cb8e299934342c9f828f2fc0d2
1,600
PASSED