problem stringlengths 716 12.9k | answer stringlengths 41 999 |
|---|---|
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <cstdio>
#include <cmath>
const double eps=1e-4;
const double PI=acos(-1.0);
double gcd(double x,double y)
{
return y>eps? gcd(y,x-floor(x/y)*y):x;
}
double bcos(double a,double b,double c)
{
return acos((a*a+b*b-c*c)/(2*a*b));
}
int main()
{
double ax,ay,bx,by,cx,cy;
scanf("%lf%lf%lf%lf%lf%l... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <stdio.h>
#include <math.h>
const double eps=1e-4;
const double PI=acos(-1.0);
double gcd(double x,double y)
{
return y>eps? gcd(y,x-floor(x/y)*y):x;
}
double bcos(double a,double b,double c)
{
return acos((a*a+b*b-c*c)/(2*a*b));
}
int main()
{
double ax,ay,bx,by,cx,cy;
scanf("%lf%lf%lf%lf%l... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
double xa,ya,xb,yb,xc,yc;
double a,b,c,A,B,C,x,y;
double length(double x,double y){return x*x+y*y; }
double gcd(double a,double b){ return fabs(b)<1E-4?a:gcd(b,fmod(a,b));}
int main()
{
scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc);
y=l... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<cmath>
#define D double
#define S(x) ((x)*(x))
#define G(t) a[t]=x[t]-x[2];b[t]=y[t]-y[2];c[t]=(S(x[t])+S(y[t])-S(x[2])-S(y[2]))/2;
#define M(p,q) (p[0]*q[1]-p[1]*q[0])
D g(D a,D b){return fabs(b)<1e-4?a:g(b,fmod(a,b));}
D x[3],y[3],a[3],b[2],c[2],A,X,Y;
int main()
{
for(int i=0;i<3;++i)scanf(... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<cmath>
#define S(x) ((x)*(x))
#define G(t) a[t]=x[t]-x[2];b[t]=y[t]-y[2];c[t]=(S(x[t])+S(y[t])-S(x[2])-S(y[2]))/2;
#define M(p,q) (p[0]*q[1]-p[1]*q[0])
double g(double a,double b){return fabs(b)<1e-4?a:g(b,fmod(a,b));}
double x[3],y[3],a[3],b[2],c[2],A,X,Y;
int main(){
for(int i=0;i<3;++i)... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
lenth = [0] * m
elem = [[] for i in range(m)]
for i in range(n):
c = 0
p = -1
for j in range(m):
if a[i] == b[j] and c + 1 > lenth[j]:
lenth[j] = c + 1
elem[j] = (elem[p]... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | def lcis(a, b):
n, m = len(a), len(b)
dp = [0]*m
best_seq, max_len = [], 0
for i in range(n):
current = 0
seq = []
for j in range(m):
if a[i] == b[j]:
f = seq + [a[i]]
if len(f) > max_len:
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | n=int(input())
ar=list(map(int,input().split()))
m=int(input())
br=list(map(int,input().split()))
t=[0]*m
A=[[] for i in range(m)]
for i in range(n):
c=0
p=-1
for j in range(m):
if(ar[i]==br[j] and c+1>t[j]):
t[j]=c+1
A[j]=(A[p] if p!=-1 else []) +[ar[i]]
if(ar[i]>br[... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
int main() {
int a,b,c;
cin >> a >> b >> c;
string ans;
if(c == 1) {
for(int i=0;i<a;i++) cout<<"0";
for(int i=0;i<b;i++) cout << "1";
}
else if(a>b) {
for(int i=0;i<a-(c-1)/2-(c-1)%2;i++) cout << "0";
for(int i=0;i<b-(c-1)/2;i++) cout << "1";
int tag = ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int a, b, x;
string s;
cin >> a >> b >> x;
if(a < b)
{
for(int i = 1; x != 1; i++, x--)
{
if(i % 2 == 0)
{
s +... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(int i=a;i<n;i++)
#define sf(n) scanf("%d",&n)
#define pii pair<int,int>
#define p2ii pair<pii,int>
#define ff first
#define ss second
int main()
{
int n,k;sf(n);sf(k);int a[n];
rep(i,0,n)sf(a[i]);int sum[n];
sum[0]=... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
int main() {
cin.tie(NULL);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<int> temper(n);
for (auto& i : temper)
cin >> i;
double avg = 0;
for (int dist = k; di... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
double sr,srm;
int n,k,a[5009],i,j;
int s,smax;
int main()
{
cin>>n>>k;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=k;i<=n;i++)
{
smax=0,s=0;
for(j=1;j<=i;j++)
s+=a[j];
smax=s;
for(j=i+1;j<=n;j++)
{
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
template<typename T>
inline T read(T&x){
x=0;int f=0;char ch=getchar();
while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x=f?-x:x;
}
const int N... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define left lef
using namespace std;
const int N = 400001;
int n,d,k,cnt,left;
vector <int> g[N];
vector <pair<int,int> > ans;
void go(int node,int levels){
while (g[node].size() < k && left > 0 && levels > 0){
g[node].push_back(cnt);
g[cnt].push_back(node);
ans.push_back(make_pair(n... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include"bits/stdc++.h"
#define endl '\n'
#define int long long int
#define maxi 100000+5
#define pii pair<int,int>
#define stat first
#define num second
#define mod 1e9+7
using namespace std;
signed main(){
int n,k;
cin >> n >> k;
while(k--){
int a;
cin >> a >> a;
}
int a = 1;
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <utility>
int main() {
std::ios_base::... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
fast;
int n,m;
cin>>n>>m;
int i;
for(i=0;i<m;i++)
{
int l,r;
cin>>l>>r;
}
int p=0;
for(int j=0;j<n;j++)
{
if(p%2==0)
cout<... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
int main()
{
ll n,m,i,x,y;
cin>>n>>m;
for(i=1;i<=m;i++)
cin>>x>>y;
for(i=1;i<=n;i++)
{
if(i%2==0)
cout<<"1";
else
cout<<"0";
}
return 0;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define FF first
#define SS second
#define PB push_back
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
const ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector<int> v;
vector<int> temp;
for(int i=0; i<n; i++)
{
int x;
cin>>x;
v.push_back(x);
}
temp = v;
sort(temp.begin(),temp.end(),greater<int>());
int sum=0;
vector<int> maxv;
for(int i=0; i<k; i++)
{
sum+=temp[i];
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
bool f(ii a, ii b){
if(a.first==b.first){
return a.second>b.second;
}
return a.first<b.first;
}
int main(){
int n, k;
cin>>n>>k;
pair<int, int> a[n];
for(int i=0;i<n;i++){
cin>>a[i].first;
a[i].second = i+1;
}
sort(a, a+n, f);
i... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
#define LL long long
using namespace std;
LL n,m,a,b,c,x,d;
long double sum,ans;
inline LL read()
{
char ch=getchar();
LL f=1,x=0;
while (ch<'0' || ch>'9')
{
if (ch=='-') f=-1;
ch=getchar();
}
while (ch>='0' && ch<='9')
{
x=x*10+ch-'0';
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,m;
cin >> n >> m;
long long sum = 0;
for(int i = 1;i <= m;i++)
{
int d,x;
scanf("%d%d",&x,&d);
sum += x*n;
// cout << sum << endl;
if(d >= 0)
{
sum += (n-1)*n/2*d;
}
if(d < 0)
{
if(n % 2 == 1)
sum+=d*(n/2)*(n/2+1);
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int read(){
int x=0,w=1;
char ch=0;
while (ch<'0' || ch>'9'){
if (ch=='-') w=-1;
ch=getchar();
}
while (ch<='9' && ch>='0'){
x=(x<<1)+(x<<3)+ch-'0';
ch=getchar();
}
return x*w;
}
int n,m;
ll ans,t1,t... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int n,m,p,t;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void imp(){
printf("Impossible");
}
int main()
{
t=0;
scanf("%d%d",&n,&m);
if(m<(n-1))
{
imp();
return 0;
}
if(n<1000)
{
for(int i... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int GG(int a,int b) {
return b>0?GG(b,a%b):a;
}
int A[100010],B[100010];
int main() {
int n,m;
scanf("%d%d",&n,&m);
if(m<n-1) {
cout<<"Impossible"<<endl;
return 0;
}
int oop=0;
for(int i=1; i<=n; i++) {
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <cstdio>
#include <cstring>
char s[100005];
int n,k,f[200];
int p[200];
int main()
{
scanf("%s",s);
scanf("%d",&k);
n=strlen(s);
memset(f,0,sizeof(f));
for(int i=0;i<n;i++)
f[s[i]]++;
memset(p,0,sizeof(p));
int m=n-k;
int ans=0;
for(int i=0;i<200 &&m>0;i++)
{
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100000
char s[N+5];
int cnt[256],ind[256];
int k;
bool cmp(int x,int y){
return cnt[x]<cnt[y];
}
int main(){
scanf("%s%d",s,&k);
for(int i=0;s[i];++i)++cnt[s[i]];
for(int i=0;i<256;++i)ind[i]=i;
sort(ind,ind+25... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
int k, f[26], c[26];
char ch[100010];
pair<int,int> a[26];
int main()
{
fgets(ch, sizeof(ch), stdin);
scanf("%d",&k);
int n = strlen(ch);
memset(f, 0, sizeof(f));
memset(c, 0, sizeof(c));
for(... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
char str[100005];
int c[26];
pair<int,char> A[26];
int main(){
int k;
scanf("%s%d",str,&k);
int size=strlen(str);
for(char ch='a';ch<='z';ch++) A[ch-'a'].second=ch;
for(int i=0;i<size;i++) A[str[i]-'a'].f... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define SG string
#define DB double
#define LL long long
using namespace std;
const LL Max=2e5+5;
LL N,M,K,Ans[Max];
inline LL Read(){
LL X=0;char CH=getchar();bool F=0;
while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=150;
int ans[maxn][maxn];
int a[maxn],b[maxn],c[maxn];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
int tot=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
tot^=a[i];
}
for(int i=1;i<=m;i++)
{
scanf("... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
int N, M;
int A[200], B[200];
int main () {
std::ios::sync_with_stdio (0);
std::cin >> N >> M;
for (int i = 0; i < N; ++i) std::cin >> A[i];
for (int i = 0; i < M; ++i) std::cin >> B[i];
int a = 0, b = 0;
for (int i = 0; i < N; ++i) a ^= A[i];
for (int i = 0; i < M; ++i) b ^= B[i];
if... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<ld> pt;
typedef vector<pt> pol;
const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i].ss<<' ';cout<<endl;
#define _accept(X,N) for(ll i=0;i<N;++i)cin>>X[i];
#define forzer(i,n) for(ll i=0;i<n;++i)
#define rep(i,s,e) for(ll i=s;i<e;+... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <cstdio>
#include <cstring>
#define N 200005
char a[N];
int n, k;
int main(){
scanf("%d%d%s", &n, &k, a + 1);
int cnt = 0, top = 0;
for (register int i = 1; i <= n; ++i){
if (a[i] == '(' && cnt < (k >> 1)) putchar('('), ++cnt, ++top;
if (a[i] == ')' && top > 0) putchar(')'), --top;
}
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | /*
yusitong
2018-08-03
*/
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int INF = 0x7fffffff;
const int N = 2e5 + 100;
int n,k;
char s[N],sta[N];
int main()
{
cin>>n>>k;
scanf("%s",s+1);
int top=0,a=0,b=0;
for(int i=1;i<=n&&top<k;i++){
if(s[i]=='('){
i... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | //Problem C
#include<bits/stdc++.h>
using namespace std;
int t,n,a[1000005],b[1000005],s,v,u;
void rd(int &a){
a=0;char ch=getchar();
while(!isdigit(ch))ch=getchar();
while( isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
}
long long cal(int a,int b,int c,int d){
return 1ll*(a+b)*(a+b)*c*d;
}
void op... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
string a, b;
int main(){
int n, m;
cin>>n>>m;
if(n<m){
for(int i = 0;i<n;i++)
a+='1', b+='1';
if(2*n-m>=0)
for(int d=2*n-m;d>0;d--)
b+='0';
if(2*n-m<0)
for(int d=m-2*n;d>0;d--)
b = '1'+b;
cout<<b<<endl<<a;
}else{
for(int i = 0;i<n;... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int i,j,l;
deque<int> dq;
j=n;
if(j>=5)
{dq.push_front(5);
j=j-5;}
else{
dq.push_front(j);
j=0;
}
while(j>0){
if(j>4){
dq.push_front(4);
j=j-4;
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
int n,m;
int main() {
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++) {
printf("1");
}
printf... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, m;
cin>>n>>m;
int x;
x=n/9+1;
/*if(n%9){
x=n/9+1;
}else{
x=n/9;
}*/
for(int i=0;i<x;i++){
cout<<'9';
}
cout<<"\n";
for(int i=0;i<x;i++){
cout<<'9';
}
for(int i=0;i<x-1;i++){
cout<<'0';
}
cout<<'1';
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
int a,b;
cin >> a >> b;
int no = a/9;
int lst = a%9;
for(int i=0;i<no;i++) cout << 9;
cout << lst;
cout << endl;
for(int i =0;i<no+1;i++) cout << 9;
if(!lst) no--;
for(int i=0;i<no;i++) cout << 0;
cout << 10-lst;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
typedef long long LL;
inline int readInt() {
int ans = 0, c, f = 1;
while (!isdigit(c = getchar()))
if (c == '-') f *= -1;
do ans = ans * 10 + c - '0';
while (isdigit(c = getchar()));
return ans * f;
}
const int N = 200050;
LL... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <cstdio>
using namespace std;
int b[141000];
long long a[141000];
int main(){
int N; scanf("%d", &N);
for(int i = 1; i <= N; i++) scanf("%d", &b[i]);
int bi = 0;
b[0] = b[N];
for(int i = 1; i <= N; i++) if(b[i] > b[i - 1]){ bi = i; break; }
if(bi == 0){
if(b[1] == 0){
puts("YES");
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main()
{
int i = 0;
bool ans = 1;
int n;
cin >> n;
char in;
for (i; i < n; i++)
{
cin >> in;
if (in == '1'){
ans >>= 1;
break;
}
}
for (++i; i < n; ++i) cin >> in;
cout << (ans ? "EASY" : "HARD") << "\n";
return 0;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main()
{
int i,q,p,a;
cin >>p;
a=0;
for (i=0; i<p; i++){
cin >>q;
if (q==1){
a=1;
break;
}
}
if (a==1) cout<<"HARD"; else cout<<"EASY";
return 0;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
using namespace std;
int main() {
int n,k,a[5]={0},sm=0,mx=0;
string s,r[5];
cin>>s;
n=s.size();
k=n/20;
if(n%20)k++;
for(int i=0;i<k;i++){
a[i]=n/k;
sm+=a[i];
}
mx=n/k;
int i=0;
while(sm<n){
sm++;
a[i]++;
if (mx<a[i])mx=a[i];
i++;
}
int p=0;
for (i=0;i<k;i++){
for(int t... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int min(int a, int b) {
if (a < b)
return a;
return b;
}
int main() {
int n, k = -1;
cin >> n;
if (n <= 2) {
cout << "No";
return 0;
}
if (n % 2 == 0) {
cout << "Yes" << endl;
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define inf 0x3f3f3f3f
using namespace std;
#define MAXN 45001
int n;
int gcd(int a, int b) {
if(a == b)
return a;
if(a>b)
return gcd(a-b, b);
return gcd(a, b-a);
}
int main() {
ios::sync_w... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0) return b;
else return gcd(b%a, a);
}
int main()
{
long long n, s1=0, s2=0, num=0;
cin >> n;
for (int i = 1; i <= n; i++) {
if (i % 2 == 0) s2 += i;
else {
s1 += i;
}
}
if (gcd(s1, s2) > 1) {
cout << "Yes\n... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#define INF (int)1e9
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define girdi freopen("in.gir", "r", stdin);
#define cikti freopen("out.cik", "w", stdout);
typedef pair < int, int > ii;
typedef long long lint;
int main()
{
//girdi cikt... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 200005
int n,i,x[MAXN],c[MAXN],d[MAXN];
ll m,l,a[MAXN],b[MAXN];
int main()
{
scanf("%d%I64d",&n,&m);
for(i=1;i<=n;i++)scanf("%I64d",a+i);
for(i=1;i<=n;i++)
{
scanf("%d",x+i);
if(x[i]<x[i-1]||x[i]<i)
{
puts("No");
return 0;
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
vector<int >v;
int n,k;
void find(int i){
int be=1;
i-=(k+1)*2;
be+=min(i,k);
v.push_back(be);
be+=(2*k+1);
//cout<<be<<endl;
while(be<=n){
v.push_back(be);
be+=(2*k+1);
}
cout<<v.size()<<endl;
for(int i=0;i<(int)v.size();++i){
cout<<v[i]<<" ";
}
cou... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
if(n <= 2*k+1){
cout<<1<<endl;
cout<<(n/2)+1<<endl;
exit(0);
}
int fp = k+1;
int rem = n%(2*k+1);
// cout<<"fp:"<<fp<<endl;
// cout<<"rem:"<<rem<<endl;
int diff = 0;
if(rem ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second
template <class _T_>
void read(_T_& d){
d=0;int f=1;char c=getchar();
for(;c<'0'||c>'9';c=getchar())if(c... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
#define N 1007
using namespace std;
int usd[N],last,a[N],b[N],n,t[N],p,ega[N],egb[N],tot;
int get() {
static int tog=1;
while (usd[tog]) tog++;
return usd[tog]=1,tog;
}
signed main () {
scanf("%d",&n);
for (int i=1;i<n;i++) {
scanf("%d%d",a+i,b+i);
if (a[i]>b[i]) swap(a[i],b[i]);
if ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
string str;
cin>>str;
vector<ll> v(str.length(),0);
v[0] = 0;
for(ll i=1;i<str.length();i++)
{
if(i==str.len... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> a(s.size(), 0);
vector<pair<char, int>> t;
s.push_back('!');
for (int i = 1; i < s.size(); ++i) {
if (s[i] != s[i - 1]) {
t.push_back({s[i - 1], i - 1});
}
}
for (int i = 1; i < t.size(); ++i) {
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
const int N=1000;
char s[N+1];
bool ans[N];
int main(){
scanf("%s",&s);
int n=strlen(s);
for(int i=n-1;i>=0;i--){
if(s[i]=='a'){
ans[i]=!ans[i];
if(i>0)ans[i-1]=true;
}
}
for(int i=0;i<n;i++)printf("%d ",ans[i]);... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
void solve() {
string s;
cin >> s;
int len = s.length();
for (int i = 0; i < len; i++) {
int should = 0;
if (i + 1 < len) {
if (s[i] != s[i + 1]) {
reverse(s.begin(), s.begin() + i + 1);
should = 1;
}
} else {
if (s[i] == 'a') {
reverse(s.beg... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
ifstream in;
ofstream out;
const long long kk=1000;
const long long ml=kk*kk;
const long long mod=ml*kk+7;
const long long inf=ml*ml*ml+7;
ll n,i,j;
vector <ll>... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, i, j, k;
cin >> n;
int d = n / 3, r = n % 3;
int a = d, b = d, c = d + r;
if (a % 3 == 0 && c % 3 != 0) {
a += 1;
b -= 1;
} else if (a % 3 == 0 &&... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false)
#define mp make_pair
#define pb push_back
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<st... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
scanf("%d" , &n);
if(!(n % 3))
printf("1 1 %d" , n - 2);
if(n % 3)
printf("1 2 %d" , n - 3);
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
typedef long long ll;
ll n,m,k,a,b,c;
int main() {
cin >> n;
a = n / 3;
b = n / 3;
c = n / 3 + n % 3;
if (a % 3 == 0 and c % 3 == 0) {
cout << a - 1 << " " << b - 1 << " " << c + 2 << endl;
} else if (a % 3 == 0) {
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,x,i,a[8],b[8];
double r,res;
void cnt(int l, int d, double s, double p) {
if (l==n) {
if (d*2>n) r+=p; else r+=(p*x)/(x+s);//killl
return;
}
if (b[l]>0) cnt(l+1,d+1,s,p*0.1*b[l]);//大了10倍`
if (b[l]<10) cnt(l+1,d,s+a[l],p*0.1*... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <stdio.h>
int n,m,x,i,a[8],b[8];
double r,res;
void cnt(int l, int d, double s, double p) {
if (l==n) {
if (d*2>n) r+=p; else r+=(p*x)/(x+s);
return;
}
if (b[l]>0) cnt(l+1,d+1,s,p*0.1*b[l]);
if (b[l]<10) cnt(l+1,d,s+a[l],p*0.1*(10-b[l]));
}
void rec(int l, int c) {
if (l==n) {
r=0;
cn... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
int N,K,A,B,ps[9],L[9];
double ans,tar;
void proc(int n,int c,int sum,double pos)
{
if (c > N/2){
tar += pos;
return;
}
if (n > N){
tar += pos*double(A)/double(A+sum);
return;
}
proc(n+1,c+1,sum,pos*(ps[n]/100.)... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2+10;
int n, a[maxn], cnt[maxn];
char ans[maxn];
int main()
{
cin >> n;
for (int i=1; i <= n; i++) cin >> a[i], cnt[a[i]]++;
int sum = 0, isup = 0;
for (int i=1; i <= 100; i++)
{
sum += (cnt[i] == 1);
isup += (cnt[i]... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
struct point
{
double x,y,z;
};
double dist(point a, point b)
{
return sqrt(((a.x - b.x) * (a.x-b.x)) +((a.y - b.y) * (a.y-b.y))+ ((a.z - b.z) * (a.z-b.z)));
}
point pontos[1002];
int main()
{
int n;
scanf("%d",&n);
for(int i = 0 ; i < n ; i++... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
struct point
{
double x,y,z;
};
double dist(point a, point b)
{
return sqrt(((a.x - b.x) * (a.x-b.x)) +((a.y - b.y) * (a.y-b.y))+ ((a.z - b.z) * (a.z-b.z)));
}
point pontos[1002];
int main()
{
int n;
scanf("%d",&n);
for(int i = 0 ; i < n ; i++... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:100000000")
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <queue>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <fstre... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int nn = n;
for(int i = 0; i<n; i++){
if(i % 2 == 0){
cout << i << " " << 2 << endl;
nn--;
if(nn == 0) return 0;
cout << i << " " << 0 << endl;
nn--;
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#pragma GCC optimize("03")
#define ll long long
#define ld long double
#define fi first
#define se second
#define mod 100
using namespace std;
int n, m, x, y, ok[110][110], vf[110], sol[110][110], cnt[110];
int main() {
// ifstream cin("tst.in");
// ofstream out("tst.out");
ios_base::sync_w... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define S second
#define F first
using namespace std;
vector <pair<int, int> > ans[10000];
int main()
{
int n, m;
cin>>n>>m;
for(int i = 0; i<n; i++)
{
ans[i].push_back({10000000 - i, i});
}
for(int i = 0; i... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int p[101],y = 1;
struct lol{
int x,y;
lol(int a = 0,int b = 0){x = a;y = b;}
};
vector<lol>ans[101];
int main(){
// freopen("readin.txt","r",stdin);
int n,m;
cin >> n >> m;
for(int i = 0;i < n;i++)ans[i].push_back({i + 1,y++});
for(int i = 0,a,b;i < m;i++){
cin >>... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <algorithm>
using namespace std;
vector<int> rooks_[101];
vector<int> a_, b_;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
set<pair<int, int>> set;
for (int i = 0; i < m; ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb emplace_back
#define pi pair<int,int>
using namespace std;
const int maxn = 104;
int n, m;
int x, y;
vector<pi> v;
vector<pi> g[maxn];
int mi[maxn];
int main(){
// freopen("scc", "r", stdin);
// freope... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
long double k1,k2;
if((n*n-4*n)<0)
cout<<"N"<<endl;
else{
k1=(n+sqrt(n*n-4*n))/2;
k2=n-k1;
cout<<"Y"<<" ";
std::cout<<std::setpre... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
#define FOR(i, x, a) for(long i=x; i<=a; i++)
#define FORD(i, x, a) for(long i=x; i>=a; i--)
#define ll long long
#define pii pair < int, int >
#define vii vector < pii >
#define ms(a, x) memset(a, x, sizeof(a))
#define NMAX 1000
using namespace std;
long t, d;
double del;
int main() {
//i... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int n, a, p, i;
double q1, q2;
cin>>n;
cout<<setprecision(16);
for(i=0; i<n; i++)
{
cin>>a;
p=a*a-4*a;
if(p<0)
{
cout<<"N"<<endl;
}
else
{
q1=a;
q2=sqrt(p);
cout<<... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t,dis;
cin>>t;
double a,b,c,x;
while(t--)
{
cin>>dis;
x=(dis*dis-4*dis);
if(x<0)
{
printf("N\n");
}
else
{
c=sqrt(x);
b=(dis+c)/2;
a=(abs)(b/(b-1));
printf("Y %.9f %.9f\n",b,a);
}
}
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int num[200005];
int cnt[200005];
bool flag[200005];
int main(int argc, char** argv) {
int n;
int m=0;
cin>>n;
int max1=0;
int xu=0;
long long ans=0;
for (int a=1;a<=n;a++)
{
scanf("%d",&num[a]);
ans+=num[a];
if (num[a]>max1)
{
xu=a;
max1=num[a];
... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n,cnt;
ll tot;
struct node{
ll num;
int id;
bool ok;
bool operator < (c... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
int x=0,f=1;char cc=getchar();
while(cc<'0' || cc>'9') {if(cc=='-') f=-1;cc=getchar();}
while(cc>='0' && cc<='9') {x=x*10+cc-'0';cc=getchar();}
return x*f;
}
int n,a[200010],s[200010],v[200010],m;
ll t;
inline bool cmp(int i,in... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
inline int read(){
int x=0,f=1;char cc=getchar();
while(cc<'0' || cc>'9') {if(cc=='-') f=-1;cc=getchar();}
while(cc>='0' && cc<='9') {x=x*10+cc-'0';cc=getchar();}
return x*f;
}
int n,k,m,s[200020],a[200020],l,r;
int main(){
n=read();k=read();
for(int i=1;i<=n;i++) ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 100001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) n... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
long long a[100001];
int main(){
int n;
scanf("%d",&n);
int i,j,k;
int m=n/2;
for(i=1;i<n;i+=2){
scanf("%lld",&a[i]);
}
long long cur=100000000000001LL;
for(i=n-1;i>=1;i-=2){
bool ok=fals... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
int const N = 100000, M = 3 * N;
ll x[N];
void no() { printf("No\n"); exit(0); }
pair<bool, int> sq(ll x){
int z = sqrt(x) + 0.5;
if ((ll)z * z != x)return make_pair(false, 0);
return make_pair... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <functional>
#include <set>
#include <cstdlib>
#include <map>
#include <cctype>
#include <algorithm>
#define pii pair<int, int>
#define ll long long
#define pis pair<int, string>
#define mp make_pair
const ll MOD = 998... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | //WikkieRitz
#include <bits/stdc++.h>
typedef long long int var;
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int x;
cin>>x;
if(x==1)
cout<<-1;
else
cout<<x<<" "<<x;
return 0;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
if (n==1) cout<<"-1";
else {
int lan= n/2;
cout<<lan*2<<" 2";
}
return 0;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if (x<2)
{
cout<<-1;
return 0;
}
cout<<x<<" "<<x;
return 0;
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
#define IOS ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
int n;
scanf("%d", &n);
int start = n * 10;
printf("%d\n2 %d 1\n1 %d %d\n", n + 1, n, n, start--);
for (int i = 0; i < n - 1; ++i)
printf("2 %d %d\n", i + 1, start--);
} |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define first fi
#define second se
//vector<pair<int, pair<int, int> > > vec;
using namespace std;
int n, sum, di, sh = 200000;
long long a[2007];
bool yes = true;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> a[0];
for (int i = 1; ... |
You are a coding expert. Given a competition-level coding problem, you need to write a Python program to solve it. You may start by outlining your thought process. In the end, please provide the complete code in a code block enclosed with ``` ```. The code should take stdin as input and print the output. Your program s... | #include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b; ++i)
#define fdto(i,a,b) for(int i=a; i>=b; --i)
using namespace std;
const int oo = 1e9+7;
int n, a[2001];
int res[2001], res2[2001];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
//("C.inp", "r", stdin);
//fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.