akhauriyash/Code-Regression huggingface dataset:
/**
 *    Author:  "Robin Singh" !!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0
#define rtn return 
#define nl "\n"      // avoid endl
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const ll INF = (1LL<<61);
const int inf = (1<<30);
//-------------------------------------------------------------------------------------------------------------
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//-------------------------------------------------------------------------------------------------------------

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    str s[n];
    fr(i, 0, n) cin >> s[i];
    int r[n], c[m];
    for(int i=0; i<n; i++){
        bool ok = 1;
        fr(j, 0, m){
            if(s[i][j] != '.') ok = 0;
        }
        if(ok) r[i] = 0;
        else r[i]  = 1;
    }
    fr(i, 0, m){
        bool ok = 1;
        fr(j, 0, n){
            if(s[j][i] != '.') ok = 0;
        }
        if(ok) c[i] = 0;
        else c[i] = 1;
    }
    fr(i, 0, n){
        fr(j, 0, m){
            if(!r[i]) s[i][j] = '0';
        }
    }
    fr(i, 0, m){
        fr(j, 0, n){
            if(! c[i]) s[j][i] = '0';
        }
    }
    fr(i, 0, n){
        bool ok = 0;
        fr(j, 0, m){
            if(s[i][j] != '0') cout << s[i][j], ok = 1;
        }
        if(ok) cout << nl;
    }
    return 0;
}

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

int main() {
    cout << fixed << setprecision(10);
    
    int n, q;
    cin >> n;
    vector<int> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    cin >> q;
    vector<int> t(q);
    rep(i, q) {
        cin >> t[i];
    }
    // sort(t.begin(), t.end());
    sort(s.begin(), s.end());
    s.emplace_back(1e5+1);
    int ans = 0;
    rep(i, q) {
        int tt = t[i];
        // cout << "tar" << tt << endl;
        int l = 0;
        int r = n;
        while(l+1 < r) {
            int c = (l+r) / 2;
            // cout << c << endl;
            if (s[c] <= tt) {
                l = c;
            } else {
                r = c;
            }
        }
        // cout << "res " << s[l] << s[r] << endl;
        if (s[l] == tt || s[r] == tt) {
            // cout << "sum" << tt << endl;
            ans += 1;
        } 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)3e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

int st[N*10];
void update(int i,int val) {
  st[i] = val;
  for(i>>=1;i>0;i>>=1) {
    st[i] = max(st[i<<1],st[i<<1|1]);
  }
}
int max_range(int l, int r) {
  int ret = 0;
  for(;l<r;l>>=1,r>>=1) {
    if(l&1) ret = max(ret,st[l++]);
    if(r&1) ret = max(ret,st[--r]);
  }
  return ret;
}
void solve() {
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  int ans = 1;
  REP(i,0,n-1) {
    cin>>a[i];
    int len = 1 + max_range(a[i]+N*6-k,a[i]+N*6+k+1);
    ans = max(ans,len);
    update(a[i]+6*N,len);
  }
  cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    // cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 6900
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;

const double PI  = 3.141592653589793238463;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int af = 1, bf = 0, cf = 0;
    char top = a[0];
    while(true){
        if(top == 'a'){
            if (af == a.size())
            {
                cout << "A";
                break;
            }
            top = a[af];
            af++;
        }
        else if(top == 'b'){
            if (bf == b.size())
            {
                cout << "B";
                break;
            }
            top = b[bf];
            bf++;
        }
        else{
            if (cf == c.size())
            {
                cout << "C";
                break;
            }
            top = c[cf];
            cf++;
        }
    }
    cout << endl;
}


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

std::string o, e;

int main(){
	std::cin >> o >> e;
	for(int i=0; i<o.size(); ++i){
		std::cout << o[i];
		if(i < e.size()) std::cout << e[i];
	}
	std::cout << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    char a[x+2][y+2];
    for(size_t i = 0; i < x+2; i++)
    {
        if(i==0||i==x+1){
            for(size_t j = 0; j < y+2; j++)
            {
                a[i][j] = '#';
            }
        }
        else{
            for(size_t j = 0; j < y+2; j++)
            {
                if(j==0||j==y+1){
                    a[i][j] = '#';
                }
                else{
                    cin >> a[i][j];
                }
            }
        }
    }
    
    for(size_t i = 0; i < x+2; i++)
    {
        for(size_t j = 0; j < y+2; j++)
        {
            cout << a[i][j] ;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.numeric;

ulong[100] TS;

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

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        TS[i] = readln.chomp.to!ulong;
    }
    auto res = TS[0];
    foreach (t; TS[1..N]) {
        res = lcm(res, t);
    }
    writeln(res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int k;
vector<string>vs;
int main(){
	cin>>s>>k;
	for(int i=1;i<=s.size()&&i<=k;i++){
		for(int j=0;j<=s.size()-i;j++){
			string st=s.substr(j,i);
			vs.push_back(st);
		}
	}
	sort(vs.begin(),vs.end());
	int s=1;
	string ans=vs[0];
	for(int i=1;s<k;i++){
		if(vs[i]!=ans)s++,ans=vs[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1660
N=int(input())#入力回数を決める
import fractions
from functools import reduce
li=[]
for i in range(N):
  li.append(int(input()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(li))

Measured memory_bytes: 5076
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>
using namespace std;
typedef long long          ll;
typedef unsigned long long ull;
typedef long double        ld;
typedef pair<int,int>      pii;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
typedef vector<long long>  vll;
#define left(x)		   (x << 1)
#define right(x) 	   (x << 1) + 1
#define mid(l, r) 	   ((l + r) >> 1)
#define mp                 make_pair
#define pb                 push_back
#define all(a)             a.begin(),a.end()
#define debug(x)	   {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define ss                 second
#define ff                 first
#define m0(x) 		   memset(x,0,sizeof(x))

template<typename T >T min_ ( T a , T b ) { return a > b ? b : a ; }
template < typename T ,  typename... Ts > T min_( T first , Ts... last ){ return  min_(first, min_(last...)); }
template<typename T >T max_ ( T a , T b ) { return a > b ? a : b ; }
template < typename T ,  typename... Ts > T max_( T first , Ts... last ){ return  max_(first, min_(last...)); }

template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
    out << "["; size_t last = v.size() - 1; for(size_t i = 0; i < v.size(); ++i) {
    out << v[i]; if (i != last) out << ", "; } out << "]"; return out;
}
const int mod = 1e9+7;

ll pwr(ll base, ll p){
ll ans = 1; while(p) { if(p&1) ans=(ans*base)%mod; base=(base*base)%mod; p/=2; } return ans;
}
ll gcd(ll a, ll b) {  return b == 0 ? a : gcd(b,a%b); }
ll lcm(ll a, ll b) {  return a*(b/gcd(a,b)); }

const long double PI = (long double)(3.1415926535897932384626433832795);
const ll  mx_ll   = numeric_limits<ll> :: max();
const int mx_int  = numeric_limits<int> :: max();

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

    set<string> st;
   int n; cin >> n;
   for(int i = 0; i < n; ++i) {
       string s; cin >> s;
       st.insert(s);
   }
   cout << st.size() << endl;
      return 0;
}


Measured memory_bytes: 19136
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    int n = 0;
    char cur = 'A';
    cin >> str;
    for(string::iterator it = str.begin(); it != str.end(); it++){
        if(*it == cur) {
            n++;
            continue;
        }
        while(*it != cur) {
            if(cur == 'Z') {
                cur = 'A';
                n+=1;
            } else {
                cur += 1;
            }
        }
    }
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	string a = "keyence";
	int x = 0;
	string temp;
	bool answer = true;
	if (s.size() < 7) {cout << "NO" << endl; return 0;}
	for (int z=0;z<=7;z++){
		temp = s.substr (0,7-z);
		temp += s.substr (s.size()-z,z);
		if (temp == "keyence") {cout << "YES" << endl; answer = false;break;}
	}
	if (answer) {cout << "NO" << endl;}
}

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

typedef struct node{
    int a;
    int b;
}node;

int asc(const void* x, const void* y){
    return ((node*)x)->a - ((node*)y)->a;
}

void swap(node* x, node* y){
    if(x == y){
        return ;
    }
    node z = *x;
    *x = *y;
    *y = z;
}

void push(node* a, int* l, node b){
    *(a+*(l)) = b;
    *l += 1;
    int x = *l;
    while(x > 1){
        if((a+(x/2)-1)->b < (a+x-1)->b){
            //printf("%d %d <-> %d %d\n", (a+(x/2)-1)->a, (a+(x/2)-1)->b, (a+x-1)->a, (a+x-1)->b);
            swap(a+(x/2)-1, a+x-1);
        }
        x = x/2;
    }
}

node pop(node* a, int* l){
    node dst = *a;
    int x=1;
    swap(a, a+*(l)-1);
    *l -= 1;
    while(x <= (*(l)-1)/2){
        if((a+(2*x)-1)->b < (a+(2*x)+1-1)->b){
            if((a+x-1)->b < (a+(2*x)+1-1)->b){
                swap(a+x-1, a+(2*x)+1-1);
            }
            x = 2*x+1;
        }else{
            if((a+x-1)->b < (a+(2*x)-1)->b){
                swap(a+x-1, a+(2*x)-1);
            }
            x = 2*x;
        }
    }
    if(*l > 0 && (*l)%2 == 0){
        if(x == (*l)/2 && (a+x-1)->b < (a+*(l)-1)->b){
            swap(a+x-1, a+*(l)-1);
        }
    }
    return dst;
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    node t[n];
    for(int i=0; i<n; i++){
        int a, b;
        scanf("%d%d", &a, &b);
        t[i].a = a;
        t[i].b = b;
    }
    qsort(t, n, sizeof(node), asc);
    /*printf("\n");
    for(int i=0; i<n; i++){
        printf("%d %d\n", t[i].a, t[i].b);
    }*/
    int l = 0, target = 0;
    node p[n];
    long long int ans = 0;
    for(int i=1; i<=m; i++){
        if(target < n){
            while(t[target].a <= i){
                /*printf("\n\n--before--\n");
                for(int i=0; i<l; i++){
                    printf("%d %d\n", p[i].a, p[i].b);
                }
                printf("--swap--\n");*/
                push(p, &l, t[target]);
                /*printf("--after--\n");
                for(int i=0; i<l; i++){
                    printf("%d %d\n", p[i].a, p[i].b);
                }*/
                target++;
                if(target == n){
                    break;
                }
            }
        }
        if(l > 0){
            ans += pop(p, &l).b;
        }
    }
    /*printf("\n");
    for(int i=0; i<l; i++){
        printf("%d %d\n", p[i].a, p[i].b);
    }*/
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
//#define double long double
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii > pip;
typedef pair<pii, pii > piipii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define all(vec) vec.begin(), vec.end()
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60)
#define mod 1000000007
#define se second
#define fi first

int N, Q;

int par[10100];
int siz[10100];

void init(){
    for(int i = 0; i < N; i++){
        par[i] = i;
        siz[i] = 1;
    }
}

int root(int x){
    if(x == par[x]){
        return x;
    }
    return par[x] = root(par[x]);
}

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

bool unite(int x, int y){
    if(same(x, y)){
        return false;
    }
    x = root(x);
    y = root(y);
    if(siz[x] >= siz[y]){
        par[y] = x;
        siz[x] += siz[y];
        siz[y] = 0;
    }
    else {
        par[x] = y;
        siz[y] += siz[x];
        siz[x] = 0;
    }

    return true;
}

signed main(){
    cin >> N >> Q;
    init();
    for(int i = 0; i < Q; i++){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            unite(x, y);
            //cout << "___________________" << siz[root(x)] << endl;
        }
        else {
            cout << same(x, y) << endl;
        }
    }
    
    return 0;
}

/*

*/


Measured memory_bytes: 3240
# 最大利益を算出するプログラム

# 入力する数を取得する
n = STDIN.gets.chomp.to_i

# 配列を初期化する
data = []
# 個数分入力する
for i in 0..n-1
    data[i] = STDIN.gets.chomp.to_i
end

# 最大利益を求める
minv = data[0]
maxv = data[1] - data[0]
for j in 1..n-1
    maxv = (maxv > (data[j] - minv)?  maxv : data[j] - minv)
    minv = (minv > data[j]? data[j] : minv)
end

# 最大利益を出力する
puts "#{maxv}"



Measured memory_bytes: 8544
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

type Ans = String

-- h <= n <= w として
--4*h <= 3*N
--4*w >= 3*N

solve :: Int -> Ans
solve n = let
  infs = [max 1 (n`div`4)..3*(n+1)`div`4]
  sups = [3*n`div`4 .. 3500]
  ((h',n',w'):ans) = traceShowId {-find (\xs -> xs /= Nothing)-} [(h,h*w*n `div` (4*h*w-n*w-n*h),w) | h <- infs, w <- sups, 4*h*w-n*w-n*h /= 0, h*w*n `div` (4*h*w-n*w-n*h) > 0 ,h*w*n == (h*w*n `div` (4*h*w-n*w-n*h))*(4*h*w-n*w-n*h)]
  in (show h') ++ " " ++ (show n') ++ " " ++ (show w')

main :: IO ()
main = putStrLn . main0 =<< B.getContents

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

main0 :: B.ByteString -> Ans
main0 cont =
   let remLines0 = map B.words (B.lines cont)
       [n']:remLines1 = remLines0
       n = readBInt n'
   in solve n


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

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

int main(){
	ll n, m;
	scanf("%lld%lld", &n, &m);
	if(n < m)
		swap(n, m);

	if(n >= 2 && m >= 2)
		printf("%lld\n", (n - 2) * (m - 2));

	if(n >= 2 && m == 1)
		printf("%lld\n", n - 2);

	if(n == 1 && m == 1)
		printf("1\n");

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif


typedef long long lint;

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

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



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

	lint x; cin >> x;
	lint ans = 2 * (x / 11);
	x %= 11;
	if (!x)ans--;
	if (x > 6)ans++;
	co(ans+1);
	gc();
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
#include <boost/algorithm/string.hpp>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pv(vector<int> V){
    for(auto v : V){
        cout << v << " ";
    }
    cout << endl;
}

bool dp_x[4010][16010];
bool dp_y[4010][16010];

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

    // input
    string s;
    cin >> s;

    int x, y;
    cin >> x >> y;

    // distances
    vector<int> X;
    vector<int> Y;

    // 原点 8000, 8000からスタートするとする
    // ゴールも移動
    x += 8000;
    y += 8000;

    // split
    vector<string> results;
    string delim = "T";
    boost::split(results, s, boost::is_any_of(delim));
    
    bool isTurnX = true;
    for(auto s : results){
        int d = s.size();
        if(isTurnX){
            X.push_back(d);
        }else{
            Y.push_back(d);
        }
        isTurnX = !isTurnX;
    }

    // Tが存在しない場合
    if(Y.size()==0){
        int d = X[0];
        if(8000+d == x){
            p("Yes");
            return 0;
        }else{
            p("No");
            return 0;
        }
    }

    FOR(i, 0, 4010){
        FOR(j, 0, 16010){
            dp_x[i][j] = false;
            dp_y[i][j] = false;
        }
    }

    // X
    int d = X[0];
    dp_x[0][d+8000] = true;
    FOR(i, 1, X.size()){
        int d = X[i];
        FOR(j, 0, 16010){
            if(dp_x[i-1][j-d] || dp_x[i-1][j+d]){
                //cout << "キタ" << d << " " << j << endl;
                dp_x[i][j] = true;
            }
        }
    }
    // 判定
    bool isXReachable;
    if(dp_x[X.size()-1][x]){
        isXReachable = true;
    }else{
        isXReachable = false;
    }

    // Y
    d = Y[0];
    dp_y[0][8000+d] = true;
    dp_y[0][8000-d] = true;
    FOR(i, 1, Y.size()){
        int d = Y[i];
        FOR(j, 0, 16010){
            if(dp_y[i-1][j-d] || dp_y[i-1][j+d]){
                dp_y[i][j] = true;
            }
        }
    }
    bool isYReachable;
    if(dp_y[Y.size()-1][y]){
        isYReachable = true;
    }else{
        isYReachable = false;
    }

    if(isXReachable && isYReachable){
        p("Yes");
    }else{
        p("No");
    }

    return 0;
}

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

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    
    long long product = a * c;
    product = max(product, a*d);
    product = max(product, b*c);
    product = max(product, b*d);
    cout << product << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define N 10000
#define Q 500

int main(){
	int n,q,s[N],t[Q];
	int sum=0;
	cin >> n;
	for(int i=0; i<n; ++i){
		cin >> s[i];
	}
	cin >> q;
	for(int i=0; i<q; ++i){
		cin >> t[i];
	}
	for(int i=0; i<q; ++i){
		for(int j=0; j<n; ++j){
			if(t[i] == s[j]){
				++sum;
				break;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;

const ll mod = 1000000007;

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

  ll dp[n + 1][k + 1];
  dp[0][0] = 1;
  REP(j, 1, k + 1) dp[0][j] = 0;
  REP(i, 1, n + 1) {
    dp[i][0] = 1;
    REP(j, 1, k + 1) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      if (j > a[i - 1]) dp[i][j] -= dp[i - 1][j - a[i - 1] - 1];
      while (dp[i][j] < 0) dp[i][j] += mod;
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][k] << endl;
}

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

int main(void)
{
  // input
  int n, W;
  std::cin >> n >> W;
  int weight[n], value[n];
  for ( int i = 0; i < n; i++ ) std::cin >> value[i] >> weight[i];

  // DP table
  int dp[n+1][W+1];
  for ( int w = 0; w <= W; w++ ) {
    dp[0][w] = 0;
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int w = 0; w <= W; w++ ) {
      if ( weight[i] <= w ) {
        dp[i+1][w] = std::max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      } else {
        dp[i+1][w] = dp[i][w];
      }
    }
  }

  std::cout << dp[n][W] << std::endl;
  return 0;
}



Measured memory_bytes: 7028
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	int n,k;
    cin>>n>>k;
    cmbset(200003);
    int m=min(n-1,k);
    LL ans=1;
    FOR(i,1,m+1){
        ans=add(ans,mul(cmb(n,i),homo(n-i,i)));
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b, q;
    ll s[112345], t[112345], x[112345];

    cin >> a >> b >> q;
    REP(i, a)
    cin >> s[i + 1];
    REP(i, b)
    cin >> t[i + 1];
    REP(i, q)
    cin >> x[i];

    ll ma = 1e15;
    ll mi = -1e15;

    s[0] = mi;
    t[0] = mi;

    s[a + 1] = ma;
    t[b + 1] = ma;

    REP(i, q)
    {
        ll tj = 0;
        ll jt = 0;

        //寺まで
        int xti = lower_bound(s, s + a + 2, x[i]) - lower_bound(s, s + a + 2, mi);

        int tji = lower_bound(t, t + b + 2, s[xti]) - lower_bound(t, t + b + 2, mi);

        tj = abs(s[xti] - x[i]) + min(abs(s[xti] - t[tji]), abs(s[xti] - t[tji - 1]));

        tji = lower_bound(t, t + b + 2, s[xti - 1]) - lower_bound(t, t + b + 2, mi);

        tj = min(tj, abs(s[xti - 1] - x[i]) + min(abs(s[xti - 1] - t[tji]), abs(s[xti - 1] - t[tji - 1])));

        //神社まで
        int xji = lower_bound(t, t + b + 2, x[i]) - lower_bound(t, t + b + 2, mi);

        int jti = lower_bound(s, s + a + 2, t[xji]) - lower_bound(s, s + a + 2, mi);

        jt = abs(t[xji] - x[i]) + min(abs(t[xji] - s[jti]), abs(t[xji] - s[jti - 1]));

        jti = lower_bound(s, s + a + 2, t[xji - 1]) - lower_bound(s, s + a + 2, mi);

        jt = min(jt, abs(t[xji - 1] - x[i]) + min(abs(t[xji - 1] - s[jti]), abs(t[xji - 1] - s[jti - 1])));

        cout << min(tj, jt) << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;

}

void solve()
{
	
	string s;
	cin >> s;
	reverse(all(s));
	if(s[0] == '1' || s[0] == '6' || s[0] == '0' || s[0] == '8') cout << "pon";
	else if(s[0] == '3') cout << "bon";
	else cout << "hon";
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	// precalc();
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int N;
        char word[100][11];
        char a,f =0;
scanf("%d",&N);
scanf("%s",&word[0] );
for (int i = 1; i < N; i++) {
  scanf("%s",&word[i] );
  for (int j = 0; j < 11; j++) {
    if (word[i-1][j]=='\0') {
      break;
    }
    a=word[i-1][j];
  }
if (a!=word[i][0]) {
  printf("No\n" );
  return 0;
  
}
for (int j = 0; j < i; j++) {
  if (strcmp(word[i],word[j])==0) {
    printf("No\n" );
    return 0;
  }
}
}
printf("Yes\n" );

        return 0;
}

Measured memory_bytes: 128
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 500010;

ll n;
ll A[maxn], lst[maxn];
set<ll> digits[10];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // ifstream cin(".in");

    string s;
    cin >> s;
    n = s.size();
    fori (i, n) A[i] = s[i] - '0', digits[A[i]].insert(i);
    ll ans = 1;
    fori (i, n - 1) {
        ll k = maxn;
        fori (d, 10) if (d != A[i]) {
            auto it = digits[d].lower_bound(i);
            if (it != digits[d].end()) smin(k, *it);
        }
        if (k == maxn) break;
        if (A[k - 1] > A[k]) {
            ++ans;
            ll j = n - 1;
            while (A[j] == 9) {
                digits[A[j]].erase(j);
                A[j] = 0;
                digits[A[j]].insert(j);
                --j;
            }
            digits[A[j]].erase(j);
            ++A[j];
            digits[A[j]].insert(j);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 29072
#include <cstdio>
using namespace std;
int main(){
	char str[3];
	scanf("%s",str);
	bool test1(false),test2(false);
	for(int i=0;i<=3;i++){
			if(str[i]=='A')test1 = true;
			if(str[i]=='B')test2 = true;
		}
	if(test1 && test2)printf("Yes");
	else printf("No");	
	return 0;
	}


Measured memory_bytes: 1704
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n;cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  int cnt = 0;
  map<string,int> mp;
  rep(i,n) {
    if(mp[s[i]] == 0) cnt++;
    mp[s[i]]++;
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 25076
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  int ans=0;
  cin>>s;
  for(int i=0;i<4;i++){
    if(s[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout<<ans<<"\n";
  return 0;
}

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

namespace Combination{
    const int MAX = 510000;

    ll fac[MAX], finv[MAX], inv[MAX];

    void combination_init(){
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for( int i = 2; i < MAX; i++ ){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * ( MOD / i ) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll comb( int n, int k ){
        if ( n < k ) return 0;
        if ( n < 0 || k < 0 ) return 0;
        return fac[n] * ( finv[k] * finv[n - k] % MOD ) % MOD;
    }
}

using namespace Combination;

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

    map<int, int> cnt;
    for( int i = 2; i * i <= M; i++ ){
        while( M % i == 0 ){
            cnt[i]++;
            M /= i;
        }
    }
    if( M > 1 ) cnt[M]++;

    combination_init();

    ll ans = 1;
    for( auto p : cnt ){
        ans *= comb( p.second + N - 1, p.second );
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i,j;
    cin>>n;
    ll arr[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        cin>>arr[i][j];
    }
    ll dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            dp[i][j]=0;
            for(ll k=0;k<3;k++)
            {
                if(k==j)
                continue;
                else
                dp[i][j]=std::max(dp[i][j],arr[i][j]+dp[i-1][k]);
            }
        }
    }
    ll ans=std::max(dp[n-1][0],dp[n-1][1]);
    ans=std::max(ans,dp[n-1][2]);
    cout<<ans<<endl;

    
    

 
    return 0;
    
}
    



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

int main(){
    int N;
    cin >> N;
    long long m1 = 0,m2 = 0;
    vector<long long> A(N); 
    for(int i = 0;i < N;++i){
        cin >> A[i];
        if(A[i] >= m1){
            m2 = m1;
            m1 = A[i];
        }else if(A[i] >= m2){
            m2 = A[i];
        }
    }
    for(int i = 0;i < N;++i){
        if(A[i] == m1) cout << m2 << endl;
        else cout << m1 << endl;
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(a) cerr << #a << ": " << a << endl
#define endl '\n'
#define int long long

const int N = 5e5+5;
const int MAXN=1e7+1;

int n;
int a[N];
int cache[N];

int dp(int idx)
{
      if(idx>n) return 1e12;
      if(idx==n) return  0;

      int &res = cache[idx];
      if(res!=-1) return res;

      res = abs(a[idx]-a[idx+1]) + dp(idx+1);
      res = min(res, abs(a[idx]-a[idx+2])+dp(idx+2));

      return res;
}

int32_t main()
{
      IOS;

      cin>>n;
      for(int i=1;i<=n; i++) cin>>a[i];

      memset(cache,-1, sizeof cache);
      int ans =dp(1);
      cout<<ans;


      return 0;
}


Measured memory_bytes: 9472
from collections import Counter
m1=0
N=int(input())
A=Counter(list(map(int,input().split())))
key=sorted(A.keys(),reverse=True)
for i in key:
  if A[i]>1 and m1==0:
    m1=i
    if A[i]>3:
      print(i**2)
      exit()
  elif m1!=0 and A[i]>1:
    print(m1*i)
    exit()
print(0)

Measured memory_bytes: 18600
def get_digit(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans


def is_palindromic(n):
    digit = get_digit(n)
    while n > 0:
        if (n % 10) == (n // 10**(digit - 1)):
            n %= 10**(digit - 1)
            n //= 10
            digit -= 2
        else:
            return False
    else:
        return True


A, B = map(int, input().split())
ans = 0
for i in range(A, B + 1):
    ans += 1 if is_palindromic(i) else 0
print(ans)


Measured memory_bytes: 3064
from datetime import datetime
ts = '%H:%M:%S'
while(True):
    n = int(input())
    if n == 0:
        break
    ipt = [None]*n
    for i in range(len(ipt)):
        ipt[i] = list(map(lambda x: datetime.strptime(x,ts),input().split()))
    ipt = sorted(ipt)
    l = [datetime.strptime('00:00:00',ts)]
    for i in range(len(ipt)):
        for j in range(len(l)):
            if l[j] <= ipt[i][0]:
                l[j] = ipt[i][1]
                break
        else:
            l.append(ipt[i][1])
    print(len(l))
    


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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),ans=0;
    vector<int> l(n);
    for (int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end());
    for (int i=0;i<n-2;i++){
        for (int i2=i+1;i2<n-1;i2++){
            for (int i3=i2+1;l[i3]<l[i]+l[i2];i3++){
                if (l[i]<l[i2]+l[i3] && l[i2]<l[i]+l[i3]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int n, m; cin >> n >> m;
    VI x(m); rep(i, m) cin >> x[i];
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(ALL(x));

    VI diff(m-1);
    rep(i, m-1){
        diff[i] = x[i+1] - x[i];
    }
    sort(diff.begin(), diff.end(), greater<ll>());
    //PRINT(diff);
    ll ans = *max_element(ALL(x)) - *min_element(ALL(x));

    rep(i, n-1) ans -= diff[i];
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 4604
N = int(input())
a = list(map(int, input().split()))

res = [0] * (N+1)
for i in range(1, N+1)[::-1]:
    cnt = 0
    for j in range(i, N+1, i):
        cnt += res[j]
    if cnt % 2 != a[i-1]:
        res[i] = 1

print(sum(res))
ans = []
for i, ele in enumerate(res):
    if ele == 1:
        ans.append(i)
print(' '.join(map(str, ans)))

Measured memory_bytes: 80104
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,k;
ll a[555];
priority_queue<ll,vector<ll>,greater<ll> >q;
int main()
{
    ll ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<=min(n,k);i++)
        for(int j=0;i+j<=min(n,k);j++)
    {
        for(int h=1,t=1;h<=i;h++,t++)
            q.push(a[t]);
        for(int h=1,t=n;h<=j;h++,t--)
            q.push(a[t]);
        int p=k-i-j;
        while(!q.empty()&&p>0&&q.top()<0)
        {
            q.pop();
            p--;
        }
        ll res=0;
        while(!q.empty())
        {
            res+=q.top();
            q.pop();
        }
        ans=max(ans,res);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
from collections import deque,Counter

SA = deque(list(input()))
SB = deque(list(input()))
SC = deque(list(input()))

turn = "a"
while len(SA)>=0 or len(SB)>=0 or len(SC)>=0:
    if turn == "a":
        if len(SA) == 0:
            print("A")
            exit()
        else:
            turn = SA.popleft()
    elif turn == "b":
        if len(SB) == 0:
            print("B")
            exit()
        else:
            turn = SB.popleft()
    else:
        if len(SC) == 0:
            print("C")
            exit()
        else:
            turn = SC.popleft()


Measured memory_bytes: 3316
n = gets.to_i
card = (1..(n * 2)).to_a
gets.to_i.times do
  case k = gets.to_i
  when 0
    tmp1 = card[0..(n - 1)]
    tmp2 = card.drop(n)
    card = []
    n.times do |num|
      card << tmp1[num]
      card << tmp2[num]
    end
  else
    tmp = card[0..(k - 1)]
    card = card.drop(k).concat(tmp)
  end
end
puts card

Measured memory_bytes: 10432
#include <iostream>

using namespace std;

int head(long long int a) {
	while (a >=10) {
		a /= 10;
	}
	return a;
}

int main() {
	long long int count[10][10],ans=0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			count[i][j] = 0;
		}
	}

	long long int n;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		count[i % 10][head(i)]++;
	}

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += count[i][j] * count[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std ;

const int N=2e5+10 ;

struct Edge { int to , nxt , v ; };
Edge e[N<<2] ;
int lst[N] ;
inline void add ( int u , int v )
{
	static int cnt=1 ;
	e[++cnt]=(Edge){v,lst[u]},lst[u]=cnt,
	e[++cnt]=(Edge){u,lst[v]},lst[v]=cnt;
}

int sz[N] ;

int fa[N] , sa , sb ;
int n ;

inline void dfs1 ( int x , int f )
{
	int i , y ;
	for ( i=lst[x],y=e[i].to ; i ; i=e[i].nxt,y=e[i].to )
		if ( y^f ) dfs1(y,x),sz[x]^=1;
	return ;
}
inline int dfs2 ( int x , int f )
{
	int i , y , ret=1 , s=0 ;
	for ( i=lst[x],y=e[i].to ; i ; i=e[i].nxt,y=e[i].to )
		if ( y^f ) ret&=dfs2(y,x),s^=1;
	if ( s^sz[x-n] ) return 0 ;
	return ret ;
}

int ans[N] ;
inline void Euler ( int x )
{
	for ( int &i=lst[x] ; i ; i=e[i].nxt ) 
		if ( !e[i].v ) 
		{
			// printf("From %d to %d\n",x,e[i].to);
			if ( e[i].to==x+n ) ans[x]=1;
			if ( e[i].to==x-n ) ans[x-n]=-1;
			e[i].v=e[i^1].v=1,Euler(e[i].to);
		}
	return ;
}

int main ()
{
	int i ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ ) 
	{
		scanf("%d",fa+i);
		if ( ~fa[i] ) add(i,fa[i]);
		sa=(~fa[i]?sa:i);
	}
	for ( i=1 ; i<=n ; i++ ) 
	{
		scanf("%d",fa+n+i);
		if ( ~fa[i+n] ) add(i+n,fa[i+n]+n);
		sb=(~fa[i+n]?sb:i+n);
	}
	dfs1(sa,sa);
	if ( !dfs2(sb,sb) ) return puts("IMPOSSIBLE")*0;
	// for ( i=1 ; i<=n ; i++ ) 
	// 	printf("%d ",v[i]); puts("");
	for ( i=1 ; i<=n ; i++ ) 
		if ( !sz[i] ) add(i,i+n);
	int S=2*n+1 ;
	add(S,sa),add(S,sb);
	Euler(S);
	puts("POSSIBLE");
	for ( i=1 ; i<=n ; i++ ) 
		printf("%d ",ans[i]);
	return 0 ;
}

Measured memory_bytes: 14592