akhauriyash/Code-Regression huggingface dataset:
// sky kaafi neeche aa gaya hai, sab choo rahe hain
// let's raise the bar now :P
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll ans = LLONG_MAX;
    for(int i = 0; i < k; i++)
        cin >> a[i];
    for(int i = 0; i < k - 1; i++){
        ans = min(ans, n - (a[i + 1] - a[i]));
    }
    ans = min(ans, n - (a[0] + n - a[k - 1]));
    cout << ans;
return 0;
}


Measured memory_bytes: 1792
h,w,ka=map(int,input().split())
mat=[list(input()) for i in range(h)]
ans=0
for i  in range(2**(h+w)):
    b=bin(i)[2:].zfill(h+w)
    rs=b[:h]
    cs=b[h:]
    ct=0
    for l in range(h):
        for k in range(w):
            if mat[l][k]=='#' and rs[l]=='0' and cs[k]=='0':
                ct+=1
    if ct==ka: ans+=1
print(ans)


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(a+b==c||b+c==a||c+a==b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
int main()
{
    priority_queue <int> q;
    priority_queue < int,vector<int>,greater<int> >Q;
    int n,t;
    long long s=0;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&t);
        if(t==1)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            s+=b;
            q.push(a),Q.push(a);
            int x=q.top(),y=Q.top();
            if(x>y)
            {
                q.pop(),Q.pop();
                s=s+x-y;
                q.push(y),Q.push(x);
            }
        }
        else  printf("%d %lld\n",q.top(),s);
    }
    return 0;
}


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

int main() {
  int N, A;
  cin >> N >> A;

  if (A == 0) {
    if (N%5 == 0){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else if ( A >= N) {
      cout << "Yes" << endl;
  }
  else if ( N%500 <= A) {
      cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    int sum=0;
    for(int i=0; i<n; i++){
        cin>>x.at(i);
        sum+=x.at(i);
    }
    double av= (double)sum/n;
    //cout<<fixed<<setprecision(5);
    //cout<<av<<endl;
    int p;
    int ans;
    if((av-sum/n)>=0.5) p=sum/n+1;
    else p=sum/n;
    //cout<<fixed<<setprecision(5);
    //cout<<p<<endl;
    for(int i=0; i<n; i++){
        ans+=pow((p-x.at(i)),2);
    //    cout<<fixed<<setprecision(5);
    //    cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int numOfMultiple(int l, int r, int d){
	if (d>r) return 0;
	if ((r-l)/d == 0){
		return 1;
	}

	return (int) (r-l+1)/d;
}


int main(){
	int L, R, D;
	cin >> L >> R >> D;
	cout << numOfMultiple(L, R, D);
	return 0;
}

Measured memory_bytes: 3592
from heapq import heapify, heappush, heappop, heapreplace
import sys
input = sys.stdin.readline
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
D = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
heapify(D)
F = set()
for _ in range(K):
    p = heappop(D)
    d, x, y, z = p
    print(-d)
    if x < X - 1:
        p = (-(A[x + 1] + B[y] + C[z]), x + 1, y, z)
        if p not in F:
            heappush(D, p)
            F.add(p)
    if y < Y - 1:
        p = (-(A[x] + B[y + 1] + C[z]), x, y + 1, z)
        if p not in F:
            heappush(D, p)
            F.add(p)
    if z < Z - 1:
        p = (-(A[x] + B[y] + C[z + 1]), x, y, z + 1)
        if p not in F:
            heappush(D, p)
            F.add(p)

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int deg[100005], dp[100005];
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        deg[b]++;
    } 
    queue<int> q;
    for(int i=1;i<=n;i++){
        if(deg[i] == 0) q.push(i);
    }
    int ans = 0;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        ans = max(ans, dp[u]);
        for(int i=0;i<g[u].size();i++){
            int v = g[u][i];
            deg[v]--;
            dp[v] = max(dp[v], dp[u]+1);
            if(deg[v] == 0){
                q.push(v);
            }
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
int dp[100001][3];
vector<tuple<int, int, int> > vec;
int N;

void input() {
    cin >> N;
    vec.resize(N);
    for(int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        vec.at(i) = make_tuple(a, b, c);
    }
}
int solve() {
    dp[0][0] = get<0>(vec.at(0));
    dp[0][1] = get<1>(vec.at(0));
    dp[0][2] = get<2>(vec.at(0));
    for(int i = 1; i < N; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + get<0>(vec.at(i));
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + get<1>(vec.at(i));
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + get<2>(vec.at(i));
    }
    return max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
}
int main() {
    input();
    cout << solve() << endl;
}

Measured memory_bytes: 2560
n = int(input())
x = []
y = []
h = []
ans = [0,0,0]
for i in range(n):
	xyh = list(map(int, input().split()))
	x.append(xyh[0])
	y.append(xyh[1])
	h.append(xyh[2])

for i in range(101):
	for j in range(101):
		for k in range(n):
			if h[k] != 0:
				height = abs(i-x[k]) + abs(j-y[k]) + h[k]
				break
			
		flag = 0
		for k in range(n):
			if h[k] != max(height- abs(i-x[k]) - abs(j-y[k]) , 0):
				flag = 1
				break
			
		if flag == 0:
			ans = [i,j,height]
			break
		
	
print('{0} {1} {2}'.format(ans[0], ans[1], ans[2]))

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

using namespace std;

int N, M, times[100009];
long long ans, tot, mars[100009];

void add (int st, int dr, int val) {mars[st] += val, mars[dr + 1] -= val; times[st] ++, times[dr + 1] --;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

int curr;
scanf ("%d %d %d", &N, &M, &curr), tot = 0;
for (int i=2; i<=N; i++)
{
    int nxt;
    scanf ("%d", &nxt);
    if (curr < nxt) tot += nxt - curr, add (curr + 1, nxt, curr + 1);
    else tot += M - curr, add (curr + 1, M, curr + 1), tot += nxt, add (1, nxt, curr - M + 1);
    curr = nxt;
}
for (int i=1; i<=M; i++)
    mars[i] += mars[i - 1], times[i] += times[i - 1];
/*printf ("%lld\n", tot);
for (int i=1; i<=M; i++)
    printf ("%lld %d   -> efic = %lld \n", mars[i], times[i], 1LL * i * times[i] - mars[i]);*/
for (int i=1; i<=M; i++)
{
    long long curr = tot - (1LL * i * times[i] - mars[i]);
//    printf ("%lld\n", curr);
    if (i == 1 || curr < ans)
        ans = curr;
}
printf ("%lld\n", ans);
return 0;
}


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

int main(){
    
    long double w,h,x,y;
    cin >> w >> h >> x >> y;
    
    if(x==(w/2)&&y==(h/2)){
        cout << fixed << setprecision(6) << (w/2.0) * h << " "<< 1<< endl;
    }else{
        cout << fixed << setprecision(6) << (w/2.0) * h << " "<< 0<< endl;
    }

}

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

using namespace std;

int main() {
	int a, b;
	while (scanf("%d%d", &a, &b) != EOF) {
		a += b, b = 0;
		while (a) ++b, a /= 10;
		printf ("%d\n", b); 
	}
	return 0;
}

Measured memory_bytes: 0
A,B,C=map(int,input().split())
ans=0
while A%2==0 and B%2==0 and C%2==0:
    if A == B == C:
        print(-1)
        exit()
    A1=A
    B1=B
    C1=C
    A = B1/2+C1/2
    B = A1/2+C1/2
    C = A1/2+B1/2
    ans +=1
print(ans)

Measured memory_bytes: 3064
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
const int MOD = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
ostream& operator<< (ostream& os, const mint& value) {
  os << value.x;
  return os;
}

#pragma endregion library

int main(){
    int n, k; cin >> n >> k;
    vector<pi> range;
    rep(i,k){
        int l, r; cin >> l >> r;
        r++;
        range.emplace_back(l,r);
    }
    vector<mint> dp(n);
    dp[0] = 1;
    mint now = 0;
    rep(i,n){
        now += dp[i];
        rep(j, k){
            int l, r;
            tie(l, r) = range[j];
            if(i+l<n) dp[i+l] += now;
            if(i+r<n) dp[i+r] -= now;
        }
    }
    cout << dp[n-1] << '\n';
    
}


Measured memory_bytes: 4776
s= list(input())
t= list(input())
ss=sorted(s)
tt=sorted(t,reverse=True)
sss=''.join(ss)
ttt=''.join(tt)
ans = []
ans.append(sss)
ans.append(ttt)
ans1=sorted(ans,key=str.lower)
if ans1[0]==ans[1]:
    print('No')
elif ans1[0]==sss:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, n, k, x;
    string s, t;
    ll ans;
    double dans;
    string sans;


    cin  >> a >> b >> c;

    ans = max(c - (a - b), (ll) 0);

    std::cout << ans << endl; 
    // std::cout << sans << endl; 
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

int c(const void *a, const void *b){
  if(*(long long int*)a - *(long long int*)b > 0) return 1;
  else if(*(long long int*)a - *(long long int*)b < 0) return -1;
  else return 0;
}

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  long long int a[N];

  int i;

  long A, B;

  for(i = 0; i < N; i++){
    scanf("%ld %ld", &A, &B);
    a[i] = A * 1000000 + B;
  }

  qsort(a, N, sizeof(long long int), c);

  i = 0;
  long sum = 0;
  long long int sum_m = 0;

  int j;

  while(sum < M){
    for(j = 0; j < a[i] % 1000000; j++){
      sum++;
      sum_m += a[i] / 1000000;
      if(sum == M) break;
    }

    i++;
  }

  printf("%lld\n", sum_m);

  return 0;
}


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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int cntb = 0, cntw = 0;
	int ans = INT_MAX;
	for (int i = 0; i < N; i++) {
		cntw += (S[i] == '.' ? 1 : 0);
	}
	for (int i = 0; i <= N; i++) {
		ans = min(ans, cntb + cntw);
		cntw -= (S[i] == '.' ? 1 : 0);
		cntb += (S[i] == '#' ? 1 : 0);
	}
	cout << ans << endl;
	return 0;
}


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

signed main() {
  int K; cin >> K;
  queue<int> q;
  for(int i=1; i<=9; i++) q.push(i);
  for(int k=1; k<K; k++) {
    int l = q.front(); q.pop();
    int d = l % 10;
    if(d-1>=0) q.push(l*10 + (d-1));
    q.push(l*10 + (d));
    if(d+1<=9) q.push(l*10 + (d+1));
  }
  cout << q.front() << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int l;	cin>>l;
	int n;	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		int x,w;	cin>>x>>w;
		sum+=x*w;
	}
	if(sum==0){
		cout<<0<<endl;
	}
	else{
		cout<<1<<endl;
		cout<<(sum>0?-1:1)<<" "<<abs(sum)<<endl;
	}
	return 0;
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    if(a<b){
        for(int i=0;i<b;i++) cout << a;
    }else{
        for(int i=0;i<a;i++) cout << b;
    }
    printf("\n");
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int B = -1;
    bool b = true;
    for (int j=0; j<N; j++) {
        if (B != A[j]) {
            B = A[j];
        }
        else {
            cout << "NO" << endl;
            b = false;
            break;
        }
    }
    if (b) {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long int ll;
const int MOD=1e9+7;
const int N=2e3+10;
ll fac[N];
ll pow(ll a,ll t){
    if(t==0)return 1;
    ll temp=pow(a,t/2);
    temp*=temp;
    temp%=MOD;
    if(t&1){
        temp*=a;
        temp%=MOD;
    }
    return temp;
}
ll rev(ll n){return pow(n,MOD-2);}
ll C(int n,int k){return (fac[n]*((rev(fac[k])*rev(fac[n-k]))%MOD))%MOD;}
ll H(int n,int k){return C(n+k-1,k);}
void init(){
    fac[0]=fac[1]=1;
    for(int i=2;i<N;i++)fac[i]=(fac[i-1]*i)%MOD;
    return ;
}
int main(){
    int n,k,now=1;
    ll ans=0;
    scanf("%d%d",&n,&k);
    if(k>n){
        printf("0\n");
        return 0;
    }
    init();
    printf("%lld\n",H(k,n-k));
    
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int h, w, d;
  cin >> h >> w >> d;
 
  vector<vector<int>> a(h, vector<int>(w));
  vector<P> ver(h*w); 
 
  rep(i,h) rep(j,w) {
    cin >> a[i][j];
    a[i][j]--;
    ver[a[i][j]] = make_pair(i, j);
  }
  vector<ll> cum(h*w+1, 0);
 
  for (int i = 0; i + d < h * w; i++) {
    int x = ver[i].first, y = ver[i].second;
    int nx = ver[i + d].first, ny = ver[i + d].second;
    int cost = abs(x - nx) + abs(y - ny);
    cum[i + d] = cum[i] + cost;
  }
  
  int q;
  cin >> q;
 
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << cum[r - 1] - cum[l - 1] << endl;
  }
  return 0;
} 

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    string S; cin >> S;
    string ans = "None";
    bool flag=true;
    for(int i=0;i<26;i++){
        if(flag){
            char a = char('a'+i);
            for(int j=0;j<S.size();j++){
                if(a == S[j]) break;
                if(j==S.size()-1) {ans=a; flag = false;}
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	long long ans = 999999999;
	for (long long i = A.at(0); i <= A.at(N - 1); i++) {
		long long sum = 0;
		for (long long j = 0; j < N; j++) {
			sum += pow((A.at(j) - i), 2);
		}
		if (ans > sum) ans = sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((100 * r + 10 * g + b) % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
const int MOD=998244353;
const int INF=1e18;
void io(string s="file"){freopen((s + ".in").c_str(), "r", stdin);freopen((s + ".out").c_str(), "w", stdout);}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    vi v(n);for(int &i:v)cin>>i;
    
    set<int> st(all(v));
    if(st.size()==1){
        cout<<n/2;
        return 0;
    }
    
    map<int,int> l,r;
    for(int i=0;i<n;i+=2)l[v[i]]++;
    for(int i=1;i<n;i+=2)r[v[i]]++;
    
    vii a,b;
    for(pii p:l){
        a.push_back({p.second,p.first});
    }
    for(pii p:r){
        b.push_back({p.second,p.first});
    }
    sort(all(a));reverse(all(a));
    sort(all(b));reverse(all(b));
    
    int ans=INF;
    for(int i=0;i<b.size();i++){
        if(a[0].second!=b[i].second){
            ans=min(ans,n-a[0].first-b[i].first);
        }
    }
    for(int i=0;i<a.size();i++){
        if(a[i].second!=b[0].second){
            ans=min(ans,n-a[i].first-b[0].first);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 17268
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    int ans = 0;
    while (true){
        bool isOK = true;
        rep(i,N){
            if (A[i] % 2 == 1){
                isOK = false;
                break;
            }
            else{
                A[i] /= 2;
            }
        }
        if (!isOK) break;
        ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define INF 1000000000000000
#define MAX_V 200
#define MAX_E 10000
#define ll long long
typedef struct LIST{
	int to;
	ll cap;
	struct LIST *rev; //逆辺のポインタ
	struct LIST *next;
}Edge;
Edge *iter[MAX_V];
Edge edge[MAX_E],rev[MAX_E];
int level[MAX_V];
int que[MAX_V];
int e_size=0;
void add_edge(Edge **g,int s,int t,ll c){
	edge[e_size].next=g[s]; g[s]=&edge[e_size];
	rev[e_size].next=g[t]; g[t]=&rev[e_size++];
	g[s]->to=t,g[s]->cap=c;
	g[t]->to=s,g[t]->cap=0;
	g[s]->rev=g[t]; g[t]->rev=g[s];
	return;
}
void bfs(Edge **g,int s){
	int front=0,rear=0,v;
	Edge *e;
	memset(level,-1,sizeof(level));
	level[s]=0;
	que[rear++]=s;
	while(front!=rear){
		v=que[front++];
		for(e=g[v];e!=NULL;e=e->next){
			if(e->cap>0&&level[e->to]<0){
				level[e->to]=level[v]+1;
				que[rear++]=e->to;
			}
		}
	}
	return;
}
ll dfs(int v,int t,ll f){
	ll d; Edge *e;
	if(v==t) return f;
	for(;iter[v]!=NULL;iter[v]=iter[v]->next){
		e=iter[v];
		if(e->cap>0&&level[v]<level[e->to]){
			d=dfs(e->to,t,MIN(f,e->cap));
			if(d>0){
				e->cap-=d;
				e->rev->cap+=d;
				return d;
			}
		}
	}
	return 0;
}
ll max_flow(Edge *g[],int s,int t){
	ll flow=0,f;
	while(1){
		bfs(g,s);
		if(level[t]<0) return flow;
		memcpy(iter,g,sizeof(iter));
		while((f=dfs(s,t,INF))>0) flow+=f;
	}
}
Edge *g[MAX_V];
int a[101];
int main(void)
{
	int n,s,t,i,j;
	ll res=0;
	scanf("%d",&n);
	s=0,t=n+1;
	FOR(i,1,n+1){
	    scanf("%d",a+i);
	    if(a[i]>0){
	        add_edge(g,i,t,a[i]);
	        res+=a[i];
	    }else{
	        add_edge(g,s,i,-a[i]);
	    }
	    for(j=2*i;j<=n;j+=i) add_edge(g,i,j,INF);
	}
	printf("%lld\n",res-max_flow(g,s,t));
	return 0;
}


Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        ans += (a >= k);
    }
    cout << ans << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


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

using namespace std;

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




int main(void){
	int w,h;
	char map[100][100];
	while(cin >> h >> w,w|h){
		rep(j,h)
			rep(i,w)
				cin >> map[i][j];
		int x=0,y=0;
		while(true){
			if(map[x][y]=='@'){
				cout << "LOOP" << endl;
				break;
			}
			if(map[x][y]=='>'){
				x++;
				map[x-1][y]='@';
			}else if(map[x][y]=='<'){
				x--;
				map[x+1][y]='@';
			}else if(map[x][y]=='v'){
				y++;
				map[x][y-1]='@';
			}else if(map[x][y]=='^'){
				y--;
				map[x][y+1]='@';
			}else{
				cout << x << " " << y << endl;
				break;
			}
		}
	}
	return 0;
}	

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
int main(){
    int n;
    cin >> n;
    int target = 1;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(a == target) target++;
    }
    if(target == 1) {cout <<- 1; return 0;}
    cout << n - target + 1;
}

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

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    int n, s;
    cin >> n >> s;
    deque<ll> x(n), p(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> p[i];
    }
    ll res = 0;
    while ((x.front() < s) == (s < x.back())) {
        res += x.back() - x.front();
        if (p.front() >= p.back()) {
            while ((x.front() < s) == (s < x.back()) && p.front() >= p.back()) {
                p.front() += p.back();
                p.pop_back();
                x.pop_back();
            }
        } else {
            while ((x.front() < s) == (s < x.back()) && p.front() < p.back()) {
                p.back() += p.front();
                p.pop_front();
                x.pop_front();
            }
        }
    }
    res += max(abs(s - x.front()), abs(s - x.back()));
    cout << res << "\n";
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

  int q,a,b;
  char s[1001],p[1002],c[8],print_buf[1001];

  scanf("%s\n",s);
  scanf("%d\n",&q);

  for(int i=0;i<q;i++){
     scanf("%s %d %d ",c,&a,&b);
     memset(print_buf,0,sizeof(print_buf));
     if(strcmp(c,"print")==0){
      strncpy(print_buf,s+a,b-a+1);
      puts(print_buf);
     }
     if(strcmp(c,"replace")==0){
       scanf("%s\n",p);
       strncpy(s+a,p,b-a+1);
     }
     if(strcmp(c,"reverse")==0){
       for(int r=0;r<(b-a+1)/2;r++){
          char swap = s[b-r];
          s[b-r] = s[a+r];
          s[a+r] = swap;
       }
     }
  }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<pair<ll, ll>> work(N);
	for (ll i = 0; i < N; ++i)
	{
		ll a, b; cin >> a >> b;
		work[i] = pair<ll, ll>(a, b);
	}

	sort(work.begin(), work.end(), [](auto &a, auto &b)
								   {
									   return a.second > b.second;
								   });

	ll t{work[0].second};

	for (ll i = 0; i < N; ++i)
	{
		t = min(t, work[i].second);
		t -= work[i].first;
	}

	if (t >= 0)
		std::cout << "Yes"<< std::endl;
	else
		std::cout << "No"<< std::endl;
}


Measured memory_bytes: 3328
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
long long divisable[10000] = {};
int main(){
	long long n;
	cin >> n;
	for (int i = 1;i <= n;++i) {
		int q = i;
		int j = 2;
		while (sqrt(q) >= j) {
			if (q % j == 0) {
				divisable[j]++;
				q /= j;
			}
			else j++;
		}
		divisable[q]++;
	}
	long long hoge = 1;
	for (int i = 2;i <= 10000;++i) {
		hoge *= (divisable[i] + 1);
		hoge %= MAX_MOD;
	}
	cout << hoge << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, q = I[:3]
l, r = I[3:3+m*2].reshape(-1, 2).T
p, q = I[3+m*2:].reshape(-1, 2).T

def main():
    res = np.zeros((n+2, n+2), dtype=np.int64)
    
    np.add.at(res, (1, r), 1)
    np.add.at(res, (l+1, r), -1)
    np.add.at(res, (1, n+1), -1)
    np.add.at(res, (l+1, n+1), 1)
    res = np.cumsum(res, axis=0)
    res = np.cumsum(res, axis=1)

    ans = res[p, q]
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

int main(){
    int n,a;
    map<ll,ll> cnt;
    scanf("%d",&n);
    ll res = 0;
    for(int i=1;i<=n;i++) {
        scanf("%d",&a);
        ll key = i-a;
        ll key2 = a+i;
        res += cnt[key];
        cnt[key2]++;
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 26360
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int k,min_;
    long long int sum=0, mul=1;
    cin >> k;
    for (int i=1; i<=k; i++){
        for (int j=1; j<=k; j++){
            for (int l=1; l<=k; l++){
                int i1 = i;
                int j1 = j;
                int l1 = l;
                mul = 1;
                
                for (int m=2; m<=max(max(i1,j1),l1);){
                    if( i1 % m == 0 && j1 % m == 0 && l1 % m == 0 ){
                        mul = mul*m;
                        i1 = i1 / m;
                        j1 = j1 / m;
                        l1 = l1 / m;
                    }
                    else m++;
                    if( i1 < m || j1 < m || l1 < m ) break; // この工夫がないとACされない
                }
                sum += mul;
                
            }
        }
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        int a = 111;
        for (int i=2; i<=10; i++){
            if (a >= n){
                System.out.println(a);
                return;
            }else{
                a = 111 * i;
            }
        }

    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

int countDivisors(int n) {
   int cnt = 0;
   for (int i = 1; i * i <= n; i++) {  // O(sqrt(n))
       if (n % i == 0) {
           int j = n / i;
           cnt++;
           if (i != j) cnt++;
       }
   }
   return cnt;
}

int N;
int SOD[10000000+1];
void generateSOD() {
   for(int i = 1; i <= N; i++) {
       for(int j = i; j <= N; j += i) {

           SOD[j] += 1;
       }
   }
}


signed main(){
    unsigned long long s=0;
    cin>>N;

    generateSOD();
    for(int i=1; i<=N; i++) s+= i*SOD[i];
    cout<<s<<endl;

}


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

int main() {
  int H,A;
  cin >> H >> A;
  int ans = (H+A-1)/A;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    scanf("%d%d", &n, &m);// don't forget &
    if (n & 1) {
        for (int i = 1; i <= m; i++) {
            printf("%d %d\n", i, n - i + 1);
        }
    } else {
        for (int i = 1; i <= (m + 1) / 2; i++) {
            printf("%d %d\n", i, n - i + 1);
        }
        for (int i = (m + 1) / 2 + 1; i <= m; i++) {
            printf("%d %d\n", i, n - i);
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

    ll lcm = a * b;

    if(a < b) swap(a, b);

    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    lcm /= b;

    cout << lcm << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())

S = sum(A)
dp = [0] * 100001
for a in A:
    dp[a] += 1


for i in range(q):
    a, b = map(int, input().split())
    dp[b] += dp[a]
    S = S + (b - a) * dp[a]
    print(S)
    dp[a] = 0


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

#define rep(i, N) for (ll i = 0; i < N; i++)

#define INF 1000000000
#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    int H, W;
    cin >> H >> W;
    int sx = 0, sy = 0, gy = H-1, gx = W-1, ans = 0;

    //cin >> sy >> sx;
    //cin >> gy >> gx;
    vector<vi> a(H,vi(W,INF));  //スタート位置からの距離
    vector<string> c(H); //迷路の形状

    rep(i, H){
        cin >> c[i];
        rep(j, W){
            if(c[i][j] == '.') ans++;
        }
    }
        
    queue<P> que;   //探索予定の座標

    a[sy][sx] = 0;  //スタート位置の移動距離距離を0に設定
    que.push(P(sy,sx));
    while(!que.empty()) {
        //現在地の取得
        P cgr = que.front(); que.pop();
        int cx = cgr.second;
        int cy = cgr.first;

         rep(i, 4){
            //チェックする座標の取得
            int chx = cx + dx[i];
            int chy = cy + dy[i];

            //チェックする座標が範囲内
            if(chx >= 0 && chx < W && chy >= 0 && chy < H){
                //チェックする座標が通れる かつ　未探索
                if(c[chy][chx] != '#' && a[chy][chx] == INF) {
                    a[chy][chx] = a[cy][cx] + 1;
                    que.push(P(chy, chx));
                }
            }
        }
    }

    if(a[gy][gx] == INF) {
        cout << "-1" << "\n";
        return 0;
    }
    ans -= a[gy][gx]+1;

    cout << ans << "\n";
    return 0;
    
}


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

int main(){
  int n;cin >> n;
  vector<string> s(n);
  map<string,pair<int,int>> map;
  long long ans = 0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    if(map[s[i]].first == 1){
      map[s[i]].second += 1;
    }else map[s[i]].first = 1;
  }
  for(int i=0;i<n;++i){
    ans += map[s[i]].second;
  }
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n, m, l;
  cin >>n>>m>>l;
  if(n*l <  m) cout <<l fin;
  else cout << m/n fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input: List<String> = readLine()!!.trim().split(" ").map{it.trim()}
    val n = input.get(0).toInt()
    val r = input.get(1).toInt()
    if (n >= 10) {
        print(r)
    } else {
        print(r + 100 * (10 - n))
    }
}


Measured memory_bytes: 36008
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	LL x;
	cin >> x;
	if(0 == x%11){
		cout << x/11 * 2 << endl;
	}
	else if(x%11 <= 6){
		cout << x/11 * 2 + 1 << endl;
	}
	else{
		cout << x/11 * 2 + 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto S = RD!string;
	auto T = RD!string;

	long ans;
	foreach (i; 0..S.length)
	{
		if (S[i] != T[i])
			++ans;
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  c = a * b;
  if (c % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
    
    io
    ll n;
    cin>>n;
    ll res=0;
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        res^=x;
    }
    if(!res)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int k,s;
  cin>>k>>s;
  int tot = 0;
  for(int x=0;x<=s;x++){
  	for(int y=0;y<=s;y++){
  		int z = s-(x+y);
  		if(z<=k&&x<=k&&y<=k&&(x+y+z)==s&&z>=0){
  			tot++;
  		}
  	}
  }
  cout<<tot<<endl;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

char s[maxn+5];

int main()
{
    scanf("%s",s);
    int n=strlen(s);
    int ans=0;
    rep(i,0,n-1) ans=(ans+s[i]-'0')%9;
    puts(ans==0?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


ll cal(ll a) {
    ll ans = 1;
    for (ll i = 1;i<=a;i++) {
        ans *= i;
        ans %= MOD;
    }
    return ans;
}

int main() {
    ll n,m;
    cin >> n >> m;
    if (((n-m) >= 2) || ((n-m) <= -2)) {
        cout << 0 << endl;
    }
    else {
        if (m==n) {
            cout << ((cal(m)%MOD)*(cal(n)%MOD)*2)%MOD << endl;
        }
        else {
            cout << ((cal(m)%MOD)*(cal(n)%MOD))%MOD << endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <time.h>
using namespace std;
clock_t fi, endtime;

const int r_c = 0;
const int r_t = 1;
const int MAX_V = 100;
const int MAX_E = 1000;
const int MAX_D = 1000;
const int MIN_D = 0;

const int INF = MAX_V * MAX_D * 2;

int main()
{
	while (1) {
		int n, m, s, g1, g2;
		int b1, b2, c;
		int ans = 0;
		int wf[MAX_V][MAX_V];
		scanf("%d %d %d %d %d", &n, &m, &s, &g1, &g2);
		if (!n && !m && !s && !g1 && !g2) break;
		--s; --g1; --g2;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				wf[i][j] = INF;
				if (i == j) { wf[i][j] = 0; }
			}
		}
		for (int i = 0; i < m; ++i) {
			scanf("%d %d %d", &b1, &b2, &c);
			--b1; --b2;
			wf[b1][b2] = c;
		}
		for (int k = 0; k < n; ++k) {
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
				}
			}
		}
		ans = wf[s][g1] + wf[s][g2];
		for (int k = 0; k < n; ++k) {
			ans = min(ans, wf[s][k] + wf[k][g1] + wf[k][g2]);
		}
		printf("%d\n", ans);
	}
}

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

int main()
{
    int a,b;

    cin >> a >> b;

    if(a > b)
    {
        cout << "a > b" << endl;
    }
    else if(a < b)
    {
        cout << "a < b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
    

    return 0;
}



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

using namespace std;

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

	bool flag = true;
	int cnt = 0;
	while (flag) {
		flag = false;

		for (int i = n - 1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				swap(a[i], a[i - 1]);
				flag = true;
				cnt++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (i != n - 1) {
			printf("%d ", a[i]);
		}
		else {
			printf("%d\n", a[i]);
		}
	}
	cout << cnt << endl;
	
	return 0;
}


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

long long n, w, i, k, dp[2][100019] = { };
vector<pair<long long, long long>> items;
//w - v
int main() {
	cin >> n >> w;
	memset(dp, 0, sizeof(dp));
	items.resize(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> items[i].first >> items[i].second;

	for(long long it = 1; it <= n; it++) {
		i = it&1;
		for(long long j = 1; j <= w; j++) {
			if(items[it].first > j) {
				dp[i][j] = dp[i^1][j];
				continue;
			}
			dp[i][j] = max(dp[i^1][j], dp[i^1][j - items[it].first] + items[it].second);

		}
	}

	cout << *max_element(begin(dp[n&1]), end(dp[n&1]));

	return 0;
}


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

int main() {
  int n, m, s = 0; cin >> n >> m;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    s += a[i];
  }
  sort(a.rbegin(), a.rend());
  bool f = true;
  rep(i, m)
    if (s > a[i] * 4 * m) f = false;
  puts(f ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256