akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int a,b,i;
	
while(scanf("%d %d", &a, &b) != EOF){
	int ans = a+b;
	for(i=0; ans>0; i++){
		ans /= 10;
	}
		printf("%d\n",i);
}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  if(s[0]==s[s.length()-1]){
    if(s.length()%2) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
  }else{
    if(s.length()%2) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
//ITP1_2_D
#include<iostream>
using namespace std;

int main(){
	int w,h,x,y,r;
	
	cin>>w>>h>>x>>y>>r;
	
	if(x<r||y<r)
	cout<<"No"<<endl;
	else if((w-x)<r||(h-y)<r)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 1156
fn main() {
    let n = getint() + 1;
    let n = n as usize;
    let mut a : Vec<i64> = vec![0; n];
    for x in 0..n - 1{
        a[x] = getint();
    }
    let mut sum : i64 = 0;
    let mut ans : i64 = 0;
    for x in 0..n {
        if a[x] == 0 {
            ans += sum / 2;
            sum = 0;
        }
        else {
            sum += a[x];
        }
//        println!("{} {}", ans, sum);
    }
    println!("{}", ans);
}

fn next_line() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input
}


fn getint() -> i64 {
    let res = next_line();
    let res = res.trim().parse().unwrap();
    res
}

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

int main() {
    int n, d; cin >> n >> d;
    vector<vector<int>> coo(n, vector<int>(d));
    for(int i =0; i < n; i++) {
        for(int j = 0; j < d; j++) cin >> coo.at(i).at(j);
    }
    int ans =0;

    for(int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int dis2 = 0;
            for (int k = 0; k < d; k++) {
                dis2 += pow((coo.at(i).at(k) - coo.at(j).at(k)), 2);
            }

            for(int k = 0; k < 130; k++) {
                if (dis2 == k * k) {
                    ans++;
                    break;
                    }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
main () {
        char s[100], t[100];
        cin >> s >> t;
        sort(s, s+strlen(s));
        sort(t, t+strlen(t), std::greater<char>());
        cout << (strcmp(s,t)<0?"Yes":"No") << endl;
}


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

using namespace std;

int h, w, a, b;

const int mod = 1e9 + 7;

int fac[200005];
int pfa[200005];

int bPow(int n, int k) {
	if (k == 0) return 1;
	if (k == 1) return n;
	int cur = bPow(n, k/2);
	if (k % 2 == 0) {
		return 1ll * cur * cur % mod;
	}
	else {
		return ( (1ll * cur * cur) % mod ) * n % mod;
	}
}

int c(int k, int n) {
	if (k > n) return 1;
	return (1ll * fac[n] * pfa[n - k] % mod ) * pfa[k] % mod;
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(0) ;
	cin >> h >> w >> a >> b;
	fac[0] = 1;
	pfa[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		fac[i] = 1ll * fac[i-1] * i % mod;
		pfa[i] = bPow(fac[i], mod - 2);
	}
	int res = 0;
	for (int i = 1; i <= h - a; i++) {
		res = (1ll * res + 1ll * c(i - 1, i + b - 2) * c(h - i, h - i + w - b - 1) % mod ) % mod;
	}
	cout << res;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    int a[3][3],ans[3][3]={};
    cin>>a[0][0]>>a[0][1]>>a[0][2];
    cin>>a[1][0]>>a[1][1]>>a[1][2];
    cin>>a[2][0]>>a[2][1]>>a[2][2];
    int n;
    cin>>n;
    rep(i,0,n){
        int b;
        cin>>b;
        rep(i,0,3){
            rep(j,0,3) if(a[i][j]==b)ans[i][j]=1;
        }
    }
    int ok=0;
    rep(i,0,3){
        if(ans[i][0]*ans[i][1]*ans[i][2])ok=1;
    }
    rep(i,0,3){
        if(ans[0][i]*ans[1][i]*ans[2][i])ok=1;
    }
    if(ans[0][0]*ans[1][1]*ans[2][2])ok=1;
    else if(ans[0][2]*ans[1][1]*ans[2][0])ok=1;
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<50);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
	ll n,k;cin>>n>>k;
  vector<pair<ll,ll>>v;
  rep(i,n){
    ll a,b;cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(all(v));
  ll count=0;
  rep(i,n){
    count+=v[i].second;
    if(count>=k){
      cout<<v[i].first<<endl;
      return;
    }
  }
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 2420
//後戻りいらない？
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, a, b;
int x[100000];

signed main() {
	int i;
	
	cin >> n >> a >> b;
	for (i = 0; i < n; i++) cin >> x[i];
	
	int ans = 0;
	for (i = 0; i < n - 1; i++) {
		ans += min(a * (x[i + 1] - x[i]), b);
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = long long;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll q, h, s, d; cin >> q >> h >> s >> d;
  ll n; cin >> n;
  cout << n/2 * min({q*8, h*4, s*2, d}) + (n%2)*min({q*4, h*2, s}) << endl;
  return 0;
}


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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.00000000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;

int a[N];
void solve() {
    int n;
    cin >> n;

    map <ll, ll> m;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        m[1ll*(i+a[i])]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++){
        ans += m[i-a[i]];
    }

    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

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

using namespace std;

void solve() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  auto x = c - a - b;
  bool yes1 = x > 0;
  bool yes2 = x * x  > 4 * a * b;
  auto yes = yes1 && yes2;
  cout << (yes ? "Yes" : "No") << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string x; cin >> x;
    stack<char> st;
    for(auto ch : x) {
        if(st.empty()) st.push(ch);
        else if(ch=='S') st.push(ch);
        else if(st.top()=='S') st.pop();  // ch=='T' && st.top=='S'
        else st.push(ch);  // ch=='T' && st.top=='T'
    }

    cout << st.size() << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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


int main()
{
    int n;
    cin >> n;
    vector<int> d;
    rep(i, n){ int tmp; cin >> tmp; d.push_back(tmp);}

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j =  i + 1; j < n; j++)
        {
            ans += d[i] * d[j];
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define MAX_H 110
#define MAX_W 110
bool ignoreH[MAX_H];
bool ignoreW[MAX_W];
int main() {
  int H, W;
  cin >> H >> W;
  string sq[H];
  REP(i, H) cin >> sq[i];
  REP(i, H) {
    ignoreH[i] = true;
    REP(j, W) {
      if (sq[i][j] == '#') {
        ignoreH[i] = false;
        break;
      }
    }
  }

  REP(j, W) {
    ignoreW[j] = true;
    REP(i, H) {
      if (sq[i][j] == '#') {
        ignoreW[j] = false;
        break;
      }
    }
  }

  REP(i, H) {
    REP(j, W) {
      if (ignoreH[i]) continue;
      if (ignoreW[j]) continue;
      cout << sq[i][j];
    }
    if (!ignoreH[i]) cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			String packageName = new Main().getClass().getPackage().getName();
			System.setIn(new FileInputStream("src/" + packageName + "/input.txt"));
			// System.setOut(new PrintStream(new FileOutputStream("src/" + packageName + "/result.txt")));
		} catch (FileNotFoundException e) {
		} catch (NullPointerException e) {
		}
		new Main().run();
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		int T = sc.nextInt();
		while (T -- > 0) solve();
	}
	void solve() {
		int n = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int[] xs = new int[n+1];
		int[] ys = new int[n+1];
		for (int i = 0; i < n+1; i++) {
			xs[i] = sc.nextInt();
			ys[i] = sc.nextInt();
		}

		int[] active = new int[n];
		boolean[][] graph = new boolean[n][n];
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++) {
				int d = (xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]);
				if (d <= 50 * 50) {
					graph[i-1][j-1] = true;
				}
			}

		for(int i = 1; i <= n; i++) {
			int j = 0;
			int d = (xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]);
			if (d <= 10 * 10) {
				active[i - 1] = 1;
			}
		}

		if (Y < X)
		{
			boolean run = false;
			for (int i = 0; i < n; i++) if (active[i] == 1) {
				for (int j = 0; j < n; j++) if (i != j && active[j] != 1) {
					if (graph[i][j]) run = true;
				}
			}
			if (run)
				System.out.println("You're always welcome!");
			else {
				int on = 0;
				for (int i = 0; i < n; i++) if (active[i] == 1) on++;
				if (on == 0)
					System.out.println(0);
				else
					System.out.println(X);
			}
		}
		else
		{
			int turn = 0;
			for (turn = 0; ; turn++) {
				boolean update = false;

				int[] next = active.clone();
				for (int i = 0; i < n; i++) if (active[i] == 1) {
					update = true;
					next[i] = 2;
					for (int j = 0; j < n; j++) if (i != j && graph[i][j] && active[j] == 0) {
						next[j] = 1;
					}
				}
				active = next;
				if (!update) break;
			}
			System.out.println(X * (turn));
		}

	}
}

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

int main(void){
    int x=0,N,max=0;
    string s;
    cin>>N;
    cin>>s;
    for(int i=0;i<N;i++){
        if(s[i]=='I'){
            x++;
            if(x>max)
                max=x;
        }else if(s[i]=='D')
            x--;
    }
    cout<<max<<endl;

    return 0;
}


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

using namespace std;

int main(){
 int n;
  cin >> n;
  
   int l[2*n];

  for(int i=0;i<2*n;i++) cin >> l[i];

  sort(l,l+2*n);
  
  int res=0;
  for(int i=0;i<2*n;i+=2) res+=l[i];
  
  cout << res << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  string s;
  cin >> s;
  if (s.size() < 3) {
    if (s[0] == s[1])
      cout << 1 << ' ' << 2 << '\n';
    else
      cout << -1 << ' ' << -1 << '\n';
    return 0;
  }
  rep(i, 0, s.size() - 3) {
    if (s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i] == s[i + 2]) {
      cout << i + 1 << ' ' << i + 3 << '\n';
      return 0;
    }
  }
  cout << -1 << ' ' << -1 << '\n';
  return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"


template <typename T, typename K> struct P {
	T a; K b;
};

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
vector <P <ll, ll> >prime_factorize( ll N );
ll pow( ll a, ll n );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
int main( void ){
	// initialize();
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << min(X*Y, Z) << endl;
}

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

/*
 * @fn eratosthenes
 * @brief O(NloglogN)~=(N)
 * @param N: その数まで
 * @return 0 or 1 の配列 (boolは都合が悪い)
 */
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

/*
 * @fn prime_factorize
 * @brief O(√N): 素因数分解
 * @param N: 素因数分解する数
 * @return vec: (a: 素数, b: 個数)
 */
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
/*
 * @fn pow
 * @brief a^n
 * @param a: 基数
 * @param n: 指数
 */
ll pow( ll a, ll n ) {
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
def f(v, i):s, n = 4 * 2 ** v - 3, 2 * 2 ** v - 1;m = (s + 1) / 2;return 0 if i < 1 or i > s else [0, f(v - 1, i - 1), n / 2 + 1, f(v - 1, i - s / 2 - 1) + n / 2 + 1, n, 1][(i > 1) + (i >= m) + (i > m) + (i >= s) + (v == 0) * 3]

print f(*map(int, raw_input().split()))

Measured memory_bytes: 2692
#include<stdio.h>

int selectionSort(int A[], int N) {
	int i, j, t, sw = 0, minj;
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj])minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if (i != minj)sw++;
	}
	return sw;
}

int main() {
	int A[100], N, i, sw;

	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	sw = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n",sw);

	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD ((ll)1e9+7)
ll N,S;
vector<pll> xpv[2];
ll i, j, k,ans;
bool ck(ll t,ll aa,ll bb){
    return t ? (aa <= bb) : (aa < bb);
}
int main(){
    //printf("%lld\n", MOD);
    scanf("%lld%lld", &N,&S);
    fornum(i,0,N){
        ll x, p;
        scanf("%lld%lld", &x, &p);
        xpv[S < x].push_back(mp(abs(x - S), p));
    }
    sort(xpv[0].begin(), xpv[0].end(), greater<pll>());
    sort(xpv[1].begin(), xpv[1].end(), greater<pll>());
    if(xpv[0].size()*xpv[1].size()==0){
        printf("%lld",xpv[0].size()?xpv[0][0].first:xpv[1][0].first);
        return 0;
    }

    ll n = 0, t = 0;
    ll ii[]={0,0};
    n= xpv[0][0].second+xpv[1][0].second;
    if(xpv[0][0].second<xpv[1][0].second){
        t = 0;
    }else{
        t = 1;
    }
    ii[t]++;
    ans += xpv[t][0].first + xpv[!t][0].first * 2;
    //printf("%lld,%lld\n", xpv[t][0].second, xpv[!t][0].second);
    while(true){
        while(ii[t]<xpv[t].size()&&ck(t,xpv[t][ii[t]].second,n)){
            //printf("%lld,%lld\n", xpv[t][ii[t]].second, n);
            n += xpv[t][ii[t]].second;
            ii[t]++;
        }
        //printf("%lld,%lld,%lld\n", t, ii[t],n);
        if(ii[t]==xpv[t].size())
            break;
        n += xpv[t][ii[t]].second;
        ans += xpv[t][ii[t]].first*2;
        t = !t;
        ii[t]++;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 2804
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500001
#define MOD 1000000007
typedef long long  ll;

using namespace std;


int max;
int cnt[MAX];

int main() {
	int A,B,C;
	cin >> A >> B >> C;

	if (A + B + C >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
n = input()
l = input().split()
num = -1
for a in reversed(l):
    if num == -1:
        num = int(a)
    else:
        if num >= int(a):
            num = int(a)
        elif num >= int(a) - 1:
            num = int(a) - 1
        else:
            print('No')
            sys.exit()
print('Yes')


Measured memory_bytes: 64112
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n;

void Input() {
	cin >> n;
}

void Solve() {
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	vll b(n);
	b[0] = 0;
	b[1] = abs(a[1] - a[0]);
	for (ll i = 2; i < n; i++) b[i] = min(abs(a[i] - a[i - 1]) + b[i - 1], abs(a[i] - a[i - 2]) + b[i - 2]);
	cout << b[n - 1];

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

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

namespace ABC172_D
{
    using static Ex;
    public class D
    {
        public static void Main(string[] args)
        {
            var n = ReadLong;
            long ans = 0;

            for (long i = 1; i <= n; i++)
            {
                for (long j = i; j <= n; j += i)
                {
                    ans += j;
                }
            }
            ans.Cw();
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }

        public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
        public static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }
    }
}


Measured memory_bytes: 27516
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	int n;
	cin >> n;
	vector<int> timing;
	long long ans = 0;
	REP(i, n) {
		int a;
		cin >> a;
		ans += a;
		timing.push_back(a);
	}
	int m;
	cin >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		cout << ans - timing[a] + b << endl;
	}
}


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

#include <cassert>

using namespace std;

const int inf = (int)1e9 + 7;

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

    int h, w;

    cin >> h >> w;

    vector<string> field (h);

    for (auto &row : field)
        cin >> row;

    for (int y = 0; y < h; y++)
        for (int x = 0; x < w; x++)
            if (field[y][x] != '#')
            {
                int cnt = 0;

                for (int dy = -1; dy <= 1; dy++)
                    for (int dx = -1; dx <= 1; dx++)
                        if (0 <= y + dy && y + dy < h &&
                            0 <= x + dx && x + dx < w)
                            cnt += (field[y + dy][x + dx] == '#');

                field[y][x] = '0' + cnt;
            }

    for (const auto &row : field)
        cout << row << endl;

    return 0;
}


Measured memory_bytes: 256
S=input()
n=len(S)
i=0
a=[0,0]
b=[0]*n
while i<n:
    while S[i]=="R":
        a[i%2]+=1
        i+=1
    k=i
    while S[i]=="L":
        a[i%2]+=1
        i+=1
        if i==n:
            break
    b[k]+=a[k%2]
    b[k-1]+=a[(k-1)%2]
    a=[0,0]
print(*b)

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define LL long long
#define Max 1000005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL a[Max];
int main()
{
    LL n;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    LL t=0;
    for(int i=1;i<=n;i++){
        t^=a[i];
    }
    if(t==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;



int32_t main() {

    simplify

    int n;
    cin>>n;
    int ans=0;

    for(int i=0;i<n;i++){
        ans+=(i+1)*(n-i);
    }

    int u,v;
    for(int i=0;i<n-1;i++){
        cin>>u>>v;
        u--;v--;
        if(u>v)swap(u,v);
        ans-=(u+1)*(n-v);
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<n;i++)
typedef pair<int,int> P;
typedef long long ll;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){cout<<"No";return 0;}
    else{cout<<"Yes";return 0;}
}

Measured memory_bytes: 256
N = int(input())
l = [int(x) for x in range(1,N+1)]

total_num,max_num = 0,0

if N <= 2:
  print(N)
  exit()

for i in range(1,N):
  total_num += i
  if total_num >= N:
    max_num = i
    break

if total_num == N:
  for i in range(max_num):
    print(i+1)
else:
  ng_num = total_num - N
  for j in range(max_num):
    if j+1 != ng_num:
      print(j+1)

Measured memory_bytes: 187296
import numpy as np
import sys
sys.setrecursionlimit(10**6)

n=int(input())

m=int(np.sqrt(n)+1)

ans=10**13
for i in range(1,m+1):
    if n%i==0:
        move=i+n/i-2
        ans=min(ans,int(move))
    
print(ans)




Measured memory_bytes: 13084
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][][] all = new int[4][][];
		all[0] = getArray(h - h / 3, w, h / 3 * w);
		all[1] = getArray(h - h / 3 - 1, w, (h / 3 + 1) * w);
		all[2] = getArray(h,  w - w / 3, w / 3 * h);
		all[3] = getArray(h, w - w / 3 - 1, (w / 3 + 1) * h);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < all.length; i++) {
		    for (int j = 0; j < all[i].length; j++) {
		        min = Math.min(min, Math.max(Math.max(all[i][j][0], all[i][j][1]), all[i][j][2]) - Math.min(Math.min(all[i][j][0], all[i][j][1]), all[i][j][2]));
		    }
		}
		System.out.println(min);
	}
	
	static int[][] getArray(int h, int w, int piece) {
	    int[][] ans = new int[2][3];
	    ans[0][0] = h / 2 * w;
	    ans[0][1] = h * w - ans[0][0];
	    ans[0][2] = piece;
	    ans[1][0] = w / 2 * h;
	    ans[1][1] = h * w - ans[1][0];
	    ans[1][2] = piece;
	    return ans;
	}
}


Measured memory_bytes: 23380
#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 <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<ll> h(n);

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

    h.push_back(0);

    ll ans = 0;

    for (int i = 100; i >= 1; i--)
    {
        for (int j = 0; j < n; j++)
        {
            if (h[j] == i)
            {

                if (h[j + 1] < h[j])
                {
                    ans++;
                }
                h[j]--;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
    int ant[5];
    ant[0] = a;ant[1] = b;ant[2] = c;ant[3] = d;ant[4] = e;
    int cnt = ant[4] - ant[0];
    if(cnt>k){
        printf(":(");
    }
    else{
        printf("Yay!");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[3];
string res="";
bool fl=1;
string s[100010];
bool b[100010][3];
int main()
{
	cin >>n;
	for (int i=0;i<3;i++) cin >>a[i];
	for (int i=0;i<n;i++)
		cin >>s[i],b[i][s[i][0]-'A']=1,b[i][s[i][1]-'A']=1;
	for (int i=0;i<n;i++)
	{
		char x=s[i][0],y=s[i][1];
		x-='A',y-='A';
		if (a[x]>a[y] ||
		(a[x]==a[y] && b[i+1][y] && !a[s[i+1][s[i+1][0]==y+'A' ? 1 : 0]-'A'])) swap(x,y);
		res+=(char)(x+'A');
		a[x]++,a[y]--; 
		if (a[y]<0) fl=0;
	}
	if (!fl) cout <<"No\n";
	else
	{
		cout <<"Yes\n";
		for (int i=0;i<n;i++) cout <<res[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 7160
import sys
input=sys.stdin.readline
INF=10**9+7
n=int(input())
a_list=list(map(int,input().split()))
l=[0,0,0]
ans=1
for i in range(n):
    c=0
    for j in l:
        if j==a_list[i]:
            c+=1
    ans=(ans*c)%INF
    for j in range(3):
        if l[j]==a_list[i]:
            l[j]+=1
            break
print(ans)
        


Measured memory_bytes: 54108
#include <map>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int H, W;


void fillUp(int **d, int h, int w, int cur_distance) {
    int ch = h - 1;
    int cd = cur_distance + 1;
    while (ch >= 0 && cd < d[ch][w]) {
        d[ch][w] = cd;
        ch -= 1;
        cd += 1;
    }
}


void fillDown(int **d, int h, int w, int cur_distance) {
    int ch = h + 1;
    int cd = cur_distance + 1;
    while (ch < H && cd < d[ch][w]) {
        d[ch][w] = cd;
        ch += 1;
        cd += 1;
    }
}

void debug(int **d) {
    //cout << "H: " << H << endl;
    //cout << "W: " << W << endl;
    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            cout << d[h][w] << ' ';
        }
        cout << endl;
    }
}


void fillDistance(int** d, int h, int w) {
    int cw, cd;

    // updown
    fillUp(d, h, w, 0);
    fillDown(d, h, w, 0);
    //debug(d);

    // left
    cw = w - 1;
    cd = 1;
    while (cw >= 0 && cd < d[h][cw]) {
        d[h][cw] = cd;
        fillUp(d, h, cw, cd);
        fillDown(d, h, cw, cd);
        cw -= 1;
        cd += 1;
    }

    // right
    cw = w + 1;
    cd = 1;
    while (cw < W && cd < d[h][cw]) {
        d[h][cw] = cd;
        fillUp(d, h, cw, cd);
        fillDown(d, h, cw, cd);
        cw += 1;
        cd += 1;
    }
}

int main() {
    cin >> H >> W;
    string A[H];
    for (int h=0; h<H; h++) {
        cin >> A[h];
    }
    int **d = new int*[H];
    for (int h=0; h<H; h++) {
        d[h] = new int[W];
        for (int w=0; w<W; w++) {
            if (A[h][w] == '#') {
                d[h][w] = 0;
            } else {
                d[h][w] = 10000;
            }
            //cout << d[h][w];
        }
    }

    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            if (A[h][w] == '#') {
                fillDistance(d, h, w);
            }
        }
    }

    int ans = -1;
    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            //cout << d[h][w];
            if (d[h][w] > ans) {
                ans = d[h][w];
            }
        }
    }
    //debug(d);

    cout << ans << endl;
}


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

int main()
{
   int n;
   while(cin >> n){
       if(n==0)
           break;
       long long m[10001];
       for(int i=0;i<n;i++){
           cin >> m[i];
       }
       sort(m,m+n);
       long long a = 0;
       long long sum = 0;
       for(int i=0;i<n;i++){
           sum += a;
           a += m[i];
       }
       cout << sum << endl;
   }
   return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int a[200000+5];

int main()
{
    int n;
	cin >> n;
    for (int i = 0; i < n; ++i)
    {
        // n-1 1 -> 0
        // n-2 2 -> n-1
        // n-3 3 -> 1
        // n-4 4 -> n-2
        int idx = n-i;
        if (idx % 2 == 1)
            idx /= 2;
        else
            idx = n - idx/2;
        cin >> a[idx];
    }
    for (int i = 0; i < n; ++i)
    {
        cout << a[i] << ' ';
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 2944
(n,i),a,*q=$<.map{_1.split.map &:to_i}
b=(0..n).map{_1&-_1}
d=b.map{[]}
z=q.map{d[_2]<<[_1-1,~i-=1]}
u=0
a.map{t=$*[_1]||n+u+=1
(b[t]-=1;t+=t&-t)until t>n
d[$*[_1]=i+=1].map{|x,y|z[y]=u
(z[y]-=b[x];x&=x-1)while x>0}}
p *z

Measured memory_bytes: 179788
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <set>
#include <numeric>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll pow(ll x, ll y, ll modulo)
{
    if (y == 0)
    {
        return 1LL;
    }
    else
    {
        ll y_2 = pow(x, y / 2, modulo) % modulo;
        ll yy = (y_2 * y_2) % modulo;
        if (y % 2 == 0)
        {
            return yy;
        }
        else
        {
            return (yy * x) % modulo;
        }
    }
}

ll popcount(ll a){
    ll ans = 0;
    for(int i = 0; (1<<i) <= a;i++){
        if (a & 1<<i){
            ans++;
        }
    }
    return ans;
}
int main()
{
    // 整数の入力
    ll N;
    cin >> N;
    string X;
    cin >> X;
    vector<ll> A(2*100000+1,0);
    for(int i = 1; i< 2*100000+1;i++){
        A[i] = A[i % popcount(i)] + 1;
        // if (i < 100){
        //     cout << A[i] << endl;
        // }
    }
    // cout << "===" << endl;
    ll ones = 0;
    for(int i = 0;i < N;i++){
        if (X[i] == '1'){
            ones++;
        }
    }
    ll plus_total = 0;
    ll minus_total = 0;
    if (ones + 1 != 0){
        for(int i = 0;i < N;i++){
            if (X[i] == '1'){
                plus_total = (plus_total + pow(2,N - 1 - i,ones+1)) % (ones+1);
            }
        }
    }
    if (ones - 1 != 0){
        for(int i = 0;i < N;i++){
            if (X[i] == '1'){
                minus_total = (minus_total + pow(2,N - 1 - i,ones-1)) % (ones-1);
            }
        }
    }
    for(int i = 0; i < N;i++){
        ll count;
        bool is_zero = false;
        if (X[i] == '1'){
            if (ones - 1 == 0){
                is_zero = true;
                count = 0;
            }else{
                count = (minus_total - pow(2,N - 1 - i,ones - 1) + ones - 1) % (ones -1);
            }
        }else{
            if (ones + 1 == 0){
                count = 0;
            }else{
                count = (plus_total + pow(2,N - 1 - i,ones + 1)) % (ones + 1);
            }
        }
        if (is_zero){
            cout << 0 << endl;
        }else{
            cout << A[count] + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5176
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define MAXN 2000000
#define int long long
#define INF (1e9 + 7)
#define MANX MAXN
// #pragma GCC optimize(2)

using namespace std;

inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = getchar();}
	return f * x;
}

int n, m, a[MAXN]; 

char c[MAXN];

signed main()
{
	cin >> c;
	int len = strlen(c);
	for (int i = 0;	i < len; i++)
		if (c[i] - 48 == 7)
		{
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)

using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int t1 = a + b;
	int t2 = a + c;
	int t3 = b + c;
	if(t1 <= min(t2, t3)) cout << t1 << endl;
	else if(t2 <= min(t1, t3)) cout << t2 << endl;
	else cout << t3 << endl;
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(410, vector<int>(410, INF)));
  dp[0][0][0] = 0;

  rep(i, n) {
    for(int ia = 0; ia <= 400; ++ia) {
      for(int ib = 0; ib <= 400; ++ib) {
        if(ia-a[i] >= 0 && ib-b[i] >= 0) chmin(dp[i+1][ia][ib], dp[i][ia-a[i]][ib-b[i]]+c[i]);
        chmin(dp[i+1][ia][ib], dp[i][ia][ib]);
      }
    }
  }


  int ans = INF;
  for(int ia = 1; ia <= 400; ++ia) {
    for(int ib = 1; ib <= 400; ++ib) {
      int g = __gcd(ia, ib);
      if(ia/g == ma && ib/g == mb) {
        chmin(ans, dp[n][ia][ib]);
      }
    }
  }
  if(ans != INF) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 31508
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  if(a+b-n>=0) cout << min(a,b) << " " << a+b-n << endl;
  else cout << min(a,b) << " " << 0 << endl;
}


Measured memory_bytes: 256
n=gets.to_i
h=Hash.new{0}

tmp=""
flg=false

n.times do
  w=gets.chomp
  if h.empty?
    h[w]+=1
    tmp=w
  else
    h[w]+=1
    if w[0]!=tmp[-1] || h[w]>1
      flg=true
      break
    end
    tmp=w
  end
end

puts flg ? "No" : "Yes"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A;
    cin >> A;
    ll N = A.size();
    ll ans = 1 + N * (N-1) / 2;
    ll cnt[30] = {};
    rep(i,0,N){
        cnt[A[i] - 'a']++;
    }
    rep(i,0,26){
        if(cnt[i] >= 2){
            ans -= cnt[i] * (cnt[i]-1)/2;
        }
    }
    print(ans);

}


Measured memory_bytes: 720
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
  int a, b;
  int ans = 0;
  cin >> a >> b;

  while(1){
    ans++;
    if ((a * ans - ans + 1) >= b){
      break;
    }
  }

  if (b == 1){
    ans = 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256