akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int main(){
    string s;
    cin>>s;
    int a=-1, z=-1;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='A'&&a==-1)a=i;
        if(s[i]=='Z')z=i;
    }
    cout<<z-a+1<<endl;
}


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

int main(){ 
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll res = 0;
  for (int d = 28; d >= 0; d--) {
    int high = (1 << (d+1)), low = (1 << d);
    for (int i = 0; i < n; i++) b[i] %= high, a[i] %= high;
    sort(b.begin(), b.end());

    ll num = 0;

    for (int i = 0; i < n; i++) {
      int cnt = 0;
      cnt += lower_bound(b.begin(), b.end(), high - a[i]) - lower_bound(b.begin(), b.end(), low - a[i]);
      cnt += lower_bound(b.begin(), b.end(), high + high - a[i]) - lower_bound(b.begin(), b.end(), high + low -a[i]); 
      num += cnt;
    }
    if (num & 1) res += (1LL << d);
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

vector <int> a;
vector <vector <long long>> dp;

long long solve(int l, int r) {
    if (l >= r)
        return 0;
    if (dp[l][r] != -1)
        return dp[l][r];
    dp[l][r] = 1e18;
    forn (i, l, r)
        chkmin(dp[l][r], solve(l, i) + solve(i + 1, r));
    forn (i, l, r + 1)
        dp[l][r] += a[i];
    return dp[l][r];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    a.resize(n);
    cin >> a;
    dp.resize(n, vector <long long> (n, -1));
    cout << solve(0, n - 1);
    return 0;
}

Measured memory_bytes: 1536
S = input()
ans_NS = 0
ans_EW = 0

if S.count('S') >= 1:
    ans_NS += 1
if S.count('N') >= 1:
    ans_NS += 1
if S.count('E') >= 1:
    ans_EW += 1
if S.count('W') >= 1:
    ans_EW += 1

if ans_EW != 1:
    if ans_NS != 1:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

const int V_MAX = 100010;

struct ModeInfo{
    ll mode_value;
    ll mode_count;
    ll mode_value_2nd;
    ll mode_count_2nd;
};

// 最頻値・最頻値2ndを求める
struct ModeInfo GetModeInfo(vector<ll> A){
    vector<int> count(V_MAX);
    FOR(i, 0, V_MAX){
        count[i] = 0;
    }
    for(ll a : A){
        count[a]++;
    }

    // max求める用
    vector<int> count_copy(V_MAX);
    copy(count.begin(), count.end(), count_copy.begin());
    sort(ALL(count_copy));
    ll l = count_copy.size();
    ll count_max = count_copy[l-1];
    ll count_max_2nd = count_copy[l-2];

    ll max_index;
    ll max_index_2nd;

    // indexを探す
    FOR(i, 0, V_MAX){
        if(count[i] == count_max){
            max_index = i;
            break;
        }
    }
    FOR(i, 0, V_MAX){
        if(count[i] == count_max_2nd){
            max_index_2nd = i;
            break;
        }
    }

    ModeInfo modeInfo;
    modeInfo.mode_value = max_index;
    modeInfo.mode_count = count_max;
    modeInfo.mode_value_2nd = max_index_2nd;
    modeInfo.mode_count_2nd = count_max_2nd;
    return modeInfo;
}

ll min(ll a, ll b){
    if(a > b){
        return b;
    }else{
        return a;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int n;
    cin >> n;

    vector<ll> a(n/2);
    vector<ll> b(n/2);

    FOR(i, 0, n/2){
        cin >> a.at(i);
        cin >> b.at(i);
    }
    
    auto modeInfoA = GetModeInfo(a);
    auto modeInfoB = GetModeInfo(b);
    
    // modeが違うなら簡単
    ll len = n/2;
    if(modeInfoA.mode_value != modeInfoB.mode_value){
        ll changeNumA = len - modeInfoA.mode_count;
        ll changeNumB = len - modeInfoB.mode_count;
        p(changeNumA + changeNumB);
    }
    // modeが同じなら、どちらかは 2nd modeを使う
    else{
        ll candidate0 = 2 * len - modeInfoA.mode_count - modeInfoB.mode_count_2nd;
        ll candidate1 = 2 * len - modeInfoA.mode_count_2nd - modeInfoB.mode_count;
        p(min(candidate0, candidate1));
    }
    
    return 0;
}

Measured memory_bytes: 2280
/*
Author : shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,x,ascii1,ascii2,ascii3,num,res=100000,n=753,count=0;
    string str;
    cin>>str;
    for(i=0;i<(str.length()-2);i++)
    {
        ascii1=str[i]-48;
        ascii2=str[i+1]-48;
        ascii3=str[i+2]-48;
        num=ascii1*100+ascii2*10+ascii3;
        res=min(res,abs(num-n));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define sort(v)     sort((v).begin(),(v).end())
#define rsort(v)    sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
//finds the next permutation to given sequence of nos
int nextpermutation(vi v)
{
    vi t=v;
    sort(t);
    int x=0;
    while(true)
    {
        x++;
        if(t==v)
        {
            return x;
        }
        next_permutation(all(t));
    }
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int x;
    cin>>x;
    for(int i=x;i<1000000;i++)
    {
        if(isPrime(i))
        {
            print(i)
            break;
        }
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  long long N, A, B, C, D, E; cin >> N >> A >> B >> C >> D >> E;
  cout << max({((N-1)/A), (N-1)/B, (N-1)/C, (N-1)/D, (N-1)/E}) + 5 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0; int j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

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

  mergeSort(A, n, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


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

typedef long long LL;
const LL maxn=2e5+5;
LL n, x, a[maxn], A[maxn];
LL val(LL x){ return x==1?5:2*x+1; }

int main(){
    scanf("%lld%lld", &n, &x); LL ans=0x3f3f3f3f3f3f3f3f;
    for (LL i=1; i<=n; ++i) scanf("%lld", &a[i]), A[i]=A[i-1]+a[i];
    for (LL k=1; k<=n; ++k){  //取k次
        LL cans=k*x, cnt=1;
        for (LL i=n; i>0; i-=k, ++cnt){
            cans+=(A[i]-A[max(i-k, 0ll)])*val(cnt);
            if (cans>ans) break;
        }
        ans=min(ans, cans);
    }
    printf("%lld\n", ans+n*x);
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
int main() {
	int h1, m1, h2, m2, k;
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	int t1 = 60 * h1 + m1;
	int t2 = 60 * h2 + m2;
	printf("%d\n", t2 - t1 - k);
	return 0;
}

Measured memory_bytes: 1728
#!/usr/bin/env ruby

def judge(str)
  return false if not str.length.even?
  m = str.length / 2
  return str[0...m] == str[m..-1]
end

def solve
  str = gets.chomp
  loop do
    str.chop!
    break if judge(str)
  end

  puts str.length
end

if $0 == __FILE__
  solve
end


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N, K; cin >> N >> K;

  ll result = 0;
  if (K==0) result = N*N;
  else for(int i=K+1; i<=N; i++){
    ll d = N/i, m = N%i;
    result += (i-K)*d;
    if (m>=K) result += m-K+1;
  }
  cout << result << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;

ll n;

ll res;

int uradi(ll k){
    if(k == 1) return 0;
    ll x = n;
    //cout << x << " " << k << endl;
    while(x%k == 0) x /= k;
    return ((x-1)%k == 0);
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin >> n;
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            res += uradi(i);
            if(i != n/i) res += uradi(n/i);
        }
    }
    //cout << res << endl;
    for(ll i=1; i*i<=n-1; i++){
        if((n-1)%i == 0){
            res += (n%i != 0);
            if(i != n/i) res += (n%((n-1)/i) != 0);
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, k; cin >> n >> k;
	for(int i = 0;1;i++) {
		if (n < pow(k, i)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll N,K;
    cin >> N >> K;
    queue<ll> que;
    REP(i,N) {
        ll A;
        cin >> A;
        if (i < K)que.push(A);
        else {
            que.push(A);
            auto f = que.front();
            que.pop();
            if (A > f) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
}

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

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

char F[2010][2010];

int main(int argc, char **argv)
{
	ll H, W; cin >> H >> W;
	REP(h, H)REP(w, W) cin >> F[h][w];
	vector<vector<ll>> C_ob(W), R_ob(H);

	REP(h, H) R_ob[h].push_back(-1);
	REP(w, W) C_ob[w].push_back(-1);

	REP(h, H)REP(w, W)
	{
		
		if (F[h][w] == '#')
		{
			C_ob[w].push_back(h);
			R_ob[h].push_back(w);
		}
	}

	REP(h, H) R_ob[h].push_back(W);
	REP(w, W) C_ob[w].push_back(H);

	ll res{0};
	REP(h, H)REP(w, W)
	{
		if (F[h][w] == '#') continue;

		ll top, down, left, right;
		top = *(lower_bound(C_ob[w].begin(), C_ob[w].end(), h)-1) + 1;
		down = *lower_bound(C_ob[w].begin(), C_ob[w].end(), h) - 1;
		
		left = *(lower_bound(R_ob[h].begin(), R_ob[h].end(), w)-1) + 1;
		right = *lower_bound(R_ob[h].begin(), R_ob[h].end(), w) - 1;

		// std::cout << "----------"<< std::endl;
		// std::cout << "h, w : " << h << ", " << w << std::endl;
		// std::cout << "top : " << top << std::endl;
		// std::cout << "down : " << down << std::endl;
		// std::cout << "left : " << left << std::endl;
		//std::cout << "right : " << right << std::endl;
		
		res = max(res, right - left + down - top + 1);
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 71040
import sys
sys.setrecursionlimit(500000)

N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])


def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)


dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])

Measured memory_bytes: 153684
A, B = list(map(int, input().split()))


def f(M):
    digit = len(bin(M)) - 2
    num = M - 2**(digit-1) + 1
    x = 0

    for i in range(digit):
        if i == 0:
            if M % 4 == 1 or M % 4 == 2:
                x += 1
        else:
            if bin(M)[-(i+1)] == '1':
                x += (num % 2) * (2**i)

    return x


if A == 0:
    print(f(B))
else:
    print(f(B)^f(A-1))


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B; cin >> A >> B;
    int ans = 0;
    for(int i = A; i <=B; i++){
        int l = i;
        int l1 = l% 10;
        int l5 = l/10000;
        if(l1 != l5) continue;
        l -= l5 * 10000;
        l /= 10;
        if(l % 10 == l/100) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int x, y; cin >> x >> y;
	int ans;
	if (x > 0 && y > 0)
	{
		if (x < y) ans = y - x;
		else ans = x - y + 2;
	}
	else if (x > 0 && y < 0)
	{
		if (x < abs(y)) ans = abs(y) - x + 1;
		else ans = x - abs(y) + 1;
	}
	else if (x < 0 && y > 0)
	{
		if (abs(x) < y) ans = y - abs(x) + 1;
		else ans = abs(x) - y + 1;
	}
	else if (x < 0 && y < 0)
	{
		if (x < y) ans = y - x;
		else ans = x - y + 2;
	}
	else if(x == 0)
	{
		if (y > 0) ans = y;
		else ans = -y + 1;
	}
	else if (y == 0)
	{
		if (x < 0) ans = -x;
		else ans = x + 1;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    n = n%10;
    if ( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) {
        cout << "hon" << endl;
    } else if ( n == 0 || n == 1 || n == 6 || n == 8 ) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
fn main() {
    let mut v: Vec<u32> = read_vec();
    v.sort();
    println!("{}", v[0] + v[1]);
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub 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()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#include <iostream>

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

using namespace std;

int main()
{
    int K;
    cin>>K;
    string s;
    cin>>s;
    if(s.size()<=K){
        cout << s << endl;
    }else{
        rep(i,K){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
from Queue import Queue
n = int(raw_input())
adjList = [[] for _ in range(n+1)]
colors = [-1] * (n+1)
start = None
for i in range(n-1):
    u, v, w = map(int, raw_input().split())
    adjList[u].append((v, w))
    adjList[v].append((u, w))
    if start is None:
        start = u
def bfs(adjList, colors, start):
    colors[start] = 0
    q = Queue()
    q.put(start)
    while not q.empty():
        u = q.get()
        for adj, w in adjList[u]:
            if colors[adj] == -1:
                if w % 2 == 0:
                    colors[adj] = colors[u]
                else:
                    colors[adj] = colors[u]^1
                q.put(adj)
bfs(adjList, colors, start)
for i in range(1, n+1):
    if colors[i] != -1:
        print colors[i]

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

using namespace std;

int main()
{
    long long int n,i,max=-2590,c=0,z;
    cin>>n;
    for(i=1;i<=n;++i){

        cin>>z;

        if(z>=max){

            max=z;
            ++c;

        }

    }
    cout<<c<<endl;

    return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
//#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=405+5,M=2e6+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n,m,bin[30]={1};
int x[M],y[M],die[N];
bitset<405>b[N];
int main(){
	read(n,m);
	rep(i,1,m)read(x[i],y[i]);
	rep(i,1,n){
		b[i][i]=1;die[i]=0;
		repd(j,m,1){
			if(b[i][x[j]]&&b[i][y[j]])die[i]=1;else
			if(b[i][x[j]])b[i][y[j]]=1;else
			if(b[i][y[j]])b[i][x[j]]=1;
		}
	}/*
	rep(i,1,n){
		rep(j,1,n)printf("%d ",!!b[i][j]);
		puts("");
	}*/
	int res=0;
	rep(i,1,n)rep(j,i+1,n)if(!die[i]&&!die[j]){
		if((b[i]&b[j]).none())res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <set>

using namespace std;

#define L 0
#define R 1


int count(string s) {
    string left = "qwertasdfgzxcvb";
    string right = "yuiophjklnm";
    int c = 0;
    int cur_hand;
    if (left.find(s[0], 0) != string::npos) cur_hand = L;
    else cur_hand = R;
    for (string::iterator si = s.begin() + 1; si != s.end(); si++) {
        if (left.find(*si, 0) != string::npos) {
            if (cur_hand == R) {
                cur_hand = L;
                c++;
//                cout << "Changed: " << *si << "\n";
            }
        } else {
            if (cur_hand == L) {
                cur_hand = R;
                c++;
//                cout << "Changed: " << *si << "\n";
            }
        }
    }
    return c;
}

int main() {
    string s;
    while (cin >> s) {
        if (s == "#") break;
        cout << count(s) << endl;
    }
    return 0;
}

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

int main() {
    int ans=0, N, a, b, c, k, tmp;   
    cin >> a>>b>>c>>k;
    priority_queue<int, vector<int>> asc;
    asc.push(a);
    asc.push(b);
    asc.push(c);
    
    for(int i=0; i<k ; i++){
	tmp = asc.top();
	asc.pop();
	asc.push(tmp*2);	
    }

    while(!asc.empty()){
	ans += asc.top();
	asc.pop();
    }

    cout << ans<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll SX, SY, GX, GY, N;
vector<pll> P;

int main(void) {
  ll mx = 1, my = 1;
  cin >> SX >> SY >> GX >> GY;
  if(SX > GX) swap(SX, GX), mx = -1;
  if(SY > GY) swap(SY, GY), my = -1;

  cin >> N;
  REP(i, 0, N) {
    ll x, y;
    cin >> x >> y;
    if(SX <= x && x <= GX && SY <= y && y <= GY) {
      P.push_back(pll(mx * x, my * y));
    }
  }
  N = P.size();
  sort(P.begin(), P.end());

  ll dp[200000];
  REP(i, 0, N) dp[i] = INF;
  REP(i, 0, N) {
    *lower_bound(dp, dp + N, P[i].second) = P[i].second;
  }
  ll t = lower_bound(dp, dp + N, INF) - dp;

  double pi = atan(1.0) * 4.0;
  double ans = ((GX - SX) + (GY - SY)) * 100 + t * (5 *  pi - 20);
  if(min(GX - SX, GY - SY) + 1 == t) ans += 5 * pi;
  printf("%.15lf\n", ans);
}


Measured memory_bytes: 6512
N, M = list(map(int,input().split()))
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
C = [[]*M for _ in range(N)]

def match(i,j):
    for k in range(M):
        if A[i+k][j:j+M] != B[k]:return False
    return True

def a():
    for i in range(N-M+1):
        for j in range(N-M+1):
            if match(i,j):return "Yes"
    return "No"

print(a())

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

long long int area(long int h, long int w, unsigned long long int min)
{
    long int i;
    unsigned long long int S[3],max=min;
    for(i=1;i<=h-1;i++){
        S[0]=i*w;
        S[1]=(h-i)*(w/2);
        S[2]=(h-i)*(w-w/2);
        if(llabs(S[0]-S[1])>=llabs(S[1]-S[2]) && llabs(S[0]-S[1])>=llabs(S[0]-S[2])) max=llabs(S[0]-S[1]);
        else if(llabs(S[1]-S[2])>=llabs(S[0]-S[1]) && llabs(S[1]-S[2])>=llabs(S[0]-S[2])) max=llabs(S[1]-S[2]);
        else max=llabs(S[0]-S[2]);
        
        if(min>max) min=max;
        
        S[1]=(h-i)/2*w;
        S[2]=(h-i-(h-i)/2)*w;
        if(llabs(S[0]-S[1])>=llabs(S[1]-S[2]) && llabs(S[0]-S[1])>=llabs(S[0]-S[2])) max=llabs(S[0]-S[1]);
        else if(llabs(S[1]-S[2])>=llabs(S[0]-S[1]) && llabs(S[1]-S[2])>=llabs(S[0]-S[2])) max=llabs(S[1]-S[2]);
        else max=llabs(S[0]-S[2]);
        
        if(min>max) min=max;
    }
    return min;
}

int main()
{
    long int H,W;
    scanf("%ld %ld",&H,&W);
    unsigned long long int min=H*W;
    if(min%3==0) puts("0");
    else{
        min=area(H,W,min);
        min=area(W,H,min);
        printf("%lld\n",min);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> G[N], W[N];
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
        W[u].push_back(w);
        W[v].push_back(w);
    }

    queue<int> que;
    que.push(0);
    vector<bool> visited(N, false);
    visited[0] = true;

    vector<int> color(N, 0);
    while (!que.empty()) {
        int u = que.front(); que.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (visited[v]) continue;
            color[v] = (color[u] + W[u][i]) % 2;
            visited[v] = true;
            que.push(v);
        }
    }

    for (int c : color) {
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

struct edge {
        int v_a;
        int v_b;
        int w;
    
        bool operator<( const  edge& right) const {
            return w < right.w;
        }
};

struct p {
    int v;
    int z;

    bool operator<( const p& right ) const {
        return z < right.z;
    }
};


int find(int x, vector<int>& par) {
    while (par[x] != x) {
        x = par[x];
    }
    
    return x;
}

void unite(int x, int y, vector<int>& rank, vector<int>& par) {
    x = find(x, par);
    y = find(y, par);
    if (x == y) {return;}
    
    if (rank[x] < rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank[x] == rank[y]) {rank[x]++;}
    }
}

bool same(int x, int y, vector<int>& par) {
    return find(x, par) == find(y, par);
}

int main(void){
    int n;
    scanf("%d", &n);
    vector<p> p_x(n);
    vector<p> p_y(n);

    for (int i = 0; i < n; i++) {
        p_x[i].v = i;
        p_y[i].v = i;
        scanf("%d %d", &p_x[i].z, &p_y[i].z);;
    } 

    sort(p_x.begin(), p_x.end());
    sort(p_y.begin(), p_y.end());

    vector<edge> e(2 * (n-1));

    for (int i = 0; i< (n-1);i++) {
        e[i].v_a = p_x[i].v;
        e[i].v_b = p_x[i+1].v;
        e[i].w = abs(p_x[i].z - p_x[i+1].z);
    
        e[i + (n-1)].v_a = p_y[i].v;
        e[i + (n-1)].v_b = p_y[i+1].v;
        e[i + (n-1)].w = abs(p_y[i].z - p_y[i+1].z);
    }

    sort(e.begin(), e.end());

    vector<int> par(n);
    vector<int> rank(n);
    
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rank[i] = 0;
    } 

    int cost = 0;

    for (int i = 0; i < 2*(n-1); i++) {
        if (!same(e[i].v_a, e[i].v_b, par)) {
            cost += e[i].w;
            unite(e[i].v_a, e[i].v_b, rank, par);
        }
    }

    printf("%d \n", cost);

    return 0;
}

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

int n;
ll a[100010];

int main(){
    while(cin >> n){
        rep(i,n) cin >> a[i];
        ll ans = 0;
        rep(i,n-1){
            if(a[i]%2 == 1 && a[i+1] >= 1){
                ++ans;
                --a[i]; --a[i+1];
            }
        }
        rep(i,n){
            ans += a[i]/2;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int odd_cnt = 0;
  REP(i,n){
    int a;
    cin >> a;
    if(a%2==1) odd_cnt++;
  }
  puts((odd_cnt%2==0 ? "YES" : "NO"));
  return 0;
}


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

public class Main {
    static Scanner scanner = new Scanner(System.in);
    static int mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Map<Integer, Set<Integer>> edge = new HashMap<>();
        for (int i = 0; i < n; i++) {
            edge.put(i, new HashSet<>());
        }
        for (int i = 0; i < m; i++) {
            edge.get(scanner.nextInt() - 1).add(scanner.nextInt() - 1);
        }
        int[][] can = new int[n][3];
        int s = scanner.nextInt() - 1;
        int t = scanner.nextInt() - 1;
        can[s][0] = 1;
        Deque<Point> deque = new ArrayDeque<>();
        deque.add(new Point(s, 0));
        while (!deque.isEmpty()) {
            Point point = deque.poll();
            for (int v : edge.get(point.x)) {
                if (can[v][(point.y + 1) % 3] == 0) {
                    can[v][(point.y + 1) % 3] = can[point.x][point.y] + 1;
                    deque.add(new Point(v, (point.y + 1) % 3));
                } else {
                    can[v][(point.y + 1) % 3] = Math.min(can[v][(point.y + 1) % 3], can[point.x][point.y] + 1);
                }
            }
        }
        if (can[t][0] == 0) {
            System.out.println(-1);
            return;
        }
        System.out.println(can[t][0] / 3);
    }
}

Measured memory_bytes: 115116
<?php
while(true){
    list($m,$f,$r)= explode(" ",trim(fgets(STDIN)));
    $total = $m + $f;
    if($m == -1 && $f == -1 && $r == -1) break;
    if($m == -1 || $f == -1 || $total < 30) echo "F\n";
    elseif($total >= 80) echo "A\n";
    elseif($total >= 65) echo "B\n";
    elseif($total >= 50 || $r >= 50) echo "C\n";
    else echo "D\n";
}

Measured memory_bytes: 15340
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        long n = scanner.nextInt(), a = 1, b = 1;
        for (int i = 0; i < n; i++) {
            long j = Math.max((a - 1) / (a = scanner.nextInt()), (b - 1) / (b = scanner.nextInt())) + 1;
            a *= j;
            b *= j;
        }
        System.out.println(a + b);
    }
}

Measured memory_bytes: 25828
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long n = scan.nextLong(),
             a = scan.nextLong(),
             b = scan.nextLong(),
             c = n % (a + b);
        long out = (n / (a + b)) * a + (c <= a ? c: a);
        System.out.println(out);
    }
}

Measured memory_bytes: 23764
//#include <bits/stdc++.h>
//
//using namespace std;
//
//#define int long long
//#define endl '\n'
//#define maxn 100010
//const int MOD = 1000000007;
//
//int n, m;
//int v[maxn], b[maxn];
//
//int solve(int pos1, int pos2, vector<int> co) {
//    if (pos1 == n and pos2 == m) {
//        for (auto x: co)cout << x << " ";
//        cout << endl;
//        return 1;
//    }
//
//    int ans = 0;
//    if (pos1 < n) {
//        co.push_back(v[pos1]);
//        ans += solve(pos1 + 1, pos2, co);
//        co.pop_back();
//    }
//    if (pos2 < 2) {
//        co.push_back(b[pos2]);
//        ans += solve(pos1, pos2 + 1, co);
//        co.pop_back();
//    }
//    return ans;
//}
//
//void solve() {
//    cin >> n >> m;
//    for (int i = 0; i < n; ++i) cin >> v[i];
//    for (int i = 0; i < m; ++i) cin >> b[i];
//    vector<int> co;
//    cout << solve(0, 0, co);
//}
//
//int32_t main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);
//
//    int t = 1;
////    cin >> t;
//
//    while (t--)
//        solve();
//    return 0;
//}
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    map<int, int> mp;
    int n = s.size();
    for (auto &x: s)mp[x]++;
    int ans = 0;
    for (auto x: mp)ans += x.second * (x.second - 1) / 2;
    cout << (n * (n - 1) / 2 - ans) + 1 << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 720
using System;
using System.Linq;
using System.Collections.Generic;

public class Program{
    public static void Main(){
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long a = input[0], b = input[1], x = input[2];
        //b以下の整数でxで割り切れるもの
        var p = b/x;
        //a未満の整数でxで割り切れるもの
        var q = (a-1)/x;
        if(a==0) q = -1;
        Console.WriteLine(p-q);
    }
}


Measured memory_bytes: 13268
N, M = map(int, input().split())

k = [list(map(int, input().split()))[1::] for i in range(M)]
p = list(map(int, input().split()))
switches = [format(i, "b").zfill(N) for i in range(2**N)]

ans = 0
for sw in switches:
    allt = True
    for i in range(M):
        sum = 0
        for s in k[i]:
            if(sw[s-1]=="1"):
                sum += 1
        if(sum%2!=p[i]):
            allt = False
            break
    if(allt):
        ans+=1

print(ans)

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

struct Edge {
    Edge(int64_t t, int64_t A, int64_t B) : to(t), cost_coin(A), cost_time(B) {}
    int64_t to, cost_coin, cost_time;
};

int main() {
    int64_t N, M, S;
    cin >> N >> M >> S;
    vector<int64_t> U(M), V(M), A(M), B(M);
    vector<vector<Edge>> edges(N);
    for (int64_t i = 0; i < M; i++) {
        cin >> U[i] >> V[i] >> A[i] >> B[i];
        U[i]--; V[i]--;
        edges[U[i]].emplace_back(V[i], A[i], B[i]);
        edges[V[i]].emplace_back(U[i], A[i], B[i]);
    }

    vector<int64_t> C(N), D(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> C[i] >> D[i];
    }

    const int64_t MAX_COIN = N * 50;

    constexpr int64_t INF = LLONG_MAX;
    vector<vector<int64_t>> cost(N, vector<int64_t>(MAX_COIN + 1, INF));
    struct Element {
        int64_t node, coin, cost_time;
        bool operator<(const Element& rhs) const {
            return cost_time < rhs.cost_time;
        }
        bool operator>(const Element& rhs) const {
            return cost_time > rhs.cost_time;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    S = min(S, MAX_COIN);
    cost[0][S] = 0;
    pq.push({ 0, S, 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost_time > cost[t.node][t.coin]) {
            continue;
        }

        //移動可能なら移動
        for (const Edge& e : edges[t.node]) {
            if (e.cost_coin > t.coin) {
                continue;
            }
            int64_t new_cost_time = t.cost_time + e.cost_time;
            int64_t new_coin = t.coin - e.cost_coin;
            if (new_cost_time < cost[e.to][new_coin]) {
                cost[e.to][new_coin] = new_cost_time;
                pq.push({ e.to, new_coin, new_cost_time });
            }
        }

        //ここで一回交換
        if (t.coin < MAX_COIN) {
            int64_t new_cost_time = t.cost_time + D[t.node];
            int64_t new_coin = min(MAX_COIN, t.coin + C[t.node]);
            if (new_cost_time < cost[t.node][new_coin]) {
                cost[t.node][new_coin] = new_cost_time;
                pq.push({ t.node, new_coin, new_cost_time });
            }
        }
    }

    for (int64_t i = 1; i < N; i++) {
        cout << *min_element(cost[i].begin(), cost[i].end()) << endl;
    }
}

Measured memory_bytes: 7356
#include <bits/stdc++.h>
#define int long long
#define MAXN 100005
#define MOD 1000000007
#define sz(a) static_cast<long long>(a.size())
#define INF 2000000000000000000
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pp;
int n,l,q,x,y,a[MAXN],nex[MAXN],sp[MAXN][21],luy2[MAXN];
void sparse_construct(){
	int i,j,k;
	for (i=1;i<=n;i++) sp[i][0]=nex[i];
	for (j=1;j<=20;j++){
		for(i=1;i<=n;i++){
			k=sp[i][j-1]; if (k==0) sp[i][j]=0;
			else sp[i][j]=sp[k][j-1];
		}
	}
}
int tinh(int x,int y){
	int i,j,val=0;
	for (i=19;i>=0;i--){
		if (sp[x][i]!=0&&sp[x][i]<y){
			//cout<<x<<' '<<i<<' '<<sp[x][i]<<'\n';
			val+=luy2[i]; x=sp[x][i];
		}
	}
	return val+1;
}
main(){
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	//freopen(".INP","r",stdin); freopen(".OUT","w",stdout);
	cin>>n; int i,j,k;
	luy2[0]=1; for (i=1;i<21;i++) luy2[i]=luy2[i-1]*2;
	for (i=1;i<=n;i++) cin>>a[i];
	cin>>l;
	j=1;
	for (i=1;i<=n;i++){
		while (j<=n&&a[j]-a[i]<=l) j++;
		nex[i]=j-1;
	}
	nex[n]=0; 
	sparse_construct();
	cin>>q;
	while (q--){
		cin>>x>>y; if (x>y) swap(x,y);
		cout<<tinh(x,y)<<'\n'; 
	}
}

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

int main(){
    ll a;
    string s;
    cin>>a>>s;
    if(a>=3200)cout<<s;
    else cout<<"red";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;


// struct UnionFind{

//   vector<ll> parent;
//   vector<ll> rank;
//   vector<ll> size;

//   UnionFind(ll n) : parent(n),rank(n),size(n) {
//     rep(i,0,n){
//       parent[i]=i;
//       rank[i]=0;
//       size[i]=0;
//     }
//   }

//   ll root(ll x){
//     if(parent[x]==x)return x;
//     return parent[x]=root(parent[x]);
//   }

//   void unite(ll x,ll y){
//     ll rx=root(x),ry=root(y);
//     if(rx==ry)return ;

//     // if(rank[rx]<rank[ry])parent[rx]=ry;
//     // else {
//     //   parent[ry]=rx;

//     // }
//     if(rank[rx]==rank[ry])rank[rx]++;
//     if(size[rx]<size[ry])swap(rx,ry);
//     size[rx]+=size[ry];
//     parent[ry]=rx;
//   }

//   bool same(ll x,ll y){
//     ll rx=root(x),ry=root(y);
//     return rx==ry;
//   }
// };
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){

  ll n,m,k;cin>>n>>m>>k;
  ll a[m],b[m];rep(i,0,m)cin>>a[i]>>b[i];
  ll c[k],d[k];rep(i,0,k)cin>>c[i]>>d[i];

  UnionFind tree(n);
  vector<ll>s(n,0);
  rep(i,0,m){
    a[i]--,b[i]--;
    tree.merge(a[i],b[i]);
    s[a[i]]++;
    s[b[i]]++;
  }
  vector<vector<ll>>e(n);
  rep(i,0,k){
    c[i]--,d[i]--;
    e[c[i]].push_back(d[i]);
    e[d[i]].push_back(c[i]);
  }

  rep(i,0,n){
    ll ans=tree.size(i)-1-s[i];
    for(auto u:e[i]){
      if(tree.issame(i,u))ans--;
    }
    cout<<ans<<" ";
  }

  return 0;
}


Measured memory_bytes: 12160
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n)
	{
		int ans = 0;
		for(int i = 0; i < 10; ++i)
		{
			for(int j = 0; j < 10; ++j)
			{
				for(int k = 0; k < 10; ++k)
				{
					for(int l = 0; l < 10; ++l)
					{
						if(i + j + k + l == n)
						{
							++ans;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 1160
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int s;
	int t;
	int x;
} data;

int i, j, k;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	char s[128];
	getstr(s);
	int cnt = 0;
	for (i = 0;; i++) {
		if (s[i] == 'o') {
		}
		else if (s[i] == 'x') {
			cnt++;
		}
		else {
			break;
		}
	}

	if (cnt < 8) {
		out("YES\n");
	}
	else {
		out("NO\n");
	}

	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 128
from collections import Counter
def factorize(n):
	from math import sqrt
	r = int(sqrt(n))
	a = []
	while not n % 2:
		a.append(2)
		n //= 2
	for m in range(3,r+1,2):
		while not n % m:
			a.append(m)
			n //= m
	if n != 1:
		a.append(n)
	return Counter(a)
mod = 10**9 + 7
N = int(input())
c = Counter()
for i in range(2,N+1):
	c += factorize(i)

ans = 1
for i in list(c.values()):
	ans = ans*(i+1)%mod
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    
    int n;
    cin >> n;
    int num = 1;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(a == num){
            num++;
        }
    }
    if(num == 1){
        cout << -1 << endl;
    }
    else{
        cout << n - num + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256