akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    ll ans = 0;
    priority_queue<int> pq;
    rep(i, n) {
        if (i == 0) {
            pq.push(a[0]);
        } else {
            int mx = pq.top();
            pq.pop();
            ans += mx;
            pq.push(a[i]);
            pq.push(a[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5040
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> color;
vector<vector<pair<int, int>>> link;

void paint(int node, int c){
  color[node] = c;
  for(auto &e : link[node]) {
    if(color[e.first]) continue;
    if(e.second) paint(e.first, -c);
    else paint(e.first, c);
  }
}

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  link.resize(N + 1, {});
  color.resize(N + 1, 0);
  for(int i = 0; i < N - 1; i++){
    int u, v, w;
    std::cin >> u >> v >> w;
    link[u].push_back({v, w & 1});
    link[v].push_back({u, w & 1});
  }
  paint(1, 1);
  for(int i = 1; i <= N; i++){
    cout << ((color[i] + 1) / 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 8192
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#define ll long long
#define IOS std::ios::sync_with_stdio(false);

using namespace std;
const int inf = 0x3f3f3f3f;
const ll mod =  1e9 + 7;

int main()
{
    IOS
    int n;
    string s;
    cin >> n >> s;
    ll s1 = 0, s2 = 0, s3 = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')s1++;
        if (s[i] == 'G')s2++;
        if (s[i] == 'B')s3++;
    }
    ans = s1 * s2 * s3;
	//cout << ans << endl;
    for (int i = 0; i <= (n-3)/2; i++)
    {
        for (int j = 0; j + 2 * i + 2 < n; j++)
        {
            if (s[j] != s[j + i + 1] && s[j] != s[j + i * 2 + 2] && s[j + i + 1] != s[j + i * 2 + 2])
            {
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main(){

string S;
  cin >> S;
int c[26] = {0};
bool a = true;  
  
  for(int i = 0;i < S.size();i++) c[S.at(i) - '0' - 49]++;  
  
  for(int i = 0;i < 26;i++){
  if(c[i] > 1){
  a = false;
    break;
  }
  }
  
  if(a) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
   
    Scanner  sc = new Scanner(System.in);
 int  H=sc.nextInt();
  int W=sc.nextInt();

      while( H!=0|| W!=0){
 for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
        if((j+i)%2==0){
            System.out.print("#");
        }else System.out.print(".");
    }
    System.out.println();
 }
 System.out.println();
  H=sc.nextInt();
  W=sc.nextInt();

}
}
}



Measured memory_bytes: 35324
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,ll y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,ll y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 1000
char s[MN+5][MN+5];
int n,m,L[MN+5],R[MN+5];
mint ans,S[MN+5],A[MN+5];
struct mat{mint z[2][2];}a,x;
mat operator*(const mat&a,const mat&b)
{
	mat c;memset(c.z,0,sizeof(c.z));
	for(int i=0;i<2;++i)for(int j=0;j<2;++j)
		for(int k=0;k<2;++k)c.z[i][k]+=a.z[i][j]*b.z[j][k];
	return c;
}
int main()
{
	int i,j,l,u0=0,u1=0;ll k;
	scanf("%d%d%lld",&n,&m,&k);
	if(!k)return 0*puts("1");--k;
	for(i=1;i<=n;++i)scanf("%s",s[i]+1);
	for(i=1;i<=n;++i)if(s[i][1]=='#'&&s[i][m]=='#')u0=1;
	for(i=1;i<=m;++i)if(s[1][i]=='#'&&s[n][i]=='#')u1=1;
	if(!u0&&!u1)
	{
		for(i=1;i<=n;++i)for(j=1;j<=m;++j)if(s[i][j]=='#')ans+=1;
		return 0*printf("%d",ans<<k);
	}
	if(u0&&u1)return 0*puts("1");
	if(u1)swap(n,m);
	for(i=1;i<=n;++i)for(j=1;j<=m;j+=l)if(l=1,(u0?s[i][j]:s[j][i])=='#')
		{while((u0?s[i][j+l]:s[j+l][i])=='#')++l;S[l]+=1;if(j==1)L[i]=l;if(j+l>m)R[i]=l;}
	for(i=1;i<=n;++i)if(L[i]&&R[i]&&L[i]<m)
		S[L[i]]-=1,S[R[i]]-=1,A[L[i]]+=1,A[R[i]]+=1,A[L[i]+R[i]]-=1,S[L[i]+R[i]]+=1;
	a.z[0][0]=a.z[1][1]=1;x.z[0][0]=S[m];x.z[1][1]=S[m]*m;
	for(i=1;i<m;++i)x.z[0][0]+=A[i],x.z[1][0]+=S[i],x.z[0][1]+=A[i]*i,x.z[1][1]+=S[i]*i;
	for(;k;k>>=1,x=x*x)if(k&1)a=a*x;
	printf("%d",a.z[0][0]+a.z[1][0]);
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[100],p[100],tmp,copy[100];
  int i,j,num_p,num_s,flag=0;
  scanf("%s %s",s,p);
  strcpy(copy,s);
  num_s=strlen(s);
  num_p=strlen(p);
  while(flag==0)
  {
    if(strstr(s,p)!=NULL){flag=1; break;}
    tmp=s[0];
    for(i=0;i<num_s-1;i++)
    {
      s[i]=s[i+1];
    }
    s[num_s-1]=tmp;
    if(strcmp(s,copy)==0) break;    
  }
  if(flag==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>

using namespace std;

#define MAX 1000001
typedef long long ll;

int main(){
  ll N,M,a;
  vector<ll> d(MAX,0),e(MAX+1,0);
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> a;
    d[a]++;
  }
  for(int i = 0 ; i < MAX ; i++){
    d[i] *= (ll)i;
  }
  for(int i = 0 ; i < MAX ; i++){
    e[i+1] = e[i] + d[i+1];
  }
  cin >> M;
  vector<ll> b(M);
  for(int i = 0 ; i < M ; i++){
    cin >> a;
    b[i] = e[a];
  }
  for(int i = 0 ; i < M ; i++){
    cin >> a;
    cout << (b[i] >= a ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 19080
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define last          freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fr            first
#define sc            second
#define lcm(a,b)      (a*b)/__gcd(a,b)
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
#define endl          '\n'
using namespace std;
int main()
{
    fast
    int n;
    cin>>n;
    map<pair<int,int>,int>mp;
    dom(i,100)
    {
        for(int j=i; j<=100; j++)
        {
            for(int k=j; k<=100; k++)
            {
                if(i*i+j*j+k*k+i*j+j*k+k*i<=10000)
                {
                    set<int>ss;
                    ss.insert(i);
                    ss.insert(j);
                    ss.insert(k);
                    mp[{i*i+j*j+k*k+i*j+j*k+k*i,ss.size()}]++;
                }
            }
        }
    }
    ll ans[n+1];
    dom(i,n)
    {
        mp[{i,2}]*=3;
        mp[{i,3}]*=6;
        ans[i]=mp[{i,1}]+mp[{i,2}]+mp[{i,3}];
    }
    dom(i,n)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 5472
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    
    int ans = n;
    int mini = n;
    for(int i=0; i<p.size(); i++){
        mini = min(mini, p.at(i));
        if(mini != p.at(i)){
            ans--;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
#if 1

#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int gl[100005],gr[100005];

int gcd(int x,int y)
{
    if(x == 0) return y;
    return gcd(y%x,x);
}

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        if(i == 1) gl[i] = a[i];
        else gl[i] = gcd(gl[i-1],a[i]);
    }
    gr[n] = a[n];
    for(int i = n-1;i >= 1;i--)
    {
        gr[i] = gcd(gr[i+1],a[i]);
    }
    int ans = max(gl[n-1],gr[2]);
    for(int i = 2;i <= n-1;i++)
    {
        ans = max(ans,gcd(gl[i-1],gr[i+1]));
    }
    printf("%d",ans);
}

#endif // 1++

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    for (auto c : s) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string a,b;

    getline (cin,a);

    int flag=0;
    int n = a.length()+1;

    for (int i=0;i<n;i++)
        {
        cin >> b[i];
        if (i!=n-1)
          {
            if (a[i]!=b[i])
                flag=1;
              else;
          }
            else;
        }


    if (flag==1)
        cout << "No" << "\n";
    else
        cout << "Yes"<< "\n";
}



Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);

	int a, b;
	cin >> a >> b;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (b <= a) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 1;
	ans += (b - a) / (a - 1);
	if ((b - a) % (a - 1)) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n, m, c, ans = 0;
    int a[20][20] = {0}, b[20] = {0};
    cin >> n >> m >> c;
    for(int j = 0; j < m; j++){
        scanf("%d", &b[j]);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(int i = 0; i < n; i++){
        int sum = c;
        for(int j = 0; j < m; j++){
            sum += a[i][j] * b[j];
        }
        if(sum > 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <string>
#include <tuple>

int main() {
  int p, q, r;
  scanf("%d %d %d", &p, &q, &r);

  printf("%d\n", std::min({p+q, q+r, r+p}));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main() {
    int x,y; cin >> x >> y;
    int cnt,lx,dy,rx,uy;
    cnt = lx = dy = 0;
    rx = uy = 1;
    while (true) {
        if (lx <= x and x < rx and dy <= y and y < uy) break;
        if (cnt%4==0) rx += uy-dy;
        else if (cnt%4==1) uy += rx-lx;
        else if (cnt%4==2) lx -= uy-dy;
        else dy -= rx-lx;

        cnt++;
    }
    cout << cnt%3 + 1 << endl;
}


Measured memory_bytes: 3076
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(void){
  int N, L;
  cin >> N >> L;
  vector<string> S;
  string s;
  REP(i, N){
    cin >> s;
    S.PB(s);
  }

  sort(ALL(S));

  string ans = "";
  REP(i, N) ans += S[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{int N,M,j,i,k,H,W,l,nM,nA,nR,nC,nH,flag;
	long long int sum,min;
	sum=1;
	scanf("%d",&N);
	char S[100000][10];
	nM=0;
	nA=0;
	nR=0;
	nC=0;
	nH=0;
	for(i=0;i<=N-1;i++){
		scanf("%s",&S[i]);}
	for(j=0;j<=N-1;j++){
		if(S[j][0]=='M'){
		nM+=1;}
		else if(S[j][0]=='A'){
		nA+=1;}
		else if(S[j][0]=='R'){
		nR+=1;}
		else if(S[j][0]=='C'){
		nC+=1;}
		else if(S[j][0]=='H'){
		nH+=1;}
		
		}
	int A[5]={nM,nA,nR,nC,nH};
	long long int B[5];
	k=0;
	for(i=0;i<=4;i++){
		if(A[i]!=0){
			B[k]=A[i];
			k+=1;}}
	if(k<3)
	printf("0");
	else if(k==3){
		sum=B[0]*B[1]*B[2];
		printf("%lld",sum);}
		else if(k==4){
			sum=B[0]*B[1]*B[2]+B[0]*B[1]*B[3]+B[0]*B[2]*B[3]+B[1]*B[2]*B[3];
			printf("%lld",sum);}
			else if(k==5){
				sum=B[0]*B[1]*B[2]+B[0]*B[1]*B[3]+B[0]*B[2]*B[3]+B[1]*B[2]*B[3]+B[0]*B[1]*B[4]+B[0]*B[2]*B[4]+B[0]*B[3]*B[4]+B[1]*B[2]*B[4]+B[1]*B[3]*B[4]+B[2]*B[3]*B[4];
				printf("%lld",sum);}
	
	



	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;

int solve (int n, int p);

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, p, mayor;
	while (cin >> n >> p, n | p) {
		mayor = solve(n, p);
		cout << mayor << endl;
	}

	return 0;
}

int check (int a[], int n, int p) {
	for (int i = 0; i < n; i++) if (a[i] == p) return i;
	return -1;
}

int solve (int n, int p) {
	int a[n], bowl = p, m_num;

	for (int j = 0; j < n; j++) a[j] = 0;

	while (1) {
		for (int i = 0; i < n; i++) {
			if (bowl == 0) {
				bowl = a[i]; 
				a[i] = 0;
			} else {
				bowl--; 
				a[i]++;
			}	
			if (bowl == 0 && (m_num = check(a, n, p)) != -1) goto SKIP;
		}
	}
	SKIP:
	return m_num;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int x,y;
	x = max(a,c);
	y = min(b,d);
	int ans;
	ans = y - x;
	if(ans>0){
		printf("%d\n",ans);
	}
	else{
		int ans2=0;
		printf("%d\n",ans2);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    cin.tie(0);
    ios::sync_with_stdio(false);

    size_t N;
    READ(N);

    vector<size_t> A(N);
   for (int i = 0; i < N - 1; ++i) {
     READ(A[i]);
   }
 
    // main procedure
   vector<unsigned int> subordinate_count(N);
   for (int i = 0; i < N - 1; ++i) {
     subordinate_count[A[i] - 1]++;
   }

    // output
   for (int i = 0; i < N; ++i) {
     WRITE_N(subordinate_count[i]);
   }
   
    return 0;
}

Measured memory_bytes: 5560
import java.util.Scanner;

//
class Main{
    final static int MOD = (int)(Math.pow(10, 9) + 7);

    static long[] cumulativeSum(long[] a) {
        long[] b = new long[a.length + 1];
        b[0] = 0L;
        for(int i = 0; i < a.length; i++)
            b[i + 1] = (b[i] + a[i]) % MOD;

        return b;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];

        for(int i = 0; i < N; i++)
            a[i] = sc.nextLong();

        long[] b = cumulativeSum(a);

        long sum = 0L;
        for(int i = 0; i < N - 1; i++) {
            sum += (a[i] * (b[N] - b[i + 1] + MOD)) % MOD;
            sum %= MOD;
        }

        System.out.println(sum % MOD);
    }

}


Measured memory_bytes: 61400
///
// File:  2502.go
// Author: ymiyamoto
//
// Created on Sat Mar 24 00:44:45 2018
//
package main

import (
	"fmt"
)

type phrase struct {
	s, l, p int
}

const melody_len int = 393

var n, m int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&n)

	phrases := make([]phrase, n)
	max_count := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&phrases[i].s, &phrases[i].l, &phrases[i].p)
		max_count += phrases[i].l
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, melody_len+1)
	}

	for i := range phrases {
		s := phrases[i].s
		l := phrases[i].l
		p := phrases[i].p
		for j := range dp[i] {
			for k := s; k <= l; k++ {
				if 0 <= j-k {
					dp[i+1][j] = max(dp[i+1][j], max(dp[i][j], dp[i+1][j-k]+p))
				} else {
					dp[i+1][j] = max(dp[i+1][j], dp[i][j])
				}
			}
		}
	}

	fmt.Scan(&m)
	var invalid bool
	var points []int
	for i := 0; i < m; i++ {
		var m int
		fmt.Scan(&m)
		if dp[n][m] == 0 {
			invalid = true
		}
		points = append(points, dp[n][m])
	}

	if invalid {
		fmt.Println(-1)
	} else {
		for _, p := range points {
			fmt.Println(p)
		}
	}
}



Measured memory_bytes: 2500
#include<bits/stdc++.h>
#include<string>

using namespace std;

//入力
int N = 0, A = 0 ;

void solve(){
    int sum = 0;
    sum = N % 500;

    if (sum <= A){
        cout << "Yes";
    }

    else {
        cout << "No";
    }

}

int main() {

    cin >> N;
    cin >> A;

    solve();
}

Measured memory_bytes: 3644
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7

def factorial(x):
    res = 1
    for i in range(1,x+1):
        res = res * i % MOD
    return res

if n == m:
    print(2 * factorial(n) ** 2 % MOD)
elif abs(n - m) == 1:
    print(factorial(n) * factorial(m) % MOD)
else:
    print(0)

Measured memory_bytes: 38384
l = list(input())
n = len(l)

count0 = 0
count1 = 0

for i in range(0,n,2):
  if(l[i] == '0'):
    count0 += 1
  if(i<n-1 and l[i+1]=='1' ):
    count1 += 1

print(min(count0+count1,n-count0-count1))

Measured memory_bytes: 3956
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_A
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

const int n=8;

bool valid(vector<vector<char>> &board){
	rep(i,2*n){
		int cnt=0;
		rep(j,n){
			if(i-j<0||i-j>=n)continue;
			if(board[i-j][j]=='Q')cnt++;
		}
		if(cnt>1) return false;
	}
	repi(i,-n+1,n){
		int cnt=0;
		rep(j,n){
			if(i+j>=n||i+j<0)continue;
			if(board[j][i+j]=='Q')cnt++;
		}
		if(cnt>1) return false;
	}
	int cnt=0;
	rep(i,n)rep(j,n)if(board[i][j]=='Q')cnt++;
	if(cnt>8)return false;
	return true;
}

int main()
{
	char board[n][n]={};
	rep(i,n)rep(j,n)board[i][j]='.';
	int k;
	cin>>k;
	rep(i,k){
		int x,y;
		cin>>x>>y;
		board[x][y]='Q';
	}

	vector<int> num(8);
	iota(all(num),0);
	do{
		vector<vector<char>> tmp(8,vector<char>(8));
		rep(i,n)rep(j,n)tmp[i][j]=board[i][j];
		rep(i,n){
			tmp[i][num[i]]='Q';
		}
		if(valid(tmp)){
			rep(i,n){
				rep(j,n){
					cout<<tmp[i][j];
				}
				cout<<endl;
			}
			return 0;
		}
	}while(next_permutation(all(num)));

	return 0;
}


Measured memory_bytes: 3092
n = int(input())
a = [0] + [int(x) for x in input().split()] + [0]
diff = [abs(a[i] - a[i + 1]) for i in range(n + 1)]
tot = sum(diff)
for i in range(1, n + 1):
    print(tot - diff[i - 1] - diff[i] + abs(a[i - 1] - a[i + 1]))

Measured memory_bytes: 20572
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    vector<string> ans;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '0') ans.push_back("0");
        if (s.at(i) == '1') ans.push_back("1");
        if (s.at(i) == 'B' && ans.size() != 0) ans.pop_back();
    }

    for (int i = 0; i < ans.size(); i++) {
        cout << ans.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<tuple<string, int, int> > a(n);
  rep(i, n){
    string s;
    int p;
    cin >> s >> p;
    a[i] = make_tuple(s, p, i+1);
  }
  sort(a.begin(), a.end());

  stack<int> st;
  rep(i, n){
    st.push(get<2>(a[i]));
    if(i != n-1 && get<0>(a[i]) == get<0>(a[i+1])) continue;
    else{
      while(!st.empty()){
        cout << st.top() << endl;
        st.pop();
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,a[100005],ans;
int main(){
	in(n);
    for(int i=1;i<=n;i++)in(a[i]);
    int x=1;
    while(x+1<=n){
        int sum=0;
        while(a[x]>=a[x+1]&&x+1<=n){
            x++;
            sum++;
        }
        x++;
        ans=max(ans,sum);
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var arr = Console.ReadLine().Split(' ');

        double sum = 0;
        foreach (var v in arr)
        {
            var a = double.Parse(v);
            sum += (1 / a);
        }

        double ret = 1 / sum;

        Console.Write(ret);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;

#define pb  push_back
#define endl  '\n'
#define w(x)  int x; cin>>x; while(x--)
#define vi  vector<int>

// Tushar Goyal : Chalie Shuru karte hai
const int N = 1e5 + 5;
vi gr[N];
int dp[N];


int longest_path(int src)
{
	if (dp[src] != -1)return dp[src];

	int lp = 0;
	for (int adj : gr[src]) {
		lp = max(lp, 1 + longest_path(adj));
	}

	dp[src] = lp;
	return lp;
}

void solve()
{
	int n, m, k;
	cin >> n >> m;

	int x, y;
	for (int i = 1; i <= m ; i++)
	{
		cin >> x >> y;
		gr[x].pb(y);
	}

	memset(dp, -1, sizeof dp);

	int ans = 0;
	for (int i = 1 ; i <= n ; i++)
	{
		ans = max(ans, longest_path(i));
	}

	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 11292
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define lll bignum
#define ls(x) ( x << 1 )
#define rs(x) ( x << 1 | 1 )
//#define mid ( ( l + r ) >> 1 )
#define lowbit(x) ( x & -x )
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define re register
#define For(i, j, k) for(re int i = (j); i <= (k); ++i)
#define foR(i, j, k) for(re int i = (j); i >= (k); --i)
#define Cross(i, j, k) for(re int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll inf = 0x3f3f3f3f3f3f;

/*
	设 f[i][0/1] 表示上一位乘了 -1 还是没乘。 
*/

ll n, Ans = 0, a[N], f[N][2];

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = (x << 3) + (x << 1) + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if ( x < 0 ) putchar ('-'), x = -x;
		if ( x > 9 ) write ( x / 10 ); putchar ( x % 10 | 48 );
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using namespace IO;

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); ll Num = 0, Numm = 0;
	For ( i, 1, n ) {
		a[i] = read();
		if ( a[i] < 0 ) ++Num;
		if ( a[i] == 0 ) Numm = 1;
	}
//	For ( i, 1, n ) {
//		if ( a[i] > 0 ) {
//			f[i][0] = max ( f[i - 1][0] - a[i], f[i - 1][1] + a[i] );
//			f[i][1] = max ( f[i - 1][1] - a[i], f[i - 1][0] + a[i] );
//		}
//		if ( a[i] < 0 ) {
//			f[i][0] = max ( f[i - 1][0] + a[i], f[i - 1][1] + a[i] );
//			f[i][1] = max ( f[i - 1][0] - a[i], f[i - 1][1] - a[i] );
//		}
//	}
//	return wln ( max (f[n][0], f[n][1]) ), 0;
//	
	
	if ( !(Num & 1) || Numm ) For ( i, 1, n ) Ans += abs (a[i]);
	else {
		ll Mn = inf, Mx = -inf;
		For ( i, 1, n ) {
			if ( a[i] > 0 ) Mn = min (Mn, a[i]);
			if ( a[i] < 0 ) Mx = max (Mx, a[i]);
		}
		if ( abs (Mx) > Mn ) {
			For ( i, 1, n ) 
				if ( a[i] != Mn ) Ans += abs (a[i]); 
			Ans -= Mn;
		} else {
			For ( i, 1, n ) if ( a[i] != Mx ) Ans += abs (a[i]); 
			Ans += Mx;
		}
	}
	return wln (Ans), 0;
}

/*

*/



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string S; cin >> S;
    long long K; cin >> K;
    vector<int> l;
    auto prev = S[0];
    int cnt = 0;
    for(auto& c : S){
        if(c == prev) ++cnt;
        else {
            l.push_back(cnt);
            prev = c;
            cnt = 1;
        }
    }
    l.push_back(cnt);
    if(S[0] == S.back()){
        if(l.size() == 1) cout << l[0] * K / 2 << endl;
        else {
            long long res = l[0]/2 + (l[0]+l.back())/2*(K-1) + l.back()/2;
            for(int i=1;i<l.size()-1;i++) res += l[i]/2 * K;
            cout << res << endl;
        }
    } else {
        long long res = 0;
        for(auto& t : l) res += t/2 * K;
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st w;
  ci(w);
  map<char, int> W;
  rep(i, sz(w)){
    W[w.at(i)]++;
  }
  each(i, W){
    if(i.sc % 2 != 0){
      co("No");
      rt;
    }
  }
  co("Yes");
}

Measured memory_bytes: 256
N, M = gets.chomp.split.map(&:to_i)
route = Array.new(N, 0)
M.times do
  a, b = gets.chomp.split.map(&:to_i)
  if a == 1
    route[b - 1] += 1
  elsif b == N
    route[a - 1] += 1
  end
end
puts route.include?(2) ? 'POSSIBLE' : 'IMPOSSIBLE'


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  int ans = 0, cnt = 1;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == cnt) cnt++;
    else ans++;
  }

  cout << ((ans == N) ? -1 : ans) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20)
#define fi first
#define se second
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int a; cin >> a;
  int w=a+a*a+a*a*a;
	cout << w << endl;
}

Measured memory_bytes: 3620
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = 0

if a[0] > x:
    ans += a[0] - x
    a[0] = x
    
for i in range(n - 1):
    ans += max(0, a[i] + a[i+1] - x)
    a[i+1] = min(a[i+1], x - a[i])
    
print(ans)

Measured memory_bytes: 14592
#include<iostream>
#include<string>
using namespace std;

int main(){
    int n;
    string ans;

    cin >> n;
    if(n == 0){
        cout << "0" << endl;
        return 0;
    }
    while(n != 0){
        int x = (n%2 < 0 ? n%2 + 2 : n%2);
        ans = (char)('0' + x) + ans;
        n = (n-x) / (-2);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define prvp(a) for(auto x : a) cout << "{" << x.ff << ',' << x.ss << "}";cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(int a, int b){return (int)((long long) a * b % mod);}
inline int modexpo(int a, int b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(int a, int b){ return mul(a, modexpo(b, mod - 2));}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  string s, t;
  cin >> s >> t;
  cout << t + s << '\n';  
}

int main(){
  fastio

  pre();

  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  ktj();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int a, b;
int main(){
	scanf("%d%d", &a,&b);
	int n = b-a;
	printf("%d\n", n*(n+1)/2 - b);
	return 0;
}


Measured memory_bytes: 256
module Weighted01DirectedGraph
  (* 道の表現 *)
  (Path : sig
    type t
    (* 辺の名前 *)
    type edge
    (* 長さ0の道 *)
    val nil : t
    (* 道の後ろに辺を付け足した道 *)
    val snoc : t -> edge -> t
  end) :
sig
  val bfs01 :
    (* 頂点数 *)
    int ->
    (* 辺の名前が付いた隣接リスト *)
    (* 辺の重さが0ならfalse，1ならtrue *)
    ('v -> ('v * Path.edge * bool) list) ->
    (* 始点 *)
    'v ->
    (* 最短経路を返す関数 辿り着けなければNoneを返す） *)
    ('v -> Path.t option)
end =
struct
  let bfs01 n es s =
    (* 始点sからの経路 *)
    let d = Hashtbl.create n in
    (* 現在BFSで走査している頂点のリスト *)
    let vps = ref [(s, Path.nil)] in
    let rec bfs t =
      try Some (Hashtbl.find d t)
      with Not_found ->
        match !vps with
        | [] -> None
        | _ :: _ -> vps := List.fold_left dfs [] !vps; bfs t
    and dfs vps (v, p) =
      if Hashtbl.mem d v then vps
      else begin
        Hashtbl.add d v p;
        List.fold_left (fun vps (u, e, b) ->
          if b
          then (u, Path.snoc p e) :: vps
          else dfs vps (u, Path.snoc p e)) vps (es v)
      end
    in bfs
end

module G = Weighted01DirectedGraph
  (struct
    type t = int
    type edge = int
    let nil = 0
    let snoc = ( + )
  end)

module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let es = Array.make n IntMap.empty in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d\n" @@ fun p q c ->
      es.(p - 1) <- IntMap.add c (q - 1 :: try IntMap.find c es.(p - 1) with Not_found -> []) es.(p - 1);
      es.(q - 1) <- IntMap.add c (p - 1 :: try IntMap.find c es.(q - 1) with Not_found -> []) es.(q - 1)
  done;
  match
    G.bfs01 (2 * m + n) (function
      | (v, 0) -> List.map (fun (c, _) -> ((v, c), 1, true)) @@ IntMap.bindings es.(v)
      | (v, c) -> ((v, 0), 0, false) :: (List.map (fun v -> ((v, c), 0, false)) (try IntMap.find c es.(v) with Not_found -> []))) (0, 0) (n - 1, 0)
  with 
  | None -> print_endline "-1"
  | Some d -> Printf.printf "%d\n" d


Measured memory_bytes: 89208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

struct UnionFind{
    vector<int> rank,p,size;
    UnionFind(int n){
        rank.resize(n,0);
        p.resize(n,0);
        size.resize(n,0);
        for(int i = 0; i < n; i++){
            p[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    int root(int x){
        if(x != p[x]){
            p[x] = root(p[x]);
        }
        return p[x];
    }
    bool unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return false;
        if(rank[rx] > rank[ry]){
            p[ry] = rx;
            size[rx] += size[ry];
        }else{
            p[rx] = ry;
            size[ry] += size[rx];
            if(rank[rx] == rank[ry]){
                rank[ry]++;
            }
        }
        return true;
    }
    int tree_size(int x){
        return (size[root(x)]);
    }
};

int main()
{
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x,y);
    }
    map<int,int> cnt;
    rep(i,n){
        if(!cnt[uf.root(i)]){
            cnt[uf.root(i)]++;
        }
    }
    cout << cnt.size();
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	pair<int,int>p[3];
	p[0]=make_pair(a,b);
	p[1]=make_pair(c,d);
	sort(p,p+2);
	a=p[0].first;
	b=p[0].second;
	c=p[1].first;
	d=p[1].second;
	if(b>=c)
	cout<<min(b-c,d-c);
	else
	cout<<"0";
	return 0;
}

Measured memory_bytes: 256
r=input().split()
N=int(r[0])
M=int(r[1])
d_pre=input().split()
d=[int(s) for s in d_pre]
x=sum(d)
ans=0
for i in range(N):
    if d[i]>=x/(4*M):
        ans+=1
if ans>=M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n, m;
    cin >> n >> m;
    vi k(m);
    vi s(m);
    vi p(m);
    rep(i,m) {
        cin >> k[i];
        rep(j,k[i]) {
            int bit;
            cin >> bit; --bit; //bitを0-indexedに
            s[i] += (1<<bit);
        }
    }
    rep(i,m) cin >> p[i];

    int answer = 0;
    bool can;
    for(int switches = 0; switches < (1<<n); ++switches) {
        can = true;
        for(int i = 0; i < m; ++i) {  // 各電球について
            int swit = s[i]&switches;
            int cnt = 0;
            rep(j,n) {
                if(swit&(1<<j)) ++cnt;
            }
            if(cnt%2 != p[i]) {
                can = false;
                break;
            }
        }
        if(can) ++answer;
    }

    cout << answer << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};

int main() {
  int N; cin >> N;
  Vld p(N);
  rep(i, N) cin >> p[i];
  
  VVld dp(N+1, Vld(N+1));
  dp[0][0] = 1;

  rep(i, N) rep(j, N+1) {
    dp[i+1][j] = dp[i][j]*(1-p[i]);
    if (j > 0) dp[i+1][j] += dp[i][j-1]*p[i];
  }

  ld ans = 0;
  rep2(j, (N+1)/2, N+1) ans += dp[N][j];
  cout << setprecision(12);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 141056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 2e5;
int N;
int a[MAX_N+5], b[MAX_N+5];
int ca[MAX_N+5], cb[MAX_N+5];

int main(){
    scanf("%d", &N);
    for(int i=0;i<N;i++) scanf("%d", &a[i]);
    for(int i=0;i<N;i++) scanf("%d", &b[i]);

    ll ans = 0, p = 1;
    for(int i=0;i<30;i++){
        for(int j=0;j<N;j++){
            ca[j] = a[j] % (p<<1);
            cb[j] = b[j] % (p<<1);
        }

        sort(cb, cb+N);

        int cnt = 0;
        for(int j=0;j<N;j++){
            int d1 = distance(lower_bound(cb, cb+N, p-ca[j]), lower_bound(cb, cb+N, 2*p-ca[j]));
            int d2 = distance(lower_bound(cb, cb+N, 3*p-ca[j]), lower_bound(cb, cb+N, 4*p-ca[j]));
            cnt ^= (d1+d2) % 2;
        }

        if(cnt) ans += p;
        p <<= 1;
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;

int main() {
	string N;
	cin >> N;
  
  	int w;
  	cin >> w;
	
  	int i = 0;
  	while(i < N.size()){
  	  cout << N.at(0+i);
      i += w;
    }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 100

int main() {
	static char s[N + 1], t[N * 2 + 1];
	int n, m, i, j, x;

	scanf("%d%s", &n, s);
	m = n;
	strcpy(t, s);
	x = 0;
	for (i = 0; i < n; i++) {
		x += (s[i] == '(' ? 1 : -1);
		if (x < 0) {
			m++;
			for (j = m - 1; j > 0; j--)
				t[j] = t[j - 1];
			t[0] = '(';
			x++;
		}
	}
	while (x > 0) {
		t[m++] = ')';
		x--;
	}
	printf("%s\n", t);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  ll ans = 1000000007 ;
  int N , M ;
  cin >> N >> M ;
  vector<int> A(N) ;
  rep(i,N) cin >>  A.at(i) ;
  sort(A.begin(),A.end()) ;
  //rep(i,N) cout << A.at(i) <<endl;
  for(int i = 0 ; i < N - M + 1 ; i++ ){
    ans = min(ans,(ll)A.at( i + M - 1 )-A.at(i) ) ;
}
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

/*
*/
ll n,x[1010],a[1010][2];
vector<int> child[1010];

bool f(int s){
	bool ok=true;
	if(child[s].size()==0){
		a[s][0]=x[s];//色0
		a[s][1]=0;//色1
	}else{
		ok=false;
		int sum=0,dp[5010]={};
		dp[0]=1;
		rep(i,child[s].size()){
			int t=child[s][i],dp2[5010]={};
			if(!f(t))return false;
			sum+=a[t][0]+a[t][1];
			rep(j,5010){
				if(dp[j]==1){
					if(j+a[t][0]<5010)dp2[j+a[t][0]]=1;
					if(j+a[t][1]<5010)dp2[j+a[t][1]]=1;
				}
			}
			rep(j,5010)dp[j]=dp2[j];
		}
		ireg(j,0,x[s]){
			if(dp[j]==1){//x[s]に一番近いやつを採用
				a[s][0]=x[s];
				a[s][1]=sum-j;//何故なら，ここを最小化したいので
				ok=true;
				break;
			}
		}
	}
	return ok;
}

int main(void){
	cin>>n;
	reg(i,1,n-1){
		int p;
		cin>>p;
		child[p-1].push_back(i);//0-originにする（1敗）
	}
	rep(i,n)cin>>x[i];
	cout<<(f(0)?"POSSIBLE":"IMPOSSIBLE")<<endl;
	// rep(i,n)cout<<a[i][0]<<","<<a[i][1]<<endl;
	return 0;
}

Measured memory_bytes: 17024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, pause
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, pause
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, pause
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, pause
#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 100005;

int n, m;
int a[N];

int gcd(int x, int y) {
	return x % y ? gcd(y, x % y) : y;
}

int main() {
	int d, x, y;
	while (~in2(n, m)) {
		d = -1, x = 0;
		rep (i, n) {
			in(y);
			x = max(x, y);
			if (d == -1) d = y;
			else d = gcd(d, y);
		}
		if (m <= x && m % d == 0) puts("POSSIBLE");
		else puts("IMPOSSIBLE");
	}
	return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
flag = False
Min = math.floor(N / 1.08)
Max = math.floor( ( N + 1 ) / 1.08 + 1)
for i in range(Min, Max + 1):
  if math.floor( i * 1.08 ) == N:
    print( i )
    flag = True
    break
if not flag:
  print(':(')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    cout << d[N/2] - d[N/2-1] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  int n;
  float a;
	cin >> n;

  a = n / 2;
  if (n % 2 == 0)
  {

    cout << a / n << endl;
  } else
  {
    cout << (a + 1) / n << endl;
  }
  
  
	return 0;
}

Measured memory_bytes: 256