akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (10000000000000000ll)
#define mod (1000000007)

string s;
int k;
vi a;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>s>>k;
	FOR(i,0,s.size()){
		int j=i;
		while(j<s.size()&&s[i]==s[j])j++;
		a.push_back(j-i);
		i=j-1;
	}
	if(a.size()==1){
		cout<<s.size()*1ll*k/2ll<<endl;
		return 0;
	}
	int nd=0;
	FOR(i,0,a.size())nd+=a[i]/2;
	ll ans=nd*1ll*k; 
	if(s[s.size()-1]==s[0]){
		if(a[0]%2==0||a.back()%2==0){
			
		}
		else ans+=k-1;
	}
	Tone(ans)
	return 0;
}


Measured memory_bytes: 256
N = int(input())
 
if  N > 999 or N < 100:
    print("error")
 
elif str(N)[-1] == '7':
  print("Yes")
elif str(N)[-2] == '7':
  print("Yes")
elif str(N)[-3] == '7':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,sum=0;
    cin>>n;
    string s;
    map<string,ll>mp;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        ++mp[s];
    }
    for(auto i : mp)
    {
        sum+=(i.second*(i.second-1)/2);
    }
    cout<<sum;
    
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int>a(n);
	int ans = 0;
	for (int i = 0; i<n; i++){
		cin >> a[i];
		ans += a[i];
	}
	sort(a.begin(), a.end());
	if (ans % 10 != 0){
		cout << ans << endl;
		return 0;
	}
	for (int i = 0; i<n; i++){
		ans -= a[i];
		if (ans % 10 != 0){
			cout << ans << endl;
			break;
		}
		ans += a[i];
		if (i == n - 1){
			cout << 0 << endl;
			break;
		}
	}
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int X, Y, Z;
  cin >> X >> Y >> Z;

  cout << Z << " " << X << " " << Y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;

int main(){
    int w,h;
    
    while(true){
        cin >> h >> w;
        if(w == 0 && h == 0){
            break;
        }
        
        for(int hh = 0;hh<h;hh++){
            for(int ww = 0;ww<w;ww++){
                if(hh % 2 == 0){
                    if(ww % 2 == 0){
                        cout << '#';
                    }
                    else{
                        cout << '.';
                    }
                }
                else{
                    if(ww % 2 == 0){
                        cout << '.';
                    }
                    else{
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void) {
	int x,y;
	scanf("%d %d",&x,&y);
	if(x<y) {
		printf("a < b\n");
	}else if(x>y){
		printf("a > b\n");
	}else if(x==y){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
n,m=map(int,input().split())
mod=10**9+7
t=[int(input()) for i in range(m)] 
dp=[-1]*(n+1)

dp[0]=1 #0が１なのは２段目の回答を合わせるためdp[０]＝０、dp[1]=0,ds[2]=1
#は入力が1,0のきエラーになるので、だめ
dp[1]=1
for i in range(m):
    dp[t[i]]=0#ここはそもそもいけないので０になる


for i in range(2,n+1):
    if dp[i]==-1:
        dp[i]=dp[i-1]+dp[i-2]#このばしょにくるほうほうは二個前からくるか一個前からくるか、そこのあたいをたっせばいい
print(dp[-1]%mod)


Measured memory_bytes: 460020
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 10007;
const LD EPS = 1e-7;

int A[MAXN], B[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("sparse.in", "r", stdin);
	//freopen("sparse.out", "w", stdout);
	int n;
	LL ka = 0, kb = 0;
	cin >> n;
	REP(i, n)
		cin >> A[i];
	REP(i, n)
		cin >> B[i];
	REP(i, n)
	{
		if (A[i] < B[i])
		{
			ka += (B[i] - A[i] + 1) >> 1;
			A[i] += ((B[i] - A[i] + 1) >> 1) << 1;
		}
		kb += max(0, A[i] - B[i]);
	}
	cout << (ka >= kb ? "Yes" : "No");
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)

using namespace std;

typedef long long ll;

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(void){
    int N, MAX = 200000;
    vector<int> A(MAX);
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    for(int i = 0;i < N;i++)A[i]--;
    vector<int>cnt(MAX);
    ll tot = 0;
    for(int i = 0;i < N;i++)cnt[A[i]]++;
    for(int i = 0;i < N;i++)tot += choose2(cnt[i]);
    rep(i, N){
        ll ans = tot;
        ans -= choose2(cnt[A[i]]);
        ans += choose2(cnt[A[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
import sys
n = int(input())
s1 = input()
s2 = input()
MOD = 10**9 + 7

if n == 1:
    print(3)
    sys.exit()

dp = [0] * n
dp[0] = 3 if s1[0] == s2[0] else 6

for i in range(1, n):
    if s1[i - 1] == s1[i]:
        dp[i] = dp[i - 1]
        continue
    if s1[i - 1] == s2[i - 1]:
        dp[i] = dp[i - 1] * 2 % MOD
    elif s1[i] != s2[i]:
        dp[i] = dp[i - 1] * 3 % MOD
    else:
        dp[i] = dp[i - 1]

print(dp[-1])

Measured memory_bytes: 9176
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int n = 10000;
    int N = 0;
    int H[n];
    int W[n];
    int h, w;

    for(int i = 0; i < n; i++){
        cin >> H[i] >> W[i];
        N++;
        if(H[i] == 0 and W[i] == 0){
            break;
        }
    }

    for(int i = 0; i < N - 1; i++){
            for(int y = 0; y < H[i]; y++){
                if(y == 0 or y == H[i] - 1){
                    for(int x = 0; x < W[i]; x++){
                        printf("#");
                        }
                    printf("\n");
                    }
                else{
                    for(int x = 0; x < W[i]; x++){
                        if(x == 0 or x == W[i] - 1){
                            printf("#");
                        }
                        else{
                            printf(".");
                        }
                    }
                    printf("\n");
                }    
                
            }
            printf("\n");
    }
    return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef unsigned long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 2e5 + 5;

int n, P[N];
bool A[N];

bool Top(int x) {
	for (int i = 0; i <= 2 * n; i++) A[i] = (P[i] >= x);
	if (A[n] == A[n - 1] || A[n] == A[n + 1]) return A[n];
	int l = n, r = n;
	while (A[l - 1] == !A[l]) l--;
	while (A[r + 1] == !A[r]) r++;
	if ((n - l) < (r - n)) return A[l];
	else return A[r];
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	for (int i = 1; i < 2 * n; i++) cin >> P[i];
	P[0] = P[1], P[2 * n] = P[2 * n - 1];
	
	int dw = 0, up = 2 * n;
	while (up - dw > 1) {
		int md = (dw + up) >> 1;
		if (Top(md)) dw = md;
		else up = md;
	}
	cout << dw << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int function2(string &str,int initial,int final,int memo[][4][3],int k,int status)
{
	if(k<0)
	   return 0;
	if(initial>final)
	{
		if(k==0)
		   return 1;
		else
		   return 0;
	}
	if(memo[initial][k][status]!=-1)
	    return memo[initial][k][status];
	else
	{
		int j;
		if(initial==0)
		{
			int val=str[initial]-48;
			if(status==0)
			{
				int answer=0;
				for(j=1;j<=val;j++)
				{
					if(j<val)
					{
						answer+=function2(str,initial+1,final,memo,k-1,1);
					}
					else
					{
						answer+=function2(str,initial+1,final,memo,k-1,0);
					}
				}
				memo[initial][k][status]=answer;
				return answer;
			}
			else
		    {
				int answer=0;
				for(j=1;j<=9;j++)
				{
					answer+=function2(str,initial+1,final,memo,k-1,1);
				}
				memo[initial][k][status]=answer;
				return answer;
			}
		}
		else
		{
			int val=str[initial]-48;
			if(status==0)
			{
				if(val==0)
				{
					int answer=0;
					answer+=function2(str,initial+1,final,memo,k,0);
					memo[initial][k][status]=answer;
					return answer;
				}
				else
				{
					int answer=0;
					answer+=function2(str,initial+1,final,memo,k,1);
					for(j=1;j<val;j++)
					{
						answer+=function2(str,initial+1,final,memo,k-1,1);
					}
					answer+=function2(str,initial+1,final,memo,k-1,0);
					memo[initial][k][status]=answer;
					return answer;
				}
			}
			else
			{
				int answer=0;
				answer+=function2(str,initial+1,final,memo,k,1);
				for(j=1;j<=9;j++)
				{
					answer+=function2(str,initial+1,final,memo,k-1,1);
				}
				memo[initial][k][status]=answer;
				return answer;
			}
		}
	}
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     string str;
     cin>>str;
     int k;
     cin>>k;
     int answer=0;
     int n=str.size();
     int j;
     for(j=1;j<n;j++)
     {
		 int memo[j+1][4][3];
		 for(int p=0;p<=j;p++)
		 {
			 for(int q=0;q<4;q++)
			 {
				 for(int r=0;r<3;r++)
				 {
					 memo[p][q][r]=-1;
				 }
			 }
		 }
		 answer+=function2(str,0,j-1,memo,k,1);
	 }
	 int memo[n+1][4][3];
	 for(int p=0;p<=j;p++)
	 {
		 for(int q=0;q<4;q++)
		 {
			 for(int r=0;r<3;r++)
			 {
				 memo[p][q][r]=-1;
			 }
		 }
	 }
	 answer+=function2(str,0,n-1,memo,k,0);
	 cout<<answer<<endl;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using LP = pair<ll, int>;
int main(){
	int N, M;
	cin >> N >> M;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	vector<LP> CB(M);
	for(int i=0; i<M; i++){
		ll c;  int b;
		cin >> b >> c;
		CB[i] = LP(c, b);
	}
	// 解1
	// sort(A.begin(), A.end());// 昇順ソート
	// sort(CB.rbegin(), CB.rend());// CBをCの値で降順ソート
	// vector<ll> vec;//CBの内で解放からN個取り出して並べる
	// for(int i=0; i<M; i++){
	// 	for(int j=0; j<CB[i].second; j++){
	// 		vec.push_back(CB[i].first);
	// 	}
	// 	if(vec.size() >= N) break;
	// }

	// ll ans = 0;
	// for(int i=0; i<N; i++){
	// 	if(vec.size() >= i+1) ans += max(A[i], vec[i]);
	// 	else ans += A[i];
	// }
	// cout << ans << endl;

	// 解2 priority_queueを使う
	priority_queue<LP> pri_qu;
	for(int i=0; i<N; i++) pri_qu.push(LP(A[i], 1));
	for(int i=0; i<M; i++) pri_qu.push(CB[i]);

	ll ans = 0;
	for(int i=0; i<N; i++){
		ll value = pri_qu.top().first;
		ll num = pri_qu.top().second;
		pri_qu.pop();
		ans += value;
		num--;
		if(num > 0) pri_qu.push(LP(value, num));
	}
	cout << ans << endl;


}



Measured memory_bytes: 9752
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    int o;
    int t;
    o = n % 10;
    t = n - o;
    if (t == 90 || o ==9)
        puts("Yes");
    else
        puts("No");
    return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vi p(n + 1);
	vb state(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			res++;
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] XA = ReadLineParseIntArray();
        int X = XA[0];
        int A = XA[1];
        WriteLine(X < A ? "0" : "10");
    }
      static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
line = input().split(" ")
h = int(line[0])
w = int(line[1])

s = []

for _ in range(h):
    s.append(input())

diff = [
    [0,1]
    ,[0,-1]
    ,[1,0]
    ,[-1,0]
]
for hi in range(h):
    for wi in range(w):
        if s[hi][wi]=="#":
            flag = False
            for d in diff:
                if h>hi+d[0]>=0 and w>wi+d[1]>=0:
                    if s[hi+d[0]][wi+d[1]]=="#":
                        flag = True
            if not flag:
                print("No")
                exit()

print("Yes")


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int num;
    double w, h, bmi;

    while ( scanf("%d,%lf,%lf", &num, &w, &h) != EOF) {
        bmi = w / h / h;
        //printf("%lf\n",bmi);
        if (bmi >= 25.0) {
            printf("%d\n",num);
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int main(){
    rep(i,3){
        string s;
        cin >> s;
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#include <deque> 
#define DBL_MIN 0.000000000000001

#include <iostream>
using namespace std;

int main(void){
    long N,M;
    cin >> N >> M;
    if(2*N > M){
        cout << (M - M % 2)/2 << endl;
    }else{
        M = M - 2*N;
        cout << N + (M-M%4)/4 << endl;
    }
    return 0;
}



Measured memory_bytes: 3564
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(range(max_sugar // C + 1)):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print(' '.join(map(str, ans)))

Measured memory_bytes: 3064
a,b,c = STDIN.gets.chomp!.split(" ").map(&:to_i) 

if (a*100 + b*10 + c) % 4 == 0 && (a >= 1 && a <= 9 || b >= 1 && b <= 9 || c >= 1 && c <= 9)
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,cnt;
int tot,ls[400010],x2[200010],sz[200010];
int x1[200010],r[200010],vt[200010],l[200010],su;
ll mo=1e9+7,ans,f[200010][3],bi[200010],sum[200010];
bool cmp(int a,int b)
{
	return sz[a]<sz[b];
}
void adde(int a,int b)
{
	r[++cnt]=x1[a];x1[a]=cnt;vt[cnt]=b;
}
ll add(ll &a,ll b)
{
	a+=b;
	if(a>=mo)a-=mo;
}
void dfs(int i,int fa,int de)
{
	int s,a,b,j,k;
	a=x1[i];sum[de]++;
	while(a)
	{
		b=vt[a];
		if(b!=fa)dfs(b,i,de+1);
		a=r[a];
	}
	a=x1[i];su=0;
	while(a)
	{
		b=vt[a];
		if(b!=fa)l[++su]=b;
		a=r[a];
	}
	if(!su)
	{
		sz[i]=1;x2[i]=++tot;
		f[tot][0]=f[tot][1]=1;
		return ;
	}
	sort(l+1,l+1+su,cmp);
	for(s=1;s<su-1;s++)
	{
		a=x2[l[s]];b=x2[l[s+1]];
		while(a)
		{
			f[b][2]=((f[a][0]+f[a][1]+f[a][2])%mo*f[b][2]%mo+(f[a][2]+f[a][1])%mo*f[b][1]%mo+f[a][2]*f[b][0]%mo)%mo;
			f[b][1]=(f[b][1]*f[a][0]+f[b][0]*f[a][1])%mo;
			f[b][0]=f[b][0]*f[a][0]%mo;
			a=ls[a];b=ls[b];
		}
	}
	if(su>1)
	{
		a=x2[l[su-1]];b=x2[l[su]];
		while(a)
		{
			f[b][2]=((f[a][0]+f[a][1]+f[a][2])%mo*f[b][2]%mo+(f[a][2]+f[a][1])%mo*f[b][1]%mo+f[a][2]*f[b][0]%mo)%mo;
			f[b][1]=(f[b][1]*f[a][0]+f[b][0]*f[a][1])%mo;
			f[b][0]=f[b][0]*f[a][0]%mo;
			add(f[b][0],f[b][2]);f[b][2]=0;
			a=ls[a];b=ls[b];
		}
	}
	x2[i]=++tot;ls[tot]=x2[l[su]];sz[i]=sz[l[su]]+1;
	f[tot][0]=f[tot][1]=1;
}
int main()
{
	int i,s,a,b,j,k;
	scanf("%d",&n);
	bi[0]=1;for(i=1;i<=n+1;i++)bi[i]=bi[i-1]*2%mo;
	for(i=1;i<=n;i++)scanf("%d",&a),adde(a+1,i+1);
	dfs(1,0,1);a=x2[1];k=0;
	while(a)k++,add(ans,f[a][1]*bi[n-sum[k]+1]%mo),a=ls[a];
	printf("%lld",ans);
	return 0;
}

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

#define int long long

int n, k;
int a[200010];
int f[200010];


bool isOK(int num){
    int kk = k;
    for(int i = 0;i < n;i++){
        int x = num/f[i];
        kk -= max(0ll, a[i]-x);
    }
    return kk >= 0;
}

signed main(){
    cin >> n >> k;

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

    sort(a, a+n, greater<int>());
    sort(f, f+n);

    int l = -1, r = 100000000000000;

    while(r-l > 1){
        int mid = (r+l)/2;
        if(isOK(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}

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

int main() {
  string A; cin >> A;
  long long N = A.size();
  long long ans = N * (N - 1) / 2 + 1;
  map<int, long long> M;
  for (int i = 0; i < N; i++) {
    int idx = A.at(i) - 'a';
    if (M.count(idx)) M[idx]++;
    else M[idx] = 1;
  }
  for (int i = 0; i < 26; i++) {
    if (M.count(i)) ans -= M[i] * (M[i] - 1) / 2; 
  }
  cout << ans << endl;
}

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

int main(){
  int x, y;
  cin >> x >> y;

  if(x>y){
    int temp=x;
    x = y;
    y = temp;
  }

  while(y!=0){
    int nx, ny;
    nx = y;
    ny = x%y;

    x = nx, y = ny;
  }

  cout << x << endl;

  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		}
	vector<ll>dp(k+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		vector<ll>prefix(k+1);
		for(int used=k;used>=0;used--){
			ll l=used+1;
			ll r=used+min(a[i],k-used);
			if(l<=r){
				prefix[l]=(prefix[l]+dp[used])%mod;
				if(r+1<=k){
					prefix[r+1]=(prefix[r+1]-dp[used]+mod)%mod;
					}
				}
			
			
			}
			ll sum=0;
			for(int i=0;i<=k;i++){
				sum=(sum+prefix[i])%mod;
				dp[i]=(dp[i]+sum)%mod;
				}
		
		}
		cout<<dp[k]<<endl;
	
}


Measured memory_bytes: 1912
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589

int main(){
	double a,b,c,C,h,S,L;
	scanf("%lf %lf %lf",&a,&b,&C);
	h=b*sin(C/180*PI);
	S=a*h/2;
	c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C/180*PI));
	printf("%lf\n%lf\n%lf",S,a+b+c,h);
	return 0;
}	

Measured memory_bytes: 676
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
//============================================================================
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace std;
const int N = 1e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
string s, arr[] = { "dream", "dreamer", "erase", "eraser" };
int dp[N] = { };
int solve(int idx) {
	if (idx >= s.size())
		return 1;
	int &ret = dp[idx];
	if (ret != -1)
		return ret;
	ret = 0;
	lp(i,0,3)
	{
		if (idx + arr[i].size() <= s.size()) {
			if (s.substr(idx, arr[i].size()) == arr[i]) {
				ret |= solve(idx + arr[i].size());
				if (ret)
					break;
			}
		}
	}
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
    FAST;
#endif
	cin >> s;
	clr(dp, -1);
	cout << ((solve(0) == 1) ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 2716
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int V[20], C[20];

int rec(int cur) {
    if (cur == -1) return 0;  
    return max(rec(cur-1) + V[cur]-C[cur], rec(cur-1));
}

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    REP(i, N) { cin >> V[i]; }  REP(i, N) { cin >> C[i]; }
    int ans = rec(N-1);
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

class Pair implements Comparable<Pair>{
	int i, num;
	public Pair(int _i, int n) {
		i = _i; num = n;
	}
	public int compareTo(Pair p) {
		if(p.num == num) return i - p.i;
		return p.num - num;
	}
}

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int[] left = new int[n / 2];
		int[] right = new int[n / 2];
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(i % 2 == 0) left[i / 2] = a;
			else right[i / 2] = a;
		}
		Arrays.sort(left);
		Arrays.sort(right);
		TreeSet<Pair> left_set = new TreeSet<Pair>();
		TreeSet<Pair> right_set = new TreeSet<Pair>();

		for(int i = 0; i < left.length; i++) {
			int tmp = i;
			while(i + 1 < left.length && left[i] == left[i + 1]) i++;
			left_set.add(new Pair(left[i], i - tmp + 1));
		}
		for(int i = 0; i < right.length; i++) {
			int tmp = i;
			while(i + 1 < right.length && right[i] == right[i + 1]) i++;
			right_set.add(new Pair(right[i],  i - tmp + 1));
		}
		Pair left_first = left_set.pollFirst(), left_second = left_set.pollFirst();
		Pair right_first = right_set.pollFirst(), right_second = right_set.pollFirst();

		if(left_first.i != right_first.i) {
			System.out.println(n - left_first.num - right_first.num);
		}else {
			/* left: first, right: second */
			int fs = n / 2 - left_first.num + n / 2 - ((right_second == null) ? 0 : right_second.num);

			/* right: first, left: second */
			int sf = n / 2 - right_first.num + n / 2 - ((left_second == null) ? 0 : left_second.num);

			System.out.println(Math.min(fs, sf));
		}
	}
}

Measured memory_bytes: 52552
n,m=map(int,input().split())
if n==1:
  if m==1:
    print(1)
  else:
    print(m-2)
elif m==1:
  if n==1:
    print(1)
  else:
    print(n-2)
elif n==2 or m==2:
  print(0)
else:
  print((m-2)*(n-2))

Measured memory_bytes: 3060
import sys


def handler():
    n, m = [int(i) for i in input().strip().split()]
    a = [int(i) for i in input().strip().split()]
    for i in range(m, n):
        if a[i] <= a[i - m]:
            sys.stdout.write('No\n')
        else:
            sys.stdout.write('Yes\n')


def main():
    while True:
        try:
            handler()
        except ValueError:
            continue
        except EOFError:
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 94176
n, m = map(int, input().split())

a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n - (m - 1)):
    for j in range(n - (m - 1)):
        if b[0] == a[i][j:j+m]:
            for k in range(1, m):
                if b[k] != a[i + k][j:j+m]:
                    break
            else:
                print("Yes")
                exit()

print("No")

Measured memory_bytes: 3064
S = input()

def solve(n, S, idx):

    if len(n) == 7:
        if eval(n) == 7:
            n+="=7"
            print(n)
            exit()
        return

    solve(n+"+"+S[idx], S,idx+1)
    solve(n+"-"+S[idx], S,idx+1)

solve(S[0], S, 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int BASE = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  int f[100100][13] = {0};
  f[0][0] = 1;
  for (int i = 0; i < s.size(); i++)
    for (int r = 0; r < 13; r++)
      for (int x = 0; x < 10; x++)
        if (s[i] == '?' || s[i] - '0' == x)
        {
          int newR = (r * 10 + x) % 13;
          f[i + 1][newR] = (f[i + 1][newR] + f[i][r]) % BASE;
        }
  cout << f[s.size()][5] << endl;
}


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


int main() {


    int64_t n,w,h;
    cin>>n>>h>>w;

    int cnt=0;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        if(n-i+1>=h&&n-j+1>=w)
          cnt++;
      }
    }

    cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef pair<int, int> P;

map<int, int> m;
//char t[1 << 24];

int encode(const vector<int>& a) {
	int ret = 0;
	for(int i = 0; i < 8; i++) {
		ret <<= 3;
		ret |= a[i];
	}
	return ret;
}

void decode(int c, vector<int>& a) {
	for(int i = 0; i < 8; i++) {
		a[7 - i] = c & 7;
		c >>= 3;
	}
}

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

	/*for(int i = 0; i < 1 << 24; i++) {
		t[i] = 10000000;
		}*/
	vector<int> a(8);
	for(int i = 0; i < 8; i++) {
		a[i] = i;
	}
	queue<P> q;
	q.push(P(encode(a), 0));
	//t[encode(a)] = 0;
	m[encode(a)] = 0;
	while(!q.empty()) {
		P p = q.front();
		q.pop();
		if(m[p.first] < p.second) continue;
		//if(t[p.first] != p.second) continue;
		decode(p.first, a);
		int d[] = { 1, -1, 4, -4 };
		for(int i = 0; i < 8; i++) {
			if(a[i] != 0) continue;
			for(int j = 0; j < 4; j++) {
				if(d[j] == 1 && (i == 3 || i == 7)) continue;
				if(d[j] == -1 && (i == 0 || i == 4)) continue;
				if(d[j] == 4 && 4 <= i) continue;
				if(d[j] == -4 && i <= 3) continue;
				swap(a[i], a[i + d[j]]);
				int code = encode(a);
				/*if(p.second + 1 < t[code]) {
					t[code] = p.second + 1;
					q.push(P(code, p.second + 1));
					}*/
				if(m.find(code) == m.end() || p.second + 1 < m[code]) {
					m[code] = p.second + 1;
					q.push(P(code, p.second + 1));
				}
				swap(a[i], a[i + d[j]]);
			}
		}
	}
	string s;
	while(getline(cin, s)) {
		for(int i = 0; i < 8; i++) {
			a[i] = s[2 * i] - '0';
		}
		int code = encode(a);
		cout << m[code] << endl;
	}

}

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

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
  return 0;
}



Measured memory_bytes: 256
z='abcdefghijklmnopqrstuvwxyz'
for _ in[0]*int(input()):
 e=input()
 for i in range(1,26,2):
  for j in range(26):
   a=''
   for c in e:
    if c in z:a+=z[(z.index(c)*i+j)%26]
    else:a+=c
   if'that'in a or'this'in a:print(a);break


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

int main(){
  int N, K;
  cin >> N >> K;
  int ans;
  for (int i = 1; i <= N; i++){
    if (i * K - (i-1) >= N) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

scores = {'r': P, 's': R, 'p': S, 'default': 0}
win_flag = [False]*(N+1)
ans = 0

# Kの剰余で別々に考えていい
for i_k in range(K):
    prev = 'default'
    for i_n in range(i_k, N, K):
        # K個前と違う手 もしくは K個前で勝たないことにした 場合
        #   => 点がもらえる
        if (T[i_n] != prev) or (not win_flag[i_n-K]):
            win_flag[i_n] = True
            ans += scores[T[i_n]]
        prev = T[i_n]

print(ans)

Measured memory_bytes: 74652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static class Team implements Comparable<Team>{
		int number;
		String name;
		int win;
		int lose;
		
		Team(int number, String name, int win, int lose) {
			this.number = number;
			this.name = name;
			this.win = win;
			this.lose = lose;
		}
		
		public int compareTo(Team o) {
			if (this.win != o.win) {
				return o.win - this.win;
			} else if (this.lose != o.lose) {
				return this.lose - o.lose;
			} else {
				return this.number - o.number;
			}
		}
		
	}
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Team team[];
		
		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			
			team = new Team[n];
			for (int i = 0; i < n; i++) {
				String name = sc.next();
				int win = 0;
				int lose = 0;
				String s[] = sc.nextLine().split(" ");
				for (int j = 1; j < n; j++) {
					if (s[j].equals("0")) {
						win++;
					} else if (s[j].equals("1")) {
						lose++;
					}
				}
				team[i] = new Team(i, name, win, lose);
			}
			Arrays.sort(team);
			for (int i = 0; i < n; i++) {
				System.out.println(team[i].name);
			}
		}
	}
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi a(N+1); REP1(i, N) cin >> a[i];
    int c = 0, c2 = 0, c4 = 0;
    REP1(i, N)
    {
        if(a[i] % 4 == 0) c4++;
        else if(a[i] % 2 == 0) c2++;
        else c++;
    }

    if(c <= c4 || (c2 == 0 && c-1 <= c4)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N, M, C;
	cin >> N >> M >> C;

	vector<int>B(M);
	for (int i = 0; i < M; i++){
		cin >> B[i];
	}

	vector<vector<int>>A(N, vector<int>(M));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < M; j++){
			cin >> A.at(i).at(j);
		}
	}

	int count = 0;
	for (int i = 0; i < N; i++){
		int sum = 0;
		for (int j = 0; j < M; j++){
			sum += A.at(i).at(j)*B[j];
		}
		if (sum + C > 0)count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N = ii()
    S = input()
    stack = []
    for s in S:
        if not stack or stack[-1] != s:
            stack.append(s)
    print(len(stack))


main()


Measured memory_bytes: 3956
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define MAX_N	(100000)

/* typedef */

/* global variables */

int uft[MAX_N + 1], dfs[MAX_N + 1], lvls[MAX_N + 1];

/* subroutines */

int rootd(int k, int& d) {
  int rk = k;
  d = 0;
  
  while (rk != uft[rk]) {
    d += dfs[rk];
    rk = uft[rk];
  }

  return rk;
}

/* main */

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if ((n | m) == 0) break;

    for (int i = 1; i <= n; i++) {
      uft[i] = i;
      dfs[i] = 0;
      lvls[i] = 1;
    }

    for (int i = 0; i < m; i++) {
      char op;
      int a, b;

      cin >> op >> a >> b;

      int ra, rb, da, db;
      ra = rootd(a, da);
      rb = rootd(b, db);
    
      if (op == '!') {
	int w;
	cin >> w;
	int rd = w + db - da;

	if (ra == rb) {
	  if (rd == 0) continue;
	  cout << "Error" << endl;
	  exit(0);
	}

	if (lvls[ra] <= lvls[rb]) {
	  uft[ra] = rb;
	  dfs[ra] = rd;
	  if (lvls[ra] == lvls[rb]) lvls[rb]++;
	}
	else {
	  uft[rb] = ra;
	  dfs[rb] = -rd;
	}
      }
      else {
	if (ra != rb)
	  cout << "UNKNOWN" << endl;
	else {
	  int d = da - db;
	  cout << d << endl;
	}
      }
    }
  }

  return 0;
}

Measured memory_bytes: 2332
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    vector<int> S;
    {
        char c;
        while ((c = getchar()) != '\n'){
            S.emplace_back(c - '0');
        }
    }

    vector<long long> power10(S.size());
    power10[0] = 1;
    for (int i = 1; i < power10.size(); ++i) power10[i] = power10[i - 1] * 10;
    vector<long long> power2(S.size());
    for (int i = 0; i < power2.size(); ++i) power2[i] = (1 << i);

    long long result = 0;
    for (int i = 0; i < S.size(); ++i){
        long long s = S[i];
        result += s * power2[i] * power10[S.size() - 1 - i];
        for (int j = i + 1; j < S.size(); ++j){
            result += s * power2[j - 1] * power10[S.size() - 1 - j];
        }
    }

    printf("%lld\n", result);
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=INF;
ll x[500005],y[500005],z[100005];
ll dp[100],ma,mi;
char s[100005];

int main(){
	cin>>n;
	y[0]=0;
	for(i=0;i<n;i++){
		cin>>x[i];
		y[i+1] =y[i] + x[i];
	}
	for(i=1;i<=n;i++){
		//iで分割しよ！
		//pe(i);
		ll mid=y[i];
		a = lb(y,y+n+1,y[i]/2)-y;
		mi=INF;
		for(j=a-2;j<=a+2;j++){
			if(j<0 || j>i)continue;
			ma = max(y[j],mid-y[j]);
			if(ma<mi){
				mi=ma;
				num = j;
			}
		}
		//pe("num=");pe(num);
		dp[0] = y[num];
		dp[1] = mid-y[num];
		//pe(dp[0]);pe(dp[1]);
		a = lb(y,y+n+1,(y[n]+mid)/2)-y;
		mi=INF;
		for(j=a-2;j<=a+2;j++){
			if(j<i || j>n)continue;
			ma = max(y[n]-y[j],y[j]-mid);
			if(ma<mi){
				mi = ma;
				num = j;
			}
		}
		dp[2]=y[num]-mid;
		dp[3] = y[n] - y[num];
		//pe(dp[2]);pe(dp[3]);
		sort(dp,dp+4);
		//p(dp[3]-dp[0]);
		ans = min(ans,dp[3]-dp[0]);
	}
	p(ans);
	return 0;
}

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

using namespace std;

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

int main() {
	int n;
	cin >> n;
	
	map<int, int> cnt[2];
	rep(i, n) { int vi; cin>>vi; cnt[i%2][vi]++; }
	
	int a0=-1, a1=-1, b0=-1, b1=-1;
	for(auto c: cnt[0]) if(c.second>cnt[0][a0]) a1=a0, a0=c.first; else if(c.second>cnt[0][a1]) a1=c.first;
	for(auto c: cnt[1]) if(c.second>cnt[1][b0]) b1=b0, b0=c.first; else if(c.second>cnt[1][b1]) b1=c.first;
	
	int ans = a0!=b0? (n-cnt[0][a0]-cnt[1][b0]) : min(n-cnt[0][a0]-cnt[1][b1], n-cnt[0][a1]-cnt[1][b0]);
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a - 2 * b > 0) {
		cout << (a - 2 * b) << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int m;
char s[4];
int main(void)
{
    scanf("%s", s);
    if (s[0] == '0' && s[1] >= '1' || s[0] == '1' && s[1] <= '2')
    {
        m = 1;
    }
    else
    {
        m = 2;
    }

    if (m == 1)
    {
        if (s[2] == '0' && s[3] >= '1' || s[2] == '1' && s[3] <= '2')
        {
            printf("AMBIGUOUS");
        }
        else
        {
            printf("MMYY");
        }
    }
    else
    {
        if (s[2] == '0' && s[3] == '0' || s[2] >= '2' || s[2] == '1' && s[3] >= '3')
        {
            printf("NA");
        }
        else
        {
            printf("YYMM");
        }
    }
    return 0;

    /*if(s[0] =='0'&&s[1] == '0'||s[2] =='0'&&s[3] == '0'){
       printf("NA");
    }else
    if (s[0] >= '2')
    {
        printf("YYMM");
    }
    else if (s[1] >= '3')
    {
        printf("YYMM");
    }
    else if(s[2] >= '2'&&s[3] >= '3'){
        printf("MMYY");
    }else {
        printf("AMBIGUOUS");
    }*/
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	in_v(int, a, N);
	ll cnt = 0;
	loop(i, N-1) {
		if (a[i] == a[i + 1]) {
			++cnt;
			a[i + 1] = -1;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll X,ans;

void input() {
	cin>>X;
}

void solve() {
	ans=(X/11)*2;
	if(X%11>6) ans++;
	if(X%11>0) ans++;
	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3652