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

using namespace std;

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

typedef long long LL;

struct Edge {
  int from, to, cap, flow, index;
  Edge(int from, int to, int cap, int flow, int index) :
    from(from), to(to), cap(cap), flow(flow), index(index) {}
};

struct PushRelabel {
  int N;
  vector<vector<Edge> > G;
  vector<LL> excess;
  vector<int> dist, active, count;
  queue<int> Q;

  PushRelabel(int N) : N(N), G(N), excess(N), dist(N), active(N), count(2*N) {}

  void AddEdge(int from, int to, int cap) {
    G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
    if (from == to) G[from].back().index++;
    G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
  }

  void Enqueue(int v) {
    if (!active[v] && excess[v] > 0) { active[v] = true; Q.push(v); }
  }

  void Push(Edge &e) {
    int amt = int(min(excess[e.from], LL(e.cap - e.flow)));
    if (dist[e.from] <= dist[e.to] || amt == 0) return;
    e.flow += amt;
    G[e.to][e.index].flow -= amt;
    excess[e.to] += amt;
    excess[e.from] -= amt;
    Enqueue(e.to);
  }

  void Gap(int k) {
    for (int v = 0; v < N; v++) {
      if (dist[v] < k) continue;
      count[dist[v]]--;
      dist[v] = max(dist[v], N+1);
      count[dist[v]]++;
      Enqueue(v);
    }
  }

  void Relabel(int v) {
    count[dist[v]]--;
    dist[v] = 2*N;
    for (int i = 0; i < G[v].size(); i++)
      if (G[v][i].cap - G[v][i].flow > 0)
	dist[v] = min(dist[v], dist[G[v][i].to] + 1);
    count[dist[v]]++;
    Enqueue(v);
  }

  void Discharge(int v) {
    for (int i = 0; excess[v] > 0 && i < G[v].size(); i++) Push(G[v][i]);
    if (excess[v] > 0) {
      if (count[dist[v]] == 1)
	Gap(dist[v]);
      else
	Relabel(v);
    }
  }

  LL GetMaxFlow(int s, int t) {
    count[0] = N-1;
    count[N] = 1;
    dist[s] = N;
    active[s] = active[t] = true;
    for (int i = 0; i < G[s].size(); i++) {
      excess[s] += G[s][i].cap;
      Push(G[s][i]);
    }

    while (!Q.empty()) {
      int v = Q.front();
      Q.pop();
      active[v] = false;
      Discharge(v);
    }

    LL totflow = 0;
    for (int i = 0; i < G[s].size(); i++) totflow += G[s][i].flow;
    return totflow;
  }
};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n, m;
  cin>>n>>m;
  PushRelabel netw(n);
  for(int i = 0; i < m; i++){
    int a, b, c;
    cin>>a>>b>>c;
    netw.AddEdge(a, b, c);
  }
  cout<<netw.GetMaxFlow(0, n-1)<<"\n";
}

Measured memory_bytes: 3224
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

const int N_MAX = 100000;
const int INF = 1e9+10;

int N;
int h[N_MAX];
int dp[N_MAX];

void solve() {
  fill(dp, dp + N, INF);
  dp[0] = 0;
  FOR(i, 1, N - 1) {
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  // DUMP(dp, N);
  printf("%d\n", dp[N - 1]);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", h + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int ball[10];
bool flag;  //true??????YES???false??????NO
//?????°??§?§£????????????
void search(int left,int right,int d){//1??????????????°????????´?????????????????????????????????
                                      //2??????????????°????????´?????????????????????????????????
                                      //3??????????????°?????±???

  if(d==10){ //???????????????????????§??\???????????????
    flag=true;
    return;
  }
  if(left<ball[d]) //????????????????????\????????¨????????¶??????????????????
    search(ball[d],right,d+1);
  if(right<ball[d])//????????????????????\????????¨????????¶??????????????????
    search(left,ball[d],d+1);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    flag=false;//????????°????????????
    for(int j=0;j<10;j++)
      cin>>ball[j];
    search(ball[0],0,1);//????????????????????\??????????????????
                        //3??????????????°?????±???
                        //?????????????????\?????????????????\???????????????????????§
                        //????????\?????????????????????????????????
    if(flag)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void a_candy_easy(void) {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) sum += i;
	cout << sum << endl;
}

int main()
{
	a_candy_easy();
    return 0;
}

Measured memory_bytes: 3540
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize){n;list:(i64,i64)});
    list.into_iter()
        .max_by_key(|x| x.0)
        .map(|x| x.0 + x.1)
        .unwrap()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3\n4 7\n2 9\n6 2" => "8",
    test2: "5\n1 10\n3 6\n5 2\n4 4\n2 8" => "7",
    test3: "2\n1 1000000000\n1000000000 1" => "1000000001",
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    string s;
    string t;
    bool ans=false;
    char tmp;
    cin >> s;
    cin >> t;
    int n=s.size();
    for(int i=0; i<n; i++){
        if(s==t){
            ans=true;
            break;
        }else{
            tmp=s[n-1];
            for(int j=n-1; j>=1; j--){
                s[j]=s[j-1];
            }
            s[0]=tmp;
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 300005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

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

	// WRWWRWRR
	ll i,j,k,l,n;
	cin>>n;
	string s;
	cin>>s;
	ll an=0;
	i=0; j=n-1;
	while(i<j){
		if(s[i]=='W'){
			while(j>i){
				if(s[j]=='R') break;
				j--;
			}
			if(j>i){
				// cout<<i<<" "<<j<<endl;
				swap(s[i],s[j]);
				an++;
			}
		}
		i+=1;
	}
	cout<<an<<endl;
	return 0;	
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    	long long n;
    	scanf("%lld",&n);
    	long long v=1;
    	int cnt=0;
    	while(v<=n) v*=10,cnt++;
    	v/=10,cnt--;
    	int ans=cnt*9;
    	for(int i=2;i<=10;i++){
    		if(v*i-1<=n)
    			ans++;
    	}
    	printf("%d\n",ans);
    	return 0;
    }

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

int a[34], b[34];
int x[1010], y[1010];
bool t1, t2;

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d%d", &x[i], &y[i]);
		if(i != 1 && (( x[i] + y[i] ) & 1) != ((x[i - 1] + y[i - 1] ) & 1)) return 0 * puts("-1");
	}
	if((x[n] + y[n]) & 1) puts("31");
	else puts("32");
	for(int i = 30; i >= 1; i--) printf("%d ", 1 << i);
	if((x[n] + y[n]) & 1) puts("1");
	else puts("1 1");
	for(int i = 1; i <= n; i++)
	{
		bool flag = 0;
		t1 = t2 = 0;
		if(x[i] < 0) x[i] = -x[i], t1 = 1;
		if(y[i] < 0) y[i] = -y[i], t2 = 1;
		for(int j = 30; j >= 0; j--) a[j] = (x[i] >> j) & 1, b[j] = (y[i] >> j) & 1;
		for(int j = 30; j >= 1; j--)
		{
			bool ok = 0, ok2 = 0;
			int id = -1, id2 = -1;
			for(int k = j; k >= 0; k--) 
			{
				if(a[k] == 1) 
				{
					if(id == -1) id = k;
					else ok = 1;
				}
				if(b[k] == 1)
				{
					if(id2 == -1) id2 = k;
					else ok2 = 1;
				}
			}
			if(!ok && !ok2 && id2 == -1 && id == -1)
			{
				printf("L");
				for(int k = 1; k <= j + 1; k++) printf("R");
				flag = 1; break;
			}
			if(!ok && !ok2 && id == id2)
			{
				if(t1)
				{
					printf("L");
					for(int k = j - 1; k >= id; k--) printf("R");
				}
				else
				{
					printf("R");
					for(int k = j - 1; k >= id; k--) printf("L");
				}
				if(t2) for(int k = 1; k <= id + 1; k++) printf("D");
				else for(int k = 1; k <= id + 1; k++) printf("U");
				flag = 1; break;
			}
			if(a[j] == 1) {if(t1) printf("L"); else printf("R"); continue;}
			if(b[j] == 1) {if(t2) printf("D"); else printf("U"); continue;}
			for(int k = j - 1; k >= -1; k--)
			{
				if(a[k] != b[k] || k == -1)
				{
					if(k == -1 || a[k] == 1)
					{
						if(t1) printf("L"); else printf("R");
						t1 ^= 1;
						for(int o = j - 1; o >= 0; o--) a[o] ^= 1;
						a[0]++;
						for(int o = 0; o <= j - 1; o++) if(a[o] == 2) a[o] = 0, a[o + 1]++;
						break;
					}
					else
					{
						if(t2) printf("D"); else printf("U");
						t2 ^= 1;
						for(int o = j - 1; o >= 0; o--) b[o] ^= 1;
						b[0]++;
						for(int o = 0; o <= j - 1; o++) if(b[o] == 2) b[o] = 0, b[o + 1]++;
						break;
					}
				}
			}
		}
		if(flag) {puts(""); continue;}
		if(a[0] == 1 && b[0] == 1)
		{
			if(t1) printf("L"); else printf("R");
			if(t2) printf("D"); else printf("U");
		}
		else if(a[0] == 1 || b[0] == 1)
		{
			if(a[0] == 1) if(t1) printf("L"); else printf("R");
			else if(t2) printf("D"); else printf("U");
		}
		else  printf("LR");
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

long double a, b, c;
ll lA[2010], uA[2010], lB[2010], uB[2010], lC[2010], uC[2010];

void solve() {
	ll n, m;
	cin >> n >> m;
	cout << (n - 1) * n / 2 + (m - 1) * m / 2 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
 
int main() {
  int H, W; cin >> H >> W;
  int c[10][10] = {0};
  vector<vector<int>> A(H, vector<int>(W, 0));
  for (int i=0; i<10; i++) { for (int j=0; j<10; j++) cin >> c[i][j]; }
  for (int i=0; i<H; i++) { for (int j=0; j<W; j++) cin >> A[i][j]; }

  for (int epoch=0; epoch<10; epoch++) {
    for (int from=0; from<10; from++) { 
      for (int to=0; to<10; to++) {
        for (int via=0; via<10; via++) {
          c[from][to] = min(c[from][to], c[from][via] + c[via][to]);
        }
      }
    }
  }

  int result = 0;
  for (auto i: A) { for (auto j: i) { if (j != -1) result += c[j][1]; } }
    cout << result << endl;
  // for (int i=0; i<10; i++) { for (int j=0; j<10; j++) cout << c[i][j]; cout << endl;}
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[2000][2000],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
queue<ll> que[2000];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n){
        rep(j,n-1){
            cin>>a[i][j];
            a[i][j]--;
            que[i].push(a[i][j]);
        }
    }
    int ok=1;
    ll kai=0;
    rep(i,n*n/2+1){
        int judge=0;
        kai++;
        if(kai==100*n+1000){
            kai=LINF;
            break;
        }
        rep(j,n){
            if(que[j].empty())continue;
            judge=1;
        }
        if(judge==0)break;
        ll vi[n+10]={};
        rep(j,n){
            if(vi[j])continue;
            if(que[j].empty())continue;
            tmp=que[j].front();
            if(vi[tmp]==1)continue;
            ll saki;
            if(que[tmp].empty()){
                ok=0;
                break;
            }
            saki=que[tmp].front();
            //cout<<j<<" "<<tmp<<"\n";
            if(j==saki){
                vi[j]=1;
                que[j].pop();
                que[tmp].pop();
                vi[tmp]=1;
                cnt++;
                //Cout("ISAO");
                //cout<<j<<" "<<saki<<"\n";
            }
        }
        if(cnt==0)ok=0;
        if(!ok)break;
        ans++;
        cnt=0;
    }
    if(kai==LINF){
        Cout(n*(n-1)/2);
        return 0;
    }
    if(ok==0)Cout(-1);
    else Cout(ans);
    return 0;
}

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

int main(){
  long long N,P;
  cin >> N >> P;
  long long a;
  long long even=0,odd=0;
  for(long long i=0; i<N; i++){
    cin >> a;
    if(a%2==0) even++;
    else odd++;
  }
  //oddからP+2n個選びevenから2^k個選ぶとよい
  //
  long long result=0;
  if(odd==0&&P==1){
    cout << result << endl;
    return 0;
  }
  for(long long i=P; i<=odd; i+=2){
    //odd_C_i
    long long add=1;
    if(i>0){
      int k=min(i,odd-i);
      for(long long j=0; j<k; j++){
        add*=(odd-j);
      }
      for(long long j=1; j<=k; j++){
        add/=j;
      }
    }
    result+=add;
  }
  cout << fixed << setprecision(0);
  cout << result*pow(2,even) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int insersionsort(vector<int>&a, int g) {
	int ret(0);
	rep(i, g, a.size()) {
		int v = a[i];
		int j = i - g;
		while (0 <= j&&a[j] > v) {
			a[j + g] = a[j];
			ret++;
			j -= g;
		}
		a[j + g] = v;
	}
	return ret;
}
void shellsort(vector<int>&a) {
	vector<int>G;
	for (int x = 1; x <= a.size(); x = 3 * x + 1)G.push_back(x);
	reverse(all(G));
	int cnt(0);
	rep(i, 0, G.size())cnt += insersionsort(a, G[i]);
	cout << G.size() << endl;
	rep(i, 0, G.size())cout << G[i] << (i == G.size() - 1 ? '\n' : ' ');
	cout << cnt << endl;
	rep(i, 0, a.size())cout << a[i] << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	shellsort(a);
	return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N , R;
    cin >> N >> R;
    if(N >= 10) cout << R << endl;
    else {
        cout << 100 * (10 - N) + R << endl;
    }

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll K,A,B,ans=1;
	cin >> K >> A >> B;
	bool x;
	x = (B-A)>2;
	for(ll i=K;i>0;--i){
		if(ans>=A && x && i>1){
			ans += (B-A);
			i--;
		}else{
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string>S(H);
  for(int i=0;i<H;i++){
    cin>>S[i];}
  
  int count=0;
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      if(S[i][j]=='.'){
        count=0;
        for(int k=max(0,i-1); k<min(H,i+2); k++)
          for(int l=max(0,j-1); l<min(W,j+2); l++)
            if(S[k][l]=='#')
              count++;
        S[i][j]=count+'0';
      }
  for(int i=0; i<H; i++){
    cout<<S[i]<<endl;}
}


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

using namespace std;

int in()
{
    int a;
    scanf("%d",&a);
    return a;
}

int hobe[30000],hobe1[30000];

int main()
{
    int a=in(),b=in(),c=in(),d=in(),e=in(),f=in();
    hobe[0]=1;
    for(int i=1;i<=4000;i++)
    {
        if(i>=c)
        {
            if(hobe[i-c]==1)
                hobe[i]=1;
        }
        if(i>=d)
        {
            if(hobe[i-d]==1)
                hobe[i]=1;
        }
    }
    hobe1[0]=1;
    for(int i=1;i<=4000;i++)
    {
        if(i>=100*a)
        {
            if(hobe1[i-100*a]==1)
                hobe1[i]=1;
        }
        if(i>=100*b)
        {
            if(hobe1[i-100*b]==1)
                hobe[i]=1;
        }
    }
    int water,sugar,hoise=0;
    int mxl=-1,mxh=-1;
    for(int i=((f+1)/100)*100;i>=1;i-=100)
    {
        if(hobe1[i])
        {
            for(int j=min(f-i,((i+1)/100)*e);j>=1;j--)
            {
                if(hobe[j])
                {
                    if(mxl==-1)
                    {
                        hoise=1;
                        mxl=(100*j);
                        mxh=i+j;
                        water=i;
                        sugar=j;
                    }
                    else if((100*j)*mxh>(mxl*(i+j)))
                    {
                        mxl=(100*j);
                        mxh=i+j;
                        water=i;
                        sugar=j;
                    }
                }
            }
        }
    }
    if(!hoise)
    {
       printf("%d 0\n",a*100);
    }
    else
    printf("%d %d\n",water+sugar,sugar);
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i=0; i<n; i++) {
    cin >> x.at(i);
  }
  
  int res = 1e9;
  for (int i=0; i<=100; i++) {
    int tmp = 0;
    for (int j : x) {
      tmp += (j - i) * (j - i);
    }
    if (tmp < res) {
      res = tmp;
    }
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;
int main() {
	int N;
	cin >> N;
	vector<int>V;
	V.push_back(0);
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		V.push_back(a);
	}
	V.push_back(0);
	int S = 0;
	for (int i = 0; i < V.size()-1; ++i) {
		S += abs(V[i] - V[i + 1]);
	}
	for (int i = 1; i < V.size() - 1; ++i) {
		cout << S - abs(V[i - 1]-V[i]) - abs(V[i + 1]-V[i]) + abs(V[i + 1] - V[i - 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=1e9+7;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=2e6+5;
vi ln(N),idx(N,-1),Z,vals(N,-1),asked(N);
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n); 
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]); // use previous z val
        while (i + z[i] < n && s[z[i]] == s[i + z[i]]) // trivial matching
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1; // update rightmost segment matched
    }
    return z;
}
int get(int i){
	if(vals[i]>-1)
		return vals[i];
	if(idx[i]==-1)
		return vals[i]=ln[i];
	asked[i]=1;
	if(asked[idx[i]]){
		cout<<-1<<endl;
		exit(0);
	}
	vals[i]=ln[i]+get(idx[i]);
	asked[i]=0;
	return vals[i];
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	string s,t;cin>>s>>t;
	string s1=s;
	while(s.size()<=t.size())		
		s+=s1;
	string temp=t+"$"+s+s;
	Z=z_function(temp);
	int n=s.size(),m=t.size();
	int ans=0;
	for(int i=n-1;i>=0;i--){
		if(i+m-1>=n-1){
			int c=Z[i+m+1];
			if(c<m)continue;
			ans=1;
			ln[i]=1;
			idx[i]=m-(n-i);
			continue;
		}
		int c=Z[i+m+1];
		if(c<m)continue;
		ans=max(ans,1+ln[i+m]);
		ln[i]=1+ln[i+m];
		if(idx[i+m]>-1)
			idx[i]=idx[i+m];
	}
	for(int i=0;i<n;i++){
		ans=max(ans,get(i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 55948
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }


    var max = 0
    var cnt = 0

    var now = h[0]
    for(i in 1 until n) {
        if(h[i] <= now){
            cnt += 1
            now = h[i]
        } else {
            max = Math.max(cnt, max)
            cnt = 0
            now = h[i]
        }
    }
    max = Math.max(cnt, max)

    println(max)
}

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

#define INF 100000000
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  REP(i, N){
    cin >> a[i];
    a[i]--;
  }
  int next = 0;
  int count = 0;
  REP(i, 100000000){
    next = a[next];
    count++;
    if(next == 1){
      cout << count << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}



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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	int n = int(s.size());
	stack<char> c;
	for(int i = 0; i < n; ++i){
		if(s[i] == '0' || s[i] == '1'){
			c.push(s[i]);
		}else{
			if(c.size()) c.pop();
		}
	}
	string ans = "";
	while(c.size()){
		char ac = c.top();
		ans += ac;
		c.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		solve(s);
	}

	private static void solve(String s) {
		int lenR = 0;
		int lenL = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'R')
				lenR++;
			else
				lenL++;
			if (i < s.length() - 1)
				if (s.charAt(i) == 'L' && s.charAt(i + 1) == 'R') {
					printSolve(lenR, lenL);
					lenR = 0;
					lenL = 0;
				}
		}
		printSolve(lenR, lenL);
		System.out.println();
	}

	private static void printSolve(int lenR, int lenL) {
		for (int i = 1; i < lenR; i++)
			System.out.print("0 ");
		System.out.print((lenR - (lenR / 2) + (lenL / 2)) + " " + ((lenR / 2) + lenL - (lenL / 2)) + " ");
		for (int i = 1; i < lenL; i++)
			System.out.print("0 ");
	}
}


Measured memory_bytes: 32624
use proconio::input;
use proconio::marker::Chars;
use std::collections::VecDeque;

fn main() {
    input! {
        s: Chars,
        mut q: usize,
    }

    let mut queue = VecDeque::new();
    for c in s {
        queue.push_back(c);
    }

    let mut opposite = false;
    for _ in 0..q {
        input! {
            t: usize,
        }
        if t == 1 {
            opposite = !opposite;
        } else {
            input! {
                f: usize,
                c: char,
            }
            if (f == 1 && !opposite) || (f != 1 && opposite) {
                queue.push_front(c);
            } else {
                queue.push_back(c);
            }
        }
    }
    if !opposite {
        while queue.len() > 0 {
            print!("{}", queue.pop_front().unwrap());
        }
    } else {
        while queue.len() > 0 {
            print!("{}", queue.pop_back().unwrap());
        }
    }
    println!("");
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int h,w,c;
  c=0;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }
  int count;
  rep(i,h){
    rep(j,w){
      if(a.at(i).at(j)=='#')
        count++;
    }
  }
  vector<vector<int>> te(h,vector<int>(w,-1));
  queue<pair<int,int>> q;
  q.push(make_pair(0,0));
  te.at(0).at(0)=0;
  while(q.size()){
    auto z=q.front();
    q.pop();
    bool b=0;
    rep(i,4){
      int nx=dx[i]+z.first;
      int ny=dy[i]+z.second;
      if(!(nx>=0&&ny>=0&&nx<h&&ny<w))
        continue;
      if(te.at(nx).at(ny)!=-1)
        continue;
      if(a.at(nx).at(ny)=='#')
        continue;
      if(nx==h-1&&ny==w-1){
        b=1;
        c=te.at(z.first).at(z.second)+1;
        break;
      }
      q.push(make_pair(nx,ny));
      te.at(nx).at(ny)=te.at(z.first).at(z.second)+1;
    }
    if(b)
      break;
  }
  if(c==0)
    cout << "-1" << endl;
  else
    cout << h*w-count-c-1 <<  endl;
}
                         

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H, W, i, j;
    
    while(1)
    {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0)
        {
            break;
        }
        else
        {
            for(i = 0; i < H; i++)
            {
                for(j = 0; j < W; j++)
                {
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 572
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,i,j,t,cc=0,mn=1111111LL;
    cin>>n>>t;
    for(i=0;i<n;i++){
        ll x,y;cin>>x>>y;
        if(y<=t){
            cc=1;
            mn=min(x,mn);
        }
    }
    if(cc==0)cout<<"TLE"<<endl;
    else
    cout<<mn<<endl;
return 0;
}


Measured memory_bytes: 4992
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))

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


int main()
{
	int n, m, c, i;
	int city[51] = { 0 };
	cin >> n >> m;
	for (i = 0; i < m * 2; i++) {
		cin >> c;
		city[c]++;
	}

	for (i = 1; i <= n; i++) {
		cout << city[i] << endl;
	}

    return 0;
}



Measured memory_bytes: 256
L, R = gets.chomp.split(" ").map(&:to_i)
MOD = 2019
MOD2 = 673
MOD3 = 3

ans = 0
if (R - L) < (MOD - 1) && (L % MOD) < (R % MOD) then
  if ((R - L) > (MOD2 - 1) || (L % MOD2) >= (R % MOD2)) && ((R - L) > (MOD3 - 1) || (L % MOD3) >= (R % MOD3)) then
    # 3 * 673 = 2019
    ans = 0
  else
    ans = (L..R).to_a.combination(2).map{|a, b| (a * b) % MOD}.min
  end
end

puts ans


Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, count = 0;
  cin >> A >> B;
  for(int i = A; i <= B; i++) {
    int rev_val = 0;
    for(int j = 1; j < 10001; j *= 10) {
      rev_val += i / j % 10 * 10000 / j;
    }
    if(i == rev_val) {
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define sd(x) scanf("%d", &x)
#define sf(x)  scanf("%lf",&x)
#define rep(i,n) for(i=0;i<(n);++i)
#define swap(a,b) ((a != b) && (a += b,b = a - b,a -= b))       //2つの変数の内容を入れ替える
#define max(a, b) ((a) > (b) ? (a) : (b))           //指定された2つの引数のうち,最大のものを返す
#define min(a, b) ((a) < (b) ? (a) : (b))           //指定された2つの引数のうち,最小のものを返す

int i,j,k;          //forループ用

int main() {

    int a,b;
    sd(a);
    sd(b);

    if(a>=13)   printf("%d\n",b);
    else if(a<=5)   printf("%d\n",0);
    else    printf("%d\n",b/2);

 return 0;
}

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

int main(){
    vector<vector<int>> a(3, vector<int> (3, 0));
    for(int i = 0; i<3; i++) {
        for(int j = 0; j<3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i<n; i++) cin >> b[i];
    bool ans = false;

    for(int i = 0; i < 3; i++) {
        for ( int j = 0; j< 3; j++) {
            for(int k = 0; k<n; k++){
                if( a[i][j] == b[k] ) a[i][j] = -1;
            }
        }
    }

    if (a[0][0] == -1 && a[0][1] == -1 && a[0][2] == -1) ans = true;
    else if (a[1][0] == -1 && a[1][1] == -1 && a[1][2] == -1) ans = true;
    else if (a[2][0] == -1 && a[2][1] == -1 && a[2][2] == -1) ans = true;
    else if (a[0][0] == -1 && a[1][0] == -1 && a[2][0] == -1) ans = true;
    else if (a[0][1] == -1 && a[1][1] == -1 && a[2][1] == -1) ans = true;
    else if (a[0][2] == -1 && a[1][2] == -1 && a[2][2] == -1) ans = true;
    else if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) ans = true;
    else if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) ans = true;

    if(ans) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int h, n;
  cin >> h >> n;
  int sum = 0;
  REP(i, n) {
    int inp;
    cin >> inp;
    sum += inp;
  }
  if (sum >= h)
    yOUT;
  else
    nOUT;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N; cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll M = 10;
    ll res = 0;
    while (N / M > 0) {
        res += N / M;  
        M *= 5;
    }
    cout << res << endl;
}


Measured memory_bytes: 3632
def count_j(arg_ls, th, b_idx, e_idx):
	if b_idx-1 == e_idx: return 0
	if b_idx == e_idx: return int(arg_ls[b_idx] > th)
	cent_idx = (e_idx+1 - b_idx) // 2 + b_idx
	cent_j = arg_ls[cent_idx]
	if cent_j > th:
		return count_j(arg_ls, th, b_idx, cent_idx-1) + (e_idx+1 - cent_idx)
	else:
		return count_j(arg_ls, th, cent_idx, e_idx)

n = int(input())
inp_ls = input().split(" ")
a_ls = [int(e) for e in inp_ls[:n]]

i_dic = {}
for i,a in enumerate(a_ls):
	val = -a+(i+1)
	if val not in i_dic: i_dic[val] = []
	i_dic[val].append(i+1)

cnt = 0
for i in range(len(a_ls)):
	val = a_ls[i] + (i+1)
	cand_ls = i_dic.get(val, [])
	result = count_j(cand_ls, (i+1), 0, len(cand_ls)-1)
	cnt += result

print(cnt)

Measured memory_bytes: 77452
import java.util.Scanner;
public class Main{
	int X,a,b;
	
	public void solve(){
		Scanner sc=new Scanner(System.in);
		X=sc.nextInt();
		
		a=X*X;
		b=a*X;
		
		System.out.println(b);
	}
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int mod;

inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

const int N = 200005;
int a[N];
int pos[N], dp[N];
int main(){
	int n;
	sd(n);
	for(int i = 1; i <= n; i++) sd(a[i]), pos[a[i]] = i;
	int ans = 0;
	for(int i = n; i >= 1; i--){
		dp[i] = 1;
		if(i != n && pos[i + 1] > pos[i]) dp[i] = max(dp[i], dp[i + 1] + 1);
		ans = max(ans, dp[i]);
	}
	cout << n - ans;
}

Measured memory_bytes: 2560
#include <stdio.h>
 
int main(void) {
    int x=0,y=0;
    while(1){
        scanf("%d",&x);
        scanf("%d",&y);
        if(x==0 && y==0)break;
        if(x<y)printf("%d %d\n",x,y);
        else if(x>y)printf("%d %d\n",y,x);
        else printf("%d %d\n",x,y);
    }
	return 0;

}

Measured memory_bytes: 600
function main()
	N=parse(Int,readline())
	X=Pair{Int,Int}[]
	for i=1:N
		x,l=map(x->parse(Int,x),split(readline()))
		push!(X,x+l=>x-l)
	end
	sort!(X)
	p=-10^9
	ans=0
	for (l,r)=X
		if p<=r
			ans+=1
			p=l
		end
	end
	println(ans)
end
main()


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

import static java.lang.Integer.parseInt;

/**
 * Sightseeing Tour
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		StringTokenizer st;

		int n = parseInt(br.readLine());

		int[][] G = new int[n][n];

		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			for (int j = 0; j < n; j++) {
				G[i][j] = parseInt(st.nextToken());
			}
		}

		long ans = 0;

		for (int i = 0; i < n - 1; i++) {
			for (int j = i; j < n; j++) {
				ans += Math.min(G[i][j], G[j][i]);
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 28824
#include<stdio.h>

int main(void)
{
    int A, B, C, D;

    scanf("%d %d %d %d", &A, &B, &C, &D);

    while(1) {
        C -= B;
        if(C <= 0) {
            printf("Yes\n");
            break;
        }
        A -= D;
        if(A <= 0) {
            printf("No\n");
            break;
        }
    }

    return 0;
}


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

/*
  ll n , m ;
  cin >> n >> m ;
  ll a , b , c ;
  cin >> a >> b >> c ;
  vector<ll> A(n) ;
  cout << "Yes" << endl ;
  cout << "No"  << endl ;
*/

int main(){
    ll n , d ;
    cin >> n >> d ;
    ll count = 0 ;
    rep(i,n){
      ll x , y ;
      cin >> x >> y ;
      if( x*x + y*y <= d*d )count++ ;
    }
    cout << count <<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 998244353;

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

void dijkstra(auto &G, auto &dis, int s)
{
  /*
  ダイクストラ法。任意の始点から各点への最短距離を求める。計算量は O((V+E)logV)。
  引数のグラフは 0-indexed の隣接リストを想定。要素は、PII(to, weight)。
  始点から各点までの距離を格納する配列を用意し、参照渡しする。すべての要素をINFで初期化しておく。
  */
  dis[s] = 0;
  priority_queue< pair<LL, int>, vector<pair<LL, int>>, greater<pair<LL, int>> > q; // 値の小さい要素を優先
  q.push({0, s});
  while(!q.empty())
  {
    pair<LL, int> node = q.top();
    q.pop();
    int u = node.second;
    LL c = node.first;
    REPx(x, G[u])
    {
      int v = x.first;
      LL w = x.second;
      if (c + w < dis[v])
      {
        dis[v] = c + w;
        q.push({dis[v], v});
      }
    }
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, LL>>> G(n, vector<pair<int, LL>>());
  REP2(i, 1, n) G[i].push_back({i-1, 0});
  REP(i, m)
  {
    int L, R;
    LL C;
    cin >> L >> R >> C;
    G[L-1].push_back({R-1, C});
  }
  VLL dis(n, INF);
  dijkstra(G, dis, 0);
  if (dis[n-1] != INF) cout << dis[n-1] << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 10112
<?php

$whn = explode(' ',trim(fgets(STDIN)));
$w = $whn[0];
$h = $whn[1];
$n = $whn[2];

for ($i=0; $i<$w; $i++){
  for ($j=0; $j<$h; $j++){
    $box[$i][$j] = 'w';
  };
}

for ($k=0; $k<$n; $k++){
  $xya = explode(' ',trim(fgets(STDIN)));
  $x = $xya[0];
  $y = $xya[1];
  $a = $xya[2];
  
  if ($a == 1){
    for ($i=0; $i<$x; $i++){
      for ($j=0; $j<$h; $j++){
        $box[$i][$j] = 'b';
      }
    };   
  } else if ($a == 2){
    for ($i=$x; $i<$w; $i++){
      for ($j=0; $j<$h; $j++){
        $box[$i][$j] = 'b';
      }
    };  
  } else if ($a == 3){
    for ($i=0; $i<$w; $i++){
      for ($j=0; $j<$y; $j++){
        $box[$i][$j] = 'b';
      }
    };  
  } else if ($a == 4){
    for ($i=0; $i<$w; $i++){
      for ($j=$y; $j<$h; $j++){
        $box[$i][$j] = 'b';
      }
    };  
  }
}

$count = 0;
for ($i=0; $i<$w; $i++){
  for ($j=0; $j<$h; $j++){
    if ($box[$i][$j] == 'w') $count++;
  }
}

echo $count;


?>

Measured memory_bytes: 4604