akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<int,int>
#define pli pair<ll,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=200005;
int n,L,pre[N],nxt[N];ll ans,f1[N],f2[N],g1[N],g2[N];
vi V1,V2;priority_queue<pii,vector<pii>,greater<pii> >Q;
inline void link(int x,int y){pre[y]=x;nxt[x]=y;}
inline ll calc(int x)
{
	int m=V2.size(),c=m/L,pl=pre[V2[0]],pr=nxt[V2[m-1]];ll res=0;
	ll s=0;rep0(i,0,m){s+=i>=L-1?f1[V2[i-L+1]]:0;res+=s*f2[V2[i]];}
	for(int i:V2)g1[i]=f1[i],g2[i]=f2[i],f1[i]=f2[i]=0;
	if(!c){nxt[pl]=n+1,pre[pr]=0;return res;}
	rep0(i,L-1,m){int t=(i+1)/L-1;f2[V2[t]]+=g2[V2[i]];}
	per(i,m-L,0){int t=c-(m-i)/L;f1[V2[t]]+=g1[V2[i]];}
	link(pl,V2[0]);rep0(i,1,c)link(V2[i-1],V2[i]);link(V2[c-1],pr);
	rep0(i,0,c)Q.push(mp(x+1,V2[i]));
	s=0;rep0(i,0,c){s+=i>=L-1?f1[V2[i-L+1]]:0;res-=s*f2[V2[i]];}
	return res;
}
int main()
{
	n=rd();L=rd();rep(i,0,n)link(i,i+1);
	rep(i,1,n){Q.push(mp(rd(),i));f1[i]=f2[i]=1;}
	while(!Q.empty())
	{
		int x=Q.top().X;V1.clear();V2.clear();
		while(!Q.empty()&&Q.top().X==x)V1.pb(Q.top().Y),Q.pop();
		fore(i,V1)
		{
			if(i&&nxt[V1[i-1]]!=V1[i])ans+=calc(x),V2.clear();
			V2.pb(V1[i]);
		}
		ans+=calc(x);
	}
	printf("%lld\n",ans+n);return 0;
}


Measured memory_bytes: 10864
N,M=map(int,input().split())
xlist=list(map(int,input().split()))

xlist.sort()
#print(xlist)

xintv=[-1]*(M-1)
for i in range(M-1):
  xintv[i]=xlist[i+1]-xlist[i]
  
xintv.sort()
#print(xintv)

if N==1:
  print(sum(xintv))
else:
  print(sum(xintv[0:-N+1]))

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}



Measured memory_bytes: 256
n,z,w=map(int, input().split())
a=list(map(int, input().split()))

if len(a)==1: print(abs(a[-1]-w))
elif abs(a[-2]-a[-1])>abs(a[-1]-w):
    print(abs(a[-2]-a[-1]))
else: print(abs(a[-1]-w))

Measured memory_bytes: 3188
s = input()
cnt = 0
if s[0] == "A" and s[2:-1].count("C") == 1:
    for i in range(len(s)):
        if ord(s[i])<=90:
            cnt += 1
    if cnt != 2:
        print("WA")
        quit()
    else:
        print("AC")
else:
    print("WA")


Measured memory_bytes: 2940
def modelAnswer(N:int,K:int,S:int) -> None:
   ans = "{} ".format(S)*K
   if(S == 10**9):
      ans += "1 "*(N-K)
   else:
      ans += "{} ".format(S+1)*(N-K)
   print(ans)
def main():
   N,K,S = map(int,input().split())
   modelAnswer(N,K,S)
if __name__ == '__main__':
   main()

Measured memory_bytes: 6260
/* Author: Akkapaka Saikiran (@saikidon911) */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using vi = vector<int>; using vll = vector<long long>; 
using vvi = vector<vector<int> >; using vb = vector<bool>;
using pii = pair<int,int>; 
#define pb push_back
#define all(v) v.begin(),v.end()
#define llmax 9223372036854775807
#define intmax 2147483647
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll mod = 1e9+7;
//////////////////////////////////////////
#define test(t) int t; cin>>t; while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
////////////////////////////////////////////
#define tki take_input 
#define tkii take_input<int>
template <typename T> void take_input(vector<T> &a,int sz){
	T t;rep(i,sz){cin>>t;a.pb(t);}}
#define prv print_vector
#define prvi print_vector<int> 
template <typename T> void print_vector(vector<T> v){
	rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;}
/////////////////////////////////////////

int main(){
	fastio;

	int n; cin>>n;
	vi cnt(4);
	
	string s;
	rep(i,n){
		cin>>s;
		if(s == "AC") cnt[0]++;
		else if(s == "WA") cnt[1]++;
		else if(s == "TLE") cnt[2]++;
		else cnt[3]++;
	}

	cout<<"AC x "<<cnt[0]<<endl;
	cout<<"WA x "<<cnt[1]<<endl;
	cout<<"TLE x "<<cnt[2]<<endl;
	cout<<"RE x "<<cnt[3]<<endl;

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    vector<int> a(m),b(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    reverse(all(a));
    reverse(all(b));

    UnionFind uf(n);
    vector<ll> ans(m);
    rep(i,m){
        if(uf.issame(a[i],b[i])) ans[i]=0;
        else{
            ll x=uf.size(a[i]);
            ll y=uf.size(b[i]);
            ans[i]=x*y;
            uf.merge(a[i],b[i]); 
        }
    }
    vector<ll> res(m);
    reverse(all(ans));
    //rep(i,m) cout<<ans[i]<<endl;
    res[0]=ans[0];
    for(int i=1;i<m;i++){
        res[i]=res[i-1]+ans[i];
    }

    rep(i,m) cout<<res[i]<<endl;
}

Measured memory_bytes: 5900
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
void solve(){
	int r; 
	cin>>r; 
	cout<<3*r*r<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int cnt_digits(ll N){
	int digits=0;
	while(N>0){
		N/=10;
		digits++;
	}
	return digits;
}

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

	int ans=cnt_digits(N);

	for(ll A=1LL;A*A<=N;++A)
	{
		if(N%A!=0)continue;
		const ll B=N/A;
		const int cur=max(cnt_digits(A),cnt_digits(B));
		//cout<<A<<endl;
		if(ans>cur)
		{
			ans=cur;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

static char MARK[4]={'S','H','C','D'};
int n,num;
char mark;
bool existCard[4][14]={false};

int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>mark>>num;
        for(int j=0;j<4;++j){
            if(mark==MARK[j]){
                existCard[j][num]=true;
            }
        }
    }
    for(int i=0;i<4;++i){
        for(int j=1;j<=13;++j){
            if(existCard[i][j]==false)
                cout<<MARK[i]<<" "<<j<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
n = int(input())
a = list(map(int, input().split()))

max_a = max(a)
l = [0] * max_a

for i in range(n):
  j = 1
  while a[i] * j - 1 < max_a:
    l[a[i] * j - 1] += 1
    j += 1

count = 0

for i in range(n):
  if l[a[i] - 1] == 1:
    count += 1

print(count)

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

int main() {
  string s;
  cin >> s;

  int ans = 0;
  int n = s.length();
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll hoge = 4 * h * n - h * N - n * N;
            if (hoge <= 0) continue;
            ll foo = h * n * N;
            if (foo % hoge == 0) {
                ll w = foo / hoge;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#################################
#配列を二つに分ける
#引数
# values: 配列
# a,b   : 配列の格納先
#戻り値
# なし
#################################
def separate(values,a,b):
    for v in values:
        a.append(v)
        a,b = b,a


##############################
#登場回数の多い数と登場回数を返す
#引数
# values: ソートされた配列
#戻り値
# 辞書型配列
##############################
def getCount(values):
    currentNum=0
    currentCount=0
    ret={'First' :{'Num':[],'Cnt':0},
         'Second':{'Num':[],'Cnt':0}}
    for v in values:
        if v==currentNum:
            currentCount+=1
        else:
            #別の数字が表れた場合
            if ret['First']['Cnt'] < currentCount:
                #最大値より大きい場合、それが新たな最大値になる
                ret['Second']=ret['First'].copy()
                ret['First']={'Num':[currentNum],'Cnt':currentCount}
            elif ret['First']['Cnt'] == currentCount:
                #最大値タイ
                ret['First']['Num'].append(currentNum)
            elif ret['Second']['Cnt'] < currentCount:
                #2番目より大きい場合、それが新たな2番目になる。
                ret['Second']={'Num':[currentNum],'Cnt':currentCount}
            elif ret['Second']['Cnt'] == currentCount:
                #2位タイ
                ret['Second']['Num'].append(currentNum)

            currentNum=v
            currentCount=1

    #配列の最後まで来た場合
    if ret['First']['Cnt'] < currentCount:
        ret['Second']=ret['First'].copy()
        ret['First']={'Num':[currentNum],'Cnt':currentCount}
    elif ret['First']['Cnt'] == currentCount:
        ret['First']['Num'].append(currentNum)
    elif ret['Second']['Cnt'] < currentCount:
        ret['Second']={'Num':[currentNum],'Cnt':currentCount}
    elif ret['Second']['Cnt'] == currentCount:
        ret['Second']['Num'].append(currentNum)

    return ret


#############################
# メイン
#############################
n = input()
vars = input ()
a=[]
b=[]
varArray=vars.split(" ")
separate(varArray,a,b)
a.sort()
b.sort()
a_result=getCount(a)
b_result=getCount(b)
if (len(a_result['First']['Num'])>1 or
    len(b_result['First']['Num'])>1):
    #最頻値が複数ある場合は素直に計算可
    xa=len(a)-a_result['First']['Cnt']
    xb=len(b)-b_result['First']['Cnt']
    x=xa+xb
else:
    #abどちらも最頻値が1種類の場合
    if a_result['First']['Num'][0]!=b_result['First']['Num'][0]:
        #abの最頻値が異なる場合は素直に計算可
        xa=len(a)-a_result['First']['Cnt']
        xb=len(b)-b_result['First']['Cnt']
        x=xa+xb
    else:
        #abの最頻値が同じ値の場合、どちらかは2番目の値を採用する必要あり
        xaa=len(a)-a_result['First']['Cnt']
        xab=len(b)-b_result['Second']['Cnt']
        xa=xaa+xab
        xba=len(a)-a_result['Second']['Cnt']
        xbb=len(b)-b_result['First']['Cnt']
        xb=xba+xbb
        x=xa if xa<xb else xb

print(x)


Measured memory_bytes: 11764
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int n, cnt = 1, i;
		cin >> n;
		string s;
		cin >> s;
		for(i = 1; i < n; i++){
			if(s[i] != s[i-1])
				cnt++;
		}
		cout << cnt;
    return 0;
} // What is to be written here?


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n; cin>>n;
  vector<int>p(n);
  rep(i,n) cin>>p[i];
  int cnt=0;
  rep(i,n){
    if(p[i]!=i+1)
      cnt++;
  }
  if(cnt<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

S += "R"

nR = True
nL = False
pair = True
pos = 0
rc = 0
lc = 0

res = [0 for _ in range(N)]

for i in range(N + 1):
    if nR and S[i] == "R":
        rc += 1
    elif nR and S[i] == "L":
        nR ^= True
        nL ^= True
        lc += 1
        pos = i - 1
    elif nL and S[i] == "L":
        lc += 1
    elif nL and S[i] == "R":
        nR ^= True
        nL ^= True
        if (rc + lc) % 2 == 0:
            res[pos] = (rc + lc) // 2
            res[pos + 1] = (rc + lc) // 2
        else:
            res[pos] = (rc + lc) // 2 + (rc % 2)
            res[pos + 1] = (rc + lc) // 2 + (lc % 2)
        rc = 1
        lc = 0

print(" ".join(list(map(str, res))))


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};

vector<int> G[100001];
bool dp[100001][3];


int main(){
    int n,m;cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        G[x].pb(y);
    }
    memset(dp,false,sizeof(dp));
    int s,t;
    cin >> s >> t;
    s--,t--;
    queue<pair<int,P>> q;
    q.push({0,{s,0}});
    while(!q.empty()){
        int c = q.front().first;
        int u = q.front().second.first;
        int k = q.front().second.second;
        q.pop();
        if(k==0&&u==t){
            cout << c << endl;
            return 0;
        }
        if(dp[u][k]) continue;
        dp[u][k]=true;
        for (int i = 0; i < G[u].size(); i++) {
            int v=G[u][i];
            q.push({c+(k==0),{G[u][i],(k+1)%3}});
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 6144
/// 12:14 am 02/08/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    ll k1 = 0;
    while (b <= a) {
        b *= 2;
        k1++;
    }
    while (c <= b) {
        c *= 2;
        k1++;
    }
    if (k1 > k) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 3560
gets
a = gets.split(' ').map(&:to_i).sort.reverse
gets
b = gets.split(' ').map(&:to_i)

count = 0

loop do
  pat = format("%0#{a.size}d", count.to_s(2))
  break if pat.size > a.size
  sum = 0
  pat.size.times { |x| sum += (pat[x] == '0' ? 0 : a[x])  }
  while b.include?(sum)
    b[b.index(sum)] = 'yes'
  end
  count += 1
end

b.each { |e| puts e == 'yes' ? e : "no" }


Measured memory_bytes: 6936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll k,a,b,u=0,d;
  cin>>k;
  cin>>a>>b;
  for(ll i=a;i<=b;i++){
  d=i%k;if(d==0){u=1;break;}
  }
  if(u==0){
    cout<<"NG"<<"\n";}
  else{cout<<"OK"<<"\n";}
  return 0;}

Measured memory_bytes: 3624
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <complex>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// define x, y as real(), imag()


template<class T>
istream& operator>> (istream& is, complex<T>& p) {
  T value;
  is >> value;
  p.real(value);
  is >> value;
  p.imag(value);
  return is;
}
#define M_PI 3.14159265358979323846
typedef long long int lli;
lli mod=998244353;
#define OS //single input use oeis
lli INF=9223372036854775807;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,s,t;
const double pi=3.14159265358979323846;
lli me(lli a,lli b)
{
    // cout<<mod<<"\n";
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}
lli factorial[1000005];
void compute()
{
	factorial[0] = 1;
for (lli i = 1; i <= 1000000; i++) {
    factorial[i] = factorial[i - 1] * i % mod;
}
}
lli binc(int n, int k) {
    return (factorial[n]%mod * mI(factorial[k])%mod) % mod * mI(factorial[n - k]) % mod;
}
int main()
{
compute();
lli n,m,k;
cin>>n>>m>>k;
lli ans=0;
for(lli j=n-1-k;j<=n-1;j++)
{
	lli tot=((binc(n-1,j)%mod*m%mod)%mod*(me(m-1,j)%mod)%mod)%mod;
	ans+=tot;
	ans%=mod;
}

cout<<ans;
}

Measured memory_bytes: 11448
import itertools as o,scipy.sparse as s;_,r,*t=[map(int,i.split())for i in open(0)];a,b,c=zip(*t);l=s.csgraph.dijkstra(s.csr_matrix((c,(a,b)),[201]*2),0);print(min(sum(int(l[i][j])for i,j in zip(a,a[1:]))for a in o.permutations(r)))

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;

  VI cnt1(26), cnt2(10);
  for(char c: S)
	if(isdigit(c))
	  cnt2[c-'0']++;
	else
	  cnt1[c-'a']++;

  int len = 0;
  while(count(ALL(cnt1), 0) < 26){
	int b = 0;
	for(;;++b) if(cnt1[b]) break;
	int e = b+1;
	for(;e<26;++e) if(!cnt1[e]) break;
	if(e-b >= 3){
	  FOR(i,b,e) --cnt1[i];
	  len += 3;
	}
	else{
	  --cnt1[b];
	  ++len;
	}
  }
  while(count(ALL(cnt2), 0) < 10){
	int b = 0;
	for(;;++b) if(cnt2[b]) break;
	int e = b+1;
	for(;e<10;++e) if(!cnt2[e]) break;
	if(e-b >= 3){
	  FOR(i,b,e) --cnt2[i];
	  len += 3;
	}
	else{
	  --cnt2[b];
	  ++len;
	}
  }

  cout << len << endl;

  return 0;
}



Measured memory_bytes: 3168
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int R = scan.nextInt();
        int I = 0;
        if(N>=10){
            I=R;
            System.out.println(I);
        }
        else{
            I=R+100*(10-N);
            System.out.println(I);
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    int r;
    r=a%b;
    if(r!=0)
    gcd(b,r);
    else
    return b;
}

int main(){
    int n,y;
    cin>>n>>y;
    int x[n];
    for(int i=0;i<n;i++)
    cin>>x[i];
    for(int i=0;i<n;i++)
    x[i]=abs(x[i]-y);
    sort(x,x+n);
    int ans;
    if(n>1){
        ans=gcd(x[1],x[0]);
        for(int i=2;i<n;i++)
        {
            ans=gcd(x[i],ans);
        }
    }
    else{
        ans=x[0];
    }
    cout<<ans<<endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, l;cin >> n >> l;
    vector<LL> a(n);
    inc(i, 0, n) cin >> a[i];
    bool ans = false;
    inc(i, 0, n-1){
        if(a[i]+a[i+1] >= l){
            ans = true;
        }
    }

    if(!ans){
        cout << "Impossible" << endl;
        return 0;
    }else{
        cout << "Possible" << endl;
    }

    vector<int> b;

    inc(i, 0, n-1){
        if(a[i]+a[i+1] >= l){
            inc(j, 0, i){
                b.pb(j+1);
            }
            dec(j, i+1, n-1){
                b.pb(j+1);
            }
            b.pb(i+1);
            break;
        }
    }

    for(auto bb : b){
        cout << bb << endl;
    }

    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
const ll maxn=100000+5;

vector<int> G[maxn];
int vis[maxn];
int n,k;

int a[maxn];

void dfs(int x)
{
    vis[x]=1;
    int cnt=0;
    for(int y:G[x])
    {
        if(vis[y])
            continue;
        a[y]=k-(cnt+(x==1?1:2));
        dfs(y);
        ++cnt;
    }
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<n-1;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    a[1]=k;
    dfs(1);
    ll ans=1;
    for(int i=1;i<=n;++i)
    {
        if(a[i]<=0)
        {
            ans=0;
            break;
        }
        ans=ans*a[i]%mod;
    }
    cout<<ans;
    return 0;
}



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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long x, a, b; scan(x, a, b);
      long y = -a + b;
      puts(y <= 0 ? "delicious" : y <= x ? "safe" : "dangerous");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string w;
    cin >> w;
    map<char, int> c;
    REP(i, w.length()) { c[w[i]]++; }
    for(auto i : c) {
        if(i.second % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<int>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// ここから開始だよ！
ll N;
std::vector<ll> v;
ll total;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
  
  cin >> N;
  rep(i, N) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
    total += tmp;
  }
  
  std::sort(v.begin(),v.end(),std::greater<int>());
  ll max_num = v[0];
  
  if (max_num < total - max_num) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String one = "',.,!?";
		String two = "abcABC";
		String three = "defDEF";
		String four = "ghiGHI";
		String five = "jklJKL";
		String six = "mnoMNO";
		String seven = "pqrsPQRS";
		String eight = "tuvTUV";
		String nine = "wxyzWXYZ";
		String zero = " ";
		
		while(sc.hasNext()){
			String ans = "";
			String line = sc.next();
			int n = 0;
			while(line.length() > n){
				int count = 0;
				while(n + 1 != line.length() && line.charAt(n) == line.charAt(n + 1)){
					count++;
					n++;
				}
				String temp = "";
				if(line.charAt(n) == '1')
					temp = one;
				else if(line.charAt(n) == '2')
					temp = two;
				else if(line.charAt(n) == '3')
					temp = three;
				else if(line.charAt(n) == '4')
					temp = four;
				else if(line.charAt(n) == '5')
					temp = five;
				else if(line.charAt(n) == '6')
					temp = six;
				else if(line.charAt(n) == '7')
					temp = seven;
				else if(line.charAt(n) == '8')
					temp = eight;
				else if(line.charAt(n) == '9')
					temp = nine;
				else if(line.charAt(n) == '0')
					temp = zero;
				if(temp == zero){
					if(count >= 1){
						for(int k = 0; k < count; k++){
							ans += " ";
						}
					}
				}else{
					ans += temp.charAt(count % temp.length());
				}
				n++;
			}
			System.out.println(ans);
		}
	}

}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; i++) cin >> S.at(i);
  sort(S.begin(), S.end());
  
  int counter = 1;
  for(int i = 0; i < N - 1; i++) {
    if(S.at(i) != S.at(i + 1)) {
      counter++;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 9564
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
#define rep(i,n) for(i = 0; i < n; i++)
#define FOR(i,m,n) for(i = m, i < n; i++)
#define repr(i,n) for(i = n; i >= 0; i--)
#define INF = 999999999
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
const int MOD = 1000000007;

  
int main(){
  string s,t;
  int i;
  cin >> s >> t;
  int N = s.size();
  int M =  t.size();
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));
  if(s < t)
    cout << "Yes" << endl;
    else
      cout << "No" << endl;

  return 0;
}
       


Measured memory_bytes: 256
//shara's here
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
int main(){
    q a,b,c;
    cin>>a;
    if(a==25){cout<<"Christmas";}
    else if(a==24){cout<<"Christmas Eve";}
    else if(a==23){cout<<"Christmas Eve Eve";}
    else if(a==22){cout<<"Christmas Eve Eve Eve";}
return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#define MAXH 100
#define MAXW 100

int row_checker(char a[MAXH][MAXW + 1], int row, int w);

int column_checker(char a[MAXH][MAXW + 1], int h, int column);

void compresser(char a[MAXH][MAXW + 1], int h, int w);

int main(void){
    int h, w;
    scanf("%d %d", &h, &w);

    char a[MAXH][MAXW + 1];
    for(int i = 0; i < h; i++){
        scanf("%s", a[i]);
    }
    
    compresser(a, h, w);
    int kaigyo;
    for(int i = 0; i < h; i++){
        kaigyo = 0;
        for(int j = 0; j < w; j++){
            if(a[i][j] == 'c') continue;

            printf("%c", a[i][j]);
            if(kaigyo == 0) kaigyo = 1;
        }
        if(kaigyo == 1) printf("\n");
    }
    return 0;
}

int row_checker(char a[MAXH][MAXW + 1], int row, int w){
    int num_white = 0;
    for(int i = 0; i < w; i++){
        if(a[row][i] == '#') return 0;

        if(a[row][i] == '.') num_white++;
    }

    return (num_white > 0)? 1 : 0;
}

int column_checker(char a[MAXH][MAXW + 1], int h, int column){
    int num_white = 0;
    for(int i = 0; i < h; i++){
        if(a[i][column] == '#') return 0;

        if(a[i][column] == '.') num_white++;
    }

    return (num_white > 0)? 1 : 0;
}

void compresser(char a[MAXH][MAXW + 1], int h, int w){
    int white_line = -1;

    for(int i = 0; i < h; i++){
        if(row_checker(a, i, w)){
            white_line = i;
            //printf("i = %d, white_line = %d\n", i, white_line);
            for(int j = 0; j < w; j++){
                a[i][j] = 'c';
            }
            break;
        }
    }

    for(int i = 0; i < w; i++){
        if(column_checker(a, h, i)){
            white_line = i;
            //printf("i = %d, white_line = %d\n", i, white_line);
            for(int j = 0; j < h; j++){
                a[j][i] = 'c';
            }
            break;
        }
    }

    if(white_line > -1) compresser(a, h, w);
    return;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D, T, S;
    cin >> D >> T >> S;
    yesno(D <= T * S);
}


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

int main()
{

   

    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if ((x+y+z)>=22)
    {
        printf("bust");
    }
    else
    {
        printf("win");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a,long long n,long long p = 998244353){
    long long result = 1;
    while(n > 0){
        if(n & 1) (result *= a) %= p;
        (a*=a) %= p;
        n >>= 1;
    }
    return result;
}
class Combination{
	private:
		const static long long MOD = 998244353;
		const static long long MAX = 210000;
		vector<long long> fact;
		vector<long long> finv;
		vector<long long> inv;
	public:
		Combination() : fact(MAX),finv(MAX),inv(MAX){ //n,k <=10^7くらいまで
			fact[0] = fact[1] = 1;
			finv[0] = finv[1] = 1;
			inv[1] = 1;
			for(int i=2;i<MAX;i++){
				fact[i] = fact[i-1] * i % MOD;
				inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
				finv[i] = finv[i-1] * inv[i] % MOD;
			}
		}

		long long nCk(long long n,long long k){
			if(n<k) return 0;
			if(n<0 || k<0) return 0;
			return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
		}

		vector<long long> com; //n固定で n<=10^9, k <= 10^7
		void nCbigk(long long n){
			com.push_back(1);
            com.push_back(n);
            for(long long i=2;i<200010;i++){
                com.push_back((com[i-1] * (n-(i-1)) % MOD) * inv[i] % MOD);
            }
		}
};

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll mod = 998244353;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,k; cin >> n >> m >> k;
    ll ans = 0;
    Combination C;
    rep(i,0,k+1){
        ll tmp = ((C.nCk(n-1,i) * m)%mod) * modpow(m-1,n-i-1);
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

struct Res {
    ll remove_sport, max_count;
};

Res f(vector<vector<int>> &sports, set<int> &close, int n, int m) {

    map<int, int> ma;
    rep(i, n) {
        vector<P> candidate;
        rep(j, m) if (close.find(j) == close.end()) candidate.push_back(P(sports[i][j], j));
        P p = *min_element(candidate.begin(), candidate.end());
        ma[p.second]++;
    }

    int ma_c = 0;
    for (auto &e : ma) cmax(ma_c, e.second);
    for (auto &e : ma) if (e.second == ma_c) return Res{e.first, e.second};
    __throw_runtime_error("");
}

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

    if(n == 1) {
        cout << 1 << endl;
        ret();
    }

    vector<vector<int>> spots(n, vector<int>(m));
    rep(i, n) rep(j, m) {
            int s;
            cin >> s;
            s--;
            spots[i][s] = j;
        }

    set<int> close;
    ll ans = INF;
    rep(i, m - 1) {
        Res r = f(spots, close, n, m);
        cmin(ans, r.max_count);
        close.insert(r.remove_sport);
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

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 repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
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<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;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	ll n;
	cin >> n;
	ll ans = (n / 11) * 2;
	if (n % 11 == 0) {
		
	}
	else if (n % 11 >= 7) {
		ans += 2;
	}
	else {
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	vector<int> ans(h+1,0);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	for (int i=1;i<=h;i++) {
		int magic = 1e9;
		rep(j, n) {
			magic = min(magic, b[j] + ans[max(0, i - a[j])]);
		}
		ans[i] = magic;
		//cout << i << " " << ans[i] << endl;
	}
	cout << ans[h] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;
double da,db,dc;

int main(){
    cin>>n;
    dc=0;
    for(int i=0;i<n;i++){
        cin>>da>>s;
        if(s=="JPY")dc+=da;
        else dc+=380000*da;
    }
    C dc E;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,w,k;cin>>h>>w>>k;int ans=0;
	int black;
	char c[h][w];
	for(int i=0;i<h;i++)
			{
				for(int j=0;j<w;j++)
				{
					cin>>c[i][j];
				}
			}

	for(int maska=0;maska<((1<<h)-1);maska++)
	{
		for(int maskb=0;maskb<((1<<w)-1);maskb++)
		{
			black=0;
			for(int i=0;i<h;i++)
			{
				for(int j=0;j<w;j++)
				{
					if((((maska>>i)&1)==0)&&(((maskb>>j)&1)==0)&&c[i][j]=='#')
					{
						black++;
					}
				}
			}
			if(black==k){
				ans++;
			}
			
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;

signed main()
{
    cin >> N;
    int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << x[N - 1] << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,b;
  cin>>a>>b;
  if(a>=13) COUT(b);
  else if(a>=6) COUT(b/2);
  else COUT(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = (a * (min(n, b-1)))/b;
    cout << ans << endl;
}

Measured memory_bytes: 3636
lit=[]
while True:
    try:
        lit.append(input())
    except EOFError:
        break
A=0
B=0
O=0
AB=0
for i in lit:
    i=i.split(',')
    if i[1]=='AB':
        AB+=1
    elif i[1]=='B':
        B+=1
    elif i[1]=='O':
        O+=1
    else:
        A+=1
print(A,B,AB,O,sep='\n')



Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	int tC = 0, cnt = 0;
	for(int i=1; i<=n; i+=2)
	{
		cnt = 0;
		for(int j=1; j<=i; j++)
		{
			if((i%j)==0)
				cnt++;
		}
		if(cnt==8)
			tC++;
	}
	cout<<tC<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3560
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
    int a[5];
    for (int i = 0; i < 5; i++) cin >> a[i];
    sort(a, a+5);
    cout << a[4];
    for (int i = 3; i >= 0; i--) {
        cout << " " << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
using namespace std;
int main() {
  int a[4];
  while(cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int hit = 0, blow = 0;
    for(int i = 0; i < 4; i++) {
      int b;
      cin >> b;
      if(b == a[i]) {
	hit++;
      } else {
	for(int j = 0; j < 4; j++) {
	  if(b == a[j]) {
	    blow++;
	    break;
	  }
	}
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 0
from collections import deque

N = int(input())
M = N - 1
graph = [[] for _ in range(N + 1)]
dis_f = []
dis_s = []
#フェネックの距離
for i in range(M):
    a,b = map(int,input().rstrip().split(" "))
    graph[a].append(b)
    graph[b].append(a)

dist_f = [-1] * (N + 1)
dist_f[0] = 0
dist_f[1] = 0
d = deque()
d.append(1)
left = N -1
while(d):
    v = d.popleft()
    for i in graph[v]:
        if dist_f[i] != -1:
            continue
        dist_f[i] = dist_f[v] + 1
        d.append(i)
    
#すぬけくんの距離

dist = [-1] * (N + 1)
dist[0] = 0
dist[N] = 0
d = deque()
d.append(N)
while(d):
    v = d.popleft()
    for i in graph[v]:
        if dist[i] != -1:
            continue
        dist[i] = dist[v] + 1
        d.append(i)

count_f = 0
count_s = 0
for i in range(N):
    if(dist_f[i + 1] <= dist[i + 1]):
        count_f += 1
    else:
        count_s += 1
if(count_f > count_s):
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 89328