akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 114514191900000
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N, Q, K;
  int a;
  int b;
  int c;
  int x[100005];
  int y[100005];
  ll d[100005];
  int s[100005];
  vector<P> v[100005];
  int t;
  queue<int> que;
  cin >> N;
  rep(i, N) {
    d[i] = INF;
    s[i] = 0;
  }
  rep(i, N-1) {
    cin >> a >> b >> c;
    a--;
    b--;
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(a, c));
  }
  cin >> Q >> K;
  rep(i, Q) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  K--;

  que.push(K);
  d[K] = 0;
  while (!que.empty()) {
    t = que.front();
    que.pop();
    for (int i = 0; i < v[t].size(); i++) {
      int a1 = v[t][i].first;
      int a2 = v[t][i].second;
      if (s[a1] == 0) {
        que.push(a1);
        // cout << t << ' ' << a1 << ' ' << a2 << endl;
        if (d[a1]>d[t]+a2)
          d[a1] = d[t]+a2;
        // cout << a1 << endl;
        s[a1] = 1;
      }
    }
  }
  rep(i, Q) {
    cout << d[x[i]]+d[y[i]] << endl;
  }
  // rep (i, N) {
  //   cout << d[i] << endl;
  // }
}


Measured memory_bytes: 9984
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N, M;
  ll L; cin >> N >> M >> L;
  int dp[N][N];
  rep(i, N){
    rep(j, N){
      dp[i][j] = inf;
    }
  }
  rep(i, M){
    int a, b; ll c;
    cin >> a >> b >> c;
    a--; b--;
    dp[a][b]=c; dp[b][a]=c;
  }
  rep(k, N){
    rep(i, N){
      rep(j, N){
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int lp[N][N];
  rep(i, N){
    rep(j, N){
      if(dp[i][j]<=L) lp[i][j]=1;
      else lp[i][j] = inf;
    }
  }
  rep(k, N){
    rep(i, N){
      rep(j, N){
        lp[i][j] = min(lp[i][j], lp[i][k] + lp[k][j]);
      }
    }
  }
  int Q; cin >> Q;
  rep(i, Q){
    int s, t;
    cin >> s >> t;
    s--; t--;
    if(lp[s][t]==inf) cout << -1 << endl;
    else cout << lp[s][t]-1 << endl;
  }
}

Measured memory_bytes: 1408
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int least[100100];
int calcLeast(vector<int>& xs, int idx){
    if(idx == 0){
        least[0] = 0;
        return 0;
    }
    return least[idx] = max(calcLeast(xs, idx - 1), max(0, idx - (xs[idx - 1] + 1) / 2));
}

bool isPossible(vector<int>& xs, int num){
    prints(num);
    while(num > 0){
        num--;
        while(num >= 0 && xs[num] == 0){
            num--;
        }
        int cnt = 0;
        for(int i=0;i<=num;i++){
            cnt += (bool)xs[i];
        }
        if(num >= 0 && (xs[num] + 1) / 2 < cnt){
            prints(xs, num, cnt);
            return false;
        }
    }
    return true;
}

int main(){
    int n; cin >> n;
    vector<int> xs(n);
    for(int i=0;i<n;i++){
        cin >> xs[i];
    }
    calcLeast(xs, n - 1);
    ll ans = 1;
    for(int i=0;i<n;i++){
        // rprint::print(least[i]);
        ans = ans * (i + 1 - least[i]) % M;
    }
    cout << ans << '\n';
    return 0;
    // vector<int> pts(n);
    // iota(pts.begin(), pts.end(), 0);
    // int ans = 0;
    // do{
    //     bool ok = true;
    //     auto _xs = xs;
    //     for(int num : pts){
    //         if(!isPossible(xs, num)){
    //             ok = false;
    //             // prints(xs, num);
    //             break;
    //         }
    //         xs[num] = 0;
    //     }
    //     ans += ok;
    //     xs = _xs;
    // }while(next_permutation(pts.begin(), pts.end()));
    // cout << ans << '\n';
    // return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
   int a;
   string s;

   cin >> a;
   cin >> s;
   if(a < 3200){
       cout << "red" << endl;
   } else {
       cout << s << endl;
   }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 変数
        int val = 0; // 入力値
        int a = 0; // 底
        int com = 0; // 比較用
        int count = 1; // 結果

        // 入力値
        Scanner sc = new Scanner(System.in);
        val = sc.nextInt();
        a = sc.nextInt();

        com = a;

        while (val >= com){
            com *= a;
            count += 1;
        }

        // 出力
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}

struct segtree {
    vector<set<ll>>mn;
    vector<ll>tree;
    size_t size = 1;
    //void build(ll x, ll lx, ll rx, vector<ll>& vec);
    void build(ll size_) {
        while (size < size_) {
            size *= 2;
        }
        tree.resize(size * 2 - 1);
        mn.resize(size * 2 - 1);
    }
    void update(ll i, ll x, ll v, ll lx, ll rx) {
        if (rx - lx == 1) {
            tree[x] = v;
            return;
        }
        ll m = (lx + rx) / 2;
        if (i < m) {
            update(i, 2 * x + 1, v, lx, m);
        }
        else {
            update(i, 2 * x + 2, v, m, rx);
        }
        tree[x] = tree[2 * x + 1] + tree[2 * x + 2];
    }

    ll get(ll l, ll r, ll x, ll lx, ll rx) {
        if (l <= lx && rx <= r) return tree[x];
        if (rx <= l || lx >= r) return 0;
        ll m = (lx + rx) / 2;
        return get(l, r, 2 * x + 1, lx, m) + get(l, r, 2 * x + 2, m, rx);
    }
};



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s)cout << "Yes";
    else cout << "No";
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    map<string, int> s;

    rep(i, n)
    {
        string a;
        cin >> a;
        if (s.count(a) == 0)
        {
            s[a] = 1;
        }
        else
        {
            s[a]++;
        }
    }
    int mx = 0;
    auto iter = s.begin();
    while (iter != s.end())
    {
        if (mx < iter->second)
            mx = iter->second;
        iter = next(iter, 1);
    }
    iter = s.begin();
    while (iter != s.end())
    {
        if (mx == iter->second)
            c(iter->first);
        iter = next(iter, 1);
    }

    return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int>a;
    int bef;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >>bef;
        a.push_back(bef);
    }
    sort(a.begin(),a.end());
    map<int,int>s;
    for(int i=0;i<n;i++){
      //  cout <<a.at(i) <<" ";
        s[a.at(i)]++;


    }
    bef=0;
    int maxs=-1;
   // cout <<endl;
    for(int i=0;i<100010;i++){
        if (s.count(i)){
        //    cout<<s.at(i)<<" ";
            bef+=s.at(i);
        }
        if(s.count(i-3)){
            bef-=s.at(i-3);
        }
        //cout <<bef<<endl;
        maxs=max(bef,maxs);
        if(maxs==bef){
            ans=i-1;
        }
    }
    
   // cout <<endl;
    cout << maxs << endl;
}


Measured memory_bytes: 3576
import math
a, b, x = map(int, input().split())
if a*a*b * (1/2) < x:
  t = math.degrees(math.atan(2*(b/a - x/(a ** 3))))
  print(t)
else:
  t = math.degrees(math.atan(a * (b ** 2)/ (2 * x)))
  print(t)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 2000020;
ll fac[MAX], inv[MAX], finv[MAX];
void init() {
	fac[0] = inv[0] = finv[0] = 1;
	fac[1] = inv[1] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll comb(int n, int k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return (fac[n] * finv[n - k] % MOD) * finv[k] % MOD;
}

ll calc(int r, int c) {
	// 2^(r + c +1) - 1    - left - right
	ll res = 1;
	for (int i = 0; i < r + c + 1; ++i) {
		res <<= 1;
		res %= MOD;
	}
	--res;
	
	ll left = 0;
	for (int i = 0; i < r; ++i) {
		left = (left * 2 + comb(c + i, c)) % MOD;
		res = (res - left + MOD) % MOD;
	}
	ll right = 0;
	for (int i = 0; i < c; ++i) {
		right = (right * 2 + comb(r + i, r)) % MOD;
		res = (res - right + MOD) % MOD;
	}
	return res;
}

int r1, r2, c1, c2;

int main()
{
	cin >> r1 >> c1 >> r2 >> c2;
	init();

	cout << (((calc(r2, c2) - calc(r2, c1 - 1) + MOD) % MOD - calc(r1 - 1, c2) + MOD) % MOD + calc(r1 - 1, c1 - 1)) % MOD;

	return 0;
}

Measured memory_bytes: 47104
#include <iostream>
using namespace std;
int main()
{
    string weather;
    cin >> weather;
    if(weather == "Sunny")
    {
        cout << "Cloudy";
    }
    else if(weather == "Cloudy")
    {
        cout << "Rainy";
    }
    else
    {
        cout << "Sunny";
    }
    
    return 0;
}

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

using namespace std;

int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
  // int a[]={b,d};
   while(a>0&&c>0)
   {
        for(int i=0;i<=1;i++)
        {
            if(i==0)
            {
                c-=b;
                if(c<=0)
                {
                    cout<<"Yes";
                    break;
                }
            }
            else
            {
                a-=d;

                if(a<=0)
                {
                    cout<<"No";
                    break;
                }
            }
        }
   }

}


Measured memory_bytes: 3592
<?php
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);
$a = str_split($S);
$len = strlen($S);
for ($i = 0; $i < $len; $i++) {
    $diff = (ord($a[$i]) - ord('A') + $N) % 26;
    echo chr(ord('A') + $diff);
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  long long  int m=min(a,min(b,min(c,min(d,e))));
  if(n%m==0){
    cout << n/m+4 << endl;
  }else{
    cout << n/m+5 << endl;
  }
}

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

int main() {
	int a, b,bsize,flg=0;
	cin >> a >> b;
	bsize = log10(b) + 1;
	for (int i = 0; (i < 350)&&(flg==0); i++) {
		if (pow(10, bsize)*a + b == i * i) {
			cout << "Yes";
			flg = 2;
		}
		else if (pow(10, bsize)*a + b <= i * i) {
			flg = 1;
		}

	}
	if (flg != 2) {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int a[100010], b[100010];
ll diff[2];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) cin >> b[i];
	for (int i = 0; i < N; i++) {
		if (a[i] > b[i]) diff[0] += a[i] - b[i];
		else diff[1] += (b[i] - a[i]) / 2;
	}
	if (diff[0] > diff[1]) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 384
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[200];ll visit[300]={};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,q;
string s,t;
ll sum = 0;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	for(auto ch : s) {
		cout<<(char)(10 - (ch - '0') + '0');
	}
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3620
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000000000000

int main(){
  long long n,m;
  cin >> n >> m;
  long long l,r,dd;
  vector<pair<long long,long long> > adj[n+1];
  for(int i=0;i<m;i++){
    cin >> l >> r >> dd;
    adj[l].push_back(make_pair(r,dd));
    adj[r].push_back(make_pair(l,-1*dd));
  }
  long long d[n+1];
  for(int i=1;i<n+1;i++){
    d[i] = INF;
  }
  bool flag = false;
  for(int i=1;i<n+1;i++){
    if(d[i] != INF) continue;
    queue<long long> q;
    q.push(i);
    d[i] = 0;
    while(!q.empty()){
      long long now;
      long long temp;
      now = q.front();
      q.pop();
      for(int j=0;j < adj[now].size();j++){
        temp = adj[now][j].first;
        if(d[temp] == INF){
          d[temp] = d[now]+adj[now][j].second;
          q.push(temp);
        }
        else{
          if(d[temp] != d[now]+adj[now][j].second){
            flag = true;
            break;
          }
        }
      }
      if(flag) break;
    }
    if(flag) break;
  }
  if(flag) cout << "No" << endl;
  else cout << "Yes" << endl;



  return 0;
}


Measured memory_bytes: 14080
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

int main(){
    int n,m,c ;
    cin >> n >> m >> c ;
    vector<vector<int> > a(n,vector<int>(m,0)) ;
    vector<int> b(m,0) ;
    for (size_t i = 0; i < m; i++)
    {
        cin >> b.at(i) ; 
    }
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < m; j++)
        {
            cin >> a.at(i).at(j) ;
        }
        
    }
    int ans = 0 ;
    for (size_t i = 0; i < n; i++)
    {
        int sum = c ;
        for (size_t j = 0; j < m; j++)
        {
            sum += a.at(i).at(j)*b.at(j) ;
        }
        if (sum > 0)
        {
            ans ++ ;
        }
        
    }
    
    cout << ans << endl ;

}

Measured memory_bytes: 256
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
string s;
cin>>s;
int n=s.length();
char c=s[n-1];
if(c=='s')s+="es";

else s+='s'; 
cout<<s<<endl;
return 0;
}

Measured memory_bytes: 3628
n = int(input())


A = ['a']

for i in range(n-1):
    B = A[i:]
    for j in B:
        for i in range(ord("a"), ord(max(j)) + 2):
            A.append("".join(j) + chr(i))
A = sorted(A)
for i in A:
    if len(i) == n:
        print(i)


Measured memory_bytes: 105520
@a=split //,<>;@b=split //,<>;@c=split //,<>;
$i=0;
sub f{
    my$s=shift;
    my$n=shift(@{$s});
    if("\n"eq$n){
        return $s;
    }else{
        return &f("$n");
    }
}
print uc&f("a")

Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  string A, B, S;
  while(cin >>A && A != "-"){
    cin >>B >>S;
    stringstream a, b;
    char c = B[0];
    B = B.substr(1);
    while(A != "" || B != ""){
      if(S.find(c) == string::npos){
        b << c;
        c = B[0];
        B = B.substr(1);
      } else{
        a << c;
        c = A[0];
        A = A.substr(1);
      }
    }
    b << c;
    cout <<b.str() <<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include "math.h"


using namespace std;

int main()
{
	int n = 0;
	int a = 0;
	int b = 0;
	cin >> n >> a >> b;
	if (0 <= (a - b)) {
		cout << "delicious" << endl;
		return 0;
	}
	if (abs((a - b)) > n) {
		cout << "dangerous" << endl;
		return 0;
	}
	cout << "safe" << endl;
	return 0;
}

Measured memory_bytes: 256
towers = [(0,0)]
for i in range (999):
    b = towers[-1][0] + (i + 1)
    towers.append((b, i))

towers.pop(0)

(a, b) = [int(i) for i in input().rstrip().split(' ')]

bi = b - a - 1
print(towers[bi][0] - b)


Measured memory_bytes: 3060
n = gets.to_i
a = [[0]]
alf = [*('a'..'z')]

(n-1).times{
  b = []
  a.each{|t|
    (t.uniq.size+1).times{|j|
      b << t+[j]
    }
  }
  a = b
}

a.each{|t|
  puts t.map{|i|alf[i]}*""
}

Measured memory_bytes: 38524
H, W, N = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
P.sort(reverse=1)

MOD = 10**9 + 7

fact = [1]*(H+W+1)
rfact = [1]*(H+W+1)
for i in range(H+W):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)
def comb(n, k):
    return fact[n] * rfact[k] * rfact[n-k] % MOD


dp = [0]*N
for i in range(N):
    r, c = P[i]
    res = comb(H - r + W - c, H - r)
    for j in range(i):
        r0, c0 = P[j]
        if not r <= r0 or not c <= c0:
            continue
        res -= comb(r0-r + c0-c, r0-r) * dp[j] % MOD
    dp[i] = res % MOD

ans = comb(H+W-2, H-1)
for i in range(N):
    r0, c0 = P[i]
    ans -= comb(r0+c0-2, r0-1) * dp[i] % MOD
print(ans % MOD)

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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int res = 0;
	for (int i = 0; i < n; i++) {
		if ((s[i] == 'L' && i != 0 && s[i] == s[i - 1])
			|| (s[i] == 'R' && i != n - 1 && s[i] == s[i + 1])) {
			res++;
		}
	}
	for (int i = 0; i < n && k > 0; i++) {
		if (s[i] == 'R') {
			while (s[i] == 'R' && i < n) i++;
			res += 2;
			k--;
			i--;
		}
	}
	cout << min(res, n - 1) << '\n';


	return 0;
}



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

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

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;

int main() {
    ll x;
    cin >> x;

    int ans = (x/500) * 1000 + (x%500)/5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <iomanip>
#include <cmath>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, hh, ww;
    cin >> h >> w >> hh >> ww;
    int arr[20][20]{};
    for (int i = 0; i < h && hh--; i++) {
        for (int j = 0; j < w; j++) {
            arr[i][j] = 1;
        }
    }
    for (int i = 0; i < w && ww--; i++) {
        for (int j = 0; j < h; j++) {
            arr[j][i] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (arr[i][j] == 0) ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
  int n,q,s[10000],t[500];

  cin>>n;
  for (int i=0;i<n;i++) cin>>s[i];

  cin >> q;
  for (int i=0;i<q;i++) cin >> t[i];

  int counter=0;

  for (int i=0;i<q;i++){
    int v=t[i];
    s[n]=v;
    int j=0;
    while(s[j]!=v){
      j++;
    }
    if (j!=n)counter++;
    
  }

  cout<<counter<<endl;
}


Measured memory_bytes: 3120
#include <stdio.h>


int main(){

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

	if(a > b){
		printf("a > b\n");
	}


	else if(a < b){
		printf("a < b\n");
	}

	else {
		printf("a == b\n");
	}


	return 0;
}

Measured memory_bytes: 580
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        Node[] nodes=new Node[k];
        for(int i=0;i<k;nodes[i]=new Node(i++));
        for(int i=1;i<k;i++){
            nodes[i].edges.add(new Edge((i*10)%k, 0));
            if((i*10)%k!=(i+1)%k) nodes[i].edges.add(new Edge((i+1)%k, 1));
        }
        System.out.println(_01bfs(nodes, 1)[0]+1);
    }

    public static int[] _01bfs(Node[] nodes, int s) {
        ArrayDeque<Integer> dq = new ArrayDeque<>();
        dq.add(s);
        int n = nodes.length;
        int[] d = new int[n];
        for (int i = 0; i < n; d[i++] = Integer.MAX_VALUE) ;
        d[s] = 0;
        while (dq.size() > 0) {
            int now = dq.pollFirst();
            for (Edge e : nodes[now].edges) {
                int next = e.id;
                int cost = e.cost;
                if (d[next] > d[now]) {
                    if (cost == 0) {
                        dq.addFirst(next);
                    } else {
                        dq.addLast(next);
                    }
                    d[next] = d[now] + cost;
                }
            }
        }
        return d;
    }

    static class Node {
        int id;
        int value;
        ArrayList<Edge> edges;

        public Node(int id) {
            this.id = id;
            this.value = Integer.MAX_VALUE;
            edges = new ArrayList<Edge>();
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Node))
                return false;
            Node n = (Node) o;
            if (n.id == id)
                return true;
            else
                return false;
        }

        @Override
        public int hashCode() {
            return id;
        }
    }

    static class Edge {
        int id;
        int cost;
        public Edge(int id, int cost) {
            this.id = id;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 55216
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

ll euclid(ll a, ll b)
{
    int nr = 0;
    while (b != 0)
    {
        int c = b;
        b = a % b;
        a = c;
        nr++;
    }
    return nr;
}


int main()
{
    ll a, b;
    cin >> a >> b;
    ll mini = min(a, b);
    ll maxi = max(a, b);
    if ((maxi - mini) % 2 == 1)
    {
        cout << "IMPOSSIBLE";
    }
    else
    {
        cout << mini + (maxi - mini) / 2;
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}
macro_rules! get_vec {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_vec!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = get_one!(isize);
    let v_a = get_vec!(isize);

    println!("{}", hoge(v_a));

}

fn hoge(v_a: Vec<isize>) -> isize {

    if v_a.iter().any(|&a| a == 0) {
        return 0
    }

    let mut mult = 1;
    for a in v_a {
        if 1000000000000000000 / mult < a {
            return -1
        }
        mult = mult * a;
    }
    return mult as isize
}


Measured memory_bytes: 4856
n = int(input())
A = [int(i) for i in input().split()]
cnt = 0
cnt1 = 0
for a in A:
  if a%4==0:
    cnt += 1
  elif a%2==0 and a%4!=0:
    cnt1 += 1
if int(n/2) <= cnt+(cnt1//2):
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 14252
#include<stdio.h>
int main()
{
    int a[4],i,j,x,y,z,temp;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<3;i++)
    {
        for(j=i+1;j<3;j++)
        {
            if(a[i]>a[j])
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    x=a[2]-a[1];
    y=a[0]+x;
    z=a[2]-y;
    if(z%2==0) z=z/2;
    else z=(z/2)+2;
    printf("%d",(x+z));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll n, d, a;
	cin >> n >> d >> a;
	vector<pair<ll, ll> > xh(n);
	for (int i = 0; i < n; i++){
		cin >> xh[i].first >> xh[i].second;
	}
	sort(xh.begin(), xh.end());

	ll sum = 0, ans = 0;
	queue<pair<ll, ll> > que;
	for (int i = 0; i < n; i++){
		if (xh[i].second > sum){
			ll num = (xh[i].second - sum + a - 1)/a;
			ans += num;
			sum += num*a;
			que.push(make_pair(xh[i].first + 2*d, num*a));
		}
		if (i != n-1){
			while (!que.empty()){
				if (que.front().first < xh[i+1].first){
					sum -= que.front().second;
					que.pop();
				}else{
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "AAA" || s == "BBB") cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

void solve();
int n, k;
string s[200000];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    solve();
}

void solve()
{
    int *a = (int *)calloc(n, sizeof(int));
    string v[n];
    sort(s, s + n);
    int k = 0;
    v[0] = s[0];
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            a[k]++;
        }
        else
        {
            k++;
            v[k] = s[i + 1];
        }
    }
    int len = 0;
    for (int i = 0; i < k + 1; i++)
    {
        len = max(len, a[i]);
    }
    for (int i = 0; i < k + 1; i++)
    {
        if (a[i] == len)
        {
            cout << v[i] << endl;
        }
    }
}

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



int main(){
  long long n;
  cin>>n;
  long long ans=0;
    ans=0;
    ans+=n/11*2;
    n%=11;
    if(1<=n&&n<=6){
      ans++;
    }
    else if(n>6){
      ans+=2;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const int INFTY = (1 << 30);
ll N, M;
void func()
{
    ll X, tmp;
    cin >> X;
    tmp = X * 360 / gcd(X, 360);
    cout << tmp / X << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3628
////////////////////////////////////////////////
//                                            //
//  Author: Muhammad Faishol Amirul Mukminin  //
//                                            //
////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;
typedef pair<pl,ll> pll;
typedef pair<double,double> pd;
typedef pair<pd,double> pdd;

#define fi first
#define se second
#define PUB push_back
#define POB pop_back
#define PUF push_front
#define POF pop_front
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"

const double EPS = 1e-9;
const double PI = acos(-1);

const ll MOD = 1e9+7;

const int dCol[] = {0,+1,0,-1,+1,+1,-1,-1};
const int dRow[] = {-1,0,+1,0,-1,+1,+1,-1};

ll A, B, N, ans=0;

bool valid(ll ang){
	ll res=0;
	while(ang>0){
		res += ang%10;
		ang /= 10;
	}

	if(A <= res && res <= B) return 1;
	else return 0;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> N >> A >> B;
	for(int i=1;i<=N;i++){
		if(valid(i)) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  double ans = ((n + 1 ) / 2) / (double)n;
  printf("%.6f\n", ans);
}

Measured memory_bytes: 256
import sys
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(len(v) // 2)
    sys.exit()

even = Counter(v[::2])
odd = Counter(v[1::2])

# 以下ifがない場合，n = 6 v = [1,1,1,1,1,2,2,1,1,1]でWA
# v[0],v[2],...,v[2//n]で最も多く出現する数字が
# v[1],v[3],...,v[2//n-1]で最も多く出現する数字と等しい場合
if even.most_common()[0][0] == odd.most_common()[0][0]:
    print(min(len(v) - odd.most_common()[0][1] - even.most_common()[1][1], len(v) - odd.most_common()[1][1] - even.most_common()[0][1]))
    sys.exit()

print(len(v) - even.most_common()[0][1] - odd.most_common()[0][1])


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

MOD = 10 ** 9 + 7

ans = 0
d = 1
for _ in range(60):
    x = 0
    for i in range(n):
        x += a[i] % 2
        a[i] //= 2
    ans = (((x * (n-x)) % MOD) * d % MOD + ans) % MOD
    d = d * 2 % MOD

print(ans)


Measured memory_bytes: 122808
N, M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
nodes = [1 for i in range(N)]
for j in range(M):
    a, b = [int(x) for x in input().split()]
    if H[a - 1] <= H[b - 1]:
        nodes[a - 1] = 0
    if H[b - 1] <= H[a - 1]:
        nodes[b - 1] = 0
print(sum(nodes))

Measured memory_bytes: 20140
NIL = -1


class Node():
    def __init__(self, p, l, r):
        self.p = p
        self.l = l
        self.r = r
        self.s = NIL
        self.deg = NIL
        self.dep = NIL
        self.h = NIL


def set_attr(u):
    def set_height(u_):
        h1 = 0
        h2 = 0
        if T[u_].l != NIL:
            h1 = set_height(T[u_].l) + 1
        if T[u_].r != NIL:
            h2 = set_height(T[u_].r) + 1
        res = h1 if h1 > h2 else h2
        T[u_].h = res
        return res

    def set_depth(u_, d):
        if u_ == NIL:
            return
        T[u_].dep = d
        set_depth(T[u_].l, d + 1)
        set_depth(T[u_].r, d + 1)

    set_height(u)
    set_depth(u, 0)


N = int(input())
T = [Node(NIL, NIL, NIL) for _ in range(N)]
for _ in range(N):
    n, l, r = map(int, input().split())
    T[n].l = l
    T[n].r = r
    deg = 0
    if l != NIL:
        T[l].p = n
        deg += 1
    if r != NIL:
        T[r].p = n
        deg += 1
    if l != NIL and r != NIL:
        T[r].s = l
        T[l].s = r
    T[n].deg = deg
root = 0
for n, t in enumerate(T):
    if t.p == NIL:
        root = n
set_attr(root)
for n, t in enumerate(T):
    if t.p == NIL:
        type_ = 'root'
    elif t.l == NIL and t.r == NIL:
        type_ = 'leaf'
    else:
        type_ = 'internal node'
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, '
          'height = {}, {}'.format(n, t.p, t.s, t.deg, t.dep, t.h, type_))



Measured memory_bytes: 5620
#include <stdio.h>

int main() {
	int N,sum,a,b,c,d,e,f,g,h,i;
	scanf("%d",&N);
	a=N/100000000;
	b=(N-a*100000000)/10000000 ;
	c= (N-a*100000000-b*10000000)/1000000;
	d=(N-a*100000000-b*10000000-c*1000000)/100000;
	e=(N-a*100000000-b*10000000-c*1000000-d*100000)/10000;
	f=(N-a*100000000-b*10000000-c*1000000-d*100000-e*10000)/1000;
	g=(N-a*100000000-b*10000000-c*1000000-d*100000-e*10000-f*1000)/100;
	h=(N-a*100000000-b*10000000-c*1000000-d*100000-e*10000-f*1000-g*100)/10;
	i=N-a*100000000-b*10000000-c*1000000-d*100000-e*10000-f*1000-g*100-h*10;
	sum=a+b+c+d+e+f+g+h+i;
	if(N%sum==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	map<int,char> m;
    	map<char,int> m1;
    	for(int i=0;i<26;i++)
    	{
    		m[i]='A'+i;
    	}
    	for(int i=0;i<26;i++)
    	{
    		m1['A'+i]=i;
    	}
    	string res;
    	for(int i=0;i<s.size();i++)
    	{
    		res.push_back(m[(m1[s[i]]+n)%26]);	
    	}
    	cout<<res<<endl;
    	return 0;
    }

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

int main(){
	int i,n,a[3];
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		std::sort(a,a + 3);
		if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1024
def solve(N, As):
    max = sorted(As)[-1]
    secmax = sorted(As)[-2]
    if max == secmax:
        for _ in range(N):
            print(max)
    else:
        for a in As:
            if a == max:
                print(secmax)
            else:
                print(max)



if __name__ == "__main__":
    N = int(input())
    As = []
    [As.append(int(input())) for i in range(N)]
    solve(N, As)


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

using namespace std;

int v[111];

int main() {
    int a, b, c, d;
    while(cin >> a >> b >> c >> d) {
        memset(v, 0, sizeof v);
        for(int i = a; i < b; i++) v[i]=1;
        int cnt = 0;
        for(int i = c; i < d; i++)
            if(v[i])
            cnt++;
        cout<<cnt<<endl;

    }
    return 0;
}

/*
4
4
abcd
*/


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

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

int main() {
    fastio;
    string in;
    cin >> in;
    int n = in.size();
    int* out = new int[n - 2];

    for (int i = 0; i < n - 2; ++i) {
        int t = stoi(in.substr(i, 3));
        out[i] = abs(753 - t);
    }
    cout << *min_element(out, out + n - 2);
    return 0;
}

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

using namespace std;

using lint = long long;

#define INF (1L << 60)

int main(void)
{
    lint N, M;
    cin >> N >> M;
    vector<lint> a(M);
    vector<lint> b(M);
    //vector<vector<bool>> c(M, vector<bool>(N, false));
    
    lint c[1000][12] = {false};
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++){
            int temp;
            cin >> temp;
            c[i][temp-1] = true;
        }
    }

    vector<lint> dp(5000, INF);
    lint NX = 1;
    
    for(int j = 0; j < N; j++){
        NX *= 2;
    }
    dp[0] = 0;
    //cout << NX << endl;
    for(int i = 0; i < M; i++){
        lint xx = 0;
        for(int j = N-1; j >= 0; j--){
            xx = xx << 1;
            if(c[i][j]) xx += 1;
            //cout << xx << endl;
        }
        for(int k = 0; k < NX; k++){
            lint subx = xx | k;
            dp[subx] = min(dp[subx], dp[k]+a[i]);
            //cout << k << " " << subx  << " " << xx << endl;
            //cout << i << " " << k << " " << dp[i][k] << endl;
            //cout << i+1 << " " << subx << " " << dp[i+1][subx] << endl;
        }
    }
    if(dp[NX-1] < INF){
        cout << dp[NX-1] << endl;
    }else{
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);


    int n;

    cin >> n;

    set <int> s;

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

        cin >> temp;

        s.insert(temp);
    }

    if(s.size() == n)
    {
        cout << "YES";
    }

    else
    {
        cout << "NO";
    }
}









Measured memory_bytes: 12956
def c_exception_handling(N, A):
    max_from_left = [0]
    max_from_right = []

    tmp = 0
    for a in A[:N - 1]:
        if a > tmp:
            tmp = a
        max_from_left.append(tmp)
    tmp = 0
    for a in A[N:0:-1]:
        if a > tmp:
            tmp = a
        max_from_right.append(tmp)

    max_from_right = max_from_right[::-1] + [0]
    ans = [max(a, b) for a, b in zip(max_from_left, max_from_right)]
    return '\n'.join(map(str, ans))

N = int(input())
A = [int(input()) for _ in range(N)]
print(c_exception_handling(N, A))

Measured memory_bytes: 29840
h,w=map(int,input().split())
P=[]
for i in range(h):
  C=[str(_) for _ in input()]
  P+=C
par=[[-1,0,0] for _ in range(h*w)]
def find(x):
  if par[x][0]<0:
    return x
  else:
    par[x][0]=find(par[x][0])
    return par[x][0]
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x][0]>par[y][0]:
      x,y=y,x
    par[x][0]+=par[y][0]
    par[y][0]=x
    return True
def same(x,y):
  return find(x)==find(y)
def size(x):
  return -par[find(x)][0]
for i in range(h*w):
  if P[i]=="#":
    par[i][1]+=1
    if (i+1)%w!=0 and P[i+1]==".":
      unite(i,i+1)
    if (i+w)<(h*w) and P[i+w]==".":
      unite(i,i+w)
  else:
    par[i][2]+=1
    if (i+1)%w!=0 and P[i+1]=="#":
      unite(i,i+1)
    if (i+w)<(h*w) and P[i+w]=="#":
      unite(i,i+w)
ans=0
for p,x,y in par:
  if p>=0:
    par[find(p)][1]+=x
    par[find(p)][2]+=y
for p,x,y in par:
  if p<-1:
    ans+=x*y
print(ans)

Measured memory_bytes: 21288
n,m=map(int,input().split())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append([x,y])
l.sort()
ans=0
re=m
for i in range(n):
    if re-l[i][1]>0:
        ans+=l[i][0]*l[i][1]
        re-=l[i][1]
    else:
        ans+=l[i][0]*re
        break
print(ans)

Measured memory_bytes: 20048
/*
 * N
 * u1 v1 w1
 * ...
 * un vn wn
*/

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>

using namespace std;
// pair(edge, weight)
using Graph = vector< vector< pair<int, int> > >;

vector<bool> seen;
vector<int> answer;

void dfs(const Graph &g, int i) {
  seen[i] = true;
  // printf("i %d\n", i);

  for (auto next_v : g[i]) {
    int next_i = next_v.first;
    // printf("  next_i %d\n", next_i);
    if (seen[next_i]) continue;

    int color = answer[i];
    // printf("  color %d\n", color);

    assert(color != -1);

    if (next_v.second % 2 == 0) {
      // 偶数なら同じ色をつかう
      answer[next_i] = color;
    }
    else {
      answer[next_i] = (color == 1 ? 0 : 1);
    }

    dfs(g, next_i);
  }
}

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

  // pair(edge, weight)
  Graph g(N);

  for (int i = 0; i < N - 1; i++) {
    int U, V, W;
    cin >> U >> V >> W;

    g.at(U - 1).push_back(make_pair(V - 1, W));
    g.at(V - 1).push_back(make_pair(U - 1, W));
  }

  seen.assign(N, false);
  answer.assign(N, -1);
  answer[0] = 0;

  dfs(g, 0);

  for (int i = 0; i < N; i++) {
    cout << answer[i] << endl;
  }
}


Measured memory_bytes: 8192
N = int(input())
L = []
candidates = [list(bin(i)[2:].zfill(N)) for i in range(2**N)]

for i in range(N):
    A = int(input())
    said = [list(map(int,input().split())) for i in range(A)]
    L.append(said)

ans = 0
for pattern in candidates:
    tmp = 0
    flag = 1
    for j in range(N): #pattern内全て
        if pattern[j] == "1":
            for said in L[j]:
                if pattern[said[0] - 1] != str(said[1]):
                    flag = 0
        else:
            pass
    if flag == 1:
        ans = max(ans, pattern.count("1"))

print(ans)

Measured memory_bytes: 66140
"""
unionFind木を使う。
根に対する距離を記録していく。
"""
import sys
sys.setrecursionlimit(2000000)
input = sys.stdin.readline
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.distance = [0]*(n+1)

    def find(self,x):
        if self.parents[x]==x:
            return x,0
        else:
            self.parents[x],dist2=self.find(self.parents[x])
            self.distance[x] += dist2
            return self.parents[x],self.distance[x]

    def union(self,l,r,dist):
        lRoot,lDist = self.find(l)
        rRoot,rDist = self.find(r)
        #まず、位置関係に矛盾がないかを調べる
        #lRootはlよりlDist右にいる
        #rRootはrよりrDist右にいる
        #lRoot=rRootのとき、lDist-rDist != distなら矛盾。
        if lRoot==rRoot and lDist-rDist != dist:
            print("No")
            exit()

        #より左にいる根を右にいる根にマージする
        if lDist < dist+rDist:
            #lRootがrRootよりも左の場合
            self.parents[lRoot]=rRoot
            self.distance[lRoot]=(dist+rDist)-lDist
        else:
            self.parents[rRoot]=lRoot
            self.distance[rRoot]=lDist-(dist+rDist)

N,M = map(int,input().split())
tree = UnionFind(N)
for i in range(M):
    L,R,D = map(int,input().split())
    tree.union(L,R,D)

print('Yes')

Measured memory_bytes: 89376
#include<iostream>
using namespace std;
int main()
{
  int n,c=1,d;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  d=a[0];
  for(int i=1;i<n;i++)
  {
    if(a[i]<=d)
    {
      c++;
      d=a[i];
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 4416