akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void bubbleSort(int A[], int N) {
    int c = 0;
    int flag = 1;
    int j, tmp;

    while (flag) {
        flag = 0;
        for (j = N-1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;

                c++;
                flag = 1;
            }
        }
    }
    for (j = 0; j < N; j++) {
        printf("%d", A[j]);
        if (j != N-1)
            printf(" ");
        else
            printf("\n");
    }
    printf("%d\n", c);
}

int main()
{
    int N, A[101];
    int i;

    scanf("%d", &N);

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

    bubbleSort(A, N);

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

template<typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll res = b - (b / c + b / d - b / lcm(c, d));
	a--;
	ll tmp = a - (a / c + a / d - a / lcm(c, d));
	cout << res - tmp << endl;
    
    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000006
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;


int main()
{
    lli cur=0;
    lli sum=0;

    lli n;
    cin>>n;

    for(lli i=0; i<n; i++)
    {
        lli a;
        cin>>a;

        if(i)
        {
            lli diff= max(cur-a, 0LL);
            sum+=diff;
        }

        cur=max(a, cur);
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine());

            Console.WriteLine((a + a * a + a * a * a).ToString());
        }
    }
}

Measured memory_bytes: 27452
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=998244353;
const long long int INF=99999999999999999;

long long int n,m,sum,res=0;

int main() {
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){cout<<"Yes";return 0;}
        }
    }
    cout<<"No"<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

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

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

vector<int> ans;
vector<ll> a;

void foo(int i) {
    ans.eb(i);
    if (i == 0 || i == (int)a.size() - 1)
        a.erase(a.begin() + i);
    else {
        a[i] = a[i - 1] + a[i + 1];
        a.erase(a.begin() + i + 1);
        a.erase(a.begin() + i - 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    a.resize(n);
    cin >> a;
    vector<ll> s(2, 0);
    ll res;
    forn(i, 0, n) if (a[i] > 0) s[i % 2] += a[i];
    if (s[0] == 0 && s[1] == 0) {
        int pos = 0;
        forn(i, 0, n)
            if (a[i] > a[pos])
                pos = i;
        res = a[pos];
        while (a[0] != res)
            foo(0);
        while (a.size() > 1)
            foo((int)a.size() - 1);
    } else {
        int opt = s[0] > s[1] ? 0 : 1;
        res = s[opt];
        while (opt || a[0] < 0) {
            foo(0);
            opt ^= 1;
        }
        while ((int)a.size() % 2 == 0 || a.back() < 0)
            foo((int)a.size() - 1);
        for (int i = 0; i < (int)a.size(); i += 2)
            while (a[i] < 0) {
                foo(i);
            }
        int sz = (int)a.size();
        for (int i = 0; i < sz / 2; ++i)
            foo(1);
    }
    cout << res << '\n';
    cout << ans.size() << '\n';
    for (int x : ans) cout << 1 + x << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  V<> a(5); for (auto&& e : a) cin >> e;
  int res = 0, mx = 0;
  for (int i = 0; i < 5; ++i) {
    int curr = (a[i] + 9) / 10 * 10;
    res += curr;
    mx = max(mx, curr - a[i]);
  }
  cout << res - mx << '\n';
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  ll K;
  cin >> K;
  ll ans = 0;
  rep(a, 1, K+1) {
    rep(b, 1, K+1) {
      rep(c, 1, K+1) {
        ll tmp = __gcd((ll) a, (ll) b);
        tmp = __gcd(tmp, (ll) c);
        ans += tmp;
      }
    }
  }

  cout << ans << endl;

  return 0;
};


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

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int tc;

void solve(){

    string n;
    cin>>n;
    char p=n[n.size()-1];
    if(p=='3')cout<<"bon"<<endl;
    else if(p=='0' || p=='1' || p=='6' || p=='8')cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

int main()
{

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}







Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, q;
    cin >> n;
    vector<ll> s(n);
    rep(i, n) cin >> s[i];
    cin >> q;
    ll ans = 0;
    rep(i, q) {
        ll t;
        cin >> t;
        if(*lower_bound(s.begin(), s.end(), t) == t) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int total_test_cases;
  while(~scanf("%d",&total_test_cases)){
    for(int test_i = 0; test_i < total_test_cases; test_i++){
      string tmp_stage;
      cin >> tmp_stage;
      vector<int> stage;
      for(int i = 0; i < tmp_stage.size(); i++){
        stage.push_back(tmp_stage[i] - '0');
      }

      int count = 0;
      while(stage.size() >= 2){
        stringstream ss;
        ss << (stage[stage.size()-2] + stage[stage.size()-1]);
        stage.pop_back();
        stage.pop_back();
        for(int i = 0; i < ss.str().size(); i++){
          stage.push_back(ss.str()[i] - '0');
        }
        count++;
      }
      printf("%s\n",count % 2 == 0 ? "Audrey wins." : "Fabre wins.");
    }
  }
}

Measured memory_bytes: 1276
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
  //?????¶????????§?§£????????¨?????????
  int H, W;
  while(cin >> H >> W, H||W){
    string pattern[H];
    for(int i = 0; i < H; ++i){
      cin >> pattern[i];
    }
    int ng = H*W + 1, ok = 2;
    int dx[] = {1,0,-1,0,1,1,-1,-1}, dy[] = {0,1,0,-1,1,-1,1,-1};
    string ans = "0";
    while(ng - ok > 1){
      int m = (ng + ok)/2;
      map<string,int> M;
      for(int i = 0; i < H; ++i){
	for(int j = 0; j < W; ++j){
	  for(int k = 0; k < 8; ++k){
	    string str(m,'.');
	    str[0] = pattern[i][j];
	    bool f = true;
	    for(int l = 1; l < m; ++l){//??????????????????
	      int s = ((i + l*dx[k])%H+H)%H, t = ((j + l*dy[k])%W+W)%W;
	      if(s == i && t == j){
		f = false;
		break;
	      }else{
		str[l] = pattern[s][t];
		//str += pattern[s][t];
	      }
	    }
	    //cout << str << endl;
	    if(f){
	      M[str] += 1;
	    }
	  }
	}
      }
      bool g = false;
      //for(map<string,int>::iterator itr = M.end(); itr != M.begin(); --itr){
      for(map<string,int>::iterator itr = M.begin(); itr != M.end(); ++itr){
	if(itr->second > 1){
	  g = true;
	  ans = itr->first;
	  break;
	}
      }
      
      if(g){
	ok = m;
      }else{
	ng = m;
      }

    }
    
    cout << ans << endl;
    
  }
  return 0;
}

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

int main(){
    ll n,y;
    cin >> n >> y;
    int a,b,c;
    a = b = c = -1;
    rep(i,n+1){
        rep(j,n+1){
            if(j + i > n) break;
            if(i*10000 + j*5000 + (n - j - i)* 1000 == y){
                a = i;
                b = j;
                c = n - i - j;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
}

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

int main(){
    int k,x;
    cin >> k >> x;
    int start = x - k + 1;
    int end = x + k - 1;
    for(int i=start; i<=end; i++){
        cout << i << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int w[101];

int main (){
  int n;
  int i,c=0,f=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>w[i];
    c+=w[i];
  }
  int z=100000;
  for(i=0;i<n-1;i++){
    f+=w[i];
    c-=w[i];
    if(z>abs(f-c)){
      z=abs(f-c);
    }
  }
  cout<<z<<endl;
  return 0;
}
    
    

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

map<int,pair<int,int>> mp;
long long int c[90005];
int main(){
    int h,w,d;
    cin >> h >> w >> d;
    int a[h+1][w+1];
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
        cin >> a[i][j];
        mp[a[i][j]]=make_pair(i,j);
    }
    for(int i=d+1;i<=h*w;i++){
        c[i]=c[i-d]+abs(mp[i].first-mp[i-d].first)+abs(mp[i].second-mp[i-d].second);
    }
    int q,l,r;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> l >> r;
        cout << c[r]-c[l] << endl;
    } 
}

Measured memory_bytes: 10248
// AtCoder Grand Contest 018
// B - Sports Festival

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 300;
const int MAX_M = 300;

int N, M;
int a[MAX_N][MAX_M];
bool removed[MAX_M];
int cnt[MAX_M];
int idx[MAX_N];

int main() {

    int mm, mp;
    int ans;

    cin >> N >> M;
    memset(removed, 0, sizeof(removed));
    memset(cnt, 0, sizeof(cnt));
    memset(idx, 0, sizeof(idx));
    mp = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> a[i][j]; a[i][j]--;
        }
        idx[i] = 0;
        cnt[a[i][idx[i]]]++;
        if (cnt[a[i][idx[i]]] >= mp) {
            mp = cnt[a[i][idx[i]]];
            mm = a[i][idx[i]];
        }
    }
    ans = mp;

    for (int k = 0; k < M - 1; k++) {
        removed[mm] = true;
        for (int i = 0; i < N; i++) {
            cnt[a[i][idx[i]]]--;
            for (int &j = idx[i]; j < M && removed[a[i][j]]; j++) {}
            cnt[a[i][idx[i]]]++;
        }
        mp = 0;
        for (int j = 0; j < M; j++) {
            if (cnt[j] >= mp) {
                mp = cnt[j];
                mm = j;
            }
        }
        ans = min(ans, mp);
    }

    cout << ans << endl;

    return 0;

}






Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
  ll N,M,R;cin>>N>>M>>R;
  vector <ll> r;r.resize(R);
  for(int i=0;i<R;i++) cin>>r[i];
  sort(r.begin(),r.end());
  ll cost[210][210];//{INF};
  for(int i=0;i<210;i++){
    for(int j=0;j<210;j++){
      cost[i][j] = INF;
    }
  }
  for(int i=0;i<M;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    cost[a][b] = c;//min(cost[a][b],c);
    cost[b][a] = cost[a][b];
  }
  for(int i=0;i<210;i++) cost[i][i] = 0;

  for(int k=1;k<=N;k++){
    for(int i=1;i<=N;i++){
      for(int j=1;j<=N;j++){
        cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
      }
    }
  }

  ll ans = INF;
  ll cnt =1;

  do {
    cnt++;

    ll preans = 0;
    //cout<<r[0];
    for(int i=1;i<R;i++){
      //cout<<r[i];
      preans += cost[r[i-1]][r[i]];
    }
    //cout<<endl;
    ans = min(preans,ans);

  } while (next_permutation(r.begin(),r.end()) or cnt < 8*7*6*5*4*3*2 + 10);

/*
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cout<<cost[i][j];
    }
    cout<<endl;
  }
*/
cout<<ans<<endl;


  return 0;

}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<Vi> ans(N + 1, Vi(N + 1));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << endl;
	}

	return 0;
}

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

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

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T cost; //辺の重み
    Edge(int t, T w) : srch(-1), to(t), cost(w) {}
    Edge(int t, T w, int src) : srch(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = std::vector<std::vector<Edge<T>>>;   //重み付きグラフ
using Graph = std::vector<std::vector<int>>;         //通常グラフ
template<typename T>
using Matrix = std::vector<std::vector<T>>;          //隣接行列(使わなさそう...)


vi d,f;
Graph g;
int TIME;
/*FUNCs=================================================*/
void recursive(int u) {
    d[u] = ++TIME;
    for(auto &v : g[u]) {
        if(d[v] != 0) continue;
        recursive(v);
    }
    f[u] = ++TIME;
}

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

    int n; cin >> n;
    d.resize(n+1), f.resize(n+1);
    g.resize(n+1);

    rep(i,n) {
        int u,v; cin >> u;
        u;
        g[0].push_back(u);
        int k; cin >> k;
        rep(j,k) {
            cin >> v;
            v;
            g[u].push_back(v);
        }
    }

    TIME = -1;
    recursive(0);

    for(int i = 1; i <= n; ++i) {
        cout << i << ' ';
        cout << d[i] << ' ';
        cout << f[i] << '\n';
    }

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3184
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	n := len(s)
	ok := (s == "keyence")
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			t := s[0:i] + s[j:n]
			if t == "keyence" {
				ok = true
			}
		}
	}

	if ok {
		puts("YES")
	} else {
		puts("NO")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

int main(){
  int A,B;
  string S;
  cin >> A >> B >> S;
  bool a=false;
  for(int  i=0;i<A+B+1;i++){
    if(i==A && S.at(i)!='-'){
      a=true;
    }
    else if(i!=A && S.at(i)=='-'){
      a=true;
    }
  }
  if(!a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = A; i <= B; i++)
    {
        if (i < A + K||i > B - K)
        {
            cout << i << endl;
        }
    }
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int gcd (int s, int t) {
  if (s < t) swap(s,t);
  return t != 0 ? gcd(t, s % t) : s;
}

int main(){
  int a, b;
  scanf("%d %d",&a,&b);
  printf("%d\n",gcd(a, b));
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   char a,b;
   cin >> a >> b;
   cout << (a==b ? 'H' : 'D');
 }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const long long int inf=1e18+7;
const int mod=1e9+7;

//const int maxn=

int main()
{
//	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	double a,b,x;
	
	cin>>a>>b>>x;
	
	double pi=acos(-1);
	
	double y=a*a*b-x;
	
	x*=2;
	
	double h=x/a/b;	
	
	double thita=atan(b/h)*180/pi;
	
	y*=2;
	
	double d=y/a/a;
	
	double thita1=atan(d/a)*180/pi;
	
	
	if(x<=y)
		printf("%.10f\n",thita);
	else
		printf("%.10f\n",thita1);
	
	return 0;
}

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

P y[100003];
int n,m,h,k;
int nau[1003];
int tokuten[1003];
P hen[100004];
int ans = 0;
int ii[1003];
int main(){
while(1){
	scanf("%d%d%d%d",&n,&m,&h,&k);
	if(n == 0)break;
	ans = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d",&tokuten[i]);
	}

	for(int i = 0;i < m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		hen[i] = (P(b,a));
	}
	sort(hen,hen + m);
	for(int i = 1;i <= n;i++){
		nau[i] = i;
	}
	for(int i = 0;i < m;i++){
		y[i] = (P(nau[hen[i].second],nau[hen[i].second+1]));
		swap(nau[hen[i].second],nau[hen[i].second+1]);
	}

	for(int i = 1;i <= n;i++){
		if(nau[i] <= k)ans += tokuten[i];
		ii[nau[i]] = tokuten[i];
	}
	int sa = 0;
	for(int i = 0;i < m;i++){
		int a = y[i].first,b = y[i].second;
		if(a > b) swap(a,b);
		if(a <= k && b > k){
			sa = min(sa,ii[b]-ii[a]);
		}
	}
	printf("%d\n",ans+sa);
}
	return 0;
}


Measured memory_bytes: 2760
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    ll = list(map(int, input().split()))
    ll.sort()

    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            rest = ll[j + 1:]
            a_plus_b = ll[i] + ll[j]
            pos_right = bisect.bisect_left(rest, a_plus_b)
            count = pos_right

            ans += count
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61024
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, a[101], sum=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> a[i];

        if(i%2==1 && a[i]%2==1) sum++;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k;
	cin >> n >> m >> k;
	k = n*m-k;
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)
		if(i*j+(m-j)*(n-i)==k)return printf("Yes")&&0;
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
typedef long long ll;
using namespace std;

int main() {
	ll n, m; scanf("%lld%lld", &n, &m);
	multimap<ll, ll> ab_map;

	// mapはソートされる
	for (int i = 0; i < n; ++i) {
		ll a, b; scanf("%lld%lld", &a, &b);
		ab_map.insert(make_pair(a, b));
	}

	ll ans = 0;
	for (auto itr = ab_map.begin(); itr != ab_map.end(); ++itr) {
		ll price = itr->first;
		ll cnt = itr->second;

		if (cnt > m) {
			ans += price * m;
			break;
		}
		else {
			ans += price * cnt;
			m -= cnt;
		}

	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0;
  cin >> N;
  map <ll,ll> mp;
  rep(i,N){
    int a = 0; cin >> a;
    mp[a] = i + 1;
  }
  for(auto p: mp){
    cout << p.second << " ";
  }
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string S;
	cin >> S;
	bool ok = true;
	if(S.size() < 4) ok = false;
	if(ok) ok = (S.substr(0, 4) == "YAKI");
	Cout(Yes(ok));
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  while(true) {
    int d[100];
    fill(d,d+100,0);
    d[0]=d[1]=1;
    while(true) {
      int a,b;
      if(scanf("%d%d", &a, &b)<2) return 0;
      if(a==0) break;
      a--; b--;
      d[a]++; d[b]++;
    }
    bool ok = true;
    for(int i = 0; i < 100; i++) ok = ok && (d[i]&1)==0;
    printf("%s\n", ok ? "OK" : "NG");
  }
  return 0;
}

Measured memory_bytes: 1012
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const LL inf = 0x3f3f3f3f;
int main(void){
    int k,v,u;
    cin>>k;
    vector<int> dp(k,1000);
    dp[1] = 0;
    deque<int> deq;
    deq.push_front(1);
    while(v = deq.front()){
        deq.pop_front();
        u = (v*10)%k;
        if(dp[u] > dp[v]){
            dp[u] = dp[v];
            deq.push_front(u);
        }
        u = (v+1)%k;
        if(dp[u] > dp[v]+1){
            dp[u] = dp[v]+1;
            deq.push_back(u);
        }
    }
    cout<<dp[v]+1<<endl;
}


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

int main()
{
  int n, y;
  cin >> n >> y;

  int a = -1, b = -1, c = -1;

  for (int i = 0; i <= n; ++i)
  {
    for (int j = 0; j <= n; ++j)
    {
      int k = n - i - j;
      if (k >= 0)
      {
        if (10000 * i + 5000 * j + 1000 * k == y)
        {
          a = i, b = j, c = k;
        }
      }
    }
  }
  cout << a << ' ' << b << ' ' << c << endl;

  return 0;
}


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

using namespace std;

int main()
{
  int x,y;
  cin>>x>>y;
  for(int i=0;i<=x;i++)
  {
    if(i*2+(x-i)*4==y)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a;
  cin >> n >> a;
  cout << n*n-a << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A, B, C;
    cin >> A >> B >> C;
    cout << A[0] << B[0] << C[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[100005][3];
int dp[100005][3];

int func(int pos,int des,int idx){
    if(dp[pos][idx]!=-1) return dp[pos][idx];
    int res;
    if(pos>des) res=0;
    else{
        int t1,t2;
        if(idx==0){
            t1=ara[pos][0]+func(pos+1,des,1);
            t2=ara[pos][0]+func(pos+1,des,2);
        }
        else if(idx==1){
             t1=ara[pos][1]+func(pos+1,des,0);
            t2=ara[pos][1]+func(pos+1,des,2);
        }
        else{
             t1=ara[pos][2]+func(pos+1,des,1);
            t2=ara[pos][2]+func(pos+1,des,0);
        }
        res=max(t1,t2);
    }
    dp[pos][idx]=res;
    return res;
}
int main(){
    memset(dp,-1,sizeof(dp));
    int n,x,y,z;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> ara[i][0] >> ara[i][1] >> ara[i][2];
    }
    x=func(1,n,0);
    y=func(1,n,1);
    z=func(1,n,2);
    int ans;
    
    ans=max(x,y);
    ans=max(ans,z);
    
    cout << ans << endl;
    
}

Measured memory_bytes: 12004
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define cl(x,y) memset(x,y,sizeof(x))
#define ct cerr<<"Time elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
const int N=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x;
	cin>>x;
	ll sum=0;
	sum=x/500*1000;
	x%=500;
	sum+=x/5*5;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[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;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll n, k;
    cin >> n >> k;
    ll mod = 1e9+7;
    ll ans = n-k+1;
    COMinit();
    for (int i = 1; i <= k; i++)
    {   
       
        cout << COM(n-k+1,i)*COM(k-1,i-1) %mod<< endl;
    }
    //cerr << (ll)3990006 * 1996 % mod << endl;

    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
    using namespace std;
	int main(){
      int A,B;
      cin >> A >> B;
      int answer = 0;
      
      for(int i = A; i < B+1; i++){
        string j = to_string(i);
        string p,q,r,s,t;
        p = j[0];
        q = j[1];
        r = j[2];
        s = j[3];
        t = j[4];
        if (p == t && q ==s) answer++;
        else continue;
      }
      cout << answer << endl;
    }


Measured memory_bytes: 3652
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, c, k;
	cin>>n>>c>>k;
	vector<ll> t(n);
	rep(i, n) cin>>t[i];
	sort(all(t)); reverse(all(t));
	ll res = 1, p = 0;
	rep(i, n){
		if(i>=p+c || t[i]+k<t[p]){
			res++;
			p = i;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char a[20000];
    scanf("%s",a); printf("%c",a[0]);
    scanf("%s",a); printf("%c",a[0]);
    scanf("%s",a); printf("%c",a[0]);
    return 0;
}

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

void print(int a, int b, string str) {
    cout << str.substr(a, b - a + 1) << endl;
}

string reverse(int a, int b, string str) {
    string tmp = "";

    for (int i = 0; i < str.length(); ++i) {
        if (i < a || b < i) {
            tmp.append(1, str[i]);
        } else {
            tmp.append(1, str[b + a - i]);
        }
    }

    return tmp;
}

string replace(int a, int b, string p, string str) {
    string h = str.substr(0, a);
    string t = str.substr(b + 1, string::npos);
    return h + p + t;
}

int main() {
    string str;
    cin >> str;

    int q;
    cin >> q;

    for (int i = 0; i < q; ++i) {
        string cmd;
        cin >> cmd;

        if (cmd == "print") {
            int j, k;
            cin >> j >> k;

            print(j, k, str);
            continue;
        }
        if (cmd == "reverse") {
            int j, k;
            cin >> j >> k;

            str = reverse(j, k, str);
            continue;
        }
        if (cmd == "replace") {
            int j, k;
            cin >> j >> k;

            string p;
            cin >> p;

            str = replace(j, k, p, str);
            continue;
        }
    }

    return 0;
}

Measured memory_bytes: 1224
n,m = map(int, input().split())
xs = list(map(int, input().split()))
xs.sort()

ds = []
for i in range(m-1):
    ds.append(xs[i+1] - xs[i])

ds.sort()
to = m - n

if to > 0:
    print(sum(ds[0:to]))
else:
    print(0)

Measured memory_bytes: 13968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int heads = in.ni(), legs = in.ni();
			if (legs % 2 != 0 || heads == 0 || heads > legs) out.println("No");
			else {
				int t = (legs + (-2*heads))/2;
				int c = heads - t;
				if (t < 0 || c < 0) {
					out.println("No");
					return;
				}
				out.println("Yes");
			}
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		private int ni() {
			return Integer.parseInt(n());
		}
	}

}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int N;
  cin >> N;
  int a[310][310],g[310][310];
  rep(i,N){
    rep(j,N){
      cin >> a[i][j];
      g[i][j] = a[i][j];
    }
  }

  rep(k,N){
    rep(i,N){
      rep(j,N){
        if(k==i || i==j || j==k || g[i][k]==INF || g[k][j]==INF)continue;
        if(a[i][j] == g[i][k]+g[k][j]){
          g[i][j] = INF;
        }else{
          if(a[i][j] > g[i][k]+g[k][j]){
            cout << -1 << endl;
            return 0;
          }
        }
      }
    }
  }

  ll sum = 0;
  rep(i,N){
    rep(j,N){
      if(g[i][j]!=INF)sum+=g[i][j];
    }
  }

  cout << sum/2 << endl;
}

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

using namespace std;

int main() {
    
    float n;
    
    cin>>n;
    
    for(int i=1;i<=n;i++)
    if(floor(i*1.08)==n)
    {
        cout<<i;
        return 0;
    }
    
    cout<<":(";
}

Measured memory_bytes: 256
n = int(input())
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["#" for x in range(20)]))


Measured memory_bytes: 5612
n=int(input())
s=list(input())
W,E=[0]*n,[0]*n
if s[0]=='W':
  W[0]=1
if s[-1]=='E':
  E[-1]=1
for i in range(1,n):
  if s[i]=='W':
    W[i]=W[i-1]+1
  else:
    W[i]=W[i-1]
  if s[n-1-i]=='E':
    E[n-1-i]=E[n-i]+1
  else:
    E[n-1-i]=E[n-i]
ans=10**9
for i in range(n):
  if i==0:
    ans=min(ans,E[1])
  elif i==n-1:
    ans=min(ans,W[n-2])
  else:
    ans=min(ans,E[i+1]+W[i-1])
print(ans)

Measured memory_bytes: 19856
#include <stdio.h>
#define MAX     111111

long abso(long x) {
    return (x > 0) ? x : (-1 * x);
}

int min(int x, int y) {
    return (x < y) ? x : y;
}

int max(int x, int y) {
    return (x > y) ? x : y;
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int dp[MAX], nums[MAX];
    dp[0] = 0;

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

    for (int i = 1; i < n; i++) {
        dp[i] = dp[max(0, i - k)] + abso(nums[i] - nums[max(0, i - k)]);
        int m = max(0, i - k);
        if (m == 0) {
            for (int a = 1; a < i; a++) dp[i] = min(dp[i], dp[a] + abso(nums[i] - nums[a])); 
        } else {
            for (int a = m; a < i; a++) dp[i] = min(dp[i], dp[a] + abso(nums[i] - nums[a]));
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 896
n = int(input())
W = [ input() for _ in range(n) ]
if sorted(W) != sorted(list(set(W))):
  print("No")
else:
  for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
      print("No")
      exit()
  print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int m=0;
long long s,n,a[1234567];
int main(){
    cin>>n;
    for(int i=1;i<1234567;i++){
        if((n%i)==0){
            a[m]=(i+(n/i)-2);
            m++;
        }
    }
    s=a[0];
    for(int i=1;i<m;i++){
        if(s>a[i])s=a[i];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=610;
const int M=1e9+7;
typedef long long ll;
int n,m,op[N],g[N],s[N];
bool empty[N];
int ans,f[N][N];
int main(){
    scanf("%d%d",&n,&m);
    n*=2;
    for (int i=1; i<=n; ++i) empty[i]=1;
    for (int i=1,x,y; i<=m; ++i){
	scanf("%d%d",&x,&y);
	op[x]=y;
	op[y]=x;
	empty[x]=0;
	empty[y]=0;
    }
    g[0]=1;
    for (int i=2; i<=n; i+=2) g[i]=(ll)g[i-2]*(i-1)%M;
    for (int i=1; i<=n; ++i) s[i]=s[i-1]+empty[i];
    //for (int i=1; i<=n; ++i) cerr<<i<<" "<<s[i]<<endl;
    for (int k=1; k<=n; ++k)
	for (int i=1; i+k-1<=n; ++i){
	    int j=i+k-1;
	    if ((s[j]-s[i-1])&1) continue;
	    bool fl=0;
	    for (int l=i; l<=j; ++l) if (!empty[l]&&(op[l]<i||op[l]>j)) fl=1;
	    if (fl) continue;
	    int &ret=f[i][j];
	    ret=g[s[j]-s[i-1]];
	    for (int l=i; l<j; ++l)
		(ret+=M-(ll)f[i][l]*g[s[j]-s[l]]%M)%=M;
	    (ans+=(ll)ret*g[n-2*m-s[j]+s[i-1]]%M)%=M;
	    //cerr<<i<<" "<<j<<" "<<f[i][j]<<endl;
	}
    cout<<ans;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int ret = 0;
  
  for (int i = A; i <= B; i++) {
    int s1, s2, s4, s5;
    s1 = i / 10000;
    s5 = i % 10;
    
    if (s1 != s5) {
      continue;
    }
    
    s2 = (i / 1000) % 10;
    s4 = (i / 10) % 10;

    if (s2 == s4)
      ret++;
  }
  
  cout << ret << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>


int main(){
    int a, p;
    cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		Card[] A=new Card[n];

		for(int i=0;i<n;i++) {
			A[i]=new Card(in.next().charAt(0),Integer.parseInt(in.next()));
		}
		in.close();
		Card[] B=A.clone();
		quickSort(A,0,n-1);
		margeSort(B,0,n-1);

		PrintWriter out=new PrintWriter(System.out);
		int s=0;
		for(;s<A.length;s++) {
			if(A[s].s!=B[s].s)break;
		}
		out.println((s==A.length)? "Stable":"Not stable");
		//System.out.println(s);
		for(int i=0;i<n;i++) {
			out.println(A[i].s+" "+A[i].v);
		}
		out.flush();
	}
	
	static int partition(Card A[],int l,int r) {
		int i=l-1,j=l,x=A[r].v;
		Card t;
		
		for(;j<r;j++) {
			if(A[j].v<=x) {
				t=A[++i]; A[i]=A[j]; A[j]=t;
			}
		}
		t=A[++i]; A[i]=A[r]; A[r]=t;
		return i;
	}
	
	static void quickSort(Card A[],int l,int r) {
		if(l<r) {
			int m=partition(A,l,r);
			quickSort(A,l,m-1);
			quickSort(A,m,r);
		}
	}

	static void margeSort(Card A[],int left,int right) {
		int middle=left+((right-left+1)/2);
		if(left!=right) {
			margeSort(A,left,middle-1);
			margeSort(A,middle,right);
		}
		else return;

		int k=left,l=middle,cnt=0;
		Card B[]=new Card[right-left+1];
		while(k<middle && l<=right) {
			if(A[k].v<=A[l].v)B[cnt++]=A[k++];
			else B[cnt++]=A[l++];
		}

		while(k<middle) B[cnt++]=A[k++];
		while(l<=right) B[cnt++]=A[l++];

		for(int i=0;i<B.length;i++)A[left+i]=B[i];
	}

}

class Card{
	int v;
	char s;

	Card(char c,int v){
		s=c;
		this.v=v;
	}

	int getN(){
		return v;
	}
}



Measured memory_bytes: 74760
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,m;

int main(){
	cin >> n >> m;
	
	if(2*n<=m) cout << n+(m-2*n)/4 << endl;
	else cout << m/2 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	// プログラミング開始時のテンプレ
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int[] a = strToIntArray(br.readLine());
			Arrays.sort(a);
			if(a[0] == 5 && a[1] == 5 && a[2] == 7){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			System.out.println();
		} catch (Exception e) {
			System.err.println("Error:" + e.getMessage());
		}
	}

	// Stringで読みこんでスペースで分割されている数字を配列に入れるやつ
	// 利用法 int[] A = strTointArray(br.readLine());
	static int[] strToIntArray(String S) {
		String[] strArray = S.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}


Measured memory_bytes: 8020