akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
import heapq

def main():
  less = []
  greater = []
  s = 0
  sum_ = 0
  q = int(input())
  def query(n):
    nonlocal s, sum_
    if n[0] == "1":
      c, a, b = map(int, n.split())
      s += b
      if len(less) == len(greater):
        if not greater or a <= greater[0]:
          heapq.heappush(less, -a)
          sum_ -= a
        else:
          r = heapq.heappushpop(greater, a)
          heapq.heappush(less, -r)
          sum_ += a - 2*r
      else:
        if a >= -less[0]:
          heapq.heappush(greater, a)
          sum_ += a
        else:
          r = -heapq.heappushpop(less, -a)
          heapq.heappush(greater, r)
          sum_ += 2*r - a
    else:
      res = sum_
      if len(less) > len(greater):
        res -= less[0]
      res += s
      print(-less[0], res)

  for _ in range(q):
    k = input()
    query(k)
    
if __name__ == "__main__":
  main()

Measured memory_bytes: 11140
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool N = false;
	bool W = false;
	bool S = false;
	bool E = false;
	int i;
	for (i = 0; i<s.length(); ++i){
		if (s[i] == 'N')
			N = true;
		if (s[i] == 'W')
			W = true;
		if (s[i] == 'S')
			S = true;
		if (s[i] == 'E')
			E = true;
	}
	if (N == S && W == E)
		cout << "Yes\n";
	else 
		cout << "No\n";
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
import random
import time

t0 = time.time()

H, W, M = map(int, input().split())
count_h = [0] * H
count_w = [0] * W
bomb = set()
for _ in range(M):
    h, w = map(int, input().split())
    bomb.add((h-1, w-1))
    count_h[h-1] += 1
    count_w[w-1] += 1

max_count_h = max(count_h)
max_count_w = max(count_w)

hs = [h for h in range(H) if count_h[h] == max_count_h]
ws = [w for w in range(W) if count_w[w] == max_count_w]

# H, W, M, bomb, count_h, count_w, hs, ws

ans = max_count_h + max_count_w

# t0 = time.time()
flag = False
while time.time() - t0 < 2.8:
    h = random.choice(hs)
    w = random.choice(ws)
    if (h, w) not in bomb:
#         print(h, w)
        flag = True
        break
if flag:
    print(ans)
else:
    print(ans - 1)
    

Measured memory_bytes: 83908
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}

ll dp[3456][3456];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll n, cnt = 0, ok = 6; cin >> n;
	while(cnt != n) {
		while (!isprime(ok)) { ok += 5; }
		if (cnt == 0) { cout << ok; }
		else { cout << ' ' << ok; }
		cnt++; ok += 5;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3556
n = int(input())
p = [int(x) for x in input().split()]
count = 0
for i in range(n):
    if i != 0 and i != n-1:
        if p[i-1] < p[i] and p[i] < p[i+1]:
            count += 1
        elif p[i-1] >  p[i] and p[i] > p[i+1]:
            count += 1

print(count)

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {
/*
    for (int h = 1; h < 100; h++) {
        int now = 0;
        vector<int> current = {h};
        while (!current.empty()) {
            vector<int> next;
            for (int k : current) {
                now++;
                if (k == 1) continue;
                next.push_back(k / 2);
                next.push_back(k / 2);
            }
            current = next;
            next = {};
        }
        cout << now << endl;
    }
*/

//    for (int h = 1; h < 100; h++) {

    ll h;
    cin >> h;

    ll current = 1;
    ll i = 0;
    while (current <= h) {
        i++;
        current *= 2;
    }

    cout << (1ll << i) - 1 << endl;
//    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, k;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k>>s;
    s=s.c_str();
    if(s[k-1]=='A')s[k-1]='a';
    if(s[k-1]=='B')s[k-1]='b';
    if(s[k-1]=='C')s[k-1]='c';
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
int n,k,a[55];
signed main() {
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	int ans=0;
	rep(i,k)ans+=a[i];
	cout<<ans<<endl;
}


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

#define INF 1e9

using namespace std;

const string MINUSINF = "-";

void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i) cin >> A[i];

    // 初期化
         for (int i = 0; i < 11000; ++i) dp[i] = MINUSINF;
    
             // 初期条件
                 dp[0] = "";
    
                     // DP ループ
                         for (int i = 0; i <= N; ++i) {
                                 if (dp[i] == MINUSINF) continue;
                                         for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
                                             }
                                                 cout << dp[N] << endl;
                                                 }


Measured memory_bytes: 43776
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0; char ch = getchar();
	while( ch < '0' || ch > '9' ) ch = getchar();
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc;
}

const int MAXN = 100010;
const int INF = 1e9 + 7;

int n, a[MAXN], b[MAXN], c[MAXN], d[MAXN], ans[MAXN], cur;
bool usd[MAXN];
priority_queue < pa > q;
vector < pa > v[MAXN];

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ ) a[ i ] = read(), b[ i ] = read();
	for( int i = 1 ; i <= n + 1 ; i++ ) c[ i ] = read();
	int Q = read();
	sort( c + 1, c + n + 2 );
	for( int i = 1 ; i <= n ; i++ ) a[ i ] = lower_bound( c + 1, c + n + 2, a[ i ] ) - c, b[ i ] = lower_bound( c + 1, c + n + 2, b[ i ] ) - c;
	for( int i = 1 ; i <= n ; i++ ) d[ a[ i ] - 1 ]--, v[ a[ i ] - 1 ].pb( mp( -b[ i ], i ) );
	d[ n + 2 ] = n;
	for( int i = n + 1 ; i ; i-- )
	{
		for( auto y : v[ i ] ) q.push( y );
		for( d[ i ] += d[ i + 1 ] ; d[ i ] - i < -1 ; q.pop() )
		{
			if( q.empty() || -q.top().xx > i ) goto yjq;
			usd[ q.top().yy ] = 1; d[ i ]++; d[ -q.top().xx - 1 ]--; ans[ 0 ]++;
		}
	}
	fill( d, 0 ); while( !q.empty() ) q.pop();
	for( int i = 1 ; i <= n ; i++ ) v[ i ].clear();
	for( int i = 1 ; i <= n ; i++ ) { d[ usd[ i ] ? b[ i ] : a[ i ] ]++; if( !usd[ i ] ) v[ b[ i ] ].pb( mp( a[ i ] - 1, i ) ); } 
	for( int i = 1 ; i <= n + 1 ; i++ )
	{
		for( auto y : v[ i ] ) q.push( y );
		d[ i ] += d[ i - 1 ]; ans[ i ] = ans[ i - 1 ];
		if( d[ i ] - i == -1 && cur < i )
		{
			if( q.empty() || q.top().xx < i ) ans[ i ] = INF;
			else cur = q.top().xx, q.pop(), ans[ i ]++;
		}
	}
	while( Q-- )
	{
		int a = lower_bound( c + 1, c + n + 2, read() ) - c - 1, b = lower_bound( c + 1, c + n + 2, read() ) - c - 1, ret;
		ret = min( ans[ a ], ans[ b ] + 1 );
		if( ret > n + 1 ) puts( "-1" );
		else printf( "%d\n", n + 1 - ret );
	}
	return 0;
yjq:while( Q-- ) puts( "-1" );
	return 0;
}


Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[200008], cnt[200008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	memset(cnt, 0, sizeof(cnt));
	cin >> n;
	zep(i, 0, n){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	ll ans = 0;
	rep(i, 1, n){
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	
	zep(i, 0, n){
		print(ans-cnt[a[i]]*(cnt[a[i]]-1)/2+(cnt[a[i]]-1)*(cnt[a[i]]-2)/2)
	}
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			Dictionary<string, string> decode = new Dictionary<string, string>()
			{
				{ "101"		, " " }, { "000000"	, "'" }, { "000011"	, "," }, { "10010001"	, "-" },
				{ "010001"	, "." }, { "000001"	, "?" }, { "100101"	, "A" }, { "10011010"	, "B" },
				{ "0101"	, "C" }, { "0001"	, "D" }, { "110"	, "E" }, { "01001"		, "F" },
				{ "10011011", "G" }, { "010000"	, "H" }, { "0111"	, "I" }, { "10011000"	, "J" },
				{ "0110"	, "K" }, { "00100"	, "L" }, { "10011001", "M"}, { "10011110"	, "N" },
				{ "00101"	, "O" }, { "111"	, "P" }, { "10011111", "Q"}, { "1000"		, "R" },
				{ "00110"	, "S" }, { "00111"	, "T" }, { "10011100", "U"}, { "10011101"	, "V" },
				{ "000010"	, "W" }, { "10010010", "X"}, { "10010011", "Y"}, { "10010000"	, "Z" }
			};
			Dictionary<string, string> encode = new Dictionary<string, string>()
			{
				{ "A", "00000" }, { "B", "00001" }, { "C" , "00010" }, { "D", "00011" },
				{ "E", "00100" }, { "F", "00101" }, { "G" , "00110" }, { "H", "00111" },
				{ "I", "01000" }, { "J", "01001" }, { "K" , "01010" }, { "L", "01011" },
				{ "M", "01100" }, { "N", "01101" }, { "O" , "01110" }, { "P", "01111" },
				{ "Q", "10000" }, { "R", "10001" }, { "S" , "10010" }, { "T", "10011" },
				{ "U", "10100" }, { "V", "10101" }, { "W" , "10110" }, { "X", "10111" },
				{ "Y", "11000" }, { "Z", "11001" }, { " " , "11010" }, { ".", "11011" },
				{ ",", "11100" }, { "-", "11101" }, { "'" , "11110" }, { "?", "11111" },
			};

			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var r1 = string.Join("", s.Select(c => encode[c.ToString()]).ToArray());
				var r = "";
				while (r1.Contains("1") || r1.Contains("000000"))
				{
					foreach (var d in decode)
					{
						if (r1.StartsWith(d.Key))
						{
							r += d.Value;
							r1 = r1.Substring(d.Key.Length);
						}
					}
				}
				Console.WriteLine(r);
			}
		}
	}
}

Measured memory_bytes: 7216
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m-1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main(){
	int n;
	llint t[2] = { 0 };
	int s = 0,y=0;
	cin >> n;
	hei(llint) a(n+1);
	rep(i, 0, n)cin >> a[i];
	
	sort(a);
	reverse(a);
	int x = 1;
	rep(i, 0, n) {
		if (y == 2)break;
		if (a[i] == a[i + 1]) {
			x++;
		}
		if (x > 1 + s) {
			t[y] = a[i];
			y++;
			s+=2;
		}
		if (a[i] != a[i + 1]) {
			s = 0;
			x = 1;
		}
		
	}
	llint ans = t[1] * t[0];
	cout << ans << endl;

	return 0;
}




  


Measured memory_bytes: 1024
import fractions

N = int(input())
A = [int(i) for i in input().split()]

L = [0]
for i in range(N):
        L.append(fractions.gcd(L[i], A[i]))

R = [0] * (N+1)
for i in reversed(range(N)):
        R[i] = (fractions.gcd(R[i+1], A[i]))

ans = []
for i in range(N):
        ans.append(fractions.gcd(L[i], R[i+1]))

print(max(ans))

Measured memory_bytes: 16116
#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 main() {
    int n;
    cin >> n;

    bool f = false;

    for (int i = 0; i * 4 <= 100; i++) {
        for (int j = 0; j * 7 <= 100; j++) {
            if (4 * i + 7 * j == n) {
                f = true;
                break;
            }
        }
    }

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    long long N,M; cin >> N >> M;
    long long ans=0;
    if(N<=M/2){
        ans+=N;
        M-=2*N;
        ans+=M/4;
    }else{
        ans+=M/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
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 java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long alice = 0, bob = 0;
		for(int i = 0; i < n; i++) {
			if(i%2==0) {
				alice += arr[n - 1 - i];
			} else {
				bob += arr[n - 1 - i];
			}
		}
		System.out.println(alice - bob);
	}
}

Measured memory_bytes: 21972
n = int(input())
s = input()
mod = 10**9 + 7

D = [[0] * (n+1) for i in range(n)]
D[0][0] = 1
for i in range(1, n):
    if s[i-1] == "<":
        for j in range(i):
            D[i][0] = (D[i][0] + D[i-1][j]) % mod
            D[i][j+1] = (D[i][j+1] - D[i-1][j]) % mod
    else:
        for j in range(i):
            D[i][j+1] = (D[i][j+1] + D[i-1][j]) % mod
            D[i][i+1] = (D[i][i+1] - D[i-1][j]) % mod
    for j in range(1, n+1):
        D[i][j] = (D[i][j] + D[i][j-1]) % mod
# print(D)
print(sum(D[-1]) % mod)

Measured memory_bytes: 136772
s = input()
t = ''
for i in range(len(s)):
    if s[i]!='x':
        t += s[i]
for i in range(len(t)):
    if t[i]!=t[-1-i]:
        print(-1)
        break
else:
    ans = 0
    L = []
    R = []
    prevl = -1
    prevr = len(s)
    for i in range(len(s)):
        if s[i]!='x':
            L.append(i-prevl-1)
            prevl = i
        if s[-1-i]!='x':
            R.append(prevr-(len(s)-1-i)-1)
            prevr = len(s)-1-i
    L.append(len(s)-prevl-1)
    R.append(prevr)
    for i in range(len(L)):
        ans += abs(L[i]-R[i])
    print(ans//2)

Measured memory_bytes: 4916
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)

void Main() {
	int a, b; cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1;
		return;
	}
	cout << a * b;
}


signed main() {
	Main();

	return 0;
}


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

int main(void) {
  int alp[26] = {0};  
  string str;
  int cnt = 0;

  cin >> str;

  for (int i=0; str[i] != '\0'; i++) {
    alp[str[i] - 'A'] += 1;
  } 

  for (int i=0; i<26; i++) {
    if (alp[i] == 2) {
      cnt += 1;
    }
  }

  if (cnt == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n), n){
    map<int, int> m;
    for(int i = 0; i < n; i++){
      int a; scanf("%d", &a);
      m[a]++;
    }

    int ans = -1;
    for(map<int, int>::iterator it = m.begin(); it != m.end(); it++)
      if(it->second > n / 2) ans = it->first;

    if(ans == -1)
      puts("NO COLOR");
    else
      printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1956
#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

inline void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0, p; char f[7];
	while (x) {
		p = x; x /= 10;
		f[s++] = p - (x << 1) - (x << 3);
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], h3[100003], h4[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int Q1[110000], Q1L, Q1R;
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	Q1[0] = 1; Q1R = 1;
	int rn = 0;
	while (Q1R > Q1L) {
		int a1 = Q1[Q1L]; Q1L++;
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1[Q1R] = i; Q1R++; rn = dist[i];
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) h3[dist[i]]++;
	for (int i = 0; i <= rn; i++) D[i].resize(h3[i]);
	for (int i = 1; i <= n; i++) D[dist[i]][h4[dist[i]]] = i, h4[dist[i]]++;
	e[1] = (1 << 30);
	for (int i = 1; i <= rn; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 25032
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
    long long x,y;
    cin>>x>>y;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    if(x%y)cout<<x<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
char in[20];
string str[210];
set<pair<long long,long long> > lis[210];
char ch[2];
inline pair<long long,long long> conv(string s){
	long long r1=0;
	long long r2=0;
	for(int i=0;i<s.size();i++){
		if(i<8){
			r1+=((long long)(s[i]-'a'+1))<<(i*5);
		}else r2+=((long long)(s[i]-'a'+1))<<((i-8)*5);
	}
	return make_pair(r1,r2);
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		int b;scanf("%d",&b);
		for(int i=0;i<a;i++){
			scanf("%s",in);
			str[i]=in;
		}
		std::sort(str,str+a);
		for(int i=0;i<a;i++)lis[i].clear();
		for(int i=0;i<a;i++){
			for(int j=0;j<str[i].size();j++){
				string tmp=str[i].substr(0,j)+str[i].substr(j+1);
				lis[i].insert(conv(tmp));
			}
			for(int j=0;j<=str[i].size();j++){
				for(int k=0;k<26;k++){
					string tmp=str[i].substr(0,j);
					ch[0]='a'+k;
					tmp.append(ch);
					tmp.append(str[i].substr(j));
					lis[i].insert(conv(tmp));
				}
			}
			for(int j=0;j<str[i].size();j++){
				char rev=str[i][j];
				for(int k=0;k<26;k++){
					str[i][j]='a'+k;
					lis[i].insert(conv(str[i]));
				}
				str[i][j]=rev;
			}
			for(int j=0;j<str[i].size()-1;j++){
				swap(str[i][j],str[i][j+1]);
				lis[i].insert(conv(str[i]));
				swap(str[i][j],str[i][j+1]);
			}
		//	std::sort(lis[i].begin(),lis[i].end());
		}
		int ret=0;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				bool ok=false;
				if(b==1){
					if(lis[i].count(conv(str[j])))ok=true;
				}else{
					for(set<pair<long long,long long> >::iterator it=lis[j].begin();it!=lis[j].end();it++){
						if(lis[i].count(*it)){
							ok=true;break;
						}
					}
				}
				if(ok){
					ret++;
					printf("%s,%s\n",str[i].c_str(),str[j].c_str());
				}
			}
		}
		printf("%d\n",ret);
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int a; cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}


Measured memory_bytes: 3644
from fractions import gcd

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

left = [0]
right = [0]

for i in range(n):
    left.append(gcd(left[i], a[i]))
    right.append(gcd(right[i], a[n - i - 1]))

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[n - i - 1]))

print(ans)

Measured memory_bytes: 16152
import sys
N = int(input())
for h in range(1,3501):
    for w in range(1,3501):
        if 4*h*w - N*(w+h) > 0:
            if N*h*w / (4*h*w - N*(w+h)) % 1 == 0:
                print(h,w,int(N*h*w / (4*h*w - N*(w+h))))
                sys.exit()

Measured memory_bytes: 9112
import math

def prime_num(num):
    if num < 2:
        return False
    for i in range(2,int(math.sqrt(num))+1):
        if (num % i == 0):
            return False
    return True

while True:
    a,d,n = map(int,raw_input().split())
    if a == 0 and d == 0 and n == 0:
        break
    hoge = (1000000-a)/d
    li = [a + d * i for i in range(hoge)]
    count = 0
    for i in li:
        if prime_num(i) == True:
            count += 1
        if count >= n:
                print i
                break

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  int res=0;
  int x;
  for(int i=0;i<n;i++){
    cin>>x;
    res += min(abs(0-x)*2,abs(k-x)*2);
  }
  cout<<res<<endl;

  return 0;
}


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

int main()
{
    int n,k,i;
    char *s;
    char a;
    scanf("%d",&n);
    s=(char*)malloc(n*sizeof(char));
    scanf("%s",s);
    scanf("%d",&k);
    a=s[k-1];
    for(i=0;i<n;i++)
    {
        if(a!=s[i]) s[i]='*';
    }
    printf("%s",s);
    free(s);
}

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

int INF = 1e9 +1;

int main(){

	int n; 
	cin >> n;

	int k;
	cin >> k;

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


	int dp[n] = {};
	for(int i = 0;i<n;i++){
		dp[i] = INF;
	}
	dp[0] = 0;

	for(int i = 0;i<n-1;i++){
		for(int j = 1;j<=k&&i+j<n;j++){
			dp[i+j] = min(dp[i+j],dp[i] + abs(arr[i] - arr[i+j]));
		}
	}

	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
		A[i] -= i + 1;
	}
	sort(ALL(A));
	int ans = 0;
	rep(i, N)ans += abs(A[i] - A[N / 2]);
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll nll ; cin >> nll;
    bitset<32> base("10101010101010101010101010101010");
    ll basell = base.to_ullong();
    basell *= -1;
    bitset<32> n(nll-basell);
    bitset<32> ans = (base ^ n);
    bool flag = false;
    for(int i=31;i>=0;i--){
        if(ans.test(i)) flag = true;
        if(flag){
            cout << (int)(ans.test(i)) ;
        }
    }
    if(!nll) cout << 0;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

n = int(input())
res = []

if n==0:
    print(0)
    sys.exit()
    
while n!=0:
    if n%2 == 1:
        res.append(1)
        n = (n-1)/(-2)
    else:
        res.append(0)
        n = n/(-2)


for i in reversed(res):
    print(i, end="")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, p[252521];
  cin>>n;
  int mi=1e9, ans=0;
  REP(i, n){
    cin>>p[i];
    if(p[i]<=mi){
      ++ans;
      mi=p[i];
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M); // 入力用配列
  vector<int> X(N,0);       // 出力用配列ゼロセット
  for (int i = 0; i < M; i++) { // 入力
    cin >> A.at(i) >> B.at(i);
  }  
  
  for (int i = 0; i < M; i++) { // 出力用配列でカウント
    X.at( A.at(i) -1 ) += 1;
    X.at( B.at(i) -1 ) += 1;
  }
  
  for  (int i = 0; i < N; i++) { //output
    cout  << X.at(i) << endl;
  }
  
}
    

Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    h, w, k = ns()
    mat = [list(input()) for _ in range(h)]

    if h == 1:
        tmp = max(0, mat[0].count("1") - 1)
        print(tmp // k)
        exit(0)

    ans = INF
    for i in range(2 ** (h - 1)):
        cut = format(i, "b").count("1")
        row = cut + 1

        cnt = [0 for _ in range(row)]

        idx_dic = dict()
        tmp_idx = 0
        for j in range(h):
            idx_dic[j] = tmp_idx
            if i >> j & 1:
                tmp_idx += 1

        tmp_ans = cut
        xi = 0
        brkflg = True
        while xi < w:
            yi = 0
            prev_brkflg = brkflg
            brkflg = False
            while yi < h:
                if mat[yi][xi] == "1":
                    cnt[idx_dic[yi]] += 1
                    if cnt[idx_dic[yi]] > k:
                        cnt = [0 for _ in range(row)]
                        xi -= 1
                        brkflg = True
                        tmp_ans += 1
                        break

                yi += 1
            if brkflg and prev_brkflg:
                tmp_ans = INF
                break
            xi += 1
        ans = min(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10832
n, x = map(int, input().split())
A = list(map(int, input().split()))


A = sorted(A)
t = 0
num = 0
if sum(A) < x:
    print(n - 1)
else:
    for i in A:
        if t + i <= x:
            t += i
            num += 1
        else:
            break
    print(num)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>

int main() {
  int H, W, cnt = 0;
  std::cin >> H >> W;
  std::vector<int> s(H*W);
  char c;
  for (int j=0; j<H; j++) {
    for (int i=0; i<W; i++) {
      std::cin >> c;
      if (c == '.') {
        s[j*W+i] = -1;
        cnt++;
      } else {
        s[j*W+i] = -2;
      }
    }
  }
  
  std::queue<int> next_x, next_y;
  next_x.push(0);
  next_y.push(0);
  s[0*W+0] = 1;
  while(!next_x.empty()) {
    int x = next_x.front();
    int y = next_y.front();
    if (0 < x && s[y*W+(x-1)] == -1) {
      s[y*W+(x-1)] = s[y*W+x] + 1;
      next_x.push(x-1);
      next_y.push(y);
    }
    if (x < W-1 && s[y*W+(x+1)] == -1) {
      s[y*W+(x+1)] = s[y*W+x] + 1;
      next_x.push(x+1);
      next_y.push(y);
    }
    if (0 < y && s[(y-1)*W+x] == -1) {
      s[(y-1)*W+x] = s[y*W+x] + 1;
      next_x.push(x);
      next_y.push(y-1);
    }
    if (y < H-1 && s[(y+1)*W+x] == -1) {
      s[(y+1)*W+x] = s[y*W+x] + 1;
      next_x.push(x);
      next_y.push(y+1);
    }
    next_x.pop();
    next_y.pop();
  }
  
  if (s[(H-1)*W+(W-1)] == -1) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << cnt - s[(H-1)*W+(W-1)] << std::endl;
  }
  
  return 0;
}

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

long long cnt;
int l;
int A[1000000];
int n;
vector < int > G;
//间隔为g的插入排序 
void insertionSort(int A[],int n,int g)
{
	for(int i = g; i < n; i++)
	{
		int v = A[i];
		int j = i - g;
		while( j>= 0 && A[j] > v)
		{
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}
void shellSort(int A[],int n)
{
	for(int h = 1 ; ; )
	{
		if(h > n)
		break;
		G.push_back(h);
		h= 3*h + 1;
	}
	for(int i = G.size()-1 ; i >= 0 ; i--)
	{
		insertionSort(A , n , G[i] );
	}
}

int main()
{
  cin>>n;
  for(int i = 0;i < n; i++)
{
	cin>>A[i];
}
cnt = 0;
shellSort(A,n);

cout<<G.size()<<endl;
for(int i = G.size() - 1 ; i>=0 ; i-- )
{
	cout<<G[i];
	if(i!=0)
	{
		cout<<" ";
	 } 
  }
  cout<<endl;  
cout<<cnt<<endl;

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


Measured memory_bytes: 7044
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";

void solve(ll D, ll T, ll S) {
  cout << (T * S >= D ? YES : NO) <<endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll D;
  cin >> D;
  ll T;
  cin >> T;
  ll S;
  cin >> S;

  solve(D, T, S);

  return 0;
}


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

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

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int arr[n+5];
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    sort(arr,arr+n,greater<int>());

    int counter=0;
    double p = (sum/(1.0*4*m));
    for(int i=0;i<n;i++){
        if(arr[i]>=p) counter++;
        if(counter==m) break;
    }

    if(counter==m) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::vector<std::string> eval = {"AC", "WA", "TLE", "RE"};
	std::vector<int> cnt(4);

	int n; scanf("%d", &n);
	while(n--) {
		std::string s; cin >> s;

		for(int i = 0; i < 4; i++) {
			if(eval[i] != s) continue;

			cnt[i]++;
		}
	}

	for(int i = 0; i < 4; i++) printf("%s x %d\n", eval[i].c_str(), cnt[i]);
	return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5 + 77;
vector<int> g[MAXN];
vector<pii> edges;
int n;
int answ = 0;
int p[MAXN], c[MAXN], mod[MAXN];

void dfs(int v) {
	vector<int> used;
	int i = 0;

	for(auto& u: g[v]) {
		if(u != p[v]) {
			p[u] = v;
			dfs(u);

			mod[u] = (answ + i - c[u]) % answ;
			used.push_back((c[u] + mod[u]) % answ);
			++i;
		}
	}

	if(p[v] != NIL) {
		sort(used.begin(), used.end());

		if(used.empty() || used.front() > 0) {
			c[v] = 0;
		} else {
			for(int i = 0; i < len(used) - 1; ++i) {
				if(used[i] + 1 != used[i + 1]) {
					c[v] = used[i] + 1;
					break;
				}
			}

			if(c[v] == NIL) {
				c[v] = len(used);
			}
		}
	}
}

void dfs2(int v) {
	if(p[v] != NIL) {
		c[v] += mod[v];
		c[v] %= answ;
	}

	for(auto& u: g[v]) {
		if(u != p[v]) {
			mod[u] += mod[v];
			mod[u] %= answ;

			dfs2(u);
		}
	}
}

void solve() {
	cin >> n;

	for(int i = 0; i < n - 1; ++i) {
		int v = fetch<int>() - 1;
		int u = fetch<int>() - 1;

		g[v].push_back(u);
		g[u].push_back(v);

		edges.emplace_back(v, u);
	}

	memset(p, NIL, sizeof(p));
	memset(c, NIL, sizeof(c));

	for(int v = 0; v < n; ++v) {
		answ = max(answ, len(g[v]));
	}

	dfs(0); dfs2(0);
	cout << answ << '\n';

	for(auto& ed: edges) {
		int v = ed.first;
		int u = ed.second;	

		if(p[u] == v) {
			cout << c[u] + 1 << '\n';
		} else {
			cout << c[v] + 1 << '\n';
		}
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 11516
#include <iostream>
#include <vector>
#include <utility>
#include <string>

using namespace std;

int main() {
    int n, k;   cin >> n >> k;
    string s;
    cin >> s;

    int i = 0, c0 = 0;
    vector<pair<int, int> > v;
    if (s[0] == '0')
        v.push_back(pair<int,int>(1, 0));
    while (i < n) {
        int start = i;
        while (i+1 < n && s[i] == s[i+1])
            i++;
        
        if (s[start] == '0')
            c0++;

        v.push_back(pair<int,int>(s[start], i-start+1));
        i++;
    }
    if (s[n-1] == '0')
        v.push_back(pair<int,int>(1, 0));

    k = min(k, c0);
    vector<int> sum(2*c0+2, 0);
    for (int i = 0; i < 2*c0+1; i++) {
        sum[i+1] = sum[i] + v[i].second;
    }

    int ans = 0;
    for (int i = 2*k+1; i <= 2*c0+1; i += 2) {
        ans = max(ans, sum[i]-sum[i-2*k-1]);
    }

    cout << ans << endl;

    return 0;
}

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

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

    int cnt = 0;
    for (int i = 1; i <= N; i++){
        int temp = i;
        int sums = 0;
        while(temp > 0){
            sums += temp % 10;
            temp = temp/10;
        }
        if(sums >= A && sums <= B){
            cnt += i;
        }
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

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

	ll ans = N*(N-1)/2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define fill(x,t) memset(x,t,sizeof(x))
#define lb(x) (x&-x)
#define get(x) ((int)log2(x))

const int N=200005;

int r[25][N],f[25][N],sum[N];
int v[25][25];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void upd(int &x,int v) {
	(x<v)?(x=v):0;
}

int main(void) {
	int n=read(),m=read();
	int prt=0;
	rep(i,1,m) {
		int x=read()-1,y=read()-1;
		v[x][y]=v[y][x]=read(),prt+=v[x][y];
		r[x][1<<y]=v[x][y];
		r[y][1<<x]=v[x][y];
	}
	rep(i,0,n-1) {
		for (int S=0;S<(1<<n);++S) {
			r[i][S]=r[i][S-lb(S)]+r[i][lb(S)];
		}
	}
	for (int S=1;S<(1<<n);++S) {
		sum[S]=sum[S-lb(S)]+r[get(lb(S))][S-lb(S)];
	}
	fill(f,-63); f[0][1]=0;
	int ans=0;
	for (int S=1;S<(1<<n);++S) {
		rep(i,0,n-1) {
			// if (!((S>>i))&1) continue;
			// if (!(S&1)) continue;
			for (int T=S;T;T=(T-1)&S) {
				if (T>>i&1) upd(f[i][S],f[i][S-T+(1<<i)]+sum[T]);
			}
			rep(j,0,n-1) if (!(S>>j&1)&&v[i][j]) {
				upd(f[j][S+(1<<j)],f[i][S]+v[i][j]);
			}
		}
		if ((S&1)&&(S>>(n-1)&1)) upd(ans,f[n-1][S]);
	}
	printf("%d\n", prt-ans);
	return 0;
}

Measured memory_bytes: 32256