akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  ll N;
  cin >> N;
  vector<ll> div = divisor(N-1);
  int ans = div.size();
  rep2(i,2,min(N,(ll)1000001)) {
    ll n = N;
    while(n%i==0) n/=i;
    if(n%i==1) {
      if (find(div.begin(),div.end(),i)==div.end()) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  ll ans = 1e9;
  if (X >= Y) {
    ll x[3] = {0, X-Y, X};
    for (int a = 0; a < 3; a++) {
      ll y[2] = {0, Y};
      for (int b = 0; b < 2; b++) {
        ll c = max(X-x[a], Y-y[b])*2;
        ans = min(ans, A*x[a]+B*y[b]+C*c);
      }
    }
  } else {
    ll y[3] = {0, Y-X, Y};
    for (int b = 0; b < 3; b++) {
      ll x[2] = {0, X};
      for (int a = 0; a < 2; a++) {
        ll c = max(X-x[a], Y-y[b])*2;
        ans = min(ans, A*x[a]+B*y[b]+C*c);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9+7
    ans = 0

    for k in range(60):
        x, y = 0, 0
        for a in A:
            x += 1 & a>>k
        tmp = x*(n-x)%mod
        tmp *= pow(2, k, mod)
        ans += tmp
        ans %= mod
    print(ans)


if __name__ =='__main__':
    main()

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

int n, k;
vector < vector < pair < int, int > > > g;
vector < pair < int, int > > edges;
vector < int > ans;

void dfs (int u, int p, int clr) {
	int cur = 1;
	for (auto pr: g[u]) {
		int v = pr.first, i = pr.second;
		if (cur == clr)
			++cur;
		if (v != p) {
			ans[i] = cur;
			dfs(v, u, cur);
			++cur;
		}
	}
}

void ckmax (int &x, int a) {
	x = max(x, a);
}

signed main () {
	cin >> n;
	g.resize(n + 1);
	edges.resize(n - 1);
	ans.resize(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		cin >> edges[i].first >> edges[i].second;
		g[edges[i].first].push_back(make_pair(edges[i].second, i));
		g[edges[i].second].push_back(make_pair(edges[i].first, i));
	}
	k = 0;
	for (int i = 1; i <= n; ++i)
		ckmax(k, int(g[i].size()));
	dfs(1, -1, -1);
	cout << k << '\n';
	for (int i = 0; i < n - 1; ++i)
		cout << ans[i] << '\n';
}


Measured memory_bytes: 8832
#include<iostream>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0){
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
} 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
int t,x;
int main(){
    cin>>t>>x;
    double ans=1.00000*t/x;
    printf("%.8lf",ans);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll cme;

ll modpow(ll b, ll e, ll m){  // bのe乗のmod m を返す
  if (e <= 0) return 1;
  cme = modpow(b, e / 2, m);
  cme = (cme * cme) % m;
  if (e % 2 == 1) cme = (cme * b) % m;
  return cme;
}

int main(){
  ll N,A[200007];
  cin >> N ;
  ll H = modpow(2,N,MOD),K = modpow(2,N-1,MOD), U = modpow(2,N-2,MOD);
  rep(i,N){
    cin >> A[i];
  }
  sort(A,A+N);
  reverse(A,A+N);
  ll C=0,X=K;
  rep(i,N){
    C+=X*A[i];
    C%=MOD;
    X+=U;
    X%=MOD;
  }
  cout << C*H%MOD << endl;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

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

//const ll mod = 1e10;
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


ll f(ll n) {
    ll res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}


vector<ll> get_ks(vector<ll> &candidates) {
    int n = candidates.size();
    vector<ll> ans;


    for (ll i = 0; i < n; i++) {
        bool b = [&] {
            for (ll j = i + 1; j < n; j++) {
                ll a = candidates[i], b = candidates[j];
                if (a * f(b) > b * f(a)) return false;
            }
            return true;
        }();
        if (b) ans.push_back(candidates[i]);
    }

    return ans;

}

int main() {
    vector<ll> res;
    ll base = 1;

    for (int i = 0; i < 15; ++i) {
        for (int j = 1; j < 150; ++j) {
            res.push_back(base * (j + 1) - 1);
        }
        base *= 10;
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());

    vector<ll> ks = get_ks(res);

    ll K;
    cin >> K;
    for (ll i = 0; i < K; ++i) {
        cout << ks[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        double ans = 0.0;
        for (int i = 1; i < n + 1; i++) {
            double p = 1;
            double a = i;
            while (a < k) {
                p *= 0.5;
                a *= 2;
            }
            ans += p/n;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21460
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> a(N);
    REP(i,N) cin>>a[i];
    vector<ll> R(N,0),L(N,0);
    ll cnt=0;
    ll num=0;

    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> que;
    set<ll> st;
    st.insert(-1);
    st.insert(N);
    REP(i,N){
        que.push(make_pair(a[i],i));
    }

    ll ans=0;

    while(!que.empty()){
        pair<ll,ll> p=que.top();
        ll num=p.first;
        ll idx=p.second;
        que.pop();
        auto itr=st.upper_bound(idx);
        ll r=*itr-idx;
        itr--;
        ll l=idx-*itr;
        ans+=num*l*r;
        st.insert(idx);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 20536
#include <iostream>
#include <vector>
#include <algorithm>


int main()
{
  int n;
  std::cin >> n;
  
  std::vector<int> heights;
  for(int i=0; i<n; i++)
  {
    int h;
    std::cin >> h;
    heights.push_back(h);
  }

  int lastHeight = -1;
  for(const auto& e : heights)
  {
    if( e < lastHeight ) { std::cout << "No"; return 0; }
    lastHeight = std::max<int>(lastHeight, e-1);
  }

  std::cout << "Yes";
}

Measured memory_bytes: 892
// i wanna find something i wanted all along
// somewhere i belong

#include <bits/stdc++.h>
#include <vector>

#define s second
#define f first
#define pb push_back
#define int ll

using namespace std;

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

const long long MAX=3e3+85,INF=1e5+7,mod=998244353;

ll n,m,t;
//string s;
//set<int>st;
//bool mark[MAX];
//int dx[2]={0,1};
//int dy[2]={1,0};
//pii p[MAX];
//vector <int> v1,v2;
//multiset <int> st;
//queue <pii> q;
//map<pii,int> dp;
//map <pii,bool> mark;
//deque <int> dq;
double p[MAX],dp[MAX][MAX],ans;

void solve()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> p[i];
    }
    // tarif dp[i][j] : ba i ta seke aval j ta roo byad
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j)
            {
                dp[i][j] += dp[i-1][j-1]*p[i];
            }
            dp[i][j]+=dp[i-1][j]*(1-p[i]);
        }
    }
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout << setprecision(12) << ans;
}

main()
{
    ios_base::sync_with_stdio(0);
    solve();
    return -0;
}


Measured memory_bytes: 72320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

const int mod = 1000000007;

ll mypow(int x){
  ll ret = 1;
  rep(i, x) ret = ret * 2 % mod;
  return ret;
}

int main(){
  int n;
  cin >> n;
  map<int, int> d;
  rep(i, n){
    int s;
    cin >> s;
    d[s]++;
  }

  bool ok = true;
  if (n % 2) {
    if (d[0] != 1) ok = false;
    for (int i = 2; i < n; i+=2) {
      if (d[i] != 2) ok = false;
    }
  } else {
    if (d[0] != 0) ok = false;
    for (int i = 1; i < n; i+=2){
      if (d[i] != 2) ok = false;
    }
  }

  if (ok) {
    ll ans = mypow(n/2);
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 4096
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer,Integer> map = new HashMap<>();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if(!map.containsKey(a)) map.put(a, 0);
            if(map.get(a) % 2 == 0) ans++;
            else ans--;
            map.put(a, map.get(a)+1);
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 63268
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	map<string, LL> freq;
	LL maxCnt = -1;
	rep(i, 0, n) {
		string s; cin >> s;
		freq[s]++;
		if(freq[s] > maxCnt) maxCnt = freq[s];
	}
	srep(it, freq.begin(), freq.end()) {
		if(it->second == maxCnt)
			cout << it->first << endl;
	}
}


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n,d=111,x=0;
	cin>>n;
	for(int i=1;i<=9;i++){
		x=d*i;
		if(n<=x) {
			cout<<x<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc054/tasks/abc054_c
//AtCoder ABC054 C - One-stroke Path
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#define debug(var) do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#else
#define debug(var)
#endif

struct Edge{
    int s0,e0;
    int s1,e1;
    Edge(int a,int b)
        : s0(a), e0(b)
        , s1(b), e1(a)
    {}
};
struct Node{
    int no;
    vector<const Edge*> etbl;
};

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    int N,M; cin>>N>>M;
    vector<Node> nodes(N);
    for(int i=0;i<N;++i){
        nodes[i].no=i+1;
    }
    vector<Edge> edges;
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        edges.emplace_back(a,b);
        auto it = edges.back();
        nodes[a-1].etbl.push_back(&it);
        nodes[b-1].etbl.push_back(&it);
    }

    //dp[回数][到達したnodeマスク]
    vector<vector<int>> dp(N+1,vector<int>(1<<N+1,0));
    dp[1][1<<0] = 1;
    FOR(msk,1,1<<N){ //状態を進めるので、その過去は決まってる
		for(const auto &e : edges) {
			auto setfunc = [&](ll st, ll ed) {
				ll n = st;
				ll nn = ed;
                // ll tmp0 = (1 << (st - 1));
                // ll tmp = msk & (1 << (st - 1));
				if((msk & (1 << (st - 1))) == 0)
					return;
				if(msk & (1 << (ed - 1)))
					return;
				ll nmsk = msk | (1 << (nn - 1));
                debug(nn);
                debug(nmsk);
				dp[nn].at(nmsk) += dp[n].at(msk);
			};
			setfunc(e.s0, e.e0);
			setfunc(e.s1, e.e1);
		}
	}
#if 0
    REP(t,N){ //回数
        for(ll msk=1;msk<1<<(N+1);++msk){
            for(const auto& e:edges){
                auto setfunc = [&](ll st, ll ed){
                    ll n = st;
                    ll nn = ed;
                    if (msk & (1<<(st-1)) == 0) return;
                    if (msk & (1<<(ed-1))) return;
                    ll nmsk = msk | (1<<(nn-1));
                    dp[nn].at(nmsk) += dp[n].at(msk);
                };
                setfunc(e.s0, e.e0);
                setfunc(e.s1, e.e1);
            }
        }
    }
#endif
    ll ans = 0;
    REP(t,N+1){
        ans += dp[t][(1<<N)-1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
#include <utility>
using namespace std;

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

    map<int, char> mapa;
    int ch = 'a';
    for (int i = 1; i <= 26; i++)
    {
        mapa.insert({i, ch});
        ch++;
    }

    string res;
    while (n)
    {
        long long temp = n % 26;
        if (temp == 0)
        {
            res += 'z';
            n -= 1;
        }
        else res += mapa[temp];
        n /= 26;
    }

    reverse(res.begin(), res.end());
    cout << res;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[8] = { 0,0,1,-1, 1,1,-1,-1 };// 前４つで４近傍
const int c_Dy[8] = { 1,-1,0,0 ,1,-1,1,-1};// 全部で８近傍
const int c_div = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846;


int main() {

	char S[1000000], R[19999];

	scanf("%s", S);


	for (int i = 0; i < strlen(S); i+=2) {
		printf("%c", S[i]);
	}



}







Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	int m,m2,n,i,a[1001],f;
	char c[11];
	while(scanf("%d%d",&m,&n)!=EOF){
		if(m==0 && n==0)break;
		m2=m;
		for(i=1;i<=m;i++)a[i]=1;f=1;
		for(i=1;i<=n;i++){
			scanf("%s",c);
			if(m!=1){
				if(strcmp(c,"Fizz")==0){
					if(i%3!=0)a[f]=0,m--;
				}else if(strcmp(c,"Buzz")==0){
					if(i%5!=0)a[f]=0,m--;
				}else if(strcmp(c,"FizzBuzz")==0){
					if(i%15!=0)a[f]=0,m--;
				}else{
					if(i!=atoi(c))a[f]=0,m--;
					else if(i%3==0)a[f]=0,m--;
					else if(i%5==0)a[f]=0,m--;
					else if(i%15==0)a[f]=0,m--;
				}
			}
			do{
				f++;
				if(f>m2)f=1;
			}while(a[f]==0);
		}
		for(i=1;i<=m2;i++)if(a[i]==1)m--,printf("%d%s",i,(m==0)?"":" ");
		printf("\n");
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans;
  int s = -1;
  for(int i = 1; i <= n; i++){
    int t = i;
    int cnt = 0;
    while(true){
      if(t%2 != 0) break;
      t /= 2;
      cnt++;
    }
    if(cnt > s){
      s = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
 }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	cin >> a[0] >> b[0] >> c[0];
	for( int i = 1; i < n; ++i ){
		int x, y, z;
		cin >> x >> y >> z;
		a[i] = x + max ( b[i-1], c[i-1] );
		b[i] = y + max ( c[i-1], a[i-1] );
		c[i] = z + max ( a[i-1], b[i-1] );
	}
	cout << max({ a[n-1], b[n-1], c[n-1] }) << endl;
	return 0;
}

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

int gcd(int a, int b, int c){
  int min=max(a,max(b,c));
  int n=1;
  for (int i=0;i<min;i++) {
    if (a%(i+1)==0 && b%(i+1)==0 && c%(i+1)==0) n=i+1;
  }
  return n;
}
int main() {
  int K;
  cin >> K;
  int count=0;
  for (int k=0; k<K; k++) {
    for (int j=0; j<k; j++) {
      for (int i=0; i<j; i++) {
        count+=gcd(i+1,j+1,k+1);
      }
    }
  }
  count*=6;
  int count_1=0;
  for (int k=0; k<K; k++) {
    for (int j=0; j<k; j++) {
        count_1+=gcd(j+1,j+1,k+1);
    }
  }
  for (int k=0; k<K; k++) {
    for (int j=0; j<k; j++) {
        count_1+=gcd(j+1,k+1,k+1);
    }
  }
  count_1*=3;
  count+=count_1;
  int count_2=0;
  for (int k=0; k<K; k++) {
        count_2+=gcd(k+1,k+1,k+1);
  }
  count+=count_2;
  cout << count << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
signed main(){
	string s;
	cin>>s;
	int n=s.size();
	int sum=0;
	for(int i=0;i<n;i++){
		if(s[i]=='x'){
			sum++;
		}
	}
	if(sum<=7){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}			

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

int main(){
  stack<char> ans, ans1;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]!='B')
      ans.push(s[i]);
    else
      if(!ans.empty())
        ans.pop();
  }
  string op;
  while(!ans.empty()){
    char k = ans.top();
    ans1.push(k);
    ans.pop();
  }
  while(!ans1.empty()){
    op += ans1.top();
    ans1.pop();
  }
  cout<<op;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    static int n,a[];
    static Boolean[][]memo;
    static boolean dp(int turn,int rem){
        if (rem<=0)return false;
        if (memo[turn][rem]!=null)return memo[turn][rem];
        boolean ans=false;
        for (int i =0;i<n;i++){
            if (rem>=a[i]){
                ans=ans|(!dp(1-turn,rem-a[i]));
            }
        }
        return memo[turn][rem]=ans;
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = sc.nextInt();
        int k =sc.nextInt();
        a= new int[n];
        for (int i =0;i<n;i++)a[i]=sc.nextInt();
        memo= new Boolean[2][k+1];
        boolean[][]dp= new boolean[2][k+1];
        for (int i =0;i<=k;i++){
            for (int j=0;j<n;j++){
                if (i+a[j]<=k){
                    dp[0][i+a[j]]|=(!dp[1][i]);
                    dp[1][i+a[j]]|=(!dp[0][i]);
                }
            }
        }
        if (dp[0][k]){
            pw.println("First");
        }
        else pw.println("Second");
        pw.flush();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}

Measured memory_bytes: 22452
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int R[1000005]={0};
int main(){
int k,n;
cin>>k>>n;
  for(int i=1;i<=n;i++){
    cin>>R[i];
  }
  R[n+1]=k+R[1];
  int ans=1000000007;
  for(int i=1;i<=n;i++){
    if(ans>k-(R[i+1]-R[i]))ans=k-(R[i+1]-R[i]);
  }
cout<<ans<<endl;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
x_lis = list(map(int, input().split()))

sorted_lis = sorted(x_lis)

output = [0] * (N - K + 1)
for i in range(N - K + 1):
    if sorted_lis[i] < 0 and sorted_lis[i + K - 1] > 0:
        first = abs(sorted_lis[i]) * 2 + sorted_lis[i + K -1]
        second = abs(sorted_lis[i + K - 1]) * 2 - sorted_lis[i]
        #print(first, second)
        output[i] = min(first, second)
    elif sorted_lis[i] < 0 and sorted_lis[i + K - 1] <= 0:
        output[i] = -sorted_lis[i]
        #print(output[i])
    elif sorted_lis[i] >= 0 and sorted_lis[i + K - 1] > 0:
        output[i] = sorted_lis[i + K - 1]
        #print(output[i])
print(min(output))

Measured memory_bytes: 14660
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Bool
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  (n, d) <- getIntPair
  ps <- replicateM n getIntPair
  print $ length $ filter ((<= d^2) . dist) ps
  where
    dist (x, y) = x^2 + y^2


-- Input

getInt :: IO Int
getInt = readLn
second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine
 
getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

-- 組み合わせ
powerset :: [a] -> [[a]]  
powerset xs = filterM (\x -> [True, False]) xs


Measured memory_bytes: 77744
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int lim = m/n;
	int maxi = 0;
	if( m%n == 0 ){
		cout << m/n << endl;
		return 0;
	}
	for( int i = 1; i <= lim; ++i ){
		if( m%i == 0 ){
			if( m/i >= n ){
				maxi = i;
			}
		} 
	}
	cout << maxi << endl;
	return 0;
}

/*

123 を 10 個の数で分ける
123 / 3 = 41
41 を 10 個の数でわけられる。

x を y 個の数でわけられるか？
→ x >= y なら OK


N M
i ∈ [2, ?]
	if( M を i で割れる )
		s = M を i で割る
		if( s を N でわけられるか？ ){
			i で OK
		}

123 / 3
	s = 123/3
	s == 41
	41 を 10 でわけられます
	
M/i >= N	
1/i >= N/M
i <= M/N


*/

Measured memory_bytes: 256
n = input().rstrip().split("/")
n=[int(x) for x in n]
if n[0]<=2019:
  if n[1]<=4:
    if n[2]<=30:
      print("Heisei")
    else:
  	  print("TBD")
  else:
    print("TBD")
else:
  print("TBD")

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int X;
  cin >> X;
  if (X >= 2000) {
    cout << 1 << endl;
  } else if (X < 100) {
    cout << 0 << endl;
  } else {
    int n = X / 100;
    int r = X % 100;
    if (r <= 5 * n) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll a,b;
	string s,t,u;
	cin >> s >> t >> a >> b >> u;
	if(s==u) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import numpy as np

a,b,c = map(int,input().split())

# print(a,b,c)
# if np.sqrt(a)+np.sqrt(b)<np.sqrt(c):
#     print("Yes")
# else:
#     print("No")
d = c-a-b
if d>0 and 4*a*b<d*d :
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12488
#include <iostream>
#include <string>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string n) {
  for (auto &c: n) {
    if (c == '9') c = '1';
    else c = '9';
  }
  cout << stoi(n) << endl;
}

int main() {
  string n;
  cin >> n;
  solve(move(n));
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k, q) = (v[0], v[1] as i32, v[2]);
    let mut score = vec![k - q as i32; n];
    for _ in 0..q {
        let i = read::<usize>() - 1;
        score[i] += 1;
    }
    for i in 0..n {
        if score[i] > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int n;
  cin >> n;
  double ans;
  ans = ceil(n/2.0) / (double)n;
  cout << ans <<  endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i=0,i2=0,i3=0,i4=0,i5=0,i6=0;
  char a[3];
  char str1[]="abc";
    char str2[]="acb";
    char str3[]="bac";
    char str4[]="bca";
    char str5[]="cab";
    char str6[]="cba";
  scanf("%s",a);
 
  i= strcmp(a, str1);
   i2= strcmp(a, str2); 
   i3= strcmp(a, str3);
   i4= strcmp(a, str4);
   i5= strcmp(a, str5);
   i6= strcmp(a, str6);
    
     if(i==0||i2==0||i3==0||i4==0||i5==0||i6==0)
       printf("Yes");
  else printf("No");
 

}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	string s; cin >> s;
	int n = s.length();
	lli ans = 0;

	for (int bit = 0; bit < (1 << n - 1); bit++) {
		lli tmp = s[0] - '0';
		rep(i, 0, n - 1) {
			if (bit&(1 << i)) {
				ans += tmp;
				tmp = s[i + 1] - '0';
			}
			else {
				tmp *= 10;
				tmp += s[i + 1] - '0';
			}
		}
		ans += tmp;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n,ans=0;
    cin>>n;
    vector<int>a(1000000);
    vector<int>b(1000000);
    vector<int>c(1000000);

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    ans+=b[a[0]-1];
    for(int i=0;i<n-1;i++){
        ans+=b[a[i+1]-1];
        if(a[i+1]-a[i]==1){
           ans+=c[a[i]-1]; 
        }
    }
    cout<<ans<<endl;


   return 0;
}

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

#define M 1000000  /* your task*/
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

long long h1(long long key){ return(key % M) /* your task */; }
long long h2(long long key){ return((key + 1) % M) /* your task */; }

int find(char str[]){

    /* your task */
	long long key, nkey;

	key = getKey(str);
	key = h1(key);
	if(H[key][0] == '\0'){
		return(1);
	}

	nkey = key;
	while(strcmp(H[nkey], str) != 0){
		nkey = h2(nkey);
		if((key == nkey) || (H[nkey][0] == '\0')){
			return(1);
		}
	}
	return(0);
}

int insert(char str[]){

    /* your task */
	long long key, nkey;

	key = getKey(str);
	key = h1(key);
	if(find(str) == 0){
		return(0);
	}

	if(H[key][0] == '\0'){
		strcpy(H[key], str);
	}else{
		nkey = key;
		do{
			nkey = h2(nkey);
			if(H[nkey][0] == '\0'){
				strcpy(H[nkey], str);
				break;
			}
		}while(key != nkey);
		if(key == nkey){
			printf("???????????????");
			return(1);
		}
	}

	return(0);
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ){
		H[i][0] = '\0';
	}
 
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
		scanf("%s %s", com, str);
		if ( com[0] == 'i' ){
			insert(str);
		} else {
			if (find(str) == 0){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
    }

    return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int a, b;
cin >> a >> b;
cout << (a + b) % 24 << endl;
return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
bef=a[0]
flag=None #前との大小関係 true 増加　false 減少
for i in range(1,n):
    #if bef==a[i] イコールのときは問題ないので処理いらない
    if bef<a[i]:
        if flag==False:
            ans+=1
            flag=None
        else:
            flag=True
    elif bef>a[i]: 
        if flag:
            ans+=1
            flag=None
        else:
            flag=False
    bef=a[i]
print(ans)

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<char> c(n);
  for(int i=0;i<n;++i) {
    cin >> c[i];
  }

  for(int i=0;i<n;++i) {
    if(c[i] == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

#define _USE_MATH_DEFINES
#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second);
    }
};

struct pair_hash {
public:
    std::size_t operator()(const std::pair<u64, u64> &x) const
    {
        return std::hash<u64>()(x.first) ^ std::hash<u64>()(x.second);
    }
};
#include <random>

const i64 mod = 1000000007ll;
const i64 smod = 999983;
const i64 inf = mod;

const double eps = 1e-10;

// del

string s;
i64 n, m;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> m;
    cin >> s;

    vector<pair<char, i64>> q;
    {
        char p = '2';
        i64 l = 0;

        for (i64 i = 0; i < s.size(); i++) {
            if (s[i] != p) {
                if (p == '0' || p == '1') {
                    q.push_back({ p,l });
                }
                p = s[i];
                l = 1;
            }
            else {
                l += 1;
            }
        }
        q.push_back({ p,l });
    }

    i64 l = 0;
    i64 r = 0;

    i64 c = 0;

    i64 s = 0;
    i64 v = 0;

    while (r < q.size()) {
        if (q[r].first == '1') {
            s += q[r].second;
            if (s > v) {
                v = s;
            }
            r++;
            continue;
        }

        if (c == m) {
            while (l < r) {
                if (q[l].first == '1') {
                    s -= q[l].second;
                    l++;
                    continue;
                }
                s -= q[l].second;
                l++;
                c--;
                break;
            }
        }

        s += q[r].second;
        if (s > v) {
            v = s;
        }

        c++;
        r++;
    }

    cout << v << endl;

    return 0;
}


Measured memory_bytes: 2548
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
  int N = nextInt();
  for(int i = 1; i <= N - 1; i++){
    String[] output = new String[N - i];
    for(int j = i + 1; j <= N; j++){
      for(int k = 0; k < 10; k++){
        if(((i ^ j) >> k) % 2 != 0){
          output[j - i - 1] = String.valueOf(k + 1);
          break;
        }
      }
    }
    myout(myconv(output, 8));
  }
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 43484
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())

B = list(int(input()) for i in range(N))

ans = 0
for a in A1:
  if a in B:
    ans += 1
if ans == 3:
  print('Yes')
else:
  ans = 0
  for a in A2:
    if a in B:
      ans += 1
  if ans==3:
    print('Yes')
  else:
    ans = 0
    for a in A3:
      if a in B:
        ans += 1
    if ans==3:
      print('Yes')  
    else:
      ans = 0
      for a in [A1[0], A2[0], A3[0]]:
        if a in B:
          ans += 1
      if ans==3:
        print('Yes') 
      else:
        ans = 0
        for a in [A1[1], A2[1], A3[1]]:
          if a in B:
            ans += 1
        if ans==3:
          print('Yes')
        else:
          ans = 0
          for a in [A1[2], A2[2], A3[2]]:
            if a in B:
              ans += 1
          if ans==3:
            print('Yes')
          else:
            ans = 0
            for a in [A1[0], A2[1], A3[2]]:
              if a in B:
                ans += 1
            if ans==3:
              print('Yes')
            else:
              ans = 0
              for a in [A1[2], A2[1], A3[0]]:
                if a in B:
                  ans += 1
              if ans==3:
                print('Yes')
              else:
                print('No')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define N 1000100
ll n,s,ans,x[N],p[N];
using namespace std;
int main(){
    scanf("%lld%lld",&n,&s);
    for (ll i=1;i<=n;i++) scanf("%lld%lld",&x[i],&p[i]);
    for (ll l=1,r=n;l<=r;){
        if (x[l]>=s){ans+=x[r]-s; break;}//所有人都在一边直接开过去
        if (x[r]<=s){ans+=s-x[l]; break;}
        ans+=x[r]-x[l]; //每次来回开一趟
        if (p[l]>=p[r])
            while (l<r && p[l]>=p[r]) p[l]+=p[r],r--;//相同往左开
        else while (l<r && p[l]<p[r]) p[r]+=p[l],l++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5120
n,a,b=map(int,input().split(" "))
kouho=[]
for i in range(1,n+1):
  i=str(i)
  keta=list(map(int,i))
  wa=sum(keta)
  if a<=wa<=b:
    kouho.append(int(i))
print(sum(kouho))
                         

Measured memory_bytes: 3548