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

int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  // string s;
  // cin>>s;
  int A[Q];
  for (int i = 0; i < Q;i++) cin>>A[i];
  for (int i = 0; i < Q;i++) A[i]-= 1;


  int minA = 0;
  if (K > Q) minA = 0;
  else minA = Q-K + 1;

  int Nans[N] = {0};
  for (int i = 0; i < Q;i++) {
    Nans[A[i]]++;
  }
  for (int i = 0; i < N;i++) {
    if (Nans[i] >= minA) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  // int val = 0;
  // cout<<val<<endl;
  return 0;
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

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

    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        int a, b, x;
        cin >> a >> b >> x;
        a--; b--;
        uf.unite(a, b);
    }

    set<int> st;
    for(int i = 0; i < n; i++){
        st.insert(uf.root(i));
    }

    cout << st.size() << endl;


    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int A, B;
	cin >> A >> B;
	if(A==1)
	{
		if(B==2)
		{
			cout << 3;
		}
		else
		{
			cout << 2;
		}
	}
	else if(A==2)
	{
		if(B==1)
		{
			cout << 3;
		}
		else
		{
			cout << 1;
		}
	}
	else
	{
		if(B==2)
		{
			cout << 1;
		}
		else
		{
			cout << 2;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#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 N;
    ll ans=0;
    cin >> N;
    REP(i, N){
        ans+=i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string s; cin >> s;
  string t(s.rbegin(), s.rend());
  int r{};
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) ++r;
  }
  auto ans = (r + 1) / 2;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string.h>

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if(a < b) cout << "a < b" << endl;
	else if(a > b) cout << "a > b" << endl;
	else cout << "a == b" << endl;
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vector<vector<double>> dp(N+1,vector<double>(N+1));
  dp[0][0]=1;
  REP(i,1,N){
    double A; cin>>A;
    double B=1-A;
    dp[i][0]=dp[i-1][0]*B;
    REP(j,1,N)
      dp[i][j]=dp[i-1][j]*B+dp[i-1][j-1]*A;
  }
  double ans=0;
  REP(i,N/2+1,N) ans+=dp[N][i];
  printf("%.10lf\n",ans);
  }



Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    REP(i, n) {
        int a;
        cin >> a;
        FOR(j, 2, sqrt(a)+1) {
            if(a % j == 0) {
                goto L1;
            }
        }
        ans++;
        L1:{};
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3001;
double dp[N + 1][N + 1];
double a[N];

double solve(int i, int x) {
	if (x == 0)
		return 1;
	if (i == -1)
		return 0;
	if (dp[i][x] > -0.9)
		return dp[i][x];
	return dp[i][x] = (solve(i - 1, x - 1) * a[i] + solve(i - 1, x) * (1 - a[i]));
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	memset(dp, -1, sizeof(dp));
	cout << fixed << setprecision(10) << solve(n, (n + 1) / 2);

	return 0;
}

Measured memory_bytes: 74404
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int a, b, c, n; cin >> a >> b >> c >> n;
  int ans = 0;
  REP (i, n + 1) {
    dump(i);
    int res = n - a * i;
    REP (j, n + 1) {
      int res2 = res - b * j;
      if (res2 >= 0 && res2 % c == 0) ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    int n, r;
    cin >> n >> r;
    cout << (n >= 10 ? r : r + 100 * (10 - n)) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,t;
  scanf("%d %d %d",&a,&b,&c);
  for(int i = 0;i < 2;i++){
    if(a > b){
      t = a;
      a = b;
      b = t;
    }
    if(b > c){
      t = b;
      b = c;
      c = t;
    }
  }
  if(a % 2 != b % 2){
    a++;
    c += 2;
  }
  printf("%d\n",c - b + (b - a) / 2);
  return 0;
}

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

int main() {
  int i, j;
  char k[3];
  scanf("%[^\n]", k);
  sscanf(k,"%d %d", &i, &j);
  if (i%j == 0) {
    printf("0");
  }else{
    printf("1");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int MAX(int a,int b){
    return a>b?a:b;
}
int main() {
    int n;
    scanf("%d",&n);
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }
    int dp[n+2][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0]=MAX(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=MAX(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=MAX(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }
    printf("%d",MAX(dp[n-1][0],MAX(dp[n-1][1],dp[n-1][2])));
        return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <set>
using namespace std;
int abc112_b(){
    // 入力
    int n,T;
    cin >> n >> T;
    vector<int> c,t;
    set<int> st;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
        cin >> tmp;
        t.push_back(tmp);
    }
    
    //処理
    for (int i=0 ; i<n; ++i) {
        if(T>=t[i]) st.insert(c[i]);
    }
    
    //出力
    auto ans = st.begin();
    if (!*ans){
        cout << "TLE" <<endl;
        return 0;
    }
    cout << *ans << endl;
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

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

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6+1;

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(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

int main(){
  string s; int K; cin >> s >> K;
  vector<string> ans;
  for(int i = 0; i < s.size(); i++) {
    for(int k = 1; k <= K; k++) {
      if(i+k > s.size()) continue;
      string t = s.substr(i,k);
      ans.pb(t);
    }
  }
  sort(all(ans));
  ans.erase(unique(all(ans)));
  // rep(i,ans.size()) cout << ans[i] << endl;
  cout << ans[K-1] << endl;
}


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

int num_of_date(int y, int m) {
    if(y % 3 == 0 or m % 2 == 1) return 20;
    return 19;
}

int main() {
    
    int N; cin >> N;
    rep(i, N) {
        int y, m, d;
        cin >> y >> m >> d;
        int sum = 0;
        while(y < 1000) {
            while(m < 11) {
                int left = num_of_date(y, m);
                if(d > 0) left -= d - 1;
                d = 0;
                sum += left;
                m++;
            }
            m = 1;
            y++;
        }
        cout << sum << endl;
    }

}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    lint cnt[60][2];
    for(int i = 0; i < 60; i++){
        cnt[i][0] = cnt[i][1] = 0;
    }
    for(int i = 0; i < N; i++){
        lint A;
        cin >> A;
        for(int j = 0; j < 60; j++){
            cnt[j][(A >> j) & 1]++;
        }
    }
    lint ans = 0;
    for(int i = 59; i >= 0; i--){
        ans = (ans * 2) % mod;
        ans += cnt[i][0] * cnt[i][1] % mod;
    }
    cout << ans % mod << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    
    int s[N];
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>s[i];
        sum+=s[i];
    }
    
    if(sum%10!=0){
        cout<<sum<<endl;
        return 0;
    }else{
        sort(s,s+N);
        for(int i=0;i<N;i++){
            if(s[i]%10!=0){
                sum-=s[i];
                cout<<sum<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
# coding: utf-8

TEST_CASES = {
    '50_100_120': {'a': 50, 'b': 100, 'c': 120, 'out': 'Yes'},
    '50_100_1000': {'a': 50, 'b': 100, 'c': 1000, 'out': 'No'},
    '19_123_143': {'a': 19, 'b': 123, 'c': 143, 'out': 'No'},
    '19_123_142': {'a': 19, 'b': 123, 'c': 142, 'out': 'Yes'},
}

def get_input():
    while True:
        try:
            yield ''.join(raw_input())
        except EOFError:
            break

def test():
    for k, case in TEST_CASES.items():
        if can_buy(case['a'], case['b'], case['c']) != case['out']:
            raise("no----")

def can_buy(a, b, c):
    return 'Yes' if _can_buy(a, b, c) else 'No'

def _can_buy(a, b, c):
    return a + b >= c

def input_to_ints(str):
    return map(int, str.split(" "))

if __name__ == '__main__':
    ints = input_to_ints(raw_input())
    result = can_buy(ints[0], ints[1], ints[2])
    print(result)

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

typedef long long ll;

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

ll pow(ll N, ll k) {
    ll res = 1;
    for (ll i = 0; i < k; ++i) res *= N;
    return res;
}

string N;
int K;
int L;
int A[100];

/*
rec(i, k, smaller) := i 桁目以降について、0 以外の値を残り K 個使用可能という状況を考える。
このとき i 桁目までの部分が「等しい」か「strict に小さくなっている」かを smaller フラグによって分岐する。
*/
ll solve(ll i,ll k, ll smaller) {
        if (i == L) {
            if (k == 0) return 1;
            else return 0;
        }
        if (k == 0) return 1;
        
        if (smaller) return nCr(L-i, k) * pow(9, k);
        else {
            if (A[i] == 0) return solve(i+1, k, false);
            else {
                ll zero = solve(i+1, k, true);
                ll aida = solve(i+1, k-1, true) * (A[i] - 1);
                ll icchi = solve(i+1, k-1, false);
                return zero + aida + icchi;
            }
        }
    }
int main()
{
    cin >> N;
    cin >> K;

    L = N.length();
    // 桁ごとの数字の取得
    for(int i=0; i<L; i++){
        A[i] = N[i] - '0';
    }
    cout << solve(0,K,false) << endl;
    return 0;
}

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

int main() {

    int a, b, c;

    cin >> a >> b >> c;

    if  (a < b) {
        if (b < c)  cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
const int MOD = 998244353;

int ks[3001];

int main() {
    int N, S;
    cin >> N >> S;
    vector<int> As(N);
    for (auto& A : As) {
        cin >> A;
    }
    ll s = 0;
    memset(ks, 0, sizeof(ks));
    ks[0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = S; j >= As[i]; j--) {
            ks[j] = (ks[j] + ks[j - As[i]]) % MOD;
        }
        s = (s + ks[S]) % MOD;
        ks[0]++;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#基本1つ飛ばしだが、パスも使える。
#奇数ならパス2回、偶数ならパス1回。
N = int(input())
A = [int(hoge) for hoge in input().split()]
DP = [[0]*3 for n in range(N)] #DP[n][y] = n桁目までみて、パスをy回使ったときの最大値

DP[0][0] = A[0]

for n in range(1,N):#n桁目までみる。
    #「選ぶ」か「パスを使う」かの2択。
    DP[n][0] = DP[n-2][0] + A[n]
    DP[n][1] = max((DP[n-2][1]+A[n],DP[n-1][0]))
    DP[n][2] = max((DP[n-2][2]+A[n],DP[n-1][1]))
if N%2:
    print(DP[n][2])
else:
    print(DP[n][1])

Measured memory_bytes: 114252
#include<bits/stdc++.h>
#define int long long

using namespace std ;
int a[1005] ;

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

    string s ;
    int n ;
    cin >> n ;
    while (n--){
        s = char('a' + (int)(n%26)) +s ;
        n /=26;
    }
    cout <<s <<endl ;




}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}


const int INF = 0x3f3f3f3f;
const int inf = INF;
typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;

const int N = 1e5 + 10;
LL a[N];
int main() {
	int n;
	RD(n);
	LL ans = 0;
	REP(i, n) RD(a[i]);
	REP(i, n) {
		ans += a[i] / 2;
		a[i] = a[i] % 2;
		ans += min(a[i], a[i + 1]), a[i + 1] -= min(a[i], a[i + 1]);
	}
	cout << ans << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;
typedef long long ll;

ll n,m,k,a,b;
vector<pair<int, int> > vp;
struct UnionFind {
  vi data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

ll all,l,r;
vector<ll> ans;
int main(void){
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        a--; b--;
        vp.pb(make_pair(a,b));
    }
    all=n*(n-1)/2;
    ans.pb(all);
    UnionFind uf(n);
    rep(i,m){
        a=vp[m-1-i].first;
        b=vp[m-1-i].second;
        l=uf.size(uf.root(a)); r=uf.size(uf.root(b));
        if(!uf.find(a,b)){
            uf.unite(a,b);
            all-=l*r;
        }
        ans.pb(all);
    }
    rep(i,m){
        cout<<ans[m-1-i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3444
N=int(input())
work=[[0,0]for i in range(N)]
sum=0
ans=0
for x in range(N):
  inp=input().split()
  work[x][0]=int(inp[1])
  work[x][1]=int(inp[0])
work2=sorted(work)
for y in range(N):
  sum+=work2[y][1]
  if sum>work2[y][0]:
    ans=1
    break
if(ans==0):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 37268
#include <iostream>
#include<algorithm>
#include<set>
#include<iterator>
#include<map>
#include<unordered_map>
#include<vector>
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define pb push_back
#define F first
#define S second

int32_t main() {
    
    int n;
    cin>>n;
    
    string s;
    cin>>s;
    
    string a,b;
    int ct = 0;
    int maxx = 0;
    for(int i=1;i<=n-1 ; ++i)
    {
        a = s.substr(0,i);
        b = s.substr(i,n-i);
        
        map<char,int> mp1,mp2;
        
        for(int i=0;i<a.size();++i)
        {
            mp1[a[i]]++;
        }
        for(int i=0;i<b.size();++i)
            mp2[b[i]]++;
        for(char ch='a';ch<='z';++ch)
        {
            if(mp1[ch]>0&&mp2[ch])
                ct++;
        }
        
        maxx = max(maxx,ct);
        ct = 0;
        
        
    }
    cout<<maxx;
    
    
    
    
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ac = [False] * N
wa = [0] * N

for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0

for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]

print(*[a, b])

Measured memory_bytes: 4596
while s = gets
  b = Array.new(13, 0)
  s.split(',').each { |c| b[c.to_i - 1] += 1 } 
  s = b.join
  b.delete(0)

  h = 'null'

  case b.sort
    when [1, 1, 1, 1, 1]
      h = 'straight' if s =~ /1{5}/ || s =~ /10{8}1{4}/
    when [1, 4]
      h = 'four card'
    when [2, 3]
      h = 'full house'
    when [1, 1, 3]
      h = 'three card'
    when [1, 2, 2]
      h = 'two pair'
    when [1, 1, 1, 2]
      h = 'one pair'
  end
   
  puts h
end

Measured memory_bytes: 2388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    string s;
    cin >> s;
    int l = s.size();
    int ans = 0;
        for (int i = 0; i < l / 2; i++) {
            if (s[i] != s[l - i - 1]) {
                ans++;
            }
        }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,x,y,ans;
int gcd(int a,int b) {
	if (!a||!b) return a+b;
	return gcd(b,a%b);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(x);
	for (int i=1;i<=n;i++) {
		read(y);
		ans=gcd(ans,abs(x-y));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    int T,y,m,d;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d",&y,&m,&d);
        int sum=0;
        if(y%3==0){
            sum+=21-d;
            sum+=(10-m)*20;
        }
        else{
            if(m%2==1) sum+=21-d;
            else sum+=20-d;
            for(int i=m+1;i<=10;i++)
                if(i%2) sum+=20;
                else sum+=19;

        }
        for(int j=y+1;j<=999;j++){
            if(j%3==0) sum+=200;
            else sum+=195;
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  vector<vector<int>> masu(H, vector<int>(W));

  for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
      if(i < B){
        if(j < A) masu[i][j] = 1;
        else if(j >= A) masu[i][j] = 0;
      }
      else if(i >= B){
        if(j < A) masu[i][j] = 0;
        else if(j >= A) masu[i][j] = 1;
      }
    }
  }

  for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
      cout << masu[i][j];
      if(j == W-1) cout << endl;
    }
  }
  
}

Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int ans = -1;
		for(var i=0;i<10000;i++){
			int a1 = i*8/100;
			int a2 = i*10/100;
			if(a1==A && a2==B){
				ans = i;
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, A int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	A, _ = strconv.Atoi(scanner.Text())

	N -= 500 * (N / 500)
	if N <= A {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int arr[200001];
    int n;
    cin >> n;
    int whole = 0;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        whole ^= arr[i];
    }
    for(int i=0; i<n; i++){
        cout << (arr[i]^whole) << ' ';
    }
    
    
    return 0;
}

Measured memory_bytes: 4328
let (_a,_b,_h,_m) = cin.quadruple
let a = Double(_a)
let b = Double(_b)
let h = Double(_h)
let m = Double(_m)

let pi = Double.pi
let alpha: Double = (h*60+m)/Double(720)*(pi*2)
let beta: Double = m/Double(60)*(pi*2)
let theta: Double = alpha - beta
let res = sqrt(a*a+b*b-Double(2.0)*a*b*cos(theta))
print(res)

// MARK: #### 以下、ライブラリ ####

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    static var quadruple: (Int, Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!, Int(line[3])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
    return Int(pow(Double(radix), Double(power)))
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}


Measured memory_bytes: 14568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
ll MOD, n;

vector<vl> adj;
vvl adj1;
vl ergs;
vl res;
vl oben;

ll dfs0 (ll pos, ll parent) {
	if (ergs[pos] != -1) {
		return ergs[pos];
	}
	ll erg = 1;
	FOR(i,0,sz(adj[pos])) {
		if(parent == adj[pos][i]) {
			continue;
		}
		adj1[pos].pb(adj[pos][i]);
		erg = (erg * (1LL + dfs0(adj[pos][i],pos))) % MOD;
	}
	ergs[pos] = erg;
	return erg;
}

void dfs1 (ll pos, ll parent) {
	ll len = sz(adj1[pos]);
	vl pref(len,1);
	vl suff(len,1);
	FOR(i,1,len) {
		pref[i] = ((1 + ergs[adj1[pos][i-1]]) * pref[i-1]) %MOD;
	}
	FORD(i,0,len-1) {
		suff[i] = ((1 + ergs[adj1[pos][i+1]]) * suff[i+1]) %MOD;
	}
	if (parent != -1) {
		res[pos] = (ergs[pos] * ((1 + oben[parent])%MOD))%MOD;
	} else {
		res[pos] = ergs[pos];
	}

	FOR(i,0,sz(adj1[pos])) {
		ll curr = adj1[pos][i];
		ll erg = 1;
		if (parent != -1) {
			erg = (erg * (1 + oben[parent]))%MOD;
		}
		erg = (((erg * suff[i])%MOD) * pref[i])%MOD;
		oben[pos] = erg;
		dfs1(curr, pos);
	}
}

int main() {
	ios::sync_with_stdio(false);

	cin >> n;
	cin >> MOD;

	adj.assign(n, vl());
	adj1.assign(n, vl());
	ergs.assign(n, -1);
	res.assign(n, -1);
	oben.assign(n, -1);

	FOR(i,0,n-1) {
		ll x,y; cin >> x >> y; x--; y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	dfs0(0, -1);
	res[0] = ergs[0];
	oben[0] = 1;
	dfs1(0, -1);

	FOR(i,0,n) {
		cout << res[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 25472
#include <cstdio>
#include <algorithm>
#define maxn 200010
int a[maxn],head[maxn],tot,n,d[maxn],ans,mx[maxn];
using namespace std;
struct node{
	int to,next;
}e[maxn<<1];
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
void dfs(int u,int fa){
	int b,v,save,flag,l,r,mid;;
	for(b=head[u];b;b=e[b].next){
		v=e[b].to;
		if(v==fa)continue;
		save=ans,flag=0;
		if(d[ans]<a[v])d[++ans]=a[v];
		else{
			l=0,r=ans;
			while(l+1<r){
				mid=(l+r)/2;
				if(d[mid]<a[v])l=mid;
				else r=mid;
			}
			flag=d[r],d[r]=a[v];
		}
		mx[v]=ans;
		dfs(v,u);
		ans=save;
		if(flag)d[r]=flag;
	}
}
void init(){
	int i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
}
int main(){
	init();
	ans=1,d[1]=a[1],mx[1]=1;
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%d\n",mx[i]);
	return 0;
}

Measured memory_bytes: 20012
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}

static const ULLONG UL_HUGE_DIVIDER = 1000000007LLU;
static const LLONG LL_HUGE_DIVIDER = 1000000007LL;

//static void ABC111D_RobotArms();
static void ABC114B_754();

#if 1
int main()
{
	//ABC111D_RobotArms();
	ABC114B_754();
	fflush(stdout);
	return 0;
}
#endif

static void ABC114B_754()
{
	char szNum[11] = { 0 };
	scanf(" %s", szNum);

	int diffMin = 2000;
	int slen = strlen(szNum);
	for (int i = 2; i < slen; i++) {
		char tmp = szNum[i + 1];
		szNum[i + 1] = '\0';
		int val = strtol(&szNum[i - 2], NULL, 10);
		szNum[i + 1] = tmp;
		diffMin = tp_min(diffMin, tp_abs((int)753 - val));
	}
	printf("%d\n", diffMin);
}


Measured memory_bytes: 256
s = input()

g, p = 0, 0
ans = 0
for s_i in s:
    if s_i == 'g':
        if g > p:
            p += 1
            ans += 1
        else:
            g += 1
    else:
        if g > p:
            p += 1
        else:
            g += 1
            ans -= 1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#define N 2005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, m, a[N], b[N], d[N][N];
int main()
{
	ll i, j;
	cin >> n >> m;
	for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for (i = 1; i <= m; i++) scanf("%lld", &b[i]);
	for (i = 0; i <= n; i++) d[i][0] = 1;
	for (i = 0; i <= m; i++) d[0][i] = 1;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
            d[i][j] = (d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + M) % M;
			if (a[i] == b[j]) d[i][j] = (d[i][j] + d[i - 1][j - 1]) % M;
		}
	}
    cout << d[n][m] << endl;
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
int N, M, K, ptr[100009]; long long dp[309][100009];
int main() {
	scanf("%d %d %d", &N, &M, &K);
	for (int i = 0; i < N; i++) scanf("%lld", &dp[0][i]);
	for (int i = 1; i < K; i++) {
		int pl = 0, pr = 0;
		for (int j = 0; j < N; j++) {
			if (j >= i) dp[i][j] = dp[i - 1][ptr[pl]] + 1LL * (i + 1) * dp[0][j];
			if (ptr[pl] == j - M) pl++;
			while (pl < pr && dp[i - 1][ptr[pr - 1]] < dp[i - 1][j]) pr--;
			ptr[pr++] = j;
		}
	}
	printf("%lld\n", *std::max_element(dp[K - 1], dp[K - 1] + N));
	return 0;
}

Measured memory_bytes: 237952
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> S(n);
    for (int i=0; i<n; i++) {
        cin >> S[i];
    }
    
    vector<int> alphabet(30,0);
    
    for (int i=0; i<n; i++) {
        vector<int> now_alphabet(30,0);
        for (int j=0; j<S[i].length(); j++) {
            now_alphabet[S[i][j]-'a']++;
            //cout << S[i][j]-'a' <<endl;
        }
        if (i==0) {
            for (int j=0; j<30; j++) {
                alphabet[j]=now_alphabet[j];
            }
        }
        else{
            for (int j=0; j<30; j++) {
                if (alphabet[j]>now_alphabet[j]) {
                    alphabet[j]=now_alphabet[j];
                }
            }
        }
        
    }
    
    
    
    for (int i=0; i<30; i++) {
        for (int j=0; j<alphabet[i]; j++) {
            char moji='a'+i;
            cout << moji;
        }
    }
    cout << endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

// https://kamino.hatenablog.com/entry/cpp-permutation-combination
void foreach_permutation(int n, std::function<void(vector<int>)> f) {
    vector<int> indexes(n);
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes.begin(), indexes.end()));
}


int main() {

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

    vector<vector<bool>> routes(n, vector<bool>(n, false));

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        routes[a][b] = true;
        routes[b][a] = true;
    }


    int ans = 0;
    foreach_permutation(n - 1, [&](vector<int> indexes) {
        vector<int> route(n);
        route[0] = 0;
        for (int k = 0; k < n - 1; k++) {
            route[k + 1] = indexes[k] + 1;
        }

        for (int k = 0; k < n - 1; k++) {
            int from = route[k];
            int to = route[k + 1];
            if (!routes[from][to]) {
                return;
            }
        }
        ans++;

    });

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	cout.precision(17);
	int N;
	cin >> N;
	double s=0;
	for(int i=0;i<N;i++){
		double v;
		cin >> v;
		s+=1/v;
	}
	cout << 1/s << endl;

	return 0;
}



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

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (c >= a && c <= b)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 256
n = int(input())
al = list(map(int, input().split())) 

al.append(0)

res = 0
r = 0
x = 0
y = 0


for l in range(n):
#    print("start",l,r)
    while x == y and r<=n:
        x += al[r]
        y = y ^ al[r]
        r += 1
#        print(x,y)
    r -= 1
    x -= al[r]
    y = y ^ al[r]
#    print(x,y,l,r)    
    res +=r-l
    x -= al[l]
    y = y^ al[l]
    if l ==r:
        r += 1

print(res)

Measured memory_bytes: 32060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<ll> L(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> L[i];
    }
    ll count=0;
    for(size_t i=0;i<N; i++)
    {
        for(size_t j=i+1;j<N; j++)
        {
            for(size_t k=j+1;k<N; k++)
            {
                if(L[i]==L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]) count++;
            }
        }
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

using namespace std;

long long n, k;
long long a[200010];
long long chk[200010];
vector<long long> tow, fin;

int main(void)
{
	scanf("%lld %lld", &n, &k);
	
	for(long long i = 1 ; i <= n ; i++)
		scanf("%lld", &a[i]);
	
	long long here = 1;
	
	if(k <= n)
	{
		for(long long i = 1 ; i <= k ; i++)
			here = a[here];
		
		printf("%lld", here);
		return 0;
	}
	
	while(1)
	{
		if(chk[here])
			break;
		
		tow.push_back(here);
		chk[here] = 1;
		here = a[here];
		k--;
	}
	
	long long gg = 0;
	
	for(long long i = 0 ; i < tow.size() ; i++)
	{
		if(tow[i] == here)
		{
			gg = i + 1;
			break;
		}
	}
	
	fin.push_back(here);
	
	for(long long i = gg ; i < tow.size() ; i++)
		fin.push_back(tow[i]);
	
	k %= fin.size();
	
	printf("%lld", fin[k]);
	return 0;
}

Measured memory_bytes: 9372