akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>

using namespace std;

#define WHITE 0
#define BLACK 1

typedef struct _range {
    _range (int l, int r, int color) {
        left = l;
        right = r;
        range_color = color;
    }

    int left;
    int right;
    int range_color;
} Range;

int main() {
    while (1) {
        int i;
        int n;
        vector<Range> stones;
        stones.clear();
        int white_num = 0;

        scanf("%d", &n);
        if (!n) return 0;

        stones.push_back(Range(0, 0, WHITE));
        for (i=1;i<=n;i++) {
            int color;
            scanf("%d", &color);

            if (i%2) {
                if (stones.back().range_color == color) {
                    stones.rbegin()->right += 1;
                } else {
                    int new_left = stones.back().right;
                    stones.push_back(Range(new_left, new_left+1, color));
                }
            } else {
                vector<Range>::reverse_iterator last = stones.rbegin();
                last->range_color = color;
                last->right += 1;
            }

            if (stones.size() > 1) {
                vector<Range>::reverse_iterator it1 = stones.rbegin();
                vector<Range>::reverse_iterator it2 = stones.rbegin();
                it2++;
                if (it1->range_color == it2->range_color) {
                    it2->right = it1->right;
                    stones.pop_back();
                }
            }
        }

        vector<Range>::iterator it = stones.begin();
        while (it != stones.end()) {
            if (it->range_color == WHITE) white_num += it->right - it->left;
            it++;
        }

        printf("%d\n", white_num);
    }
}

Measured memory_bytes: 1032
#include <iostream>
#include <vector>

int main()
{
	int n, k, q;
	std::cin >> n >> k >> q;
	std::vector<int> points(n);
	for (int i = 0; i < q; ++i)
	{
		int a;
		std::cin >> a;
		++points[a - 1];
	}

	for (int point : points)
	{
		std::cout << (point > q - k ? "Yes" : "No") << std::endl;
	}
}

Measured memory_bytes: 3068
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, v, p int
	fmt.Scan(&n, &m, &v, &p)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	ok, ng := 0, n
	for ng-ok > 1 {
		mid := (ok + ng) / 2
		if check(as, mid, m, v, p) {
			ok = mid
		} else {
			ng = mid
		}
	}
	fmt.Println(ok + 1)
}

func check(as []int, x, m, v, p int) bool {
	if x <= p-1 {
		return true
	}
	if as[x]+m < as[p-1] {
		return false
	}

	point := m * v
	for i := 0; i < len(as); i++ {
		if i < p-1 || x <= i {
			point -= m
		}
	}
	if point <= 0 {
		return true
	}

	xv := as[x] + m
	for i := p - 1; i < x; i++ {
		if as[i] < xv {
			point -= xv - as[i]
		}
	}
	if point <= 0 {
		return true
	}

	return false
}


Measured memory_bytes: 7464
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			return 0;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}







Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int r,g,b,n;cin>>r>>g>>b>>n;
  int ans = 0;
  rep(i,n+1){
    rep(j,n-i+1){
      if((n-(i*r)-(j*g))%b == 0 && (n-(i*r)-(j*g)) >= 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A, B, C;
int main()
{
  cin >> A >> B >> C;
  if (A <= C && C <= B)
    cout << "Yes" << endl;
  else if (A >= C && C >= B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int N;

int main(){
  cin >> N;
  int ans = 0;
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j < 15; j++){
      if(N == 4 * i + 7 * j){
        ans ++;
      }
    }
  }
  if(ans == 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	multiset<int> st;
	for(int i = 0; i < n; ++i) {
		int a;
		cin>>a;
		st.insert(a);
	}
	int m;
	cin>>m;
	int ok = 1;
	for(int i = 0; i < m; ++i) {
		int a;
		cin>>a;
		if(st.find(a) == st.end()) ok = 0;
		else 
		st.erase(st.find(a));
	}
	if(ok) cout<<"YES\n";
	else cout<<"NO\n";
}


Measured memory_bytes: 9600
#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(void){
  int n, r;
  cin >> n >> r;
  if(n < 10) cout << r+100*(10-n) << endl;
  else cout << r << endl;
  return 0;
}

Measured memory_bytes: 3596
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;

int main() { 
	string t; cin >> t; 
	bool n,w,s,e; 
	n = w = s = e = false; 
	for( auto x : t ) 
		if( x == 'N' ) n = true; 
		else if( x == 'S' ) s = true; 
		else if( x == 'W' ) w = true; 
		else if( x == 'E' ) e = true; 

	if( (n ^ s) == false && (w ^ e) == false ) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
  int a,b,cun=0;
  cin>>a>>b;
  while(a>0){
    a=a/b;
    cun++;
  }
cout<<cun<<"\n";

  return(0);
}



Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val X = sc.nextLong()
    // レベルnのハンバーガーの層数はf(n)で表され,f(n) = 2f(n-1) + 3, f(0) = 1である.
    // つまり, レベルNのハンバーガーの場合f(N)枚であり, このうちX層食べた時のパティの枚数を知りたい.

    // もし, X < f(N) / 2 + 1 の時, ハンバーガーの真ん中の途中まで食べているので,
    // レベル N - 1 のハンバーガーを X - 1 層食べた時の パティの枚数 が答えになる.

    // X == f(N) / 2 + 1 の時, ハンバーガーの真ん中まで食べているので,
    // レベルN - 1のハンバーガーに含まれるパティの数だけ食べていることになる.

    // X > f(n) / 2 + 1 の時, ハンバーガーの真ん中よりも食べているので,
    // レベル N - 1 のハンバーガーに含まれるパティの数 +
    // レベル N - 1 のハンバーガーを X - (f(N) / 2 + 1) 層食べた時の パティの枚数 が答えになる.

    // こうして再帰的に求めていけるが, レベル 0 の ハンバーガーに含まれるパティの数は 当然 1 である.

    def solve(): Long = {
      val f = new Array[Long](N+1)
      f(0) = 1
      var i = 1
      while (i <= N) {
        f(i) = 2 * f(i-1) + 3
        i += 1
      }

      val dp = new Array[Long](N+1)
      dp(0) = 1

      // 5 枚 ,3 枚目 が半分, 4枚まで食べたい時,
      def dfs(level: Int, X: Long): Long = {
        val center = f(level) / 2 + 1
        if (X == 1) {
          if (level > 0) 0
          else 1
        } else if (X > 1 && X < center) {
          dfs(level - 1, X - 1)
        } else if (X >= center) {
          val miniBarger =
            if (dp(level - 1) != 0)
              dp(level - 1)
            else {
              dp(level - 1) = dfs(level - 1, f(level - 1))
              dp(level - 1)
            }
          if (X == center)
            miniBarger + 1
          else if (X > center && X < f(level))
            miniBarger + 1 + dfs(level - 1, X - center)
          else if (X == f(level))
            miniBarger + 1 + miniBarger
          else 0
        } else 0
      }

      dfs(N, X)
    }

    println(solve())
  }

}


Measured memory_bytes: 25504
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(a<b&&b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

//  両端から活発な子を詰めていくのが最適
// {Ai | 1<= i <= N, Aiは降順} Ai := 活発さ
// {Pi | 1<= i <= N} Pi := Aiの子供の位置
// dp[x][y] := 活発度の高い方から(x+y)人選び、x人左、y人右に詰めていったときの最大値
// dp[x][y] <- dp[x-1][y] + A[x+y]*abs(P[i] - x)
// dp[x][y] <- dp[x][y-1] + A[x+y]*abs(P[i] - (N - y + 1))

int main() {
    int N;
    cin >> N;
    vector<pair<int,int>> A(N);
    for(size_t i = 0; i < N; ++i) {
        cin >> A[i].first;
        A[i].second = i+1;
    }
    
    sort(A.begin(), A.end(), greater<pair<int,int>>());
    vector<vector<long long>> dp(N+1,vector<long long>(N+1, 0LL));

    for(int sm = 1; sm <= N; ++sm) {
        long long a = A[sm-1].first;
        long long pos = A[sm-1].second;
        for(int x = 0; x <= sm; ++x) {
            int y = sm - x;
            if(x > 0) dp[x][y] = max(dp[x][y], dp[x-1][y] + a*abs(pos - x));
            if(y > 0) dp[x][y] = max(dp[x][y], dp[x][y-1] + a*abs(pos - (N - y + 1)));
        }
    }
    long long res = 0LL;
    for(int x = 0; x <= N; ++x) {
        res = max(res, dp[x][N-x]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 34612
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    if(a<=5){
        cout<<0<<endl;
    }
    else if(a<=12){
        cout<<b/2<<endl;
    }
    else{
        cout<<b<<endl;
    }
    
}

Measured memory_bytes: 256
from collections import deque
def mbfs(S,H,W,sh,sw):
    dist=[[-1]*W for i in range(H)]
    dist[sh][sw]=0

    d=deque()
    d.append([sh,sw])
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    while(len(d)!=0):
        h=d[0][0]
        w=d[0][1]
        d.popleft()
        for dir in range(4):
            nh=h+dx[dir]
            nw=w+dy[dir]
            if(nh>H-1 or nh<0 or nw>W-1 or nw<0):
                continue
            if(dist[nh][nw]!=-1 or S[nh][nw]=='#'):
                continue
            dist[nh][nw]=dist[h][w]+1
            S[nh][nw]=='#'
            d.append([nh,nw])
    return dist

H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())
cnt=0
for i in range(H):
    for j in range(W):
        if(S[i][j]=='#'):
            cnt+=1


li=mbfs(S,H,W,0,0)
if(li[H-1][W-1]!=-1):
    print(H*W-cnt-(li[H-1][W-1]+1))
else:
    print(-1)

Measured memory_bytes: 3316
def main():
    import copy
    n = int(input())
    if n==1:
        print(0)
        return
    k = copy.deepcopy(int(n**0.5)+2)
    ans = 0
    for i in range(2,k):
        if n%i==0:
            m = 1
            ans += 1
            n = n//i
            cnt = 0
            while n%i==0:
                n = n//i
                cnt += 1
                if cnt > m:
                    m = m+1
                    cnt = 0
                    ans += 1
        if n==1:
            break
    if ans==0:
        print(1)
        return
    if n!=1:
        print(ans+1)
        return
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9548
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind (int n) {
        par.resize(n, -1);
        rank.resize(n, 1);
    }
    int root (int n) {
        if (par[n] == -1) return n;
        return par[n] = root(par[n]);
    }
    void unite (int n, int m) {
        n = root(n);
        m = root(m);
        if (n == m) return;
        if (rank[n] < rank[m]) {
            par[n] = m;
        } else {
            par[m] = n;
            if (rank[n] == rank[m]) {
                rank[n]++;
            }
        }
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> edge(m);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        edge[i] = make_pair(a, b);
    }
    int ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if (i == j) continue;
            uf.unite(edge[j].first, edge[j].second);
        }
        set<int> roots;
        rep(j, n) roots.insert(uf.root(j));
        if (roots.size() > 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, z, w;
    cin >> n >> z >> w;
    VI a(n);
    REP(i, n) cin >> a[i];
    if(n == 1) cout << abs(w - a[n - 1]) << "\n";
    else cout << max(abs(w - a[n - 1]), abs(a[n - 2] - a[n - 1])) << "\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

int KH[300001], KW[300001];
int h[300001], w[300001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int H, W, M;
	cin >> H >> W >> M;

	rep(i, M) {
		cin >> h[i] >> w[i];
		KH[h[i]]++;
		KW[w[i]]++;
	}

	int saidaih = -1, hh = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			hh = 1;
		}
		else if (saidaih == KH[i]) hh++;
	}
	int saidaiw = -1, ww = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			ww = 1;
		}
		else if (saidaiw == KW[i]) ww++;
	}

	ll are = ll(hh) * ww;

	int kazu = 0;
	rep(i, M) {
		kazu += (KH[h[i]] == saidaih && KW[w[i]] == saidaiw);
	}

	if (kazu == are) co(saidaih + saidaiw - 1);
	else co(saidaih + saidaiw);

	Would you please return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

const int Nmax=201712;
vi wafBuffer[Nmax];
int wafBufferUsed;

struct Waf{
	vi*ptr;
	Waf(){
		ptr=wafBuffer+wafBufferUsed++;
	}
	void push_front(int v){
		ptr->PB(v);
	}
	int size(){
		return ptr->size();
	}
	int& operator[](int i){
		return ptr->at(size()-1-i);
	}
};

vi tr[Nmax];
Waf dfs(int v){
	if(tr[v].empty()){
		Waf res;
		res.push_front(modInv(2));
		return res;
	}
	vector<Waf> ws;
	for(auto ch:tr[v])
		ws.PB(dfs(ch));
	sort(ALL(ws),[&](Waf a,Waf b){
		return a.size()>b.size();
	});
	if(int(ws.size())>=2){
		REP(i,ws[1].size()){
			int dp[3]{1,0,0};
			REP(j,ws.size()){
				if(ws[j].size()<=i)break;
				for(int k=1;k>=0;k--){
					add(dp[k+1],dp[k]*ws[j][i]);
					int x=1;sub(x,ws[j][i]);
					mult(dp[k],x);
				}
			}
			ws[0][i]=dp[1];
		}
	}
	ws[0].push_front(modInv(2));
	return ws[0];
}

signed main(){
	int n=read();
	REP(i,n)
		tr[read()].PB(i+1);
	Waf w=dfs(0);
	int ans=0;
	REP(i,w.size())
		add(ans,w[i]);
	mult(ans,modPow(2,n+1));
	cout<<ans<<endl;
}

Measured memory_bytes: 53240
n = int(input())
b = list(map(int, input().split()))
ans = []

while b:
    for i in range(len(b)-1, -1, -1):
        if b[i] == i+1:
            ans += [b.pop(i)]
            break

    else:
        print(-1)
        exit()

for i in ans[::-1]:
    print(i)

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

int main()
{
	int num;
	cin >> num;
	int* T = new int[num];
	for (int i = 0; i < num; i++)
	{
		cin >> T[i];
	}
	int num1=0;
	for(int i=0;i<num;i++)
	{
		int mini = i;
		for(int j=i+1;j<num;j++)
		{
			if(T[j]<T[mini])
				mini = j;
		}
		if(mini!=i)
		{
			swap(T[i], T[mini]);
			num1++;
		}
	}
	for (int j = 0; j < num; j++)
	{
		cout << T[j] << (j == num - 1 ? '\n' : ' ');
	}
	cout << num1 << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>

void funcB() {
  int n, m, sum = 0;
  std::cin >> n >> m;
  std::vector<int> a(n,0);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    sum += a[i];
  }
  int overq = 0;
  for (int i = 0; i < n; i++) if (4 * a[i] * m >= sum)overq++;
  std::cout << (m <= overq ? "Yes" : "No");
}

int main(void) {
  funcB();
  return 0;
}

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

int main()
{
    int ans=0,cnt=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
        ++cnt;
        else
            cnt=0;
        ans=max(ans,cnt);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3524
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define MAX_V 100
#define MAX_B 100

struct edge{pii to;int cost;};
vector<edge> G[MAX_V][MAX_B+1];
int d[MAX_V][MAX_B+1];

void dijkstra(pii s){
    priority_queue< pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > que;
    rep(i,MAX_V)rep(j,MAX_B+1)d[i][j]=INF;
    d[s.first][s.second]=0;
    que.push(make_pair(0,s));
    
    while(que.size()){
        pair<int,pii> p=que.top();
        que.pop();
        
        int v=p.second.first;
        int b=p.second.second;
        if(d[v][b]<p.first)continue;
        
        rep(i,G[v][b].size()){
            edge e=G[v][b][i];
            if(d[e.to.first][e.to.second]>d[v][b]+e.cost){
                d[e.to.first][e.to.second]=d[v][b]+e.cost;
                que.push(make_pair(d[e.to.first][e.to.second],e.to));
            }
        }
    }
}

int main(){
    int v,e,l;
    while(cin>>v>>e>>l&&(v||e||l)){
        rep(i,MAX_V)rep(j, MAX_B+1)G[i][j].clear();
        rep(i,e){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            a--,b--;
            rep(i,l+1){
                G[a][i].pb(edge{pii(b,i),d});
                if(i+c<=l)G[a][i].pb(edge{pii(b,i+c),0});
            }
            rep(i,l+1){
                G[b][i].pb(edge{pii(a,i),d});
                if(i+c<=l)G[b][i].pb(edge{pii(a,i+c),0});
            }
        }
        
        dijkstra(pii(0,0));
        int ans = INF;
        rep(i,l+1)ans = min(ans,d[v-1][i]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 12860
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int l = s.length();
    if (s[0] == s[l - 1]) {
        if (l % 2 == 0)
            return cout << "First" << endl, 0;
        else
            return cout << "Second" << endl, 0;
    }
    else {
        if (l % 2 == 0)
            return cout << "Second" << endl, 0;
        else
            return cout << "First" << endl, 0;
    }
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"strconv"
	"math"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	var ans = solve(a, b)
	if float64(ans) == math.Pow(float64(int(math.Sqrt(float64(ans)))), 2) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func solve(a int, b int) int {
	var tmp_a, tmp_b string
	tmp_a = strconv.Itoa(a)
	tmp_b = strconv.Itoa(b)

	var ref int
	ref, _ = strconv.Atoi(tmp_a + tmp_b)

	return ref
}


Measured memory_bytes: 1836
#include <iostream>

using namespace std;

int main()
{
   int A,B;
   cin>>A>>B;
   if(A==1){
       A=14;
   }
   if(B==1){
       B=14;
   }
   if(A>B){
       cout<<"Alice"<<endl;
   }
   else if(A<B){
       cout<<"Bob"<<endl;
   }
   else{
       cout<<"Draw"<<endl;
   }
   return 0;
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	stack<char>st;
	string front = "", back = "";
	for (int i = 0;i < n;++i) {
		if (s[i] == ')') {
			if (st.empty()||st.top()==')')front = front + "(";
			else if (st.top() == '(')st.pop();
		}
		else st.push(s[i]);
	}
	while (st.size()) {
		back = back + ")";
      	st.pop();
	}
	cout << front << s << back << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac,k2,gk2;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  k2.push_back(1);
  gk2.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
    k2.push_back(k2[i-1]*2%mod);
    gk2.push_back(gyaku(k2[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}

int main(){
  ll b,w;
  cin>>b>>w;
  set_frac(b+w+100);
  ll f=gk2[w+1],g=gk2[b+1];
  for(int i=1;i<=b+w;i++){
    ll ans=gyaku(2);
    if(i>w){
      ans+=f;
      ans%=mod;
      f+=nCr(i-1,i-w)*gk2[i+1]%mod;
      f%=mod;
    }
    if(i>b){
      ans-=g;
      ans+=mod;
      ans%=mod;

      g+=nCr(i-1,i-b)*gk2[i+1]%mod;
      g%=mod;
    }
    cout<<ans/*<<" "<<f<<" "<<g*/<<endl;
  }
}


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

using namespace std;
using ll = long long;

const int nax = 405;

vector<ll> ar(nax);
vector<vector<ll>> dp(nax, vector<ll>(nax, -1));

ll sum(int l, int r) {
  ll res = 0;
  for(int i = l; i <= r; ++i) res += ar[i];
  return res;
}

ll rec(int l, int r) {
  if(l >= r) {
    return 0;
  }
  if(dp[l][r] != -1) {
    return dp[l][r];
  }
  ll x = 1e18;
  ll ad = sum(l, r);
  for(int i = l; i < r; ++i) {
    x = min(x, rec(l, i) + rec(i + 1, r) + ad);
  }
  return dp[l][r] = x;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  cout << rec(0, n - 1) << '\n';
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <unordered_set>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int i = 1, j = n;
	bool ch = false;
	for (int k = 0; k < m; k++) {
		int a = i + n - j;
		int b = j - i;
		if (ch == false && (a + b) % 2 == 0 && a >= b) {
			j--;
			ch = true;
		}
		cout << i++ << " " << j-- << endl;
	}
	return 0;
}


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

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


    if (N>=10) {
        cout << R << endl;
    } else {
        cout << R+100*(10-N) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  int N,M; scanf("%d %d",&N,&M);
  pair<int,int> s[N],c[M];
  rep(i,N) scanf("%d %d",&s[i].first,&s[i].second);
  rep(j,M) scanf("%d %d",&c[j].first,&c[j].second);

  rep(i,N){
    int min_dist = E9+10;
    int min_ind = 0;
    rep(j,M){
      int dist = abs(s[i].first-c[j].first) + abs(s[i].second-c[j].second);
      if (min_dist > dist){
        min_dist = dist;
        min_ind = j;
      } 
    }
    cout << min_ind+1 << endl;
  }



  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	ll int a[n];
	ll int sum[n+1];
	sum[0] = 0;
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
		sum[i+1] = a[i] + sum[i];
	}

	ll int dp[n][n];
	memset(dp, 1, sizeof(dp));
	for (int g = 0; g < n; ++g)
	{
		for (int i = 0, j = i+g; i < n and j< n; ++i, j++)
		{
			if( i == j)
				dp[i][j] = 0;
			for(int k = i; k < j; k++)
			{
				dp[i][j] = min( dp[i][j] , dp[i][k] + dp[k+1][j] + (sum[k+1] - sum[i]) + (sum[j+1] - sum[k+1]) );
			}
		}
	}
	cout << dp[0][n-1];

}

Measured memory_bytes: 1536
import sys
H = input()

def main():
    A = map(int,raw_input().split())
    buildMaxHeap(A)
    for i in A:
        sys.stdout.write(" {}".format(i))
    print ""

def maxHeapify(A,i):
    l = 2*i
    r = 2*i+1
    if l <= H and A[l-1] > A[i-1]:
        largest = l
    else:
        largest = i
    if r <= H and A[r-1] > A[largest-1]:
        largest = r

    if largest != i:
        v = A[i-1]
        A[i-1] = A[largest-1]
        A[largest-1] = v
        maxHeapify(A,largest)

def buildMaxHeap(A):
    for j in range(H/2):
        i = H/2-j
        maxHeapify(A,i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 49676
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

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

    cout<<n*(n-1)/2<<endl;
}

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


int main()
{    
    string S;
    cin >> S;

    string R{S.rbegin(),S.rend()};
    
    int Q;
    cin >> Q;

    int a=1;
    string F="";
    string B="";
    for (int i = 0; i < Q; ++i) {
        int q;
        cin >> q;

        if (q==1){
            a*=-1;
        }
        if (q==2){
            int q;
            cin >> q;
            char c;
            cin >> c;
            if (a==1){
                if (q==1){
                    F=c+F;
                    
                }
                if (q==2){
                    B=B+c;
                    
                }
            }
            if (a==-1){
                if (q==1){
                    B=B+c;
                    
                }
                if (q==2){
                    F=c+F;
                   
                }
            }
        }
    }

    if (a==-1){
        reverse(F.begin(),F.end());
        reverse(B.begin(),B.end());
        cout << B+R+F << endl;
    }
    if (a==1){
        cout << F+S+B << endl;
    }
    return 0;
}

Measured memory_bytes: 1544
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
map<pair<int, int>, int> futon;
map<pair<int, int>, int> color;
int futonX[30000];
int futonY[30000];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

bool dfs(int x, int y, int c) {
  if (color[make_pair(x, y)] != -1) {
   if (color[make_pair(x, y)] == c) { return true; }
   else { return false; }
  }
  color[make_pair(x, y)] = c;
  REP(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (!futon.count(make_pair(nx, ny))) { continue; }
    int nc = c;
    if (futon[make_pair(nx, ny)] == futon[make_pair(x, y)]) { nc ^= 1; }
    if (!dfs(nx, ny, nc)) { return false; }
  }
  return true;
}

int main() {
  while (scanf("%d", &n), n) {
    futon.clear();
    color.clear();
    REP(i, n) {
      int x, y;
      char c;
      scanf("%d %d %c", &x, &y, &c);
      futonX[i] = x;
      futonY[i] = y;
      int dir = c == 'x' ? 0 : 1;
      REP(j, 2) {
        int nx = x + dx[dir] * j;
        int ny = y + dy[dir] * j;
        futon[make_pair(nx, ny)] = i;
        color[make_pair(nx, ny)] = -1;
      }
    }
    REP(i, n) {
      int x = futonX[i];
      int y = futonY[i];
      if (color[make_pair(x, y)] != -1) { continue; }
      if (!dfs(x, y, 0)) {
        puts("No");
        goto next;
      }
    }
    puts("Yes");
next:;
  }
}

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> time(5);
  rep(i,5) cin >> time[i];
  sort(time.begin(), time.end());
  ll MIN = time[0];
  cout << (n + MIN - 1)/MIN + 4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

struct edge {
	int to, cost;
};
vector<edge> G[100010];
vector<int> vis(100010, INF);

bool res = true;

void bfs(int k) {
	queue<P> que;
	que.push(P(k, 0));
	vis[k] = 0;
	
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		int s = p.first;
		for (int i = 0; i < (int)G[s].size(); i++) {
			edge e = G[s][i];
			if (vis[e.to] == INF) {
				vis[e.to] = vis[s] + e.cost;
				que.push(P(e.to, vis[e.to]));
			}
			else if (vis[e.to] != vis[s] + e.cost) {
				res = false;
			}
		}
	}
}

int main()
{
	int N, M;
	cin >> N >> M;
	int l, r, d;
	for (int i = 1; i <= M; i++) {
		cin >> l >> r >> d;
		G[l].push_back(edge{ r, d });
		G[r].push_back(edge{ l, -d });
	}
	for (int i = 1; i <= N; i++) {
		if (vis[i] == INF && G[i].size() != 0) bfs(i);
	}
	if (res) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
string s, ans = "ABC";
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> s;
  if(s == "ABC") {
  	ans = "ARC";
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s, t, u;
    int a, b, ans = 0;
    cin >> s >> t >> a >> b >> u;
    if(s == u){
        a--;
    }else{
        b--;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int m;
  for(int i=1;i<=10000;i++){
    if(i*(i+1)/2>=n){
      m=i;
      break;
    }
  }
  for(int i=1;i<=m;i++){
    if(i!=m*(m+1)/2-n){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
def solve1(t, x, y):
    ax = abs(x)
    ay = abs(y)
    if ax > t:
        return False
    t -= ax
    ax = 0
    if ay > t:
        return False
    t -= ay
    ay = 0
    if t % 2 != 0:
        return False
    return True

def solve(txy):
    t, x, y = 0, 0, 0
    for e in txy:
        if not solve1(e[0] - t, e[1] - x, e[2] - y):
            return False
        t, x, y = e
    return True

N = int(input())
txy = []
for i in range(N):
    txy.append([int(x) for x in input().split()])

if solve(txy):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		
		loop:	for(int i = a; i <= Integer.MAX_VALUE ; i++) {
			for(int j = 2; j <= (int)Math.sqrt(i) ; j++) {
				if(i % j == 0) {
					continue loop;
				}
			}
			
			System.out.println(i);
			return;
		}
	}

}


Measured memory_bytes: 22996
/**
*    created: 07.07.2020 18:55:08
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int a; cin >> a;
        if (1 <= a and a < 400) mp[0]++;
        else if (400 <= a and a < 800) mp[1]++;
        else if (800 <= a and a < 1200) mp[2]++;
        else if (1200 <= a and a < 1600) mp[3]++;
        else if (1600 <= a and a < 2000) mp[4]++;
        else if (2000 <= a and a < 2400) mp[5]++;
        else if (2400 <= a and a < 2800) mp[6]++;
        else if (2800 <= a and a < 3200) mp[7]++;
        else mp[8]++;
    }
    
    if (!mp.count(8)) cout << mp.size() << " " << mp.size() << endl;
    else cout << max((int)mp.size()-1ll,1ll) << " " << (int)mp.size() - 1ll + mp[8] << endl;
    return 0;
}


Measured memory_bytes: 3556
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    Set<String> ans = new HashSet<>();
    for (int i = 0; i < n; i++) {
      ans.add(sc.next());
    }
    pw.println(ans.size());
  }
}


Measured memory_bytes: 76680
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

import Debug.Trace

import GHC.Exts

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m ] <- readInts
	ps <- sortWith snd . map ( id *** pred ) . map mp <$> replicateM m readInts
	print $ solve ps

solve [] = 0
solve ( ( a, b ) : ps ) = 1 + solve ( dropWhile ( \( x, y ) -> x <= b && b <= y ) ps )

Measured memory_bytes: 89468
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

string s;

int main(){
	cin>>s;
	for(string::iterator i=s.begin();i!=s.end();i++){
		*i-=3;
		if(*i<'A') *i+=26;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1180
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int getDigits(int i) {
  if (i < 10) return 1;
  if (i < 100) return 2;
  if (i < 1000) return 3;
  if (i < 10000) return 4;
  if (i < 100000) return 5;
  if (i < 1000000) return 6;
  return 0;
}

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

  int count = 0;
  for (int i = 1; i <= N; i++) {
    int d = getDigits(i);
    if (d % 2 == 1) count += 1;
  }

  cout << count << 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 = Integer.parseInt(sc.next());

      int[] L = new int[n];
      for(int i=0;i<n;i++){
        L[i] = Integer.parseInt(sc.next());
      }

      Arrays.sort(L);

      int cnt = 0;

      for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
          for(int k=j+1;k<n;k++){
            boolean a = (L[i]<(L[j]+L[k]));
            boolean b = (L[j]<(L[k]+L[i]));
            boolean c = (L[k]<(L[i]+L[j]));
            if(a && b && c){
              cnt++;
            }
            int sa1=0,sa2=0,sa3=0;
            if(!a){
              sa1 = L[i]-L[j]-L[k];
            }
            if(!b){
              sa2 = L[j]-L[k]-L[i];
            }
            if(!c){
              sa3 = L[k]-L[i]-L[j];
            }
            i += sa1;
            j += sa2;
            k += sa3;
            if(j>=n-1 || i>=n-2){
              break;
            }
          }
          if(i>=n-2){
            break;
          }
        }
      }


      System.out.println(cnt);

    }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 099 C / Link: http://abc099.contest.atcoder.jp/tasks/abc099_c  ----- */


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

	LL N; 
	cin >> N;
	

	VL a;
	a.push_back(1);
	FOR(i, 1, 7){
		a.push_back(pow(9, i));
		a.push_back(pow(6, i));
	}
	VL dp(N + 1, LINF);
	dp[0] = 0;
	for (auto it : a) {
		FOR(i, 0, N - it + 1) {
			dp[i + it] = min(dp[i + it], dp[i] + 1);
		}
	}
	LL ans = dp[N];
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 1024
import sys
from math import sqrt, floor

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


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


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


def main():
    a, b, n = MI()

    if b - 1 <= n:
        print((a * (b - 1)) // b)
    else:
        print((a * n) // b - (a * (n // b)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
struct seed{
  string l;
  int p,a,b,c,d,e,f,s,m;
  double n;
  double r,t;
  int i,j;
  void k(){
    t = a+b+c + (d+e) * m;
    r = f*s*m-p;
    n = r / t;
  }
  bool operator<(const seed & a)const{
    return n==a.n ? (l<a.l) : n > a.n;
  }
};
int main(){
  int n;
  int i,j,k;
  cin >> n;
  while(n!=0){
    vector <seed> ss;
    seed s;
    for(i=0;i<n;i++){
      cin >> s.l >> s.p >> s.a >> s.b >> s.c >> s.d >> s.e >> s.f >> s.s >> s.m;
      s.k();
      ss.push_back(s);
    }
    sort(ss.begin(),ss.end());
    for(i=0;i<n;i++) cout << ss[i].l << endl;
    cout << "#" <<  endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 1228
A = list(map(int,input().split()))
a = 0
k  = []
for c in range(A[0],A[1]+1):
  k.append(c)
  a += 1
  if a== A[2]:
    break;
a = 0
for c in range(A[1], A[0], -1):
  if a == A[2]:
    break;
  k.append(c)
  a += 1
k = sorted(list(set(k)))
for i in k:
  print(i)

Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;


public class Main{
    static long MOD = 998244353 ;
    static long [] fac;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt(), m = sc.nextInt();
            int lo = 1, hi = n / 2 * 2;
            boolean even = n % 2 == 0;
            for(int i = 0; i < m; i ++)
            {
                out.println(lo + " " + hi);
                lo++;
                hi--;
                if(even && (hi - lo == n / 2 - 1 || hi - lo == n / 2)) hi--;
            }
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 42480