akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/dp/tasks/dp_f
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(int i=1;i<=n;i++)
#define fok(i,k,n)      for(int i=k;i<=n;i++)
#define rfo(i,n)        for(int i=n;i>=0;i--)
#define rfo1(i,n)       for(int i=n;i>0;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<string,string>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define M               (int)1e6+6
#define inf             1e18
using namespace std;

int n,k,x,y,z,a1,b,c,d,i,j,l,r;
string s,t;





void sol()
{   
    cin>>s>>t;
    int n=s.size();
    int m=t.size();

    // string dp[2][m+1];

    // for(int i=1;i<=n;i++)
    // {   int x=i%2;
    //     for(int j=1;j<=m;j++)
    //     {   
    //         y=(x==0)?1:0;
    //         if(s[i-1]==t[j-1])dp[x][j]=dp[y][j-1]+s[i-1];
    //         else
    //         {
    //             dp[x][j]=(dp[x][j-1].length()>dp[y][j].length())?dp[x][j-1]:dp[y][j];
    //         }
           
    //     }
    // }
    
    // cout<<dp[n%2][m]<<endl;

   //another and memory efficient approach
    vector<vi> dp(3001,vi(3001,0));
    fo1(i,n)
    {
        fo1(j,m)
        {
            if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    int cnt=dp[n][m];
    i=n;
    j=m;
    string ans;
    while(i!=0 && j!=0)
    {
        if(dp[i-1][j]==cnt)i--;
        else if(dp[i][j-1]==cnt)j--;
        else {
            ans.pb(s[i-1]);
            i--;
            j--;
            cnt--;
        }
    }
    reverse(all(ans));
    cout<<ans<<endl;
    
    
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 70784
var
 k,b,a,t:int64;
begin
 readln(k,a,b);
 if a>=k then writeln(1)
  else
   if b>=a then writeln(-1)
    else
     begin//你是猪还是狗
      t:=(k-a) div (a-b);//你是猪？矣~~~
      if (k-a) mod (a-b)<>0 then inc(t);//你是狗？乖，狗狗
      t:=t*2+1;//随便？啧啧啧，垃圾
      writeln(t);//都不是？猪狗不如的人渣
     end;
end.//你傻得我无言以对

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

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

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B, C;

  cin >> A >> B >> C;

  if (A == B && A != C ||
      B == C && B != A ||
      C == A && C != B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
using namespace std;
#define Would
#define you

int ans, n;
int main() {
	for (int i = 0; i < 10; ++i) {
		cin >> n;
		ans += n;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
typedef long long i64;
const int P=924844033,M=2e5+7;
int pw(int a,int n){
	if(n<0)n+=P-1;
	int v=1;
	for(;n;n>>=1,a=i64(a)*a%P)if(n&1)v=i64(v)*a%P;
	return v;
}
int A[533333],B[533333],r[533333],E[533333];
int n,ep=2,fac[M],fiv[M],e0[M],sz[M],t[M],N,K;
struct edge{
	int to,nx;
}e[M*2];
void f1(int w,int pa){
	sz[w]=1;
	for(int i=e0[w];i;i=e[i].nx){
		int u=e[i].to;
		if(u!=pa)f1(u,w),sz[w]+=sz[u];
	}
	++t[sz[w]];
	++t[n-sz[w]];
}
int fix(int x){return x+(x>>31&P);}
void ntt(int*a,int t){
	for(int i=1;i<N;++i)if(i<r[i])std::swap(a[i],a[r[i]]);
	for(int i=1;i<N;i<<=1){
		for(int j=0;j<N;j+=i<<1){
			i64 z=pw(5,(P-1)/(i<<1)*t);
			E[0]=1;
			for(int k=1;k<i;++k)E[k]=E[k-1]*z%P;
			int*b=a+j,*c=b+i;
			for(int k=0;k<i;++k){
				int x=b[k],y=c[k]*i64(E[k])%P;
				b[k]=fix(x+y-P);
				c[k]=fix(x-y);
			}
		}
	}
	if(t==-1){
		i64 I=pw(N,-1);
		for(int i=0;i<N;++i)a[i]=a[i]*I%P;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=fac[0]=1;i<=n;++i)fac[i]=i64(i)*fac[i-1]%P;
	fiv[n]=pw(fac[n],-1);
	for(int i=n;i;--i)fiv[i-1]=i64(i)*fiv[i]%P;
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		e[ep]=(edge){b,e0[a]};e0[a]=ep++;
		e[ep]=(edge){a,e0[b]};e0[b]=ep++;
	}
	f1(1,0);
	for(N=2,K=0;N<n*2+5;N<<=1,++K);
	for(int i=1;i<N;++i)r[i]=r[i>>1]>>1|(i&1)<<K;
	for(int i=1;i<n;++i)A[n-i]=i64(t[i])*fac[i]%P;
	for(int i=0;i<=n;++i)B[i]=fiv[i];
	ntt(A,1),ntt(B,1);
	for(int i=0;i<N;++i)A[i]=i64(A[i])*B[i]%P;
	ntt(A,-1);
	for(int i=1;i<=n;++i){
		int v=(i64(n)*fac[n]%P*fiv[n-i]%P-A[n-i])*fiv[i]%P;
		printf("%d\n",(v+P)%P);
	}
	return 0;
}

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

int sum( int num ){

  int count = 0;
  for( int a = 0; a < 10; a++ ){
    for( int b = 0; b < 10; b++ ){
      for( int c = 0; c < 10; c++ ){
	for( int d = 0; d < 10; d++ ){
	  if( a+b+c+d == num ){
	    count++;
	  }
	}
      }
    }
  }

  return count;

}

int main(){

  int num;

  while( cin >> num ){
    cout << sum(num) << endl;
  } 

  return 0;
}

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

int main() {
	int w,h,r,x,y;
	cin>>w>>h>>x>>y>>r;
if(x>=r && x<=w-r && y>=r && y<=h-r){cout<<"Yes\n";return 0;}
else cout<<"No\n";

	
	// your code goes here
	return 0;
}

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

int main() {
    long long N,K,AMARI;
    cin >> N >> K;

    long long A = N % K;
    long long B = K - N % K;

    if(A < B){
        cout << A << endl;
    }else{
        cout << B << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
c = 0
for x,y,h in xyh:
    if h==0:
        c += 1
    else:ans = [x,y,h]
if c==n-1:
    print(*ans)
    exit()

for i in range(101):
    for j in range(101):
        a = -1
        ok = True
        for x,y,h in xyh:
            if h>0:
                if a==-1:
                    a = h+abs(x-i)+abs(y-j)
                elif h+abs(x-i)+abs(y-j)!=a:
                    ok = False
        if ok:
            print(i,j,a)
            exit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
//constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

ll modpow(ll x,ll n,int mod){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

int main(){
    int n,p;
    string s;
    cin>>n>>p>>s;
    if(p==2||p==5){
        ll ans=0;
        rep(i,n){
            int d=s[i]-'0';
            if(d%p==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    int r[n];
    rep(i,n){
        r[i]=modpow(10%p,i,p);
    }
    int inv[n];
    rep(i,n){
        inv[i]=modpow(r[i],p-2,p);
    }
    ll cnt[p]={};
    int t=0;
    ll ans=0;
    rep(i,n){
        t=(10*t+(s[i]-'0'))%p;
        if(t==0)++ans;
        int x=(t*inv[i])%p;
        ans+=cnt[x];
        int u=(t*inv[i])%p;
        ++cnt[u];
        //cout<<t<<" "<<x<<" "<<u<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B ;
    cin >> A >> B ;
    ll rest = A-B;
    
    ll C;
    cin >> C;
    
    cout << max(C-rest, 0LL) << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int N,M,H,W;
ll A,B,a,b;
string T;
ll C[10005][205][3];
typedef pair<ll,ll> P;
typedef pair<P,P> O;
int main(){
	cin>>N>>A>>B;
	cout<<min(N*A,B)<<endl;

	return 0;
}


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

int main( void )
{
	while (1)
	{
		int n;
		cin >> n;
		if ( n == 0 )
			break;

		vector < vector <int> > T( n+1, vector<int>(n+1, 0) );
		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < n; j++ )
			{
				cin >> T[i][j];
			}
		}

		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < n; j++ )
			{
				T[i][n] += T[i][j];
				T[n][j] += T[i][j];
			}
		}

		for ( int i = 0; i < n; i++ )
		{
			T[n][n] += T[n][i];
		}

		for ( int i = 0; i <= n; i++ )
		{
			for ( int j = 0; j <= n; j++ )
			{
				cout << setw(5) << T[i][j];
			}
			cout << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 0
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
n = [[-1, 0], [1, 0], [0, 1], [0, -1]]
for h in range(H):
    for w in range(W):
        flag = False
        if S[h][w] == '.':
            continue
        for nn in n:
            if h + nn[0] < 0 or h + nn[0] > H-1 or w + nn[1] < 0 or w + nn[1] > W-1:
                continue
            if S[h + nn[0]][w + nn[1]] == '#':
                flag = True
        if flag:
            continue
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d,f;
  char a[10]={},b[10]={},c[10]={};
  cin>>a>>b>>c;
  for(int i=0;i<10;i++){
    if(a[i]==0){
      d=i-1;
      break;
    }
    if(i==10)
      d=9;
  }
   for(int i=0;i<10;i++){
      if(b[i]==0){
        f=i-1;
         break;
    }
     if(i==10)
       f=9;
   }
   if(a[d]==b[0] && b[f]==c[0])
     cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
      
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>

using namespace std;

vector<int> make(int a, int b, int F) {
  set<int> s;
  for (int i = 0; i <= F / a; i++) {
    for (int j = 0; j <= F / b; j++) {
      int x = a * i + b * j;
      if (x > F) continue;
      if (s.find(x) == s.end()) {
        s.insert(x);
      }
    }
  }

  vector<int> v(s.begin(), s.end());
  return v;
}

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  const vector<int> ax = make(100 * A, 100 * B, F);
  const vector<int> ay = make(C, D, F);

  int max_total = 0;
  int max_y = 0;
  for (auto&& x : ax) {
    for (auto&& y : ay) {
      if (x + y == 0 || x + y > F) continue;
      if (100 * y > E * x) continue;
      int total = x + y;
      if (max_total == 0) {
        max_total = total;
        max_y = y;
        continue;
      }
      if (100 * max_y * total < 100 * y * max_total) {
        max_total = total;
        max_y = y;
      }
    }
  }
  cout << max_total << " " << max_y << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int a, b;
	cin >> a >> b;

	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	} else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
//lunchtime june Increasing and Decreasing
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}
void solve()
{ll n;
 in n;
  string s[n];
  ll cntac=0;
  ll wa=0;
  ll tle=0;
  ll re =0;
  for(ll i=0;i<n;i++){
    in s[i];
    if(s[i]=="AC")
        cntac+=1;
    else if(s[i]=="WA")
        wa+=1;
    else if(s[i]=="TLE")
        tle+=1;
    else if(s[i]=="RE")
        re+=1;

  }
  out "AC x "<<cntac<<en;
  out "WA x "<<wa<<en;
  out "TLE x "<<tle<<en;
  out "RE x "<<re<<en;

}




int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


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

char s[100][101];
int h,w;
bool vis[101][101];

struct node
{
    int x,y,v;
    node(){}
    node(int x,int y,int v):x(x),y(y),v(v){}
};
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};

int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)cin>>s[i];

    int white = 0;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)if(s[i][j]=='.')white++;

    queue<node> q;
    q.push(node(0,0,0));
    int ans=-1;
    while(!q.empty())
    {
        node now = q.front();
        q.pop();
        for(int i=0;i<4;i++)
        {
            int x=now.x+fx[i],y=now.y+fy[i];
            if(x<0||x==h||y<0||y==w||vis[x][y]||s[x][y]=='#')continue;
            if(x==h-1&&y==w-1)
            {
                return cout<<white-now.v-2,0;
            }
            vis[x][y]=1;
            q.push(node(x,y,now.v+1));
        }
    }
    cout<<"-1";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef unsigned long long ull;

#define MOD 1000000007

ull powmod(ull m, ull n)
{
    if (n == 0) return 1;
    return powmod(m * m % MOD, n / 2) * (n % 2 ? m : 1) % MOD;
}

int main(void)
{
    ull m, n;

    scanf("%llu %llu", &m, &n);
    printf("%llu\n", powmod(m, n));

    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#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
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,m,c,count=0,ans,arr[N],x;
		cin>>n>>m>>c;
		rep(i,0,m)
		cin>>arr[i];
		rep(i,0,n)
		{
			ans=c;
			rep(i,0,m)
			{
				cin>>x;
				ans+=x*arr[i];
			}
			if(ans>0)
				count++;
		}
		cout<<count;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define NMAX 100010
using namespace std;
int n,a[NMAX],p[NMAX];
vector<int> c[NMAX];
bool vis[NMAX];
queue<pair<int,int> > Q;
void DFS(int x,int P){
	p[x]=P;
	for(int i=0;i<c[x].size();i++)DFS(c[x][i],P);
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];if(a[i])
		c[i+a[i]].push_back(i);
		p[i]=-1,vis[i]=0;
	}
	for(int i=0;i<n;i++)if(!a[i])DFS(i,i);
	Q.push(make_pair(0,0));
	while(!Q.empty()){
		int x=Q.front().first,len=Q.front().second;
		if(x==n-1){
			cout<<len<<endl;
			break;
		}
		for(int i=1;i<7;i++){
			int k=i+x;
			if(k<n)if(p[k]+1&&!vis[p[k]]){
				vis[p[k]]=1;
				Q.push(make_pair(p[k],len+1));
			}
		}
		Q.pop();
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long sum = 0;
    // odd -> minus
    long long cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum > 0)
                continue;
            else {
                cnt1 += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum < 0)
                continue;
            else {
                cnt1 += 1 + sum;
                sum = -1;
            }
        }
    }
    sum = 0;
    // even -> minus
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 1) {
            if (sum > 0)
                continue;
            else {
                cnt2 += 1 - sum;
                sum = 1;
            }
        } else {
            if (sum < 0)
                continue;
            else {
                cnt2 += 1 + sum;
                sum = -1;
            }
        }
    }
    cout << min(cnt1, cnt2) << endl;
    return 0;
}

Measured memory_bytes: 640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

def main():
    import sys
    input = sys.stdin.readline
    N, M, K = map(int, input().split())
    union_find = UnionFind(N)
    friends = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        friends[a].append(b)
        friends[b].append(a)
        union_find.union(a, b)
    blacks = [[] for _ in range(N)]
    for _ in range(K):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        blacks[c].append(d)
        blacks[d].append(c)
    ans = []
    for i in range(N):
        a = union_find.size(i) - len(friends[i])
        for black in blacks[i]:
            if union_find.same(i, black):
                a -= 1
        ans.append(a-1)
    print(" ".join(map(str, ans)))

if __name__ == '__main__':
    main()

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

int main(){

    int h,a;
    int cnt=0;
    cin>>h;
    cin>>a;

    int x = h/a;
    while(h>0){
        h = h-a;
        cnt++;
    }
     cout<<cnt;

    return 0;


}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    s = list()
    c = list()

    for i in range(m):
        si, ci = map(int, input().split())
        si -= 1

        s.append(si)
        c.append(ci)

    # KeyInsight
    # 全探索
    # https://www.youtube.com/watch?v=TdR816rqc3s&feature=youtu.be
    # https://drken1215.hatenablog.com/entry/2020/03/02/015100
    for i in range(1000):
        digit = list(str(i))

        # 入力の桁よりも小さい
        if len(digit) != n:
            continue

        ok = True

        # 各桁で矛盾がないかチェック
        # 誤読: 同じ桁で違う数字が出てきたらNGなのに、最小の数字を選択すればいいと思っていた
        # 境界値: 先頭の桁が0がどうかの判定をifで処理したつもりになっていた
        for j in range(m):
            if int(digit[s[j]]) != c[j]:
                ok = False

        if ok:
            print(i)
            exit()

    print(-1)


if __name__ == '__main__':
    main()


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

bool cmp2( pair<ll,ll> &a,
           pair<ll,ll> &b)
{
    return a.second>b.second;
}


void solve() {
  ll n ,W;
  cin>>n>>W;
  ll wt[n+1],val[n+1];
  fo(i,1,n+1){
      cin>>wt[i]>>val[i];
  }

  ll ans[n+1][W+1];
  memset(ans,0,sizeof(ans));
  for(ll i=1;i<=n;i++){
      for(ll j=1;j<=W;j++){
          if(j-wt[i]>=0)ans[i][j]=MAX(ans[i-1][j],ans[i-1][j-wt[i]]+val[i]);
          else ans[i][j]=ans[i-1][j];


      }
  }

  cout<<ans[n][W];




}

























int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

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

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    ll cnt = 0;
    rep(i,N){
        ll a;
        cin >> a;
        if (a % 2) cnt++;
    }
    cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int ans = 0;
    for (int i = 1; i < S.length(); i++) {
      if (S.charAt(i-1) != S.charAt(i)){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

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

bool valid(int A, int B, string S)
{
  if (A + B + 1 != S.size())
  {
    return false;
  }

  int seek = 0;
  for (char c : S)
  {
    if (seek == A)
    {
      if (c != '-')
      {
        return false;
      }
      else
      {
        //ok
      }
    }
    else if ('0' <= c && c <= '9')
    {
      //ok
    }
    else
    {
      return false;
    }
    seek++;
  }
  return true;
}

int main()
{
  int A, B;
  string S;
  cin >> A >> B >> S;

  bool ok = valid(A, B, S);

  if (ok)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int n;
int a[25][25];
int dp[25][2100000];
const int MOD = 1e9 + 7;

int rek(int x, int y) {
	if (x == n) {
		return 1;
	}
	
	int &ret = dp[x][y];
	if (ret != -1) return ret;
	ret = 0;
	
	for (int i = 0; i < n; i ++) {
		if (a[x][i] == 1 && (y&(1 << i)) == 0) {
			ret += rek(x+1, (y|(1 << i)));
			ret %= MOD;
		}
	}
	
	return ret;
}

int main () {
	
	cin >> n;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < n; j ++) {
			cin >> a[i][j];
		}
	}
	
	cout << rek(0, 0);
	
	
	return 0;
}

Measured memory_bytes: 205312
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N];
int main(){
    ll x,c=100;
    int r = 0;
    cin >> x;
    while(c<x){
        r++;
        c = c/100 + c;
    }
    cout <<r <<'\n';
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

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



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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}



int main() {
	string S;
	int i, j, k;
	//ll N, M, K;
	int N, M, K;

	int A[100] = { 0 };

	cin >> N >> K;

	rep(i, 0, K) {
		int d;
		cin >> d;
		rep(j, 0, d) {
			int a;
			cin >> a;
			A[a-1]++;
		}

	}
	int ans = 0;
	rep(i, 0, N) {
		if (A[i] == 0)ans++;

	}
	cout << ans;
	return 0;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	ll ans[10005]={0};
	for(ll i = 1; i <= 100; i++)
	{
		for(ll j = 1; j <= 100; j++)
		{
			for(ll k = 1; k <= 100; k++)
			{
				ll x = i, y = j, z = k;
				ll sum = x * x + y * y + z * z + x * y + y * z + z *x;
				if(sum <= 10000)
					ans[sum]++;
			}
		}
	}
	ll n; cin >> n;
	for(ll i = 1; i <= n; i++)
		cout << ans[i] << endl;
	}

Measured memory_bytes: 3724
#include<stdio.h>
typedef long long ll;

int main(){
    ll i,n;
    ll redcount = 0;
    ll whitecount = 0;
    char c[200005];
    scanf("%lld",&n);
    //printf("%lld\n",n);
    for(i=0;i<=n;i++){
        scanf("%c",&c[i]);
        if(c[i] == 'R'){
            redcount++;
        }
    }
    for(i=0;i<=redcount;i++){
        if(c[i] == 'W'){
            whitecount++;
        }
    }
    printf("%lld\n",whitecount);
    return 0;
}

Measured memory_bytes: 1892
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define re return
#define pb push_back

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

#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

vector<int> v[2];

int fi[200500];
int se[200500];

int main() {
#ifdef home
  freopen("i", "r", stdin);
  freopen("d", "w", stderr);
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#endif
  int n;
  cin >> n;
//  n = 200000;
  f(i, n) {
//    fi[i] = rand() * rand() & ((1 << 28) - 1) ;
    cin >> fi[i];
  }
  f(j, n) {
    cin >> se[j];
  }
  int ans = 0;
  f(bit, 29) {
//    cerr << bit << endl;
    int cnt = 0;
    int mask = (1 << bit) - 1;
    v[0].clear();
    v[1].clear();
    f(i, n) {
      int val = se[i] & (1 << bit);
      int cur = se[i] & mask;
      v[val != 0].pb(cur);
    }
    sort(all(v[0]));
    sort(all(v[1]));
//    for (auto x : v[0]) {
//      cerr << x << ' ';
//    }
//    cerr << '\n';
//    for (auto x : v[1]) {
//      cerr << x << ' ';
//    }
//    cerr << '\n';
    f(i, n) {
      int val = fi[i] & (1 << bit);
      int cur = mask - (fi[i] & mask) + 1;
      if (val == 0) {
        cnt ^= v[0].size() - (lower_bound(all(v[0]), cur) - v[0].begin());
        cnt ^= lower_bound(all(v[1]), cur) - v[1].begin();
      } else {
        cnt ^= v[1].size() - (lower_bound(all(v[1]), cur) - v[1].begin());
        cnt ^= lower_bound(all(v[0]), cur) - v[0].begin();
      }
    }
    if (cnt & 1) {
      ans |= 1 << bit;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

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

    LL ans = 0;

    for(int i = 0; i < n; i += k-1){
        if(i == 0){
            i++;
        }
        ans++;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    long int n;
    cin >> n;
    long int t = 0,min = limit;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        t += a;
        if(a % 10 != 0 && min > a){
            min = a;
        }
    }
    if(min == limit){
        cout << 0 << endl;
        return 0;
    }
    if(t % 10 == 0){
        cout << t - min << endl;
    }else{
        cout << t << endl;
    }
}

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



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

using namespace std;

string str;

int main() {
    cin >> str;
    if(str.size() == 2)
        cout << str << endl;
    else {
        if(str.size() == 3)
            for(int i = str.size() - 1; i >= 0; --i)
                cout << str[i];
    }
}

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

using namespace std;

struct _node
{
    int c, t;
}a[101];

int N, T, ans = 0x7f7f7f;

int main()
{
    cin >> N >> T;
    for (int i = 1; i <= N; i++)
        cin >> a[i].c >> a[i].t;
    for (int i = 1; i <= N; i++)
        if (a[i].t <= T)
            ans = min(ans, a[i].c);
    if (ans == 0x7f7f7f)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,a;
	cin>>h>>a;
	cout<< (ll)ceil((double)h/(double)a) ;
    return 0;
}


//252908XL

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() {
	string s;
	cin >> s;
	int len = s.length();
	int ans = 0;
	rep(i,len) if (s[i] != s[len-1-i]) ans++;
	cout << ans /2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[155];
int b[155];
int arr[155];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=n;i++) arr[i]=i;
	int cnt=1;int x1=0,x2=0;
	do{
		int f1=1,f2=1;
		
		for(int i=1;i<=n;i++){
			if(a[i]!=arr[i]){
				f1=0;
			}
			if(b[i]!=arr[i]){
				f2=0;
			}	
		}
		if(f1&&f1!=-1){
			x1=cnt;
			f1=-1;
		}
		if(f2&&f2!=-1){
			x2=cnt;
			f2=-1;
		}
		cnt++;
	}while(next_permutation(arr+1,arr+1+n));
	//cout<<x1<<" "<<x2;
	cout<<abs(x1-x2);
	return 0;
} 

Measured memory_bytes: 256
cou=0
n=int(input())
a=input()
b=input()
c=input()
for i in range(n):
    if (a[i]==b[i] and a[i]!=c[i]) or (a[i]==c[i] and a[i]!=b[i]) or (b[i]==c[i] and b[i]!=a[i]):
        cou+=1
    elif a[i]!=b[i] and a[i]!=c[i]:
        cou+=2
print(cou)

Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int S = input.nextInt();
        int h,m,s;
        h = S/3600;
        m = (S/60)%60;
        s = S%60;
        System.out.printf("%d:%d:%d\n",h,m,s);
    }
}


Measured memory_bytes: 26452
K=int(input())
A,B=map(int,input().split())
a=A%K
b=B%K
ans=0
ans=a*b
if(ans==0):
    print("OK")
else:
    if((A+K-a)<=B or (B-b)>=A):
        print("OK")
    else:
        print("NG")

Measured memory_bytes: 9180
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

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

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	vec A(N);
	ll maxi = -1;
	ll maxA = -1;
	ll nextA = -1;
	REP(i, N) {
		cin >> A[i];
		if (A[i] > maxA) {
			maxi = i;
			nextA = maxA;
			maxA = A[i];
		} else if (A[i] > nextA) {
			nextA = A[i];
		}
	}

	REP(i, N) {
		if (i == maxi) {
			cout << nextA << endl;
		}
		else {
			cout << maxA << endl;
		}
	}




	return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e9
#define F first
#define S second


const int MAX = 402;

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;


int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1,0);
    Rep(i,n)cin >> a[i];
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    Rep(i,n){
        if(a[i+1] - a[i] > 1){
            cout << -1 << endl;
            return 0;
        }else if(a[i+1] - a[i] != 1){
            ans += a[i];
        }
    }
    cout << ans << endl;
    //cin >> n;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
	int n, a, b;

	cin >> n >> a >> b;

	if (((b - a) & 1) == 1) {
		cout << "Borys" << endl;
	}
	else {
		cout << "Alice" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,x,y,a[100010],now=0,ans=0;

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		a[x]++;
		a[y+1]--;
	}
	rep(i,n)
	{
		now+=a[i];
		if(now==m) ans++;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
 
using namespace std;
 
struct Node {
    int key;
    Node *right, *left, *parent;
};
 
Node *root, *NIL;
 
Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
 
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
     
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
     
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
     
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
 
void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
     
int main(void) {
    int n, i, x;
    string com;
    scanf("%d",&n);
     
    for(i=0;i<n;i++) {
        cin >> com;
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(com == "insert") {
            scanf("%d",&x);
            insert(x);
        } else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
 
    return 0;
}



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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1e9+7;
#define INF (1 << 30)
#define REP(i,m,n) for(int i=(int)m; i < (int)n; ++i)
#define rep(i,n) REP(i,0,n)


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

    int n; cin >> n;
    vector<int> dp(n+1);
    rep(i, n+1) dp[i] = i;
    
    rep(i, n) {
        int x = 6;
        while(i+x <= n) {
            dp[i+x] = min(dp[i+x], dp[i]+1);
            x *= 6;
        }
        int y = 9;
        while(i+y <= n) {
            dp[i+y] = min(dp[i+y], dp[i]+1);
            y *= 9;
        }
    }

    cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <iomanip>
//#include <cmath>
#include <queue>
#include <deque>
#include <stack>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long double ld;
typedef long long ll;
typedef double db;
#define endl '\n'
#define pb push_back
#define pii pair<ll, ll>
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define optimize1() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma warning(disable:4996)

using namespace std;

const ll MX = 5e4 + 10, INF = 1e9 + 1;
ll n;
vector<vector<int>> a;
vector<int> cur(20, 0);

bool can(int l) {
	for (int i = 0; i <= 20; ++i)
		if (cur[i] + a[l][i] == 2)
			return false;
	return true;
}

signed main() {
	optimize1();
	cin >> n;
	a.resize(n);
	int x;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		for (int j = 0; j <= 20; ++j) {
			a[i].pb(x % 2);
			x /= 2;
		}
	}
	ll ans = 0, l = 0;
	for (int i = 0; i < n; ++i) {
		while (l < n && can(l)) {
			for (int j = 0; j <= 20; ++j)
				cur[j] += a[l][j];
			l++;
		}
		//cout << i << ' ' << l << endl;
		ans += l - i;
		for (int j = 0; j <= 20; ++j)
			cur[j] -= a[i][j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 33024