akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    set<string> st;
    rep(i,0,SZ(S)-SZ(T)+1){
        bool flag = true;
        rep(j,0,SZ(T)){
            if(T[j] != S[i+j]){
                if(S[i+j] == '?') continue;
                flag = false;
            }
        }
        if(flag){
            string s;
            rep(j,0,SZ(S)){
                if(j >= i && j < i+SZ(T)){
                    s += T[j-i];
                }else if(S[j] == '?'){
                    s += 'a';
                }else{
                    s += S[j];
                }
            }
            st.insert(s);
        }
    }
    if(st.empty()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }else{
        string ans = *(st.begin());
        cout << ans << endl;
        return 0;
    }
}

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

using namespace std;

int main() {
  long long int N, M;
  cin >> N >> M;
  vector<pair<long long int, long long int>> kans(N);
  for (int i=0; i<N; i++){
    cin >> kans[i].first >> kans[i].second;
  }
  sort(kans.begin(), kans.end());
  long long int cnt = 0;
  long long int money = 0;
  int i=0; 
  while(cnt<M){
    money += kans[i].first * min(kans[i].second, M-cnt);
    cnt+= kans[i].second;
    i++;
  }
  cout << money << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n;
	ll ans = 1;
	for( ll i = 1; i <= n; ++i ){
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b, c;

	cin >> a >> b >> c;

	cout << yn((a < c && c < b) || (a > c && c > b)) << endl;
}


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

int main(){
    int N;
    cin >> N;
    if(64<N&&N<91){
        cout << "1" << endl;
    }else if(96<N&&N<123){
        cout << "2" << endl;
    }else{
        cout << "0" << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int ab = 0;
    int a = 0;
    int b = 0;
    int loop = 0;
    string s;
    REP(i, n) {
        cin >> s;
        int m = sz(s);
        if (s[0] == 'B') b++;
        if (s[m - 1] == 'A') a++;
        if (s[0] == 'B' and s[m - 1] == 'A') loop++;
        REP(i, m - 1) if (s[i] == 'A' and s[i + 1] == 'B') ab++;
    }
    cout << ab + min(a, b) - (loop == a and loop == b and min(a, b) > 0 ? 1 : 0) << endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,l,a[100005],v1[100005],v2[100005];
bool cmp(pair<int,int> a,pair<int,int> v1){return a.first>v1.first;}
vector<pair<int,int> >f,g;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),l=max(l,a[i]);
	for(int i=1;i<=n;i+=2) v1[a[i]]++;
	for(int i=2;i<=n;i+=2) v2[a[i]]++;
	for(int i=1;i<=l;i++) if(v1[i]) f.push_back(make_pair(v1[i],i));
	for(int i=1;i<=l;i++) if(v2[i]) g.push_back(make_pair(v2[i],i));
	f.push_back(make_pair(0,0));
	g.push_back(make_pair(0,0));
	sort(f.begin(),f.end(),cmp);
	sort(g.begin(),g.end(),cmp);
	if(f[0].second==g[0].second)
	{
		int ans=max(f[0].first+g[1].first,f[1].first+f[0].first);
		printf("%d\n",n-ans);
	}
	else printf("%d\n",n-f[0].first-g[0].first);
	return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1000000007;

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    ll cnt[101010];
    for (int i = k; i > 0; i--) {
        ll num = beki(k / i, n, mod);
        for (int j = i * 2; j <= k; j += i) {
            num -= cnt[j];
        }
        cnt[i] = num;
        ans = (ans + num * i) % mod;
    }
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

int main() {
    int n;

    float x;

    cin>>n;

    float ans = 0;
    for(int i=0;i<n;i++)
    {
        cin>>x;

        ans += 1 / x;
    }

    ans = 1 / ans;

    printf("%.5f", ans);

	return 0;
}


Measured memory_bytes: 256
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
//use std::cmp; // cmp::max,cmp::min

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

//////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2018&lang=jp

fn solve() -> bool{
    let xs = read_ints();
    let (n,m,p) = (xs[0],xs[1],xs[2]);

    if n==0{
        return true;
    }

    let xs = read_ints2(n);
    let n_win = xs[(m-1) as usize];
    let s = xs.iter().fold(0,|x,y| x + y);

    if n_win == 0{
        println!("0");
    }else{
        let rest = s * (100-p) / n_win;

        println!("{}",rest);
    }
    return false;
}

fn main(){
    loop{
        if solve (){
            break;
        }
    }
}





/*
DOCS

///////////////// Vec /////////////////

let v = vec![0;2]; // [0,0]
let sum_x = xs.iter().fold(0,|s,i|s+i); // xs : Vec<i64>

s.chars().nth(i as usize).unwrap();

let xs : Vec<i32> = read_charvec().iter().map(|&c| 
    if c == 'A'{
        0
    }else if c == 'B'{
        1
    }else if c == 'X'{
        2
    }else{
        3
    }
).collect();

// search
let i = match xs.iter().find(|&&m| m==0){
    Some(v) => true,
    None => false,
};

///////////////// HashMap /////////////////

let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}

///////////////// swap /////////////////

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);

///////////////// priority queue /////////////////

// https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html
let mut heap = BinaryHeap::new();

heap.push(1);
heap.push(5);
heap.push(2);

assert_eq!(heap.pop(), Some(5));
assert_eq!(heap.pop(), Some(2));
assert_eq!(heap.pop(), Some(1));
assert_eq!(heap.pop(), None);

let mut vs = heap.into_vec();
vs.reverse();

*/



Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
long long gcd(long long a,long long b){
    if(b > a){
        swap(a,b);
    }
    bool flag = true;
    long long gcdl;
    while(flag){
        if(a%b == 0){
            flag = false;
            gcdl = b;
        }
        else{
            swap(a,b);
            b = b % a;
        }
    }
    return gcdl;
}
int main(){
    int n,m;
    cin >> n >> m;
    string sn,sm;
    cin >> sn >> sm;
    long gcdnm = gcd(n,m);
    long a = n/gcdnm;
    long b = m/gcdnm;
    bool fl = true;
    rep(i,gcdnm){
        if(sn[i*a] != sm[i*b]){
            cout << -1 << endl;
            fl = false;
            break;
        }
    }
    if(fl){
        cout << a*b*gcdnm << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

struct Fenwick {
	vl t;
	Fenwick(int n) : t(n+1) {}
	ll sum(int pos) {
		++pos;
		ll ret = 0;
		while(pos > 0) {
			ret += t[pos];
			pos &= (pos-1);
		}
		return ret;
	}
	void add(int pos, ll val) {
		++pos;
		while(pos < t.size()) {
			t[pos] += val;
			pos += (pos & -pos);
		}
	}
};

int main(void) {
	//freopen("in.txt", "r", stdin);
	int n;
	ll k;
	cin >> n >> k;
	vl a(n+1);
	rep(i,1,n+1) {
		cin >> a[i];
		a[i] -= k;
	}
	rep(i,1,n+1) {
		a[i] += a[i-1];
	}
	map<ll, ll> r;
	rep(i,0,n+1) {
		if(r.find(a[i]) != r.end()) {
			r[a[i]]++;
		} else {
			r[a[i]] = 1;
		}
	}
	map<ll, int> idx;
	Fenwick tree(r.size());
	int t = 0;
	for(auto e : r) {
		idx[e.F] = t++;
		tree.add(idx[e.F], e.S);
	}
	ll ret = 0;
	ll mx = r.rbegin()->F;
	rep(i,0,n+1) {
		tree.add(idx[a[i]], -1);
		ret += tree.sum(idx[mx]) - tree.sum(idx[a[i]]-1);
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
 
int n;
string s;
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> s;
	n = s.size();
	for (int j = n; j >= 1; j--) {
		int can = n - j + 1;
		for (int i = 0; i < 26; i++) {
			int bad = 0;
			for (int k = 1; k <= j; k++) {
				int ok = 0;
				for (int l = k; l <= k + can - 1; l++) {
					if (s[l - 1] - 'a' == i) {
						ok = 1;
					}
				}
				if (!ok) {
					bad = 1;
					break;
				}
			}
			if (!bad) {
				cout << n - j;
				return 0;
			}
		}
	}
}


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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<double,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[20000];

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) {
        cin >> a[i] >> b[i];
    }
    rep(i,20000) dp[i] = INF;
    dp[0] = 0;
    rep(i,h) {
        rep(j,n) {
            dp[i+a[j]] = min(dp[i+a[j]],dp[i]+b[j]);
        }
    
    }
    ll ans = INF;
    for (int i = h; i < 20000; ++i){
        if (ans > dp[i]) ans = dp[i];
    }
    cout << ans << endl;
    return 0;
}


































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

int main()
{
  i64 n;
  cin >> n;
  string ans = "No";
  for (i64 i = 1; i < 10; i++)
    for (i64 j = 1; j < 10; j++)
      if (i * j == n)
        ans = "Yes";
  cout << ans << endl;
  return 0;
}


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

#define int long long
int n, m;
vector<pair<int, int>> g[2][100000];

inline vector<int> dijkstra(int x, int y) {
	vector<int> dist(n, 1LL << 60);
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
	dist[x] = 0;
	que.push(make_pair(0, x));
	while ((int) que.size()) {
		pair<int, int> p = que.top();
		que.pop();
		int cur = p.second;
		int d = p.first;
		if (dist[cur] < d) continue;
		for (auto &nbr : g[y][cur]) {
			int to = nbr.first;
			int dd = nbr.second;
			if (dist[to] > dist[cur] + dd) {
				dist[to] = dist[cur] + dd;
				que.push(make_pair(dist[to], to));
			}
		}
	}
	return dist;
}

class SegmentTree {
private:
	int siz;
	vector<int> dat;
	
public:
	SegmentTree(vector<int> v) {
		siz = 1;
		while(siz < (int) v.size()) siz <<= 1;
		dat.resize(2 * siz - 1, -LLONG_MAX);
		for(int idx = 0; idx < (int) v.size(); idx++) {
			dat[idx + siz - 1] = v[idx];
		}
		for(int idx = siz - 2; idx >= 0; idx--) {
			dat[idx] = max(dat[2 * idx + 1], dat[2 * idx + 2]);
		}
	}
	
	void update(int idx, int val) {
		idx += (siz - 1);
		dat[idx] = val;
		while(idx > 0) {
			idx = (idx - 1) / 2;
			dat[idx] = max(dat[2 * idx + 1], dat[2 * idx + 2]);
		}
	}
	int get(int a, int b, int idx = 0, int l = 0, int r = -1) {
		if(r < 0) r = siz;
		if(r <= a || b <= l) return -LLONG_MAX;
		if(a <= l && r <= b) return dat[idx];
		int val1 = get(a, b, 2 * idx + 1, l, (l + r) / 2);
		int val2 = get(a, b, 2 * idx + 2, (l + r) / 2, r);
		return max(val1, val2);
	}
};

signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int s[2];
	cin >> n >> m >> s[0] >> s[1];
	s[0]--; s[1]--;
	for (int i = 0; i < m; i++) {
		int u, v, a[2];
		cin >> u >> v >> a[0] >> a[1];
		u--; v--;
		for (int j = 0; j < 2; j++) {
			g[j][u].emplace_back(v, a[j]);
			g[j][v].emplace_back(u, a[j]);
		}
	}
	vector<int> a[2];
	for (int i = 0; i < 2; i++) {
		a[i] = dijkstra(s[i], i);
	}
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		b[i] = 1LL * 1e15 - a[0][i] - a[1][i];
	}
	SegmentTree sgt(b);
	for (int i = 0; i < n; i++) {
		cout << sgt.get(i, n) << '\n';
	}
	return 0;	
}

Measured memory_bytes: 21756
// Linear Search
#include <stdio.h>

int s[10010], t[510];
int linearSearch(int key, int n){
    for(int i=0; i<n; i++){
        if(s[i]==key){return 1;}
    }
    return -1;
}
int main(void){
    int n, q, cnt=0;
    scanf("%d", &n);
    for(int i=0; i<n; i++){scanf("%d", &s[i]);}
    scanf("%d", &q);
    for(int i=0; i<q; i++){scanf("%d", &t[i]);}
    for(int i=0; i<q; i++){
        if(linearSearch(t[i], n)==1){cnt++;}
    }
    printf("%d\n", cnt);
    return 0;
}


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

#define N 300000
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
int main(void){
  int n;
  int d[N], dmax;
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> d[i];
  // L->R
  dmax = 0;
  for (int i=0; i<n; i++){
    if (dmax<10*i){
      cout << "no" << endl;
      return 0;
    }
    dmax = MAX(dmax, 10*i+d[i]);
  }
  // L <- R
  dmax = 0;
  for (int i=0; i<n; i++){
    if (dmax<10*i){
      cout << "no" << endl;
      return 0;
    }
    dmax = MAX(dmax, 10*i+d[n-1-i]);
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 4292
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	sort(A.rbegin(), A.rend());
	sort(F.begin(), F.end());

	Int low = -1, high = 1e18;
	while (high - low > 1) {
		Int mid = (high + low) / 2;

		Int sum = 0;
		for (int i = 0; i < N; ++i) {
			sum += max(Int(0), A[i] - (mid / F[i]));
		}
		if (sum > K) { low = mid; }
		else { high = mid; }
	}
	cout << high << endl;

	return 0;
}


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

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

mint dp0[2005][2005];
mint dp1[2005][2005];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n+1), t(m+1);
  rep(i,n) scanf("%d", &s[i]);
  rep(i,m) scanf("%d", &t[i]);
  dp0[0][0] = 1;
  rep(i,n+1)rep(j,m+1) {
    dp0[i+1][j] += dp0[i][j];
    dp1[i][j] += dp0[i][j];
    dp1[i][j+1] += dp1[i][j];
    if (s[i] == t[j]) {
      dp0[i+1][j+1] += dp1[i][j];
    }
  }
  mint ans = dp1[n][m];
  cout << ans.x << endl;
  return 0;
}


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

using namespace std;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b)
        printf("%d" ,c);
      //cout << "c";
    else if(a==c)
        printf("%d" ,b);
      //cout << "b";
    else if(b==c)
        printf("%d" ,a);
      //cout << "a";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[1010][1010];
int main()
{
	int n,m,q,x,y,k;
	scanf("%d%d%d",&n,&m,&q);
	memset(dp,0,sizeof(dp));
	for(int i=1; i<=m; i++)
	{
		scanf("%d%d",&x,&y);
		dp[x][y]++;
	}
	for(int j=1;j<n;j++)
		for(int i=1;i+j<=n;i++)
		{
			dp[i][i+j]=dp[i][i+j]+dp[i+1][i+j]+dp[i][i+j-1];
			if(j>1)dp[i][i+j]-=dp[i+1][i+j-1];
		}
	while(q--)
	{
		scanf("%d%d",&x,&y);
		printf("%d\n",dp[x][y]);
	}
	return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n;
  cin>>n;
  vector<P> ans;
  ll n2=n;
  while(n2>1){
    if(n2%2==1) break;
    n2/=2;
  }
  if(n2==1) {
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=2;i<n;i+=2){
    ans.push_back(P(i,1));
    ans.push_back(P(i,i+1));
    ans.push_back(P(i+n+1,1));
    ans.push_back(P(i+n+1,i+n));
  }
  bool f=false;
  if(n%2==0){
    for(int i=2;i<n;i+=2){
      if((n^1^i)<n){
        ans.push_back(P(i,n));
        ans.push_back(P(2*n,(n^1^i)+n));
        f=true;
        break;
      }
    }
  }
  if(n%2==0&&!f){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<ans.size();i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
  cout<<3<<" "<<1+n<<endl;
}


Measured memory_bytes: 5740
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    int n, k;
    cin >> n;
    vi v(n);
    rep(i, 0, n)cin >> v[i];
    int cur = 1000;
    rep(i, 0, n){
        while(i+1 < n and v[i+1] <= v[i])i++;
        int stsz = cur/v[i];
        cur %= v[i];
        while(i+1 < n and v[i+1] >= v[i])i++;
        cur += stsz*v[i];
    }
    cout << cur << endl;
}
signed main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

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

#define itn long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
const ll MOD=1e9+7;

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;
  string c=".,!? ";
  string al="pqrstuvwxyz";
  rep(i,N){
    string s;
    cin>>s;
    int ct=0;
    for(int i=0;i<s.size();i++)
      if(s[i]=='0'){
        if(ct==0)continue;ct--;
        int l=s[i-1]-'1';
        if(!l)cout<<c[ct%5];
        else if(l==6)
          cout<<al[ct%4];
        else if(l==7)
          cout<<al[4+ct%3];
        else if(l==8)
          cout<<al[7+ct%4];
        else cout<<(char)(--l*3+ct%3+'a');ct=0;
      }else ct++;
    cout<<endl;
  }
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


Measured memory_bytes: 3140
while 1:
    n = 1000 - input()
    if n==1000:break
    m = [500,100,50,10,5,1]
    for i in range(6):
        x = n / m[i]; n -= m[i] * x; m[i] = x;
    print reduce(lambda a, x: a+x, m)

Measured memory_bytes: 6408
n,m = map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        flag=1
        for k in range(m):
            for l in range(m):
                if b[k][l]!=a[i+k][j+l]:
                    flag=0
                    break
            if not flag: break
        if flag:
            print("Yes")
            break
    if flag: break
if not flag: print("No")

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    int n;cin >> n;
    vii graph(n);
    int m;cin >> m;
    rep(i,m){
        int a,b;cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vi dist(n,-1);

    dist[0] = 0;
    queue<int> que;
    que.push(0);
    map<int,int> ans;

    while(!que.empty()){
        int base = que.front();que.pop();
        for(int n : graph[base]){
            if(dist[n] != -1)continue;
            dist[n] = dist[base] + 1;
            que.push(n);
            ans[n] = base;
        }
    }

    cout << "Yes" << endl;
    for(int i=1;i<n;i++){
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 14816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	bool ansjud=false;
	bool fjud=false;
	while(scanf("%c",&a))
	{
		if(a=='C')
			fjud=true;
		if(a=='F'&&fjud)
			ansjud=true;
		if(a=='\n')
		{
			if(ansjud)
				cout<<"Yes"<<endl;
			else
				cout<<"No"<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut edges = vec![Vec::new(); n];
    for a in 0..n - 1 {
        let v = read_vec::<usize>();
        edges[v[0] - 1].push(v[1] - 1);
        edges[v[1] - 1].push(v[0] - 1);
    }

    let root = 0usize;
    let mut tree: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut parent_dict: HashMap<usize, usize> = HashMap::new();
    make_tree(root, n, &edges, &mut tree, &mut parent_dict);

    let mut rank = 1;
    let mut pointer = n - 1;
    let mut color = vec![0; n]; // 0: uncolored, 1: black, 2: white
    while pointer != 0 {
        rank += 1;
        pointer = parent_dict[&pointer];
    }
    let mut pointer = n - 1;
    for i in 0..rank {
        if i < rank / 2 {
            color[pointer] = 2;
        } else {
            color[pointer] = 1;
        }
        if i == rank - 1 {
            break;
        }
        pointer = parent_dict[&pointer];
    }

    let mut topological_sorted_indexes = vec![root];
    topological_dfs(root, &tree, &mut topological_sorted_indexes);
    // debug!(topological_sorted_indexes);

    for idx in topological_sorted_indexes {
        for &child_idx in edges[idx].iter() {
            if color[child_idx] == 0 {
                color[child_idx] = color[idx];
            }
        }
    }
    // debug!(color);
    let mut black_count = 0;
    let mut white_count = 0;
    for i in 0..n {
        if color[i] == 1 {
            black_count += 1;
        } else if color[i] == 2 {
            white_count += 1;
        }
    }

    assert!(black_count + white_count == n);
    if white_count >= black_count {
        println!("Snuke");
    } else {
        println!("Fennec");
    }
}

fn make_tree(
    cur_idx: usize,
    parent_idx: usize,
    edges: &Vec<Vec<usize>>,
    tree: &mut Vec<Vec<usize>>,
    parent_dict: &mut HashMap<usize, usize>,
) {
    for child_idx in edges[cur_idx].iter() {
        if *child_idx == parent_idx {
            continue;
        }
        tree[cur_idx].push(*child_idx);
        parent_dict.insert(*child_idx, cur_idx);
        make_tree(*child_idx, cur_idx, edges, tree, parent_dict);
    }
}

fn topological_dfs(cur_idx: usize, tree: &Vec<Vec<usize>>, result: &mut Vec<usize>) {
    for child_idx in tree[cur_idx].iter() {
        result.push(*child_idx);
        topological_dfs(*child_idx, tree, result);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 60176
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e9;
const int INF=0x3f3f3f3f;
bool A[101];
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		int a,b;
		cin>>a>>b;
		if(a==b) A[i]=1;
	}
	int cnt=0;
	bool flag=0;
	for(int i=0;i<n;++i){
		if(A[i]) ++cnt;
		else cnt=0;
		if(cnt==3) flag=1;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

typedef pair<int,int> P;

int d[31][31];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
enum{RIGHT,UP,LEFT,DOWN};

bool tate[30+1][30];
bool yoko[30][30+1];
int W,H;

bool canmove(int x,int y,int mx,int my,int d){
     if(mx<0||my<0||mx>=W||my>=H){
	  return false;
     }else{
	  switch(d){
	  case RIGHT:
	       if(tate[x][y])return false;
	       break;
	  case LEFT:
	       if(tate[x-1][y])return false;
	       break;
	  case DOWN:
	       if(yoko[x][y-1])return false;
	       break;
	  case UP:
	       if(yoko[x][y])return false;
	  }
	  return true;
     }
}

int bfs(){
  queue< pair<int,int> > que;

  for(int i=0;i<W;i++){
    for(int j=0;j<H;j++){
      d[i][j]=-1;
    }
  }

  que.push(P(0,0));
  d[0][0]=0;

  while(que.size()){
    P p=que.front();
    que.pop();
    if(p.first==W-1&&p.second==H-1)break;
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(canmove(p.first,p.second,nx,ny,i)&&d[nx][ny]==-1){
	que.push(P(nx,ny));
	d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[W-1][H-1];
}
	  
int main(){
     for(int i=0;i<30;i++){
	  for(int j=0;j<31;j++){
	       tate[j][i]=0;
	       yoko[i][j]=0;
	  }
     }
     while(cin>>W>>H,W||H){
	  for(int i=0;i<H;i++){
	       for(int j=0;j<W-1;j++){
		    cin>>tate[j][i];
	       }
	       if(i!=H-1){
		    for(int j=0;j<W;j++){
			 cin>>yoko[j][i];
		    }
	       }
	  }
  
	  int a=bfs();
	  /*for(int j=0;j<H;j++){
	       for(int i=0;i<W;i++){
		    cout<<d[i][j];
	       }
	       cout<<endl;
	       }*/
	  
	  if(a==-1)cout<<0<<endl;
	  else cout<<a+1<<endl;
     }
     return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
v<ll> fact;
//factorial
void factorial(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <=n; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
}
// modular exponentiation 
ll binpow(ll val, ll deg)
{
    if (!deg)
        return 1 % M;
    if (deg & 1)
        return binpow(val, deg - 1) * val % M;
    ll res = binpow(val, deg >> 1);
    return (res * res) % M;
}
//combination
ll C(ll n, ll i)
{
    if(n<i) return 0;      
    ll res = fact[n]; 
    ll div = fact[n - i] * fact[i];
    div %= M;
    // using fermat little theorum
    div = binpow(div, M - 2); // modular inverse  
    return (res * div) % M; 
}
int main() {
	//your code goes here
	IOS;
	ll n,m;       
	ll j,y,z,k,b,a,x,t,i;   
	 cin>>n;
	 ll V=0;
	 for(i=1;i<=n;i++){
	       V+=i*(n+1-i);
	 }
	 ll edges=0;
	 rep(i,n-1){
	       ll u,v;
	       cin>>u>>v;
	       ll mn=min(u,v);
	       ll mx=max(u,v);
	       edges+=mn*(n+1-mx);
	 }
	 cout<<V-edges;
	 
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int solve(string s) {
    int cnt = 0;
    int ret = 0;
    for (int i = 0; i < s.size(); i++) {
        cnt++;
        if (i == s.size() - 1 || s[i] != s[i + 1]) {
            ret += cnt / 2;
            cnt = 0;
        }
    }
    return ret;
}

signed main() {
    string s;
    int k;
    cin >> s >> k;
    bool flag = true;
    for (int i = 1; i < s.size(); i++) {
        if (s[0] != s[i]) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << s.size() * k / 2<< "\n";
        return 0;
    }
    string sc = s + s;
    int x = solve(s);
    int y = solve(sc);
    cout << x + (k - 1) * (y - x) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<sstream>

using namespace std;

string itos(int x){
  if(x==0)return "";
  stringstream ss;
  ss<<x;
  return ss.str();
}

int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<=s.size();i++){
    string sa=s.substr(0,i);
    string sb=s.substr(i);
    int a=atoi(sa.c_str());
    int b=atoi(sb.c_str());
    int x=a+b,y=b-a;
    int xx=x/2,yy=y/2;
    ans+=x>=0&&y>=0&&x%2==0&&y%2==0&&s==itos(xx-yy)+itos(xx+yy);
  }
  cout<<ans<<endl;
}

    

Measured memory_bytes: 1220
#include <stdio.h>

int main(void) {
    int N, X, Y, max, min;
    scanf("%d%d%d", &N, &X, &Y);
    if (X >= Y)
        max = Y;
    else
        max = X;

    if (N >= (X + Y))
        min = 0;
    else
        min = X + Y - N;

    printf("%d %d\n", max, min);
    return 0;
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	int p;
	for(auto i = 0; i < n; ++i){
		int a;
		cin >> a;
		if(a == 1) p = i;
	}
	int ans = max(0, p - k + 1 + k - 2) / (k - 1) + 1;
	ans += (n - ans * (k - 1) - 1 + k - 2) / (k - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

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

int str_to_int(string s){
  int keta=1;
  int num=0;
  char c;
  while(s.size()){
    c=s[s.size()-1];
    s.pop_back();
    num+=keta*int(c-'0');
    keta*=10;
  }
  return num;
}

void solve(string s){
  int maxi=str_to_int(s);
  int cnt=0;
  for(cnt=0;;cnt++){
  	if(maxi<=10)break;
    if(cnt==100)break;
  	maxi=-INF;
  	  string ss;
  	  ss.pb(s[0]);
      s.erase(s.begin());
    while(s.size()){
      //cout<<str_to_int(s)<<" "<<str_to_int(ss)<<" ";
      maxi=max(maxi,str_to_int(ss)*str_to_int(s));
      //cout<<maxi<<endl;
      ss+=s[0];
      s.erase(s.begin());
    }
    //cout<<maxi<<endl<<endl;;
    if(cnt>=100)break;
    else s=to_string(maxi);
  }
  cout<<cnt<<endl;
}

int main(){
  int n;
  string s;

  cin>>n;
  rep(i,n){
    cin>>s;
    solve(s);
  }

  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n; cin >> n;
  vector<int> v;
  while(n > 0) {
    v.push_back(n % 10);
    n /= 10;
  }
  cout << ((v[0] == v[1] && v[1] == v[2]) || (v[1] == v[2] && v[2] == v[3]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define N_MAX 5000
#define M_MAX 100000
int main() {
	int n, m;
	int win[M_MAX + 1], lose[M_MAX + 1];
	int lost[N_MAX + 1] = { 0 };
	queue< int > rank;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> win[i] >> lose[i];
		
		lost[lose[i]]++;
	}
	bool jud = false;
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		int team;
		for (int j = 1; j <= n; j++) {
			if (lost[j] == 0) {
				team = j;
				cnt++;
			}
		}
		if (cnt >= 2)jud=true;

		rank.push(team);

		for (int k = 0; k <= m; k++)if (win[k]==team)lost[lose[k]]--;
		lost[team] = -5000;
	}
	for (int i = 0; i < n; i++) {
		cout << rank.front() << endl;
		rank.pop();
	}
	if (jud)cout << '1' << endl;
	else cout << '0' << endl;

	return 0;
}


Measured memory_bytes: 4000
def D_Derangement():
    try:
        LOCAL_FLAG
        N = 5
        raw_p = "1 4 3 5 2"
        p = list(map(int, raw_p.split()))

    except NameError:
        N = int(input())
        p = list(map(int, input().split()))

    bad = []
    for i in range(N):
        if(p[i] == i+1):
            bad.append(i+1)

    n_bad = len(bad)
    n_ope = n_bad
    
    while n_bad > 0:
        if(bad[n_bad-2] == (bad[n_bad-1]-1)):
            n_ope -= 1
            n_bad -= 2
        else:
            n_bad -= 1

    print(n_ope)

D_Derangement()

Measured memory_bytes: 14008
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int x,rem;
    int f=0, o=0;
    cin >> x;
    if (x < 100)cout << 0 << endl;
    else {
        rem = x / 100;
        x %= 100;
        if (x >= 5) {
            f = x / 5;
            x %= 5;
        }
        if (x >= 1)o = 1;
        if (rem >= (f + o))cout << 1 << endl;
        else cout << 0 << endl;

    }
    return 0;

}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  int N;
  
  scanf("%d", &N);
  
  int sum = 0;
  while(N > 0)
  {
    sum += N%10;
    N /= 10;
  }
  
  if(sum > 1) printf("%d\n", sum);
  else printf("10\n");
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int n, m; cin >> n >> m;
  Graph g(n+1);

  vector<int> cnt(n+1, 0);
  REP(i, m){
    int a, b; cin >> a >> b;
    cnt[a]++; cnt[b]++;
  }

  FOR(i, 1, n+1){
    if(cnt[i] % 2){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 2944
m,p,i;P(n){for(p=i=2;p&&i*i<=n;)p*=n%i++!=0;}main(n){for(;~scanf("%d",&n);){for(m=n;P(--m),!p;);for(;P(++n),!p;);printf("%d %d\n",m,n);}}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    

    
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        String answer;
        if(a+b>=c){
            answer="Yes";
        }else{
            answer="No";
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22608
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(pow(N, 3))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// GCD,LCMを求める関数
ll gcd(ll a,ll b){
	if(a%b==0) return(b);
	else return(gcd(b,a%b));
}
ll lcm(ll a, ll b){
	return a/gcd(a,b)*b;
}

signed main(){
	int n; cin>>n;
	VL t(n); rep(i,n) cin>>t[i];
	ll ans = t[0];
	reps(i,n-1) ans=lcm(ans,t[i]);
	cout << ans << endl;
  return 0;
}


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

int main(){
  while (true) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (j == W-1) {
          cout << "#" << endl;
        }
        else {
          cout << "#";
        }
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3056
N, M = map(int, raw_input().split())

arr = []

for i in range(M):
    arr.append(map(int, raw_input().split()))

ans = [0 for i in range(N)]

for i in range(M):
    tempa = arr[i][0] - 1
    tempb = arr[i][1] - 1

    ans[tempa] += 1
    ans[tempb] += 1

for i in range(N):
    print ans[i]

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
string s;
int n, k, c;
vector<int> v;
pair<int, int> d[200001]; // i부터 시작해서 얻을 수 있는 최대 개수
pair<int, int> d2[200001];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k >> c;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o') {
			v.push_back(i);
		}
	}

	for (int i = 0; i < v.size(); i++) {
		if (i == 0) {
			d[i].first = 1;
			d[i].second = v[i];
		}
		else {
			if (v[i] - d[i - 1].second > c) {
				d[i].first = d[i - 1].first + 1;
				d[i].second = v[i];
			}
			else {
				d[i] = d[i - 1];
			}
		}
	}

	for (int i = v.size() - 1; i >= 0; i--) {
		if (i == v.size() - 1) {
			d2[i].first = 1;
			d2[i].second = v[i];
		}
		else {
			if (d2[i + 1].second - v[i]> c) {
				d2[i].first = d2[i + 1].first + 1;
				d2[i].second = v[i];
			}
			else {
				d2[i] = d2[i + 1];
			}
		}
	}

	if (d[v.size() - 1].first < k || d[v.size() - 1].first > k) {
		return 0;
	}

	vector<int> ans;
	if (v.size() == 1) {
		cout << v[0] + 1<< '\n'; return 0;
	}
	if (d2[1].first < k) {
		ans.push_back(v[0]);
	}
	if (d[v.size() - 2].first < k) {
		ans.push_back(v[v.size() - 1]);
	}

	for (int i = 1; i <= v.size() - 2; i++) {
		if (d[i].second == v[i]) {
			int sum = d[i - 1].first + d2[i + 1].first;
			if (sum < k) {
				ans.push_back(v[i]);
			}
		}
	}
	sort(ans.begin(), ans.end());
	for (int next : ans) {
		cout << next + 1 << '\n';
	}

}


Measured memory_bytes: 6540