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

//------------------------- DEBUGGING -----------------------------------------------------------------------
#ifdef DEBUG
#define debug( args... ) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
#else
#define debug(...)
#endif
//------------------------ MACROS ----------------------------------------------------------------------------

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 1e5 + 2;

vvi adj;
int ar[NN];

void solve(){
    int i = 0, j = 0, k = 0, n = 0, m = 0;
    cin >> n;
    vi x(n), y(n), h(n); 
    int mrk = -1;
    fr(i, 0, n) {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0) {
            mrk = i;
        }
    }
    bool dn = 0;
    int H;
    for(int cx = 0; cx <= 100 && !dn; cx++) {
        for(int cy = 0; cy <= 100 && !dn; cy++) {

            if(mrk != -1) {

                bool eq = 1;
                H = abs(x[mrk] - cx) + abs(y[mrk] - cy) + h[mrk];
                debug(mrk, H);
                fr(i, 0, n) {

                    int eval = max(0, H - abs(x[i] - cx) - abs(y[i] - cy));
                    if(eval != h[i]) {
                        eq = 0;
                        break;
                    }
                }
                debug(eq);
                if(eq) {
                    dn = 1;

                }
            }
            else {
                int mnn = INT_MAX;
                fr(i, 0, n) {
                    mnn = min(mnn, abs(x[i] - cx) + abs(y[i] - cy));
                }
                if(mnn > 0) {
                    H = mnn;
                    dn = 1;
                }
            }
            if(dn) {
                j = cx; k = cy;
            }
        }
    }
    cout << j  <<  ' ' << k << ' ' << H << el;
}

int main(){
#ifndef DEBUG
    ios::sync_with_stdio(false); cin.tie(0); 
#endif
    int T = 1, tc;
    for(tc = 1; tc <= T; tc++){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	int a[n] = {};
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	cout << accumulate(a, a + k, 0);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	reverse(all(s));
	reverse(all(t));
	int n = s.size();
	int k = t.size();
	bool ok = false;
	rep(i, n) {
		string tmp = s.substr(i, k);
		bool elf = true;
		rep(j, k) {
			if (tmp[j] != t[j] && tmp[j] != '?') {
				elf = false;
				break;
			}
		}
		if (elf) {
			for (int j = i; j < i + k; ++j) {
				s[j] = t[j - i];
			}
			ok = true;
			break;
		}
	}
	if (!ok) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	rep(i, n) {
		if (s[i] == '?') s[i] = 'a';
	}
	reverse(all(s));
	cout << s << endl;
	return 0;
}

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


int main() {
    int V, E;
    std::cin >> V >> E;


    std::vector<std::vector<std::pair<int, int>>> link_list(V);

    for (int i = 0; i < E; i++) {
        int s, t, w;
        std::cin >> s >> t >> w;
        link_list[s].emplace_back(std::make_pair(t, w));
        link_list[t].emplace_back(std::make_pair(s, w));
    }

    std::vector<int> color(V, 0);

    auto compare = [] (std::pair<int, int> lhs, std::pair<int, int> rhs) {
        return lhs.second > rhs.second;
    };

    std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(compare)> que {compare};
    for (auto & next : link_list[0]) {
        que.push(next);
    }
    color[0] = 1;
    int sum = 0;
    while (!que.empty()) {
        auto link = que.top();
        que.pop();
        if (color[link.first] != 0) {
            continue;
        }

        color[link.first] = 1;
        sum += link.second;

        for (auto & next : link_list[link.first]) {
            if (color[next.first] == 0) {
                que.push(next);
            }
        }
    }
    std::cout << sum << std::endl;
}



Measured memory_bytes: 6800
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
 
  cin >>A>>B;
   int C=A*B;
  if((A <=9) &&(B <=9)) {
    cout << C << endl;
  }
else {
cout << "-1" << endl;
}
}

 

Measured memory_bytes: 256
def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    total = T
    for n in range(1, N):
        if t[n] < t[n-1] + T:
            total += (t[n]+T) - (t[n-1]+T)
        else:
            total += T

    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ap = ReadInts();
            var a = ap[1];
            a += ap[0] * 3;
            WriteLine(a / 2);
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <vector>

using namespace std;

int main()
{

    vector<int> n(3);
    cin >> n[0] >> n[1] >> n[2];
    int cnt = 0;

    sort(n.begin(), n.end());

    n[0] = abs(n[2] - n[0]);
    n[1] = abs(n[2] - n[1]);
    n[2] -= n[2];
    int diff = 0;
    for (int i = 0; i < 3; i++)
    {
        // cout << n[i] << ",";
        diff += n[i];
    }
    // cout << "diff:" << diff << endl;
    if (diff % 2 == 0)
    {
        cnt = diff / 2;
    }
    else
    {
        cnt = diff / 2 + 2;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop1(i,n) for(long long int i = 1;i < n+1; i++)
#define loop(i,n) for(long long int i = 0;i < n; i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define lli long long int 
#define li long int
using namespace std;

int main(){
    fast;
  int r, c;
  int  p = 1e9+7;
  cin>>r>>c;
  char m[r+1][c+1];
  int ways[r+1][c+1];
  loop1(i,r)
    loop1(j,c){
        cin>>m[i][j];
    }
  
  loop(i,r+1)
    loop(j,c+1)
        ways[i][j] = 0;

 ways[0][1] = ways[1][0] = 1;   

 loop1(i,r)
    if(m[i][1]== '.')
        ways[i][1] = ways[i-1][1];

 loop1(i,c)
    if(m[1][i]== '.')
         ways[1][i] = ways[1][i-1];

 for(int i=2;i<=r;i++){
    for(int j=2;j<=c;j++){
        if(m[i][j] == '.'){
            ways[i][j] = (ways[i][j-1]+ways[i-1][j])%p;
        }
    }
 }
 cout<<ways[r][c]<<endl;
  return 0;
}

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

int main(){
  int A, B, result;
  cin >> A >> B;
  if((A + B) > (A - B)){
  	result = A + B;
  }else{
  	result = A- B;
  }
  if(result < (A * B)){
  	result = A * B;
  }
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	for (int i=0;i<=100000;i++){
		if (a&1 || b&1 || c&1){
			printf("%d\n",i);
			return 0;
		}
		int d=a/2,e=b/2,f=c/2;
		a=e+f,b=d+f,c=d+e;
	}
	printf("-1\n");
	return 0;
} 

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60



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

	int N; cin >> N;
	vector<P> V;
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		V.push_back(P(x, y));
	}

	map<P, int> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i != j) {
				int dx = V[i].first - V[j].first;
				int dy = V[i].second - V[j].second;
				M[P(dx, dy)]++;
			}
		}
	}

	int cnt = 0;
	while (!M.empty()) {
		map<P, int>::iterator it = M.begin();
		//cout << it->second << endl;
		cnt = max(cnt, it->second);
		M.erase(it);
	}
	cout << N - cnt << endl;

	return 0;
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



void solve()
{
    ll a, b, c;
    cin>>a>>b>>c;
    if(a == b && b != c) cout<<"Yes"<<endl;
    else if(a == c && a != b) cout<<"Yes"<<endl;
    else if(b == c && a != b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


int main()
{
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

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

const long long INF = 1LL << 60;

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

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

long N, W, w[110], v[110];
long DP[110][100010] = {};

int main() {
	cin >> N >> W;
	
	for(int i = 0; i < N; i++){
		cin >> w[i] >> v[i];
	}
	
	for(int i = 0; i < 110; i++) {
		for(int j = 0; j < 100010; j++) {
			DP[i][j] = INF;
		}
	}
	
	DP[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 100000+1; j++){
			chmin(DP[i+1][j], DP[i][j]);
			if(j - v[i] >= 0) {
				chmin(DP[i+1][j], DP[i][j - v[i]] + w[i]);
			}
		}
	}
	long long ans = 0;
	for(int i = 0; i < 100001; i++) {
		if(W >= DP[N][i] && ans < i) {
			ans = i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 86144
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#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 mkp make_pair
#define mkt make_tuple
#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;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, c, x[114514], y[114514];
int sumri[114514], sumle[114514];
int le_ri1[114514], le_ri2[114514], ri_le1[114514], ri_le2[114514];
signed main() {
	cin >> n >> c;
	REP(i, n + 1)cin >> x[i] >> y[i];
	REP(i, n + 1) {
		sumle[i] = sumle[i - 1] + y[i];
		le_ri1[i] = max(le_ri1[i - 1], sumle[i] - x[i]);
		ri_le1[i] = max(ri_le1[i - 1], sumle[i] - x[i] * 2);
	}
	for (int i = n; i > 0; i--) {
		sumri[i] = sumri[i + 1] + y[i];
		le_ri2[i] = max(le_ri2[i + 1], sumri[i] - (c - x[i]) * 2);
		ri_le2[i] = max(le_ri2[i + 1], sumri[i] - (c - x[i]));
	}
	int ans = 0;
	rep(i, n + 1) {
		ans = max(ans, le_ri1[i] + le_ri2[i + 1]);
		ans = max(ans, ri_le1[i] + ri_le2[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include<set>
#include<cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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

    string L;
    cin >> L;

    ll n = L.size();
    ll cnt = 0;
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        if (L[i] == '1') {
            ans += modpow(2, cnt) % MOD * modpow(3, n-1-i) % MOD;
            ans %= MOD;
            cnt++;
        }
    }

    ans += modpow(2, cnt);
    ans %= MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int N, M;
  cin >> N >> M;
  int ret = N * (N-1) / 2 + M * (M-1) / 2;
  cout << ret << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

int L, m, a[100], b[100], c[100];

void add(int x, int y, int z) {
	m++;
	a[m] = x;
	b[m] = y;
	c[m] = z;
}

int main() {
	scanf("%d", &L);
	printf("%d ", 20);
	for (int i = 19; i > 1; i--) {
		add(i, i + 1, 1 << (19 - i));
		add(i, i + 1, 0);	
	}
	int pre = 0;
	while (L >= 262144) {
		add(1, 2, pre);
		pre += 262144;
		L -= 262144;
	}
	for (int i = 17; i >= 0; i--)
		if ((1 << i) & L) {
			if (i == 19) {
				add(1, 2, 0);
				add(1, 2, 1 << 18);
				pre = (1 << 19);
			}else {
				add(1, 20 - i, pre);
				pre += (1 << i);
			}
		}
	printf("%d\n", m);
	for (int i = 1; i <= m; i++)
		printf("%d %d %d\n", a[i], b[i], c[i]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A, B , C;
  cin >> A >> B >> C;

  string str1 = A;
  string str2 = B;
  string str3 = C;
  
  char a = str1.at(str1.size()-1);
  char b = str2.at(0);
  char c = str2.at(str2.size()-1);
  char d = str3.at(0);
  
	if(a == b && c == d){
      cout << "YES" << endl;
    }
  else if( a != b || c!= d) {
      cout << "NO" << endl;
  }
      
	
}

	


Measured memory_bytes: 256
#ifndef ___Class_RMQ
#define ___Class_RMQ

#define INF (1LL << 60)

#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

class RMQ
{
private:

	int size;

	vector<long long> minvalue;
	vector<long long> maxvalue;

	pair<long long, long long> _query(int a, int b, int k, int l, int r)
	{
		if (r <= a || b <= l) { return make_pair(INF, -INF); }
		if (a <= l && r <= b) { return make_pair(minvalue[k], maxvalue[k]); }

		pair<long long, long long> vl = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		pair<long long, long long> vr = _query(a, b, 2 * k + 2, (l + r) / 2, r);

		return make_pair(min(vl.first, vr.first), max(vl.second, vr.second));
	}

public:

	RMQ(int size_)
	{
		for (size = 1; size < size_;) { size <<= 1; }

		minvalue = vector<long long>(size * 2 - 1, INF);
		maxvalue = vector<long long>(size * 2 - 1, -INF);
	}

	void update(int i, long long x)
	{
		i += size - 1;

		minvalue[i] = x;
		maxvalue[i] = x;

		while (i > 0)
		{
			i = (i - 1) / 2;

			minvalue[i] = min(minvalue[2 * i + 1], minvalue[2 * i + 2]);
			maxvalue[i] = max(maxvalue[2 * i + 1], maxvalue[2 * i + 2]);
		}
	}

	pair<long long, long long> query(int s, int t)
	{
		return _query(s, t, 0, 0, size);
	}
};

#endif


// ------ main ------ //

#include <iostream>

using namespace std;

int n, q, com, x, y;

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

	RMQ r(n);

	for (int i = 0; i < q; i++)
	{
		cin >> com >> x >> y;

		if (com == 0) 
		{
			r.update(x, y);
		}
		if (com == 1) 
		{
			pair<long long, long long> p = r.query(x, y + 1);

			cout << (p.first != INF ? p.first : (1LL << 31) - 1) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 7064
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n,s;
    while(cin>>n>>s){
        if(n==0 && s==0)break;
        
        vi in;
        rep(i,n){
            int a;
            cin>>a;
            in.pb(a);
        }
        
        
        sort(all(in));
        
        int sum=0;
        rep(i,n-1){
            for(int j=i+1;j<n;j++){
                if(in[i]+in[j]>s){
                    sum+=n-j;
                    break;
                }
            }
        }
        
        cout<<sum<<endl;
        
        
    }
    
    return 0;
}

Measured memory_bytes: 1324
#include <cstdio>
#include <queue>
#include <string>
#include <cstring>
#include <set>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

const int MAX_NUM = 1000;
int W, H, N;
int X, Y;
int x1[MAX_NUM], y1[MAX_NUM], x2[MAX_NUM], y2[MAX_NUM];

bool field[6 * MAX_NUM][6 * MAX_NUM] = {};

int dir[] = { 0, 1, 0, -1, 0 };

void paint(int i, int j) {
    field[i][j] = true;
    
    queue<P> que;
    que.push(P(i, j));
    
    while (!que.empty()) {
        P curr = que.front(); que.pop();
        
        int x = curr.first, y = curr.second;
        
        for (int d = 0; d < 4; d++) {
            int nx = x + dir[d], ny = y + dir[d+1];
            if (0 <= nx && nx < X && 0 <= ny && ny < Y && !field[nx][ny]) {
                field[nx][ny] = true;
                que.push(P(nx, ny));
            }
        }
    }
}

int compress(int x1[], int x2[], int W) {
    set<int> dist;
    
    for (int i = 0; i < N; i++) {
        for (int d = -1; d <= 1; d++) {
            int nx1 = x1[i] + d, nx2 = x2[i] + d;
            if (0 <= nx1 && nx1 < W) dist.insert(nx1);
            if (0 <= nx2 && nx2 < W) dist.insert(nx2);
        }
    }
    
    vector<int> nx;
    for (set<int>::iterator it = dist.begin(); it != dist.end(); it++) {
        nx.push_back(*it);
    }
    
    
    for (int i = 0; i < N; i++) {
        x1[i] = (int)(find(nx.begin(), nx.end(), x1[i]) - nx.begin());
        x2[i] = (int)(find(nx.begin(), nx.end(), x2[i]) - nx.begin());
    }
    
    return (int)nx.size();
}

int main() {
//    freopen("aoj0531.in", "r", stdin);
    
    while (scanf("%d%d", &W, &H)) {
        if (W == 0 && H == 0) break;
        
        scanf("%d", &N);
        memset(field, false, sizeof(field));
        
        for (int i = 0; i < N; i++) {
            scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
            x2[i]--;
            y2[i]--;
        }
        
        X = compress(x1, x2, W);
        Y = compress(y1, y2, H);
        
        for (int i = 0; i < N; i++) {
            for (int x = x1[i]; x <= x2[i]; x++) {
                for (int y = y1[i]; y <= y2[i]; y++) {
                    field[x][y] = true;
                }
            }
        }
        
        
        int count = 0;
        for (int i = 0; i < X; i++) {
            for (int j = 0; j < Y; j++) {
                if (!field[i][j]) {
                    paint(i, j);
                    count++;
                }
            }
        }
        
        printf("%d\n", count);
    }
    
    return 0;
}

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define rep(i,x,y) for(int i = x;i <= y;i++)
#define rvp(i,x,y) for(int i = y;i >= x;i--)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int N = 1e5 + 10;
string s[N];
int main()
{
	int n;
	ios
	while(cin >> n)
	{
		rep(i,1,n) {
			cin>>s[i];
			sort(s[i].begin(),s[i].end());
		}
		sort(s+1,s+n+1);
		ll ans = 0;
		int cnt = 1;
		string cur = s[1];
		rep(i,2,n)
		{
			if(cur == s[i]) cnt++;
			else{
				ans += 1ll*(cnt-1)*cnt/2;
				cur = s[i];
				cnt = 1;
			}
		}
		ans += 1ll*(cnt-1)*cnt/2;
		cout<< ans << endl; 
	}
	return 0;
}

Measured memory_bytes: 5760
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	M = MOD;
	for (int i = 0; i < N; i++) {
		cin >> K;
		if (K < M) {
			L++;
			M = K;
		}
	}
	cout << L << endl;
	return 0;
}

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

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i,N){
        cin >> t[i];
    }

    ll sum = T;

    for (int i = 0; i < N-1;i++){
        sum += min(t[i + 1] - t[i], T);
    }
        cout << sum;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

template< typename Monoid >
struct SegmentTree {
    using F = function< Monoid(Monoid, Monoid) >;
    
    int sz;
    vector< Monoid > seg;
    
    const F f;
    const Monoid M1;
    
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }
    
    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }
    
    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    
    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    
    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }
    
    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
    
    template< typename C >
    int find_subtree(int a, const C &check, Monoid &M, bool type) {
        while(a < sz) {
            Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
            if(check(nxt)) a = 2 * a + type;
            else M = nxt, a = 2 * a + 1 - type;
        }
        return a - sz;
    }
    
    template< typename C >
    int find_first(int a, const C &check) {
        Monoid L = M1;
        if(a <= 0) {
            if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
            return -1;
        }
        int b = sz;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) {
                Monoid nxt = f(L, seg[a]);
                if(check(nxt)) return find_subtree(a, check, L, false);
                L = nxt;
                ++a;
            }
        }
        return -1;
    }
    
    template< typename C >
    int find_last(int b, const C &check) {
        Monoid R = M1;
        if(b >= sz) {
            if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
            return -1;
        }
        int a = sz;
        for(b += sz; a < b; a >>= 1, b >>= 1) {
            if(b & 1) {
                Monoid nxt = f(seg[--b], R);
                if(check(nxt)) return find_subtree(b, check, R, true);
                R = nxt;
            }
        }
        return -1;
    }
};

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

    int n, q;
    cin>>n>>q;
    SegmentTree<ll> st(n, [](ll a, ll b){ return a + b; }, 0);

    rep(i, q) {
        ll c, x, y;
        cin>>c>>x>>y;

        if (c == 0) {
            int a = st.query(x, x + 1);
            st.update(x, a + y);
        }
        else {
            cout<<st.query(x, y + 1)<<endl;
        }
    }
}


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

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

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

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

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

int N, a[1010];

signed main() {
    cin >> N;
    int mi = INF, ma = -1;
    rep(i,0,N) {
        cin >> a[i];
        chmin(mi, a[i]);
        chmax(ma, a[i]);
    }
    cout << ma - mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int x;
        cin>>x;
        int a,b;
        loop(i,-1000,1000){
            bool flg = false;
            loop(j,-1000,1000){
                int y = pow(i,5);
                int z = pow(j,5);
                int Y = max(y,z);
                int Z = min(y,z);
                if(Y-Z==x){
                    a=max(i,j);
                    b=min(i,j);
                    flg = true;
                    break;
                }
            }
            if(flg) break;
        }
        cout<<a<<" "<<b;
    }
    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll x;cin>>x;
  ll now=100;
  int count=0;
  while(now<x)
  {
    now=(now+now/100);
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

const int N=1010;

int n,cnt;
double ret;
ii a[N];
int b[N];

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    n=in;
    forinc(i,1,n) a[i]={in,in},b[i]=i;
    do{
        forinc(i,2,n){
            ret+=sqrt((a[b[i]].fi-a[b[i-1]].fi)*(a[b[i]].fi-a[b[i-1]].fi)+(a[b[i]].se-a[b[i-1]].se)*(a[b[i]].se-a[b[i-1]].se));
        }
        cnt++;
    }while(next_permutation(b+1,b+n+1));
    cout<<setprecision(12)<<fixed<<ret/cnt;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int H, W, D; std::cin >> H >> W >> D;
    std::vector<std::vector<int>> a(H, std::vector<int>(W));
    std::vector<std::pair<int, int>> pos(H*W + 2);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            std::cin >> a[i][j];
            pos[a[i][j]] = { i, j };
        }
    }
    std::vector<std::vector<std::vector<std::pair<int, int>>>>
        p(30, std::vector<std::vector<std::pair<int, int>>>(
            H, std::vector<std::pair<int, int>>(W)));
    std::vector<std::vector<std::vector<int>>>
        q(30, std::vector<std::vector<int>>(H, std::vector<int>(W)));
    auto cost = [](const auto &p, const auto &q) {
        return std::abs(p.first - q.first) + std::abs(p.second - q.second);
    };
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] + D > H*W) continue;
            p[0][i][j] = pos[a[i][j] + D];
            q[0][i][j] = cost(std::make_pair(i, j), p[0][i][j]);
        }
    }
    for (int t = 1; t < 21; t++) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (a[i][j] + D*(1LL << t) > H*W) continue;
                p[t][i][j] =
                    p[t - 1][p[t - 1][i][j].first][p[t - 1][i][j].second];
                q[t][i][j] = q[t - 1][i][j] +
                    q[t - 1][p[t - 1][i][j].first][p[t - 1][i][j].second];
            }
        }
    }
    int Q; std::cin >> Q;
    while (Q--) {
        int l, r; std::cin >> l >> r;
        int d = (r - l) / D;
        std::pair<int, int> c = pos[l];
        long long ans = 0;
        for (int t = 0; t < 21; t++) {
            if (~(d >> t) & 1) continue;
            ans += q[t][c.first][c.second];
            c = p[t][c.first][c.second];
        }
        std::cout << ans << std::endl;
    }
    return 0;
}


Measured memory_bytes: 34944
A,V=map(int,input().split())
B,W=map(int,input().split())
K=int(input())
Apos=A
Bpos=B
count=0
rev=False
if B>A:
    pass
else:
    rev=True

if rev==False:

    
        
    A=A+V*K
    B=B+W*K
    if A>=B:
        print("YES")
        exit()
    
        

else:
    A=A-V*K
    B=B-W*K
    if A<=B:
        print("YES")
        exit()

print("NO")

Measured memory_bytes: 9204
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int a = Integer.parseInt(br.readLine());
    int b = Integer.parseInt(br.readLine());
    int c = Integer.parseInt(br.readLine());
    int x = Integer.parseInt(br.readLine());
    int ans = 0;

    for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
        for (int j2 = 0; j2 <= c; j2++) {
          int total = 500*i + 100*j + 50*j2;
          if (total == x) ans++;
        }
      }
    }
    out.println(ans);
    out.close();
  }
}

Measured memory_bytes: 32756
H,W=map(int,input().split())
s=[]
s.append(['.']*(W+2))
#s=[list(map(str,input().split())) for i in range(H)]
for i in range(H):
    l=list(input())
    l.insert(0,'.')
    l.append('.')
    s.append(l)

s.append(['.']*(W+2))
flag=0
for i in range(H):
    for j in range(W):
        if s[i][j]=='#' and s[i][j-1]!='#' and s[i][j+1]!='#' and s[i-1][j]!='#' and s[i+1][j]!='#':
            flag=1
            break
if flag==1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
import Control.Applicative
import Data.List
import Control.Monad
strToInteger s = (read :: String -> Integer) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, h] <- map strToInteger . words <$> getLine
    ns <- replicateM (fromInteger n) $ do
        [a, b] <- map strToInteger . words <$> getLine
        return (a, b)
    -- 出力
    putStrLn . show $ func ns h

func :: [(Integer, Integer)] -> Integer -> Integer
func ns h = if sum bs' <= h then damage `div` amax + (fromIntegral . length $ filter (amax <) $ bs) + c
                            else fromIntegral . (+ 1) . length $ takeWhile (h >) $ scanl1 (+) bs'
    where
        amax = maximum $ map fst ns
        bs = map snd ns
        bs' = reverse . sort $ filter (amax <) bs
        damage = h - (sum bs')
        c = if damage `mod` amax == 0 then 0 else 1


Measured memory_bytes: 76156
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
using namespace std;


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	char ch;
	stack<int> s1;	//?????????'\'????¨???????
	stack< pair<int, int> > s2;//first??¨????°´??¢?????????'\'????¨???????,second??¨?????\?§??°´?????¢?§?
	int sum = 0;
	for (int i = 0; cin >> ch; ++i)
	{
		if (ch == '\\')
			s1.push(i);
		else if (ch == '/' && !s1.empty())
		{
			int l = s1.top();
			s1.pop();
			int r = i;
			sum += r - l;
			int a = r - l;
			while (!s2.empty() && s2.top().first > l)
			{
				a += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(l, a));
		}
	}
	vector<int> ans;
	while (!s2.empty())
	{
		ans.push_back(s2.top().second);
		s2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl << ans.size();
	for (int i = 0; i != ans.size(); ++i)
	{
		cout << ' ' << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int a,b;
    cin>>a>>b;
    bool print=false;
    for(int i=0;i<1000000;i++)
    {
        int x = double(i)*(0.08);
        int y = double(i)*(0.1);
        if(x==a&&y==b)
        {
            cout<<i<<endl;
            print=true;
            break;
        }
    }
    if(!print)
    cout<<-1<<endl;
}


Measured memory_bytes: 256
import collections
import bisect
import sys
input = sys.stdin.readline

# mod = 998244353
# mod = 1000000007

n, d, a = [ int(v) for v in input().split() ]
monster = []
for _ in range(n):
    x, h = [ int(v) for v in input().split() ]
    monster.append([x, h])
monster.sort()


monster_x, monster_h = [], []
for x, h in monster:
    monster_x.append(x)
    monster_h.append(h)
    

deq = collections.deque([])
totaldamage = 0
ans = 0

for i in range(n):
    
    stop = 1
    while stop == 1 and len(deq) > 0:
        if deq[-1][0] < monster_x[i]:
            totaldamage -= deq[-1][1]
            deq.pop()
        else:
            stop = 0
    
    monster_h[i] -= totaldamage
    if monster_h[i] > 0:
        index = monster_x[i] + 2*d
        
        f = (monster_h[i] + a - 1) // a
        ans += f 
        totaldamage += f * a
        deq.appendleft([index, f*a])
        monster_h[i] = 0

print(ans)

Measured memory_bytes: 94940
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

int N, K;
bool D[12];

bool check(int num) {
    while (num >= 1) {
        int q = num % 10;
        if (D[q]) return false;
        num /= 10;
    }
    return true;
}

int main() {
    while (cin >> N >> K) {
        memset(D, 0, sizeof(D));
        for (int i = 0; i < K; ++i) {
            int d; cin >> d;
            D[d] = true;
        }
        int res = N;
        for (res = N; res <= 9999999; ++res) {
            if (check(res)) {
                break;
            }
        }
        cout << res << endl;
    }
}




Measured memory_bytes: 256
using System;

class Program {
    static void Main(string[] args) {

        string[] str1 = Console.ReadLine().Split(' ');
        string[] str2 = Console.ReadLine().Split(' ');

        int N = int.Parse(str1[0]);
        int M = int.Parse(str1[1]);
        int C = int.Parse(str1[2]);

        int[] Bs = new int[M];

        for(int i = 0; i < M; ++i) {
            Bs[i] = int.Parse(str2[i]);
        }
        int count = 0;
        int res = 0;
        while (true) {
            ++count;
            if (count > N) break;

            string[] str3 = Console.ReadLine().Split(' ');
            int[] As = new int[M];
            for(int k = 0; k < M; ++k) {
                As[k] = int.Parse(str3[k]);
            }

            int Sum = 0;

            for(int j = 0; j < M; ++j) {
                Sum += (As[j] * Bs[j]);
            }

           

            if(Sum + C > 0) {
                ++res;
            }
        

        }

        Console.WriteLine(res);
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  i64 k;
  cin >> n >> k;
  vi32 a(n);
  cin >> a;
  sort(all(a));
  auto f = [&](i64 x) {
    i64 ret = 0;
    rep(i, n) {
      if (a[i] < 0) {
        ret += partition_point(a.begin() + i + 1, a.end(), [&](int y) {
          return (i64) y * a[i] >= x;
        }) - (a.begin() + i + 1);
      } else if (a[i] > 0) {
        ret += partition_point(a.rbegin(), a.rend() - i - 1, [&](int y) {
          return (i64) y * a[i] >= x;
        }) - a.rbegin();
      } else {
        if (x <= 0) ret += n - (i + 1);
      }
    }
    return ret;
  };
  i64 L = (i64) n * (n - 1) / 2 - k + 1;
  i64 ok = -2e18, ng = 2e18;
  while (abs(ok - ng) > 1) {
    i64 md = (ok + ng) / 2;
    (f(md) < L ? ng : ok) = md;
  }
  cout << ok << endl;
}


Measured memory_bytes: 1152