akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define EPS (1e-10)
#define rep(i, a, b) for (ll i = a; i < (ll)(b); ++i)
#define rrep(i, a, b) for (ll i = b - 1; i >= (ll)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

ll mod(ll x) {
    x %= MOD;
    if (x < 0) { x += MOD; }
    return x;
}

// O(log(p))
ll mpow(ll x, ll p) {
    if (p == 0) { return 1; }
    if (p == 1) { return x % MOD; }
    if (p % 2 == 1) { return (x * mpow(x, p - 1)) % MOD; }
    ll sub = mpow(x, p / 2);
    return (sub * sub) % MOD;
}

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

    int n, k;
    cin >> n >> k;

    vll cnt(k + 1, 0);

    rrep(x, 1, k + 1) {
        // xの倍数の個数．
        ll num_div = k / x;

        // 最大公約数がxの倍数となる順列の個数．
        ll tmp = mpow(num_div, n);

        // 最大公約数が i * x (i >= 2) となる順列の個数を引く．
        for (ll ix = 2 * x; ix <= k; ix += x) { tmp = mod(tmp - cnt[ix]); }

        cnt[x] = tmp;
    }

    ll ans = 0;
    rep(i, 1, k + 1) { ans = mod(ans + mod(i * cnt[i])); }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3992
N,M=map(int,input().split())
l=[]
for i in range(M):P,Y=map(int,input().split());l.append([i,P,Y,0])
from operator import*
l.sort(key=itemgetter(2))
P=[0]*N
for i in range(M):P[l[i][1]-1]+=1;l[i][3]=P[l[i][1]-1]
l.sort(key=itemgetter(0))
for i in range(M):print(str(l[i][1]).zfill(6)+str(l[i][3]).zfill(6))


Measured memory_bytes: 98624
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main(void) {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;


		int s = 0;	s -= n;
		for (int i = 1; i <= sqrt(n); i++) {
			if (n%i == 0) {
				s += n / i;
				if (n != 1 && i != n / i) s += i;
			}
		}
		//cout << s << endl;

		if (n == s)
			cout << "perfect number" << endl;
		else if (n > s)
			cout << "deficient number" << endl;
		else
			cout << "abundant number" << endl;

	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	int ret = 0;
	rep(i, n) {
		int r, l;
		cin >> r >> l;

		ret += l - r + 1;
	}

	cout << ret << endl;

    return 0;
}


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

bool linear_search(int *array, int size, int num);
void print_array(int *array, int size);
int main(){
	int s_num;
	int t_num;

	cin >> s_num;

	int* array_s = (int*)malloc(s_num * sizeof(int));

	for(int i = 0; i < s_num; ++i){
		cin >> array_s[i];
	}

	cin >> t_num;

	int* array_t = (int*)malloc(t_num * sizeof(int));

	for(int i = 0; i < t_num; ++i){
		cin >> array_t[i];
	}
	int result_max_num = s_num;
	if(t_num < s_num) result_max_num = t_num;
	int result_size = 0;

	for(int i = 0; i < t_num; ++i){
		if(linear_search(array_s, s_num, array_t[i])){
			++result_size;
		}
	}

	cout << result_size << endl;
	return 0;
}

bool linear_search(int *array, int size, int num){
	for(int i = 0; i < size; ++i){
		if(array[i] == num){
			return true;
		}
	}
	return false;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();

        if(x >= r && y >= r && x + r <= W && y + r <= H)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

Measured memory_bytes: 26276
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(i64, N, M);
    vector<i64> a(M);
    read(a);
    const i64 sum = accumulate(all(a), 0LL);
    if (sum > N) {
        print(-1);
    } else {
        print(N - sum);
    }

    return 0;
}


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

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

    while(1) {
        string s = to_string(n);
        if (s[0]==s[1] && s[1]==s[2]) {
            cout << n << endl;
            return 0;
        }
        n++;
    }
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc087/tasks/arc090_a

"""
import sys
from sys import stdin
from itertools import accumulate
input = stdin.readline


def solve(candies, N):
    if N == 1:
        return candies[0][0] + candies[1][0]

    dp = []
    dp.append(list(accumulate(candies[0])))
    dp.append([0] * N)
    dp[1][0] = candies[0][0] + candies[1][0]

    for x in range(1, N):
        dp[1][x] = max(dp[0][x], dp[1][x-1]) + candies[1][x]
    return dp[-1][-1]


def main(args):
    N = int(input())
    candies = []
    for _ in range(2):
        candies.append([int(x) for x in input().split()])
    ans = solve(candies, N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;
int main(){
	ll n;
	cin>>n;
	ll f[n+1];
	rep(i,n+1)f[i]=1;
  	ll a[n+1]={};
	for(ll i=2;i<=n;i++){
		if(f[i]!=1)continue;
		ll t=i;
		
		while(t<=n){
			for(ll j=t;j<=n;j+=t){
				a[j]++;
			}
			t*=i;
		}
		for(int j=i;j<=n;j+=i){
			f[j]*=a[j]+1;
          	a[j]=0;
		}
	}
	ll ans=0;
	rep(i,n+1){
		ans+=f[i]*i;
	}
	puts(ans);
}


Measured memory_bytes: 159824
N = int(input())
A = list(map(int,input().split()))

ans_list=[]
a_max=0

for a_idx,a in enumerate(A):
    if a > a_max:
        a_max = a
        ans_list.append(0)
    else:
        ans_list.append(a_max-a)
        
print(sum(ans_list))

Measured memory_bytes: 101768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int A, B, T;
	cin >> A >> B >> T;
	int key = ((T + 0.5) / A);
	cout << key * B << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
  int N;
  long long int a = -1;
  long long int b = -1;
  cin >> N;
  std::vector<long long int> d(N);
  
  for(int i = 0; i < N; ++i)
    cin >> d[i];
  
  std::sort(d.begin(), d.end(), greater<long long int>());
  
  for(int i = 0; i < N-1; ++i){
    if(d[i] == d[i+1]){
      if(a < 0){
        a = d[i];
        i++;
      }else {
        b = d[i];
        break;
      }
    }
  }
  if(a > 0 && b > 0)
    cout << a * b << endl;
  else
    cout << 0 << endl;
}

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

int main() {
  int n, a;
  cin >> n;
  if (64 <= n) a = 64;
  else if (32 <= n) a = 32;
  else if (16 <= n) a = 16;
  else if (8 <= n) a = 8;
  else if (4 <= n) a = 4;
  else if (2 <= n) a = 2;
  else a = 1;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Map<String,Integer> sales=new HashMap<>();
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++) {
	    int a=sc.nextInt();
		if(a==0) {
		String k=sc.next();
		int x=sc.nextInt();
		sales.put(k,x);	
		}
		if(a==1) {
			String y=sc.next();
				System.out.println(sales.get(y));
			}
		}
	}
}



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

int main(void){
    int N;
    int i, j, k, l, m;
    int A;
    scanf("%d",&N);
    int p[N];
    for(i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
// irekae
    for(j=0;j<N-1;j++){
        if(p[j+1]-p[j] < 1){
            A = p[j];
            p[j] = j+1;
            break;
        }
    }
    for(l=0;l<N-1;l++){
         if(p[l+1]-p[l] < 1){
            p[l+1] = A;
        }
    }
//    for(m=0;m<N;m++){
//        printf("a%d\n",p[m]);
//    }
//hantei
    for(k=0;k<N-1;k++){
        if(p[k+1]-p[k] != 1){
            printf("NO\n");
            exit(0);
        }
    }
    printf("YES\n");
    return 0;
}


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

int		main(void)
{
	int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x, y;

	cin >> x >> y;
	if (a[x] == a[y])
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
}



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

int main(){
  ll x; cin >> x;
  ll ans;
  if(x % (6 + 5) == 0) ans = x / (6 + 5) * 2;
  else if(x % (6 + 5) < 7) ans = x / (6 + 5) * 2 + 1;
  else if(x % (6 + 5) < 12) ans = x / (6 + 5) * 2 + 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int s = sc.nextInt();
			if(n == 0 && s == 0)break;
			int ans = solve(n,s,0);
			System.out.println(ans);
		}
	}
	public static int solve(int n,int s,int c){
		if(n==1&&s>=c&&s<10) return 1;
		if(n == 1) return 0;
		int sum = 0;
		for(int i=c;i<10&&i<s;i++){
			sum += solve(n-1,s-i,i+1);
		}
		return sum;
		
	}
}



Measured memory_bytes: 25808
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = (int)1e5 + 10;
int a[maxN], b[maxN];
int n, m, k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m >> k;
    int mnA = INT_MAX;
    int mnB = INT_MAX;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        mnA = min(mnA, a[i]);
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        mnB = min(mnB, b[i]);
    }
    int best = mnA + mnB;
    for (int i = 1; i <= k; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        best = min(best, a[x] + b[y] - c);
    }
    cout << best;
    return 0;
}

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

int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long ans =0;
    long long ab = a+b;

    long long q = n/ab;
    long long r = n%ab;

    ans += q*a;
    if(r!=0){
        ans += min(r,a);
    }
    cout << ans << endl;
}


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

int main(){
   string s;
   
   cin >> s;
   
   for(int i=0; i<s.size(); i++){
      if(i%2==0){
         if(s[i]=='1') continue;
         if(s[i]=='2') cout << "k";
         if(s[i]=='3') cout << "s";
         if(s[i]=='4') cout << "t";
         if(s[i]=='5') cout << "n";
         if(s[i]=='6') cout << "h";
         if(s[i]=='7') cout << "m";
         if(s[i]=='8') cout << "y";
         if(s[i]=='9') cout << "r";
         if(s[i]=='0'&&s[i+1]=='U') cout << "n";
         else if(s[i]=='0') cout << "w";
      }else{
         if(s[i-1]=='0'){
            if(s[i]=='T') cout << "a";
            if(s[i]=='U') cout << "n";
            if(s[i]=='D') cout << "o";
         }else{
            if(s[i]=='T') cout << "a";
            if(s[i]=='L') cout << "i";
            if(s[i]=='U') cout << "u";
            if(s[i]=='R') cout << "e";
            if(s[i]=='D') cout << "o";
         }
      }
   }
   cout << endl;
   
   return 0;
}

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

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

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

signed main(){
    int N,x;
    cin>>N>>x;
    vector<int> a(N);
    rep(i,N) cin>>a[i];
    int ans=0;
    if(N>=3) rep(i,N-2){
    	int left=a[i]+a[i+1],right=a[i+1]+a[i+2];
    	left-=x;right-=x;
    	if(left>0){
    		ans+=left;
    		if(a[i+1]<left){
    			right-=a[i+1];
    			left-=a[i+1];
    			a[i+1]=0;
    			a[i]-=left;
    			left=0;
    		}
    		else{
    			a[i+1]-=left;
    			right-=left;
    		}
    	}
    	if(right>0){
    		ans+=right;
    		a[i+2]-=right;
    	}
    }
    else if(a[0]+a[1]>x) ans=a[0]+a[1]-x;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
   string S;cin >> S;
   bool frag = 1;
   rep(i,26){
       if(count(ALL(S),'a'+i) % 2 != 0) frag = 0;
   }
   if(frag) cout << "Yes" << endl;
   else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

map<int, int> factorize(int a) {
    map<int, int> ret;
    for(int i = 2; i * i <= a; i++) {
        int cnt = 0;
        while (a % i == 0) a /= i, cnt++;
        if (cnt != 0) ret[i] = 1;
    }
    if (a != 1) ret[a] = 1;
    return ret;
}
signed main() {
    int A, B;
    cin >> A >> B;
    auto a = factorize(A);
    auto b = factorize(B);
    
    int ans = 1;
    for (pii x : a) {
        if (contains(b, x.first)) {
            ans++;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>

struct task
{
public:
	int a;
	int b;
	int c;
	// task(int x, int y,int z)
	// {
	// 	a=x;
	// 	b=y;c=z;
	// }
};

ll solvewrong(task *day, int n)
{
	ll dp[n]={0};
	ll selected[n]={0};
	selected[0]=max(day[0].a, max(day[0].b,day[0].c));
	dp[0]=selected[0];
	for(int i=1;i<n;i++)
	{
		if(selected[i-1]==day[i-1].a)
			{dp[i]=dp[i-1]+max(day[i].b, day[i].c);
				selected[i]=max(day[i].b, day[i].c);
			}
		else if(selected[i-1]==day[i-1].b)
			{dp[i]=dp[i-1]+max(day[i].a, day[i].c);
				selected[i]=max(day[i].a, day[i].c);
			}
		else
			{dp[i]=dp[i-1]+max(day[i].a, day[i].b);
				selected[i]=max(day[i].b, day[i].a);
			}

	}
	return dp[n-1];

}
ll solve(task* arr, int n)
{
	task dp[n];
	dp[0].a=arr[0].a;
	dp[0].b=arr[0].b;
	dp[0].c=arr[0].c;

	for(int i=1;i<n;i++)
	{
		dp[i].a=arr[i].a+max(dp[i-1].b, dp[i-1].c);
		dp[i].b=arr[i].b +max(dp[i-1].a, dp[i-1].c);
		dp[i].c=arr[i].c + max(dp[i-1].a, dp[i-1].b);
	}


return max(dp[n-1].a, max(dp[n-1].b, dp[n-1].c));
}

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

    ll n,x,a,b,c;
    cin>>n;
    
    task *arr=new task[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a>>b>>c;
    	arr[i].a=a;
    	arr[i].b=b;
    	arr[i].c=c;
    }

    ll ans=solve(arr, n);
    cout<<ans;

return 0;
}


Measured memory_bytes: 2560
import sys
N, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
    print(N)
    sys.exit()
else:
    a.sort()
    ans = 0
    for i in range(N-1):
        if a[i] <= x:
            ans += 1
            x -= a[i]
        else:
            print(ans)
            break
    else:
        print(ans)

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

int main() {
    string s, t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));
    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
        }
    }
    string ans = "";
    for(int i=n, j=m; i>0 && j>0;) {
        if(s[i-1] == t[j-1]) {
            ans += s[i-1];
            i--, j--;
        }
        else if(dp[i][j-1] > dp[i-1][j]) j--;
        else i--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#define INF 100000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long
/* define/include */

int main(){
  int R,G;
  cin >> R >> G;
  int A;
  A = R+(G-R)*2;
  cout << A;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
money = []
for _ in range(N):
    x , u = input().split()
    money.append([float(x) , u])

for i in range(N):
    if money[i][1] == "JPY":
        ans += money[i][0]
    else:
        ans += money[i][0] * 380000.0
print(ans)

Measured memory_bytes: 3060
s = gets.strip.to_s
for i in 1..(s.size/2-1)
  t = s[0..(s.size-2*i-1)]
  a = s[0..(s.size/2-i-1)]
  b = s[(s.size/2-i)..(s.size-2*i-1)]
  if a==b
    puts t.size
    exit
  end
end

Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
    dcl(n);
    vector<vector<ll>> h(2,vector<ll>(n,0ll));
    getii(h);
    auto p=h;
    for(int i=n-1;i>0;i--){
        if(h[0][i]==h[0][i-1]){
            h[0][i]=0;
        }
    }
    for(int i=1;i<n;i++){
        if(h[1][i-1]==h[1][i]){
            h[1][i-1]=0;
        }
    }
    if(p[0].back()!=p[1].front()){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    rep(i,n){
        if(h[0][i]!=h[1][i] && h[0][i] && h[1][i]){
            cout<<0<<endl;
            return 0;
        }else if(h[0][i]==0 && h[1][i] && p[0][i]<p[1][i]){
            cout<<0<<endl;
            return 0;
        }else if(h[1][i]==0 && h[0][i] && p[1][i]<p[0][i]){
            cout<<0<<endl;
            return 0;
        }
        ll odd=1;
        if(h[0][i]==0 && h[1][i]==0){
            odd=min(p[0][i],p[1][i]);
        }
        ans=ans*odd%MOD;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A), greater<lint>());
  vector<lint> S(N+1);
  REP(i, N) S[i+1] = S[i] + A[i];
  int l = -1;
  int r = N;
  while(r-l > 1) {
    lint m = (l+r) / 2;
    if(A[P-1] > A[m]+M) {
      r = m;
      continue;
    }
    lint area = 0;
    REP(i, N) {
      if(i < P-1 || i >= m) {
        area += M;
      } else {
        area += A[m]+M-A[i];
      } 
    }
    if(area >= M*V) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << l+1 << endl;
}

Measured memory_bytes: 1792
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let n: usize = io.read();
    let t: usize = io.read();
    let mut a = io.readn::<i64>(n);
    // 最小値を取るやつの個数になる？🐈
    // なぞってみる
    let mut mini = INF;
    let mut maxsa = -INF;
    for (i, &x) in a.iter().enumerate() {
        maxsa = max(maxsa, x - mini);
        mini = min(mini, x);
    }
    io.debug(maxsa);

    let mut mp = HashMap::new();
    let mut ans = 0i64;
    for (i, &x) in a.iter().enumerate() {
        ans += mp.get(&(x - maxsa)).map_or(0, |x| *x);
        let e = mp.entry(x).or_insert(0);
        *e += 1;
    }
    io.writeln(ans);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 12540
x,n=map(int,input().split())

sett=list(map(int,input().split()))
arr=[i for i in range(-5,151) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)


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

typedef long long ll;

int main() {
    int N, R = 0, ans = 0;
    string c;
    cin >> N >> c;
    rep(i, N) if (c[i] == 'R') R++;
    rep(i, R) if (c[i] == 'W') ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 3764
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 一 12/11 20:46:20 2017
 * Ended  Time*  : 一 12/11 21:04:29 2017
*********************************************/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;

int n;
int a[55];

int main(){
	scanf("%d", &n);
	int p = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(abs(a[i]) >= abs(a[p])) p = i;
	}
	printf("%d\n", 2 * n - 1);
	for(int i = 1; i <= n; i++) printf("%d %d\n", p, i);
	if(a[p] > 0) for(int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
	else for(int i = n; i > 1; i--) printf("%d %d\n", i, i - 1);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  string S;
  cin>>S;
  int dp[S.size()+1][2];
  dp[0][0]=0;
  dp[0][1]=1;
  rep(i,S.size()){
    dp[i+1][0]=min(dp[i][0]+(S[i]-'0'),dp[i][1]+10-(S[i]-'0'));
    dp[i+1][1]=min(dp[i][0]+(S[i]-'0')+1,dp[i][1]+9-(S[i]-'0'));
  }
  cout<<dp[S.size()][0]<<endl;
}



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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int k = sc.nextInt();

		if (k % 2 == 0) {
			pr.println(k / 2 * (k / 2));
		} else {
			pr.println(k / 2 * ((k + 1) / 2));
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main()
{
	int number[]{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int K;
	cin >> K;

	cout << number[K - 1];

}

Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e5+69, INF=2e9+6969;

int qq;

int main()
{
	scanf("%d", &qq);
	while(qq--)
	{
		ll n,t[R];
		string s;
		scanf("%lld", &n);
		for(int i=0;i<n;++i) scanf("%lld", &t[i]);
		cin >> s;
		vector <ll> base;
		base.clear();
		bool ok=1;
		for(int i=n-1;i>=0;--i)
		{
			ll x = t[i];
			for(ll e: base) x = min(x,e^x);
			if(x==0) continue;
			if(s[i]=='0') base.pb(x);
			else
			{
				ok=0;
				break;
			}
		}
		puts(ok ? "0" : "1");
	}
	return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>

void cmp(int a, int b) {
	if (a > b) printf("a > b\n");
	if (a < b) printf("a < b\n");
	if (a == b)printf("a == b\n");
	return;
}

int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	cmp(a, b);
	return 0;
}


Measured memory_bytes: 2048
if __name__ == '__main__':
    N,M = map(int, input().split())
    xyz = [tuple(map(int, input().split())) for _ in range(N)]

    constraint = []
    for x,y,z in xyz:
        ci = []
        for b in range(8):
            v = 0
            if (b>>0)&1==1: v += x 
            else: v -= x
            if (b>>1)&1==1: v += y
            else: v -= y
            if (b>>2)&1==1: v += z 
            else: v -= z
            ci.append(v)
        #print(ci)
        constraint.append(ci)

    ans = 0
    for c in zip(*constraint):
        cond = sorted(c, reverse=True)[:M]
        ans = max(ans, sum(cond))
    print(ans)

Measured memory_bytes: 3732
/*
      author  : nishi5451
      created : 14.08.2020 18:17:59
*/

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


int main(){
    vector<int> a(3);
    int k;
    cin >> a[0] >> a[1] >> a[2];
    cin >> k;
    int sum = 0;
    sort(a.begin(),a.end());
    while(k--){
        a.back()*=2;
    }
    rep(i,3) sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3532
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  long n;
  cin >> n;
  long i;
  for(i = 1; i*i <= n; i++);
  cout << (i-1)*(i-1) << endl;
}


Measured memory_bytes: 256
// CONTEST SOURCE
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <climits>
//#include <priority_queue>
using namespace std;
#define ll long long
#define x first
#define y second
#define pii pair<int, int>
#define pdd pair<double, double>
#define L(s) (int)(s).size()
#define VI vector<int>
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define inf 1000000000
int n, m;
set<pair<int, int> > need;
int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    int x; scanf("%d", &x);
    need.insert(mp(x, i));
  }
  scanf("%d", &m);
  while(m--) {
    int x; scanf("%d", &x);
    set<pair<int, int> >::iterator it = need.lower_bound(mp(x, -1));
    if (it != need.end() && it->x == x) {
      need.erase(it);
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    while (N > 0) {
        int tmp = N % 26;
        if (tmp == 0) {
            tmp = 26;
            N--;
        }
        S += 'a' + tmp - 1;
        N /= 26;
    }
    reverse(ALL(S));
    cout << S << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b)ans = a;
	else ans = a - 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 12 + 5;
const int MAXM = 2e5 + 5;
const int MAXP = 1e6 + 5;

int pw3[MAXN];

struct Node
{
	int id;
	bool tag;
	Node* son[3];
	
	inline void push_down(void)
	{
		if(!tag) return;
		tag=0;
		swap(son[1],son[2]);
		for(int i=0; i<3; ++i)
			son[i] -> tag ^= 1;
	}
}p[MAXP];
int pcnt=0;

int n;

inline void build(Node *&u,int dep,int now)
{
	u = &p[++pcnt];
	if(dep==n)
	{
		u -> id = now;
		return;
	}
	for(int i=0; i<3; ++i)
		build(u -> son[i], dep+1, now + i*pw3[dep]);
}

inline void add(Node *u,int dep)
{
	if(dep==n) return;
	u -> push_down();
	
	Node *tmp = u -> son[2];
	u -> son[2] = u -> son[1];
	u -> son[1] = u -> son[0];
	u -> son[0] = tmp;
	
	add(u -> son[0], dep+1);
}

int ans[MAXP];

inline void dfs(Node *u,int dep,int now)
{
	if(dep==n)
	{
		ans[u -> id] = now;
		return;
	}
	u -> push_down();
	for(int i=0; i<3; ++i)
		dfs(u -> son[i], dep+1, now + i*pw3[dep]);
}

int m;
char s[MAXM];

int main(void)
{
	scanf("%d%s",&n,s+1);
	m = strlen(s+1);
	
	pw3[0]=1;
	for(int i=1; i<=n; ++i) pw3[i] = pw3[i-1]*3;
	
	Node *root;
	build(root,0,0);
	
	for(int i=1; i<=m; ++i)
	{
		if(s[i]=='S')
			root -> tag ^= 1;
		else add(root,0);
	}
	
	dfs(root,0,0);
	for(int i=0; i<pw3[n]; ++i)
		printf("%d ",ans[i]);
	return 0;
}

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

int main(void){
    int n,k,i,sa;
    cin >> n >> k;

    vector<int> h(n);
    for(i=0; i<n; i++){
        cin >> h.at(i);
    }

    sort(h.begin(),h.end());
    sa = h.at(n-1) - h.at(0);
    
    for(i=0; i<n-k+1; i++){
        sa = min( sa, h.at(i+k-1) - h.at(i));
    }

    cout << sa << endl;

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll x = 0;
    cin >> x;
    ll sum = 0, ans = 1;
    while (true) {
        sum += ans;
        if (sum >= x) {
            cout << ans << endl;
            break;
        }
        ans++;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<=n;i++)
	{
		if((int)(i*1.08)==n)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;




}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize
    }
    if n < 105 {
        println!("0");
        return
    }
    let mut ans = 0;
    for i in 105..n+1{
        if i % 2 == 0 {continue}
        if divisor(i) == 8 {ans += 1}
    }
    println!("{}", ans);
}

fn divisor(n : usize) -> usize {
    let mut i = 1;
    let mut res = 0;
    while i * i <= n {
        if n % i == 0 {
            res += 1;
            if i * i != n {
                res += 1;
            }
        }
        i += 1;
    }
    res
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}

vi factorize(int n ) {
	vi ans ;

	for (int i = 1 ; i <= sqrt(n) ; i++) {
		if (n % i == 0) {
			ans.pb(i);
			ans.pb(n / i);
		}
	}
	return ans;
}

int32_t main() {


	int n ;
	cin >> n;

	vi factors = factorize(n);

	int x = factors[factors.size() - 2];
	int y = factors[factors.size() - 1];
	int ans = (x - 1) + (y - 1);
	cout << ans;

	return 0;
}

Measured memory_bytes: 3604
package main

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

var sc = NewScanner(os.Stdin, 1000000)

var memo []int
var graph [][]int

func main() {
	var tmpx int
	var tmpy int
	N := sc.readInt()
	M := sc.readInt()
	graph = make([][]int, N+1)
	for i := 0; i < M; i++ {
		tmpx = sc.readInt()
		tmpy = sc.readInt()
		graph[tmpx] = append(graph[tmpx], tmpy)
	}
	memo = make([]int, N+1)
	for i := 0; i <= N; i++ {
		memo[i] = -1
	}
	for i, v := range graph {
		if len(v) == 0 {
			memo[i] = 0
		}
	}
	for i := 1; i <= N; i++ {
		memo[i] = dp(i)
	}

	res := sliceMax(memo)
	fmt.Println(res)

}

func dp(i int) int {
	if memo[i] != -1 {
		return memo[i]
	}
	if len(graph[i]) == 0 {
		return 0
	}
	var candidate []int
	for _, v := range graph[i] {
		candidate = append(candidate, dp(v)+1)
	}
	memo[i] = sliceMax(candidate)
	return memo[i]
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func sliceMin(s []int) int {
	result := math.MaxInt64
	for _, v := range s {
		if v < result {
			result = v
		}
	}
	return result
}

func sliceMax(s []int) int {
	result := math.MinInt64
	for _, v := range s {
		if v > result {
			result = v
		}
	}
	return result
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 22912
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int ansp=0;
    double ansbmi=10000;
    int p;
    double h,w;
    rep(i,n){
      cin>>p>>h>>w;
      h/=100;
      if(ansbmi>fabs(22-w/h/h)){
        ansp=p;
        ansbmi=fabs(22-w/h/h);
      }
    }
    cout<<ansp<<endl;
  }
}

Measured memory_bytes: 3044
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define LL long long
#define rint register int
#define MAXN 200005
using namespace std;

int n, c[20][20];
LL ans;
double a[MAXN];

int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i) scanf("%lf", &a[i]);
    for(rint i=1; i<=n; ++i)
    {
        int num2=0, num5=0;
        LL temp=a[i]*1000000000.0+0.5;
        while(temp%2==0 && num2<18) num2++, temp/=2;
        while(temp%5==0 && num5<18) num5++, temp/=5;
        for(rint j=0; j<=18; ++j)
            for(rint k=0; k<=18; ++k)
                if(j+num2>=18 && k+num5>=18) ans+=c[j][k];
        c[num2][num5]++;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3220
n = int(input())
a1 = int(input())
flag = a1%2
ans = a1//2
for i in range(n-1):
    a = int(input())
    if flag:
        ans+=1 if 0<a else 0
        ans+=(a-1)//2 if a!=0 else 0
        flag=1 if a!=0 and (a-1)%2==1 else 0
    else:
        ans +=a//2
        flag=a%2
print(ans)

Measured memory_bytes: 45316