akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int d[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << d[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
 
int n,g[101][101], x[101], y[101];
 
void bfs(int,int);
 
int main(){
  int i, j, m;
 
  scanf("%d",&n);
 
  for(i = 1; i <= n; i++){
    x[i] = 100000000;
    scanf("%d", &m);
    scanf("%d", &y[m]);
 
    for(j=1;j<=y[m];j++) scanf("%d",&g[m][j]);
  }
 
  bfs(1,0);
 
  for(i=1;i<=n;i++){
    if(x[i] == 100000000) x[i] = -1;
  }
 
  for(i=1;i<=n;i++) printf("%d %d\n",i,x[i]);
 
  return 0;
}

void bfs(int a,int b){
  int i;
  x[a]=b;
  for(i=1;i<=y[a];i++){
    if(b+1<x[g[a][i]]) bfs(g[a][i],b+1);
  }
}

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

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int nh = n / 2;
  int nk = (n - 1) / 2;

  if (k > nh) {
    cout << -1 << endl;
    return 0;
  }

  int c = 0;
  
  for (int i = 0; i < nh; i++) {
    if (c) putchar('\n');

    for (int j = 1; j <= nk; j++) {
      int n0 = i + j;
      int n1 = (i + n - j) % n;
      printf("%d %d\n", n0 + 1, n1 + 1);
    }

    for (int j = 0; j < nh; j++) {
      int n0 = i + j + 1;
      int n1 = (i + n - j) % n;
      if (n0 != n1) printf("%d %d\n", n0 + 1, n1 + 1);
    }

    if (++c >= k) break;
  }
  
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 405
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

int n;
int k;
ll a[N];
ll dp[N][N];

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> n;
    for(int i=1;i<=n;i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    memset(dp, 0x3f, sizeof(dp));
    for(int i = 1; i <= n; i++)
        dp[i][i] = 0;
    for(int len = 2; len <= n; len++) {
        for(int j = 1; j + len - 1 <= n; j++)
            for(int len2 = 1; len2 < len; len2++)
                dp[j][j + len - 1] = min(dp[j][j + len - 1], 
                dp[j][j + len2 - 1] + dp[j + len2][j + len - 1] + a[j + len - 1] - a[j - 1]);
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 1536
import numpy as np

K, N = [int(element) for element in input().split(" ")]
AList = np.array([int(element) for element in input().split(" ")])
distance = np.diff(AList)
start_end_distance = abs((K - AList[-1]) + AList[0])
distance = np.append(distance, start_end_distance)

print(K - np.max(distance))

Measured memory_bytes: 43600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        int year = 0;
        long money = 100;
        while (money<x){
            year++;
            money +=money/100;
        }
        System.out.println(year);
    }
}


Measured memory_bytes: 35644
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    vector<string> map(H+2,"");
    REP(i,H+2){
        if(i==0||i==H+1)REP(y,W+2)map[i]+=".";
        else {
            string s;cin>>s;
            map[i]= "."+s+".";
        }
    }
    for(int i=1;i<=H;i++){
        for(int y=1;y<=W;y++){
            if(map[i][y]=='#')cout<<'#';
            else {
                int cnt=0;
                if(map[i-1][y-1]=='#')cnt++;
                if(map[i-1][y]=='#')cnt++;
                if(map[i-1][y+1]=='#')cnt++;
                if(map[i][y-1]=='#')cnt++;
                if(map[i][y+1]=='#')cnt++;
                if(map[i+1][y-1]=='#')cnt++;
                if(map[i+1][y]=='#')cnt++;
                if(map[i+1][y+1]=='#')cnt++;
                cout<<cnt;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,pair<int,int>>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, a[405], sum[405];
int dp[514][514];
signed main() {
	cin >> n;
	REP(i, n + 1) {
		cin >> a[i];
		sum[i] += a[i];
		sum[i + 1] += sum[i];
	}
	rep(i, n + 1)rep(j, n + 1)dp[i][j] = inf;
	rep(i, n + 1)dp[i][i] = 0;
	REP(i, n) {
		REP(j, n - i + 1) {
			//j~j+i
			int mi = inf;
			for (int k = j; k < j + i; k++) {
				mi = min(mi, dp[j][k] + dp[k + 1][j + i]);
			}
			dp[j][j + i] = mi + sum[j + i] - sum[j - 1];
		}
	}
	cout << dp[1][n] << endl;
}

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

int main(){
    int n;
    cin >> n;
    set <int> s;
    rep(i,n){
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}


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

inline int readint(){
	int cnt=0; char c=getchar();
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9') cnt=cnt*10+c-'0',c=getchar();
	return cnt;
}

inline bool ok(int x){
	return x==1||x==5||x==9;
}

int main(){
	int a,sum=0,cnt=0;
	for(int i=1;i<=9;i++){
		a=readint();
		if(ok(i)) cnt+=a; sum+=a;
	}
	if(sum==cnt*3) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n;
  cin>>n;
  ll a[n+2];
  for(ll i=1;i<n+1;i++)cin>>a[i];
  a[0]=0;
  a[n+1]=1000000000;
  bool count=true;
  for(ll i=0;i<n+1;i++){
    if(a[i]>a[i+1]){
      count=false;
      break;
    }
    else{
      if(a[i]+1<=a[i+1])a[i+1]--;
    }
  }
  if(count)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;

#define MAXN 200000

char c[MAXN + 5];

void scan(int &x) {
    x = 0;

    char c = getchar();
    int f = 1;

    while ('0' > c || c > '9') {
        if (c == '-') {
            f = -1;
        }

        c = getchar();
    }

    while ('0' <= c && c <= '9') {
        x = x * 10 - '0' + c;

        c = getchar();
    }

    x *= f;

    return;
}

void print(int x) {
    if (x < 0) {
        putchar('-');
        print(0 - x);

        return;
    }

    if (x >= 10) {
        print(x / 10);
    }

    putchar(x % 10 + '0');

    return;
}
int main (){
	int ans = 0;
	
	scanf ("%s", c + 1);
	for (int i = 1; c[i] != '\0'; i ++) {
		ans += (c[i] - '0');
		ans %= 9;
	}
	if (!(bool (ans))) {
		printf ("Yes");
	}
	else {
		printf ("No");
	}
	
	return 0;
}



Measured memory_bytes: 1924
STDIN.each do |l|
  s = Array.new
  l.split(' ').each do |c|
    case c
    when '+','-','*','/'
      a, b = [s.pop, s.pop]
      s.push eval("#{b} #{c} #{a}")
    else
      s.push c.to_f
    end
  end
  puts "%.6f" % s[0]
end

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

class lazy_segtree {
    private:
        int size;
        vector<long long> node,lazy;
    public:
        lazy_segtree(int n_) {
            size=1;
            while (size<n_) size*=2;
            node.resize(2*size, 0);
            lazy.resize(2*size, 0);
        }

        void setlazy(int k,long long v,int l, int r) {
            lazy[k] += v;
            node[k] += v*(r-l);
        }

        void push(int k,int l,int r) {
            if (lazy[k] == 0) return ;
            setlazy(k*2+1,lazy[k],l,(r+l)/2);
            setlazy(k*2+2,lazy[k],(r+l)/2,r);
            lazy[k] = 0;
        }

        void merge(int k){
            node[k]=node[k*2+1]+node[k*2+2];
        }

        void range_add(int queryL,int queryR,int val,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return ;
            if (queryL<=nodeL && nodeR<=queryR) {
                setlazy(k,val,nodeL,nodeR);
                return ;
            }
            else {
                push(k,nodeL,nodeR);
                int nodeM=(nodeL+nodeR)/2;
                range_add(queryL,queryR,val,k*2+1,nodeL,nodeM);
                range_add(queryL,queryR,val,k*2+2,nodeM,nodeR);
                merge(k);
                return ;
            }
        }

        long long get_sum(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return 0;
            if (queryL<=nodeL && nodeR<=queryR) return node[k];
            else {
                push(k,nodeL,nodeR);
                int nodeM=(nodeL+nodeR)/2;
                long long vl=get_sum(queryL,queryR,k*2+1,nodeL,nodeM);
                long long vr=get_sum(queryL,queryR,k*2+2,nodeM,nodeR);
                return vl+vr;
            }
        }
};

int n,q;

int main(){
    cin >> n >> q;
    lazy_segtree ls(n);
    for (int i=0; i<q; i++) {
        int que,s,t,x,idx;
        cin >> que;
        if (que==0) {
            cin >> s >> t >> x;
            ls.range_add(s-1,t,x);
        }
        else {
            cin >> s >> t ;
            cout << ls.get_sum(s-1,t) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
ll a,b,c,k;
ll ans=0;
cin>>a>>b>>c>>k;
if(a>=k)ans=k;
else if (a<k && k<=a+b)ans=a;
else if(a+b<k)ans=a-(k-a-b);
cout<<ans<<endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long binpow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = binpow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return binpow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (long long i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (long long i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(3, -1);
    for (int i = 0; i < m; i++)
    {
        int s, c;
        cin >> s >> c;
        if (a[s - 1] != -1 && a[s - 1] != c)
        {
            cout << "-1\n";
            return 0;
        }
        else
        {
            a[s - 1] = c;
        }
        
    }
    if (a[0] == 0 && n != 1)
    {
        cout << "-1\n";
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] == -1)
        {
            if (i == 0)
            {
                if (n == 1)
                {
                    cout << '0';
                }
                else
                {
                    cout << '1';
                }
            }
            else
            {
                cout << '0';
            }
        }
        else
        {
            cout << a[i];
        }
        
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			string n = Console.ReadLine();
			int num = int.Parse(n);
			string arr = Console.ReadLine();
			string[] a = arr.Split(' ');

			Array.Reverse(a);

			for(int i = 0; i < num; i++)
			{
				Console.Write("{0}", a[i]);
				if(i < num - 1)
				{
					Console.Write(" ");
				}
			}
			Console.WriteLine();
		}
	}
}



Measured memory_bytes: 17952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int n, k;
bool check(vector<int>& v) {
    for(int i = 0; i<n; ++i) {
        if(v[i] != n) return false;
    }
    return true;
}

int main() 
{ 
    fastio
    cin>>n>>k;
    vector<int> a(n);
    for(int i = 0; i<n; ++i) cin>>a[i];
    while(k-- && !check(a)) {
        vector<int> pref(n);
        for(int i = 0; i<n; ++i) {
            pref[max(0, i-a[i])]+=1;
            if(i+a[i] < n-1) {
                pref[i+a[i]+1] -= 1; 
            }
        }

        for(int i = 1; i<n; ++i)
            pref[i] += pref[i-1];

        a = pref;
    }

    for(int i = 0; i<n; ++i) 
        cout<<a[i]<<" ";
    cout<<endl;
} 

Measured memory_bytes: 4880
#include<bits/stdc++.h>
using namespace std;
int main(){
    long int n;
    cin >> n;
    if(n==0)cout << "0" << endl;
    else{
    string S;
    long int i=0;
    long int tmp=2;
    long int hugo = 1;
    while(n!=0L){
        if(n%tmp!=0){
            S.push_back('1');
            n-=((tmp/2)*hugo);
        }
        else S.push_back('0');
        i++;
        hugo*=-1;
        tmp*=2;
    }
    for(int j=S.length()-1;j>=0;j--)cout << S[j];
    cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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 main() {
    ll R, G, B;
    cin >> R >> G >> B;
    ll value = R * 100 + G * 10 + B;
    cout << ((value % 4 == 0) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,a[100001],p=0,a1[100001],a2[100001],ans;
main(){
  cin>>n;
  r(i,n)cin>>a[i];
  r(i,n){
    if(!a[i])p=1e9;
    if(a[i]<0)p=min(p,-a[i]);
    if(a[i]>0)a1[i]=max(a1[i],min(a[i],p));
    p--;
  }
  p=0;
  for(int i=n-1;i>=0;i--){
    if(!a[i])p=1e9;
    if(a[i]<0)p=min(p,-a[i]);
    if(a[i]>0)a1[i]=max(a1[i],min(a[i],p));
    p--;
  }
  r(i,n)ans+=max(a1[i],a2[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
long long k;
cin>>k;
cout<<a[k-1]<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {

  def read(): (Int, Int) = {
    val sc: Scanner = new Scanner(System.in)
    val a, b = sc.nextInt
    sc.close()
    (a, b)
  }


  def solve(a: Int,b: Int): Int = {
    Seq(a+b, a-b, a*b).max
  }


  def main(args: Array[String]): Unit = {
    val (a, b) = read()
    println(solve(a, b))
  }

}


Measured memory_bytes: 25536
slist=list(input())
x,y=map(int,input().split())

vec=[(1,0),(0,1),(-1,0),(0,-1)]

direction_x=True
xlist=[]
ylist=[]
cnt=0
for s in slist:
  if s=="F":
    cnt+=1
  else:
    if direction_x:
      xlist.append(cnt)
    else:
      ylist.append(cnt)
    cnt=0     
    direction_x=not direction_x
else:
  if direction_x:
    xlist.append(cnt)
  else:
    ylist.append(cnt)

x-=xlist[0]
xlist=xlist[1:]
#print(x,y,xlist,ylist)

# check each x,y
dp_x=[]
for _ in range(len(xlist)+1):
  dp_x.append(set())
dp_x[0]={0}
for i in range(1,len(xlist)+1):
  for j in dp_x[i-1]:
    dp_x[i].add(j+xlist[i-1])
    dp_x[i].add(j-xlist[i-1])
#print(dp_x)

dp_y=[]
for _ in range(len(ylist)+1):
  dp_y.append(set())
dp_y[0]={0}
for i in range(1,len(ylist)+1):
  for j in dp_y[i-1]:
    dp_y[i].add(j+ylist[i-1])
    dp_y[i].add(j-ylist[i-1])
#print(dp_y)

#print(dp_x,dp_y)
if x in dp_x[-1] and y in dp_y[-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 270088
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double complex<long double>
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

int G[15][15];

signed main() {
	int N, K;
	cin >> N >> K;

	vector<int> a(N, 0);
	rep(i, N) {
		cin >> a[i];
	}

	
	int ans = LL_HALFMAX;
	// 見えるようにするビルを全探索
	rep(S, 1 << N) {
		int look = 0;
		int cost = 0;
		int nowMax = a[0] - 1;
		rep(i, N) {
			if (nowMax < a[i]) {
				look++;
				nowMax = a[i];
			}
			// ビットが立ってたら編集してよい
			else if ((1LL << i) & S) {
				look++;
				int addCost = nowMax - a[i] + 1;
				nowMax = nowMax + 1;
				cost += addCost;
			}
		}
		if (look >= K) {
			chmin(ans, cost);
		}
	}

	cout << ans << "\n";

	return 0;
}

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

using namespace std;

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

  vector<int> n(3);
  cin >> n[0] >> n[1] >> n[2];
  sort(n.rbegin(), n.rend());
  cout << n[0]*10 + n[1] + n[2] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N,H,W;
	cin>>N>>H>>W;
	cout<<(N-H+1)*(N-W+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,ans;
  cin >> n;
  rep(i,7) {
    if(n >= pow(2,i)) ans = pow(2,i);
  }
  cout << ans;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
using namespace std;
typedef long long ll;

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

  string S;
  cin >> S;

  ll ans = 0;
  ll r, g, b;
  r = g = b = 0;
  REP(i, N)
  {
    switch (S[i])
    {
    case 'R':
      r++;
      break;
    case 'G':
      g++;
      break;
    case 'B':
      b++;
      break;
    }
  }

  ans = r * g * b;
  FOR(i, 0, N - 3)
  {
    FOR(j, i + 1, N - 2)
    {
      ll k = 2 * j - i;
      if (k < N && S[i] != S[j] && S[j] != S[k] && S[k] != S[i])
        ans--;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  
  vector<int> a(A), b(B);
  
  for (int i = 0; i < A; i++) cin >> a.at(i);

  int minA = *min_element(a.begin(), a.end());
//  for (int i = 0; i < A; i++) {
//    if (i < minA) {
//      minA = a.at(0);
//    }
//  }
    
  for (int j = 0; j <B; j++) cin >> b.at(j);

  int minB = *min_element(b.begin(), b.end());  
//  int minB = b.at(0);
//  for (int j = 0; j < B; j++) {
//    if (j < minB) {
//      minB = b.at(0);
//    }
//  }
  
  int minAB = minA + minB; 
  
  vector<int> x(M), y(M), c(M);
  
  for (int k = 0; k < M; k++) {  
  cin >> x.at(k) >> y.at(k) >> c.at(k);
  }
  
  int minm = a.at(x.at(0) - 1) + b.at(y.at(0) - 1) - c.at(0);

  for (int k = 0; k < M; k++) {
    if (a.at(x.at(k) - 1) + b.at(y.at(k) - 1) - c.at(k) < minm) {
      minm = a.at(x.at(k) - 1) + b.at(y.at(k) - 1) - c.at(k);
    }  
  }

  cout << min(minAB, minm) << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,c;cin >> n >> k >> c;
    string s;cin >> s;
    vector<int> sl(n+1),sr(n+1);
    rep(i,n){
        if(s[i]=='o'){
            sl[i+1]=sl[max(0,i-c)]+1;
        }
        else{
            sl[i+1]=sl[i];
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='o'){
            sr[i]=sr[min(n,i+c+1)]+1;
        }
        else{
            sr[i]=sr[i+1];
        }
    }
    rep(i,n){
        if(sl[i]+sr[i+1]<k&&s[i]=='o'){
            cout << i+1 << endl;
        }
    }
}

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

using namespace std;

int main() {
  
  int n;
  cin >> n;
  vector<int> p(n);
  int ans=0;
  
  for (int i = 0; i < n; ++i) {
    cin>>p[i];
  }
  for (int i = 1; i < n-1; ++i) {
    if((p[i-1]<p[i] && p[i]<p[i+1])||(p[i-1]>p[i] && p[i]>p[i+1])){
      ans+=1;
    }
  }

  cout << ans << endl;

}


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

using namespace std;
#define ll long long
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int inf = 1e9 + 9;
const ll linf  = 1ll * inf * inf;
const int N = 500000 + 7;
const int M = 30;
const int multipleTest = 0;
const double pi = acos(-1);

int p[N];
string s[N];
bool chosen[N];
int n, m;

bool is_palin(string s) {
	static int cnt[26];
	rep(i, 0, 26) cnt[i] = 0;
	for(char c : s) cnt[c - 'a']++;
	int one = 0;
	rep(i, 0, 26) one += cnt[i] & 1;
	return one <= 1;
}

bool is_rev(string u, string v) {
	for (int i = 0, j = sz(v) - 1; i < sz(u); ++i, --j)
		if (u[i] != v[j]) return false;
	return true;
}

string col[N];

bool chk[N];
bool f_check() {
	rep(j, 0, m) {
		if (chk[j]) continue;
		rep(t, j + 1, m) if (!chk[t] && is_rev(col[j], col[t])) {
			chk[j] = chk[t] = true;
			break;
		}
		if (!chk[j]) return false;
	}
	return true;
}

bool check() {
	rep(j, 0, m) {
		col[j] = "";
		rep(i, 0, n) col[j] += s[p[i]][j];
	}
	
	if (m & 1) {
		rep(j, 0, m) {
			if (!is_palin(col[j])) continue;
			rep(t, 0, m) chk[t] = false;
			chk[j] = true;
			if (f_check()) return true;
		}
	} else {
		return f_check();
	}
	return false;
}

int u, v;

void go() {
	int lhs = -1;
	rep(i, 0, n) if (!chosen[i]) {
		lhs = i; break;
	}
	
	if (lhs == -1) {
		if (check()) {
			puts("YES");
			exit(0);
		}
		return;
	}
	
	rep(i, lhs + 1, n) if (!chosen[i]) {
		p[u++] = lhs;
		p[v--] = i;
		chosen[lhs] = chosen[i] = true;
		go();
		--u; ++v;
		chosen[lhs] = chosen[i] = false;
	}
	
}

void solve() {
	cin >> n >> m;
	rep(i, 0, n) cin >> s[i];
	rep(i, 0, n) p[i] = -1;
	u = 0; v = n - 1;
	
	if (n & 1) {
		rep(i, 0, n) {
			chosen[i] = true;
			p[n / 2] = i;
			go();
			p[n / 2] = -1;
			chosen[i] = false;
		}
	} else
		go();
	puts("NO");
}



int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//    freopen("out.txt", "w", stdout);
#endif
	int Test = 1;
	if (multipleTest) {
		cin >> Test;
	}
	for(int i = 0; i < Test; ++i) {
		//		printf("Case #%d: ", i + 1);
		solve();
	}
#ifdef _LOCAL_
	cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 9984
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    n = int(input())
    s = input()
    t = input()
    r = len(s)+len(t)
    sl = len(s)
    tl = len(t)
    for i in range(len(s)):
        if i + tl < n:
            continue
        if s[i:] == t[:sl-i]:
            r = i + tl
            break

    return max(r,n)


print(f())


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

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

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

int main() {
  int H,W;
  cin>>H>>W;
  
  string a[110];
  bool goodx[110]={false};
  bool goody[110]={false};
  
  for(int i=0;i<H;++i){
    cin>>a[i];
  }
  
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(a[i][j]=='#'){
        goodx[i]=true;
        goody[j]=true;
      }
    }
  }
  
  for(int i=0;i<H;++i){
    if(goodx[i]){
      for(int j=0;j<W;++j){
        if(goody[j]){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
    
  }
  
}


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

#define ll long long
using namespace std;
const int N = 1e6 + 5, mod = 998244353;
ll a[N];
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
int f(int n)
{
	int x=0;
	while(n%2==0)
	{
		n=n>>1;
		x++;
	}
	return x;
}
int main()
{      
  
  int n,m,i,j,t;
  cin>>n;
  vi a;
  for(i=0;i<n;i++)
  {
  	int x;
  	cin>>x;
  	if(x%2==0)
  	{
  		a.pb(x);
  	}
  }
  
  LL mx=0;
  for(i=0;i<a.size();i++)
  {
  	mx+=f(a[i]);;
  }
  cout<<mx;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;

int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    rep(i,n) cin >> a[i+1];
    
    ll b[n+1];
    rep(i,n+1) b[i]=0;
    vector<ll> ans;
    
    for(ll i=n;i>=1;i--){
        ll hantei=0;
        for(ll j=1;j*i<=n;j++){
            hantei+=b[j*i];
        }
        if(hantei%2==a[i]) b[i]=0;
        else {
            b[i]++;
            ans.pb(i);
        }
    }
    sort(ans.begin(),ans.end());
    kaku(ans.size());
    for(ll i=0;i<ans.size();i++){
        cout << ans[i] << " " ;
    }
}



Measured memory_bytes: 4980
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<set>
#include<cmath>
#include<vector>
using namespace std;

typedef long long LL;
const LL mod=998244353;
typedef vector<LL> vec;
typedef vector<vec> mat;

int  main()
{

    int n,a;
    while(~scanf("%d%d",&n,&a)){
        printf("%d\n",n*n-a);
    }
    return 0;
}


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

using namespace std;

void solve()
{
	int N, Q;
	cin >> N >> Q;
	vector<long> as(N);
	for (int i = 0; i < N; i++) cin >> as[i];

	while(Q--)
	{
		long ans = 0, r = 0, s = 0, x;
		cin >> x;
		for (int l = 0; l < N; l++)
		{
			while(r < N && s+as[r] <= x)
			{
				s += as[r++];
			}
			ans += r-l;
			if (l == r) r++;
			else s -= as[l];
		}
		cout << ans << endl;
	}

}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
    string s;
    cin >> s;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'p') {
            a[i]++;
        }
        a[i] += a[i + 1];
    }

    int gu = 0, pa = 0, win = 0, lose = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'g') {
            if (a[i] > gu) {
                gu++;
            } else if (pa < gu) {
                pa++;
                win++;
            } else {
                gu++;
            }
        } else {
            if (gu - pa > 0) {
                pa++;
            } else {
                gu++;
                lose++;
            }
        }
    }
    cout << win - lose << endl;
}

Measured memory_bytes: 896
#include <vector>
#include <iostream>
using namespace std;
int m, n; string s; vector<int> r;
int main() {
	while(~scanf("%d%d", &m, &n)) {
		if(m == 0 && n == 0) break; int pos = 0; r.clear();
		for(int i = 1; i <= m; i++) r.push_back(i);
		for(int i = 1; i <= n; i++) {
			cin >> s;
			if(i % 15 == 0) {
				if(s != "FizzBuzz" && r.size() != 1) r.erase(r.begin() + pos);
				else pos++;
			}
			else if(i % 3 == 0) {
				if(s != "Fizz" && r.size() != 1) r.erase(r.begin() + pos);
				else pos++;
			}
			else if(i % 5 == 0) {
				if(s != "Buzz" && r.size() != 1) r.erase(r.begin() + pos);
				else pos++;
			}
			else {
				if(s != to_string(i) && r.size() != 1) r.erase(r.begin() + pos);
				else pos++;
			}
			pos %= r.size();
		}
		for(int i = 0; i < r.size(); i++) {
			if(i) printf(" ");
			printf("%d", r[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n;
	long long k;
	cin >> n >> k;

	vector<long long> as(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> as[i];
	}


	long long x = 0;
	for (int i = 50; i >= 0; i--) {
		long long tmp = x + (1LL << i);

		if (tmp > k) {
			continue;
		}

		vector<int> bits(2, 0);
		for (auto a: as) {
			bits[(a >> i) & 1]++;
		}

		if (bits[0] > bits[1]) {
			x = tmp;
		}
	}

	long long ans = 0;
	for (auto a: as) {
		ans += x ^ a;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    string a, b;
    cin >> a >> b;

    string s = a + b;
    int ans;

    ans = atoi(s.c_str());

    bool flag = false;
    for(int i=1; i < 1000; i++){
        if(i*i==ans){
            flag = true;
            break;
        }
    }

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

    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << n / 3 << '\n';

    return 0;
}


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

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

const int N = int(1e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

string s;
int main (){
    cin >> s;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < sz(s); ++i){
        if (i & 1){
            if (s[i] != '1') cnt1++;
            else cnt2++;
        }
        else {
            if (s[i] != '1') cnt2++;
            else cnt1++;
        }
    }
    return !printf ("%d\n", min(cnt1, cnt2));
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long N,K,b,p,r,a;
int main() {
  cin>>N>>K;
  if(K==0){
    cout<<N*N<<endl;;
    return 0;
  }
  for(b=1;b<=N;b++){
    p=N/b;
    r=N%b;
    a+=p*max(0L,b-K)+max(0L,r-K+1);
  }
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 256
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}

	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		//LinkedList<Integer> ll = this.;
		for(int i=0; i<totalVertex; i++) {
			LinkedList<Integer> vertexes = this.adjList.get(i);
			for(int j=0; j<totalVertex; j++) {				
				if(vertexes.contains(j)) {
					adjMatrix[i][j] = 1;
					System.out.print("1");
				}else {
					adjMatrix[i][j] = 0;
					System.out.print("0");
				}
				if(j!= totalVertex -1) {
					System.out.print(" ");
				}
			}
//			if(i<totalVertex-1) {
				System.out.println();
//			}
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


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

int main()
{
 int K;
  cin >> K;
  int a = 7;
  int c = 1;
  int q = K % 2;
  int w = K % 5;
  if ( q == 0 || w == 0) {
    cout << -1 << endl;
                         }
  
  else {
    
  while ( true ){
    
    a = a % K;
   
     if ( a == 0 ){
       cout << c << endl;
       break;
                   }        
     else {
      a = a*10 + 7;
      c++;
          }
    
                 }
    
        }
  
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    for(int i = k; i < n; i ++){
        if(a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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

int main(){
	int A, B, T;
	cin >> A >> B >> T;
	int count = 0;
	int time = 0;
  
	while(time < T + 0.5){
		time += A;
		count += B;
	}
	
	cout << count - B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mpi map<int,int>
#define mpl map<ll,ll>
#define umpi unordered_map<int,int>
#define umpl unordered_map<ll,ll>
#define si set<int>
#define sl set<ll>
#define msi multi_set<int>
#define msl multi_set<ll>

#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    ll n;
    cin>>n;
    ll k=n/1000;
    if(n%1000!=0)
    k++;
    ll ans=k*1000-n;
    cout<<ans<<nl;
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>  
#include <cstring>  
#include <cmath>  
#include <sstream>  
#include <iostream>  
#include <algorithm>  
#include <string>  
#include <stack>  
#include <queue>  
#include <vector>  
#include <map>  
#include <set>  
#include <utility>  
   
using namespace std;  
#define LL long long  
#define pb push_back  
#define mk make_pair  
#define pill pair<int, int>  
#define ft first  
#define sd second  
#define mst(a, b)   memset(a, b, sizeof a)  
#define REP(i, x, n)    for(int i = x; i <= n; ++i)  
const int qq = 1e5 + 10;  
const int MOD = 1e9 + 7;  
LL num[60];  
LL p[qq];  
int main(){  
    LL n;   scanf("%lld", &n);  
    for(int i = 0; i < n; ++i) {  
        scanf("%lld", num + i);  
    }  
    LL k = 0;  
    while(1) {  
        int cnt = 0;  
        for(int i = 0; i < n; ++i) {  
            if(num[i] <= n - 1)  cnt++;  
        }  
        if(cnt >= n) break;  
        LL sum = 0;  
        for(int i = 0; i < n; ++i) {  
            p[i] = num[i] / n;  
            sum += p[i];  
        }  
        k += sum;  
        for(int i = 0; i < n; ++i) {  
            num[i] = num[i] - p[i] * n + (sum - p[i]);  
        }  
    }  
    printf("%lld\n", k);  
    return 0;  
}  

Measured memory_bytes: 256
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n, l;
	cin >> n >> l;
	int*a = new int[n + 1];
	int sum = 0;
	for (int i = 1; i <= n; i++)
		a[i] = (i+l)-1,sum+=a[i];
	int ans = INF,sub=0;
	for (int i = 1; i <= n; i++)
	{
		if (abs(a[i]) < ans)
		{
			ans = abs(a[i]);
			sub = a[i];
		}
	}
	cout << sum - sub << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

char in[200];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> in;
    if (in[0] != 'Y') printf("No\n");
    else if (in[1] != 'A') printf("No\n");
    else if (in[2] != 'K') printf("No\n");
    else if (in[3] != 'I') printf("No\n");
    else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
x=input()
p=0
for i in x:
    if i=="1":
        p+=1
rp=0
rq=0
for i in range(n):
    if x[i]=="1":
        rp+=pow(2,(n-1-i),p+1)
        rp%=p+1
        if p!=1:
          rq+=pow(2,(n-1-i),p-1)
          rq%=p-1
        else:
          rq=pow(2,(n-1-i))
def popcnt1(n):
    return bin(n).count("1")
res=[0]*n

for i in range(1,n+1):
    res[i-1]=i%popcnt1(i)

for i in range(n):
    ans=0
    if x[i]=="1":
        if p==1:
          print(0)
          continue
        q=rq-pow(2,(n-1-i),p-1)
        q%=p-1
        while True:
            if q==0:
                print(1+ans)
                break
            ans+=1
            q=res[q-1]
    else:
        q=rp+pow(2,(n-1-i),p+1)
        q%=p+1
        while True:
            if q==0:
                print(1+ans)
                break
            ans+=1
            q=res[q-1]

Measured memory_bytes: 80640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 1e12;
const ll MOD = 1000000000 + 7;
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define mii map<int, int>
#define mci map<char, int>
#define mll map<ll, ll>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << "debug: " << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  ll x;
  cin >> x;
  ll p = 0;
  p = x / 11;
  ll ans = 2 * p;

  if (x - p * 11 > 0) {
    ans++;
    if (x - p * 11 > 6) ans++;
  }
  out(ans);
}
int main(void) { solve(); }


Measured memory_bytes: 3640