akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e6 + 100;
const int mod = 1e6 + 3;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int q;
ll fac[maxn], inv[maxn];
ll pwr(ll a, ll pw)
{
	ll r = 1;
	while(pw > 0)
	{
		if(pw & 1)
			r = r * a % mod;
		a = a * a % mod;
		pw >>= 1;
	}
	return r;
}
ll modinv(ll a)
{
	return pwr(a, mod - 2);
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	fac[0] = inv[0] = 1;
	for(ll i = 1; i < maxn; i++)
	{
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = modinv(fac[i]);
	}
	cin >> q;
	while(q--)
	{
		ll x, d, n;
		cin >> x >> d >> n;
		if(d == 0)
		{
			cout << pwr(x, n) << "\n";
			continue;
		}
		if(n >= mod)
			cout << "0\n";
		else
		{
			ll a = x * modinv(d) % mod;
			ll ans = fac[a + n - 1];
			if(a != 0)
				ans = (ans * inv[a - 1]) % mod;
			ans = (ans * pwr(d, n)) % mod;
			cout << ans << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  vector<ll> s(n + 1, 0);
  REP(i, n) { s[i + 1] = s[i] + a[i]; }
  map<ll, vector<ll>> mp;
  REP(i, n + 1) { mp[(s[i] - i + 1000 * k) % k].push_back(i); }
  ll ans = 0;
  for (auto& kv : mp) {
    vector<ll> v = kv.second;
    REP(i, SZ(v)) {
      ll x = max(0LL, upper_bound(ALL(v), v[i] + k - 1) - v.begin() - i - 1);
      ans += x;
    }
  }
  cout << ans << endl;
}

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

#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

int MIN(int a, int b)
{
    return (a > b) ? b : a;
}



void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int k; cin >> k;
    vector<int> keta(k+10);
    keta[0] = 7 % k;
    for (int i = 1; i < k+10; i++) {
        keta[i] = ((keta[i-1] % k) * (10 % k)) % k;
    }

    int tmp = 0;
    for (int i = 0; i < k+10; i++) {
        tmp += keta[i];
        if (tmp % k == 0) {
            cout << i + 1 << endl;
            return;
        }
    }

    cout << -1 << endl;


}

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


Measured memory_bytes: 11080
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	string s;cin>>s;
	int div;cin>>div;
	for(int i=0;i<(int)s.size();i++){
		if(i%div==0)cout<<s[i];
	}
	cout << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    ll X;
    cin >> X;
    ll a = 100;
    ll c = 0;
    while (a < X)
    {
        a = a * 1.01;
        c++;
    }
    cout << c;
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3640
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    as <- tail . map (fst . fromJust . B.readInt) . B.lines <$> B.getContents
    print $ sum $ map (\s -> length s `mod` 2) $ group $ sort as


Measured memory_bytes: 15612
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};
  
/* ----------------------------------------------------------------------------------- */



void solve() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[2]) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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

int main()
{
	
	ll n,dis,cn=0;
	cin>>n>>dis;
	ll x,y;
	double d,k ;
	k = dis*1.0;
	for(ll i = 0;i<n;i++){
		cin>>x>>y;
		d = sqrt((x*x + y*y));
		
		if(d>k){
			 cn++;
		} 
	}
	cout<<n-cn;
	return 0;
}

Measured memory_bytes: 3660
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int n,m;
	cin>>n>>m;
	Graph to(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i,n) cout<<to[i].size()<<endl;
}

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

dp=[2000000000 for i in range(n)]
dp[0]=0
for i in range(n):
    
    for j in range(k+1):
        #print(i,j)
        if i+j>=n:
            break
        else:
            dp[i+j]=min(abs(h[i+j]-h[i])+dp[i],dp[i+j])
            #print(dp[i+j])
print(dp[n-1])
#print(dp)
    


Measured memory_bytes: 56544
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    vector<int> arr(len);
    for(int i = 0; i < len; i++) cin >> arr[i];
    vector<int> dp(len, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < len - 1; i++) {
        int right = min(len - 1, i + 2);
        for(int j = i + 1; j <= right; j++) {
            int cost = abs(arr[j] - arr[i]);
            if(dp[i] + cost < dp[j]) dp[j] = dp[i] + cost;
        }
    }
    cout << dp[len - 1];
}

Measured memory_bytes: 3856
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	int n;
	cin >> n;
	string s;
	cin >> s;
	int query;
	cin >> query;
	REP(tea, query) {
		int border = 0;
		cin >> border;
		long long ans = 0;
		long long now_d = 0;
		long long now_m = 0;
		long long now_value = 0;
		for (int i = 0; i < s.length(); ++i) {
			if (s[i] == 'D') {
				now_d++;
			}
			else if (s[i] == 'C') {
				ans += now_value;
			}
			else if (s[i] == 'M') {
				now_value += now_d;
				now_m++;
			}
			if (i >= border - 1) {
				int nexter = i - border + 1;
				if (s[nexter] == 'D') {
					now_value -= now_m;
					now_d--;
				}
				else if (s[nexter] == 'M') {
					now_m--;
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 1912
l,r = map(int,input().split())
tmp = 2019
tmp2 = 0
for i in range(l,min(r+1,l+2018)):
  
  for j in range(i+1,min(r+1,l+2018)):
    tmp = min(tmp,i*j%2019)
    
  if tmp == 0:
    break

print(tmp)

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

ll rec (ll n){
  if(n == 1) return 1;
  return rec(n / 2) * 2 + 1;
}

int main(){
  ll h;
  cin >> h;
  ll ans = rec(h);
  cout << ans << endl;
}


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

int main()
{
	string input_str;
	int k;

	cin >> input_str >> k;
	int len = input_str.length();

	string min_str = "zzzzzz";	// 咬ませ犬
	for( char c = 'a'; c <= 'z'; ++c )
	{
		int len_m = 0;		// 1文字目が[c]から成る文字列の最大長
		for( int i = 0; i <= len; ++i )		//文字列の最後まで
		{
			if( input_str[i] == c )
			{
				if( len-i < k )			// [c]からの文字列長が[k]に満たない場合
				{
					k -= (len-i);
					break;
				}
				else
				{
					string tmp_str = input_str.substr(i,k);
					if( min_str > tmp_str )
						min_str = tmp_str;
				}
			}
		}
	}

	cout << '\n' << min_str << endl;
}

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

int main() {
    int A,B,n;
    cin >> A >> B;
    if(A+B == 3)
        n = 3;
    else if(A+B == 5)
        n = 1;
    else
        n = 2;
    
    cout << n << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    ans = [0]*(M+1)
    for _ in range(N):
        food = list(map(int, input().split()))
        K = food[0]
        for i in range(1, K + 1):
            ans[food[i]] += 1
    print(ans.count(N))


if __name__ == '__main__':
    main()


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

int main() {
	string s, t;
	cin >> s >> t;
	vector<string> v(2);
	for (int i = 0; i < s.size(); i++) {
		v[i % 2].push_back(s[i]);
	}
	bool r = false;
	for (auto e : v) {
		int i, j;
		for (i = 0, j = 0; i < e.size() && j < t.size(); j++) {
			if (e[i] == t[j]) {
				i++;
			}
		}
		if (i == e.size()) {
			r = true;
			break;
		}
	}
	cout << (r ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <set>

int main() {
    int q;
    std::cin >> q;

    std::set<int> S;
    for (int i = 0; i < q; i++) {
        int op;
        std::cin >> op;
        if (op == 0) {
            int x;
            std::cin >> x;
            S.insert(x);
            std::cout << S.size() << std::endl;
        } else if (op == 1) {
            int x;
            std::cin >> x;
            std::cout << (int)(S.find(x) != S.end()) << std::endl;
        } else if (op == 2) {
            int x;
            std::cin >> x;
            S.erase(x);
        } else if (op == 3) {
            int L, R;
            std::cin >> L >> R;
            auto begin = S.lower_bound(L);
            auto end = S.upper_bound(R);
            for (auto it = begin; it != end; it++) {
                std::cout << *it << std::endl;
            }
        }
    }
}



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

int main(){
int i, j, N; cin >> N; int M=N-1, A[M], B[M];
vector< vector<int> > edges(N);
for(i=0; i<M; i++){ 
  cin >> A[i] >> B[i]; A[i]--; B[i]--;
  edges[A[i]].push_back(i); edges[B[i]].push_back(i); 
}
vector<int> V={0}; int v, w, e, d[N]={1};
for(i=0; i<V.size(); i++){
  for(v=V[i], j=0; j<edges[v].size(); j++){
    e=edges[v][j]; w=(v==A[e])?B[e]:A[e];
    if(!d[w]){ V.push_back(w); d[w]=d[v]+1; }
    if(w==N-1){ i=V.size(); break; }
  }
}
vector<int> P={N-1};
for(i=0; i<P.size(); i++){
  for(v=P[i], j=0; j<edges[v].size(); j++){
    e=edges[v][j]; w=(v==A[e])?B[e]:A[e];
    if(d[w]==d[v]-1){ P.push_back(w); if(d[w]==1){ i=P.size(); } break; }
  }
}
int s=P.size(), cl[N]={}; cl[0]=1; cl[N-1]=2;
for(i=1; i<s; i++){ 
  if(!cl[P[s-i-1]]){ cl[P[s-i-1]]=1; }
  if(!cl[P[i]]){ cl[P[i]]=2; }
}
vector<int> W={0}; int b=1; bool seen[N]={}; seen[0]=true;
for(i=0; i<W.size(); i++){
  for(v=W[i], j=0; j<edges[v].size(); j++){
    e=edges[v][j]; w=(v==A[e])?B[e]:A[e];
    if(cl[w]!=2&&(!seen[w])){ W.push_back(w); seen[w]=true; b++; }
  }
}
string ans=(b<=N-b)?"Snuke":"Fennec";
cout << ans << "\n";
}

Measured memory_bytes: 8568
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
ans = [0] * n
even_a = 0
for i in a[1::2]:
    even_a += i
ans[0] = s - 2 * even_a
for i in range(1, n):
    ans[i] = 2 * a[i-1] - ans[i-1]
print(" ".join(map(str, ans)))

Measured memory_bytes: 19092
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=10000010;
const ll mod=1000000007;
ll f[N],h,w,a,b;
ll powmod(ll x,ll n)
{
    ll s=1;
    while(n)
    {
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll lucas(ll n,ll m)
{
    ll a=f[n],b=(f[m]*f[n-m])%mod;
    return (a*powmod(b,mod-2))%mod;
}
int main()
{
    f[0]=1;
    for(ll i=1;i<N;i++)
        f[i]=(f[i-1]*i)%mod;
    	scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
        ll res=0;
        for(ll i=b+1;i<=w;i++)
        {
            ll tmp=(lucas(i-1+h-a-1,h-a-1)*lucas(w-i+a-1,w-i))%mod;
            res=(res+tmp)%mod;
        }
        printf("%lld\n",res);    
    return 0;
}

Measured memory_bytes: 78464
N = list(str(input()))
if N[-1] == '3':
    print('bon')
elif N[-1] == '0':
    print('pon')
elif N[-1] == '1':
    print('pon')
elif N[-1] == '6':
    print('pon')
elif N[-1] == '8':
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9120
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, W: "List[str]"):
    print(YES if len(set(W)) == N and all(
        W[i][-1] == W[i + 1][0]
        for i in range(N - 1)
    ) else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, W)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def main():
    k, n = map(int, input().split())
    a = [int(i) for i in input().split()]
    r = [a[i+1] - a[i] for i in range(n-1)]
    if a[-1] - a[0] < k/2.:
        r.append(a[-1]-a[0])
    else:
        r.append(a[0] + k - a[-1])
    rmax = max(r)
    ans = k - rmax
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24948
# coding: UTF-8
from collections import deque
#入力値の整理
n = int(input())
adj={}
visited={}
d={}
f={}
t=0
visited=set()
for i in range(n):
  raw=list(map(int,input().split()))
  u = raw.pop(0)
  k = raw.pop(0)
  raw.sort()
  q = deque(raw)
  adj[u] = q  
  d[u] = -1
  f[u] = -1

next = 1
v = next
d[next] = t + 1
stack = deque()
visited.add(v)

while True:
  t = t+1
  clear = True
  while adj[v]:
    cand = adj[v].popleft()
    if cand not in visited:
      next = cand
      d[next] = t + 1
      visited.add(next)
      clear = False
      break
  if clear:
    f[v] = t + 1
    if stack:
      next = stack.pop()
      v = next
    else:
      end = True
      for i in range(n):
        if i+1 not in visited:
          next = i+1
          end = False
          break
      if end:
        break
      else:
        t = t+1
        v = next
        d[next] = t + 1
        visited.add(v)
  else:
    stack.append(v)
    v = next

#print
i = 0
for j in range(n):
  i += 1
  print(str(i) + " " + str(d[i]) + " " + str(f[i]))

#return d,f



Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
/*
double squareRoot(long long number, int precision) 
{ 
    long long start = 0, end = number; 
    long long mid; 
    double ans; 
    while (start <= end) { 
        mid = (start + end) / 2; 
        if (mid * mid == number) { 
            ans = mid; 
            break; 
        }  
        if (mid * mid < number) { 
            start = mid + 1; 
            ans = mid; 
        } 
        else { 
            end = mid - 1; 
        } 
    } 
    double increment = 0.1; 
    for (long long i = 0; i < precision; i++) { 
        while (ans * ans <= number) { 
            ans += increment; 
        } 
        ans = ans - increment; 
        increment = increment / 10; 
    } 
    return ans; 
} 
*/
bool ispalin(string str)
{
	int i = 0, j = str.length() - 1;
	while (i < j)
	{
		if (str[i] != str[j]) return false;
		i++, j--;
	}
	return true;
}
void solve()
{
int n,r; cin>>n>>r;
if(n>=10)
cout<<r;
else
{
r+=100*(10-n);
cout<<r;
}
return ;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t =1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in).useDelimiter("[,\\s]+");
        int nRectangles = 0;
        int nLozenges = 0;

        while (scanner.hasNextInt()) {
            int side1 = scanner.nextInt();
            int side2 = scanner.nextInt();
            int diagonal = scanner.nextInt();
            if (side1 * side1 + side2 * side2 == diagonal * diagonal) {
                nRectangles++;
            }
            if (side1 == side2) {
                nLozenges++;
            }
        }
        System.out.println(nRectangles);
        System.out.println(nLozenges);
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	for i := 0; i < n; i++ {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}
	for i := 0; i < n; i++ {
		sc.Scan()
		c[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(a)
	sort.Ints(c)

	ans := int64(0)
	for _, x := range b {
		// (l, r]
		l := -1
		r := n
		for r-l > 1 {
			mid := (l + r) / 2
			if a[mid] >= x {
				r = mid
			} else {
				l = mid
			}
		}
		j := int64(r)
		// [l, r)
		l = -1
		r = n
		for r-l > 1 {
			mid := (l + r) / 2
			if c[mid] <= x {
				l = mid
			} else {
				r = mid
			}
		}
		ans += j * int64(n-(l+1))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6016
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  // int n;
  // int m;
  // cin >> n;
  // cin >> m;
  ll a,b,x,s,e;
  cin>>a>>b>>x;
  s=a/x;
  if(a%x)++s;
  e=b/x;
  cout << e-s+1;

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



Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
P = list(map(int, input().split()))
mn = [N] * (N-K)
mx = [-1] * (N-K)
min_heap = []
max_heap = []
for i in range(K):
    heappush(min_heap, P[i])
    heappush(max_heap, -P[i])
used = set()
for i in range(N-K):
    heappush(min_heap, P[i+K])
    heappush(max_heap, -P[i+K])
    while min_heap[0] in used:
        heappop(min_heap)
    while -max_heap[0] in used:
        heappop(max_heap)
    mn[i] = min_heap[0]
    mx[i] = -max_heap[0]
    used.add(P[i])
ans = 1
for i in range(N-K):
    if P[i] != mn[i] or P[i+K] != mx[i]:
        ans += 1
inc = 1
cnt = 0
for i in range(1, N):
    if P[i-1] < P[i]:
        inc += 1
    else:
        inc = 1
    if inc == K:
        cnt += 1
ans -= max(0, cnt-1)
print(ans)




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

//#define DEBUG 1

//#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 100000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    //freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n;
    cin >> n;
    int max_val=0, max_pos=0;
    for0(i,n) {
        int x;
        read(x);
        if (abs(x) > abs(max_val)) {
            max_val = x;
            max_pos = i;
        }
    }
    cout<<2*n-2<<endl;
    for (int i=0; i<n; i++) {
        if (i != max_pos) {
            printf("%d %d\n",max_pos+1,i+1);
        }
    }
    if (max_val <= 0) {
        for (int i=n-1; i>0; i--)
            printf("%d %d\n",i+1,i);
    }
    else {
        for (int i=0; i<n-1; i++) 
            printf("%d %d\n",i+1,i+2);
    }
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's')
    s += "es";
  else
    s += "s";
  cout << s << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3660
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN


int main() {
	ll n,a[210]={},ans=0;
	cin>>n;
	reg(i,1,n){
		reg(j,1,n){
			if(i*j>n)break;
			a[i*j]++;
		}
	}
	reg(i,1,n)if(a[i]==8 && i%2==1)ans++;
	cout<<ans<<endl;
	return 0;
}

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

dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i + j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h_ls[i+j] - h_ls[i]))
print(dp[-1])

Measured memory_bytes: 56928
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n, k, s;
  cin >> n >> k >> s;
  int rest = s + 1;
  if (s + 1 > 1e9) rest = 1;
  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    int cur = s;
    if (i >= k) cur = rest;
    cout << cur;
  }
  return 0;
}


Measured memory_bytes: 1280
from itertools import accumulate
n,c=map(int,input().split())
sushi=[list(map(int,input().split())) for i in range(n)]

r=[sushi[0][1]-sushi[0][0]]
for i in range(1,n):
    r.append(r[-1]+sushi[i][1]-(sushi[i][0]-sushi[i-1][0]))
l=[sushi[n-1][1]-(c-sushi[n-1][0])]
for i in range(n-2,-1,-1):
    l.append(l[-1]+sushi[i][1]-((c-sushi[i][0])-(c-sushi[i+1][0])))
r2=[sushi[0][1]-2*sushi[0][0]]
for i in range(1,n):
    r2.append(r2[-1]+sushi[i][1]-2*(sushi[i][0]-sushi[i-1][0]))
l2=[sushi[n-1][1]-2*(c-sushi[n-1][0])]
for i in range(n-2,-1,-1):
    l2.append(l2[-1]+sushi[i][1]-2*((c-sushi[i][0])-(c-sushi[i+1][0])))
r=list(accumulate(r,max))
l=list(accumulate(l,max))

cand=[l[-1],r[-1]]
for i in range(n):
    if 0<=n-i-2<=n-1:
        cand.append(l2[i]+r[n-i-2])
        cand.append(r2[i]+l[n-i-2])

print(max(max(cand),0))

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



int main(){
   
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    if(N==1){
        cout <<A.at(0)<<endl;
    }
    else if(N%2==0){
        for(int i=N-1; i>0; i-=2){
            cout << A.at(i) << ' ';
        }
        for(int j=0; j<N; j+=2){
        cout << A.at(j) << ' ';
        }
        cout <<endl;
    }
        else
    {
            for(int i=N-1; i>=0; i-=2){
                cout << A.at(i) << ' ';
            }
            for(int j=1; j<N-1; j+=2){
                cout << A.at(j) << ' ';
            }
        cout << endl;
        }
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_map>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

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

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

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

	bool result = true;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		if (x % 2 == 0) {
			if ((x % 3) * (x % 5) != 0) { result = false; }
		}
	}

	if (result) {
		cout << "APPROVED"<<endl;
	}
	else {
		cout << "DENIED" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

vector<int> ZAlgorithm(const string &s) {
    vector<int> prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j         = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        auto prefix_length = ZAlgorithm(s.substr(i, n - i));
        for (int j = 0; j < prefix_length.size(); ++j) {
            if (prefix_length[j] <= j)
                chmax(ret, prefix_length[j]);
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 



s = sorted(input())
ans = "No"
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
    ans = "Yes"
print(ans)


Measured memory_bytes: 3060
fn main() {
    macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            input_inner!{iter, $($r)*}
        };
        ($($r:tt)*) => {
            let mut s = {
                use std::io::Read;
                let mut s = String::new();
                std::io::stdin().read_to_string(&mut s).unwrap();
                s
            };
            let mut iter = s.split_whitespace();
            input_inner!{iter, $($r)*}
        };
    }
    
    macro_rules! input_inner {
        ($iter:expr) => {};
        ($iter:expr, ) => {};
    
        ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($iter, $t);
            input_inner!{$iter $($r)*}
        };
    }
    
    macro_rules! read_value {
        ($iter:expr, ( $($t:tt),* )) => {
            ( $(read_value!($iter, $t)),* )
        };
    
        ($iter:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        };
    
        ($iter:expr, chars) => {
            read_value!($iter, String).chars().collect::<Vec<char>>()
        };
    
        ($iter:expr, usize1) => {
            read_value!($iter, usize) - 1
        };
    
        ($iter:expr, $t:ty) => {
            $iter.next().unwrap().parse::<$t>().expect("Parse error")
        };
    }

    input!{
        a: usize,
        b: usize,
    }
    println!("{}", a*b);
}

Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<string>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert	//お試し
typedef pair<int,int> pii;//You can add other pairs of types in the same way.

const long long M=1000000007;

int main(){
	int n,m=3;
	long long ans=1;
	vector<int> p;
	vector<int> v;
	p.pb(2);
	cin>>n;
	while(m<=n){
		int m0=sqrt(m);
		bool f=false;
		for(int i=0;i<p.size()&&p[i]<=m0;++i){
			if(m%p[i]==0){
				f=true;
				break;
			}
		}
		if(!f){
			p.pb(m);
		}
		++m;
	}
	for(int i=0;i<p.size();++i){
		int q=p[i],c=0;
		m=n;
		m/=q;
		while(m>0){
			c+=m;
			m/=q;
		}
		v.pb(c);
	}
	for(int i=0;i<v.size();++i){
		ans*=(v[i]+1);
		ans%=M;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)

from operator import mul
from functools import reduce
from functools import lru_cache

N = int(input())
A_list = [int(e) for e in input().split()]

#ある番号のボールが何個あるかをまとめる
number_dict = dict()

for i in range(N):
    ball_number = A_list[i]
    if ball_number not in number_dict:
        number_dict[ball_number] = 0
        
    number_dict[ball_number] += 1

#それぞれの番号のボールから2個選ぶ組み合わせをカウントする。
comb_dict = dict()

@lru_cache(maxsize=10000000000000)
def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
    
@lru_cache(maxsize=10000000000000)
def two_choice(N):
    if N == 2:
        return 1
    elif N <= 1:
        return 0
    elif N == 3:
        return 3
    else:
        return combinations_count(N,2)

all = 0

for in_dict in number_dict.items():
    ball_number = in_dict[0]
    balls = in_dict[1]
    comb_dict[ball_number] = two_choice(balls)
    all += comb_dict[ball_number]

#回答作成
for i in range(1,N+1):
    ball_number = A_list[i-1]
    now_balls = number_dict[ball_number] - 1
    print(int(all-comb_dict[ball_number]+two_choice(now_balls)))

Measured memory_bytes: 31888
N=int(input())
s=input()
S=list(s)
#print(S[0])
flg=0
for i in range(N-2):
    if S[i] == 'A':
        if S[i+1] =='B':
            if S[i+2] =='C':
                flg+=1
print(flg)

Measured memory_bytes: 2940
num_dic = {}
num_num = int(input())
odd_count = 0
input_line = input().split(" ")
for i in range(len(input_line)):
    num_dic[i+1] = int(input_line[i])
for k, v in num_dic.items():
    if int(k) % 2 == 1 and int(v) % 2 == 1:
        odd_count += 1
print(odd_count)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n  >>m;
	
	VI a(n,0);
	rep(i, n) cin >>a[i];
	
	priority_queue<int> pq;
	rep(i, n) pq.push(a[i]);
	
	while(sz(pq) && m>0){
		int cr = pq.top();
		pq.pop();
		if(cr/2 > 0) pq.push(cr/2);
		m--;
	}
	ll ans =0;
	while(sz(pq)){
		int cr = pq.top();
		pq.pop();
		ans += cr;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1276
#=
B:
- Julia version: 0.5.2
- Author: abap
- Date: 2019-12-21
=#

S = readline()

len = length(S)

count = 0


for i in  1:div(len,2)
     if S[i] != S[len-i]
         count += 1
      end
end

println(count)

Measured memory_bytes: 109532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		int n1;
		int n2;
		n1 = a > b ? b : a;
		n2 = c > d ? d : c;
		System.out.println(n1 + n2);
	}

}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N; cin >> N;
    V<int> A = V<int>(N+1); REP(i,1,N+1) cin >> A[i];
    V<int> B = V<int>(N+1); REP(i,1,N+1) cin >> B[i];
    V<int> C = V<int>(N+1); REP(i,1,N+1) cin >> C[i];
    sort(A.begin()+1,A.end());
    sort(B.begin()+1,B.end());
    sort(C.begin()+1,C.end());

    V<ll> B_num = V<ll>(N+1, 0);
    REP(b,1,N+1) {
        ll pos = lower_bound(A.begin()+1,A.end(),B[b]) - A.begin() -1;
        B_num[b] = pos;
        // REP(a,1,N+1) {
        //     if(A[a]>=B[b]) break;
        //     B_num[b]++;
        // }
    }

    V<ll> C_num = V<ll>(N+1, 0);
    REP(i,2,N+1) B_num[i] += B_num[i-1];
    REP(c,1,N+1) {
        ll pos = lower_bound(B.begin()+1,B.end(),C[c]) - B.begin() -1;
        C_num[c] = B_num[pos];
        // REP(b,1,N+1) {
        //     if(B[b]>=C[c]) break;
        //     C_num[c] += B_num[b];
        // }
    }

    cout << accumulate(C_num.begin()+1,C_num.end(), 0L) << endl;
    return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        switch (n % 10)
        {
            case (2):
            case (4):
            case(5):
            case (7):
            case (9):
            System.out.println("hon");
            break;

            case (0):
            case (1):
            case (6):
            case (8):
                System.out.println("pon");
                break;
            case (3):
                System.out.println("bon");

        }

    }
}


Measured memory_bytes: 35772