akhauriyash/Code-Regression huggingface dataset:
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_3-C: Doubly Linked List

#include <cstdio>

template <typename T>
class DoublyLinkedList {
  struct Node {
    Node* prev_;
    Node* next_;
    T x_;
  };
  Node sentinel_;
public:
  DoublyLinkedList()
  {
    sentinel_.prev_ = sentinel_.next_ = &sentinel_;
  }

  void insert_elem_to_first(const T& x)
  {
    Node* np = new Node();
    np->x_ = x;
    np->prev_ = &sentinel_;
    np->next_ = sentinel_.next_;
    np->prev_->next_ = np;
    np->next_->prev_ = np;
  }

  void delete_first_elem(const T& x)
  {
    delete_node(search_first_elem(x));
  }

  void delete_first_node()
  {
    delete_node(sentinel_.next_);
  }

  void delete_last_node()
  {
    delete_node(sentinel_.prev_);
  }
private:
  void delete_node(Node* np)
  {
    if (np) {
      np->next_->prev_ = np->prev_;
      np->prev_->next_ = np->next_;
      delete np;
    }
  }

  Node* search_first_elem(const T& x) const
  {
    Node* np = sentinel_.next_;
    for (;np != &sentinel_; np = np->next_) {
      if (np->x_ == x) return np;
    }
    return nullptr;
  }
public:
  void print(const char* sep=" ") const
  {
    const char* out_sep = "";
    for (const Node* np = sentinel_.next_; np != &sentinel_; np = np->next_) {
      printf("%s%d", out_sep, np->x_);
      out_sep = sep;
    }
    puts("");
  }
};

int main()
{
  unsigned int n;
  std::scanf("%d", &n);
  DoublyLinkedList<int> list;

  for (auto i = 0u; i < n; ++i) {
    char buf[11+1]; // max_length == "deleteFirst".size()+1('\0')
    int x;
    std::scanf("%11s", buf);
    if (buf[0] == 'i') { // insert x
      std::scanf("%d", &x);
      list.insert_elem_to_first(x);
    } else if (buf[6] == 'F') { // deleteFirst
      list.delete_first_node();
    } else if (buf[6] == 'L') { // deleteLast
      list.delete_last_node();
    } else { // (buf[6] == '\0') // delete x 
      std::scanf("%d", &x);
      list.delete_first_elem(x);
    }
  }
  list.print();
}

// eof

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

using namespace std;

string t[10] = {" ", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"};

int main(){
    string s;
    while(cin >> s){
        int n = stoi(s.substr(0, 1)), count = 1;
        string ret;
        for(int i=0; i< s.size()-1; i++){
            if(n == stoi(s.substr(i+1, 1)))count++;
            else {
                if(n == 0) for(int i=0; i < count-1; i++) ret += " ";
                else ret += t[n][count-1];
                n = stoi(s.substr(i+1, 1)); count = 1;
            }
        }
        ret += t[n][count-1];
        cout << ret << endl;
    }
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
typedef long long lint;
using namespace std;

const int MAXN = 212345;
int A[MAXN];
lint cumsum[MAXN];

// [l, r) の和
lint get_sum(int l, int r) {
    return cumsum[r] - cumsum[l];
}

// [l, r) 区間でなるべく差が小さくなるようにする
int get_center(const int l, const int r) {
    const auto f = [&](const int c) {
        const lint left = get_sum(l, c);
        const lint right = get_sum(c, r);
        return abs(right - left);
    };
    // [L, R)
    int L = l+1, R = r;
    while (R - L > 2) {
        const int m1 = (2*L+R) / 3;
        const int m2 = (L+2*R) / 3;
        if (f(m1) < f(m2)) {
            R = m2;
        } else {
            L = m1;
        }
    }
    int ret = -1;
    lint mini = 1e18;
    for (int i = L; i < R; i++) {
        lint diff = f(i);
        if (diff < mini) {
            mini = diff;
            ret = i;
        }
    }
    return ret;
    // tle
    //int ret = -1;
    //lint mini = 1e18;
    //for (int c = l+1; c < r; c++) {
    //    const lint left = get_sum(l, c);
    //    const lint right = get_sum(c, r);
    //    const lint diff = abs(right - left);
    //    if (diff < mini) {
    //        mini = diff;
    //        ret = c;
    //    }
    //}
    //return ret;
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 1; i <= N; i++) {
        cumsum[i] = cumsum[i-1] + A[i-1];
    }
    lint mini = 1e18;
    // [0, c), [c, N) で区切る
    // c >= 2, N-c >= 2 より 2 <= c <= N-2
    for (int c = 2; c <= N-2; ++c) {
        // 二つの区間で差が最小になるところを探す
        const int c1 = get_center(0, c);
        const int c2 = get_center(c, N);
        vector<lint> pqrs(4);
        pqrs[0] = get_sum(0, c1);
        pqrs[1] = get_sum(c1, c);
        pqrs[2] = get_sum(c, c2);
        pqrs[3] = get_sum(c2, N);
        sort(pqrs.begin(), pqrs.end());
        mini = min(mini, pqrs[3] - pqrs[0]);
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define inf 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0;i < n;i++) cin >> h[i];
  int ans = 0;
  int down = 0;
  for (int i = 0;i < n-1;i++) {
    if (h[i] >= h[i+1]) down += 1;
    if (h[i] < h[i+1]) down = 0;
    if (down > ans) ans = down;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

void a()
{
    string s;
    cin >>s;
    bool tf = true;
    if(s.length()%2==1)
    {
        cout<<"No";
        return;
    }
    for(int i=0;i<s.length()/2;i++)
    {
        if((s.substr(i*2,2).compare("hi"))!=0)
        {
            tf = false;
        }
    }
    if(tf)
    cout<<"Yes";
    else cout<<"No";
    //cout << 1<<endl;
}
int main(void)
{
    a();
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<double,double>;

signed _main(){
  // 入力
  int n; // 都市数
  cin >> n;
  int P[n],Q[n];
  rep(i,n) cin >> P[i];
  rep(i,n) cin >> Q[i];
  // 初期順列
  vector<int> order(n);
  for (int i = 0; i < n; ++i) order[i] = i+1;
  int a=0,b=0,cnt=0;
  // 探索
  do {
    cnt++;
    int acnt=0,bcnt=0;
    for (int i = 0; i < n; ++i) {
      if(order[i]==P[i]) acnt++;
      if(order[i]==Q[i]) bcnt++;
    }
    if(acnt==n) a=cnt;
    if(bcnt==n) b=cnt;
    if(a!=0 && b!=0) break;
  } while (next_permutation(order.begin(), order.end()));

  // 答えを出力
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

lli gcd(lli a , lli b) {
    if(b == 0) return a;
    a %= b;
    return gcd(b,a);
}


lli n, m;
lli a[MAXN], dp[MAXN];

lli f(lli x) {
    if (x > n) return 0;
    if (x == n) return 1;
    if (dp[x] != -1) return dp[x];

    lli ans = 0;

    if (!binary_search(a + 1, a + m + 1, x + 1)) {
        ans += f(x + 1);
        ans %= MOD;
    }

    if (!binary_search(a + 1, a + m + 1, x + 2)) {
        ans += f(x + 2);
        ans %= MOD;
    }

    return dp[x] = ans;
}
void solve() {
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));

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

    cout << f(0) << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

#define MAX 500000

int A[MAX] = { 0 };

int partition(int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = 0; j < r; j++) {
		if (A[j] <= x) {
			i = i + 1;
			std::swap(A[i], A[j]);
		}
	}
	std::swap(A[i + 1], A[r]);
	return i + 1;
}

int main() {
	int n = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	int r = A[n-1];
	int q = partition(0,n-1);

	for (int i = 0; i < n; i++) {
		if (i) {
			printf(" ");
		}
		if (i == q) {
			printf("[%d]", A[i]);
		}
		else {
			printf("%d", A[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

vector<string> st;

int main(void){
	int c[5555],p[5555],i,j,n,m,k;
	string s;
	cin >> s;
	cin >> k;
	n = s.l_ength();
	if(n <= 50){
		for(i=0; i<n; ++i){
			for(j=i; j<n; ++j){
				st.push_back(s.substr(i,j-i+1));
			}
		}
		sort(st.begin(),st.end());
		st.push_back("nyan");
		i = 0;
		while(k){
			if(st[i] != st[i+1]){
				--k;
			}
			++i;
		}
		cout << st[i-1] << endl;
		return 0;
	}
	for(i=(n-k); i>=0; --i){
		st.push_back(s.substr(i,k));
	}
	for(i=1; i<=k; ++i){
		st.push_back(s.substr(n-i,i));
	}
	sort(st.begin(),st.end());
	c[0] = 0; p[0] = st[0].l_ength();
	for(i=1; i<n; ++i){
		for(j=0; j<(min(st[i-1].l_ength(),st[i].l_ength())); ++j){
			if(st[i-1][j] != st[i][j]){
				break;
			}
		}
		c[i] = j;
		p[i] = st[i].l_ength()-j;
	}
	i = 0;
	while(true){
		if(k <= p[i]){
			cout << (st[i].substr(0,c[i]+k)) << endl;
			break;
		}else{
			k -= p[i];
		}
		++i;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int getColor(int rating)
{
    VEC(int) v {399, 799, 1199, 1599, 1999, 2399, 2799, 3199};
    FOR(i, 0, SZ(v))
        if (rating <= v[i])
            return i;
    return SZ(v);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);

    VEC(int) Counts(9, 0);
    for (int a : A)
        Counts[getColor(a)]++;

    int minColors = 0;
    FOR(i, 0, 8)
        minColors += Counts[i] > 0;

    int minColors2 = minColors;
    if (Counts[8] > 0)
        minColors = max(1, minColors);
    int maxColors = minColors2 + Counts[8];
    cout << minColors << " " << maxColors << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
solve :: [Int] -> [Int]
solve (x:xs) = [menseki, shui]
    where menseki = x * head xs
          shui = (x + head xs) * 2

main :: IO ()
main = do
    a <- getLine
    let input = solve(map read (words a))
    putStrLn ((show $ head input) ++ " " ++ (show $ head $ tail input))

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define PI acos(-1.0)
#define EPS 1e-9 //epsilon 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define go(i,a,n) for(int i=a;i<n;i++)
#define og(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) go(i,0,n)
#define per(i,n) og(i,0,n)
#define sz(x) (x.size())
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pr(x) cout<<(x)<<endl
#define exist(e,s) ((s).find(e)!=(s).end()) //Element e in structure s
#define existstr(c,s) ((s).find(c) !=string::npos) //Character in structure
#define fo(x,s) for(auto &x:s) //for all x in structure s
typedef vector<int> vi;typedef vector<ll> vll;typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvll;typedef pair<int,int> ii;typedef pair<int, pair<int,int> > iii;
typedef pair<ll,ll> pll;typedef vector<ii> vii;typedef vector<iii> viii;typedef map<int,int> mii;
const int inf=1e9+7; //10^9 +7
inline void rvi(vi& v, int n){int temp; go(i,0,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll& v, int n){ll temp;go(i,0,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prmii(map<int,int>& m){for(auto x:m){cout<<x.fi<<" "<<x.se<<endl;}}
inline vll prefixsum(vi& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
void solve();
int main(){ios;solve();return 0;}
//--------SOLVE---------------------------------------------------------------------
void solve()
{
	vi a;
	a.pb(1);
	int curr=6;
	const int INF = 100000;
	for(int i=0;i<100;i++)
	{
		a.pb(curr);
		curr*=6;
		if(curr>INF) break;
	}
	curr=9;
	for(int i=0;i<100;i++)
	{
		a.pb(curr);
		curr*=9;
		if(curr>INF) break;
	}
//	cout<<a.size()<<endl;
	int n;cin>>n;
	vi dp(n+1,inf);
	dp[0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<a.size();j++)
		{
			if(i+a[j]<=n)
			{
				dp[i+a[j]]=min(dp[i+a[j]],dp[i]+1);
			}
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
people = list(range(1,n+1))

li = []
for i in range(k) :
  gomi = input()
  [li.append(int(j)) for j in input().split()]
st = set(li)
  
ans = 0
for i in people :
  if not i in st :
    ans += 1
print(ans)

Measured memory_bytes: 9304
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
int n;
long long sum = 0;
const long long Mod = 1e9 + 7;
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //-------------------------------
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        long long x;
        cin >> x;
        ans += x * sum;
        ans %= Mod;
        sum += x;
        sum %= Mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	int64_t k; cin >> k;
	char only = s[0];
	bool flg = true;
	for(char c : s) {
		if(only != c) {
			flg = false;
		}
	}
	if(flg) {
		cout << s.size() * k / 2 << endl;
		return 0;
	}
	int n = s.size();
	int64_t ans1 = 0;
	{
		char pre = s.front();
		int64_t cnt = 0;
		for(int i = 0; i < n; ++i) {
			if(s[i] != pre) {
				ans1 = cnt / 2;
				break;
			} else {
				cnt++;
			}
		}
	}
	int64_t ans4 = 0;
	{
		char pre = s.back();
		int64_t cnt = 0;
		for(int i = 0; i < n; ++i) {
			if(s[n - 1 - i] != pre) {
				ans4 = cnt / 2;
				break;
			} else {
				cnt++;
			}
		}
	}
	int64_t ans3 = 0;
	{
		char sss = s.back();
		for(int i = 0; i < n; ++i) {
			if(s[i] == sss) ans3++;
			else break;
		}
		for(int i = n - 1; i >= 0; --i) {
			if(s[i] == sss) ans3++;
			else break;
		}
		ans3 /= 2;
	}
	int64_t ans2 = 0;
	{
		char pre = s.front();
		s += '$';
		int64_t cnt = 0;
		for(int i = 0; i <= n; ++i) {
			if(s[i] != pre) {
				ans2 += cnt / 2;
				cnt = 1;
				pre = s[i];
			} else {
				cnt++;
			}
		}
		ans2 -= ans4 + ans1;
	}
	cerr << ans1 << ans2 << ans3 << ans4 << endl;
	if(s.front() == s[n - 1]) {
		cout << ans1 + ans2 * k + ans3 * (k - 1) + ans4 << endl;
	} else {
		cout << (ans1 + ans2 + ans4) * k << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

ll nDigit(ll n){
    if(n<10) return 1;
    else return 1 + nDigit(n/10);
}

ll cnt(ll L, ll A, ll B){
    ll N = nDigit(A);
    ll left = 0, right = L;
    while(right - left > 1){
        ll mid = (right+left)/2;
        if(N == nDigit(A+B*mid)){
            left = mid;
        }else{
            right = mid;
        }
    }
    return left+1;
}
vector<vector<ll>> multiple(vector<vector<ll>> K, vector<vector<ll>> L, ll mod){
    int S = K.size();
    vector<vector<ll>> ret = vector<vector<ll>>(S, vector<ll>(S,0));
    for(int i=0; i<S; i++) for(int j=0; j<S; j++){
        for(int k=0; k<S; k++){
            ret[i][j] = (ret[i][j]%mod + (K[i][k]%mod)*(L[k][j]%mod)%mod) % mod;
        }
    }
    return ret;
}
vector<vector<ll>> mod_pow(vector<vector<ll>> K, ll c, ll mod){
    int S = K.size();
    vector<vector<ll>> ret(S, vector<ll>(S,0));
    for(int i=0; i<S; i++){
        ret[i][i] = 1;
    }
    if(c==0) return ret;

    ret = mod_pow(multiple(K, K, mod), c/2, mod);
    if(c%2==1){
        ret = multiple(K, ret, mod);
    }
    return ret;
}

int main(){
    ll L, A, B, mod;
    cin >> L >> A >> B >> mod;

    ll ans = 0;
    while(L>0){
        ll c = cnt(L, A, B);
        ll p = 1;
        for(ll i=0; i<nDigit(A); i++){
            p*=10;
            p%=mod;
        }
        vector<ll> b = {ans, A%mod, 1};
        vector<vector<ll>> K = {{p,  0,    0},
                                {1,  1,    0},
                                {0, B%mod, 1}};
        K = mod_pow(K, c, mod);
        vector<ll> a(3);
        a[0] = (b[0] * K[0][0] + b[1] * K[1][0] + b[2] * K[2][0]) % mod;
        a[1] = (b[0] * K[0][1] + b[1] * K[1][1] + b[2] * K[2][1]) % mod;
        a[2] = (b[0] * K[0][2] + b[1] * K[1][2] + b[2] * K[2][2]) % mod;

        ans = a[0];
        L -= c;
        A += B*c;
    }
    cout << ans << endl;
}



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

struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};

typedef struct node * Node;
Node root;

main()
{
  int n, i, x;
  char str[20];
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s", str);	
    if(str[0]=='i'){
      scanf("%d", &x);
      insert(x);
    }
    else if(str[0]=='p'){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}


void insert(int k)
{
  Node a=NIL;
  Node b=root;
  Node new;
  
  new = malloc(sizeof(struct node));
  new->key=k;
  new->l=NIL;
  new->r=NIL;
  
  while(b!=NIL){
    a=b;
    if(new->key < b->key) b=b->l;
    else b=b->r;
  }
  new->p=a;
  
  if(a==NIL) root=new;
  else if(new->key < a->key) a->l=new;
  else a->r=new;
}


void Preorder(Node t)
{
  printf(" %d",t->key);
  if(t != NIL){
    if(t->l != NIL)Preorder(t->l);
    if(t->r != NIL)Preorder(t->r);
  }
}

void Inorder(Node t)
{
  
  if(t != NIL){
    if(t->l != NIL){
      Inorder(t->l);
	}
    printf(" %d",t->key);

    if(t->r != NIL){
      Inorder(t->r);
	}
  }
}

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

using namespace std;

void chk(long w,long h,vector<vector<long>>&wh) {
	for (long j = h; j >= 0; j--) {
		for (long i = 0; i <= w; i++) {
			cout << wh[i][j];
		}
		cout << endl;
	}
	cout << endl;
}


int main() {

	 long w, h, n;

	cin >> w >> h >> n;

	vector<vector<long>> wh(w + 2, vector<long> (h + 2, 0));
	long x, y, a;

//	chk(w, h, wh);

	for (long i = 0; i <= w; i++) {
		wh[i][0] = 1;
	}
	for (long i = 0; i <= h; i++) {
		wh[0][i] = 1;
	}

	for (long i = 0; i < n; i++) {
//		chk(w, h, wh);
		cin >> x >> y >> a;
		if (a == 1) {
			for (long j = 0; j <= x; j++) {
				for (long k = 0; k <= h; k++) {
					wh[j][k] = 1;
				}
			}
		}
		else if (a == 2) {
			for (long j = x+1; j <= w; j++) {
				for (long k = 0; k <= h; k++) {
					wh[j][k] = 1;
				}
			}
		}
		else if (a == 3) {
			for (long j = 0; j <= w; j++) {
				for (long k = 0; k <=y; k++) {
					wh[j][k] = 1;
				}
			}
		}
		else if (a == 4) {
			for (long j = 0; j <= w; j++) {
				for (long k = y+1; k <= h; k++) {
					wh[j][k] = 1;
				}
			}
		}
	}

//	chk(w, h, wh);

	long counter = 0;
	for (long i = 0; i <= w; i++) {
		for (long j = 0; j <= h; j++) {
			if (wh[i][j] == 0) { counter++; }
		}
	}
	cout << counter << endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int K; cin >> K;
  int buf = 7;
  int ans = 1;
  while(true){
    buf = buf%K;
    if(buf == 0){
      break;
    }
    if(ans > 10000000){
      ans = -1;
      break;
    }
    ans ++;
    buf = buf*10 + 7;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h> 
using namespace std; 
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pll pair<lli,lli>
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,a,n) for(lli i=a;i<(n);i++)
#define frj(j,a,n) for(lli j=a;j<(n);j++)
#define frx(i,a,n) for(lli i=a;i>(n);i--)
#define frxj(j,a,n) for(lli j=a;j>(n);j--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define endl '\n'
#define db(x) cout << "[ " << x << " ]" << endl;
#define dbarr(arr,a,n) {fr(i,0,n) cout<<arr[i]<<" "; cout<<endl;}

int main() {
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    lli ans=max(max(a*c,a*d),max(b*c,b*d));
    cout<<ans;
}

Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define dd double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int s;
  cin>>s;
  string f;
  int x=s/100;
  int y=s%100;
  
  if(x>=1&&x<=12){
  	if(y<=12&&y>=1){
  		f=f+"AMBIGUOUS";
	  }
	else if(y>12){
		f=f+"MMYY";
	} 
	else if(y==0){
		f=f+"MMYY";
	}
  }
  else if(y>=1&&y<=12){
  	if(x<=12&&x>=1){
  		f=f+"AMBIGUOUS";
	  }
	else if(x>12){
		f=f+"YYMM";
	}  
	else if(x==0){
		f=f+"YYMM";
	}
	  
  }
  
  else{
  	f=f+"NA";
  }
	
	  
   cout<<f<<endl; 

  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n; string s;
	cin >> n >> s;
	
	vector<set<string>> dp(4);
	dp[0].insert("");
	inc(i, n) {
		dec(j, 3) {
			RF(e, dp[j]) { dp[j + 1].insert(e + s[i]); }
		}
	}
	
	cout << SI(dp[3]) << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, A, B, X, t = 0, tb = 0;
  string S;
  
  cin >> N >> A >> B;
  cin >> S;
  X = A + B;
  
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'c'){
      cout << "No" << endl;
    }
    else if(S.at(i) == 'a' && X > t){
      cout << "Yes" << endl;
      t += 1;
    }
    else if(S.at(i) == 'b' && X > t && B > tb){
      cout << "Yes" << endl;
      t += 1;
      tb += 1;
    }
    else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	map <int,int> vis;
	void solve(){
		lli N,X,i,j,p,q,l,r;
		cin>>X>>N;
		for(i=0;i<N;i++){
			cin>>arr[i];
			vis[arr[i]]=1;
		}
		sort(arr,arr+N);
		p=0;
		q=1e9;
		for(i=0;i<=101;i++){
			if(vis[i])continue;
			if(abs(i-X)<q){
				p=i;		
				q=abs(i-X);
			}
		}
		cout<<p;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	int H, W, N; 
	cin >> H >> W >> N; 
	int sr, sc; 
	cin >> sr >> sc; sr --; sc --; 
	string S, T;
	cin >> S >> T; // 上下左右に抜けられるかを独立に判定
	bool left = false; 
	bool right = false; 
	bool top = false; 
	bool bottom = false; 
	int pos = sc; 
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'L') {pos --; 
			if(pos < 0){
				left = true; break; 
			}
		}
		if(T.at(i) == 'R'){
			pos = min(W-1, pos + 1); 
		}
	}
	pos = sc; 
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'R') {pos ++; 
			if(pos >= W){
				right = true; break; 
			}
		}
		if(T.at(i) == 'L'){
			pos = max(0, pos - 1); 
		}
	}
	pos = sr; 
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'U') {pos --; 
			if(pos < 0){
				top = true; break; 
			}
		}
		if(T.at(i) == 'D'){
			pos = min(H-1, pos + 1); 
		}
	}
	pos = sr; 
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'D') {pos ++; 
			if(pos >= H){
				bottom = true; break; 
			}
		}
		if(T.at(i) == 'U'){
			pos = max(0, pos - 1); 
		}
	}
	if(top || bottom || left || right) cout << "NO" << endl; 
	else cout << "YES" << endl; 
  //cout << top << bottom << left << right << endl; 
}

Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 200020
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int k,a[N],n,mx;
int main(){
	k=read(),n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=2;i<=n;++i){
		mx=max(mx,a[i]-a[i-1]);
	}
	mx=max(mx,k-a[n]+a[1]);
	printf("%d\n",k-mx);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ll n; cin >> n;
    vector<ll> a;
    ll x, y, ans;
    x = y = 0;
    ans = n-1;
    
    for(ll i=2;i<=sqrt(n);i++){
        x = i;
        if(n % x != 0) continue;
        y = n/x;
        ans = min(ans, x+y-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll X,Y,cnt=1;

void solve(){
    ll cur = X;
    while(true){
    ll buff = cur * 2;
    if(buff <= Y){
        cnt++;
        cur = buff;
    }
    else break;
    }
    cout << cnt << endl;
}

int main(){
    cin >> X >> Y;

    solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        ArrayList<Integer> array = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            array.add(num);
        }
        for(int j=array.size()-1;j>=0;j--){
            if(j==0){
                System.out.println(array.get(j));
            }else{
                System.out.print(array.get(j) + " ");
            }
        }
    }
}



Measured memory_bytes: 26140
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef  int ll;
using namespace std;
 ll n,m,x;
ll c[15];
ll b[15][15];
ll p[15];
ll ans=1e9;
ll dfs(ll i,ll v[],ll cost)
{
  //   cout<<cost<<" "<<i<<endl;
    
    bool f=true;
    for(ll j=1;j<=m;++j)
    {
        if(v[j]<x)
        {
            f=false;
           break;
        }
    }
    if(f)
    {//cout <<i<<" ->> "<<cost<<endl;
      return cost;
    }
    if(i>n)
    return 1e9;
    ll v1[15];
    memset(v1,0,sizeof(v1));
    ll ans1=1e9;
    for(ll j=i;j<=n;++j)
    {
     //   cout<<"** "<<i<<" "<<j<<"->> ";
        for(ll u=1;u<=m;++u)
        {
            v1[u]=(v[u]+b[j][u]);
           // cout<<v1[u]<<" ";
        }
       // cout<<endl;
        ans1=min(dfs(j+1,v1,cost+c[j]),ans1);
    }    
    return ans1;
}      
int main() {
    ios;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      cin>>n>>m>>x;
      for(ll i=1;i<=n;++i)
      {
          cin>>c[i];
          for(ll j=1;j<=m;++j)
          {
              cin>>b[i][j];
              p[j]+=b[i][j];
          }
      }
      for(ll i=1;i<=m;++i)
      {
          if(p[i]<x)
          {
              cout<<"-1";
              return 0;
          }
      }
     ll v[15];
     for(ll j=0;j<=m;++j)
      v[j]=0;
      cout<<dfs(0LL,v,0LL)<<endl;
    }
}




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

int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}

	int dmin=1e9;
	for (int i = 0; i < n; i++){
		int count=0;
		while(a[i]%2==0){
			a[i]/=2;
			count++;
		}
		dmin=min(dmin,count);
	}

	cout<<dmin<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

/*vector<int> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(f);
    rak.assign(f+1,1);
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rank[a]+=rank[b];
    }
}*/

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>x>>y>>z;
    cout<<min(z,y/x);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
typedef vector<ll> vl;
set <int> st;
vector<int> videos(105);
double now=0;
queue<int> num;
ll n,k;
vl w(100005);
vl d(100005);

bool solve(ll left,ll right)
{
  ll mid=(left+right)/2;
  ll cnt=0;
  for(int i=0;i<n;i++)
    {
      if(w[i]<=mid)
	{
	  cnt+=((mid-w[i])/d[i]+1);
	}
    }
  return cnt>=k;
}
int main(int argc,char const* argv[])
{
  cin >> n >> k;
  for(int i=0;i<n;i++)
    {
      cin >> w[i] >> d[i];
    }
  ll left=-1;
  ll right=2e18+1;
  ll mid;
  while(right-left>1)
    {
      mid=(left+right)/2;
      if(solve(left,right)==true)
	{
	  right=mid;
	}
      else
	{
	  left=mid;
	}
    }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	rep(i,n + 1){
		rep(j,n + 1){
			if(i + j > n or i * 10000 + j * 5000 > y) break;

			int k = n - i - j;
			if(i * 10000 + j * 5000 + k * 1000 == y){
				cout << i << ' ' << j << ' ' << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int n,k;
    cin>>n>>k;
    if(n%k==0) cout<<"0"<<endl;
    else cout<<"1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  cin>>N>>L;
  int A;
  A=(L-1)*N+N*(N+1)/2;
  if(L-1+N<0)A-=L-1+N;
  if(L>0)A-=L;
  
  cout<<A<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int w,h;
int memo[101][101][5];
//joutai 0 最初 1...ｘに曲がったばかり 2...ｙに曲がったばかり 3 ｙを進んでいる 4 ｘを進んでいる
int dfs(int y,int x,int joutai){
  if(h<y || w<x){
    return 0;
  }
  if(y==h && x==w){
    return 1;
  }
  if(memo[y][x][joutai]!=-1){
    return memo[y][x][joutai];
  }
  if(joutai==1){
    return memo[y][x][joutai]=dfs(y,x+1,4)%100000;
  }else if(joutai==2){
    return memo[y][x][joutai]=dfs(y+1,x,3)%100000;
  }else if(joutai==3){
    return memo[y][x][joutai]=(dfs(y+1,x,3)+dfs(y,x+1,1))%100000;
  }else if(joutai==4){
    return memo[y][x][joutai]=(dfs(y+1,x,2)+dfs(y,x+1,4))%100000;
  }else if(joutai==0){
    return memo[y][x][joutai]=(dfs(y+1,x,3)+dfs(y,x+1,4))%100000;
  }
}
int main(){
  while(1){
    cin>>w>>h;
    if(w==0 && h==0) break;
    memset(memo,-1,sizeof(memo));
    cout<<dfs(1,1,0)<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class392
    {
        static void Main()
        {
            int X = int.Parse(Console.ReadLine());
            while (true)
            {
                bool frag = true;
                for (int i = 2; i <=(int)Math.Sqrt(X) ; i++)
                {
                    if (X % i == 0)
                    {
                        frag = false;
                        break;
                    }
                }

                if (frag)
                {
                    Console.WriteLine(X);
                    return;
                }
                X++;
            }
        }
    }
}


Measured memory_bytes: 26900
from string import ascii_lowercase
S = input()
try:
    if not S[0] is 'A' or not 'C' in S[2:-1]:
        raise RuntimeError
    for i in range(1,len(S)):
        if i == S.index('C'):
            continue
        if not S[i] in ascii_lowercase:
            raise RuntimeError
    print('AC')
except:
    print('WA')
# S[2:-1] in 'C'
# S.remove('A'),S.remove('C')
# S is all lower


Measured memory_bytes: 3772
from itertools import groupby
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = input()

x,y = map(int,input().split())

d = [len(i) for i in s.split('T')]

x_li = d[2::2]
y_li = d[1::2]

now_x = [0]
now_y = [0]

x -= d[0]

for i in x_li:
    nx = set()
    for j in now_x:
        nx.add(j-i)
        nx.add(j+i)
    now_x = nx

for i in y_li:
    ny = set()
    for j in now_y:
        ny.add(j-i)
        ny.add(j+i)
    now_y = ny

if x in now_x and y in now_y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3820
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<	 #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }
#define p   200005



  
void solve()
{  

  int n;
  cin>>n;
  string s="",t;
  for(int i=1;i<=n;i++)
  	  {
  	     s=s+char('0'+i);
  	  }
  	  t=s;
string s1="",s2="";
for(int i=0;i<n;i++)
   {
     int a;
     cin>>a;
     s1+=char('0'+a);

   }
   for(int i=0;i<n;i++)
   {
     int a;
     cin>>a;
     s2+=char('0'+a);

   }

   int a=1,b=1;
   while(s1!=s)
   	  {   a++;

   	  	next_permutation(all(s));
   	  }
   	  while(s2!=t)
   	  	 {
   	  	 	b++;
   	  	 	next_permutation(all(t));
   	  	 }
   	  	 cout<<abs(a-b);













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












Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long K, std::string S){
    if(S.length()<=K){
        cout<<S<<endl;
    }
    else{
        cout<<S.substr(0, K)<<"..."<<endl;
    }
}
int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3668
#include<cstdio>
const int maxn=105;
int a[maxn],n;
int min=400000*100,cost;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=-100;i<=100;i++)
    {
        cost=0;
        for(int j=1;j<=n;j++)
        {
            cost+=(i-a[j])*(i-a[j]);
        }
        if(cost<min)
            min=cost;
    }
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
var
a:array[1..100] of longint;
i,j,t,n,k,m,s:longint;
begin
readln(n,k);
for i:=1 to n do read(a[i]);
for i:=1 to n-1 do 
for j:=i+1 to n do 
if a[i]>a[j] then 
 begin
  t:=a[i];
  a[i]:=a[j];
  a[j]:=t;
 end;
 for i:=n downto n-k+1 do 
 s:=s+a[i];
 writeln(s);
 end.
   

Measured memory_bytes: 128