akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string s;
  cin >> s;

  bool ease = true;
  re(i, s.size()) {
    if(i % 2 == 1) {
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') ease = false;
    } else {
      if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') ease = false;
    }
  }
  if(ease) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    intmax_t W, H, x, y;
    intmax_t ans = 0;
    double cx, cy;

    scanf("%jd%jd%jd%jd", &W, &H, &x, &y);

    cx = (double)W / 2;
    cy = (double)H / 2;
    if (x == cx && y == cy) ans = 1;

    printf("%f %jd\n", ((double)W * (double)H / 2), ans);

    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n, wm;
  cin >> n >> wm;
  int vm = n * 1000;
  vl w(n), v(n);
  rep (i, n) {
    cin >> w[i] >> v[i];
  }
  vll dp(n + 1, vl(vm + 1, INF));
  dp[0][0] = 0;
  rep (i, n) {
    rep (j, vm + 1) {
      chmin(dp[i + 1][j], dp[i][j]);
      if (j + v[i] > vm) continue;
      if (dp[i][j] + w[i] <= wm) {
        chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
      }
    }
  }
  ll ans = -INF;
  rep (i, vm + 1) {
    if (dp[n][i] != INF) {
      ans = i;
    }
  }
  cout << ans << endl;
}
  


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

int main(void){
  int n,m;
  int dx[4] = { 0 , 1 , 0 , -1 };
  int dy[4] = { 1 , 0 , -1 , 0 };
  int angle;
  string order;
  int x,y;
  int Go;

  while(1){

    angle = 0; x = y = 1;

    cin >> n >> m;

    if( n == 0 && m == 0 ) break;

    while(1){

      cin >> order;

      if( order == "RIGHT" ){
	angle++;
	if( angle == 4 ) angle = 0;
	continue;
      }

      else if( order == "LEFT" ){
	angle--;
	if( angle == -1 ) angle = 3;
	continue;
      }

      else if( order == "STOP" ){
	cout << x << " " << y << endl;
	break;
      }

      cin >> Go;

      if( order == "FORWARD" ){

	x += dx[angle]*Go;
	y += dy[angle]*Go;

	if( x < 1 ) x = 1;
	if( y < 1 ) y = 1;
	if( x > n ) x = n;
	if( y > m ) y = m;

      }

      else if( order == "BACKWARD" ){

	x -= dx[angle]*Go;
	y -= dy[angle]*Go;

	if( x < 1 ) x = 1;
	if( y < 1 ) y = 1;
	if( x > n ) x = n;
	if( y > m ) y = m;

      }
    }
  }

  return 0;

}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n;
   cin>>n;
   
   vector<int> a;
   int sum=0;
   a.push_back(0);
   rep(i,n){
      int x;
      cin>>x;
      a.push_back(x);
   }
   a.push_back(0);

   rep(i,n+1){
      sum+=abs(a[i+1]-a[i]);
   }
   
   rep(i,n+1){
      if(i==0) continue;
      cout<<sum+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))<<endl;
   }
   
   return 0;
}


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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

int n;

int main()
{
  cin >> n;
  int a, even = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0) even++;
  }

  if (n == even)
    cout << "second" << endl;
  else
    cout << "first" << endl;
  
  return 0;
}


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

#define null                ""
#define all(dat)            dat.begin(), dat.end()
#define over(msg)           cout << msg << endl, exit(0);
#define loop(i, to)         for (num i = 0; i < to; ++i)
#define cont(i, to)         for (num i = 1; i <= to; ++i)
#define foreach(i, dat)     for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long           num;

using namespace std;

struct sta {
    
    int from, com, d;
    
    sta() {}
    
    sta(int a, int b, int c) {
        
        this -> from = a;
        
        this -> com = b;
        
        this -> d = c;
        
    }
    
};

bool operator < (sta a, sta b) {

    return a.d > b.d;

}

const int inf = 0x3f3f3f;

int n, m, ans = inf;

vector<int> g[100005];

unordered_map<int, int> dis[100005];

unordered_map<int, vector<int>> com[100005];

int main() {
    
    cin >> n >> m;
    
    loop (i, m) {
        
        int p, q, c;
        
        cin >> p >> q >> c;
        
        --p;
        
        --q;
        
        com[p][c].push_back(q);
        
        com[q][c].push_back(p);
        
        g[p].push_back(c);
        
        g[q].push_back(c);
        
    }
    
    priority_queue<sta> q;
    
    dis[0][0] = 0;
    
    q.push(sta(0, 0, 0));
    
    while (!q.empty()) {
        
        sta u = q.top();
        
        q.pop();
        
        if (dis[u.from][u.com] != u.d)  continue;
        
        if (dis[u.from].find(0) == dis[u.from].end() || dis[u.from][0] > u.d) {
            
            dis[u.from][0] = u.d;
            
            q.push(sta(u.from, 0, u.d));
            
        }
        
        if (u.com == 0) {
            
            loop (i, g[u.from].size()) {
                
                int v = g[u.from][i];
                
                if (dis[u.from].find(v) == dis[u.from].end() || dis[u.from][v] > u.d + 1) {
                    
                    dis[u.from][v] = u.d + 1;
                    
                    q.push(sta(u.from, v, u.d + 1));
                    
                }
                
            }
            
            continue;
            
        }
        
        loop (i, com[u.from][u.com].size()) {
            
            int v = com[u.from][u.com][i];
            
            if (dis[v].find(u.com) == dis[v].end() || dis[v][u.com] > u.d) {
                
                dis[v][u.com] = u.d;
                
                q.push(sta(v, u.com, u.d));
                
            }
            
        }
        
    }
    
    foreach (it, dis[n - 1]) {
        
        ans = min(ans, it -> second);
        
    }
    
    if (ans == inf) {
        
        over(-1);
        
    }
    
    over(ans);
    
}


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

int n,k;
int A[100010];
int32_t main() {
	cin >> n >> k;
	for (int i =0;i<n;i++) cin >> A[i];
	int ans = LLONG_MAX/2;
	for (int i =0;i<=n-k;i++) {
		ans = min(ans, abs(A[i]) + (A[i+k-1] - A[i]));
		ans = min(ans,abs(A[i+k-1]) + abs(A[i] - A[i+k-1])); 
	}
	cout << ans;
}


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

int main(){

  string s;
  while(getline(cin, s)){

    for(int i=0;i<26;i++){

      for(int j=0;j<s.size();j++){
        if(s[j] == ' ' || s[j] == '.') continue;
        s[j] = 'a'+(s[j]-'a'+1)%26;
      }

      if(s.find("this") != string::npos) break;
      if(s.find("that") != string::npos) break;
      if(s.find("the") != string::npos) break;
    }

    cout << s << endl;
  }
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    ll n;
    cin >> n;
    vector<char> ans;
    while(n>0){
        n--;
        ans .push_back('a' + n % 26);
        n/=26;
    }
    rep(i,ans.size()){
        cout << ans[ans.size()-i-1];
    }
    cout << endl;

    return 0;
}




Measured memory_bytes: 3600
#include<stdio.h>
typedef long long ll;
ll sqr(ll x){return x*x;}
int k;
int query(int l,int r,int i){
	if(l+k-l%k<=r-r%k){
		int s=0;
		if(i>=l%k)s++;
		l+=k-l%k;
		if(i<=r%k)s++;
		r-=r%k;
		s+=(r-l)/k;
		if(k==0)s++;
		return s;
	}else
		if(l%k>r%k)
			return i<=r%k||i>=l%k;
		else
			return l%k<=i&&i<=r%k;
}
int main(){
	int n,i;
	ll s;
	scanf("%d%d",&n,&k);
	s=0;
	for(i=1;i<=n;i++){
		if((k-i%k)*2%k==0)s+=sqr(query(1,n,(k-i%k)%k));
	}
	printf("%lld",s);
}

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

using namespace std;

int main()
{
    int a[3],k,i,sum;
    cin>>a[0]>>a[1]>>a[2];
    cin>>k;
    sort(a,a+3);
    for(i=1;i<=k;i++)
        a[2]=a[2]*2;
    sum=a[0]+a[1]+a[2];
    cout<<sum;
    return 0;
}


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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

string s;
int k;

int main(){
  cin >> s >> k ;
  vector<string> vec;

  for(int i = 1 ; i <= min(int(s.size()),k) ;i++){
    for(int j = 0 ; j <= s.size()-i; j++){
      vec.push_back(s.substr( j, i ));
    }
  }


  set<string> set1(vec.begin(), vec.end());
  vector<string> vec2(set1.begin(), set1.end());

  cout << vec2[k-1] << endl;


  return 0;
}


Measured memory_bytes: 2428
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;cin>>n>>m;
    vector<int>a(m),b(m);
    vector<int> ab[101];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        ab[a[i]].pb(b[i]);
        ab[b[i]].pb(a[i]);
        
    }
        
    for(int i=0;i<n;i++)
        cout<<ab[i].size()<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[][] stu = new long[N][];
		for (int i = 0; i < N; i++) {
			stu[i] = new long[]{sc.nextInt(), sc.nextInt()};
		}
		long[][] p = new long[M][];
		for (int i = 0; i < M; i++) {
			p[i] = new long[]{sc.nextInt(), sc.nextInt()};
		}
		for (int i = 0; i < N; i++) {
			int ans = 0;
			for (int j = 1; j < M; j++) {
				if (Math.abs(stu[i][0] - p[j][0]) + Math.abs(stu[i][1] - p[j][1]) <
					Math.abs(stu[i][0] - p[ans][0]) + Math.abs(stu[i][1] - p[ans][1])) {
					ans = j;
				}
			}
			System.out.println(ans + 1);
		}
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    LL T; cin >> T;
    LL ans = 0;

    LL t1; cin >> t1;
    LL pre = t1;

    FOR(i,1,N)
    {
        LL tmp; cin >> tmp;
        if(tmp-pre > T) ans += T;
        else ans += tmp - pre;

        pre = tmp;

    }
    ans += T;
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(int argc,char** argv)
{

	int n;
	cin >> n;

	long long a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int cnt=0;
	for(int i = 0; i < n; i++){
		while(a[i]%2==0 && a[i]!=0){
			a[i] = a[i]/2;
			cnt++;
		}
	}

	cout << cnt <<endl;

	return 0;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
main(){
long long int n,w;
cin>>n>>w;
vector < array <long long int ,2> > vt(n);

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

sort(vt.begin(),vt.end());
long long int val[w+1];
memset(val,0,sizeof(val));
for(int i=0;i<n;i++)for(int j=w;j>=1;j--)
{if(j<vt[i][0])continue;
val[j]=max(val[j],vt[i][1]+val[j-vt[i][0]]);

//cout<<val[j];

}

cout<<val[w];

}


Measured memory_bytes: 4360
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ok := false
LOOP1:
	for i := 0; i <= N; i++ {
		for j := 0; j <= N-i; j++ {
			if i*4+j*7 == N {
				// fmt.Printf("[dbg] i->%d, j->%d, tot->%d\n", i, j, i*4+j*7)
				ok = true
				break LOOP1
			}
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

static const int N = 8;
static const int FREE = 1, NOT_FREE = 0;

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
bool X[N][N];   // 初期クイーン配置を記録しておく

void initialize(){
    rep(i,N) row[i] = col[i] = FREE;
    rep(i,2*N-1) dpos[i] = dneg[i] = FREE;
}

// クイーン配置全パターンのうち、初期配置に合致した場合（この場合は必ず1つ）に出力する
void printBorad(){
    rep(i,N) rep(j,N) if(X[i][j]) if(row[i] != j) return;
    rep(i,N){
        rep(j,N) cout << (row[i] == j ? "Q":".");
        cout << endl;
    }
}

// この関数によってクイーン配置全パターンを試す
void recursive(int i){
    if(i == 8){
        printBorad(); return;
    }
    rep(j,N){
        if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+(N-1)] == NOT_FREE) continue;
        // i,jにクイーンを配置する
        row[i] = j; col[j] = dpos[i+j] = dneg[i-j+(N-1)] = NOT_FREE;
        // 次の行を試す
        recursive(i+1);
        // (i, j)に配置されているクイーンを取り除く
        row[i] = col[j] = dpos[i+j] = dneg[i-j+(N-1)] = FREE;
    }
    // クイーンの配置に失敗した処理を書く
}

int main()
{
    initialize();

    int n; cin >> n;
    rep(i,n){
        int r, c; cin >> r >> c;
        X[r][c] = true;
    }

    recursive(0);

    return 0;
}


Measured memory_bytes: 3124
#include <iterator>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
#include <sstream>
using namespace std;
int main(int argc, char **argv) {
  int N, M;
  cin >> N >> M;

  vector<int> liked;
  liked.resize(M + 1);
    cin >> ws;
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; ++j) {
      int a;
      cin >> a;
      liked[a]++;
    }
  }

  cout << count_if(liked.begin(), liked.end(), [N](int v) { return v == N; }) << endl;

  return 0;
}

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

using namespace std;

class dice 
{
private:
	int num[7];
public:
	dice(int array[]);
	void turnE();
	void turnN();
	void turnS();
	void turnW();
	void command(string com);
	void displayTop();
};

dice::dice(int array[])
{
	int i;
	for (i = 0; i < 6; i++)
		num[i + 1] = array[i];
}

void dice::command(string com)
{
	int len = com.length();
	int i;
	char ch;
	for (i = 0; i < len; i++)
	{
		ch = com.at(i);
		if (ch == 'E')
		{
			turnE();
			continue;
		}
		if (ch == 'N')
		{
			turnN();
			continue;
		}
		if (ch == 'W')
		{
			turnW();
			continue;
		}
		if (ch == 'S')
		{
			turnS();
			continue;
		}
	}
}

void dice::turnE()
{
	int temp;
	temp = num[6];
	num[6] = num[3];
	num[3] = num[1];
	num[1] = num[4];
	num[4] = temp;
}

void dice::turnN()
{
	int temp;
	temp = num[6];
	num[6] = num[5];
	num[5] = num[1];
	num[1] = num[2];
	num[2] = temp;
}

void dice::turnS()
{
	int temp;
	temp = num[6];
	num[6] = num[2];
	num[2] = num[1];
	num[1] = num[5];
	num[5] = temp;
}

void dice::turnW()
{
	int temp;
	temp = num[6];
	num[6] = num[4];
	num[4] = num[1];
	num[1] = num[3];
	num[3] = temp;
}

void dice::displayTop()
{
	cout << num[1] << endl;
}


int main(void)
{
	int array[6];
	int i;
	for (i = 0; i < 6; i++)
		cin >> array[i];
	dice dic(array);
	string input;
	cin >> input;
	dic.command(input);
	dic.displayTop();

	return 0;
}


Measured memory_bytes: 3216
#include<stack>
#include<cstdio>
#include<vector>

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

using namespace std;

typedef long long ll;

template<class T>
class segment_tree{
	static const int N_MAX=1<<17;
	int n;
	T dat[2*N_MAX];

	void update_min(int l,int r,int a,int b,int u,T v){
		if(l<=a && b<=r){ dat[u]=min(dat[u],v); return; }

		int c=(a+b+1)/2;
		if(l<c && a<r) update_min(l,r,a,c,2*u,v);
		if(l<b && c<r) update_min(l,r,c,b,2*u+1,v);
	}

public:
	void build(int N,T val){
		for(n=1;n<N;n*=2);
		rep(u,2*n) dat[u]=val;
	}

	void update_min(int l,int r,T v){ update_min(l,r,0,n,1,v); }

	T query(int u){
		u+=n;
		T res=dat[u];
		for(u/=2;u>=1;u/=2) res=min(res,dat[u]);
		return res;
	}
};

int n;
vector<int> T[100000]; // tree
 
int start[100000],end[100000];
 
int idx;
void dfs(int u){
    start[u]=idx++;
    rep(i,T[u].size()) dfs(T[u][i]);
    end[u]=idx;
}

int main(){
	for(int q;scanf("%d%d",&n,&q),n;){
		rep(u,n) T[u].clear();
		rep(i,n-1){
			int u,v=i+1; scanf("%d",&u); u--;
			T[u].push_back(v);
		}

        idx=0;
        dfs(0);

		static int f[100000]; // f : start[u] -> u
		rep(u,n) f[start[u]]=u;

		static segment_tree<int> S;
		S.build(n,0);

		ll ans=0;
		while(q--){
			char c;
			int u; scanf(" %c%d",&c,&u); u--;
			if(c=='Q'){
				ans+=f[-S.query(start[u])]+1;
			}
			else{
				S.update_min(start[u],end[u],-start[u]);
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 12404
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
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;}
string get_str(string s) {
	s+=',';
	string ret="";
	for(int i=0; i<s.size(); i++) {
		if(s[i]==',') ret+="=%ld, ";
		else ret+=s[i];
	}
	return ret;
}
#define dump(...) printf(get_str(#__VA_ARGS__).c_str(),__VA_ARGS__);cout<<endl
 
#define endl '\n'
#define IOS()                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
 
//******************************************************************************
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main()
{
	//IOS();
	int H,W,N;
	cin>>H>>W>>N;
	int sr,sc;
	cin>>sr>>sc;
	string s,t;
	cin>>s>>t;
	auto Asum = make_v<int>(N+1,4);//LRUD
	auto Tsum = make_v<int>(N+1,4);
	auto ma = make_v<int>(N+1,4);
	fill_v(Asum,0);
	fill_v(Tsum,0);
	fill_v(ma,0);
	rep(i,0,N){
		if(t[i]=='L')Asum[i][0]++;
		else if(t[i]=='R')Asum[i][1]++;
		else if(t[i]=='U')Asum[i][2]++;
		else Asum[i][3]++;
		if(s[i]=='L')Tsum[i][0]++;
		else if(s[i]=='R')Tsum[i][1]++;
		else if(s[i]=='U')Tsum[i][2]++;
		else Tsum[i][3]++;
		rep(j,0,4){
			Asum[i+1][j]+=Asum[i][j];
			Tsum[i+1][j]+=Tsum[i][j];
		}
	}
	rep(i,0,N){
		rep(j,0,4){
			ma[i+1][j] = (Tsum[N][j] - Tsum[i][j]) - (Asum[N-1][j] - Asum[i][j]);
		}
	}
	//上から落ちる
	int cnt = sr;
	rep(i,0,N){
		if(s[i]=='D')cnt++;
		if(cnt==H+1){
			cout<<"NO"<<endl;
			return 0;
		}
		if(cnt!=1&&t[i]=='U'&&-ma[i+1][3]+cnt-1>0)cnt--;
	}
	//下から落ちる
	cnt = sr;
	rep(i,0,N){
		if(s[i]=='U')cnt--;
		if(cnt==0){
			cout<<"NO"<<endl;
			return 0;
		}
		if(cnt!=H&&t[i]=='D'&&ma[i+1][2]+cnt+1<=H)cnt++;
	}

	//右から
	cnt = sc;
	rep(i,0,N){
		if(s[i]=='L')cnt--;
		if(cnt==0){
			cout<<"NO"<<endl;
			return 0;
		}
		if(cnt!=W&&t[i]=='R'&&ma[i+1][0]+cnt+1<=W)cnt++;
	}

	//左
	cnt = sc;
	rep(i,0,N){
		if(s[i]=='R')cnt++;
		if(cnt==W+1){
			cout<<"NO"<<endl;
			return 0;
		}
		if(cnt!=1&&t[i]=='L'&&-ma[i+1][1]+cnt-1>0)cnt--;
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 42888
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;

long long int getMin(long long int a, long long int b){
    if(a<b)
        return a;
    return b;
}

int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    long long int ans[n+1];
    ans[1]=0;
    ans[2]=abs(h[0]-h[1]);
    for(int i=3;i<=n;i++){
        ans[i] = getMin(ans[i-1]+abs(h[i-2]-h[i-1]),ans[i-2]+abs(h[i-3]-h[i-1]));
    }
    cout<<ans[n];
}

Measured memory_bytes: 1408
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    ns <- sort <$> replicateM n ((\[a,b]->(a,b)) . 
            map (fst . fromJust . B.readInt) . B.words <$> B.getLine) :: IO [(Int,Int)]
    print $ f k ns

f i ((n,m):ns)
    | i-m <= 0  = n
    | otherwise = f (i-m) ns
    



Measured memory_bytes: 49532
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
      	int size=sc.nextInt();
      	int[][] arr=new int[size][3];
      for(int i=0;i<size;i++){
      	for(int j=0;j<3;j++){
        	arr[i][j]=sc.nextInt();
        }
      }
      int[][] res=new int[size][3];
      res[0][0]= arr[0][0];
      res[0][1]= arr[0][1];
      res[0][2]= arr[0][2];
      for(int i=1;i<size;i++){
      	for(int j=0;j<3;j++){
          res[i][j]=Math.max(res[i-1][(j+1)%3],res[i-1][(j+2)%3])+arr[i][j];
        }
      }
      System.out.println(Math.max(res[size-1][2],Math.max(res[size-1][0],res[size-1][1])));
    }
}

Measured memory_bytes: 94900
#include <stdio.h>

int main()
{

  int A[1000],N,i,j,k,v;

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<N;i++){
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1) printf(" ");
    }
    
    printf("\n");   
  }
  
  return 0;
}



Measured memory_bytes: 2124
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if d == 0:
        print(pow(x, n, mod))
        continue
    elif x == 0:
        print(0)
        continue
    elif p == 0:
        print(0)
        continue
    elif p + n - 1 >= mod:
        print(0)
        continue
    
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)


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

const int MAX_N = 2e5;
int n;
int a[MAX_N][21];
int sum[21];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        for (int j = 0; x > 0; j++) {
            a[i][j] = x & 1;
            x >>= 1;
        }
    }

    long ans = n;
    for (int i = 0, j = 0; i < n; i++) {
        bool judge = true;
        while (j < n && judge) {
            for (int k = 0; k < 21; k++) {
                if (sum[k] + a[j][k] > 1) {
                    judge = false;
                    break;
                }
            }
            if (judge) {
                ans += j - i;
                for (int k = 0; k < 21; k++) sum[k] += a[j][k];
                j++;
            }
        }
        for (int k = 0; k < 21; k++) sum[k] -= a[i][k];
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 16512
#include <stdio.h>
int main()
{

    int i,a,b,c,j,n,m,k,l;
    scanf("%d%d%d",&l,&a,&b);
    i=l+a;
    j=l+b;
    k=a+b;
    if(i<=j&&i<=k){
        printf("%d\n",i);
    }
    else if(j<=i&&j<=k){
        printf("%d\n",j);
    }
    else{
        printf("%d\n",k);
    }
    return 0;
}



Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(v1, v2 int) int {
	if v1 < v2 {
		return v1
	}
	return v2
}

func main() {
	var dp [100005]int

	sc.Split(bufio.ScanWords)
	n := nextInt()
	var h []int
	for i := 0; i < n; i++ {
		h = append(h, nextInt())
		dp[i] = math.MaxInt32
	}

	dp[0] = 0
	dp[1] = abs(h[0] - h[1])
	for i := 2; i < n; i++ {
		dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]))
	}
	ans := dp[n-1]
	fmt.Println(ans)
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	int N,M,K;
	cin >> N >> M >> K;
	vector<int>a(N),as(N + 1);
	REP(i,N){
		cin >> a[i];
		as[i + 1] += as[i] + a[i];
	}
	vector<int>b(M);
	REP(i,M){
		cin >> b[i];
	}
	int ans = 0;
	REP(i,M + 1){
		if(i)K -= b[i - 1];
		if(K < 0)continue;
		int it = upper_bound(ALL(as),K) - as.begin();
		//out(i,K,it);
		CHMAX(ans,i + it - 1);
	}
	out(ans);
}

Measured memory_bytes: 8008
#include<iostream>

using namespace std;
int main(){
int a,b;
char op;
while(1){
cin >> a >> op >> b;

if(op=='?')break;
if(op=='+')cout << a+b << endl;
else if (op=='-')cout << a-b <<endl;
else if (op=='*')cout << a*b <<endl;
else if (op=='/')cout << a/b <<endl;
}

return 0;

}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(rall(t));
    rep(i,s.size()){
        if (s[i] < t[i]){
            cout << "Yes" << endl;
            return 0;
        }
        if (s[i] > t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    if (s.size() >= t.size()){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#define ll long long
#define vel vector<int>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define mp make_pair 
using namespace std;
int main() {
	int n; cin >> n;
	int ans = n * 1000;
	vel wa(3);
	cin >> wa[1] >> wa[2] >> wa[0];
	int rui = 1;
	vel l(n);
	for (int i = 0; i < n; i++) { rui *= 4; cin >> l[i]; }
	for (int i = 0; i < rui; i++) {
		vel x(n);
		int mi = i;
		vel mak(4);
		vel ko(4, 0);
		for (int j = 0; j < n; j++) {
			int kin = mi % 4;
			mi = mi / 4;
			mak[kin] += l[j];
			ko[kin]++;
		}
		if (ko[0] > 0 and ko[1] > 0 and ko[2] > 0) {
			int qans = (ko[0] + ko[1] + ko[2] - 3) * 10;
			for (int j = 0; j < 3; j++) {
				qans += abs(mak[j] - wa[j]);
			}
			ans = min(ans, qans);
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main()
{
    int K;
    cin >> K;
    int s = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            int gcdab = __gcd(a, b);
            for (int c = 1; c <= K; c++)
                s += __gcd(c, gcdab);
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

void output_yoko(vector<char> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}


signed main() {
    int d,t,s; cin>>d>>t>>s;

    if(d<=t*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int MAX = 20; 

int main(){
	
    int num;
    int p[MAX];
  	int count=0;	
  
  	cin >>num;
  
  	for(int i=0;i<num;i++){
      cin>>p[i];
    }
  
  	for(int i=0;i<num-2;i++){
      if(p[i]<p[i+2]){
      	if(p[i]<=p[i+1]&&p[i+1]<p[i+2])count++;
      }else if(p[i]>p[i+2]){
      	if(p[i]>p[i+1]&&p[i+1]>=p[i+2])count++;
      }else if(p[i]==p[i+2]){
      	if(p[i]>p[i+1])count++;
      }
    }
  	
  	cout<<count;	
  
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
using L = long long int;
int main(){
	int h,n;
	L sum = 0;
	cin >> h >> n;
	for(int i = 0;i < n;i++){
		int buf;
		cin >> buf;
		sum += buf;
	}
	if(sum >= h){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    string str; cin >> str;
    vector<int> nums(26);
    for (auto c : str)
        nums[c-'a']++;
    for (auto n : nums)
        if ((n & 2 != 0)) {
            cout << "No" << endl; return 0;
        }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
inf = float('inf')
N = int(input())
A = []
B = []
for _ in range(N):
    A.append(tuple(map(int, input().split())))
for _ in range(N):
    B.append(tuple(map(int, input().split())))
B.sort(key=lambda t: t[0])

count = 0
for i in range(N):
    x, y = B[i]
    max_y = -1
    idx = -1
    for j in range(len(A)):
        tx, ty = A[j]
        if x > tx and y > ty:
            if max_y < ty:
                max_y = ty
                idx = j
    if idx >= 0:
        A.pop(idx)
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define chmin(x, v) x = min(x, v)
using namespace std;

int main()
{
   int n;
   cin >> n;
   int dp[n+1], h[n];
   for (int i=0;i<=n;++i)dp[i]=pow(10, 9);
   for (int i=0;i<n;++i)cin>>h[i];
   dp[0] = 0;
   
   for (int i=0;i<n;++i)
   {
     //  co
       if ( i < n - 1)  
           chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
       if (i < n -2)
           chmin(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
   }
   cout << dp[n-1];
   return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();


		int count = 0;
		for(int i = 0; i <= S.length(); i++) {
			int tmpCount = 0;
			for(int j = i + 1; j <= S.length(); j++) {
				String tmp = S.substring(i, j);
				int num = tmp.length() - 1;
				if(tmp.substring(num).equals("A") || tmp.substring(num).equals("C") || tmp.substring(num).equals("G") || tmp.substring(num).equals("T")) {
					tmpCount++;
				}else {
					break;
				}
			}
			if(count < tmpCount) count = tmpCount;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
ll prime[100002];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);

ll mul(ll a, ll b){
    ll ans= ((a%mod)*(b%mod))%mod;
    return ans%mod;
}

vector<ll>ft;
void solve(){
    ll n;
    cin >> n;
    ll a = (exp(10,n))%mod;
    ll b =(exp(8,n))%mod;
    ll c = 0;
    for(ll i=1;i<=n;i++){
        ll temp=(ncr(n,i))%mod;
        ll semp=(exp(8,n-i))%mod;
        c=(c+(mul(temp,semp)) )%mod;
        c=c%mod;
    }
    if(n==1){cout<<"0";return;}
    c=mul(2,c);
    c=c%mod;
    a=(a-b+mod)%mod;
    a=(a-c+mod)%mod;
    cout<<(a)%mod<<endl;
}
int main()
{
    ll t=1;
    ft.pb(1);
    fact(10000001);
    //cin >> t;
    while(t--) {
        solve();
    }
}

//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res%mod;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n)
{
    return floor(log10(n) + 1);
}


Measured memory_bytes: 134320
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
ans=0
for i in range(1,n+1):
    if len(str(i))%2==1:
        ans+=1
print(ans)



Measured memory_bytes: 63852
#include<iostream>
#include<vector>
#include<algorithm>
#define pb push_back
const int INF=1e9;
using namespace std;
int n,m,s,t;
int dist[222][222];
int u[2222],v[2222],d[2222],c[2222];
struct FordFulkerson{
    struct Edge { 
        int to,cap,rev; 
        Edge(int to=0,int cap=0,int rev=0) :
            to(to),cap(cap),rev(rev){}
    };

    int V;
    vector<vector<Edge> > G;
    vector<bool> used;

    FordFulkerson(int V) : V(V) {
        G.resize(V);
        used.assign(V,false);
    }

    void add_edge(int from,int to,int cap) {
        G[from].pb(Edge(to,cap,G[to].size()));
        G[to].pb(Edge(from,0,G[from].size()-1));
    }

    int dfs(int v,int t,int f) {
        if(v==t) return f;
        used[v]=true;
        for(int i=0;i<G[v].size();i++) {
            Edge &e=G[v][i];

            if(!used[e.to] && e.cap>0) {
                int d=dfs(e.to,t,min(f,e.cap));
                if(d>0) {
                    e.cap-=d;
                    G[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s,int t) {
        int flow=0;
        while(1) {
            used.assign(V,false);
            int f=dfs(s,t,INF);
            if(f==0) break;
            flow+=f;
        }

        return flow;
    }
};
int main()
{
	cin>>n>>m>>s>>t;s--;t--;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i!=j)dist[i][j]=1e9;
	for(int i=0;i<m;i++)
	{
		cin>>u[i]>>v[i]>>d[i]>>c[i];
		u[i]--;v[i]--;
		dist[u[i]][v[i]]=d[i];
	}
	for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
	FordFulkerson ff(n);
	for(int i=0;i<m;i++)
	{
		if(dist[s][u[i]]+d[i]+dist[v[i]][t]==dist[s][t])
		{
			ff.add_edge(u[i],v[i],c[i]);
		}
	}
	cout<<(ff.max_flow(s,t))<<endl;
	return 0;
}


Measured memory_bytes: 3304
#include<iostream>
using namespace std;
int main() {
    long long a,b,t,GCD,LCM,g;
    while(cin >> a >> b) {
        g = a*b;
        while(b) {
            t = b;
            b = a % b;
            a = t;
        }
        GCD = a;
        LCM = g/a;
        cout << GCD << " " << LCM << endl;
    }
    return 0;
}

Measured memory_bytes: 3000
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let x:u64 =read();
    let ans = if x < 1200 {
        "ABC"
    } else {
        "ARC"
    };
    println!("{}",ans );
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>


using namespace std;
int main(){
    long int N; cin >> N;
    vector<long int> L(N+1);
    L[0]=2; L[1]=1;
    for (int i=2;i<=N;i++) L[i]=L[i-1]+L[i-2];
    cout << L[N] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pc1(const P& firstElof, const P& secondElof)
{//first降順
	return firstElof.first > secondElof.first;
}
bool pc2(const P& firstElof, const P& secondElof)
{//first昇順
	return firstElof.first < secondElof.first;
}
bool pc3(const P& firstElof, const P& secondElof)
{//second降順
	return firstElof.second > secondElof.second;
}
bool pc4(const P& firstElof, const P& secondElof)
{//second昇順
	return firstElof.second < secondElof.second;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector < pair < ll , ll >> AB(N);
	rep(i, N) {
		cin >> AB[i].first>>AB[i].second;
	}
	sort(AB.begin(), AB.end(), pc2);
	ll  count = 0;
	ll ans = 0;
	int i = 0;
	//cout << 1 << endl;
	while (count != M) {
		if (i > AB.size()-1) {
			break;
		}
		ans += AB[i].first*AB[i].second;
		count += AB[i].second;
	//	cout << count << endl;
		//cout <<"a"<< ans << endl;
		if (count > M) {
		 	ans -= (count - M)*AB[i].first;
			count = M;
		
		}
		i++;
		//cout << ans << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
from itertools import permutations

N,M = map(int,input().split())

L = [[] for i in range(N)]

for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    
    L[a].append(b)
    L[b].append(a)

P = permutations([0] + [i for i in range(1,N)])

ans = 0

for perm in P :
    visited = [0 for i in range(N)]
    visited[0] = 1
    for i in range(N-1) :
        if perm[i+1] not in L[perm[i]] :
            break
         
        if visited[perm[i+1]] :
            break
        
        visited[perm[i+1]] = 1
    
    if sum(visited) == N :
        ans += 1

print(ans)


Measured memory_bytes: 3064