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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    int res = 0;
    for(int i = 1; i < n - 1; i++) {
        if((p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)) ||
           p.at(i - 1) > p.at(i) && p.at(i) > p.at(i + 1)) {
            res++;
        }
    }
    cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<vector<int>>v(n,vector<int>(3));
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
      cin>>v[i][j];
  }
  vector<vector<int>>dp(n,vector<int>(3,0));
  dp[0][0]=v[0][0];
  dp[0][1]=v[0][1];
  dp[0][2]=v[0][2];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=max(v[i][0]+dp[i-1][1],v[i][0]+dp[i-1][2]);
    dp[i][1]=max(v[i][1]+dp[i-1][0],v[i][1]+dp[i-1][2]);
    dp[i][2]=max(v[i][2]+dp[i-1][0],v[i][2]+dp[i-1][1]);
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}


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

int gcd(int a,int b){
    if(a > b) swap(a,b);
    if(b % a == 0) return a;
    return gcd(a, b%a);
}

int main() {
    int a,b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
}



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

using namespace std;

using ll = long long;

const long long MOD_NUMBER = 1000000007;
const int MAX = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  char al;
  cin >> al;
  if ('A' <= al && al <= 'Z'){
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    string S;
    cin >> S;
    cout << string(S.size(), 'x') << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <climits>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
	return 0;
}

Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, ans;
ullong p[MXN], h[MXN];
string s;

bool check(llong l, llong r, llong len){
    ullong h1 = h[l + len] - h[l - 1];
    ullong h2 = h[r + len] - h[r - 1];
    h1 *= p[r - l];
    if(h1 == h2) return true;
    return false;
}

int main () {
    ios;
    cin >> n >> s;
    s = '#' + s;
    p[0] = 1;
    for(int i = 1; i <= n; i++){
        p[i] = (p[i - 1] * 31);
        h[i] = (h[i - 1] + (s[i] - 'a' + 1) * p[i]);
    }
    for(llong i = 1; i <= n; i++){
        for(llong j = i + 1; j <= n; j++){
            llong l = 0, r = min(j - i - 1, n - j);
            while(r - l > 1){
                llong m = (r + l) / 2;
                if(check(i, j, m)){
                    l = m;
                }else{
                    r = m;
                }
            }
            if(check(i, j, r)){
                ans = max(r + 1, ans);
            }else if(check(i, j, l)){
                ans = max(l + 1, ans);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define max 10000
#define NIL -1

struct node{int p,l,r;};
struct node t[max];
int n;

void preparse(int u){
	if(u==NIL) return;
	printf(" %d",u);
	preparse(t[u].l);
	preparse(t[u].r);
}
void inparse(int u){
	if(u==NIL) return;
	inparse(t[u].l);
	printf(" %d",u);
	inparse(t[u].r);
}
void postparse(int u){
	if(u==NIL) return;
	postparse(t[u].l);
	postparse(t[u].r);
	printf(" %d",u);
}
int main(){
	int i,v,l,r,root;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		t[i].p=NIL;
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		t[v].l=l;
		t[v].r=r;
		if(l!=NIL) t[l].p=v;
		if(r!=NIL) t[r].p=v;
	}
	for(i=0;i<n;i++) if(t[i].p==NIL) root=i;
	printf("Preorder\n");
	preparse(root);
	printf("\n");
	printf("Inorder\n");
	inparse(root);
	printf("\n");
	printf("Postorder\n");
	postparse(root);
	printf("\n");
	return 0;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = int(2e5), inf = 0x3f3f3f3f;
int n, rt = 1, a[nsz + 5], siz[nsz + 5], dfn[nsz + 5];
vector<int> p[nsz + 5], fm[nsz + 5];

struct graph {
	int sz, hd[nsz + 5];
	
	struct edge {
		int nxt, to;
		
		edge(int nxt = 0, int to = 0) {
			this->nxt = nxt, this->to = to;
		}
	} e[2 * nsz + 5];
	
	inline edge& operator [] (int id) { return e[id]; }
	
	void inline link(int u, int v) {
		e[++sz] = edge(hd[u], v), hd[u] = sz;
		e[++sz] = edge(hd[v], u), hd[v] = sz;
	}
};
graph g;

void dfs(int u = rt, int p = -1) {
	static int t = 0;
	dfn[u] = ++t;
	siz[u] = 1;
	int c = a[u], pc = p != -1 ? a[p] : 0;
	for (int i = g.hd[u]; i; i = g[i].nxt) {
		int v = g[i].to;
		if (v == p)  continue;
		dfs(v, u);
		siz[u] += siz[v];
	}
	::p[c].push_back(u);
	if (pc && c != pc)  ::p[pc].push_back(u);
}

bool inline in(int a, int l, int r) { return a >= l && a <= r; }

num inline f(num a) { return a * (a + 1) / 2; }

num inline solve(int c) {
	static int sum[nsz + 5];
	num res = f(n);
	loop (i, p[c].size()) {
		int u = p[c][i], l = i;
		for (; l - 1 >= 0 && in(dfn[p[c][fm[c][l - 1]]], dfn[u], dfn[u] + siz[u] - 1); l = fm[c][l - 1]);
		fm[c].push_back(l);
		if (a[u] == c)  sum[i + 1] = sum[i] + siz[u] - (sum[i] - sum[l]);
		if (a[u] != c)  sum[i + 1] = sum[i], res -= f(siz[u] - (sum[i] - sum[l]));
	}
	res -= f(n - sum[p[c].size()]);
	return res;
}

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
	}
	cont (i, n - 1) {
		int u, v;
		scanf("%d%d", &u, &v);
		g.link(u, v);
	}
	dfs();
	cont (c, n) {
		printf("%lld\n", solve(c));
	}
}

Measured memory_bytes: 43332
#include <bits/stdc++.h>
using namespace std;
const double pi=2*acos(0.0);
double inff=1.0/0.0;
#define ll           long long int
#define inf          1000000000000000008
#define MOD          1000000007
#define pb           push_back
#define sz(x)        (int)x.size()
#define mp           make_pair
#define lbd          lower_bound
#define ubd          upper_bound
#define ipair        pair<ll,ll> 
#define all(v)       v.begin(),v.end()
#define watch(x)     cout<<(#x)<<" is "<<(x)<<endl;
#define rep(a,b,c)   for(a=(int)b;a<(int)c;a++)    
#define bac(a,b,c)   for(a=(int)b;a>=(int)c;a--)
#define se           second
#define f            first
#define ios          ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
#define mem(a,val)   memset(a,val,sizeof a)
#define endl         "\n"
#define mxn          200002
#define vi           vector<ll>
#define vii          vector<ipair> 
#define si           set<ll> 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*Variables Start*/
ll x,y,n,i,z,j,k,w,u,q,m,t;
ll rit[mxn];
/*Variables End*/
void solve()
{
  string str;
  cin>>n>>m;
  n++;
  cin>>str;
  ll timer=0,left=0,curr=1;
  reverse(all(str));
  rit[0]=0;
  while(curr<n)
  {
    timer++;
    // cout<<timer<<" "<<left<<endl;
    ll prev=left;
    while(curr<=left+m and curr<n)
    {
      if(str[curr]=='0')
      {
        prev=curr;
      }
      curr++;
    }
    if(prev==left)
    {
      cout<<"-1"<<endl;
      return;
    }
    left=prev;
    rit[timer]=prev;
  }
  while(timer)
  {
    cout<<rit[timer]-rit[timer-1]<<" ";
    timer--;
  }
  cout<<endl;
}
int main() 
{ 
  int TESTS=1;
  ios;  
  // cin>>TESTS;
  while(TESTS--)
  {
    solve();
  }  
}

Measured memory_bytes: 1488
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int64_t n, a, b;
    std::cin >> n >> a >> b;
    std::vector<int64_t> arr(n);
    for (int i = 0; i < n; ++i)
    {
        std::cin >> arr[i];
    }
    std::sort(arr.begin(), arr.end());

    const int64_t c = a - b;
    int64_t min = (arr.front() + a - 1) / a;
    int64_t max = (arr.back() + b - 1) / b;
    if (min == max)
    {
        std::cout << min << std::endl;
        return 0;
    }

    int64_t t = (min + max) / 2;
    while (true)
    {
        const int64_t base = t * b;
        int64_t count = 0;
        for (const auto h : arr)
        {
            if (h <= base)
            {
                continue;
            }

            count += (h - base + c - 1) / c;
        }
        if (count > t)
        {
            min = t + 1;
        }
        else if (count <= t)
        {
            max = t;
        }

        if (min == max)
        {
            t = min;
            break;
        }
        else
        {
            if (min + 1 == max)
            {
                t = min;
            }
            else
            {
                t = (min + max) / 2;
            }
        }
    }

    std::cout << t << std::endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define PRINT(x) cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;


int main()
{
    string S;
    cin >> S;
    string pre = "";
    ll cnt = 0;
    ll left = 0;
    REP(i, S.length()) {
        if (S.substr(left, i+1 - left) != pre) {
            pre = S.substr(left, i+1 - left);
            left = i+1;
            cnt++;
        }
    }
    PRINT(cnt);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=8 && b<=8)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

const int mod = 1000000007;

struct mint {
    ll x;

    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

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

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};


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

    vector<P> s;
    for (int i = 1; i * i <= n; i++) {
        s.push_back(P(i, 0));
        s.push_back(P(n / i, 0));
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    rep(i, s.size() - 1) {
        int l = n / s[i + 1].first;
        int r = n / s[i].first;
        s[i].second = r - l;
    }
    s.back().second = 1;
    int m = s.size();

    map<int, int> mp;
    rep(i, m) mp[s[i].first] = i;

    vector<vector<mint>> dp(k + 1, vector<mint>(m));
    dp[0][mp[n]] = 1;

    rep(i, k) {
        for (int j = m - 2; j >= 0; j--) dp[i][j] += dp[i][j + 1];
        rep(j, m) {
            int nj = mp[n / s[j].first];
            dp[i + 1][j] = dp[i][nj] * s[j].second;
        }
    }

    mint ans = 0;
    rep(j, m)ans += dp[k][j];
    cout << ans.x << endl;

}

Measured memory_bytes: 54264
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0;i<(n);i++)
using namespace std;

int N;
map<int, int> mp;

int calc(int x, int y, int z) {
  int res = x*x + y*y + z*z + x*y + y*z + z*x;
  return res;
}

int main() {
  cin >> N;
  
  //初期化
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
  	    int f = calc(i, j, k);
        mp[f]++;
      }
    }  
  }
  
  for (int i = 1; i <= N; i++) {
    cout << mp[i] << endl;
  }
}

Measured memory_bytes: 5400
n, m = map(int, input().split())
mod = lambda x:x%n+1
for i in range((m+1)//2):
    print(mod(-i-(m+1)//2), mod(i+1-(m+1)//2))
for i in range(m//2):
    print(mod(-i+m//2), mod(i+2+m//2))

Measured memory_bytes: 9144
n, q = [int(i) for i in input().split()]
s = input()
td = reversed([input().split() for _ in range(q)])

l = 0
r = n - 1
for t, d in td:
    if d == "L":
        if 0 <= l < n and s[l] == t:
            l = l + 1

        if 0 <= r + 1 < n and s[r + 1] == t:
            r = min(r + 1, n - 1)
    else:
        if 0 <= l-1 < n and s[l - 1] == t:
            l = max(0, l - 1)

        if 0 <= r < n and s[r] == t:
            r = r - 1


'''
    if s[l] == t:
        if d == "L":
            l += 1
        else:
            l -= 1
        l = max(0, min(n - 1, l))
    if s[r] == t:
        if d == "L":
            r += 1
        else:
            r -= 1
        r = max(0, min(n - 1, r))
'''
print(max(0, r-l+1))


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

int main(){
  int a,b,c,d;
//  int tmpmin,tmpmax;
  int ans;
  cin >> a >> b >> c >> d;
  if(b <= c or d <= a) ans = 0;
  else ans = min(b,d) - max(c,a);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
char C;
cin >> C;
if(C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o'){
cout << "vowel" << endl;
}
else {
cout << "consonant" << endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
class BinaryIndexedTree {
	std::vector<long long int> vec;
public:
	BinaryIndexedTree(int size) : vec(size, 0) {};
	long long int get(int position) const {
		long long int result = 0;
		while (position >= 0) {
			result += vec[position];
			position -= ~position & (position + 1);
		}
		return result;
	}
	void increase(int position, int value) {
		while (position < vec.size()) {
			vec[position] += value;
			position += ~position & (position + 1);
		}
	}
};
int main() {
	int q; std::cin >> q;
	std::vector<std::vector<int>> query(q);
	for (auto& vec: query) {
		int t; std::cin >> t;
		if (t == 1) {
			vec.resize(2);
			for (auto& v : vec) std::cin >> v;
		}
	}
	std::vector<int> a_all; a_all.reserve(q);
	for (const auto& p : query) if (!p.empty()) a_all.push_back(p.front());
	std::sort(a_all.begin(), a_all.end());
	std::unordered_map<int, int> map;
	for (auto i = 0; i < a_all.size(); ++i) {
		if (i > 0 && a_all[i] == a_all[i - 1]) continue;
		map[a_all[i]] = i;
	}
	BinaryIndexedTree sum_bit(a_all.size()), count_bit(a_all.size());
	long long int a_sum{ 0 }, b_sum{ 0 };
	int count{ 0 };
	for (const auto vec : query) {
		if (vec.empty()) {
			int min = 0, max = a_all.size();
			while (min < max) {
				const auto mid = (min + max) >> 1;
				const auto c = count_bit.get(mid);
				if (c * 2 < count) {
					min = mid + 1;
				}
				else {
					max = mid;
				}
			}
			const auto minus = sum_bit.get(max) - (count_bit.get(max) - ((count + 1) >> 1)) * a_all[max];
			const auto plus = a_sum - minus;
			const auto min_value = (count & 1) * a_all[max] + b_sum + plus - minus;
			std::cout << a_all[max] << ' ' << min_value << '\n';
		}
		else {
			a_sum += vec[0]; b_sum += vec[1];
			const auto pos = map[vec[0]];
			sum_bit.increase(pos, vec[0]);
			count_bit.increase(pos, 1);
			++count;
		}
	}
}


Measured memory_bytes: 16288
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, t;
    cin >> n >> t;
    int a, b;
    int ans = INT_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (b <= t) {
            ans = min(ans, a);
        }
    }
    if (ans < INT_MAX) {
        cout << ans << "\n";
    } else {
        cout << "TLE\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
using namespace std;

int main(int argc,char *argv[])
{
    ll a,b,k;
    cin>>a>>b>>k;
    if(a-k>=0)
        cout<<a-k<<' '<<b;
    else if(a+b-k>=0)
        cout<<0<<' '<<a+b-k;
    else
        cout<<0<<' '<<0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(double i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b;
  cin >> a >> b;
  REP(i, 1001001001){
    int A = i * 0.08;
    int B = i * 0.1;
    if(A == a && B == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}



Measured memory_bytes: 256
require "set"
x, n = gets.split.map(&:to_i)
arr = gets.to_s.split.map(&:to_i).to_set

if !arr.include?(x)
  puts x
  return
end

(1..(n+1)).each do |i|
  if !arr.include?(x - i)
    puts x - i
    return
  elsif !arr.include?(x + i)
    puts x + i
    return
  end
end


Measured memory_bytes: 14492
#include<iostream>
#include<string>

using namespace std;

string s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> s;
	cout << *s.begin() << s.size() - 2 << *--s.end() <<'\n';
	return 0;
}



Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 0
# +1 しないと実際に input() から取得した値が range で処理できない
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if (a * 500 + b * 100 + c * 50) == X:
                res += 1
print(res)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// }}}

signed main()
{
    int N;
    i64 a[100010];
    i64 sum[100010] {};

    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        sum[i] = sum[i-1] + a[i];
    }

    auto slv = [&](bool p) {
        vector<int> s(sum, sum + N+1);
        i64 ans = 0;
        i64 propagation = 0;

        for (int i = 1; i <= N; ++i) {
            i64 tmp = 0;
            s[i] += propagation;

            if(p && s[i] <= 0) {
                tmp = (1 - s[i]);
            } else if (!p && s[i] >= 0) {
                tmp = -1 - s[i];
            }

            ans += abs(tmp);
            propagation += tmp;
            p = !p;
        }
        return ans;
    };

    cout << min(slv(true), slv(false)) << endl;

    return 0;
}


Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,M; cin >> N >> M;
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        ll A,B; cin >> A >> B;
        A--; B--;
        G[A].emplace_back(B);
        G[B].emplace_back(A);
    }

    vector<pll> dist(N,pll(INF,-1));
    dist[0].first = 0;
    queue<int> q; q.emplace(0);
    while(q.size()){
        int n = q.front(); q.pop();

        for(auto next:G[n]){
            if(dist[next].first > dist[n].first + 1){
                dist[next].first = dist[n].first + 1;
                dist[next].second = n+1;
                q.emplace(next);
            }
        }
    }
    if(max_element(dist.begin(),dist.end())->first == INF){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        for(int i = 1; i < N;i++){
            cout << dist[i].second << endl;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve<ll>(0);
    // cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 13308
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, f;
int main() {
	while(cin >> a >> b >> e >> c >> d >> f) {
		double p = d * e - b * f; p /= a * d - b * c; if(-1e-10 < p && p < 1e-10) p = 0.0;
		double q = a * f - c * e; q /= a * d - b * c; if(-1e-10 < q && q < 1e-10) q = 0.0;
		printf("%.3lf %.3lf\n", p, q);
	}
	return 0;
}

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

int main(){
    vector<int> nedan(3);
    for(int i=0;i<3;i++){
        cin >> nedan.at(i);
    }
    stable_sort(nedan.begin(),nedan.end());
    cout << nedan.at(0)+nedan.at(1) << endl;
}

Measured memory_bytes: 256
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int h[100001],a,b,n,m,ans;
bool bad[100001];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>h[i];
	}
	for(int i=1;i<=m;++i)
	{
		cin>>a>>b;
		if(h[a]<=h[b])
		{
			bad[a]=true;
		}
		if(h[a]>=h[b])
		{
			bad[b]=true;
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(!bad[i])
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define debug(x) cout << #x << "=" << (x) << endl;
 
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  int N;
  cin>>N;
  int cost[N][N];
  ll res=0;
  rep(i,N)
    rep(j,N)
      cin>>cost[i][j];
  rep(i,N)
    REP(j,i+1,N)
      res+=min(cost[i][j],cost[j][i]);
  cout<<res<<endl;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


Measured memory_bytes: 3224
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
#include <stack>
#include <utility>
#include <math.h>
using namespace std;

typedef long long ll;

const int MAX_N = 10010, MAX_M = 10010, INF = 10000000;

typedef pair<int, int> P;

int main()
{
	string S;
	int A, B, C, D;
	cin >> S;
	A = S[0] - '0';
	B = S[1] - '0';
	C = S[2] - '0';
	D = S[3] - '0';

	if (A + B + C + D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "+");
		S.insert(2, "+");
		S.insert(1, "+");
		cout << S << endl;
		return 0;
	}

	if (A + B + C - D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "-");
		S.insert(2, "+");
		S.insert(1, "+");
		cout << S << endl;
		return 0;
	}

	if (A + B - C + D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "+");
		S.insert(2, "-");
		S.insert(1, "+");
		cout << S << endl;
		return 0;
	}

	if (A + B - C - D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "-");
		S.insert(2, "-");
		S.insert(1, "+");
		cout << S << endl;
		return 0;
	}

	if (A - B + C + D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "+");
		S.insert(2, "+");
		S.insert(1, "-");
		cout << S << endl;
		return 0;
	}

	if (A - B + C - D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "-");
		S.insert(2, "+");
		S.insert(1, "-");
		cout << S << endl;
		return 0;
	}

	if (A - B - C + D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "+");
		S.insert(2, "-");
		S.insert(1, "-");
		cout << S << endl;
		return 0;
	}

	if (A - B - C - D == 7)
	{
		S.insert(4, "=7");
		S.insert(3, "-");
		S.insert(2, "-");
		S.insert(1, "-");
		cout << S << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
aaa = list(map(int, input().split()))
sa = sum(aaa)
bbb = list(map(int, input().split()))
for i, b in enumerate(bbb):
    c = min(aaa[i], b)
    aaa[i] -= c
    aaa[i + 1] -= min(aaa[i + 1], b - c)
print(sa - sum(aaa))


Measured memory_bytes: 18476
using System;

namespace DChristmas
{
    class Solution
    {
        long[] burgerWidth;
        long[] pattiesWidth;


        public long GetNumberOfPattiesFromBurgerLevel(long n, long x)
        {
            if (x <= 0 || n < 0)
                return 0;

            burgerWidth = new long[ n + 1];
            pattiesWidth = new long[n + 1];

            burgerWidth[0] = 1;
            pattiesWidth[0] = 1;

            CalculateBurgerWidth(n);

            if (x > burgerWidth[n])
                return 0;

            return GetPattiesFrom(n,x);
        }

        public void CalculateBurgerWidth(long level)
        {
            for (int i = 1; i <= level; i++)
            {
                burgerWidth[i] = 2 * burgerWidth[i - 1] + 3;
                pattiesWidth[i] = 2 * pattiesWidth[i - 1] + 1;
            }
        }

        public long GetPattiesFrom(long n, long x)
        {
            if (n == 0)
            { 
                if (x <= 0)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            else if(x > burgerWidth[n - 1] + 1)
            {
                return GetPattiesFrom(n - 1,  x - burgerWidth[n-1] - 2) + 1 + pattiesWidth[n-1];
            }
            else
            {
                return GetPattiesFrom(n - 1, x - 1);
            }
        }

        public long GetHamburgerWidthFromFirstLevel(long x)
        {
            if (x == 0)
                return 0;

            if (x < 5)
                return x - 1;

            return x - 2;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            long n = long.Parse(str[0]);
            long x = long.Parse(str[1]);

            Solution s = new Solution();

            Console.WriteLine(s.GetNumberOfPattiesFromBurgerLevel(n, x));
        }
    }
}

Measured memory_bytes: 11092
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let ints = readInts()
let n = ints[0]
let sum = ints[1]

func main() {
    for i in 0...n {
        for j in 0...(n - i) {
            for k in 0...(n - i - j) {
                if i * 10_000 + j * 5_000 + k * 1_000 == sum && i + j + k == n {
                    print("\(i) \(j) \(k)")
                    return
                }
            }
        }
    }
    print("-1 -1 -1")
}

main()


Measured memory_bytes: 7952
n,c=map(int,input().split())

import heapq  # heapqライブラリのimport
tv=[-1]
heapq.heapify(tv)  # リストを優先度付きキューへ
#print(heapq.heappop(a))  # 最小値の取り出し
#heapq.heappush(a, -2)
ch=[0]*c

stc=[]
for _ in range(n):
    s,t,c=map(int,input().split())
    stc.append((s,t,c))

stc.sort()

for item in stc:
    s,t,c=item[0],item[1],item[2]
    temp=heapq.heappop(tv)
    if temp<s:
        heapq.heappush(tv,t)
    elif temp==s and ch[c-1]==temp:
        heapq.heappush(tv, t)
    else:
        heapq.heappush(tv,temp)
        heapq.heappush(tv,t)
    ch[c-1]=t
    #print(tv)
print(len(tv))




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

int main() {
  int n, k;

  cin >> n >> k;

  vector<long> a(n + 1);

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

  for (int i = 1; i <= n - k; i++) {
    if (a[i] < a[i + k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 4792
#include<iostream>
using namespace std;
string ar[2][3050];
string a,b;
string bg(string l,string r){
	if (l.size()>r.size()) return l;
	return r;
}
int main(){
	cin>>a>>b;
	for(int i=1;i<=a.size();i++){
		for(int j=1;j<=b.size();j++){
			ar[i%2][j]=bg(ar[(i-1)%2][j],ar[i%2][j-1]);
			if(a[i-1]==b[j-1])
			ar[i%2][j]=bg(ar[i%2][j],ar[(i-1)%2][j-1]+a[i-1]);
		}
	}
	cout<<ar[a.size()%2][b.size()];
}

Measured memory_bytes: 16816
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  string s;cin>>s;
  int n;n = s.length();
  int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
  rep(i,n){
    if(i%2==0&&s[i] =='1')cnt1++;
    if(i%2==1&&s[i]=='1') cnt2++;
    if(i%2==0&&s[i] =='0')cnt3++;
    if(i%2==1&&s[i]=='0') cnt4++;
  }
  int ans = min(cnt1+cnt4,cnt2+cnt3);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	xy := []int{a * c, a * d, b * c, b * d}
	sort.Ints(xy)
	fmt.Println(xy[3])
}


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

int main(){
    int N,u,k,x;
    cin>>N;
    
    int array[N][N];
    for(int i=0;i<N;i++){for(int j=0;j<N;j++){array[i][j]=0;}}
    
    for(int i=0;i<N;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>x;
            array[u-1][x-1]=1;
        }
    }
    
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(j!=0){
                    cout<<" ";
                }
                cout<<array[i][j];
            }
            cout<<"\n";
        }
        
        return 0;

}


Measured memory_bytes: 3112
'use strict'
const main = (input: string) => {
    const data = [1, 2, 3];
    const std: string[] = input.split('\n')
    const a: number = ~~std.shift()
    const b: number = ~~std.shift()
    const ir = [a, b]
    const r = data.filter((obj) => ir.indexOf(obj) == -1);
    console.log(r[0])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


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

priority_queue<pair<int,int>> pq;
for(int i = 0;i<N;i++){
    pq.push(P(A[i]-A[i]/2,i));
}

for(int i = 0;i<M;i++){
    int k = pq.top().second;//A[i]-A[i]/2がMAXになるA[i]のiを取得
    A[k] /= 2;
    pq.pop();
    pq.push(P(A[k]-A[k]/2,k));
}
ll ans = 0;
for(int i = 0;i<N;i++){
    ans += A[i];
}
cout << ans << endl;
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>


using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);

    lint mod = 1e9 + 7;
    int n, k; cin>>n>>k;
    vl a(n);
    vl plus;
    vl mius;
    for (lint &i : a)
    {
        cin>>i;
        if (i >= 0) plus.push_back(i);
        else if (i < 0) mius.push_back(i);
    }
    sort(plus.rbegin(), plus.rend());
    sort(mius.begin(), mius.end());

    sort(a.begin(), a.end(), [](lint m, lint n){
        return abs(m) > abs(n);
    });

    if (plus.size() + mius.size() < k)
    {
        cout<<0;
        return 0;
    }

    int minmius = k - plus.size();
    if (minmius < 0) minmius = 0;

    if (k == n){

        lint res = 1;
        for (lint i : a){
            res = res * i %mod;
        }
        cout<<(res + mod)%mod;
        return 0;
    }

    if (mius.size() == n){
        lint res = 1;
        if (k%2 == 0){
            for (int i=0; i<k; ++i){
                res = res * (-mius[i]) % mod;
            }
        } else {
            for (int i = n-1; i>= n-k; i--){
                res = res * (-mius[i]) % mod;
            }
            res = -res + mod;
        }
        cout<<res;
        return 0;
    }

    int miuspair;
    for (miuspair = minmius/2 + minmius%2;
         (miuspair+1) * 2 <= mius.size() && (miuspair+1) * 2 <= k;
         miuspair++)
    {
        int need = k - 2*miuspair;
        lint prev = plus[need-1] * plus[need-2];
        lint next = mius[2*miuspair] * mius[2*miuspair + 1];

        if (next < prev) break;
    }

    lint res = 1;
    int need = k - 2*miuspair;
    for (int i=0; i< need; ++i) {
        res = res * plus[i] % mod;
    }

    for (int i = 0; i< 2*miuspair; ++i){
        res = res * (-mius[i]) % mod;
    }

    cout<<res;





}


Measured memory_bytes: 6876
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    n=len(s)
    target="keyence"
    if s==target:
        print("YES")
        sys.exit()
    for i in range(n):#文字列開始
        for j in range(n):#文字列終了
            for k in range(i,j+1):
                #区間[i,j]が予想
                s_exp=s[:i]+s[j+1:]
                if s_exp==target:
                    print("YES")
                    sys.exit()
    print("NO")



if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n,k;
  string s;
  cin>>n>>s>>k;
  for(int i=0;i<n;i++){
    if(s[i]==s[k-1])cout<<s[i];
    else cout<<"*";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n, m;
long x[100005];

int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 0; i < n; i++){
		scanf("%ld", &x[i]);
	}
	long ans = LINF;
	for(int i = 0; i+m-1 < n; i++){
		//printf("%ld, %ld\n", x[i], x[i+m-1]);
		if(x[i] * x[i+m-1] < 0){
			ans = std::min(ans, std::min(std::abs(x[i]), std::abs(x[i+m-1])) + (x[i+m-1] - x[i]));
		}else{
			if(x[i+m-1] <= 0){
				ans = std::min(ans, -x[i]);
			}else{
				ans = std::min(ans, x[i+m-1]);
			}
		}
		if(ans == 0){
			//printf("!\n");
		}
	}
	printf("%ld\n", ans);
	return 0;
}
			


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 9;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 2e5 + 5;

map<int, int> cnt;

int main() {
 
	sync;
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		cnt[x]++;
	}

	int ans = 0;
	for (pii p : cnt) {
		if (p.first == p.second) continue;
		if (p.first < p.second) ans += p.second - p.first;
		else ans += p.second;
	}
	cout << ans << endl;

	return 0;
}


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


    typedef long long ll;
    typedef pair<int,int> ii;
    typedef vector<int> vi;
    typedef vector<ii> vii;
    typedef long double ld;

    typedef set<int>::iterator sit;
    typedef map<int,int>::iterator mit;
    typedef vector<int>::iterator vit;

    const int INF = 1e9 + 7;
    const int MOD = 1e9 + 7;
    const int MAXN = 1e6 + 3;

    #define _  %  MOD
    #define __ %= MOD

    #define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
    #define      sortA(v)          sort(v.begin(), v.end())
    #define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
    #define      fill(a)           memset(a, 0, sizeof (a))

    #define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
    #define      rep(i, n)         for(ll i = 0; i < (n); ++i)
    #define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
    #define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
    #define watch(x) cout << (#x) << " is " << (x) <<endl

    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back

    #define fbo find_by_order
    #define ook order_of_key

    ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
    ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

    int main()
    {
        ios_base::sync_with_stdio(false); // don't use printf and scanf
        cin.tie(NULL); // cout<<fixed<<setprecision
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<'\n';
        return 0;
    }
    // JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
    // KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long ans=1,n;
    cin>>n;
    f(i,1,n+1){
        ans*=i;
        ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
s = int(input())
a = s % 100
b = ((s-a) / 100)
if a <= 12 and b <= 12 and a != 0 and b != 0:
  print("AMBIGUOUS")
elif b <= 12 and b != 0:
  print("MMYY")
elif a <= 12 and a != 0:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 8964
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const string NO = "IMPOSSIBLE";

void solve(long long A, long long B){
 if((A+B)%2){
   op("IMPOSSIBLE")
   return;
 }
 op((A+B)/2)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e16;
struct edge {int to; long long int cap; int rev;} ;
 
vector<edge> G[2010];
int level[2010];
int iter[2010];
 
void add_edge(int from, int to, long long int cap){
	edge e;
	e.to=to, e.cap=cap, e.rev=G[to].size();
	G[from].push_back(e);
	e.to=from, e.cap=0, e.rev=G[from].size()-1;
	G[to].push_back(e);
}
 
void bfs(int s){
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		for(int i=0; i<G[v].size(); i++){
			edge e=G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}
 
long long int dfs(int v, int t, long long int f){
	if(v==t) return f;
	for(int &i=iter[v]; i<G[v].size(); i++){
		edge &e=G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
			long long int d=dfs(e.to, t, min(f, e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
 
long long int max_flow(int s, int t){
	long long int flow=0;
	while(1){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter, 0, sizeof(iter));
		long long int f;
		while((f=dfs(s, t, INF))>0){
			flow+=f;
		}
	}
}
int n, m, l;
ll d[101][101];
void init(){
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) d[i][j]=0;
            else d[i][j]=INF;
        }
    }
    for(int i=0; i<2010; i++){
        G[i].clear();
    }
}
int main()
{
    while(1){
        cin>>n>>m>>l;
        if(n==0) return 0;
        init();
        for(int i=0; i<m; i++){
            int u, v, d0; cin>>u>>v>>d0;
            d[u][v]=d[v][u]=d0;
        }
        for(int k=0; k<n; k++){
            for(int i=0; i<n; i++){
                for(int j=0; j<n; j++){
                    d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
                }
            }
        }
        int p[1010]; ll t[1010];
        for(int i=0; i<l; i++){
            cin>>p[i]>>t[i];
        }
        for(int i=0; i<l; i++){
            for(int j=0; j<l; j++){
                if(i==j) continue;
                if(t[i]+d[p[i]][p[j]]<=t[j]){
                    add_edge(i, j+l, 1);
                }
            }
        }
        int S=2*l, T=2*l+1;
        for(int i=0; i<l; i++){
            add_edge(S, i, 1);
            add_edge(i+l, T, 1);
        }
        cout<<l-max_flow(S, T)<<endl;
    }
    return 0;
}


Measured memory_bytes: 49868
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a , int b){return a<b? a:b;}

int main(){
  int i,q;
  P u;
  scanf("%d%d",&n,&q);
  head=1;tail=n+1;
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  int c,time=0;
  while(head != tail){

    u=dequeue();
    c=min(u.t,q);
    time+=c;
    if(u.t-c<=0){
      printf("%s %d\n", u.name,time);
    }else{u.t=u.t-c;enqueue(u);}
  }
  return 0;

}



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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  if (S==1000000000000000000) {
    cout << "0 0 0 1000000000 1000000000 0\n";
    return 0;
  }

  ll l = -1, r = 1e9 + 1;
  ll a, b, c, d;
  while (l+1 < r) {
    ll w = (l + r)/2;
    if (w * w > S) {
      r = w;
    } else {
      l = w;
    }
    a = l;
  }
  a++;
  d = a;

  ll x = a * d - S;
  for (int i = 1; i <= x; i++) {
    if (x % i == 0 && x / i <= 1e9) {
      b = i;
      c = x / i;
      break;
    }
  }

  cout << "0 0 " << a << SP << b << SP << c << SP << d << "\n";
  return 0;
}

Measured memory_bytes: 256