akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n, m, a[100000], b[100000], p[100000], s[100000];
long long ans[100000];
void init() {
	for (int i = 0; i < n; i++) {
		p[i] = i;
		s[i] = 1;
	}
}
int find(int u) {
	return (p[u] == u) ? u : (p[u] = find(p[u]));
}
void merge(int u, int v) {
	p[u] = v;
	s[v] += s[u];
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	init();
	long long cur = ((long long)n * (n - 1)) / 2;
	for (int i = m - 1; i >= 0; i--) {
		ans[i] = cur;
		a[i] = find(a[i]);
		b[i] = find(b[i]);
		if (a[i] != b[i]) {
			cur -= (long long)s[a[i]] * s[b[i]];
			merge(a[i], b[i]);
		}
	}
	for (int i = 0; i < m; i++) {
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int a[maxn],b[maxn],c[maxn];
vector<int> x[maxn<<1],y[maxn<<1];
void add(int u,int v,int w)
{
    if(u==v) return ;
    x[w].push_back(u);
    y[w].push_back(v);
}
int fa[maxn];
int findfa(int x)
{
    if(x==fa[x]) return x;
    return fa[x]=findfa(fa[x]);
}
int main()
{
    int n,q;
    int mn=1000000000;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%d",a+i,b+i,c+i);
        mn=min(mn,c[i]);
    }
    long long ans=1LL*mn*(n-1);
    for(int i=1;i<=q;i++)
    {
        if(c[i]>mn+2*n) continue;
        c[i]-=mn;
        a[i]++;b[i]++;
        add(a[i],b[i],c[i]);
        a[i]++;
        if(a[i]>n) a[i]-=n;
        add(a[i],b[i],c[i]+1);

    }
    for(int i=1;i<=n;i++)
        fa[i]=i;
    for(int i=0;i<=2*n;i++)
    {
        for(int j=0;j<x[i].size();j++)
        {
            int tx=x[i][j],ty=y[i][j];
            int fx=findfa(tx),fy=findfa(ty);
            if(fx==fy) continue;
            //printf("%d %d %d\n",tx-1,ty-1,i);
            fa[fx]=fy;
            tx++;ty++;
            ans+=i;
            if(tx>n) tx-=n;
            if(ty>n) ty-=n;
            add(tx,ty,i+2);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 40320
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  ll a, b;
  while(cin>>a>>b){
    if(a+b==15)
      cout<<"+"<<endl;
    else if(a*b==15)
      cout<<"*"<<endl;
    else
      cout<<"x"<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, ans = 1;
    cin >> n;

    for (lli i = 2; i <= sqrt(n); i++) {
        lli p = n;
        if (p % i != 0) {
            continue;
        }
        while (p % i == 0) {
            p /= i;
        }
        if (p % i == 1) {
            ans++;
        }

        p = n;
        lli val = n / i;
        while (p % val == 0) {
            p /= val;
        }
        if (p % val == 1) {
            ans++;
            if (i == sqrt(n) && n % i == 0) {
                ans--;
            }
        }
    }

    lli n2 = n - 1;

    for (lli i = 2; i <= sqrt(n2); i++) {
        if (n2 % i == 0) {
            ans += 2;
        }
        if (i == sqrt(n2) && n2 % i == 0) {
            ans--;
        }
    }

    if (n2 >= 2) {
        ans++;
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
//#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int s,w;cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else cout<<"safe"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

















































Measured memory_bytes: 3640
#include <iostream>
#include <string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	string a;
	cin>>a;
	if(a[0]=='7' || a[1]=='7' || a[2]=='7')
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3044
#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 min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#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 Graph = vector<vector<int>>;
int t=1;
v<int> d,f;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
  if(seen[v]==true) return;
  seen[v] = true; // v を訪問済にする
  d[v]=t++;
  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue; // next_v が探索済だったらスルー
    dfs(G, next_v); // 再帰的に探索
  }
  f[v]=t++;
}

signed _main() {
  // 頂点数と辺数
  int N; cin >> N;

  // グラフ入力受取 (ここでは無向グラフを想定)
  Graph G(N);
  d.resize(N);
  f.resize(N);
  for (int i = 0; i < N; ++i) {
    int u, k; cin >> u >> k;
    u--;
    rep(j,k){
      int v; cin >> v;
      v--;
      G[u].push_back(v);
    }
  }

  // 頂点 0 をスタートとした探索
  seen.assign(N, false); // 全頂点を「未訪問」に初期化
  rep(i,N){
    dfs(G,i);
  }
  rep(i,N){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}



Measured memory_bytes: 3252
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t int64;
typedef int64_t ll;

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

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

using namespace std;


class C {
	int n;
	vector<int> a;
public:
	C()
	{
		cin >> n;
		a.resize(n);

		REP(i, n)
		{
			cin >> a[i];
			a[i] -= (i + 1);
		}
	}

	void solve()
	{
		sort(ALL(a));

		int med;
		if (n & 1)
			med = a[(n - 1) / 2];
		else
			med = (a[n / 2 - 1] + a[n / 2]) / 2;

		ll ans{ 0 };
		ll tmp{ 0 };

		REP(i, n)
		{
			ans += abs(a[i] - med);
			tmp += abs(a[i] - med - 1);
		}

		chmin(ans, tmp);

		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		int n;
		cin >> n;
		vector<int> a(n + 1);
		int b;
		REP(i, n) {
			cin >> a[i] >> b;
		}
		a[n] = b;
		vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
		RREP(i, n + 1) {
			FOR(j, i + 2, n + 1) {
				int tmp = INT_MAX;
				FOR(k, i + 1, j) {
					chmin(tmp, dp[i][k] + dp[k][j] + a[i] * a[k] * a[j]);
				}
				dp[i][j] = tmp;
					
			}
		}
		put(dp[0][n]);
	}
		
	
} // namespace idaten

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



Measured memory_bytes: 3236
/*
Question:

*/

/*
Solution:
*/
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;

#define PB push_back
#define MP make_pair
// #define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define show(arr)                          \
    for (auto& ax : arr) cout << ax << ", "; \
    cout << "\n";
#define disp(x) cerr << #x << " is " << x << endl;

//One-char comment switch:
/*
commented
//*/

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k, a, b;
    cin >> k >> a >> b;

    if (a % k == 0 || b % k == 0 || (a + (k-(a%k)) <= b))
        cout << "OK" << "\n";
    else
        cout << "NG" << "\n";
}


Measured memory_bytes: 3688
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN(ll, q);
	IN_VPair(ll, ll, abls, n - 1);
	IN_VPair(ll, ll, pxls, q);
	
	vector<ll> cnt(n, 0);
	vector<vector<ll>> children(n);

	sort(ALL(abls));
	REP(i, 0, n - 1) {
		children[abls[i].first - 1].push_back(abls[i].second - 1);
	}
	REP(i, 0, q) {
		cnt[pxls[i].first - 1] += pxls[i].second;
	}
	
	cout << cnt[0];
	for (auto& child : children[0])cnt[child] += cnt[0];
	REP(i, 1, n) {
		cout << " " << cnt[i];
		for (auto& child : children[i])cnt[child] += cnt[i];
	}

	return 0;
}

Measured memory_bytes: 21120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
const int N=1e6;

int32_t main()
{
    boost;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif // ONLINE_JUDGE
    
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<n;i++)
    	cin>>b[i];
    vector<int>c=a;
    sort(c.begin(),c.end());
    int a1=0,b1=0,cnt=0;
    do{
    	cnt++;
    	if(c==a && c==b){
    		a1=b1=0;
    		break;
    	}
    	else if(c==a){
    		a1=cnt;
    		a.push_back(n+1);
    	}
    	else if(c==b){
    		b1=cnt;
    		b.push_back(n+1);
    	}
    }while(next_permutation(c.begin(),c.end()));
    cout<<abs(a1-b1)<<endl;
}   

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

int main()
{
    int arr[3],i,f1=0,f3=0,f2=0,sum=0;
    for(i=0;i<3;i++)
    {
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    /*for(i=0;i<2;i++)
    {
        if(arr[i]==5)
        {
            f1=1;
            continue;
        }
        if(arr[i]==5&&f1==1)
        {
            f2=1;

        }
        if(arr[i]==7)
        {
            f3=1;

        }*/
        if(sum==17)
            printf("YES");
        else
            printf("NO");


    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int i,n,a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int tmp1,tmp2;
    for(i=0;i<n/2;i++){
        tmp1=a[i];
        tmp2=a[n-1-i];
        a[i]=tmp2;
        a[n-1-i]=tmp1;
    }
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i==n-1){
            printf("\n");
        }else{
            printf(" ");
        }
    }
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl

void solve(){
	int n,k; cin>>n>>k;
	vi v(n); rep(i,0,n-1) cin>>v[i];
	sort(all(v));
	ll ans = 0;
	rep(i,0,k-1) ans += v[i];
	cout << ans;
}

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}


Measured memory_bytes: 3660
#pragma GCC optimize("O3")
            #pragma comment(linker, "/stack:200000000")
            #pragma GCC optimize("unroll-loops")
             
            #include <algorithm>
            #include <bitset>
            #include <cassert>
            #include <chrono>
            #include <cmath>
            #include <complex>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <ctime>
            #include <deque>
            #include <functional>
            #include <iomanip>
            #include <iostream>
            #include <iterator>
            #include <limits>
            #include <climits>
            #include <list>
            #include <map>
            #include <numeric>
            #include <queue>
            #include <random>
            #include <ratio>
            #include <set>
            #include <sstream>
            #include <stack>
            #include <string>
            #include <unordered_map>
            #include <unordered_set>
            #include <utility>
            #include <vector>
            using namespace std;
             
            typedef long long ll;
            typedef long double ld;
            #define int ll
            #define double ld
            #define pb push_back
            #define mp make_pair
            #define REP(i,n) for (int i = 0; i < n; i++)
            #define loop(i,n) for (int i = 0; i < n; i++)
            #define FOR(i,a,b) for (int i = a; i < b; i++)
            #define REPD(i,n) for (int i = n-1; i >= 0; i--)
            #define FORD(i,a,b) for (int i = a; i >= b; i--)
            #define remax(a,b) a = max(a,b)
            #define remin(a,b) a = min(a,b)
            #define mem(a, b) memset(a, b, sizeof a)
            #define append push_back
            #define all(v) v.begin(),v.end()
            #define F first
            #define S second
            #define print(x) cout << (x) << endl
            #define PRECISION(x) cout << fixed << setprecision(x)
            #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
            
            const double PI=acos(-1);
            const int MOD = 1000000007;
            const int FMOD = 998244353;
            const double eps = 1e-9;
             
            mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
 int dp[10005][105][2][2];
 string k;
 int d;
 int solve(int pos,int tight,int st,int sum)
 {
 	if(pos==k.size())
 	{
 		if(sum==0 && st)
 		return 1;
 		return 0;
	 }
	 if(dp[pos][sum][tight][st]!=-1)
	 {
	 	return dp[pos][sum][tight][st];
	 }
	int up=(tight)?(k[pos]-'0'):9;
	
	int ans=0;
	ans=(ans+solve(pos+1,tight&(up==0),st,sum))%MOD;
	for(int i=1;i<=up;i++)
	{
		ans=(ans+solve(pos+1,tight&(up==i),1,(sum+i)%d))%MOD;
	}
	return dp[pos][sum][tight][st]=ans;
 }
signed main(){

	
	cin>>k>>d;
	mem(dp,-1);
	cout<<solve(0,1,0,0);
}
			

Measured memory_bytes: 38400
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll i,j,k,n,ans;
int main(){
	while (scanf("%lld",&n)!=EOF){
		ans=n/11*2;k=n%11;
		if (k&&k<=6) ans++;
		if (k>6) ans+=2;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String Str1 = scan.next();
		String Str2 = scan.next();
		String Str3 = scan.next();
		long H = Long.parseLong(Str1);
		long W = Long.parseLong(Str2);
		long N = Long.parseLong(Str3);
		long answer  = 0;
		if(W > H) {
			for(int i = 0; W > i ; i++) {
				N = N - W;
				if(N <= 0) {
					answer = i+1;
					break;
				}
			}
			if(N > 0) {
			for(int i = 0; H > i ; i++) {
				N = N - H;
				if(N <= 0) {
					answer = i+1;
					break;
				}
			}
			}
		}else{
				for(int i = 0; H > i ; i++) {
					N = N - H;
					if(N <= 0) {
						answer = i+1;
						break;
					}
			}
				if(N > 0) {
				for(int i = 0; W > i ; i++) {
					N = N - W;
					if(N <= 0) {
						answer = i+1;
						break;
					}
				}
			}
		}
		System.out.print(answer);

		}
	}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n,m;
vector<ll> a,b;

void input(){
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<m;i++) cin >> b[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<ll> andv,orv;
    set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(andv));
    set_union(a.begin(), a.end(), b.begin(), b.end(), back_inserter(orv));
    cout << andv.size() << ' ' << orv.size() << endl;
    for(auto e:andv) cout << e << endl;
    for(auto e:orv) cout << e << endl;
}


Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

//const ll mod = 998244353;
const ll mod = 1e9 + 7;
const ll MAX_SIZE = 1000005;
array<ll, MAX_SIZE> fac, inv, finv;
ll fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % mod;
    finv[0] = modpow(fac[MAX_SIZE - 1], mod - 2, mod);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % mod;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, mod - 2, mod);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % mod; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % mod * finv[a - b] % mod; }


int main() {
    init();
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    ll N = H + W;
    fac_init();

    ll ans = 0;
    rep(i, H-A){
        ans += comb(i + B - 1, i) * comb((H-i-1)+(W-B-1), W-B-1) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int a;
    string b,c;
    cin>>a;
    for(int i=0;i<a;i++){
	cin>>b>>c;
	int lcs[1005][1005]={};
	for(int j=1;j<=b.size();j++){
	    for(int k=1;k<=c.size();k++){
		if(b[j-1]==c[k-1]) lcs[j][k]=lcs[j-1][k-1]+1;
		else lcs[j][k]=max(lcs[j-1][k],lcs[j][k-1]);
	    }
	}
	cout<<lcs[b.size()][c.size()]<<"\n";
    }
}



Measured memory_bytes: 7080
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st;
	    int sum = 0, wa = 0, count = 0;
	    while((st=sc.readLine())!=null){
		String[] a = st.split(",");
		sum += Integer.valueOf(a[0])*Integer.valueOf(a[1]);
		wa += Integer.valueOf(a[1]);
		count++;
	    }
	    System.out.printf("%d\n%d\n",sum,(int)((double)wa/count+0.5));
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 11000
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int N; cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


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

int main() {


//long long a,b;
//int *num=new int[4];
//char *s=new char[3];
string s;
cin >> s;

//if (s.find("AC") != std::string::npos) {

int n=(int)(s.length());
int res=0;

if(n<=3){
cout << "No";
}else if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){

cout << "Yes";
}else{
cout << "No";

}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
}

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

  
int main() {
 int H , N;
  cin >> H >>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
   cin >> A[i]; 
  }
  int S=0;
    for(int i=0;i<N;i++){
	S += A[i];
    }
  if(S >=H) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main(){
  int k;
  vector<int> antena(5);

  for(int i = 0; i < 5; i++){
    cin >> antena.at(i);
  }

  cin >> k;

  if(antena.at(4) - antena.at(0) > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;

}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int n,m;
int cnt=0;

int p[2000000];
int main() 
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a*b*c==5*5*7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



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

using namespace std;

int main(){
	int x, y, rest, cnt;

	while (cin >> x >> y, x) {
		if (x < y) {
			rest = x;
			x = y;
			y = rest;
		}
		cnt = 0;
		while(true) {
			++cnt;
			rest = x%y;
			if (rest == 0) {
				break;
			}
			x = y;
			y = rest;
		}
		cout << y << " " << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int r, D;
  ll x;
  cin >> r >> D >> x;
  for(int i=0; i<10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t k,n;
    cin >> k >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    // 一番間隔の広い場所を探して引けば良い
    sort(a.begin(), a.end());
    vi distance(n);
    rep(i,n-1){
        distance.at(i) = a.at(i+1) - a.at(i);
    }
    distance.at(n-1) = k + a.at(0) - a.at(n-1);
    sort(distance.begin(), distance.end(), greater<>());
    cout << k-distance.at(0) << endl;
}

Measured memory_bytes: 3456
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        ans += c[A[i][j]][1]

print(ans)


Measured memory_bytes: 3700
import java.util.*;
public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        boolean[] isPrime = new boolean[1000001];
        Arrays.fill(isPrime,true);
        isPrime[0] = isPrime[1] = false;
        for(int i = 2; i*i < 1000000; i++){
            if(isPrime[i]){
                for(int ii = i+i; ii < 1000000; ii+=i){
                    isPrime[ii] = false;
                }
            }
        }
        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n==0 && x==0){
                break;
            }
            int price[] = new int[n];
            for(int i = 0; i < n; i++){
                price[i] = sc.nextInt();
            }
            boolean[] dp = new boolean[x+1];
            dp[0] = true;
            for(int p: price){
                for(int i = 0; i <= x-p; i++){
                    dp[i+p] = dp[i] || dp[i+p];
                }
            }
            int ans = 0;
            for(int i = x; i > 0; i--){
                if(dp[i] && isPrime[i]){
                    ans = i;
                    break;
                }
            }
            System.out.println(ans==0 ? "NA" : ans);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}
    

Measured memory_bytes: 59428
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	String[] ss;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			ss=new String[n];
			for(int i=0; i<n; i++){
				ss[i]=sc.next();
			}
			solve();
		}
	}

	int size;
	int[] cs;
	int[] map;
	boolean[] used;
	int ans;

	void solve(){
		int[] a=new int[256];
		fill(a, -1);
		size=0;
		for(String s : ss){
			for(int i=0; i<s.length(); i++){
				if(a[s.charAt(i)]==-1){
					size++;
					a[s.charAt(i)]=INF;
				}
				a[s.charAt(i)]=min(a[s.charAt(i)], s.length()-1-i);
			}
		}
		cs=new int[size];
		for(int k=0, i=0; i<256; i++){
			if(a[i]>=0){
				cs[k++]=i+1000*a[i];
			}
		}
		sort(cs);
		/*
		 * for(int i=0;i<size;i++){
		 * cs[i]%=1000;
		 * }
		 */
		// debug(size, cs);

		for(int i=0; i<size; i++){
			// debug(i, (char)(cs[i]%1000), cs[i]/1000);
		}

		used=new boolean[10];
		map=new int[256];
		fill(map, -1);
		ans=0;
		dfs(0);
		// debug(ans);
		println(""+ans);
	}

	void dfs(int k){
		if(k>5&&false){
			debug("k", k);
			String debug="";
			for(int i=0; i<size; i++){
				debug+=(char)(cs[i]%1000)+":"+map[cs[i]%1000]+", ";
			}
			debug(debug);
		}
		if(k==size){
			// ツつィツづュツつス
			if(ok()){
				ans++;
			}
			return;
		}
		for(int i=0; i<10; i++){
			if(!used[i]){
				used[i]=true;
				map[cs[k]%1000]=i;
				// ツづつォツづーツづ可チツェツッツク
				if(ok(k)){
					dfs(k+1);
				}
				map[cs[k]%1000]=-1;
				used[i]=false;
			}
		}
	}

	boolean ok(int k){
		int sum=0;
		int d=cs[k]/1000;
		// debug("d", d);
		for(int j=0; j<n; j++){
			if(map[ss[j].charAt(0)]==0&&ss[j].length()>1){
				return false;
			}
			int num=0;
			for(int i=max(0, d-ss[j].length()); i<d; i++){
				num=num*10+map[ss[j].charAt(ss[j].length()-d+i)];
			}
			// debug(j, num);
			if(j==n-1){
				sum-=num;
			}else{
				sum+=num;
			}
		}
		int mod=1;
		for(int i=0; i<d; i++){
			mod*=10;
		}
		return sum%mod==0;
	}

	boolean ok(){
		int sum=0;
		for(int j=0; j<n; j++){
			if(map[ss[j].charAt(0)]==0&&ss[j].length()>1){
				return false;
			}
			int num=0;
			for(int i=0; i<ss[j].length(); i++){
				num=num*10+map[ss[j].charAt(i)];
			}
			if(j==n-1){
				sum-=num;
			}else{
				sum+=num;
			}
		}
		return sum==0;
	}

	boolean nextPermutation(int[] is){
		int n=is.length;
		for(int i=n-1; i>0; i--){
			if(is[i-1]<is[i]){
				int j=n;
				while(is[i-1]>=is[--j]);
				swap(is, i-1, j);
				rev(is, i, n);
				return true;
			}
		}
		rev(is, 0, n);
		return false;
	}

	void swap(int[] is, int i, int j){
		int t=is[i];
		is[i]=is[j];
		is[j]=t;
	}

	void rev(int[] is, int i, int j){
		for(j--; i<j; i++, j--){
			int t=is[i];
			is[i]=is[j];
			is[j]=t;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;
typedef long long ll;

template <int MD>
struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0   ) : v(_v) {}
    M& operator += (const M &r) {
        if ((v += r.v) >= MD) v -= MD;
        return *this;
    }
    M& operator *= (const M &r) {
        v = ll(v) * r.v % MD;
        return *this;
    }
    M operator + (const M &r) const { return M(*this) += r; }
    M operator * (const M &r) const { return M(*this) *= r; }
    M pow(int n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return this->pow(MD - 2); }
};
typedef ModInt<998244353> Mint;

const int MN = 4444;
int N, K;
Mint fac[MN], ifac[MN], p2[MN];

void first() {
    fac[0] = 1;
    for (int i = 1; i < MN; i++) {
        fac[i] = fac[i - 1] * Mint(i);
    }
    ifac[MN - 1] = fac[MN - 1].inv();
    for (int i = MN - 2; i >= 0; i--) {
        ifac[i] = ifac[i + 1] * Mint(i + 1);
    }
    for (int i = 0; i < MN; i++) {
        assert((fac[i] * ifac[i]).v == 1);
    }
    p2[0] = 1;
    for (int i = 1; i < MN; i++) {
        p2[i] = p2[i - 1] + p2[i - 1];
    }
}

Mint C(int n, int r) {
    if (n < r || n < 0 || r < 0) return Mint(0);
    return fac[n] * ifac[r] * ifac[n - r];
}

Mint solve(int n, int k) {
    int p = (k - 1) / 2 - max(1, k - K) + 1;
    Mint sm = 0;
    int d = (k % 2 == 0);
    for (int q = 0; q <= p; q++) {
        sm += C(p, q) * p2[q] * C(n - 1 + K - 2 * p - d, q + K - 2 * p - d - 1);
    }
    return sm;
}

int main() {
    first();
    cin >> K >> N;
    for (int k = 2; k <= 2 * K; k++) {
        Mint ans = solve(N, k);
        if (k % 2 == 0) ans += solve(N - 1, k);
        cout << ans.v << '\n';
    }
    return 0;
}

Measured memory_bytes: 384
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N+1):
        if (N - i - j) * 10000 + i * 5000 + j * 1000 == Y:
            if (N - i - j) < 0:
                continue
            print(N - i - j, i, j)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 40684
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, C) = Read3Longs();
            if (A == B)
            {
                return C;
            }
            else if (A == C)
            {
                return B;
            }
            else
            {
                return A;
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27924
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n=in();
  vi h(n);
  rep(i,n) cin>>h[i];
  bool ok = true;
  for(int i=n-1;i>=1;--i){
    if(h[i-1]-h[i]==1){ h[i-1]--; }
    else if(h[i-1]-h[i]>1){ ok = false; break; }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())

tree = [[] for _ in range(N)]

for _ in range(N):
    u, k, *v = map(int, input().split())
    tree[u-1] = v

ans = [float('inf') for _ in range(N)]
ans[0] = 0

from collections import deque

q = deque([(0, 0)])

while q:
    p, d = q.popleft()
    for c in tree[p]:
        if ans[c-1] > d+1:
            ans[c-1] = d+1
            q.append((c-1, d+1))

for i in range(N):
    if ans[i] == float('inf'):
        print(i+1, -1)
    else:
        print(i+1, ans[i])


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

int main()
{
   int A,B;
   cin >> A >> B;
   int num=0;
   for (int i=A;i<B+1;i++)
   {
      int c[5] = {0};
      for (int j=0;j<5;j++)
      {
         int a,b;
         a = i / pow(10,j);
         b = i / pow(10,j+1);
         c[j] = a - b*10;
      }
      
      if((c[0]==c[4])&&(c[1]==c[3])) num += 1;
   }
   cout << num << endl;
}

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

using namespace std;
/*int gcd(int a,int b){
	return b?(b,a%b):a;
}*/
int main(){
	long long int a,n,x;
	cin>>n;
	cin>>a;
	n--;
	while(n--){
		
		cin>>x;
		a = __gcd(a,x);	
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a;
    cin >> n >> a;
    print(n*n-a);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    double d,t,s;
    cin>>d>>t>>s;
    double result = d/s;
    if( t-result >= 0 ){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

        //static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NXY = Sarray();
            var N = NXY[0];
            var X = NXY[1];
            var Y = NXY[2];
            var dst = new long[N];
            for (var l = 1; l <= N - 1; ++l)
            {
                for (var r = l + 1; r <= N; ++r)
                {
                    if (l <= X)
                    {
                        if (r <= X) ++dst[r - l];
                        else if (r <= Y) ++dst[X - l + Min(r - X, Y - r + 1)];
                        else if (Y < r) ++dst[X - l + 1 + r - Y];
                    }
                    else if (l <= Y)
                    {
                        if (r <= Y) ++dst[Min(r - l, l - X + 1 + Y - r)];
                        else if (Y < r) ++dst[Min(Y - l, l - X + 1) + r - Y];
                    }
                    else
                    { ++dst[r - l]; }
                }
            }
            for (var i = 1; i <= N - 1; ++i)
                WriteLine(dst[i]);
        }
    }
}

Measured memory_bytes: 13396
n = int(input())

b = list(map(int, input().split(' ')))

a = [10 ** 6 for i in range(n)]
a[0] = b[0]
for i in range(n - 1):
    if a[i] > b[i]:
        a[i] = b[i]
    a[i + 1] = b[i]
print(sum(a))

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
    int m[50], t[50], r[50];
    int sum[50];
    int i = 0;
    int j;

    while (1)
    {
        i++;
        scanf("%d %d %d", &m[i], &t[i], &r[i]);

        sum[i] = m[i] + t[i];

        if (m[i] == -1 && t[i] == -1 && r[i] == -1) //全て-1の時終了。
        {
            break;
        }
    }

    for (j = 1; j < i; j++)
    {
        if (m[j] == -1 || t[j] == -1)
        {
            puts("F");
        }
        else if (sum[j] >= 80)
        {
            puts("A");
        }
        else if (65 <= sum[j] && sum[j] < 80)
        {
            puts("B");
        }
        else if (50 <= sum[j] && sum[j] < 65)
        {
            puts("C");
        }
        else if (30 <= sum[j] && sum[j] < 50)
        {
            if (r[j] >= 50)
            {
                puts("C");
            }
            else
            {
                puts("D");
            }
        }

        else
        {
            puts("F");
        }
    }

    return 0;
}



Measured memory_bytes: 2604
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N,t;
  cin>>N;
  vector<int> A(N,0);
  vector<int> O(N,0);
  for(int i=0;i<N;i++){
    cin>>t;
    A[i]=t;
  }
  t=1;
  for(int i=0;i<N;i++){
    O[A[i]-1]=i+1;
  }
  for(int i=0;i<N;i++){
    cout<<O[i];
    if(i+1!=N){
      cout<<" ";
    }else{
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll a, b;
    cin >> a >> b;
    if (b >= a) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3620
from collections import Counter
from collections import deque
INF = 1145141919810364364334
n = int(input())
c = []
b = [0] * (n-1)
edge = [[] for i in range(n)]
for i in range(n-1):
    a,b[i] = map(int,input().split())
    edge[a-1].append(b[i]-1)
    edge[b[i]-1].append(a-1)
    c.append(a)
    c.append(b[i])

d = Counter(c)
hen = d.most_common()[0][1]

col = [INF] * n
col[0] = 0

q = deque()
q.append(0)

while q:
    x = q.popleft()
    no = (col[x] + 1) % hen
    for i in edge[x]:
        if col[i] == INF:
            col[i] = no
            no = (no+1) % hen 
            q.append(i)
            
print(hen)
for i in range(n-1):
    print(col[b[i]-1] + 1)

Measured memory_bytes: 99356
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        boolean ans = false;
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                ans = true;
            }
        }
        if (ans) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 27068
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(ll, a, b, k);

  if (a <= k)
    cout << 0 << " " << max(0ll, b - (k - a)) << endl;
  else
    cout << a - k << " " << b << endl;

  return 0;
}

Measured memory_bytes: 256