akhauriyash/Code-Regression huggingface dataset:
#include<sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstdlib> 
#include <iomanip> 
#include<numeric>
#include<set>
#include<bitset>
#include<cstring>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<vector>
#include<ctype.h>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std;
int main() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	long long a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;



	system("pause");
		 //return 0;

}


Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n);
	vector<int> y(m);
	//bool a = 1;
	//bool b = 1;
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
		//if (x[i] == X) {
	//		a = 0;
		//}
	}
	for (int i = 0; i < m; ++i) {
		cin >> y[i];
	//	if (y[i] == Y) {
	//		b = 0;
		//}
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	if (x[n - 1] < y[0] && X < Y && X < y[0] && Y > x[n - 1]) {
		cout << "No War";
	}else {
		cout << "War";
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 8+3*2
int w[MAX][MAX];//二次配列のポインタを関数に渡すやり方が分からなかった

void search(int a,int b){
    int i;
    w[a][b]=0;
    for(i=1;i<4;i++){
        if(w[a+i][b])search(a+i,b);
        if(w[a-i][b])search(a-i,b);
        if(w[a][b+i])search(a,b+i);
        if(w[a][b-i])search(a,b-i);
    }
}

int main(){
    int i,j,n,a,b,cnt=0;
    char c;

    if(scanf("%d%*c%*c",&n)==EOF)return 0;
    while(cnt!=n){
        for(i=3;i<MAX-3;i++){
            for(j=3;j<MAX-3;j++){
                if(scanf("%c",&c)==EOF)return 0;
                w[i][j]=c-'0';
            }
            getchar();
        }
        if(scanf("%d%d%*c%*c",&a,&b)==EOF)return 0;
        search(b+2,a+2);
        printf("Data %d:\n",++cnt);
        for(i=3;i<MAX-3;i++){
            for(j=3;j<MAX-3;j++){
                printf("%d",w[i][j]);
            }
            puts("");
        }
    }
return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    bool ans[100][100];
    for(int i = 0; i < 100; i++)for(int j = 0; j < 100; j++)ans[i][j] = (i < 50 ? 1 : 0);
    pair<int, int> po = pair<int, int>(0, 0), yo(99, 99);
    for(int i = 1; i < a; i++){
        ans[po.first][po.second] = 0;
        po.second += 2;
        if(100 <= po.second)po = pair<int, int>(po.first + 2, 0);
    }
    for(int i = 1; i < b; i++){
        ans[yo.first][yo.second] = 1;
        yo.second -= 2;
        if(yo.second < 0)yo = pair<int, int>(yo.first - 2, 99);
    }
    cout << 100 << ' ' << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++) cout << (ans[i][j] ? '#' : '.');
        cout << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    while(1) {
        string s;
        ll y, m, d;
        cin >> s;
        if(s == "#") break;
        cin >> y >> m >> d;

        if(y <= 30 || (y == 31 && m <= 4)) {
            cout << "HEISEI " << y << " " << m << " " << d << endl;
        } else {
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int digit_sum(int n) {
    int res = 0;

    while (n > 0) {
        res += (n%10);
        n /= 10;
    }

    return res;
}

int main() {
    int n;
    cin >> n;
    if (n % digit_sum(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool dfs(const vvi& g,const vl& a,int p,int u,vl& xs)
{
	int m=0;
	for(int v:g[u]) if(v!=p) m++;
	if(m==0){
		xs[u]=a[u];
		return true;
	}
	ll sum=0,mx=0;
	for(int v:g[u]) if(v!=p){
		if(!dfs(g,a,u,v,xs))
			return false;
		sum+=xs[v];
		mx=max(mx,xs[v]);
	}
	xs[u]=2*a[u]-sum;
	if(xs[u]<0||sum-xs[u]<0||(sum-xs[u])/2>sum-mx)
		return false;
	if(u==0){	// root
		if(m==1&&xs[u]!=sum)
			return false;
		if(m>1&&xs[u]>0)
			return false;
	}
	return true;
}

bool solve(vvi g,vl a)
{
	int n=a.size();
	vl xs(n);
	return dfs(g,a,-1,0,xs);
}

int main()
{
	for(int n;cin>>n&&n;){
		vl a(n);
		rep(i,n) cin>>a[i];
		vvi g(n);
		rep(i,n-1){
			int u,v; cin>>u>>v; u--,v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		cout<<(solve(g,a)?"YES":"NO")<<endl;
	}
}


Measured memory_bytes: 22912
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int N;
  std::string s;
  std::cin >> N;
  std::cin >> s;
  int wcount = 0, rcount = 0;
  for (int i=0; i<N; i++) {
    if (s[i]=='R') rcount++;
    else wcount++;
  }
  int ans2 = wcount;
  int ans3 = rcount;
  int ans1 = 0;
  for (int i=0; i<N; i++) {
    if (s[i]=='W' && i<rcount) ans1++;
  }
  int ans = std::min(ans1, std::min(ans2, ans3));
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


const ll MOD = 1e9 + 7;
typedef long long number;
typedef vector<number> vec;
typedef vector<vec> matrix;

// O( n )
matrix ident(int n) {
	matrix A(n, vec(n));
	for (int i = 0; i < n; ++i) A[i][i] = 1;
	return A;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
	matrix C(A.size(), vec(B[0].size()));
	for (int i = 0; i < (int)C.size(); ++i)
		for (int j = 0; j < (int)C[i].size(); ++j)
			for (int k = 0; k < (int)A[i].size(); ++k) {
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= MOD;
			}
	return C;
}
// O( n^3 log e )
matrix mat_pow(const matrix &A, ll e) {
	if (e == 0) return ident(A.size());
	if (e == 1) return A;
	if (e % 2 == 0) {
		matrix tmp = mat_pow(A, e / 2);
		return mul(tmp, tmp);
	} else {
		matrix tmp = mat_pow(A, e - 1);
		return mul(A, tmp);
	}
}


int main() {
	in(ll, H, W, K);

	matrix mat(W, vector<ll>(W, 0));

	loop(i, (1ll << (W-1))) {
		// is valid
		{
			bool valid = true, bef = false, bef_t;
			auto t = i;
			loop(u, W-1) {
				bef_t = (bool)(t & 1);
				if (bef && bef_t)
					valid = false;
				bef = bef_t;
				t >>= 1;
			}
			if (!valid)
				continue;
		}
		// calc
		vector<int> t(W);
		loop(tt, W)
			t[tt] = tt;
		loop(k, W-1) {
			if (i & (1ll << k)) {
				swap(t[k], t[k + 1]);
			}
		}
		loop(tt, W)
			++mat[tt][t[tt]];
	}

	auto ans = mat_pow(mat, H)[0][K-1];

	out(ans);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
int main() {
	char s[5]={};
	bool canFmm=false;
	bool canLmm=false;
	scanf("%s", s);
	for (int i = 0; i < 4; i++) {
		s[i]-='0';
	}
	int first=s[0]*10+s[1];
	int last=s[2]*10+s[3];
	if(1<=last&&last<=12)
		canLmm=true;
	if(1<=first&&first<=12)
		canFmm=true;
	if(canFmm&&canLmm)
		printf("AMBIGUOUS\n");
	else if(canFmm)
		printf("MMYY\n");
	else if(canLmm)
		printf("YYMM\n");
	else
		printf("NA\n");
	return 0;
}


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


int main(){

int N, K;
cin >> N >> K;

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

sort(l.rbegin(), l.rend());
int maxl = 0;
for(int i =0; i < K; i++){
maxl += l.at(i);
}

cout << maxl << endl;
}

 
    
    
  
  
  
  
  

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const long long mod = 1000000007;
long long pw(long long b, long long e) {
	if (e == 0) return 1;
	long long a = pw(b, e / 2);
	a = a * a % mod;
	if (e % 2) a = a * b % mod;
	return a;
}
long long fac[200001], inv[200001], stans[200000], pans[200000];
int N, stsize[200000];
vector<int> adjlist[200000];
int dfs(int v, int p) {
	stans[v] = 1;
	stsize[v] = 1;
	for (int i: adjlist[v]) {
		if (i == p) continue;
		stsize[v] += dfs(i, v);
		stans[v] = stans[v] * stans[i] % mod * inv[stsize[i]] % mod;
	}
	stans[v] = stans[v] * fac[stsize[v] - 1] % mod;
	return stsize[v];
}
void dfs2(int v, int p) {
	if (v != 0) {
		pans[v] = stans[p];
		pans[v] = pans[v] * inv[stsize[p] - 1] % mod;
		pans[v] = pans[v] * fac[stsize[v]] % mod;
		pans[v] = pans[v] * pw(stans[v], mod - 2) % mod;
		pans[v] = pans[v] * pans[p] % mod * inv[N - stsize[p]] % mod;
		pans[v] = pans[v] * fac[N - stsize[v] - 1] % mod;
	} else pans[v] = 1;
	for (int i: adjlist[v]) {
		if (i == p) continue;
		dfs2(i, v);
	}
}
int main() {
	fac[0] = 1;
	for (int i = 1; i <= 200000; ++i) fac[i] = i * fac[i - 1] % mod;
	for (int i = 0; i <= 200000; ++i) inv[i] = pw(fac[i], mod - 2);
	int a, b;
	scanf("%d", &N);
	for (int i = 1; i < N; ++i) {
		scanf("%d %d", &a, &b);
		adjlist[a - 1].push_back(b - 1);
		adjlist[b - 1].push_back(a - 1);
	}
	dfs(0, -1);
	dfs2(0, -1);
	for (int i = 0; i < N; ++i) {
		long long ans = stans[i];
		ans = ans * pans[i] % mod;
		ans = ans * fac[N - 1] % mod * inv[stsize[i] - 1] % mod * inv[N - stsize[i]] % mod;
		printf("%lld\n", ans);
	}
	return 0;
}

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

#define int long long

const int INF = 0x7f7f7f7f;

int n,m,t,a[100005],b[100005];
int ans,mn1=INF,mn2=INF;

signed main()
{
	cin>>n>>m>>t;
	for(int i=1;i<=n&&cin>>a[i];i++)
		mn1 = min(mn1,a[i]);
	for(int i=1;i<=m&&cin>>b[i];i++)
		mn2 = min(mn2,b[i]);
	ans = mn1+mn2;
	for(int i=1,c,x,y;i<=t&&cin>>x>>y>>c;i++)
		ans = min(ans,a[x]+b[y]-c);
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
  string a;
  cin>>a;
  
  if(a=="AKIHABARA"||a=="AKIHABAR"||a=="AKIHABRA"||a=="AKIHABR"){
    cout<<"YES"<<endl;
  }
  else if(a=="AKIHBARA"||a=="AKIHBAR"||a=="AKIHBRA"||a=="AKIHBR"){
    cout<<"YES"<<endl;
  }
  else if(a=="KIHABARA"||a=="KIHABAR"||a=="KIHABRA"||a=="KIHABR"){
    cout<<"YES"<<endl;
  }
  else if(a=="KIHBARA"||a=="KIHBAR"||a=="KIHBRA"||a=="KIHBR"){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n;
ll maxi(ll x,ll y)
{
	if(x<y)
		return y;
	else
		return x;
}
int main()
{
	ll k,x,y,z,w;
	cin>>n>>w;
	vector<pair<ll,ll> > h(n+1);
	std::vector<std::vector<ll> > dp(n+1,std::vector<ll>(w+1,0));
	for (int i = 1; i <= n; ++i)
	{
		cin>>h[i].first>>h[i].second;
	}
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= w; ++j)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(h[i].first>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],h[i].second+dp[i-1][j-h[i].first]);
		}
	}
	cout<<dp[n][w]<<"\n";
}

Measured memory_bytes: 80256
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int L;
    cin >> L;
    int rest = L;

    ll next = 1ll;
    int maxN = 0;

    vector<vector<ll> > ans;
    for (int i = 0; next * 2 <= L; i++) {
        rest -= next;
        ans.push_back(vector<ll>({i + 1, i + 2, next}));
        ans.push_back(vector<ll>({i + 1, i + 2, 0}));
        next <<= 1;
        chmax(maxN, i + 2);
    }
    rest--;

    while (rest > 0) {
        int tbit = -1;
        for (int i = 0;; ++i) {
            if (rest >> i & 1) {
                tbit = i;
                break;
            }
        }
        int diff = 1 << tbit;
        ans.push_back(vector<ll>({tbit + 1, maxN, next}));
        rest -= diff;
        next += diff;
    }

    cout << maxN << " " << ans.size() << endl;
    for (auto e : ans) {
        cout << e[0] << " " << e[1] << " " << e[2] << endl;
    }


    return 0;
}


Measured memory_bytes: 888
class Node():
    def __init__(self, parent =None ,left =None ,right = None):
        self.parent = parent
        self.left = left
        self.right = right

def get_depth(u,tree_list):
    d = 0
    while tree_list[u].parent != -1:
        u = tree_list[u].parent
        d += 1
    return d


def get_sibling(i, tree_list):
    if tree_list[i].parent == -1:
        return -1
    p = tree_list[i].parent
    if tree_list[p].left != i and tree_list[p].left != -1:
        return tree_list[p].left

    if tree_list[p].right != i and tree_list[p].right != -1:
        return tree_list[p].right

    return -1

def get_higt(i, tree_list):
    h1 = 0
    h2 = 0
    if tree_list[i].left != -1:
        h1 = get_higt(tree_list[i].left, tree_list) + 1
    if tree_list[i].right != -1:
        h2 = get_higt(tree_list[i].right, tree_list) + 1

    return max(h1,h2)

if __name__ == "__main__":
    n = int(input())

    tree_list = [Node(-1,-1,-1) for m in range(n)]
    for i in range(n):
        l = input().split()
        v = int(l[0])
        c_list = [int(l[m]) for m in range(1,len(l))]
        tree_list[v].left = c_list[0]
        tree_list[v].right = c_list[1]
        if c_list[0] != -1:
            tree_list[c_list[0]].parent = v
        if c_list[1] != -1:
            tree_list[c_list[1]].parent = v

    for i,t in enumerate(tree_list):
        sibling = get_sibling(i,tree_list)
        degree = 0
        if tree_list[i].left != -1:
            degree += 1
        if tree_list[i].right != -1:
            degree += 1

        depth = get_depth(i, tree_list)
        higt = get_higt(i,tree_list)
        tree_type = ''
        if tree_list[i].parent == -1:
            tree_type = 'root'
        elif tree_list[i].left == -1 and tree_list[i].right == -1:
            tree_type = 'leaf'
        else:
            tree_type = 'internal node'

        print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
            i,t.parent,sibling,degree,depth,higt,tree_type))




Measured memory_bytes: 5628
import sys

N=int(input())
S=input()

flgT=["SSS","SWW","WWS","WSW"]
flgF=["SSW","WSS","SWS","WWW"]

if S[0]=='o':
  for i in range(4):
    str=flgT[i]
    for j in range(1,N):
      if (S[j]=="o" and str[-1]=="S") or (S[j]=="x" and str[-1]=="W"):
        str=str+str[-2]
      else:
        if str[-2]=="W":
          str=str+"S"
        else:
          str=str+"W"
    if str[-2]==str[0] and str[-1]==str[1]:
      str=str[1:-1]
      print(str)
      sys.exit()
else:
  for i in range(4):
    str=flgF[i]
    for j in range(1,N):
      if (S[j]=="o" and str[-1]=="S") or (S[j]=="x" and str[-1]=="W"):
        str=str+str[-2]
      else:
        if str[-2]=="W":
          str=str+"S"
        else:
          str=str+"W"
    if str[-2]==str[0] and str[-1]==str[1]:
      str=str[1:-1]
      print(str)
      sys.exit()

print(-1)

Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=310;
int n,m,l;
int times[MAXN][MAXN];
int d[MAXN][MAXN];
int main()
{
    // freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin>>n>>m>>l;
    memset(times,0x3f,sizeof(times));
    memset(d,0x3f,sizeof(d));
    for(int u=0;u<m;u++){
        int a,b,c;
        cin>>a>>b>>c;
        d[a][b]=d[b][a]=c;
    }
    for(int k=1;k<=n;k++){
        for(int u=1;u<=n;u++){
            for(int v=1;v<=n;v++){
                d[u][v]=min(d[u][v],d[u][k]+d[k][v]);
            }
        }
    }
    for(int u=1;u<=n;u++){
        for(int v=1;v<=n;v++){
            if(d[u][v]<=l)times[u][v]=1;
        }
    }
    for(int k=1;k<=n;k++){
        for(int u=1;u<=n;u++){
            for(int v=1;v<=n;v++){
                times[u][v]=min(times[u][v],times[u][k]+times[k][v]);
            }
        }
    }
    int q;
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        int ans=times[s][t]!=0x3f3f3f3f?times[s][t]-1:-1;
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 1408
import Foundation

extension String {
    func wordsMap<T>(_ f: (Substring) -> T?) -> [T] {
        return self.split(separator: " ").compactMap(f)
    }
}

private func readWords<T>(_ f: (Substring) -> T?) -> [T] {
    return readLine()!.wordsMap(f)
}

prefix operator *
private prefix func *<T>(a: inout IndexingIterator<[T]>) -> T {
    return a.next()!
}

extension Optional {
    func pleaseAC(){
        print(self!)
    }
}

readLine().map { line -> Any in 
    let nk = line.wordsMap { Int($0) }
    let n = nk[0]
    let k = nk[1]

    let H = (1...n).map { _ in Int(readLine()!)! }.sorted()
    var mini = Int.max
    for i in 0...(n-k) {
        mini = min(mini, H[i+k-1] - H[i])
    }

    return mini
}
.pleaseAC()


Measured memory_bytes: 14888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
       FastReader fs=new FastReader();
       int n=fs.nextInt();
       int ct=0;
       for(int i=1;i<n;i++)
       {
    	   int fact=n/i;
    	   if(n%i==0)
    		   ct+=fact-1;
    	   else
    		   ct+=fact;
       }
       System.out.println(ct);
	}
    
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 

}


Measured memory_bytes: 32836
def bubble_sort(A):
    global N
    flag = True
    i = 0 
    cnt = 0
    while flag:
        flag = False
        for j in range(N-1, i, -1):
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1],A[j]
                cnt += 1
                flag = True
        i += 1
    return cnt

N = int(input())
A = list(map(int, input().split()))
cnt = bubble_sort(A)
print(' '.join(list(map(str, A))))
print(cnt)



Measured memory_bytes: 5600
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
def sn(a,n):
  c=0
  for i in a:
    if i<n:
      c+=1
  return c
def comb(n):
  k=1
  if n<=1:
    return 1
  for i in range(1,n+1):
    k=k*i
  return k
def numberorder(a,n):
  s=set({})
  for i in range(1,n+1):
    s=s|{i}
  c=0
  for p in range(n):
    c+=(sn(s,a[p]))*comb(n-1-p)
    s=s-{a[p]}
  return c
P_num=numberorder(P,N)
Q_num=numberorder(Q,N)
print(abs(P_num-Q_num))

Measured memory_bytes: 3064
/*|In The Name of Allah|*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pair<int,int> > vii;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> pii;
#define el	'\n'
#define lp(i,n) for(int i = 0;i < int(n);i++)
#define rlp(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rng(i,a,b) for(int i = int(a);i <= int(b);i++)
#define mp(x,y)  	make_pair((x),(y))
#define pb(x)    	push_back((x))
#define all(v)  	((v).begin()),((v).end())
#define sz(x)  		((int) (x).size())
#define bits(a) 	__builtin_popcountll(a)
#define fr first
#define sc second
#define pii pair<int, int>
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define SS stringstream
#define ll long long
#define clr(x, y) memset(x, y, sizeof(x))
#define foreach(it,x) for(__typeof__((x).begin()) it = (x).begin(); it != (x).end(); ++it)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
ll gcd(ll a, ll b){if (a == 0)return b;return gcd(b % a, a);}



void MisSiOn_ImPosSiBlE(){
//freopen("portals.in", "r", stdin);
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

}


int const N = 5e6 + 9, mod = 1e9+7 , oo = 0x3f3f3f3f;
//------------------------------------------------------------------------------------

int cnt=0;
string str;
int n,k,m;
int getlastone(int i){
while(i<n&&str[i]=='1')i++;
return i-1;
}
int getlastzero(int i){
while(i<n&&str[i]=='0')i++;
return i-1;
}
int main()
{


    MisSiOn_ImPosSiBlE();
    cin>>n>>k;
    cin>>str;
    int lo=0,hi=0;
    while(lo<n){
        while(hi<n&&cnt<=k){
            if (str[hi]=='0'&&cnt==k)break;
            if (str[hi]=='0'){
            hi=getlastzero(hi);
            cnt++;
            }
        else  if (str[hi]=='1'){
            hi=getlastone(hi);
            }
            hi++;
        }
        m=max(m,hi-lo);
        if (str[lo]=='0'){
            lo=getlastzero(lo);
            cnt--;
        }
        else if (str[lo]=='1'){
            lo=getlastone(lo);
        }
        lo++;
    }
cout<<m;
















/*
*/
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    bool ok = true;
    rep(i, n - 1) if (p[i] > p[i + 1]) ok = false;
    if (ok)
    {
        cout << "YES" << endl;
        return 0;
    }
    rep(i, n)
    {
        rep(j, n)
        {
            if (p[i] > p[j])
            {
                swap(p[i], p[j]);
                ok = true;
                rep(k, n - 1) if (p[k] > p[k + 1]) ok = false;
                if (ok)
                {
                    cout << "YES" << endl;
                    return 0;
                }
                swap(p[i], p[j]);
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main()
{
	int h, m1 ,m2, s;
	int S;

cin >> S;
if(S>=0 && S<=86400)
	{
		h = S/3600;
		m1 = S % 3600;
    m2 = m1/60;
    s = m1 % 60;

    cout << h <<":"<< m2 <<":"<< s <<endl;
	}
else
  {
  cout <<"error" <<endl;
  }

return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int dp[100][2][100];//dp[keta][未満である][0でない数の個数]

struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};
int main(){
    int N;cin >> N;
    string S;cin >> S;
    int i[3];
    int ans = 0;
    for(i[0] = 0;i[0] < 10;++i[0]){
        for(i[1] = 0;i[1] < 10;++i[1]){
            for(i[2] = 0;i[2] < 10;++i[2]){
                int j = 0,k = 0;
                while(j < 3 && k < N){
                    if(i[j] == S[k] - '0'){
                        ++j;
                        ++k;
                    }else{
                        ++k;
                    }
                }
                if(j == 3)
                    ans++;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
while True:
    a, b = map(int,input().split())
    if a==0 and b==0:
        break
    if a <= b:
        a, b = b, a
    d = 1
    while True:
        c = a%b
        if c==0:
            break
        if c!=0:
            a,b = b, c
            d += 1
    print(b,d)


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

using namespace std;

#define ll long long

int main(void){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    int flag = 0;

    if((m1+1) == m2 || (m1==12 && m2==1)){
        if(d2 == 1){
            flag = 1;
        }
    }

    cout << flag << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#define REP(i,x) for(int i=0; i<(x); i++)

using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int T, P;
string N;
vector<int> ans;
bool dbld = false;

void show_vector(vector<int> v) {
    for(auto e : v) cout << e << " ";
    cout << endl;
}

void solve(int p, vector<int> v) {
    if(p == N.length()) {
        int sum = 0;
        rep(i,0,v.size()) sum += v[i];
        if(T >= sum) {
            if(P < sum) {
                P = sum;
                ans = v;
                dbld = false;
            }
            else if(P == sum) {
                // show_vector(v);
                dbld = true;
            }
        }
    }
    else {
        int val = N[p] - '0';
        int idx = v.size() - 1;
        vector<int> s = v, t = v;
        s[idx] *= 10; s[idx] += val;
        t.push_back(val);
        solve(p+1, s);
        if(p != 0) solve(p+1, t);
    }
}

signed main() {
    while(cin >> T >> N, T) {
        P = -1; dbld = false;

        vector<int> INIT(1, 0);
        solve(0, INIT);

        if(P == -1) cout << "error" << endl;
        else if(dbld) cout << "rejected" << endl;
        else {
            printf("%lld", P);
            rep(i,0,ans.size()) printf(" %lld", ans[i]);
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	int n;
	while (cin >> n && n){
		int a = 0, b = 0;
		FOR(i, n){
			int s, t; cin >> s >> t;
			if (s > t) a += s + t;
			else if (s < t) b += s + t;
			else a += s, b += t;
		}

		cout << a << " " << b << endl;
 	}

	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int ans=1;
  for(int i=0;i<n;i++){
    if(ans<k)
      ans*=2;
    else
      ans+=k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    ll x;
    cin >> x;
    ll res = x / 11 * 2;
    x %= 11;
    if(x != 0) {
        res += (x > 6 ? 2 : 1);
    }
    cout << res << endl;
}


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

using namespace std;


#define M_DEBUG if(0)


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

	typedef

******************************************************************************/
typedef unsigned long long int ullint;


/*! Main */
int main() {
	ullint n = 0;
	ullint k = 0;
	ullint q = 0;
	cin >> n >> k >> q;
	// cout << n << " " << k << " " << q << endl;
	assert(n >= 2 && n <= 100000);
	assert(k >= 1 && k <= 1000000000);
	assert(q >= 1 && q <= 100000);

	ullint *points_pls = new ullint[n]{0}; // 加点を集計
	M_DEBUG {
		cout << "----- Ininialize : points_pls ----------------------" << endl;
		for (ullint i = 0; i < n; i++) {
			cout << "points_pls[" << i << "]: " << points_pls[i] << endl;
		}
		cout << "----------------------------------------------------" << endl;
	}
	for (ullint i = 1; i <= q; i++) {
		ullint a_i = 0;
		cin >> a_i ;
		assert(a_i >= 1 && a_i <= n);
		points_pls[a_i-1] += 1; // points_pls[i] <- A_{i+1}
	}
	M_DEBUG {
		cout << "----- Point added : points_pls ---------------------" << endl;
		for (ullint i = 0; i < n; i++) {
			cout << "points_pls[" << i << "]: " << points_pls[i] << endl;
		}
		cout << "----------------------------------------------------" << endl;
	}
	for (ullint i = 0; i < n; i++) {
		M_DEBUG cout << "k: " << k << ", points_pls[i]:" << points_pls[i] << ", q:" << q << endl;
		M_DEBUG cout << "Point of A_" << i+1 << " > 0 ? : " << (k + points_pls[i] > q) << endl; // これが全ラウンド終了時点のポイント
		string answer = (k + points_pls[i] > q)? "Yes" : "No";
		cout << answer << endl;
	}

	delete[] points_pls;
	return 0;
}


Measured memory_bytes: 1408
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >>A >> B;
  ll max_ab = max(A+B, A-B);
  max_ab = max(max_ab, A*B);
  
  
  cout << max_ab << endl;
}


Measured memory_bytes: 256
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";
// vector<bad()ool> v(1E5, false);




int main()
{
    fastio;
    ll a[3][3];
    bool b[3][3];
    loop(i,0,3)loop(j,0,3)cin>>a[i][j];
    ll n;cin>>n;
    map<ll,bool> m;
    loop(i,0,n){
        ll x;cin>>x;
        m[x]=true;
    }
    loop(i,0,3){
        loop(j,0,3){
            if(m[a[i][j]])
                b[i][j] = true;
            else
                b[i][j] = false;
        }
    }

    if(b[0][0] && b[0][1] && b[0][2])
        cout<<yes;
    elif(b[0][0]&&b[1][1]&&b[2][2])
        cout<<yes;
    elif(b[0][0]&&b[1][0]&&b[2][0])
        cout<<yes;
    elif(b[0][1]&&b[1][1]&&b[2][1])
        cout<<yes;
    elif(b[0][2]&&b[1][2]&&b[2][2])
        cout<<yes;
    elif(b[0][2]&&b[1][1]&&b[2][0])
        cout<<yes;
    elif(b[1][0]&&b[1][1]&&b[1][2])
        cout<<yes;
    elif(b[2][0]&&b[2][1]&&b[2][2])
        cout<<yes;
    else
        cout<<no;


}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        ArrayList<Integer> list = new ArrayList<>();

        int cnt = 1;
        for (int i = 0; i<N; i++) {
            int sc = scanner.nextInt();
            if (sc == cnt) {
                list.add(cnt++);
            }
        }

        int rst =  N - list.size();
        System.out.println(rst == N ? -1 : rst);
    }
}

Measured memory_bytes: 83132
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
map<int,map<int,int> >m;
int f[9][8][2]={-2,-2,-2,-1,-2,0,-1,-2,-1,-1,-1,0,0,-2,0,-1,
                -2,-1,-2,0,-2,1,-1,-1,-1,0,-1,1,0,-1,0,1,
                -2,0,-2,1,-2,2,-1,0,-1,1,-1,2,0,1,0,2,
                -1,-2,-1,-1,-1,0,0,-2,0,-1,1,0,1,-2,1,-1,
                -1,-1,-1,0,-1,1,0,-1,1,0,0,1,1,-1,1,1,
                -1,0,-1,1,-1,2,1,0,0,1,0,2,1,1,1,2,
                0,-2,0,-1,1,-2,1,-1,1,0,2,-2,2,-1,2,0,
                0,-1,0,1,1,-1,1,0,1,-1,2,-1,2,0,2,1,
                0,1,0,2,1,0,1,1,1,2,2,0,2,1,2,2
                };
LL ans[15];
int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    ans[0]=1LL*(h-2)*(w-2);
    while(n--){
        int a,b;
        cin>>a>>b;
        for(int i=a-1;i<=a+1;i++){
            if(i<=0||i>h) continue;
            for(int j=b-1;j<=b+1;j++){
                if(j<=0||j>w) continue;
                int cnt=0,flag=1;
                for(int ii=i-1;ii<=i+1&&flag;ii++){
                    if(ii<=0||ii>h) flag=0;
                    for(int jj=j-1;jj<=j+1&&flag;jj++){
                        if(jj<=0||jj>w) flag=0;
                        if(m[ii][jj]) cnt++;
                    }
                }
                if(!flag) continue;
                ans[cnt]--;
                ans[cnt+1]++;
            }
        }
//        for(int i=0;i<9;i++){
//            int cnt=0,flag=1;
//            for(int j=0;j<8&&flag;j++){
//                int x=a+f[i][j][0];
//                int y=b+f[i][j][1];
//                if(x<=0||x>h||y<=0||y>w) flag=0;
//                if(m[x][y]){
//                    cnt++;
//                }
//            }
//            if(!flag) continue;
//            ans[cnt]--;
//            ans[cnt+1]++;
//        }
        m[a][b]=1;
//        for(int i=0;i<10;i++) cout<<ans[i]<<" ";
//        puts("");
    }
    if(h<3||w<3) memset(ans,0,sizeof ans);
    for(int i=0;i<10;i++) cout<<ans[i]<<endl;
    return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M)
{
  int ret = n % m;
  if (ret < 0)
    ret += m;
  return ret;
}

int exp(int n, int k)
{
  if (k == 0)
    return 1;
  if (k == 1)
    return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2)
    ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b)
{
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution()
{
  int lst = 0;
  int n;
  cin >> n;
  int ans = 0;
  rep(i, 0, n, 1)
  {
    int x;
    cin >> x;
    ans += max(0LL, lst - x);
    lst = max(lst, x);
  }
  cout << ans << endl;
}

int32_t main()
{
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--)
    solution();
}


Measured memory_bytes: 3652
def function(n, a)
	a.each do |c|
		if (c % 2).zero? && !(c % 3).zero? && !(c % 5).zero?
			return 'DENIED'
		end
	end
	'APPROVED'
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
puts function(n, a)


Measured memory_bytes: 3836