akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll l, r, d;
	cin >> l >> r >> d;

	ll a = (l-1) / d, b = r / d;
	cout << b - a << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int INF=int(1e9);
int S[1111111];
int MX[1111111];

int solve(string &s, int mn)
{
	if(mn>0) return INF;
	int sum=0; int mx=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='0') 
		{
			sum--; 
		}
		else if(s[i]=='1')
		{
			sum++;
			mx=max(mx,sum);
		}
		else
		{
			if(sum-1+(S[i+2]-MX[i+2])>=mn)
			{
				sum--;
			}
			else
			{
				sum++;
				mx=max(mx,sum);
			}
		}
		if(sum<mn) return INF;
	}
	return mx;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s; int n=s.length();
	int sum=0; int minsum=0;
	for(int i=0;i<n;i++)
	{
		sum+=(s[i]=='0'?-1:1);
		minsum=min(minsum,sum);
	}
	for(int i=n;i>=1;i--)
	{
		S[i]=S[i+1]+(s[i-1]=='0'?-1:1);
		MX[i]=max(MX[i+1],S[i]);
	}
	int ans=min(solve(s,minsum)-minsum,solve(s,minsum-1)-(minsum-1));
	cout<<ans<<'\n';
}


Measured memory_bytes: 12156
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;

int main(){
  int N,L[1000],ans=0;
  cin>>N;
  for(int i=0;i<2*N;i++){
    cin>>L[i];
  }
  sort(L,L+2*N);
  for(int i=0;i<2*N;i+=2){
    ans+=L[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
// using ll = long long;
#define int long long

int expo(int a, int b, int m) {
	a %= m;
	int ret = 1;
	while(b) {
		if(b & 1) ret = (ret * a) % m;
		a = (a * a) % m;
		b /= 2;
	}
	return ret;
}

int f(int x) {
	int ret = 0;
	while(x) {
		x = x % (__builtin_popcountll(x));
		++ret;
	}
	return ret;
}

signed main() {
    IO;
    int n;
    cin >> n;
    string s; cin >> s;
    int o = 0;
    for(int i = 0; i < n; ++i) {
    	if(s[i] == '1') ++o;
    }
    int lo = o - 1, hi = o + 1;
    int hhi = 0, hlo = 0;
    int two = 1;

    // hi
    for(int i = n - 1; i >= 0; --i) {
    	if(s[i] == '1') {
    		hhi = (hhi + two) % hi;
    	}
    	two = (2 * two) % hi;
    }

    // hi
    if(o != 1) {
	    two = 1;
	    for(int i = n - 1; i >= 0; --i) {
	    	if(s[i] == '1') {
	    		hlo = (hlo + two) % lo;
	    	}
	    	two = (2 * two) % lo;
	    }
	}

    for(int i = 0; i < n; ++i) {
    	if(s[i] == '0') {
    		int r1 = (hhi + expo(2, n - 1 - i, hi)) % hi;
    		// DB(r1);
    		// DB(expo(2, n - 1 - i, hi));
    		// DB(hhi);
    		// DB(hi);
    		cout << f(r1) + 1 << "\n";
    	}
    	else {
    		if(o == 1) {
    			cout << "0\n";
    			continue;
    		}
			int r1 = (hlo - expo(2, n - 1 - i, lo) + 10ll * lo) % lo;
    		cout << f(r1) + 1 << "\n";
    	}
    }
    return 0;
}

Measured memory_bytes: 3768
import os
import sys
import numpy as np

def solve(N, AB):
    mod = 10**9+7
    half = mod // 2 + 1
    G = [[0]*0 for _ in range(N+1)]
    for i in range(len(AB)):
        a, b = AB[i]
        G[a].append(b)
        G[b].append(a)
    P = np.zeros(N+1, dtype=np.int64)
    Size = np.zeros(N+1, dtype=np.int64)
    def dfs(v):
        # siz = 1
        # p = P[v]
        # for u in G[v]:
        #     if u != p:
        #         P[u] = v
        #         dfs(u)
        #         siz += Size[u]
        # Size[v] = siz
        st = [(v, 0)]
        while st:
            v, state = st.pop()
            p = P[v]
            if state == 0:
                st.append((v, 1))
                Size[v] = 1
                for u in G[v]:
                    if u != p:
                        P[u] = v
                        st.append((u, 0))
            else:
                Size[p] += Size[v]
    dfs(1)
    ans = 0
    Prob = np.empty(202020, dtype=np.int64)
    h = 1
    for i in range(202020):
        Prob[i] = 1-h+mod
        h = h * half % mod
    for v in range(1, len(G)):
        siz_v = Size[v]
        Gv = G[v]
        if v == 1:
            ps = [0]*0
        else:
            ps = [Prob[N-siz_v]]
        par = P[v]
        for u in Gv:
            if par != u:
                siz_u = Size[u]
                ps.append(Prob[siz_u])
        if len(ps)<=1:
            continue
        cumprod1_ps = [1, 1]
        cumprod2_ps = [1, 1]
        cp = 1
        for p in ps:
            cp = cp * (1-p+mod) % mod
            cumprod1_ps.append(cp)
        cp = 1
        for p in ps[::-1]:
            cp = cp * (1-p+mod) % mod
            cumprod2_ps.append(cp)
        cumprod2_ps.reverse()
        an = 1 - cumprod1_ps[-1]
        for j in range(1, len(cumprod1_ps)-1):
            cp1 = cumprod1_ps[j]
            cp2 = cumprod2_ps[j]
            p = ps[j-1]
            an -= cp1 * cp2 % mod * p % mod
        ans += an
    ans = ans % mod * half % mod
    return ans


# >>> numba compile >>>
numba_config = [
    [solve, "i8(i8,i8[:,:])"],
]
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba import njit
    from numba.pycc import CC
    cc = CC("my_module")
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature)(func)
        cc.export(func.__name__, signature)(func)
    cc.compile()
    exit()
elif os.name == "posix":
    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
else:
    from numba import njit
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature, cache=True)(func)
    print("compiled!", file=sys.stderr)
# <<< numba compile <<<


def main():
    sys.setrecursionlimit(505050)
    input = sys.stdin.buffer.readline
    N = int(input())
    AB = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(N - 1, 2)
    ans = solve(N, AB)
    print(ans)

main()


Measured memory_bytes: 79712
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n,i;
      cin>>n;
      int a[n+1];
      int l[n+2],r[n+2];
      for(i=1;i<=n;i++) cin>>a[i];
      l[0]=0;
      r[n+1]=0;
      for(i=1;i<=n;i++)  l[i]=__gcd(l[i-1],a[i]);
      for(i=n;i>=1;i--)  r[i]=__gcd(r[i+1],a[i]);
      int mx=0;
      for(i=1;i<=n;i++)
      {
        mx=max(mx,__gcd(l[i-1],r[i+1]));
      }
      cout<<mx;
      return 0;
    }

Measured memory_bytes: 1408
import math

h = int(input())
a = list(map(int,input().split()))

def parent(node):
    return math.floor(node/2)

def left(node):
    return 2*node

def right(node):
    return 2*node+1

for i in range(1,h+1):
    print('node {}: key = {}, '.format(i,a[i-1]),end='')
    if parent(i) > 0:
        print('parent key = {}, '.format(a[parent(i)-1]),end='')
    if left(i) <= h:
        print('left key = {}, '.format(a[left(i)-1]),end='')
    if right(i) <= h:
        print('right key = {}, '.format(a[right(i)-1]),end='')
    print()



Measured memory_bytes: 5752
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int* a = new int[n];
	rep(i, n) cin >> a[i];

	int x = 0;
	rep(i, n / 2) {
		x ^= (a[i*2] ^ a[i*2 + 1]);
	}

	rep(i, n) {
		cout << (x ^ a[i]) << " ";
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 4436
n, m = map(int, input().split())

arr = [list(map(int, input().split())) for i in range(n)]

arr.sort(key = lambda x: x[0])

honsuu = 0
price = 0
for i in arr:
	temp = min(i[1], m-honsuu)
	honsuu += temp
	price += i[0] * temp

print(price)


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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for (int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
void fnSeqMaxNum(const vector<int>& cnrvnSeq)
{
  vector<int> vnSrtSeq(cnrvnSeq);
  sort(begin(vnSrtSeq), end(vnSrtSeq));

  for (int i = 0; i < cnrvnSeq.size(); i++)
  {
    int nMax = vnSrtSeq[vnSrtSeq.size() - 1];
    if (cnrvnSeq[i] == vnSrtSeq[vnSrtSeq.size() - 1])
      nMax = vnSrtSeq[vnSrtSeq.size() - 2];

    cout << nMax << endl;
  }
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  fnSeqMaxNum(vnSeq);

  return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        REP(i, a) cout << a;
        cout << endl;
    } else if (a < b) {
        REP(i, b) cout << a;
        cout << endl;
    } else if (a > b) {
        REP(i, a) cout << b;
        cout << endl;
    }
}

signed main() {
    solve();
}


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

int main() {
    string S;
    cin >> S;
    bool a = S[0] == 'R';
    bool b = S[1] == 'R';
    bool c = S[2] == 'R';
    int i = 0;

    if (a && b && c)
    {
        i = 3;
    }
    else if ((a && b) || (b && c))
    {
        i = 2;
    }
    else if (a || b || c)
    {
        i = 1;
    }
    else
    {
        i = 0;
    }

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 3628
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    ll n;
    cin >> n;
    ll a[100001];
    ll dp[100001];
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout << dp[n-1] << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a[5] = {0}, k;
    REP(i, 5)
    cin >> a[i];
    cin >> k;
    bool is_exist = true;
    REP(i, 5)
    {
        FOR(j, i + 1, 5)
        {
            if (abs(a[i] - a[j]) > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}


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

int main(int argc, char *argv[]) {
	int N = 0;
	int X = 0;
	std::cin >> N >> X;
	std::vector<int> materials;

	int cur;
	int min_material = 0;
	int at_least_material = 0;
	for (int i = 0; i < N; i++) {
		std::cin >> cur; 
		materials.push_back(cur);
		at_least_material += cur;
	}

	int sub_material = X - at_least_material;
	min_material = *std::min_element(materials.begin(), materials.end());

	std::cout << N + (sub_material / min_material) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using i64 = long long int;
using P = pair<i64, i64>;

i64 gcd(i64 a, i64 b){
    //
    // Euclidean Algorithm (かっこいい) O(logN)
    // i64 a, b: GCDを求める数 a > b を仮定している
    //
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

i64 lcm(i64 a, i64 b){
    //
    // a * b / gcd(a, b) O(logN)
    //
    return a * b / gcd(a, b);
}

i64 extended_gcd(i64 a, i64 b, i64 &x, i64 &y){
    //
    // https://qiita.com/drken/items/b97ff231e43bce50199a を見た まだ理解していないんですけど...
    // 拡張ユークリッドの互除法 ax + by = gcd(a, b) を満たす(x, y)を求める O(logN)
    //
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    i64 d = extended_gcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

i64 modpow(i64 x, i64 n){
    //
    // 繰り返し二乗法 O(logN)
    // i64 x, n: x^n mod 1e9+7 を求める modの値の変え忘れに注意(modを渡すべき?)
    //
    const i64 mod = 1000000007;
    i64 res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

map<i64, i64> prime_factorize(i64 n){
    // 
    // ひたすら割るやつ O(n^(1/2))
    // i64 n : 素因数を求める数
    // map<i64, i64> は range-based for を使うと楽(C++11~?)
    //
    map<i64, i64> mp;
    for(i64 i = 2;  i * i <= n; ++i){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

i64 phi(i64 n){
    // 
    // オイラーのトーシェント関数 O(n^(1/2))
    // 素因数ごとに減らしていく感じ
    // prime_factorize が必要
    //
    map<i64, i64> factors = prime_factorize(n);
    i64 res = n;
    for(auto f: factors){
        res -= res / f.first;
    }
    return res;
}

void NTL_1_A(){
    i64 n;
    cin >> n;
    auto factors = prime_factorize(n);
    cout << n << ':';
    for(auto f : factors){
        for(int i = 0; i < f.second; ++ i){
            cout << ' ' << f.first;
        }
    }
    cout << endl;
}

void NTL_1_B(){
    i64 m, n;
    cin >> m >> n;
    cout << modpow(m, n) << endl;
}

void NTL_1_C(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    i64 ans = 1;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ans = lcm(ans, a[i]);
    }
    cout << ans << endl;
}

void NTL_1_D(){
    i64 n;
    cin >> n;
    cout << phi(n) << endl;
}

void NTL_1_E(){
    i64 a, b;
    cin >> a >> b;
    i64 x, y;
    extended_gcd(a, b, x, y);
    cout << x << " " << y << endl;
}

int main(){
    /* NTL_1_A(); /* https://onlinejudge.u-aizu.ac.jp/status/users/kobaryo222/submissions/1/NTL_1_A/judge/3892592/C++14 */
    /* NTL_1_B(); /* https://onlinejudge.u-aizu.ac.jp/status/users/kobaryo222/submissions/1/NTL_1_B/judge/3892552/C++14 */
    /* NTL_1_C(); /* https://onlinejudge.u-aizu.ac.jp/status/users/kobaryo222/submissions/1/NTL_1_C/judge/3892620/C++14 */
    /* NTL_1_D(); /* https://onlinejudge.u-aizu.ac.jp/status/users/kobaryo222/submissions/1/NTL_1_D/judge/3892636/C++14 */
    NTL_1_E();
}


Measured memory_bytes: 3088
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n,m; 
ll a[maxn];
int cnt[maxn];

int main(){
	double r;
	cin>>r;
	r = acos(-1)*2.0*r;
	printf("%.10lf\n",r);
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n, d;
    set<int> st;
    cin >> n >> d;
    for(int i = 0; i < d; i++){
        int numb;
        cin >> numb;
        for(int j = 0; j < numb; j++){
            int a;
            cin >> a;
            st.insert(a);
        }
    }
    cout << n - st.size();
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int main(int argc, char *argv[])
{
    int a, b;
    vector<tuple<int, int>> tv;

    while (1)
    {
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        tv.push_back(tuple<int, int>(a, b));
    }

    for (tuple<int, int> t : tv)
    {
        for (int i = 0; i < get<0>(t); i++)
        {
            for (int j = 0; j < get<1>(t); j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,ans=0;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&x);
    if(k-x > x) ans+=x*2;
    else ans+=(k-x)*2;
  }
  printf("%d\n",ans);
  return 0;
}


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

void fastio()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
}

# define MOD 1000000007

int f(int n)
{
	if (n%2==0)
		return (n/2);
		
	return (3*n + 1);
}

int main()
{
	fastio();
	int s;
	cin >> s;
	vector <int> seq;
	seq.push_back(s);
	int term=s,flag=0,ans=0;
	while(1)
	{
		
		//cout<<"term: "<<term<<endl;
		term = f(s);
		ans++;		
		seq.push_back(term);
		s = term;
		for(int x=0;x<seq.size()-1;x++)
		{
		//	c++;
			if (seq[x] == term)
			{
				flag=1;
				break;
			}
		}
		if (flag)
		{
//			ans = c;
			break;
		}
	}
	cout<<(ans+1)<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

const long long mod = 1000000007;

long long fpow(long long a, long long p)
{
	long long r = 1;
  while (p){
if (p & 1) r = r * a % mod;
    a = a * a % mod;
    p /= 2;
  }
  return r;
}

int n,k;
long long phi[100100];

int main()
{
  scanf ("%d %d",&n,&k);
 for (int i=1;i<100100;i++){
    phi[i] = fpow(i,n);
   int s = 2;
   while (s <= i){
	int e = i / (i / s) + 1;
     phi[i] = (phi[i] + mod - (e - s) * phi[i/s] % mod)%  mod;
     s = e;
   }
 }
  long long ans = 0;
  for (int i=1;i<=k;i++) ans = (ans + i * phi[k/i]) % mod;
  printf ("%lld\n",ans);
return 0;
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    char s[100001];
    cin >> n >> s;
    int q=strlen(s);
    for(int i=0;i<n;i++){
        for(int j=0;j<q;j++){
            if(s[j]=='Z'){
                s[j]='A';
            }
            else{
                s[j]++;
            }
        }
    }
    cout << s << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,ans;
  vi d;
  cin >> N;
  REP(i,N){
		int x;
		cin >> x;
		d.push_back(x);
	}
  sort(d.begin(), d.end());
  ans = d[N/2]-d[N/2-1];
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int n,cnt=0;
    int a,b,ba;
    a=0;b=0;ba=0;
    string str;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		cin>>str;
		int L=str.size();
		for(int j=0;j+1<L;j++)
		{
			if(str[j]=='A'&&str[j+1]=='B')
			{
				cnt++;
			}
		}
		if(str[0]=='B') b++;
		if(str[L-1]=='A') a++;
		if(str[0]=='B'&&str[L-1]=='A') ba++;
	}
	cnt+=min(a,b);
	if(a==ba&&b==ba&&b>0) cnt--;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

const int INF = 1001001001;
int main() {

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

	int c[15];
	int a[15][15];

	rep(i, n) {
		cin >> c[i];
		rep(j, m) {
			cin >> a[i][j];
		}
	}
	int ans = 1001001001;
	rep(s, 1 << n) {//1 << n :2^n
		int cost = 0;
		vector<int> d(m);
		rep(i, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, m) {
					d[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		rep(j, m) {
			if (d[j] < x) ok = false;
		}
		if (ok) ans = min(ans, cost);
	}
	if (ans == 1001001001) cout << -1 << endl;
	else cout << ans << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int count = 0;
  int con = M - N + 1;
  for ( int i = 0 ; i < con ;i++){
    string s = to_string(N + i);
    if(s.at(0) == s.at(4) && s.at(1) == s.at(3))count++;
  }
  cout  << count;
}

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

const int INF = 999999999;

int r, c;
char t[55][55];
int dist[55][55];

int main() {
  int black = 0;
  cin >> r >> c;
  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      dist[i][j] = INF;
      cin >> t[i][j];
      if (t[i][j] == '#')
        ++black;
    }
  }
  queue<int> qr, qc;
  qr.push(0);
  qc.push(0);
  dist[0][0] = 1;
  while (!qr.empty()) {
    int cr = qr.front();
    qr.pop();
    int cc = qc.front();
    qc.pop();
    for (int dr = -1; dr <= 1; ++dr) {
      for (int dc = -1; dc <= 1; ++dc) {
        if ((dr == 0) != (dc == 0)) {
          int nr = cr + dr;
          int nc = cc + dc;
          if (nr < 0 || nr >= r || nc < 0 || nc >= c || t[nr][nc] == '#')
            continue;
          if (dist[nr][nc] == INF) {
            dist[nr][nc] = dist[cr][cc] + 1;
            qr.push(nr);
            qc.push(nc);
          }
        }
      }
    }
  }
  if (dist[r - 1][c - 1] != INF) {
    cout << (r * c - dist[r - 1][c - 1] - black) << '\n';
  } else {
    cout << "-1\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int r, k;
    int x;
    scanf("%d%d%d", &r, &k, &x);
    for (int i = 0; i < 10; i++)
    {
        x = x * r - k;
        printf("%d\n", x);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{
 int a, b, k; cin >> a >> b >> k;
  int cnt = 0;
  vi v1(0,0);
  int whi = max(a,b);
  for(int i =1; i <= whi; ++i){
    if(a%i == 0&&b%i == 0){
     v1.PB(i);
      ++cnt;
    }
  }
/*for(int i = 1; i <= whi; ++i){
  cout << a%i;
  cout << b%i << endl;
}*/
  

  reverse(v1.begin(),v1.end());
//    REP(i, cnt){cout << v1[i] << endl;}
  
  cout << v1[k-1];
 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n;
	int i;
	int p;
	int d1;
	int d2;
	int max;
	int maxp;
	
	scanf("%d", &n);
	while(n != 0) {
		max = 0;
		maxp = 0;
		for(i = 0; i < n; i++) {
			scanf("%d %d %d", &p, &d1, &d2);
			if(d1 + d2 >= max) {
				max = d1 + d2;
				maxp = p;
			}
		}
		printf("%d %d\n", maxp, max);
		
		scanf("%d", &n);
	}
	return (0);
}

Measured memory_bytes: 412
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1000), 300500)
}

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

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

func cumSum(a string) []int {
	res := make([]int, len(a)+1)
	var sum = 0
	for i := 1; i <= len(res)-1; i++ {
		if a[i-1] == 'E' {
			sum++
		}
		res[i] = sum
	}
	return res
}

func main() {
	n := ri()
	s := rs()

	cumSumE := cumSum(s)

	minCost := n
	for i := 1; i <= n; i++ {
		cost, leftW, rightE := 0, 0, 0

		leftW = (i - 1) - cumSumE[i-1]
		rightE = cumSumE[n] - cumSumE[i]

		cost = leftW + rightE

		if cost < minCost {
			minCost = cost
		}
	}
	fmt.Println(minCost)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  char a, b;
  cin >> a >> b;
  if(a==b) co("H");
  else co("D");
}

Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
#define PP pair<pair<ll,ll>,pair<pair<ll,ll>,ll>>
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	// cases
	{
		ll n;
		cin >> n;
		ll val = 26, p = 26;
		while (val < n)
		{
			n -= val;
			// cout << val << END;
			val = p * 26;
			p *= 26;
		}
		ll dig = 0;
		ll d = p / 26;
		while (d > 0)
		{
			++dig;
			d /= 26;
		}
		// cout << dig << END;
		string ans = "";
		n--;
		p /= 26;
		while (dig > 0)
		{
			// cout << n << " " << p << " " << n / p << END;
			ans += ('a' + n / p);
			n %= p;
			p /= 26;
			--dig;
		}
		if (p != 0)
			ans += 'a';
		cout << ans << END;
		// cout << n << " " << dig << END;
	}


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3656
n = input()
n = int(n)
d = []
for i in range(n):
    d.append(input().split())
active = False
count = 0
for x in d:
    if x[0] == x[1]:
        active = True
        count += 1
    else:
        count = 0
        active = False
    if count >2:
        break
if count > 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	ll X;
	cin >> X;
	ll yokin = 100;
	int year = 0;
	while(yokin<X)
	{
		yokin += yokin/100;
		year++;
	}
	cout << year << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash>
    //gp_hash_table<long long, int, custom_hash>
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	
	int n, m; scanf("%d%d", &n, &m);
	int a[m];
	for(int i = 0; i<m; i++){
		cin>>a[i];
	 	n-=a[i];
	}
	if(n<0){
		n = -1;
	}
	cout<<n<<endl;
	
	return 0;
}

Measured memory_bytes: 3808
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AGarden {
public:
	void solve(istream& in, ostream& out) {
	    int a, b;
	    in >> a >> b;
	    out << a * b - (a + b) + 1 << endl;
	}

};

int main() {
	AGarden solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    string s;
    cin >> s;
    bool flag1 = false;
    bool flag2 = false;
    if(s[0] == '0' && s[1] != '0') flag1 = true;
    else if(s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2')) flag1 = true;
    if(s[2] == '0' && s[3] != '0') flag2 = true;
    else if(s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2')) flag2 = true;
    if(flag1) {
        if(flag2) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else if(flag2) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s[2];
    cin >> s[0] >> s[1];
    cout << (s[0][0] == s[1][2] && s[0][1] == s[1][1] && s[0][2] == s[1][0] ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    solve();
	}
    }

    static void solve(){
	int c1 = kbd.nextInt();
	int c2 = kbd.nextInt();
	int c3 = kbd.nextInt();
	boolean[] card = new boolean[11];
	Arrays.fill(card, true);
	card[0] = card[c1] = card[c2] = card[c3] = false;

	int i;
	int sum = 0;
	double p=0;
	for(i=1; i<card.length; i++){
	    if(card[i]){
		sum = c1+c2+i;
		if(sum <= 20) p++;
	    }
	}

	p = p/7*100;
	//System.out.println(p);
	if(p>=50)
	    System.out.println("YES");
	else
	    System.out.println("NO");
    }
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
}


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

#define   ld             long double
#define   ll             long long
#define   boost_         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   pb             push_back
#define   ppb            pop_back
#define   ull            unsigned long long
#define   over           return 0
#define   scan(i,n,a)    for(i=0;i<n;i++) cin>>a[i]

using namespace std;

                        //**************************GCD**************************//

int gcd(int x,int y){

    if(x==0) return y;
    else return gcd(y%x,x);

}


                        //**************************MAIN**************************//

int main(){

    char ch;

    cin>>ch;
    if(isupper(ch)) cout<<'A'<<endl;
    else cout<<'a'<<endl;
    over;


}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int mx  = 0;
    int sum = 0;
    REP(i, 2 * N) {
        if (N <= sum) {
            mx = i;
            break;
        }
        sum += i + 1;
    }
    vector<int> ans;
    RREP(i, mx) {
        if (N - i - 1 < 0)
            continue;
        N -= i + 1;
        ans.emplace_back(i + 1);
    }
    if (ans.empty())
        ans.emplace_back(N);
    vprint(ans);

    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = [0] + list(map(int, input().split()))

B = [0] * (N + 1)

for i in range(N, 0, -1):
    # mod2 の足し算は xor
    sum_a = 0
    for j in range(i + i, N + 1, i):
        sum_a ^= B[j]
    B[i] = sum_a ^ A[i]

# print(A, B)
out = []
for i in range(1, N + 1):
    if B[i] == 1:
        out.append(i)
if len(out) > 0:
    print(len(out))
    print(*out)
else:
    print(0)


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

vector<int> cntv(100005);
vector<int> cntu(100005);
int vm,um;
int vmc,umc;
int main() {
  int n,t;cin >> n;
  rep(i,n){
    cin >>t;
    if(i%2==0){
      cntv[t]++;
      if(cntv[t]>vmc){vmc=cntv[t],vm=t;}
    }
    else {
      cntu[t]++;
      if(cntu[t]>umc){umc=cntu[t],um=t;}
    }
  }
  sort(rALL(cntu));
  sort(rALL(cntv));
  if(um!=vm)cout << n-umc-vmc;
  else cout <<n- max(vmc+cntu[1],umc+cntv[1]);
}




Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
set<string> s;
int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	cin>>T;
	bool first=false;
	char temp;
	for(int i=0; i<T; i++) {
		string st;
		cin>>st;
		if(first){
		if(temp!=st[0]) {
			std::cout << "No" << '\n';
			return 0;
		}}
		if(s.count(st)) {
			cout<<"No"<<endl;
			return 0;
		}
		s.insert(st);
		  temp=st[(int)(st.length())-1];
		first=true;
	}
    cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define fori(i,n) for(long long i=1;i<=n;i++)
#define forj(j,n) for(long long j=1;j<=n;j++)
#define fors(i,ssz) for(long long i=0;i<s.size();i++)
#define Need_for_Speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
ll n,dp[100001],h[100001],maxi;
int main(){
	Need_for_Speed
	cin>>n;
	fori(i,n)
	cin>>h[i];
	dp[1]=0;
	dp[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 5208
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
N,P = inputlist()
A = inputlist()
for i in range(N):
    A[i] = A[i] % 2
from collections import Counter
c = Counter(A)
n0 = c[0]
n1 = c[1]
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans = 0
ans2 = 0
for i in range(1,n1+1):
    if i % 2 == 0:
        continue
    ans += comb(n1,i)
for i in range(n1+1):
    if i % 2 == 1:
        continue
    ans2 += comb(n1,i)
if P == 1:
    print((2**n0)*ans)
if P == 0:
    print((2**n0)*ans2)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define ok(x) (0 <= x && x < s.size() && s[x] == 'Y')

using namespace std;

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

const int N = 10010;
bool np[N];

void sieve(){
	np[1] = true;
	for (int i = 2; i*i < N; ++i){
		if (!np[i]){
			for (int j = i * 2; j < N; j += i){
				np[j] = true;
			}
		}
	}
}

int main(){
	sieve();
	int n;
	while (cin >> n){
		int cnt = 0;
		for (int i = 1; i <= n; ++i){
			if (!np[i] && !np[n - i + 1]) ++cnt;
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1168