akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N;
    cin >> N;

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    rep(i, N) {
        bool flg = true;
        rep(j, 3) {
            if (N <= i + j) {
                flg = false;
                break;
            }
            flg &= A[i + j] == B[i + j];
        }

        if (flg) {
            puts("Yes");
            return 0;
        }
    }

    puts("No");
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll A,B,K; cin>>A>>B>>K;
  if(A>K){
    A=A-K;
  }
  else{
    B=max(B-(K-A), ll(0));
    A=0;
  }
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int h, w; cin >> h >> w;
  string field[h];
  rep(i, h) cin >> field[i];

  int dh[4] = {-1, 0, 1, 0};
  int dw[4] = {0, -1, 0, 1};

  bool flag = true;
  rep(i, h) rep(j, w) {
    if(field[i][j] == '#') {
      bool can = false;
      rep(k, 4) {
        int nh = i+dh[k];
        int nw = j+dw[k];

        if(0<=nh && 0<=nw && nh<h && nw<w && field[nh][nw] == '#') can = true;
      }
      if(!can) flag = false;
    }
  }

  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k, a, b;
	cin>>k>>a>>b;
	for(int i=a; i <= b; i++)
	{
		if(i%k==0)
		{ cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	// if(b==a) cout<<"OK"<<endl;
	// else if(b-a>=k)
	// {
	// 	cout<<"OK"<<endl;
	// }
	// else cout<<"NG"<<endl
	return 0;

}

Measured memory_bytes: 3640
def resolve():
    from collections import defaultdict

    d = defaultdict(int)
    n = int(input())
    for _ in range(n):
        s = input()
        d[s] += 1

    print("AC x {}".format(d['AC']))
    print("WA x {}".format(d['WA']))
    print("TLE x {}".format(d['TLE']))
    print("RE x {}".format(d['RE']))

resolve()

Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 2e4+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int c[N],a[400][N],n,ans,t,day[N];
signed main()
{
	Very_fast;
	cin>>n;
	for(int i=0;i<26;i++)cin>>c[i];
	rep(i,n)
	rep(j,26)cin>>a[i][j];
	rep(i,n)
	{
		cin>>t;t--;day[t]=i+1;
		ans+=a[i][t];
		rep(j,26)ans-=c[j]*(i-day[j]+1);
		cout<<ans<<"\n";
	}
	return 0;
}

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

char S[100000];
int s[100000];

void Do2(int N, int n, int K){
  int i, M, m;
  M = 0;
  m = 0;
  for(i = 0;i <= 2 * K - 1;i++){
    if(i >= n) break;
    m += s[i];
  }
  M = m;
  if(M != N){
    for(i = 1;i < n;i += 2){
      if(i + 2 * K - 1 >= n) break;
      m -= s[i-1];
      if(i >= 2) m -= s[i-2];
      m += s[i+2*K-1];
      if(i + 2 * K < n) m += s[i+2*K];
      if(M < m) M = m;
    }
  }
  printf("%d\n", M);
}

void Do(int N, int K){
  int i, c, C;
  c = C = 0;
  for(i = 0;i < N;i++){
    if(S[i] == '0' + (C % 2)) c++;
    else{
      s[C] = c;
      C++;
      c = 1;
    }
  }
  s[C] = c;
  C++;
  Do2(N, C, K);
}

int main(void){
  int N, K;
  scanf("%d %d", &N, &K);
  scanf("%s", S);
  Do(N, K);
  return 0;
}


Measured memory_bytes: 640
// By Atul Rathore

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	


int main()
{
	fastio;
	int n,m;
	cin>>n>>m;
	int sum=0;
	int a[n];
	f(n)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int z=4*m;
	int ans=0;
	int x=sum/z;
	int o=sum%z;
	f(n)
	{
		if(a[i]>x)ans++;
		if(o==0)
		{
			if(a[i]==x)ans++;
		}
	}
	if(ans>=m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	
	
}


Measured memory_bytes: 256
def by6(x):
    res = 0
    k = 6**7
    while x > 0:
        while x >= k:
            x -= k
            res += 1
        k /= 6
    return res
def by9(x):
    res = 0
    k = 9**6
    while x > 0:
        while x >= k:
            x -= k
            res += 1
        k /= 9
    return res
n = int(input())
ans = n
for i in range(n + 1):
    ans = min(ans, by6(i) + by9(n - i))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int f[100005][2],p[100005];
int n,v1,u1;vector<int> v[100005];
void dfs1(int s,int l){
	if(l==0)return;
	if(p[s])return ;
	p[s]=1;
	for(int i=0;i<v[s].size();i++)dfs1(v[s][i],l-1);
}
void dfs2(int s,int color,int l){
	if(l==0)return ;
	if(f[s][color])return;
	f[s][color]=1;
	for(int i=0;i<v[s].size();i++)dfs2(v[s][i],1-color,l-1);
}
bool check(int l){
	memset(f,0,sizeof(f));
	memset(p,0,sizeof(p));
	dfs1(v1,l+1);
	dfs2(u1,0,l+2);
	int ans1=1,ans2=1;
	for(int i=1;i<=n;i++){
		if(f[i][1]&&!p[i])ans1=0;
		if(f[i][0]&&!p[i])ans2=0;
	}
	return (ans1||ans2);
}
int main(){
	cin>>n>>u1>>v1;
	int x,y;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int l=0,r=n,mid,ans=-1;
	while(r>=l){
		mid=(l+r)>>1;
		if(check(mid)){
			ans=mid;
			r=mid-1;
		}else l=mid+1;
	}
	cout<<ans;
	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  vll a(n);
  REP(i,n){
    cin>>a[i];
    a[i]--;
  }
  
  ll cnt=0;
  REP(i,n){
    if(i==a[a[i]])
      cnt++;
  }
  
  ll ans=cnt/2;
  cout<<ans<<endl;
    
  
      
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,r;
	cin>>n>>r;
	if (n==1){cout<<1;return 0;}
	long double a,b;
	a=log(n);
	b= log(r);
	// cout<<a<<" "<<b;
	cout<<ceil(a/b);
	// cout<<a;
}
// cnt == s.length() || 

Measured memory_bytes: 384
/*
	0134:Exit Survery
*/
#include	<iostream>

using namespace std;

int main(void) {
	int w;
	unsigned long long ave, sum = 0;
	
	cin >> w;
	for(int i = 0; i < w; i++) {
		int bu;
		
		cin >> bu;
		sum += bu;
	}
	ave = sum / w;
	cout << ave << endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
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> P;
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 REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#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;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    char s[N]; REP(i,N) cin >> s[i];
    map<char,int> m; m['P'] = 0; m['W'] = 0; m['G'] = 0; m['Y'] = 0;
    REP(i,N){
        m[s[i]] = 1;
    }
    if(m['P']+m['W']+m['G']+m['Y'] == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

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

int n;
map<array<int, 4>, int> mp;

int same(array<int, 4> a, array<int, 4> b) {
  int res = 0;
  if (a == array<int, 4>{b[0], b[1], b[2], b[3]}) res++;
  if (a == array<int, 4>{b[1], b[2], b[3], b[0]}) res++;
  if (a == array<int, 4>{b[2], b[3], b[0], b[1]}) res++;
  if (a == array<int, 4>{b[3], b[0], b[1], b[2]}) res++;
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  cin >> n;
  vector<array<int, 4>> up;
  long long ans = 0;

  for (int i = 0; i < n; i++) {
    array<int, 4> c;
    for (int j = 0; j < 4; j++) {
      cin >> c[j];
    }

    for (auto &d : up) {
      array<int, 4> w = {d[0], d[3], c[0], c[3]};
      array<int, 4> x = {d[3], d[2], c[1], c[0]};
      array<int, 4> y = {d[2], d[1], c[2], c[1]};
      array<int, 4> z = {d[1], d[0], c[3], c[2]};

      long long cur = 1;
      cur *= 1ll * mp[w] - same(d, w);
      cur *= 1ll * mp[x] - same(w, x) - same(d, x);
      cur *= 1ll * mp[y] - same(w, y) - same(x, y) - same(d, y);
      cur *= 1ll * mp[z] - same(w, z) - same(x, z) - same(y, z) - same(d, z);
      ans += cur;
    }

    up.push_back({c[0], c[1], c[2], c[3]}); mp[up.back()]++;
    up.push_back({c[1], c[2], c[3], c[0]}); mp[up.back()]++;
    up.push_back({c[2], c[3], c[0], c[1]}); mp[up.back()]++;
    up.push_back({c[3], c[0], c[1], c[2]}); mp[up.back()]++;
  }

  cout << ans << "\n";
  return 0;

}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
	VL p(a), q(b), r(c);
	rep(i,a) cin>>p[i]; rep(i,b) cin>>q[i]; rep(i,c) cin>>r[i];
	sort(RALL(p)); sort(RALL(q)); sort(RALL(r));
	int u=x-1, v=y-1;
	rep(i,c){
		if(u==-1&&v==-1) break;
		else if(u==-1&&v>=0){
			if(r[i]>q[v]) q[v]=r[i], v--;
			else break;
		}else if(v==-1&&u>0){
			if(r[i]>p[u]) p[u]=r[i], u--;
			else break;
		}else{
			if(p[u]<q[v]&&r[i]>p[u]) p[u]=r[i], u--;
			else if(p[u]>=q[v]&&r[i]>q[v]) q[v]=r[i], v--;
			else break;
		}
	}
	ll ans = 0;
	rep(i,x){
		cerr<<p[i] << ' ';
		ans+=p[i];
	}
	cerr << endl;
	rep(i,y){
		cerr<<q[i] << ' ';
		ans+=q[i];
	}
	cerr << endl;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int q,ans1,tot=0,hs[N];
ll sum,s,sum1,sum2,si1,si2,t[N*4],si[N*4];
int opt[N],x[N],y[N];
void fix(int l,int r,int k,int x)
{
    if(l==r)
    {
        t[k]+=hs[l];
        si[k]++;
        return;
    }
    int m=l+r>>1;
    if(x<=m) fix(l,m,k<<1,x);
    else fix(m+1,r,k<<1|1,x);
    t[k]=t[k<<1]+t[k<<1|1];
    si[k]=si[k<<1]+si[k<<1|1];
}
ll query(int l,int r,int k)
{
    if(l==r)
    {
        ans1=hs[l];
        return si1*hs[l]-sum1+sum2-si2*hs[l];
    }
    int m=l+r>>1;
    if(si2+si[k<<1|1]<=s/2&&si[k<<1])
    {
        sum2+=t[k<<1|1];
        si2+=si[k<<1|1];
        return query(l,m,k<<1);
    }
    else
    {
        sum1+=t[k<<1];
        si1+=si[k<<1];
        return query(m+1,r,k<<1|1);
    }
}
int main()
{
    scanf("%d",&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&opt[i]);
        if(opt[i]==1)
            scanf("%d%d",&x[i],&y[i]),hs[++tot]=x[i];
    }
    sort(hs+1,hs+1+tot);
    for(int i=1;i<=q;i++)
    {
        if(opt[i]==1)
        {
            s++;
            fix(1,tot,1,lower_bound(hs+1,hs+1+tot,x[i])-hs);
            sum+=y[i];
        }
        else
        {
            sum1=sum2=si1=si2=0;
            ll ans2=query(1,tot,1)+sum;
            printf("%d %lld\n",ans1,ans2);
        }
    }
}

Measured memory_bytes: 13184
#include <stdio.h>
#include <math.h>

int main(){
  int i,j,k,n,num=0,count=0,flag=0,s[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  for(j=0;j<n;j++){
    flag=0;
    num=sqrt(s[j]);
  for(k=2;k<=num;k++){
    if(s[j]%k==0)flag=1;
  }
  if(flag==0)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 628
using System;

public class Program {
    public static void Main() {
        while (true) {
            int n = int.Parse(Console.ReadLine());
            if (n == 0) return;
            int[] arr = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
            for (int i = 0; i < n; i++) {
                arr[int.Parse(Console.ReadLine())]++;
            }
            foreach (int i in arr) {
                if (i == 0) Console.WriteLine("-");
                else {
                    for (int j = 0; j < i; j++) {
                        Console.Write("*");
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 8848
from collections import Counter


def f(s, t):
    sc = Counter(s)
    tc = Counter(t)
    sn = [x for x in sc.values()]
    tn = [x for x in tc.values()]
    sn.sort()
    tn.sort()
    print("Yes") if sn == tn else print("No")


s = input()
t = input()
f(s, t)


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

int main(){

  int n, max = -1, ans;

  cin >> n;

  if(n == 1){
    cout << 1 << endl;
  }else{
    for(int i = 1; i <= n; i++){
      if(i % 2 == 0){
        int tmp = i, cnt = 0;
        while(tmp % 2 == 0){
          tmp /= 2;
          cnt++;
        }
        if(cnt > max){
          ans = i;
          max = cnt;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
int main() {
  int n; cin >> n;
  vector<int>a(n);
  for(int i; i<n; i++) cin >> a[i];
  sort( a.begin(), a.end() );
  cout << a.at(n-1)-a.at(0) << endl;
}



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

int main(){
  int N,L;
  string S[110];
  cin >> N >> L;
  for(int i = 0; i < N; ++i) cin >> S[i];
  sort(S, S + N);
  string ans;
  for(int i = 0; i < N; ++i) ans += S[i];
  cout << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef  int lli;
using namespace std;
int main(){
    
    lli cards,gates;
    cin >> cards >> gates;
    
    lli right = 100005;
    lli left = 0;
    for(int i =1;i<=gates;i++){
        lli l, r;
        cin >> l >> r;
        left = max(left,l);
        right = min(r,right);
    }
    lli ans = right-left+1;
    ans = max(ans,0);
    cout << ans << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    for (int i = 0; i < (1 << s.size() - 1); i++) {
        int sum = s[0] - '0';
        for (int j = 1; j < s.size(); j++) {
            if (i & (1 << (j - 1))) sum += s[j] - '0'; else sum -= s[j] - '0';
        }
        if (sum == 7) {
            cout << s[0];
            for (int j = 1; j < s.size(); j++) {
                if (i & (1 << (j - 1))) cout << '+'; else cout << '-';
                cout << s[j];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int>data(N,K-Q);

  for(int i=0;i<Q;i++){
    int x;
    cin>>x;
    x--;
    data[x]++;
  }
  for(int i=0;i<N;i++){
    if(data[i]<=0)cout<<"No"<<endl;
    if(data[i]>0)cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int w = Integer.parseInt(in.next());
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int ans = 0;

            if (a <= b && b <= (a + w)) {
                ans = 0;
            } else {
                ans = Math.abs(a - b) - w;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21588
#include <iostream>
#include <set>
#include <vector>

using namespace std;

bool solve() {
  // Inputs.
  int n, m;
  cin >> n >> m;
  if (n == 0 && m == 0) {
    return false;
  }
  vector<int64_t> a(n), w(m);
  for (auto &i : a) {
    cin >> i;
  }
  for (auto &i : w) {
    cin >> i;
  }

  // List measurable weights.
  set<int64_t> s{0};
  for (auto &i : w) {
    set<int64_t> t;
    for (auto &j : s) {
      t.emplace(j + i);
      t.emplace(j);
      t.emplace(j - i);
    }
    s = move(t);
  }

  // List unmeasurable chemicals.
  vector<int> b;
  for (auto &i : a) {
    if (s.find(i) == s.end()) {
      b.emplace_back(i);
    }
  }

  // All chemicals are measurable.
  if (b.empty()) {
    cout << 0 << endl;
    return true;
  }

  // List feasible weights for each unmeasurable chemical.
  vector<set<int64_t>> r(b.size());
  for (int i = 0; i < int(b.size()); ++i) {
    for (auto &j : s) {
      r[i].emplace(abs(b[i] - j));
    }
  }

  // Intersection of feasible weights.
  set<int64_t> p(r[0]);
  for (auto &i : r) {
    set<int64_t> q;
    for (auto &j : i) {
      if (p.find(j) != p.end()) {
        q.emplace(j);
      }
    }
    p = move(q);
  }

  // Output the minimum feasible weight.
  if (!p.empty()) {
    cout << *(p.begin()) << endl;
  } else {
    cout << -1 << endl;
  }

  return true;
}

int main() {
  while (solve()) {
  }
}



Measured memory_bytes: 240912
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

int dp[N];

void solve()
{
    //dp[1]=0;
    dp[1]=0;
    int n,k;
    cin>>n;
    k=2;
    for(int i=2;i<=n;i++)
        dp[i]=INF;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int j=2;j<=n;j++)
    {
        for(int i=j-1;i>=max((int)1,j-k);i--)
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    }
    cout<<dp[n]<<endl;
    
    
    
    
}


int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int long long 
#define cint boost::multiprecision::cpp_int

signed main(){
    int N;
    cin >> N;

    string s = "second";

    bool odd = false;
    rep(i,N){
        int n;
        cin >> n;
        if(n%2) odd = true;
    }
    if(odd) s = "first";

    cout << s << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  vl A(5);
  rep(i, 5) cin >> A[i];
  vl a(5);
  rep(i, 5) a[i] = (A[i]-1)%10+1;
  sort(all(a));
  ll ans=a[0]-10;
  rep(i, 5) ans += (A[i]+9)/10*10;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int table[14][14];

int main(){
	int a,b,c;
	while(~scanf("%d,%d,%d",&a,&b,&c)){
		a+=2;
		b+=2;
		switch(c){
			case 3:
				table[a-2][b]++;
				table[a+2][b]++;
				table[a][b-2]++;
				table[a][b+2]++;
			case 2:
				table[a+1][b+1]++;
				table[a-1][b-1]++;
				table[a+1][b-1]++;
				table[a-1][b+1]++;
			case 1:
				table[a][b+1]++;
				table[a][b-1]++;
				table[a-1][b]++;
				table[a+1][b]++;
				table[a][b]++;
		}
	}
	int max=0;
	int ans=0;
	for(int i=2;i<12;i++){
		for(int j=2;j<12;j++){
			if(table[i][j]>0)ans++;
			if(table[i][j]>max)max=table[i][j];
		}
	}
	printf("%d\n%d\n",100-ans,max);
}

Measured memory_bytes: 0
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
K = sum(B)-sum(A)
for a,b in zip(A,B):
    if a < b:
        K -= (b-a+1)//2
print('Yes' if K >= 0 else 'No')




Measured memory_bytes: 4596
#include<iostream>
#include<vector>
using namespace std;
int n, a, b; vector<int>x[125000]; bool used[125000];
int dfs(int pos) {
	used[pos] = true;
	int s = 0;
	for (int i = 0; i < x[pos].size(); i++) {
		if (used[x[pos][i]] == true)continue;
		s ^= (dfs(x[pos][i]) + 1);
	}
	return s;
}
int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		x[a].push_back(b);
		x[b].push_back(a);
	}
	int G = dfs(1);
	if (G == 0)cout << "Bob" << endl;
	else cout << "Alice" << endl;
	return 0;
}

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

int main() {
    int x;
    cin >> x;
    if (x >=400 && x <= 599) cout << "8" << endl;
    if (x >=600 && x <= 799) cout << "7" << endl;
    if (x >=800 && x <= 999) cout << "6" << endl;
    if (x >=1000 && x <=1199) cout << "5" << endl;
    if (x >=1200 && x <= 1399) cout << "4" << endl;
    if (x >=1400 && x <= 1599) cout << "3" << endl;
    if (x >=1600 && x <= 1799) cout << "2" << endl;
    if (x >=1800 && x <= 1999) cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int n;
int h[21];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
    	cin >> h[i];
	}
    bool f=0;
    int op=1;
	for(int i=2;i<=n;i++)
	{
		f=1;
		for(int j=1;j<=i;j++)
		{
			if(h[i]<h[j])
			f=0;
		}
		if(f) op++;
	}
	cout << op << endl;
    return 0;
}

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

int main(){
  string S,result="No";
  cin >> S;

  if(S=="hi"||S=="hihi"||S=="hihihi"||S=="hihihihi"||S=="hihihihihi"){
    result = "Yes";
  }

  // if(S.length()==1){
  //   result = "No";
  // }

  // for(int i=0;i<S.length();i++){
  //   if(i%2==0){
  //     if(S[i]!='h'){
  //       result = "No";
  //       break;
  //     }
  //   }else{
  //     if(S[i]!='i'){
  //       result = "No";
  //       break;
  //     }
  //   }
  // }

  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n),y(m);
	REP(i, n) {
		cin >> x[i];
	}
	REP(i, m) cin >> y[i];
	rep(i, X+1, Y) {
		bool can1 = true;
		bool can2 = true;
		REP(j, n) {
			if (x[j] >= i) {
				can1 = false;
				break;
			}
			
		}
		REP(j,m){
			if (y[j] < i) {
				can2 = false;
				break;
			}
		}
		if (can1&&can2) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
int a,b;
   cin>>a;
   cin>>b;
   if(a==b){
       cout<<"a == b";
   }
   else if(a>b){
       cout<<"a > b";
   }
   else if(b>a){
       cout<<"a < b";
   }
   cout<<endl;
}


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

int main() {
 	

  ll n,k; cin >> n >> k;
  map<int,ll> m;
  
  for(int i=0; i<n; i++) {
    ll a,b; cin >> a >> b;
    m[a]+=b;
  }
  
  ll sum = 0;
  for(auto x:m){
   	 sum += x.second;
    if( sum >= k ) {
      cout << x.first << endl;
      break;
    }
  }
     
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

ll two( vector<ll> &v, ll key){
    
    ll left = 0;
    ll right = v.size() - 1;

    while (right - left != 1)
    {
        ll mid = (left + right) / 2;
        if( v[mid] > key ){
            left = mid;
        }
        else{
            right = mid;
        }
    }

    return left;
    
}

int main(){

    ll N, M, V, P;
    cin >> N >> M >> V >> P;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    sort(rall(v));
    ll goal = v[P - 1];
    ll gf = -1;
    ll ge = -1;
    for(int i = 0; i < N; i++){
        if(v[i] == goal){
            if(gf == -1) gf = i;
            ge = i;
        }
    }


    vector<ll> vsum(N);
    vsum[0] = v[0];
    for(int i = 1; i < N; i++){
        vsum[i] = vsum[i - 1] + v[i];
    }

    ll ans = N;
    for(int i = 0; i < N; i++){
        if( v[i] >= goal ) continue;
        
        if( v[i] + M < goal) ans --;
        else {

            // 関係ある投票数
            // 関係ある区間
            ll key = two(v, v[i]);
            ll relation = key - gf + 1;
            ll no_relation = N - relation;


            // 関係ある区間にしなければならない投票数
            ll vote = V - no_relation;
            if(vote < 0) continue;

            ll vote_sum = vote * M;
            // そこの区間の合計
            
            // 関係ある区間の合計
            ll vsum_tmp = vsum[ key  ] - vsum[gf - 1];
            if(DEBUG){
                cout << endl;
                cout << "i is " << i << endl;
                cout << "vote is " << vote << endl;
                cout << "relation " << key << " " << gf << endl;
                cout << "vsum_tmp " << vsum_tmp << endl;
            }

            vsum_tmp += vote_sum;
            ll votemax = ( vsum_tmp + (relation - 1) ) / (relation);
            if( votemax > v[i] + M ) ans --;
        }
    }
    
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 1920
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D;
	cin >> S;
	bool F = true;
	bool K = false;
	if (B < C && B < D && C<D) {
		//cout << "KOO" << endl;
		FOR(i, B - 1, D-1) {
			if (S[i] == S[i + 1] && S[i] == '#') {
				F = false;
			
			}
		}
		S[D - 1] = '#';
		FOR(i, A - 1, C-1) {
			if (S[i] == S[i + 1] && S[i] == '#') {
				F = false;
				
			}
		}

	}
	else if (B < C && B < D && D < C) {
		FOR(i, A - 1, C-1) {
			if (S[i] == S[i + 1] && S[i] == '#') {
				F = false;
			}
		}
		FOR(i, B - 2, D-1) {
			if (S[i] == S[i + 1] && S[i+2] == S[i] && S[i]=='.') {
				K = true;
			}
		}
		if (!K)F = false;
	}
	else {
		FOR(i, A - 1, C-1) {
			if (S[i] == S[i + 1] && S[i] == '#') {
				F = false;
			}
		}
		FOR(i, B - 1, D-1) {
			if (S[i] == S[i + 1] && S[i] == '#') {
				F = false;
			}
		}
	}

	if (!F) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}



Measured memory_bytes: 592
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "+" : "-"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	string s;
	int ans = 0;
	cin >> s;
	Vi dis(4);
	int cnt = 0;
	rep(i, 4) { dis[i] = s[i] - '0'; }
	clog << dis << endl;
	rep(bit, 8) {
		cnt = dis[0];
		rep(i, 3) {
			if (bit & (1 << i)) {
				cnt += dis[i + 1];
			}else{
				cnt -= dis[i + 1];
			}
		}
        if(cnt==7){
			cout << dis[0] << solve(bit & 1) << dis[1] << solve(bit & 2) << dis[2]
			     << solve(bit & 4) << dis[3] << "=7" << endl;
			return 0;
		}
	}
//	cout << ans << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn=10010;
int n;
int h,w;
int a[maxn];
int p[110][110];

int main(){
    scanf("%d%d%d",&w,&h,&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    int cnt=0;
    int x=0,y=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<a[i];j++){
           p[x][y]=i+1;
           if(y==h-1){
            x++;
            y=0;
           }else {
            y++;
           }
        }
    }
    for(int i=0;i<w;i++){
        if(i&1){
            for(int j=h-1;j>=0;j--) printf("%d%c",p[i][j],j?' ':'\n');
        }else {
            for(int j=0;j<h;j++) printf("%d%c",p[i][j],j!=h-1?' ':'\n');
        }
    }
}


Measured memory_bytes: 384
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let mut ans = String::new();
    for i in 0..n {
        for j in (i + 1)..n {
            let d = (i ^ j).trailing_zeros() + 1;
            ans.push_str(&format!("{}", d));
            ans.push(' ');
        }
        ans.pop();
        ans.push('\n');
    }
    print!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4604
#include<stdio.h>
int main(void){
    int i,t,n;
    int a[]={6000,4000,3000,2000};

    for(i=0;i<4;i++){
	scanf("%d%d",&t,&n);
	printf("%d\n",a[t-1]*n);
    }

    return 0;
}

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

using namespace std;

int const inf = 0x3f3f3f3f;

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

    int n;
    cin >> n;

    vector<int> const w = [&] {
        vector<int> w(n);
        for (auto& i : w) {
            cin >> i;
        }
        return w;
    } ();

    auto cost = [&] (int i, int j) {
        return abs(w[i] - w[j]);
    };

    vector<int> dp(n, inf);
    dp[n-1] = 0;
    dp[n-2] = cost(n-2, n-1);

    for (int i = n-3; i >= 0; i--) {
        dp[i] = min(dp[i+1] + cost(i, i+1), dp[i+2] + cost(i, i+2));
    }

    cout << dp[0] << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long A[N];
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    long long ans = 1000000000000000000;
    long long psum = 0;
    for (int i = 0; i < N; i++)
    {
        psum += A[i];
        ans = min(ans, abs(sum - 2 * psum));
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, m;
    cin >> n >> m;

    vector< vector<int> > g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> q;
    vector<int> ans(n, -1);
    q.push(0);
    ans[0] = 0;

    while (!q.empty()) {
        int cur = q.front();
        q.pop();

        for (int nex : g[cur]) {
            if (ans[nex] != -1) continue;
            ans[nex] = cur + 1;
            q.push(nex);
        }
    }

    cout << "Yes\n";
    for (int i = 1; i < n; i++) {
        cout << ans[i] << newl;
    }
    return 0;
}

Measured memory_bytes: 10304
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int X,Y;
    cin >> X >> Y;
    int arr[] = {300000, 200000, 100000, 0};
    int sum = 0;
    sum += arr[min(X-1, 3)] + arr[min(Y-1, 3)];
    if(X == 1 && Y == 1)sum += 400000;
    cout << sum << endl;
}

Measured memory_bytes: 764
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

// Main Code
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) rep(j, m) {
        cin >> a[i][j];
        --a[i][j];
    }
    
    vector<bool> use(m, true);
    int ans = inf;
    while (true) {
        vector<int> cnt(m, 0);
        rep(i, n) rep(j, m) {
            if (use[a[i][j]]) {
                ++cnt[a[i][j]];
                break;
            }
        }
        int mx = 0;
        rep(i, m) chmax(mx, cnt[i]);
        if (mx == 0) break;
        chmin(ans, mx);
        rep(i, m) {
            if (cnt[i] == mx) use[i] = false;
        }
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3944
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt()-1;
    }
    
    int c = 0;
    for (int i = 0; i < N; i++) {
      if (a[a[i]] == i) {
        c++;
      }
    }
    System.out.println(c/2);
  }
}

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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0; 
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false; 
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
  int n ,a[104],flag = 0;
  scanf("%d",&n);
  for(int i = 0 ;i<n;i++)
     scanf("%d",&a[i]);
  for(int i = 0;i<n;i++)
    {
       for(int j = 0;j<n-i-1;j++)
         {
            int temp;
           if(a[j]>a[j+1])
           {
             temp = a[j];
             a[j] = a[j+1];
             a[j+1] = temp;
             flag += 1;
            }
         }
}  for(int i = 0;i<n;i++)
     {
       if(i<n-1)
         printf("%d ",a[i]);
       else printf("%d",a[i]);
     }
  printf("\n");
  printf("%d\n",flag);
  return 0 ;
}


Measured memory_bytes: 3220
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void)
{
	int total;
	while(scanf("%d",&total)!=EOF)
	{
		int test[100000];
		//int *test;
		//test = new int[total];
		int totalin=0;
		for(int i=0;i<total;i++)
			scanf("%d",&test[i]);
		sort(test,test+total);
		for(int i=0,pre=-1;i<total;i++)
		{
			if(test[i]==pre)
			{
				pre =-1;
				totalin--;
			}
			else
			{
				pre = test[i];
				totalin++;
			}
		}
		printf("%d",totalin);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
int dp[100100];
int cnt = 0;
signed main() {
  int a,b;
  cin >> a>> b;
  if(a>b)swap(a,b);
  if(a==1&&b==2)cout << 3 << endl;
    if(a==1&&b==3)cout << 2 << endl;
      if(a==2&&b==3)cout << 1 << endl;



  return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;
int main(){
 int W,H,x,y,r;
 cin >> W>>H>>x>>y>>r;

if(0+r<=x and x<=W-r and 0+r<=y and y<=H-r ){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}




return 0;
}


Measured memory_bytes: 3104
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val a = Array(M) {0}
    val b = Array(M) {0}
    val c = Array(M) { Array(0) {0} }
    val mk = Array(M) { 0 }

    for (i in a.indices) {
        val (s, t) = readLine()!!.split(" ").map{it.toInt()}
        a[i] = s
        b[i] = t
        c[i] = readLine()!!.split(" ").map{it.toInt()}.toTypedArray()
        mk[i] = c[i].fold(0) { s, v -> s or (1 shl v - 1) }
    }
    val INF = 1e9.toInt()
    val dp = Array(1 shl N) { INF }
    dp[0] = 0

    for (s in dp.indices) {
        for (j in a.indices) {
            dp[s or mk[j]] = Math.min(dp[s or mk[j]], dp[s] + a[j])
        }
    }

    println(if(dp.last() < INF) dp.last() else -1)
}


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

int main()
{
  long long int n,min,temp;
  cin>>n;
  min=n;
  for(int i=sqrt(n);i>0;i--){
    if(n%i) continue;
    else {
        temp=i+n/i-2;
        if(temp<min)
            min=temp;
    }
  }
  cout<<min;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
int main()
{
    std::string str;
    std::cin >> str;

    std::transform(str.begin(),str.end(),str.begin(),tolower);

    int count = 0;


    while (1) {
        std::string se;
        std::cin >> se;

        if (se == "END_OF_TEXT") {
            break;
        }

        std::transform(se.begin(),se.end(),se.begin(),tolower);
        if (se == str) {
            count +=1;
        }
    }


    std::cout << count << std::endl;


    return 0;
}

Measured memory_bytes: 1192
#import <stdio.h>
#import <limits.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

int main() {
    int N;
    scanf("%d", &N);

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

    long max = -9999999999;
    int min = R[0];
    for (int i = 1; i < N; i++) {
        max = MAX(max, R[i] - min);
        min = MIN(min, R[i]);
    }

    printf("%ld\n", max);

    return 0;
}



Measured memory_bytes: 2520
#include<cstdio>


int main() {
    int a ,b;
    scanf("%d %d", &a, &b);

    int d = a / b;
    int r = a % b;
    double f = (double)a / b;
    printf("%d %d %.5f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 2728
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        mut v: [usize;3],
    }

    v.sort();
    if v[0]==5 && v[1]==5 && v[2]==7 {
        println!("YES");
    } else {
        println!("NO");
    }

}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
using namespace std;
ll maxi(ll a,ll b)
{
	if(a>=b)
	return a;
	else
	return b;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=0,d,x,y;
    cin>>n>>d;
    d=d*d;
    for(int i=0;i<n;i++)
    {
    	cin>>x>>y;
    	x=x*x+y*y;
    	if(x<=d)
    	{
    		ans++;
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632