akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
const ll N=3000010;
ll n,pre[N],suc[N],answ=1e9;char s[N];
int main(){
	n=read();readstr(s+1);
	For(i,1,n){
		pre[i]=pre[i-1]+(s[i]=='E');
	}
	FOr(i,n,1)suc[i]=suc[i+1]+(s[i]=='W');
	For(i,1,n)	Min(answ,(i-1-pre[i-1])+(n-i-suc[i+1]));
	writeln(answ);
}

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

inline long long read(){
	long long s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}
const int MAX_N = 1e6;
map <string, int> pq;
struct xcj{
	string nam;
	int num;
}q[MAX_N];
int n, cnt;
bool cmp (xcj x, xcj y){
	if (x.num != y.num){
		return x.num > y.num;
	}
	return x.nam < y.nam;
}
int main(){
	n = read();
	for (int i = 1; i <= n; i++){
		string s;
		cin >> s;
		if (pq[s] == 0){
			cnt++;
			q[cnt].nam = s;
		}
		pq[s]++;
	}
	for (int i = 1; i <= cnt; i++){
		q[i].num = pq[q[i].nam];
	}
	sort(q + 1, q + 1 + cnt, cmp);
	int Max = q[1].num;
	for (int i = 1; i <= cnt; i++){
		if (q[i].num < Max){
			break;
		}
		cout << q[i].nam << endl;
	}
	
	return 0;
}


Measured memory_bytes: 41088
n=int(input())
slime=list(map(int,input().split()))
stack=0
count=0
ans=0
for i in slime:
  if i!=stack:
    stack=i
    ans+=((count+1)//2)
    count=0
    continue
  count+=1
  stack=i
ans+=((count+1)//2)
print(ans)

Measured memory_bytes: 3064
M, K = map(int,input().split())
if M==1:
  if K!=0:
    print(-1)
  else:
    print(0,0,1,1)
elif K>=2**M:
  print(-1)
else:
  b = [i for i in range(K)] + [i for i in range(K+1,2**M)]
  c = b[::-1]
  ans = b+[K]+c+[K]
  print(*ans)

Measured memory_bytes: 71536
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int a,b,c,k,x,s=0;
	cin>>a>>b>>c>>k;
	x = min(a,k);
	s += x;
	k -= x;
	k-=b;
	if(k>0){
		s -= k;
		}
	cout<<s<<nw;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
 
long long mod = 1000000007;
 
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
 
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
 
#define REP(i, n) for (long long i = 0; i < (n); i++)
 
int main() {
    long long n, b, c;
    cin >> n;
    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) {
            continue;
        }
        sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
import qualified Data.Map as MP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Data.List

type Count = MP.Map Int Int

step :: (Count, Count) -> (Int,Int) -> (Count, Count)
step (emp,omp) (i,e)
    | even i = (emp', omp)
    | odd i = (emp, omp')
    where
        emp' = MP.adjust (+1) e emp
        omp' = MP.adjust (+1) e omp

solve :: Count -> Count -> Int -> Int
solve emp omp n
    | ek1 == ok1 = min (n-ev1-ov2) (n-ev2-ov1)
    | otherwise = n-ev1-ov1
    where
        ((ev1,ek1):(ev2,ek2):[]) = take 2 $ getList emp
        ((ov1,ok1):(ov2,ok2):[]) = take 2 $ getList omp

        getList :: Count -> [(Int, Int)]
        getList mp = sortBy (flip compare) $ MP.foldlWithKey (\acc k v  -> (v,k):acc) [] mp

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace) <$> BC.getLine
    
    let
        base = VU.foldl' (\m k -> MP.insert k 0 m) MP.empty $ VU.fromList [1..10^5]
        (emp,omp) = VU.foldl' step (base, base) $ VU.zip (VU.fromList [1..n]) xs
        res = solve emp omp n
    
    print res

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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    string answer = "Yes";
    if (x + r > w || x - r < 0) answer = "No";
    if (y + r > h || y - r < 0) answer = "No";
    cout << answer << endl;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> t(n);
	int sum=0;
	rep(i,n){
		cin>>t[i];
		sum+=t[i];
	}
	int m;
	cin>>m;
	rep(i,m){
		int p,x;
		cin>>p>>x;
		p--;
		cout<<sum-t[p]+x<<endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type work struct{ time, limit int }
type works []work

func (w works) Len() int      { return len(w) }
func (w works) Swap(i, j int) { w[i], w[j] = w[j], w[i] }
func (w works) Less(i, j int) bool {
	if w[i].limit == w[j].limit {
		return w[i].time < w[j].time
	}
	return w[i].limit < w[j].limit
}

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var ws works = make([]work, n)
	for i := range ws {
		sc.Scan()
		ws[i].time, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		ws[i].limit, _ = strconv.Atoi(sc.Text())
	}

	sort.Sort(ws)
	sum := int64(0)
	for _, w := range ws {
		sum += int64(w.time)
		if sum > int64(w.limit) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 6272
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        s: String,
    }
    let n0 = s.chars().filter(|&c| c == '0').count();
    let n1 = s.chars().filter(|&c| c == '1').count();
    println!("{}", 2 * n0.min(n1));
}


Measured memory_bytes: 2224
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,num,add,k;
int main(void){
	priority_queue<ll> pq;
	scanf("%lld",&n);
	for(int i=0;i<n;++i) scanf("%lld",&num), pq.push(num);
	while(pq.top()+add>=n){
		num = pq.top()+add;
		pq.pop();
		k = num/n;
		num-=k*n;
		add+=k;
		pq.push(num-add);
	}
	printf("%lld\n",add);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    const int HW_MAX = 300 * 300;
    int H, W, D;

    gc(H);
    gc(W);
    gc(D);

    int x[HW_MAX];
    int y[HW_MAX];

    int A;
    REP (i, H)
    {
        REP (j, W)
        {
            gc(A);

            // 0-indexed
            A--;

            x[A] = i;
            y[A] = j;
        }
    }

    int d[HW_MAX];
    FOR (i, D, HW_MAX)
    {
        d[i] = d[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D]);
    }

    int Q;
    gc(Q);

    int L, R;
    int ans;
    while (Q--)
    {
        gc(L);
        gc(R);

        // 0-indexed
        L--;
        R--;

        ans = d[R] - d[L];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 20:29:30 2020

@author: liang
"""

n = int(input())
E = list()
O = list()
i = 0
for v in input().split():
    if i%2 == 0:
        E.append(int(v))
    else:
        O.append(int(v))
    i += 1
#print(E)
#print(O)
edic = {-1:0}
odic = {-1:0}
for e in E:
    if e not in edic.keys():
        edic[e] = 1
    else:
        edic[e] += 1

for o in O:
    if o not in odic.keys():
        odic[o] = 1
    else:
        odic[o] += 1

etup = list()
otup = list()
for e in edic.keys():
    etup.append((e,edic[e]))
for o in odic.keys():
    otup.append((o,odic[o]))    
etup.sort(reverse=True,key=lambda x:x[1])
otup.sort(reverse=True,key=lambda x:x[1])

#print(etup)
#print(otup)
i = 0
j = 0
while True:
    ekey, etmp = etup[i]
    okey, otmp = otup[j]
    if ekey != okey:
        break
    if etup[i+1][1] < otup[j+1][1]:
        j += 1
    else:
        i += 1
    #rint("calc")

#print(edic)

ans = n - etmp - otmp
    
print(ans)

Measured memory_bytes: 26716
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<pair<ll, int>> ab(n); cin >> ab;
    SORT(ab);

    ll ans = 0;
    each(i, ab) {
        ll a; int b; tie(a, b) = i;
        if (m <= b) {
            ans += a * m;
            break;
        }
        ans += a * b;
        m -= b;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <string>
#include <string.h>
#include <deque>
#include <functional>
#include <tuple>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vec> vec2;

//for文
#define FOR(i,a,b) for(ll i = (ll)a;i < (ll)b;i++)
#define FORE(i,a,b) for(ll i = (ll) a;i <= (ll) b;i++ )
#define REP(i,size_of_array)  for(ll i =(ll)0;i<size_of_array;i++)
#define REPE(i,size_of_array)  for(ll i =(ll)0;i<=size_of_array;i++)
#define REPR(i,size_of_array)  for(ll i =(ll)size_of_array;i>=0;i--)

//ソート
#define ALL(vec) (vec).begin(),(vec).end()
#define SORT(vec) sort(ALL(vec))
#define INVSORT(vec) sort((vec).rbegin(),(vec).rend())

//最大値最小値
#define MAX(vec) *max_element(ALL(vec))
#define UNIQ(vec) SORT(vec);vec.erase(unique(ALL(vec)),vec.end())
#define MIN(vec) *min_element(ALL(vec))

//表示
#define printl(a) cout << a << "\n"
#define print(a) cout << a
#define OUT(a) printf("%lld",a)
#define SP cout << " "

//入力
#define INPUT(x) scanf("%lld",&x)
#define INPUTV(vec) REP(i,vec.size()) scanf("%lld",&vec[i])
#define inputV(vec) REP(i,vec.size()){cin >> vec[i];}
#define input(a) cin >> a

//型
#define float ld
#define double ld
#define P pair<ll,ll>
#define vp vector<P>
#define F first
#define S second

//特殊
//#define int ll
#define DEBUG(x) cerr << #x << ":" << x<<endl
#define  DEBUGV(V) REP(i,V.size()){cerr << i << ":" << V[i]<<endl;}

template<class T> inline void umax(T &a,const T &b) { if(a < b) a = b; }
template<class T> inline void umin(T &a,const T &b) { if(a > b) a = b; }

const ll INF = 1ll << 60;
const ld EPS = 1e-8;

signed main(){
    ll N;
    INPUT(N);
    vec A(N);
    INPUTV(A);
    bool dec = false;
    bool inc = false;
    ll cnt = 0;
    FOR(i,1,N){
        if(A[i-1] > A[i]) dec = true;
        else if(A[i-1] < A[i]) inc = true;

        if(dec and inc){
            cnt++;
            dec = false;
            inc = false;
        }
    }

    OUT(++cnt);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  int ans = 1<<30;
  for(int i = 1;i <= n/2 ; i++){
    int a = 0;
    int b = 0;
    a = i % 10 + i /10 % 10 + i /100 % 10 + i /1000 % 10 + i /10000 % 10;
    b = (n - i) % 10 +(n- i )/10 % 10 + (n- i )/100 % 10 +(n- i) /1000 % 10 +(n- i )/10000 % 10;
    if( ans > a + b){
      ans = a + b;
    }
  }
  cout << ans << endl;
}

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

int main(){
  vector<int> x(4,0);
  REP(i,4) cin>>x.at(i);
  sort(x.begin(),x.begin()+3);
  for(int i=0;i<x.at(3);i++) x.at(2)*=2;
  cout<<accumulate(x.begin(),x.begin()+3,0);
}

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

int main() {
   
	long long n,i,j,k,sum=0,count=0,ans=0,mx=100000000000,s,mn=100000000000;
	cin>>n;
	long long a[n],b[n];
	for(i=0;i<n;i++)
	{
	   cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
	    if(a[i]<=mn)
	    count++;
	    mn=min(mn,a[i]);
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int d;
    cin>>d;
    vector<ll> c(26),last(26,-1),v(d);
    vector<vector<int>> s(d,vector<int>(26));
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<d;i++){
        if(i) v[i]=v[i-1];
        int t;
        cin>>t;
        t--;
        v[i]+=s[i][t];
        last[t]=i;
        for(int j=0;j<26;j++) v[i]-=c[j]*(i-last[j]);
    }
    for(int a : v) cout<<a<<endl;
}

Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int main(){
    int n;
    int S[10000];
    int q;
    int T[500];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>T[i];
    }
    int C=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(S[j]==T[i]){
                C++;
                break;
            }
        }
    }
    cout<<C<<endl;
}


Measured memory_bytes: 3108
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int s[1005];
vector<int>edge[1005];
vector<int>edge2[1005];
P mem[1005][1005];
int p[1005];
int main()
{
	int n,m,h,k;
	while(1)
	{
		scanf("%d %d %d %d",&n,&m,&h,&k); if(!n)  return 0;
		for(int i=0;i<1005;i++){ edge[i].clear(); edge2[i].clear();}
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&s[i]);
		}
		for(int i=0;i<m;i++)
		{
			int a,b; scanf("%d %d",&a,&b);
			edge[a].pb(b);
			edge2[a+1].pb(b);
		}
		for(int i=1;i<n;i++) sort(edge[i].begin(),edge[i].end());
		for(int i=2;i<=n;i++) sort(edge2[i].begin(),edge2[i].end());
		int ret=0;
		for(int i=1;i<=n;i++)
		{
			int cur=i;
			int now=0;
			while(1)
			{
				int f=INF,f2=INF;
				if(!edge[cur].empty()) f=upper_bound(edge[cur].begin(),edge[cur].end(),now)-edge[cur].begin();
				if(!edge2[cur].empty()) f2=upper_bound(edge2[cur].begin(),edge2[cur].end(),now)-edge2[cur].begin();

				if((f<edge[cur].size() && f2>=edge2[cur].size()) || (f<edge[cur].size() && f2<edge2[cur].size() && edge[cur][f]<edge2[cur][f2]))
				{
					mem[cur][f].first=i;
					now=edge[cur][f];
					cur++;
					
				}
				
				else if((f>=edge[cur].size() && f2<edge2[cur].size()) || (f<edge[cur].size() && f2<edge2[cur].size() && edge[cur][f]>=edge2[cur][f2]))
				{
					mem[cur-1][f2].second=i;
					now=edge2[cur][f2];
					cur--;
				}
				else
				{
					break;
				}
			}
			if(i<=k) ret+=s[cur];
			p[i]=s[cur]; //printf("%d %d\n",i,p[i]);
		}
		int res=0;
		for(int i=1;i<n;i++)
		{
			for(int j=0;j<edge[i].size();j++)
			{
				int x=mem[i][j].first;
				int y=mem[i][j].second; //printf("%d %d\n",x,y);
				if(x<=k && y<=k) continue;
				if(x>k && y>k) continue;
				if(x>y) swap(x,y);
				res=max(res,p[x]-p[y]);
			}
		}
		printf("%d\n",ret-res);
	}
}

Measured memory_bytes: 10136
#include <bits/stdc++.h>
using namespace std;
int solve(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                    count++;
            }
        }
    }
    return count;
    // unordered_map<int,int> umap;
    // for(int i=0;i<n;i++){
    //     int a;
    //     cin>>a;
    //     umap[a]++;
    // }
    // vector<pair<int,int>> v;
    // for(auto x: umap)
    //     v.push_back(x);

    // sort

}
int main() {
    cout<<solve();
}


Measured memory_bytes: 3628
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False

# xor
# n + i = n ^ i implies n & i = 0


def sumXOR(arr,  n):
    _sum = 0
    for i in range(0, 64):
        zc = 0
        oc = 0

        # Individual sum at each bit position
        idsum = 0
        for j in range(0, n):
            if (arr[j] % 2 == 0):
                zc = zc + 1
            else:
                oc = oc + 1
            arr[j] = arr[j] >> 1

        # calculating individual bit sum
        idsum = oc * zc * (1 << i)
        print(zc, oc, idsum)

        # final sum
        _sum = _sum + idsum
        _sum %= MOD

    return _sum


def main():
    N = I()
    A = list(MI())
    BIT = 61
    C = [[0] * BIT for i in range(N+1)]
    pows = [pow(2, i, MOD) for i in range(BIT)]
    ans = 0

    for i in range(N):
        bit = 1
        for j in range(BIT):
            if A[i] & bit:
                C[i+1][j] = C[i][j] + 1
            else:
                C[i+1][j] = C[i][j]
            bit = bit << 1

    for i in range(N):
        bit = 1
        for j in range(BIT):
            oc = C[N][j] - C[i][j]
            # print('b', ans, i, j, bit, oc)
            if A[i] & bit:
                zc = N - i - oc
                ans += pows[j] * zc
            elif oc != 0:
                ans += pows[j] * oc
            ans %= MOD
            bit = bit << 1
            # print('a', ans, i, j, bit, oc)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 213268
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;

    priority_queue<int> q;
    rep(_, n){
        int c; cin >> c;
        q.push(c);
    }

    rep(_, m){
        int c = q.top(); q.pop();
        q.push(c / 2);
    }

    ll res = 0LL;
    while(q.size()){
        int c = q.top(); q.pop();
        res += c;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
const int MOD = 1000000007;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
 
int main(){
  int n;cin >>n;
  int s=1;
  while((s*(s+1))/2<n){
    s++;
  }
  cout << s << endl;
}

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

int main(){
  int n;
  cin>>n;
  ll a[n];
  ll pdt=1;
  ll ref = pow(10,18);
  for(int i=0;i<n;i++){
	cin>>a[i];
    if(a[i]==0){
      cout<<0;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    if(a[i]>1000000000000000000/pdt){
      cout<<-1;
      return 0;
    }
    pdt*=a[i];
  }
  cout<<pdt;
  return 0;
}

Measured memory_bytes: 4380
#Union Find
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]


N,M = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N+1)

for i in range(M):
    a,b = map(int,input().split())
    unite(a,b)

ans = 1
for i in range(1,N+1):
    ans = max(ans,size(i))

print(ans)

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

int main() {
int a,b;
  cin >> a >> b;
  if(a<b){
    cout << "a < b" << endl;
  } if(a>b){
    cout << "a > b" << endl;
  } if(a==b){
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3072
x ,n= list(map(int, input().split()))
if n == 0:
    p = input()
    print(x)
else:
    p = list(map(int, input().split()))
    d = 0
    answer = 0
    while True:
        if x-d not in p:
            answer = x-d
            break
        elif x+d not in p:
            answer = x+d
            break
        d += 1
    print(answer)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#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 ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

ll goch(ll a){
    for (ll i = 0; i*i*i*i*i <= a; i++) {
        if (i*i*i*i*i == a) {
            return i;
        }
    }
    return -1;
}


int main() {
    IN(string, s);
    IN(string, t);
    bool flag = true;
    REP(i, s.length()){
        if (s[i]!=t[i]) {
            flag = false;
        }
    }
    Yes(flag);
    
}


Measured memory_bytes: 3628
# include <bits/stdc++.h>
/// my holy template
# define F first    
# define S second
# define mp make_pair
# define pii pair<int,int>         
/// eveything goes according to my plan
# define long long long  
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
/// countdown BEGAN. 10 , 9 , 8 ...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right
/// dzyn dzyn dzyn   
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 9223372036854775807;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
int a, b, n;

int f (int n) {
  int res = 0;
  while (n) {
    res += n%10;
    n /= 10;
  }
  return res;
}  
                              
int main() 
{
  Read_rap ();
  int n;  cin >> n;
        
  cout << (n % f(n) == 0 ? "Yes" : "No");


  return 0;
} 










// Coded by Z...

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

// Union-Find
struct UnionFind {
    vector<int> par;
    vector<int> scale1;
    // par[i]はiの親の番号
    // scale[i]はiが親の時にのみ意味を持ち, その木の要素の数

    //最初は全てが根であるとして初期化
    UnionFind(int N) : par(N), scale1(N,1){
        for(int i = 0; i < N; i++) par[i] = i;
    }

    // データxが属する木の根を再帰で得る
    int root(int x){
        if (par[x] == x) return x;
        par[x] = root(par[x]); // 親を根にする付け替えによって次回以降の参照を高速化
        return par[x];
    }

    // xとyの木を併合
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(scale1[rx] > scale1[ry]){
            par[ry] = rx;
            scale1[rx] += scale1[ry];
        }else if(scale1[rx] < scale1[ry]){
            par[rx] = ry;
            scale1[ry] += scale1[rx];
        }else{
            par[ry] = rx;
            scale1[rx] += scale1[ry];
        }
    }

    // 2つのデータx, yが属する木が同じならtrueを返す関数
    bool same(int x, int y){
        return root(x) == root(y);
    }

    // xの属する木の要素の数を返す関数
    int scale(int x){
        return scale1[root(x)];
    }
};


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

    UnionFind tree(N);
    vector<ll>ans(M);
    ll temp = N;
    temp = (temp * (temp-1)) / 2; // このオーバーフローのせいで30分溶かした
    for(int i = M - 1; i >= 0; --i){
        ans[i] = temp;
        if(! tree.same(A[i]-1, B[i]-1)){
            ll aS = tree.scale(A[i]-1);
            ll bS = tree.scale(B[i]-1);
            temp = temp - aS * bS;
            tree.unite(A[i]-1, B[i]-1);
        }
    }

    for (int i = 0; i < M; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG
#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>;

void solve()
{
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    if (s == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    solve();
    return 0;
}

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

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

typedef long long ll;
typedef vector<int> vi;

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

	vi c(n);
	vi t(n);

	rep(i, n){
		cin >> c[i] >> t[i];
	}

	int ans = 10000;
	rep(i, n){
		if(t[i] <= T){
			ans = min(ans, c[i]);
		}
	}

	if(ans == 10000){
		cout << "TLE" << endl;
	}else{
		cout << ans << endl;
	}

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  char b;
  in(b);
  if(b == 'A')
    out('T');
  if(b == 'T')
    out('A');
  if(b == 'C')
    out('G');
  if(b == 'G')
    out('C');
  memi;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, s = 0; cin >> n;
  map<int, int> m; rep(i, n){int a; cin >> a; m[a]++;}
  for(auto p: m){
    if(p.se > 1) continue;
    if(p.fi < 4){
      ++s;
      continue;
    }
    bool b = 1;
    rep(i, sqrt(p.fi)){
      if(i == 0) continue;
      else if(p.fi % (i+1) == 0 && (m.count(i+1) || m.count(p.fi / (i+1)))){
        b = 0;
        break;
      }
    }
    if(b) ++s;
  }
  if(m[1] == 1) s = 1;
  if(m[1] > 1) s = 0;
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 12920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
vector<ll> cnt;
vector<ll> pat;
 
ll rec(ll N,ll X){
  if(X==0) return 0;
  if(N==0&&X==1) return 1;
  X--;
  if (X <= cnt[N - 1]) return rec(N - 1, X);
  X-=cnt[N-1];
  if (X == 1) return pat[N-1]+1LL;
  X--;
  if (X <= cnt[N - 1]) return pat[N-1] + rec(N - 1, X) + 1;
  return pat[N];
}
 
int main() {
    ll N,X;
    cin >> N >> X;
    cnt.resize(N+1); cnt[0] = 1;
    pat.resize(N+1); pat[0] = 1;
    rep(i,N){
        cnt[i + 1] = 3 + 2 * cnt[i];
        pat[i + 1] = 1 + 2 * pat[i];
    }
    cout << rec(N,X) << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()

    mn = int(N**0.5) + 5
    d = defaultdict(int)

    for x in range(1, mn):
        for y in range(1, mn):
            for z in range(1, mn):
                d[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1

    for i in range(1, N + 1):
        print(d[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 74404
#include <stdio.h>
int main (){
	int a, b, c, count = 0;
	scanf("%d %d %d", &a,&b,&c);
	while(1){
		if(c % a == 0)
			count++;
	        if(a == b)
                        break;
                 a++;
}
	printf("%d\n", count);
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]--;
  }
  int Z=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    Z+=a;
  }
  vector<int> q(N-1);
  for(int i=0;i<N-1;i++){
    cin>>q[i];
  }
  for(int i=0;i<N-1;i++){
    if(p[i]+1==p[i+1]){
      Z+=q[p[i]];
    }
  }
  cout<<Z<<endl;
    
}

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


int main(){
    int A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;
    int ko;
    for(int i=A; i>0; i--){
        if(A%i==0 && B%i==0){
            ko = i;
            cnt++;
        }
        if(cnt == K) break;
    }
    cout << ko << endl;
}   

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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N, K;

// *********************************************************
int main(){

    cin >>  N>> K;

    vector<int> p;
    for(int i=0; i<N; ++i) {
        int pn;
        cin >> pn;
        p.emplace_back(pn);
        
    }

    sort(p.begin(), p.end());

    int sum=0;
    rep(i,K){
        sum += p.at(i);
    }

    cout << sum <<endl;


    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll fast_pow(ll a, ll b){
    if(b == 0) return 1;
    a = a % MOD;
    ll t=fast_pow(a,b/2)%MOD;
    t=t*t%MOD;
    if(b&1)t=t*a%MOD;
    return t;
}

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

    ll ans = 0;

    ans += fast_pow(10, N);
    ans -= 2 * fast_pow(9, N);
    ans %= MOD;
    if(ans < 0) ans += MOD;
    ans += fast_pow(8, N);
    ans %= MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

int main() {
	int n, k;
	while(~scanf("%d%d", &n, &k)) {
		if(n % k != 0) printf("1\n");
		else printf("0\n");
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll x,y;
    string s;
    cin>>x>>y;
    ll ans=0;
    if(x==1)ans+=300000;
    if(x==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 764
import sys
e=sys.stdin.readline
p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),
   'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)}
for n in iter(e,'0\n'):
 a=1;s=[1,2,3,4,5,6]
 for _ in[0]*int(n):
  s=[s[i]for i in p[e()[0]]]
  a+=s[0]
 print(a)


Measured memory_bytes: 5664
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
vector<int> buf;
vector<vector<int>> a_s;
int vectorrow=0;

void dfs(int i, const int size, const int range_start, const int range_end)
{
    if (i == size) {
        a_s.push_back(buf);
        vectorrow++;
    }
    else{
        int lastd=range_start;
        if(i>0){
            lastd=buf[i-1];
        }
        for(int j = lastd; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
    int n,m,q;
    cin>>n>>m>>q;
    vector<int> a(q),b(q),c(q),d(q);
    for(int i=0;i<q;i++){
        int ai,bi;
        cin>>ai>>bi>>c[i]>>d[i];
        a[i]=ai-1;
        b[i]=bi-1;
    }
    buf.resize(n);
    dfs(0, n, 1, m);
    int max=0;
    for(int i=0;i<a_s.size();i++){
        int point=0;
        for(int j=0;j<q;j++){
            if(a_s[i][b[j]]-a_s[i][a[j]]==c[j]){
                point+=d[j];
            }
        }
        if(max<point){
            max=point;
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 9732