akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int n,m=0,d,i,k=1,p[200010],f[200010]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d);
    p[d]=i+1;
  }
  p[0]=n+1;
  p[n+1]=0;
  for(i=1;i<=n;i++){
    if(p[i-1]<p[i]&&p[i]<p[i+1])f[i]=1;
    if(p[i-1]<p[i]||p[i]<p[i+1])k=2;			
  }
  d=0;
  for(i=1;i<=n;i++){
    if(f[i])d++;
    else    d=0;
    if(m<d)m=d;
  }
  //if(m<d)m=d;printf("%d\n",m);
  printf("%d\n",n-m-k);
  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll values[2005];

int main() {
  ll X;
  scanf("%lld", &X);

  for (ll i = 0; i < 2000; i++) {
    ll n = i - 1000;
    values[i] = n * n * n * n * n;
  }

  bool finish = false;

  for (ll i = 0; i < 2000; i++) {
    for (ll j = 0; j < 2000; j++) {
      if (values[i] - values[j] == X) {
        cout << i - 1000 << " " << j - 1000 << endl;
        finish = true;
        break;
      }
    }
    if (finish) {
      break;
    }
  }
}


Measured memory_bytes: 3776
using System;
using System.Linq;

namespace A___Ferris_Wheel
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = AB[0], B = AB[1];

            Console.WriteLine(A <= 5 ? 0 : A <= 12 ? B / 2 : B);
        }
    }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int now = 1;
    int count = 0;
    while(now != 2){
            now = A.at(now - 1);
            count++;
            if(count > N){
                count = -1;
                break;
            }
        }
    cout << count << endl;

}

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

int main() {
    int n, x;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout << " " << i;
        }
        else{
            x=i;
            while(x != 0){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x /=10;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1160
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
  S = input()

  if S == "AC":
    AC += 1
  elif S == "WA":
    WA +=1
  elif S == "TLE":
    TLE +=1
  else:
    RE +=1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


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

int main() {
    int N; cin >> N;
    vector<pair<int, int>> vec(N);
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        vec[i].first = a; vec[i].second = b;
    }
    sort(vec.begin(), vec.end());
    int cnt = 0;
    int flag = vec[0].first+vec[0].second;
    int INF = 1e9;
    vector<int> dp(N+1, INF); // dp[i]は初期状態でi個のロボットがある状態での最小の取り除く数
    dp[1] = 0;
    for (int i = 1; i < N; i++) {
        if (vec[i].first-vec[i].second < flag) {
            //被っている最初の方を取り除くかもう一方を取り除くかで貪欲
            cnt ++;
            flag = min(flag, vec[i].first+vec[i].second);
        }
        else flag = vec[i].first+vec[i].second;
    }
    cout << N-cnt << endl;
}

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

int main(){
    string s;cin>>s;
    ll ans=0;
    int n=s.size();
    
    for(int bit=0;bit<(1<<n-1);bit++){
        string ss="";
        for(int i=0;i<n;i++){
            ss+=s[i];
            if(bit>>i&1){
                ans+=stoll(ss);
                ss="";
            }
        }
        ans+=stoll(ss);
        ss="";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    if (A == 1 && B == 1) {
        cout << "Draw" << endl;
    } else if (A == 1) {
        cout << "Alice" << endl;
    } else if (B == 1) {
        cout << "Bob" << endl;
    } else {
        if (A > B) {
            cout << "Alice" << endl;
        } else if (A < B) {
            cout << "Bob" << endl;
        } else {
            cout << "Draw" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[200010],c[200010];

int main(void){
	int i;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

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

	for(i=1;i<=n;i++) a[i]=i;
	stack<int>st;
	for(i=1;i<=m;i++){
		int x;
		cin >> x;
		st.push(x);
		a[x]=-1;
	}

	while(!st.empty()){
		int p=st.top();
		st.pop();
		if(c[p]==0){
			cout << p << endl;
			c[p]=1;
		}
	}

	for(i=1;i<=n;i++) if(a[i]!=-1) cout << a[i] << endl;

	return 0;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
#include <string>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;

void iluzn() {
int n,m;
cin>>n>>m;
int count=0;
 count+=(n*(n-1))/2+(m*(m-1))/2;
 cout<<count;



}
 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
     {
      iluzn();
    
      }
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10724
#include <iostream>
#define llint long long

using namespace std;

llint n, m, p;
llint x[105];

int main(void)
{
	while(1){
		cin >> n >> m >> p;
		if(n == 0) break;
		for(int i = 1; i <= n; i++) cin >> x[i];
		
		if(x[m] == 0){
			cout << 0 << endl;
			continue;
		}
		
		llint sum = 0;
		for(int i = 1; i <= n; i++) sum += x[i] * 100;
		sum = sum * (100-p) / 100;
		
		cout << sum / x[m] << endl;
	}
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    string S;
    ll K;
    cin >> N >> S >> K;
    K--;
    iter(c, S) {
        if(c == S[K]) cout << c;
        else cout << '*';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> f(n);
  for(int i=0; i<k; i++){
    int d; cin >> d;
    vector<int> a(d);
    for(int j=0; j<d; j++){
      cin >> a[j];
      f[a[j]-1]=1;
    }
  }
  int cnt=0;
  for(int i=0; i<n; i++){
    if(f[i]==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vi cost(n,1e18);
    vi h(n);
    ffor(i,n) cin >> h[i];
    cost[0] = 0;
    
    for(int i = 0; i < n; ++i)
    {
        for(int j = 1;j <= k; ++j)
        {
            if(i + j < n)
            {
                cost[i + j] = min(cost[i + j],cost[i] + abs(h[i + j] - h[i]));
            }
        }
    }
    cout << cost[n - 1];
}


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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;



int main(){

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

    int n,m; cin >> n >> m;
    cout << (n * (n - 1) / 2) + (m * (m - 1) / 2);


    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;

int pre[maxn];
int dp[maxn], b[maxn];
vector<int> v[maxn];

struct segtree{
	int seg[4 * maxn];
	int lazy[4 * maxn];

	void init(){
		memset(seg, 0x3f3f3f3f, sizeof(seg));
		memset(lazy, 0x3f3f3f3f, sizeof(lazy));
	}

	void push(int x, int l, int d){
		seg[x] = min(seg[x], lazy[x]);
		if(l != d){
			lazy[2 * x] = min(lazy[2 * x], lazy[x]);
			lazy[2 * x + 1] = min(lazy[2 * x + 1], lazy[x]);
		}
		lazy[x] = 0x3f3f3f3f;
	}

	void update(int x, int l, int d, int i, int j, int val){
		push(x, l, d);
		if(l > d || l > j || d < i)
			return;

		if(i <= l && d <= j){
			lazy[x] = min(lazy[x], val);
			push(x, l, d);
			return;
		}

		int mid = (l + d) / 2;
		update(2 * x, l, mid, i, j, val);
		update(2 * x + 1, mid + 1, d, i, j, val);
		seg[x] = min(seg[2 * x], seg[2 * x + 1]);
	}

	int query(int x, int l, int d, int i, int j){
		push(x, l, d);
		if(l > d || l > j || d < i)
			return 0x3f3f3f3f;

		if(i <= l && d <= j){
			return seg[x];
		}

		int mid = (l + d) / 2;
		int ret = query(2 * x, l, mid, i, j);
		ret = min(ret, query(2 * x + 1, mid + 1, d, i, j));
	//	seg[x] = min(seg[2 * x], seg[2 * x + 1]);
		return ret;
	}
} seg;

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", b + i);
		pre[i] = pre[i - 1] + (!b[i]);
	}

	int q;
	scanf("%d", &q);
	while(q--){
		int l, d;
		scanf("%d%d", &l, &d);
		v[d].pb(l);
	}

	seg.init();
	memset(dp, 0x3f3f3f3f, sizeof(dp));

	dp[0] = 0;
	seg.update(1, 0, n, 0, 0, 0);
	for(int i = 1; i <= n; i++){
		sort(v[i].begin(), v[i].end());

		dp[i] = dp[i - 1] + b[i];
		seg.update(1, 0, n, i, i, dp[i] - pre[i]);

		for(int j : v[i]){
			int cur = seg.query(1, 0, n, j - 1, j - 1) + pre[i];
			dp[i] = min(dp[i], cur);
			seg.update(1, 0, n, j, i, cur - pre[i]);
		}
	}

	printf("%d\n", dp[n]);
	return 0;
}

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

using namespace std;
#define         MAX         1000000
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)

int main() {

    int n,m;

    cin>>n>>m;

    vector<int>v(n);
    int sum = 0;

    for(int i=0;i<n;i++){
        cin>>v[i];
        sum += v[i];
    }


    int cnt = 0;
    double val = ((sum)/(double)(4*m));

    //cout<<val<<endl;

    for(int i=0;i<n;i++){

        //double tmp = (v[i])/(double)sum;

        if(v[i]>=val) cnt++;


    }

    (cnt>=m)?cout<<"Yes":cout<<"No";
    cout<<endl;

//    if(cnt >= m){
//        cout<<"Yes"<<endl;
//    }else{
//        cout<<"No"<<endl;
//    }





    return 0;
}


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

long sum(int N, int M, long *x, long *y, long *z, int cx, int cy, int cz){
  long sum = 0;
  long* s = new long[N];
  for(int i = 0; i < N; i++){
    s[i] = cx * x[i] + cy * y[i] + cz * z[i];
    
  }
  sort(s, s + N);
  for(int i = N - 1, j = 0; j < M; i--, j++){
    sum+=s[i];
  
  }
  return sum;
  
}

int main(void){
  bool debug=true;
  
  int N, M;
  cin >> N >> M;

  long* x = new long[N];
  long* y = new long[N];
  long* z = new long[N];
  
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> z[i];
    
  }
     
  long sol = 0;
  long s;
  // (1) p,p,p
  if(sol < (s = sum(N, M, x, y, z, 1, 1, 1))){
    sol = s;
    
  }
  
  // (2) p,p,n
  if(sol < (s = sum(N, M, x, y, z, 1, 1, -1))){
    sol = s;
    
  }

  // (3) p,n,p
  if(sol < (s = sum(N, M, x, y, z, 1, -1, 1))){
    sol = s;
    
  }

  // (4) p,n,n
  if(sol < (s = sum(N, M, x, y, z, 1, -1, -1))){
    sol = s;
    
  }

  // (5) n,p,p
  if(sol < (s = sum(N, M, x, y, z, -1, 1, 1))){
    sol = s;
    
  }

  // (6) n,n,p
  if(sol < (s = sum(N, M, x, y, z, -1, -1, 1))){
    sol = s;
    
  }
  
  // (7) n,p,n
  if(sol < (s = sum(N, M, x, y, z, -1, 1, -1))){
    sol = s;
    
  }

  // (8) n,n,n
  if(sol < (s = sum(N, M, x, y, z, -1, -1, -1))){
    sol = s;
    
  }
  
  cout << sol << endl;  
  
}



Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#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 pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll MOD=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

int main() {
  int N, M, P[100000], Q[100000];
  cin >> N >> M;
  map< int, vector< int > > mp;
  for(int i = 0; i < M; i++) {
    cin >> P[i] >> Q[i];
    mp[P[i]].emplace_back(Q[i]);
  }
  for(auto &p : mp) {
    SORT( p.second )
  }
  for(int i = 0; i < M; i++) {
    // auto id = distance( lower_bound( begin(mp[P[i]] ), end( mp[P[i]] ), Q[i]), begin( mp[ P[i] ] ) );
    auto id = lower_bound(begin(mp[P[i]]), end(mp[P[i]]), Q[i]) - begin(mp[P[i]]);
    printf("%06d%06d\n", P[i],  (ll)id + 1);
  }
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if ( ( a + b ) == ( c + d ) ) {
        cout << "Balanced" << endl;
    } else {
        if ( ( a + b ) > ( c + d ) ) {
            cout << "Left" << endl;
        }  else {
            cout << "Right" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

int w, h;
int map[100][100];
int island_number[100][100];

int angle[][2] = {
	{-1, 0}, {-1, -1}, {0, -1}, {1, -1},
	{1, 0}, {1, 1}, {0, 1}, {-1, 1}
};

void dfs(int y, int x)
{
	for (int i = 0; i < 8; i++){
		if (
		y + angle[i][0] >= 0 &&
		y + angle[i][0] < h &&
		x + angle[i][1] >= 0 &&
		x + angle[i][1] < w &&
		island_number[y + angle[i][0]][x + angle[i][1]] == (y + angle[i][0]) * h + x + angle[i][1]
		){
			island_number[y + angle[i][0]][x + angle[i][1]] = island_number[y][x];
			dfs(y + angle[i][0], x + angle[i][1]);
		}
	}
}

int main()
{
	
	while (scanf("%d %d", &w, &h), w + h){
		memset(island_number, 0, sizeof(island_number));
		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				scanf("%d", &map[i][j]);
				if (map[i][j] == 1){
					island_number[i][j] = i * h + j;
				}
				else {
					island_number[i][j] = -1;
				}
			}
		}
		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (island_number[i][j] == i * h + j && island_number[i][j] >= 0){
					dfs(i, j);
				}
			}
		}
		
		bool ex[100 * 100] = {false};
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (island_number[i][j] >= 0){
					ex[island_number[i][j]] = true;
				}
//				printf("%d ", island_number[i][j]);
			}
//			puts("");
		}
		
		int cnt = 0;
		for (int i = 0; i < 100 * 100; i++){
			cnt += ex[i];
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long n, ans = 0;
    cin >> n;
    vector<long long> as(n);
    vector<long long> ms(n);
    REP(i, n) { cin >> as[i]; }
    long long sum = 0;
    REP(i, n) { sum += as[i]; }
    for (long long i = 1; i < n; i += 2) {
        sum -= 2 * as[i];
    }
    ms[0] = sum;
    cout << ms[0] << " ";
    REP(i, n - 1) {
        ms[i + 1] = 2 * as[i] - ms[i];
        cout << ms[i + 1] << " ";
    }
}

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

int main() {
	string s1; cin >> s1;
	string s2 = s1;
	reverse(s2.begin(), s2.end());
	for(int i = 0; i < s2.size(); ++i)
		if(s2[i] == 'b') s2[i] = 'd';
		else if(s2[i] == 'd') s2[i] = 'b';
		else if(s2[i] == 'p') s2[i] = 'q';
		else if(s2[i] == 'q') s2[i] = 'p';
	if(s1 == s2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
const int c[] = { 10, 50, 100, 500 };
int main(){
	int price = 0;
	int n[4];
	int a = 0;
	while( 1 ){
		cin >> price;
		if( price == 0 ) break;
		for( int i = 0; i < 4; i++ ){
			cin >> n[i];
			price -= c[i] * n[i];
		}
		price *= -1;
		for( int i = 3; i >= 0; i-- ){
			if( price >= c[i] ){
				//cout << c[i] << ' ' << n[i] << endl;
				n[i] -= price / c[i];
				price %= c[i];
			}
		}
		if( a != 0 ) cout << endl;
		for( int i = 0; i < 4; i++ ){
			if( n[i] > 0 ){
				cout << c[i] << ' ' << n[i] << endl ;
			}
		}
		a = 1;
	}
}

Measured memory_bytes: 1160
X = int(input())
ans = 0
for i in range(1000):
  for j in range(1000):
    if i**5 - j**5 == X:
      ans += 1
      A = i
      B = j
    if i**5 - (-j)**5 == X:
      ans += 1
      A = i
      B = -j
    if (-i)**5 - j**5 == X:
      ans += 1
      A = -i
      B = j
    if (-j)**5 - j**5 == X:
      ans += 1
      A = -i
      B = -j

print(str(A)+" "+str(B))


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

int main()
{
	int n,b[100],i,ans=0,num=100000;

	cin>>n;
	for(i=0;i<n-1;i++){
		cin>>b[i];

		if(num<b[i]){
			ans+=num;
		}else{
			ans+=b[i];
		}

		num=b[i];
	}

	ans+=num;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3572
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	x := make([]int, n)
	for i := range x {
		sc.Scan()
		x[i], _ = strconv.Atoi(sc.Text())
	}
	ans := 1000000000
	for i := 0; i+k-1 < n; i++ {
		left, right := x[i], x[i+k-1]
		ans = min(ans, min(abs(left), abs(right))+right-left)
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}
func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int w, a, b; cin >> w >> a >> b;
  if(a + w < b) cout << b - (a + w) << endl;
  else if(a + w >= b && b + w >= a) cout << 0 << endl;
  else cout << a - (b + w) << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

ll n;
ll A[(1<<18)];

set<P> B[(1<<18)];

ll ans[(1<<18)];

int main(){
  
  cin>>n;
  for(int i=0;i< (1<<n);i++){
    cin>>A[i];
  }
  
  for(int i=0;i< (1<<n);i++){
    B[i].insert( P( A[i], i ) );
    
    for(int j=0;j<n;j++){
      if( i >> j & 1 ){
        int tmp=i-(1<<j);

        for(auto p:B[tmp]){
          B[i].insert( p );
        }
        
        while( B[i].size()>3 ){
          B[i].erase( B[i].begin() );
        }
        
      }
    }
  }
  
  for(int i=0;i<(1<<n);i++){
    ans[i]=0;
    for(auto p:B[i]){
      for(auto q:B[i]){
        if(p.second!=q.second){
          ans[i]=max(ans[i], p.first+q.first );
        }
      }
    }
  }

  ll Max=0;
  for(int K=1;K<(1<<n);K++){
    Max=max(Max,ans[K]);
    cout<<Max<<endl;
  }
  return 0;
}


Measured memory_bytes: 68992
# C

import copy
import itertools

h, w, k = map(int, input().split())
c_l = [list(input()) for y in range(h)]

ans = 0

for i in range(2**w):
    _c_l = copy.deepcopy(list(zip(*c_l)))
    for x in range(w):
        if (i >> x) & 1:
            _c_l[x] = [0] * h
    _c_l = list(zip(*_c_l))
    for j in range(2**h):
        __c_l = copy.deepcopy(_c_l)
        for y in range(h):
            if (j >> y) & 1:
                __c_l[y] = [0] * w
        _list = list(itertools.chain.from_iterable(__c_l))
        if _list.count("#") == k:
            ans += 1
    
print(ans)
    

Measured memory_bytes: 9336
require 'prime'

def calcComb(a, b)
  return calcComb(a, a - b) if a - b < b

  (a - b + 1..a).to_a.inject(1, &:*) / (1..b).to_a.inject(1, &:*)
end

mod = 10**9 + 7
n, m = gets.split.map(&:to_i)
pr = m.prime_division
ans = 1
pr.each { |v| ans *= calcComb(n - 1 + v[1], v[1]) % mod } if n != 1
puts ans % mod


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());

int main()
{
    int n, x;
    cin >> n >> x;
    int mina = INT_MAX;
    int sum = 0;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        sum += temp;
        mina = min(mina, temp);
    }
    cout<<(x-sum)/mina+n<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] aInput = Console.ReadLine().Split(' ');
        int[] a = Array.ConvertAll(aInput, int.Parse);
        int[] ans = new int[200001];
        for (int i = 0; i < n - 1; i++) ans[a[i]]++;
        for (int i = 1; i < n + 1; i++) Console.WriteLine(ans[i]);
    }
}


Measured memory_bytes: 43084
import java.util.Scanner;

public class Main {
    static int WHITE = 0;
    static int GRAY = 1;
    static int BLACK = 2;

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[][] G = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                G[i][j] = -1;
            }
        }
        for (int i = 0; i < n; i++) {
            int u = input.nextInt();
            int k = input.nextInt();
            for (int j = 0; j < k; j++) {
                int v = input.nextInt();
                int c = input.nextInt();
                G[u][v] = c;
            }
        }

        int[] p = new int[n];
        int[] d = new int[n];
        int[] color = new int[n];

        // 初始化
        for (int i = 0; i < n; i++) {
            d[i] = Integer.MAX_VALUE;
            p[i] = -1;
            color[i] = WHITE;
        }
        d[0] = 0;
        color[0] = GRAY;
        while (true) {
            int minCost = Integer.MAX_VALUE;
            int u = -1;
            for (int j = 0; j < n; j++) {
                if (color[j] != BLACK && d[j] < minCost) {
                    minCost = d[j];
                    u = j;
                }
            }
            if (u == -1) {
                break;
            }
            color[u] = BLACK;

            for (int v = 0; v < n; v++) {
                if (color[v] != BLACK && G[u][v] != -1) {
                    if (d[u] + G[u][v] < d[v]) {
                        d[v] = d[u] + G[u][v];
                        p[v] = u;
                        color[v] = GRAY;
                    }
                }
            }
        }
        for(int i = 0; i < n; i++) {
            System.out.println(i + " " + d[i]);
        }
    }
}


Measured memory_bytes: 40420
def main():
    n = int(input())
    a,b,c = 0,0,0
    for _ in range(n):
        s,t = input().split()
        if s==t:c+=1
        elif s>t:a+=3
        else :b+=3
    print(a+c,b+c)


if __name__ == '__main__':
    main()




Measured memory_bytes: 5600
import collections, itertools, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    xy = [LI() for _ in range(N)]

    # x, y全ての重複あり組み合わせに対して含まれる点の個数を算出する

    x_coord = [i[0] for i in xy]
    x_coord.sort()
    x_val_num = {x_coord[i]: i for i in range(N)}
    y_coord = [i[1] for i in xy]
    y_coord.sort()
    y_val_num = {y_coord[i]: i for i in range(N)}

    # 2次元累積和
    xy_cnt = [[0] * N for _ in range(N)]
    for x, y in xy:
        xy_cnt[y_val_num[y]][x_val_num[x]] = 1
    # for i in xy_cnt:
    #     print(i)
    xy_acm = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(N):
            xy_acm[i+1][j+1] = xy_cnt[i][j] + xy_acm[i+1][j] + xy_acm[i][j+1] - xy_acm[i][j]
    # for i in xy_acm:
    #     print(i)

    ans = INF
    for yl, yu in itertools.combinations(range(N + 1), 2):
        for xl, xu in itertools.combinations(range(N + 1), 2):
            cnt = xy_acm[yu][xu] - xy_acm[yu][xl] - xy_acm[yl][xu] + xy_acm[yl][xl]
            # print(cnt, yl, yu, xl, xu)
            if cnt >= K:
                ans = min((x_coord[xu-1] - x_coord[xl]) * (y_coord[yu-1] - y_coord[yl]), ans)

    print(ans)

if __name__ == '__main__':
    resolve()


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

int main(){
  vector<int64_t> A(3);
  for(int64_t &i:A)
    cin>>i;
  sort(A.begin(),A.end());
  if(A[0]%2==0 || A[1]%2==0 || A[2]%2==0)
    cout<<0<<endl;
  else
    cout<<A[0]*A[1]<<endl;
}

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

using namespace std;


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

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




template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};


#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    int n;
    cin>>n;

    vector<vector<int>> items(n,vector<int>(3));

    for(int i=0; i<n; i++)
    {
        cin>>items[i][0]>>items[i][1]>>items[i][2];
    }

    vector<vector<int>> dp(n,vector<int>(3,0));

    for(int i=0; i<3; i++)
    {
        dp[0][i]=items[0][i];
    }

    for(int i=1; i<n; i++)
    {
        pair<int,int> mx,smx;

        for(int j=0; j<3; j++)
        {
            if(mx.first<dp[i-1][j]){
                smx.first=mx.first;
                smx.second=mx.second;
                mx.first=dp[i-1][j];
                mx.second=j;
            }
            else if(smx.first<dp[i-1][j]){
                smx.first=dp[i-1][j];
                smx.second=j;
            }
        }

        for(int j=0;j<3;j++){

            int mxi=mx.first;

            if(j==mx.second){
                mxi=smx.first;
            }

            dp[i][j]=items[i][j]+mxi;
        }
    }

    int mx=0;

    for(int i=0; i<3; i++)
    {
        mx=max(dp[n-1][i],mx);
    }

    cout<<mx<<nl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
bool solve(ll mid){
    ll dum[101010];
    rep(i,0,N){
        dum[i]=0;
    }
    dum[0]+=mid;
    dum[N-1]+=mid;
    rep(i,0,N-1){
        dum[i+1] += a[i] - dum[i];
        dum[i]+= a[i] - dum[i];
    }
    return a[N-1]<=dum[N-1];
}
void answer(ll num){
    cout<<num*2;
    ll dum[101010];
    rep(i,0,N){
        dum[i]=0;
    }
    dum[0]+=num;
    dum[N-1]+=num;
    rep(i,0,N-1){
        cout<<" "<<(a[i]-dum[i])*2;
        dum[i+1]+=a[i]-dum[i];
    }
    return;
}
int main() {
    cin>>N;
    rep(i,0,N){
        cin >>a[i];
    }
    ll ng = -1;
    ll ok = a[0];
    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(solve(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    answer(ok);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    __int128_t ans;
    
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ans = a[n - 1];
    for(int i = 0;i < n - 1;i++){
        ans *= a[i];
        if(ans > 1000000000000000000){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << int64_t(ans) << endl;
}


Measured memory_bytes: 4048
package main

import "fmt"

type edge struct {
	from int
	to   int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	from1 := make([]bool, N)
	toN := make([]bool, N)
	var x, y int
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		if x == 1 {
			from1[y-1] = true
		}
		if y == N {
			toN[x-1] = true
		}
	}

	found := false
	for i := 0; i < N; i++ {
		if from1[i] && toN[i] {
			found = true
			break
		}
	}

	if found {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 7424
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()
S = input()
 
if S[K - 1] == "A":
  S = S[0:K - 1] + "a" + S[K:]
if S[K - 1] == "B":
  S = S[0:K - 1] + "b" + S[K:]
if S[K - 1] == "C":
  S = S[0:K - 1] + "c" + S[K:]

print(S)

Measured memory_bytes: 5384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (a >= b) cout << "delicious" << endl;
  else if (b - a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
using namespace std;

map<int,int>mp,blacklisted;
int main()
{
    int n;
    cin>>n;
    int x;
    set<int>st;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        st.insert(x);
        mp[x]++;

    }
    long long ans = 0;
    int i =0;

    for(auto u : st)
    {
        if(mp[u] - u <0 && blacklisted[u] == 0)
        {
            ans += mp[u];
            blacklisted[u] = 1;
        }
        else if(blacklisted[u] == 0)
        ans += mp[u] - u;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 13824
a,b = map(int,input().split())
def lcm(a, b):
    return a * b // gcd (a, b)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def prime_factor(n):
    ass = [1]
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
s = 0


l = prime_factor(gcd(a,b))


print(len(set(l)))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		if (N / 3 < 1) {
			System.out.println(0);
			return;
		}

		if (N % 3 == 0) {
			System.out.println(N / 3);
		} else {
			if (N % 3 > 3) {
				System.out.println((int)Math.ceil(N/3));
			} else {
				System.out.println((int)Math.floor(N/3));
			}
		}



	}
}


Measured memory_bytes: 25556
N = int(input())
A = list(map(int,input().split()))
L = 0
R = 0
S = A[0]
ans = 0
while(R < N-1):
    if S + A[R+1] == S ^ A[R+1]:
        S += A[R+1]
        R+= 1
    elif R > L:
        S -= A[L]
        ans += R - L + 1
        L += 1
    else:
        L += 1
        R += 1
        ans += 1
        S = A[L]
print(ans+(R-L+2)*(R-L+1)//2)

Measured memory_bytes: 77900
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N;
    cin >> N;
    write(180 + (N - 3) * 180);
}

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

int main() {
    int n;
    long a, sum = 0;
    long min_val = LONG_MAX;
    long max_val = LONG_MIN;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        sum += a;
        min_val = min(a, min_val);
        max_val = max(a, max_val);
    }
    cout << min_val << " " << max_val << " " <<sum << endl;

    return 0;
}


Measured memory_bytes: 3096
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int train = sc.nextInt();
        int taxi = sc.nextInt();
        if(train * n <= taxi){
        	System.out.println(train * n);
        }else{
        	System.out.println(taxi);
        }
    }
}

Measured memory_bytes: 35700
#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define si set<int>
#define sll set<ll>
#define ins insert
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define mod 1000000007
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
        // freopen("input.txt", "r", stdin); (input from the file)
	// freopen("output.txt", "w", stdout);   
	cin.tie(0);
	cout.tie(0);
        ll a,b,c,k;
        cin>>a>>b>>c>>k;
        ll sum=0;
         sum=min(a,k);
         k=k-a-b;
         if(k<=0)
         cout<<sum<<"\n";
         else
         {
         	sum=sum-(k);
         	cout<<sum;
         }
return 0;
}

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

#define     MX        2000005
#define     mod       998244353
#define     ll        long long
#define     ld        double
#define     mem(a,b)  memset(a,b,sizeof(a))
#define     fast()    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     F         first
#define     S         second
#define     mp        make_pair
#define     inf       2e18
#define     PI        acos(-1.0)

int dx[] = {+1,-1,0,0};
int dy[] = {0,0,+1,-1};

int n,s;
int a[3005];
int dp[2][3005];

int main(){
    fast();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n>>s;
    for(int i=1;i<=n;i++) cin>>a[i];
    int cur=0;
    dp[cur][0]=1;
    for(int i=n;i>=1;i--){
        for(int j=0;j<=s;j++) dp[cur^1][j]=0;
        for(int j=0;j<=s;j++) dp[cur^1][j]=(2LL*dp[cur][j])%mod;
        for(int j=a[i];j<=s;j++) dp[cur^1][j]= (dp[cur^1][j]+dp[cur][j-a[i]])%mod;
        for(int j=0;j<=s;j++) dp[cur][j]= dp[cur^1][j];
        cur^=1;
    }
    cout<<dp[cur][s]<<endl;
    return 0;
}


Measured memory_bytes: 3660
n=gets.to_i
a,b=gets.chomp.split(" ").map(&:to_i)
fristQuestions=[]
secondQuestions=[]
thirdQuestions=[]
gets.chomp.split(" ").map(&:to_i).each do |value|
  if value<=a
    fristQuestions << value
  elsif value>=a+1 && value<=b
     secondQuestions << value
  else
    thirdQuestions << value
  end
end
puts [fristQuestions.count, secondQuestions.count, thirdQuestions.count].min

Measured memory_bytes: 1788
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  if ((n + 1) / 2 >= k) {
    cout << "YES" << endl;

  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
	int H, *A, i;

	scanf("%d", &H);
	A = (int *)malloc(sizeof(int) * (H+1));
	for(i = 1; i <= H; i++)
		scanf("%d", &A[i]);

	for(i = 1; i <= H; i++){
		if(i == 1)
			printf("node %d: key = %d, left key = %d, right key = %d, \n", i, A[i], A[2*i], A[2*i+1]);
		else if(2*i+1 <= H)
			printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n", i, A[i], A[i/2], A[2*i], A[2*i+1]);
		else if(2*i > H)
			printf("node %d: key = %d, parent key = %d, \n", i, A[i], A[i/2]);
		else
			printf("node %d: key = %d, parent key = %d, left key = %d, \n", i, A[i], A[i/2], A[2*i]);
	}
	free(A);
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<ll> a(n);rep(i,n){cin>>a[i];a[i]/=2;}
    ll l = 1;
    bool odd = true;

    for(int i=0; i<n; i++){
        l = l/__gcd(l,a[i])*a[i];
    }
    for(int i=0; i<n; i++){
        if((l/a[i])%2==0)odd=false;
    }
    if(odd)cout<<(m/l+1)/2;
    else cout<<0;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
list_A = list(map(int, input().split()))
list_N = [0]*n

for i in range(n, 0, -1):
    k, cnt = 0, 0
    while True:
        if k+i > n:
            break
        if list_N[k+i-1] == 1:
            cnt += 1
        k += i
    list_N[i-1] = (list_A[i-1]+cnt) % 2

ans = []
for i in range(n):
    if list_N[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)

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

int main(int argc, const char * argv[]) {
    int A, B;
    cin >> A;
    cin >> B;
    
    int ans = A - 2 * B;
    if (ans < 0) {
        ans = 0;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  string str;
  int n; cin >> n;
  while(n--){
    cin >> str;
    int idx = 2;
    int cnt = 0;
    bool flg = true;
    if(str[0] == '>' && str[1] == 39){
      bool used = false;
      while(idx < str.size() && str[idx] == '=') {
	used = true;
	cnt++;
	idx++;
      }
      if(str[idx] == '#'){
	idx++;
	while(idx < str.size() && str[idx] == '=') {
	  cnt--;
	  idx++;
	}
      }
      if(str[idx] == '~' && cnt == 0 && used) {
	cout << "A" << endl;
	flg = false;
      }
    } else if(str[0] == '>' && str[1] == '^'){
      while(idx+1 < str.size() && str[idx] == 'Q' && str[idx+1] == '='){
	idx += 2;
	cnt++;
      }
      if(cnt > 0 && str[idx] == '~' && str[idx+1] == '~') {
	cout << "B" << endl;
	flg = false;
      }
    }
    if(flg) cout << "NA" << endl;
  }
}

Measured memory_bytes: 1200