akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;
int main()
{
	int n, k, l;
	int p, q, r, s;
	vector<int> v1[200000], v2[200000];
	scanf("%d %d %d", &n, &k, &l);
	for(int i=0; i<k; i++){
		scanf("%d %d", &p, &q);
		p--;
		q--;
		v1[p].push_back(q);
		v1[q].push_back(p);
	}
	for(int i=0; i<l; i++){
		scanf("%d %d", &r, &s);
		r--;
		s--;
		v2[r].push_back(s);
		v2[s].push_back(r);
	}
	set<int> st;
	for(int i=0; i<n; i++){
		st.insert(i);
	}
	vector<int> conn1[200000];
	int c[200000];
	int t=0;
	while(!st.empty()){
		auto itr=st.begin();
		vector<int> v;
		v.push_back(*itr);
		conn1[t].push_back(*itr);
		st.erase(itr);
		while(!v.empty()){
			int x=v.back();
			v.pop_back();
			for(int i=0; i<v1[x].size(); i++){
				if(st.find(v1[x][i])!=st.end()){
					conn1[t].push_back(v1[x][i]);
					v.push_back(v1[x][i]);
					st.erase(v1[x][i]);
				}
			}
		}
		t++;
	}
	int u=0;
	vector<int> conn2[200000];
	for(int i=0; i<n; i++){
		st.insert(i);
	}
	while(!st.empty()){
		auto itr=st.begin();
		vector<int> v;
		v.push_back(*itr);
		conn2[u].push_back(*itr);
		st.erase(itr);
		while(!v.empty()){
			int x=v.back();
			v.pop_back();
			for(int i=0; i<v2[x].size(); i++){
				if(st.find(v2[x][i])!=st.end()){
					conn2[u].push_back(v2[x][i]);
					v.push_back(v2[x][i]);
					st.erase(v2[x][i]);
				}
			}
		}
		u++;
	}
	int c1[200000], c2[200000];
	for(int i=0; i<t; i++){
		for(int j=0; j<conn1[i].size(); j++){
			c1[conn1[i][j]]=i;
		}
	}
	for(int i=0; i<u; i++){
		for(int j=0; j<conn2[i].size(); j++){
			c2[conn2[i][j]]=i;
		}
	}
  
	multimap<P, int> mp;
	for(int i=0; i<n; i++){
		mp.insert(make_pair(P(c1[i], c2[i]), i));
	}
	while(!mp.empty()){
		auto itr=mp.begin();
		P pr=itr->first;
		auto r=mp.equal_range(pr);
		int x=0;
		for(auto itr1=r.first; itr1!=r.second; itr1++){
			x++;
		}
		for(auto itr1=r.first; itr1!=r.second; itr1++){
			c[itr1->second]=x;
		}
		mp.erase(r.first, r.second);
	}
	for(int i=0; i<n; i++){
		printf("%d ", c[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 50404
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

G = [list() for _ in range(n + 1)]
for a, b in edges:
    G[a].append(b)
    G[b].append(a)

checked = [False for _ in range(n)]

ans = 0

def dfs(v):
    global ans
    if all(checked):
        ans += 1
        return
    for u in G[v]:
        if not checked[u - 1]:
            checked[u - 1] = True
            dfs(u)
            checked[u - 1] = False
    return

checked[0] = True
dfs(1)
print(ans)


Measured memory_bytes: 9132
/**
 *    author:  tourist
 *    created: 27.01.2020 05:50:57       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    --x[i];
  }
  vector<vector<pair<int, int>>> at(n * n + 1);
  auto Add = [&](int a, int b, int c) {
    at[a].emplace_back(b, c);
  };
  for (int i = 0; i < n; i++) {
    Add(x[i], x[i], i);
    for (int j = 0; j < i; j++) {
      Add(0, x[i] - 1, i);
    }
    for (int j = i + 1; j < n; j++) {
      Add(x[i] + 1, n * n - 1, i);
    }
  }
  multiset<pair<int, int>> s;
  vector<int> ans(n * n);
  for (int i = 0; i < n * n; i++) {
    for (auto& j : at[i]) {
      s.insert(j);
    }
    if (s.empty()) {
      cout << "No" << '\n';
      return 0;
    }
    auto p = *s.begin();
    s.erase(s.begin());
    if (p.first < i) {
      cout << "No" << '\n';
      return 0;
    }
    ans[i] = p.second;
  }
  cout << "Yes" << '\n';
  for (int i = 0; i < n * n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << ans[i] + 1;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 19060
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int dp[3005][3005];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> p(n);
    rep(i, n) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());

    int ans = 0;
    rep(i, n) {
        rep(j, t) {
            chmax(dp[i + 1][j], dp[i][j]);
            int nj = j + p[i].first;
            if (nj < t) chmax(dp[i + 1][nj], dp[i][j] + p[i].second);
        }
        int now = dp[i][t - 1] + p[i].second;
        chmax(ans, now);
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<double> v(n);
  rep (i, n) cin >> v[i];
  sort(v.begin(), v.end());
  rep (i, n-1) {
    v[i+1] = (v[i] + v[i+1]) / 2;
  }
  cout << std::fixed;
  cout << setprecision(7) << v[n-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    int x,N,i;
    int maxVal=-1;

    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&x);

        if(x>maxVal)
        {
            maxVal=x;
            continue;
        }
        if(x<maxVal-1)
            break;
    }
    if(i==N)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

int maxSubSetXor(int *a,int n) {
	int ans = 0;
	int id = 0;
	for(int i = 61; i >= 0; i--) {
		int maxid  = -1, maxi = -1;
		for(int j = id; j < n; j++) {
			if( a[j] & (1ll << i) && a[j] > maxi) {
				maxi = a[j];
				maxid = j;
			}
		}
		if(maxid == -1)
			continue;
		swap(a[maxid] , a[id]);
		for(int j = 0; j < n; j++) {
			if(j != id && a[j] & (1ll << i) )
				a[j] ^= maxi;
		}
		id++;
	}

	for(int i = 0; i < n; i++)
		ans ^= a[i];
	return ans;
}

int32_t main() {
	int n;
	cin >> n;
	int a[n] , xr = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		xr ^= a[i];
	}
	for(int i = 0; i < n; i++)
		a[i] &= ~xr;
	int ans  = maxSubSetXor(a, n);
	ans = 2 * ans + xr;
	cout << ans << endl;
}

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

vector<int> vr,vg,vb;

int main(){
	string s;
	int n;
	long long ans=0;
	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		if(s[i]=='R') vr.push_back(i);
		else if(s[i]=='G') vg.push_back(i);
		else vb.push_back(i);
	}
	
	int a=vr.size(),b=vg.size(),c=vb.size();
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			ans+=c;
			
			int d=abs(vr[i]-vg[j]);
			int mi=min(vr[i],vg[j]),ma=max(vr[i],vg[j]);
			
			if(mi-d>=0&&s[mi-d]=='B') ans--;
			if(ma+d<n&&s[ma+d]=='B') ans--;
			if((vr[i]+vg[j])%2==0&&s[mi+d/2]=='B') ans--;
		}
	}
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3660
import sys
import math
N,D=map(int, input().split())
X=[0]*N
Y=[0]*N
for i in range(N):
    X[i],Y[i] = map(int, input().split())
s=0
for i in range(N):
    if X[i]**2  +   Y[i]**2   <= D**2:
        s=s+1
print(s)

Measured memory_bytes: 24756
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var L1 = input[0].map(e => parseInt(e, 10));
  var N = L1[0];
  var K = L1[1];
  var vec_p = input[1].map(e => parseInt(e, 10));
  var tmpSum = 0;
  var tmpSet = [];
  var changed, ans;
  for (var i = 0; i < K; i++){
    tmpSum += vec_p[i];
    tmpSet.push(vec_p[i]);
  }
  ans = tmpSum;
  for (var i = K; i < N; i++){
    changed = i % K;
    tmpSum += (vec_p[i] - tmpSet[changed]);
    tmpSet[changed] = vec_p[i];
    if (tmpSum > ans) ans = tmpSum;
  }
  ans = (ans + K) / 2;
  console.log(ans);
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 51744
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*----------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    str s, t;
    std::cin >> s >> t;

    ll a, b;
    std::cin >> a >> b;

    str u;
    std::cin >> u;

    if (u == s)
        std::cout << a - 1 << ' ' << b << '\n';
    else
        std::cout << a << ' ' << b - 1 << '\n';
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int n = 0;
	int r = 0;
	cin >> n >> r;

	int internal = 0;

	if (n >= 10) {
		internal = r;
	}
	else {
		internal = r + 100 * (10 - n);
	}

	cout << internal << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
/******************************************
	* AUTHOR : GURUTEJA *
	******************************************/
	#include <bits/stdc++.h>
	using namespace std;
	#define LL long long
	#define N 100005
	#define MOD 1000000007
	#define dd double
	#define rep(i, n) for(int i = 0; i < n; i++)
	#define REP(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,b) for(int i=1;i<=b;i++)
	#define pb push_back
	#define mp make_pair
	#define clr(x) x.clear()
	#define sz(x) ((int)(x).size())
	#define F first
	#define S second

	void debug(){
		#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	    #endif 

	}

	  int main() {
	    debug();
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n,d,x,a,count=0;
	    cin>>n>>d>>x;

	    for (int i = 0; i <n; ++i)
	    {
	    	cin>>a;
	    	count++;
	    	int j=1,y=a;
            while(((j*a)+1)<=d){
           	  count++;
              y=((j*a)+1);
              j++;
            }
	    }
	    cout<<count+x<<endl;
	    return 0;
	  }

Measured memory_bytes: 3628
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    AIN(string, s, N);
    map<char, ll> v{{'A', A}, {'B', B}, {'C', C}};
    vector<char> ans(N);
    bool ok = true;
    REP(i, N)
    {
        ll x = v[s[i][0]];
        ll y = v[s[i][1]];
        ll j = y > x or (x == 1 and y == 1 and (i == N - 1 or s[i][0] == s[i + 1][0] or s[i][0] == s[i + 1][1]));
        --v[s[i][j]];
        ++v[s[i][1 - j]];
        ans[i] = s[i][1 - j];
        ok &= v[s[i][j]] >= 0;
    }
    if (ok)
    {
        OUT("Yes");
        REP(i, N)
        {
            OUT(ans[i]);
        }
    }
    else
    {
        OUT("No");
    }
}

Measured memory_bytes: 6332
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

signed main()
{
    fast;
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> r(n,0) ;
    int cnt = k;
    for(int i=n-1 ; i>=0 ; i-- )
    {
        if( s[i] == 'o' )
        {
            r[i] = cnt--;
            i -= c;
        }
    }
    cnt = 0;
    for(int i=0 ; i<n ; i++ )
    {
        if( s[i] == 'o' )
        {
            ++cnt;
            if( cnt == r[i] )
                cout << i+1 << '\n';
            i += c;
        }
    }
    
}





Measured memory_bytes: 3348
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

char tmp[4010];

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
//    freopen(NAME".out", "w", stdout);

    int n;
    scanf("%d\n", &n);
    scanf("%s\n", tmp);
    string s = (const char*) tmp;
    vvi sum(3, vi(n + 1, 0));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < n; j++) {
            sum[i][j + 1] = sum[i][j];

            if ((i == 0 && s[j] == 'R') || (i == 1 && s[j] == 'G') || (i == 2 && s[j] == 'B')) {
                sum[i][j + 1]++;
            }
        }
    }

    ll ans = 0LL;

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) {
                continue;
            }

            int k = 0;

            if (s[i] == 'R' || s[j] == 'R') {
                k++;
            }

            if (k && (s[i] == 'G' || s[j] == 'G')) {
                k++;
            }

            ans += (ll) (sum[k][n] - sum[k][j + 1]);

            if ((j + j - i) < n && s[j + j - i] != s[i] && s[j + j - i] != s[j]) {
                ans--;
            }
        }
    }

    printf(lld"\n", ans);

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3848
let a, b, k = Scanf.sscanf (read_line()) "%d %d %d" (fun a b k ->
  a, b, k
)

let end_a = if a < k then 0 else a - k
let end_b = if end_a != 0 then b else if b < k - a then 0 else b - (k - a)

let _ = Printf.printf "%d %d\n" end_a end_b


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 9999999999;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	

	ll n,k;
	cin >> n >> k;
	if(k==1)
	{
		return cout << 0 << endl,0;
	}

	ll g = k-1;
	n-=g;

	cout << n-1 << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll A,B;
  cin>>A>>B;
  string S;
  cin>>S;
  if(S[A]!='-') {
cout<<"No"<<endl;
  return 0;
  }
  for(ll i=0;i<A+B+1;i++) {
if(i==A) {
continue;
}
    if(S[i]-'0'<0||S[i]-'0'>9) {
cout<<"No"<<endl;
      return 0;
    }
  }
  
  cout<<"Yes"<<endl;
}

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

int main() {
	int n, t, a,buf,i,c =1;
	double tt,ttt;
	vector<int> h;
	cin >> n >> t >> a;
	for (i = 0; i < n; i++) {
		cin >> buf;
		h.push_back(buf);
	}
	ttt = (double)t - (double)h[0] * 0.006;
	for (i = 1; i < n; i++) {
		tt = (double)t - (double)h[i] * 0.006;
		if (abs(tt-(double)a) < abs(ttt-(double)a)) {
			ttt = tt;
			c = i + 1;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
/*
???????????´??° x, y ?????????????????????????????????????°?????????????????????????????????°?????????????????????????????????

?????????????????????????????\?????????????????????????????????????????????????????????????????????????????¨?????¨?????????????????????
*/
#include <iostream>

int main() {
	while(true){
		int num1, num2;
		std::cin >> num1 >> num2;

		if (num1 == 0 && num2 == 0)break;
		else if (num1 < num2) std::cout << num1 << " " << num2 << std::endl;
		else std::cout << num2 << " " << num1 << std::endl;


	}
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;


int main(void) {
  int n;
  ll a, b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  rep (i, 0, n) cin >> h[i];
  
  ll l = 0, r = 1000000000;
  ll dif = a - b;
  while (r-l>1) {
    ll m = (r+l)/2;
    ll t = m;
    rep(i, 0, n) {
      ll hp = h[i];
      hp -= b*m;
      if (hp>0) t -= (hp+dif-1)/dif;
    }
    
    if (t>=0) r = m;
    else l = m;
  }

    cout << r << "\n";
    return 0;
}



Measured memory_bytes: 4040
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N;
int ct[555];
int ans[510*510];
int x[555];

void check(){
	for(int p=1;p<=N;p++){
		int pct = 0;
		int c = 0;
		REP(i,N*N)if(ans[i]==p){
			c++;
			pct++;
			if(pct==p){
				assert(i+1==x[p]);
			}
		}
		assert(c==N);
	}
}

int main(){
	memset(ans,-1,sizeof(ans));
	cin>>N;
	vector<pii> v;
	REP(i,N){
		pii p;
		cin>>x[i+1];
		p.first = x[i+1];
		p.second = i+1;
		v.push_back(p);
	}
	REP(i,N)ct[i+1] = N;
	sort(ALL(v));
	int tail = 0;
	REP(i,v.size()){
		int x = v[i].first, t = v[i].second;
		assert(tail<=x-1);
		assert(ans[x-1]==-1);
		ans[x-1] = t;
		REP(j,t-1){
			while(ans[tail]!=-1)tail++;
			if(tail>x-1){
				cout<<"No"<<endl;
				return 0;
			}
			ans[tail] = t;
			tail++;
		}
		ct[t]-=t;
	}
	REP(i,v.size()){
		int x = v[i].first, t = v[i].second;
		REP(j,ct[t]){
			while(ans[tail]!=-1)tail++;
			if(tail<x-1){
				cout<<"No"<<endl;
				return 0;
			}
			ans[tail] = t;
			tail++;
		}
	}
	while(ans[tail]!=-1)tail++;
	assert(tail==N*N);
	cout<<"Yes"<<endl;
	REP(i,N*N){
		assert(ans[i]!=-1);
		cout<<ans[i];
		if(i<N*N-1)cout<<" ";
	}
	cout<<endl;
//	check();
	return 0;
}


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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int n;cin>>n;
  if (n == 0) {
    cout << 0 << endl;
    return;
  }
  string ans;
  while (n != 0) {
    if (n % (-2) == 0) {
      ans = "0"+ans;
    } else {
      ans = "1"+ans;
      n--;
    }
    n /= (-2);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;cin>>a>>b;
  ll ans;
  if(a==b)ans=0;
  else if(a<b){
    if(a*b>=0)ans=b-a;
    else{
      if(-a<=b)ans=1+abs(b+a);
      else ans=-b-a+1;
    }
  }
  else{
    if(a*b>0)ans=a-b+2;
    else{
      ans=1+abs(-a-b);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int,input().split()))
total = 0
sum1 = 0
sum2 = 0
minsum = 9999
for i in range(n):
    sum1 = sum(s[i:])
    sum2 = sum(s[:i])
    total = abs(sum1-sum2)
    minsum = min(minsum,total)
print(minsum)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, k - n);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib> 
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define For(i, m, n) for(int i = m;i < n;i++)

using namespace std;


int main(){
    int n;
    cin >> n;
    int arg[n];
    int count = 0;

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

    if(sizeof(arg) == 1){
        
    } else if(sizeof(arg) == 2){
        if(arg[1] < arg[0]){
            count++;
        }
    } else {

        for(int i = 1; i < n; i++){
            for(int j = 0; j < n + 1; j++){
                if(j == i){
                    count++;
                } else {
                    if(arg[j] > arg[i]){
                        break;
                    }
                }
            }
        }

    }
    count++;
    cout << count << endl;

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            var cent = S.Length / 2 - 1;
            for (var i = cent; 0 < i; --i)
            {
                var isEven = true;
                for (var j = 0; j < i; ++j)
                {
                    if (S[j] != S[i + j])
                    {
                        isEven = false;
                        break;
                    }
                }
                if (isEven)
                {
                    WriteLine(i * 2);
                    return;
                }
            }
            //Out.Flush();
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int s,f;
    cin >> s >> f;
    sum += (f - s + 1);
  }
  cout << sum << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  int mx = -1, mmx = -1, mi = -1, mmi = -1;
  rep(i, 0, n) {
    if(v[i] >= mx) {
      mmx = mx;
      mmi = mi;
      mx = v[i];
      mi = i;
    } else if(v[i] >= mmx) {
      mmx = v[i];
      mmi = i;
    }
  }
  rep(i, 0, n) {
    if(i == mi) {
      cout << mmx << "\n";
    } else {
      cout << mx << "\n";
    }
  }
}

Measured memory_bytes: 2432
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

for x, y, h in l:
    if h != 0:
        break

for Cx in range(0, 101):
    for Cy in range(0, 101):
        H = abs(Cx-x) + abs(Cy-y) + h
        if all(hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l):
            print(Cx, Cy, H)
            exit()
                

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;


int main()
{
	while (true)
	{
		int n, s[1000];
		double sum = 0;
		cin >> n;

		if (n == 0) {
			break;
		}

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

		double ave = sum / n;
		sum = 0;

		for (int i = 0;i < n;i++) {
			sum += pow(s[i] - ave, 2);
		}

		printf("%lf\n", sqrt(sum / n));
	}

    return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>

#define NMAX 100000

int partition(int A[], int p, int r) {
    if(p==r){
        return p;
    }
    int i = p - 1, j = p, x = A[r], t;
    while (j < r) {
        if (A[j] > x) {
            // A[p,i]<=x
            j++;
        } else {
            // A[i,j)>x
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
            j++;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}

int main() {
    int A[NMAX],n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d",&A[i]);
    }
    int k=partition(A,0,n-1);
    for(int i=0;i<n;i++) {
        if(i==k){
        printf("[%d]",A[i]);
        }else{
            printf("%d",A[i]);
        }
        if(i==n-1){
            printf("\n");
        }else{
            printf(" ");
        }
    }
    return 0;
}


Measured memory_bytes: 2956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
  long long d, n;
  cin >> d >> n;

  long long x = pow(100, d) * n;
  if(n == 100){ x += pow(100, d);}
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w; cin >> h >> w;
    char m[h][w];
    REP(i,h)REP(j,w) cin >> m[i][j];
    V<bool> ta(h, false), yo(w, false);
    REP(i,h){
        bool flg = true;
        REP(j,w) if(m[i][j] == '#'){
            flg = false;
            break;
        }
        ta[i] = flg;
    }
    REP(j,w){
        bool flg = true;
        REP(i,h) if(m[i][j] == '#'){
            flg = false;
            break;
        }
        yo[j] = flg;
    }
    REP(i,h){
        REP(j,w){
            if(ta[i] or yo[j]) continue;
            cout << m[i][j];
        }
        if(!ta[i]) cout << endl; 
    }
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;
long long size[51];
long long paty[51];

long long answer(int l, long long x){
    if(l==0 && x==1) return 1;
    if(x==0) return 0;
    long long a = size[l-1];
    if(x <= 1+a) return answer(l-1,x-1);
    else if(x == 2+a) return paty[l-1] + 1;
    else if(2+a<x && x<=2*a+2) return answer(l-1,x-a-2) + paty[l-1] + 1;
    else return paty[l];
}
int main(){
    int N;
    long long X;
    cin >> N >> X;
    size[0] = 1;
    paty[0] = 1;
    for(int i=1; i<N+1; i++){
        size[i] = 3+2*size[i-1];
        paty[i] = 1+2*paty[i-1];
    }
    long long ans = answer(N,X);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

ll solve(ll x, ll k, ll d)
{
    x = abs(x);

    auto dc = min(k, x / d);
    auto rest = x - dc * d;
    auto restK = k - dc;
    if(restK % 2 == 0)
    {
        return rest;
    }
    else
    {
        return d - rest;
    }
    abort();
}

int main(int, const char**)
{
    ll x, k, d;
    cin >> x >> k >> d;

    auto ans0 = solve(x, k, d);
    cout << ans0 << endl;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    ret = [0] * N
    for a in A:
        ret[a - 1] += 1
    for r in ret:
        print(r)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 89552
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int n,m;cin>>n>>m;
	_for(i,0,m){
		int x;cin>>x;
		n-=x;
	}
	if(n<0)cout<<-1;
	else cout<<n;
	return 0;
}

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <iomanip> 
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_M = 100000;
const double PI = 3.14159265358979323846;
int dp[5005][5005];



int main(int argc, char *args[]) {
	int n, m, l;
	cin >> n >> m >> l;
	vector<vector<int>> dist(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) {
		dist[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		--a, --b;
		dist[a][b] = dist[b][a] = c;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	vector<vector<int>> dist2(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dist[i][j] <= l)dist2[i][j] = 1;
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
			}
		}
	}
	int q;
	cin >> q;
	for (int qi = 0; qi < q; qi++) {
		int s, t;
		cin >> s >> t;
		--s; --t;
		int ans = dist2[s][t] - 1;
		if (dist2[s][t] == INF)ans = -1;
		cout << ans << endl;
	}
}

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

#define N 1000010 

using namespace std;

int Log[N];

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
	int x = 0, f = 1;
	char c = nc();
	while (c < 48) {
		if (c == '-')
			f = -1;
		c = nc();
	}
	while (c > 47) {
		x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
	}
	return x * f;
}

int bin[21];

int a[20];

struct Node {
	int x, y, z;
}e[100];

int main() {
	int n = rd();
	n -- ;
	bin[0] = 1;
	for (int i = 1; i <= 20; i ++ ) {
		bin[i] = bin[i - 1] << 1;
	}
	int k = 0;
	int m = n;
	bool flag = false;
	while (m) {
		k ++ ;
		if (m % 2 == 0) {
			flag = true;
		}
		m /= 2;
	}
	int tot = 0;
	if (!flag) {
		cout << k + 1 << ' ' ;
		for (int i = 1; i <= k; i ++ ) {
			// i -> i + 1
			tot ++ ;
			e[tot].x = i, e[tot].y = i + 1, e[tot].z = bin[i - 1];
			tot ++ ;
			e[tot].x = i, e[tot].y = i + 1, e[tot].z = 0;
		}
		cout << tot << endl ;
		for (int i = 1; i <= tot; i ++ ) {
			printf("%d %d %d\n", e[i].x, e[i].y, e[i].z);
		}
		return 0;
	}
	// puts("Fuck");
	cout << k << ' ' ;
	for (int i = 1; i < k; i ++ ) {
		tot ++ ;
		e[tot].x = i, e[tot].y = i + 1, e[tot].z = bin[k - i - 1];
		tot ++ ;
		e[tot].x = i, e[tot].y = i + 1, e[tot].z = 0;
	}
	int cnt = 0;
	for (int i = 0; i <= 20; i ++ ) {
		if (n & bin[i]) {
			a[ ++ cnt] = i;
		}
	}
	int pre = bin[a[cnt]];
	for (int i = cnt - 1; i; i -- ) {
		tot ++ ;
		e[tot].x = 1, e[tot].y = k - a[i], e[tot].z = pre;
		pre += bin[a[i]];
	}
	tot ++ ;
	e[tot].x = 1, e[tot].y = k, e[tot].z = n;
	cout << tot << endl ;
	for (int i = 1; i <= tot; i ++ ) {
		printf("%d %d %d\n", e[i].x, e[i].y, e[i].z);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
  std::cin >> x;
  std::vector<int> v(x);
  rep(i,x){
    std::cin >> v[i];
    y+=v[i];
  }
  if(y%10!=0){
    std::cout << y << '\n';
    return 0;
  }else {
    sort(all(v));
    rep(i,x){
      if(v[i]%10!=0){
        std::cout << y-v[i] << '\n';
        return 0;
      }
    }
  }
std::cout << 0 << '\n';
}


Measured memory_bytes: 256
def main():
    import sys
    from collections import Counter

    input = sys.stdin.readline
    input()
    a = list(map(int, input().split()))
    ans = sum(a)
    a = Counter(a)
    for _ in range(int(input())):
        b, c = map(int, input().split())
        if b in a:
            ans += (c - b) * a[b]
            print(ans)
            if c in a:
                a[c] += a[b]
            else:
                a[c] = a[b]
            del a[b]
        else:
            print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 20968
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll INF=1e18;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}
vector< vector<ll> > v(3005,vector<ll>(3005));
ll n,m,k;
ll dp[3005][3005][4];
ll solve_recur(ll x,ll y,ll carry)
{
     if(x>n || y>m)
          return -INF;
     if(dp[x][y][carry]!=-1)
          return dp[x][y][carry];
     dp[x][y][carry]=0;
     if(x==n && y==m)
     {
          if(carry==3)
          {
               dp[n][m][3]=0;
               return 0;
          }
          else 
          {
               dp[n][m][carry]=v[n][m];
               return dp[n][m][carry];
          }
     }
     if(v[x][y]==0)
     {
          dp[x][y][carry]=max(solve_recur(x+1,y,0),solve_recur(x,y+1,carry));
          return dp[x][y][carry];
     }
     else 
     {
          if(carry!=3)
          {
               dp[x][y][carry]=max(dp[x][y][carry],solve_recur(x+1,y,0)+v[x][y]);
               dp[x][y][carry]=max(dp[x][y][carry],solve_recur(x,y+1,carry+1)+v[x][y]);
          }
          dp[x][y][carry]=max(dp[x][y][carry],solve_recur(x+1,y,0));
          dp[x][y][carry]=max(dp[x][y][carry],solve_recur(x,y+1,carry));
     }
     return dp[x][y][carry];
}
void solve()
{
     
     cin>>n>>m>>k;
     ll i,j,ii;
     for(i=1;i<=k;i++)
     {
          ll x,y,val;
          cin>>x>>y>>val;
          v[x][y]=val;
     }
     for(i=0;i<=n;i++)
          for(j=0;j<=m;j++)
               for(ii=0;ii<=3;ii++)
                    dp[i][j][ii]=-1;
     ll ans =solve_recur(1,1,0);
     cout<<ans;

}


int main()
{
    ios;
    ll t;
//    cin>>t;
    t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 356496
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
#define rep(i,a,b)      for(int i=a;i<=b;i++)
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
vi pref(200001,0);
vi dp(200001,0);
int sum(int l,int r)
{
    l=max(l,0);
    return (pref[r]-(l==0?0:pref[l-1]));
}
void oblivious()
{
    int m1=998244353;
    int n,k;
    cin>>n>>k;
    int l[k],r[k];
    pref[1]=1;
    dp[1]=1;
    for(int i=0;i<k;i++)
    {
        cin>>l[i]>>r[i];
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<k;j++)
        {
            if(i-l[j]>=0)
            {
                int cur=sum(i-r[j],i-l[j])%m1;
                dp[i]+=cur%m1;
                dp[i]%=m1;
            }
        }
        pref[i]=(pref[i-1]%m1+dp[i]%m1)%m1;
    }
    dp[n]%=m1;
    cout<<(dp[n]+m1)%m1<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    //int z=t;
    while(t--)
    {
        //cout<<"Case #"<<(z-t)<<": ";
        oblivious();
    }
    return 0;
}
//Editorial
/*

    */

Measured memory_bytes: 6292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

double dp[3010][3010];

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<double> p(n); {
		rep(i, n) cin >> p[i];
	}

	dp[0][0] = 1.0;

	rep(i, n)rep(j, n) {
		dp[i + 1][j + 1] += dp[i][j] * p[i];
		dp[i + 1][j] += dp[i][j] * (1. - p[i]);
	}

	double ans = 0;
	for (int i = n / 2 + 1; i <= n; ++i) {
		ans += dp[n][i];
	}
	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 70784
while l = gets.split.map(&:to_i)
  break if l.all?{|n| n == 0}
  n, m, p = l
  cand = n.times.map{ gets.to_i }
  if cand[m - 1] == 0 then p 0
  else p cand.reduce(:+) * (100 - p) / cand[m - 1]
  end
end

Measured memory_bytes: 8732