akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	vector<int> v(2*n+1);
	REP(i,2*n+1){
	    v[i] = -1;
	}
	REP(i,n){
	    int temp;
	    cin >> temp;
	    v[temp] = 1;
	}
	vector<int> taro;
	vector<int> hana;
	FOR(i,1,2*n+1){
	    if(v[i] == 1){
		taro.PB(i);
	    }else if(v[i] == -1){
		hana.PB(i);
	    }
	}
	sort(ALL(taro));
	sort(ALL(hana));

	int cur = 1;
	int card = -1;
	while(taro.size() > 0 && hana.size() > 0){
	    if(cur == -1){
		int p = upper_bound(ALL(hana),card) - hana.begin();
		if(p < hana.size() && card < hana[p]){
		    card = hana[p];
		    hana.erase(hana.begin()+p);
		}else{
		    card = -1;
		}
	    }else if(cur == 1){
		int p = upper_bound(ALL(taro),card) - taro.begin();
		if(p < taro.size() && card < taro[p]){
		    card = taro[p];
		    taro.erase(taro.begin()+p);
		}else{
		    card = -1;
		}
	    }
	    cur *= -1;
	}
	int anst,ansh;
	anst = hana.size();
	ansh = taro.size();
	cout << anst << endl;
	cout << ansh << endl;

    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = max({a*c,a*d,b*c,b*d});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#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++)

int main(){
    int a , b;
    cin >> a >> b;
    if(b%2 == 0 && 2*a <= b && b <= 4*a)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a.back() - a.front() << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n;
	long long ans = 0;
	scanf("%d", &n);
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a.push_back(x);
		ans += x - 1;
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int[] A)
        {
            var dict = new Dictionary<int, int>();
            foreach (int a in A)
            {
                if (!dict.ContainsKey(a)) { dict[a] = 0; }
                ++dict[a];
            }
            var values = dict.Values;
            int count = values.Count(value => value % 2 == 0);
            return (count % 2 == 0) ? values.Count : values.Count - 1;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(N, A));
        }
    }
}


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

int main() {
	int N;
  	cin >> N;
    int64_t L0 = 2;
    int64_t L1 = 1;
	int64_t L2;
    if(N == 1){
    	cout << 1 << endl;
    }else{
    	for(int i = 0 ; i < N - 1 ; i++){
    		L2 = L0 + L1;
      		L0 = L1;
      		L1 = L2;
    	}
  	    //printf("%lld\n" , L2);
        cout << L2 << endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0; i<n; i++)cin>>vec[i];
    
    int m,k,ans=0;
    cin>>m;
    for(int i=0; i<m; i++){
        cin>>k;
        if(*lower_bound(vec.begin(), vec.end(), k)==k)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3136
n = int(input())
a = list(map(int,input().split()))
tmp = 0
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            tmp += 1
if tmp == 0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 9088
//AOJ0077

#include<iostream>
#include<string>
int main(){
	std::string s;
	while (std::cin >> s){
		std::string ans;
		for (int i = 0; i < s.size(); ++i){
			if (s[i] == '@'){
				std::string p(s[i + 1] - '0', s[i + 2]);
				ans.append(p);
				i += 2;
			}
			else{
				ans.push_back(s[i]);
			}
		}
		std::cout << ans << std::endl;
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

// v[i][j] := iCj
template <typename T>
std::vector<std::vector<T>> comb2(T n)
{
    std::vector<std::vector<T>> v(n + 1, std::vector<T>(n + 1, 0));
    for (int i = 0; i < (int)v.size(); i++)
    {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < (int)v.size(); j++)
    {
        for (int k = 1; k < j; k++)
        {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
            v[j][k] %= MOD;
        }
    }
    return v;
}

auto comb = comb2(1010);
vector<ll> fact(1010, 1);

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

    ll n, k;
    cin >> n >> k;
    for (int i = 2; i <= 1000; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
    }
    ll ret = 0;
    for (int i = 1; i <= k; i++)
    {
        // i 個空
        ll r = k - i;
        ll tmp = comb[k][i] * mypow(r, n) % MOD;
        if (i % 2)
            ret = (ret + tmp) % MOD;
        else
            ret = (ret - tmp + MOD) % MOD;
    }
    ret = (mypow(k, n) - ret + MOD) % MOD;
    cout << ret << endl;
}



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

int main(){
    int n;
    cin >> n;
    for(int k=2; ;k++){
        if((k-1)*k/2 > n) break;
        if((k-1)*k/2 == n){
            cout << "Yes" << endl;
            cout << k << endl;
            vector<vector<int>> ans(k);
            int index = 0;
            int t=1;
            for(int i=k-1; i>=1; i--){
                for(int j=1; j<=i; j++){
                    ans[index].push_back(t);
                    ans[index+j].push_back(t);
                    t++;
                }
                index++;
            }
            for(int i=0; i<k; i++){
                cout << k-1 << ' ';
                for(auto p=ans[i].begin(); p!=ans[i].end(); p++){
                    cout << *p << ' ' ;
                }
                cout << endl;
            }
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int k, a, b;
  cin >> k >> a >> b;
  if(a >= b-1 || k < a-1){
    cout << k+1 << endl;
    return 0;
  }
  ll tmp = 1;
  k -= (a - tmp);
  tmp = a;
  int t = k / 2;
  tmp += 1LL*t*(b-a);
  if(k % 2 != 0) tmp++;
  cout << tmp << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,a,col[8]={},x=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(a<400)col[0]++;
        else if(a<800)col[1]++;
        else if(a<1200)col[2]++;
        else if(a<1600)col[3]++;
        else if(a<2000)col[4]++;
        else if(a<2400)col[5]++;
        else if(a<2800)col[6]++;
        else if(a<3200)col[7]++;
        else x++;
    }
    int ans=0;
    for(int i=0;i<8;i++){
        if(col[i]!=0)ans++;
    }
    int min=ans;
    if(min==0)min=1;
    ans+=x;
    printf("%d %d\n",min,ans);
    return 0;
}

Measured memory_bytes: 128
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
   let (n, k): (isize, isize);
   input!(n, k);

   println!("{}", std::cmp::min(n % k, (n % k - k).abs()));
}


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

int main() {
    int n;
    vector<vector<int>> a;

    cin >> n;
    a.resize(n, vector<int> (3));
    for (vector<int> &elem : a) {
        for (int &elem_ : elem) {
            cin >> elem_;
        }
    }

    vector<vector<int>> dp(n + 1, vector<int> (3, 0));
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (k == j) {
                    continue;
                }

                dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i - 1][j]);
            }
        }
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
    return 0;
}



Measured memory_bytes: 11136
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
l = 0
for i in range(n-1):
    if (x[i+1] - x[i]) *  a <= b:
        l += (x[i+1] -x[i])*a
    else:
        l += b

print(l)

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i,n) for (int i=0; i < int(n); i++)
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num) {
	return floor(num) == num;
}

Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int n, m;
char field[100][100];

void dfs(int x, int y) {
	field[x][y] = '.';

	for (int dx = -1; dx <= 1; dx++) {
		for (int dy = -1; dy <= 1; dy++) {
			int nx = x + dx, ny = y + dy;
			if (0 <= nx && nx < n && 0 <= ny && ny < m && field[nx][ny] == 'W') {
				dfs(nx, ny);
			}
		}
	}
	return;
}





int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n * a, b) << endl;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define int long long
using namespace std;

signed main(){
	int a,b,c,x,y,ans=0;
	cin>>a>>b>>c>>x>>y;
	while(1){
		if(!x&&!y)break;
		if(!x){
			ans+=(c*2<b)?c*2:b;
			y--;
		}else if(!y){
			ans+=(c*2<a)?c*2:a;
			x--;
		}else{
			ans+=((c*2<a+b)?c*2:a+b);
			x--;y--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
fn main() {
    let mut string = String::new();
    io::stdin().read_line(&mut string).ok();
    let mut iter = string.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    let ans = if (a < b) && (b < c) { "Yes" } else { "No" };

    println!("{}", ans);
}



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

using namespace std;
#define ll long long
#define inf 998244353

int d[2005][2005], ma[2005];

int main()
{
    int n ,x ,y;
    memset(ma,0,sizeof(ma));
    scanf("%d %d %d",&n,&x,&y);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            d[i][j]=abs(j-i);
        }
    }
    d[x][y]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            d[i][j]=min(d[i][j],d[i][x]+d[x][y]+d[y][j]);
            d[j][i]=d[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            d[i][j]=min(d[i][j],d[i][x]+d[x][y]+d[y][j]);
            d[j][i]=d[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            //printf("%d ",d[i][j]);
            ma[d[i][j]]++;
        }
        //printf("\n");
    }
    for(int i=1;i<n;i++)
    {
        printf("%d\n",ma[i]/2);
    }
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int v[1111];
int n;
vector<int> ans;
void make_op(int parity, int pos = -1){
	vector<int> mark(n, 0);
	
	if(pos == -1)
		for(int i = parity; i < n; i+=2){
			if(v[i] >= 0)
			mark[i] = 1;
		}
	else mark[pos] = 1;
	//cout << pos << endl;

	while(mark.size() > 1){

		for(int l = 0; l < mark.size(); l++){
			if(mark[l]) continue;
			if(l == 0 || l == mark.size()-1){
				ans.push_back(l+1);
				mark.erase(mark.begin() + l);
				continue;
			}
			if((mark[l-1] && mark[l+1]) || (!mark[l-1] && !mark[l+1])){
				ans.push_back(l+1);
				if(mark[l-1]) mark[l] = 1;
				mark.erase(mark.begin()+l+1);
				mark.erase(mark.begin()+l-1);
				break;
			}
		}
		
	}
	cout << ans.size() <<"\n";
	for(auto &u : ans){
		cout << u << "\n";
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n;
	
	int x;
	long long p = 0;
	int qp = 0;
	long long imp = 0;
	int qi = 0;
	int ma = -1e9;
	int i_ma = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		x = v[i];
		if(x >= 0){
			if(i & 1)
				qi++, imp += x;
			else qp++, p += x;
		}
		if(x > ma){
			ma = x;
			i_ma = i;	
		}
	}
	if(qp && p >= imp){
		cout << p << "\n";
		make_op(0);
	}
	else if(qi && imp > p){
		cout << imp << "\n";
		make_op(1);
	}
	else {
		cout << ma << "\n";
		make_op(0, i_ma);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int>> inp;
vector<int> dp;

void graph_dp(int i)
{
    int ans=0;
    for(auto ele:inp[i])
    {
        if(dp[ele] == -1) graph_dp(ele);
        ans = max(ans,1 + dp[ele]);
    }
    dp[i] = ans;
}  

int driver()
{
    dp.assign(n,-1);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i] == -1) graph_dp(i);
        ans = max(ans,dp[i]);
    }
    return ans;
}

 

int main()
{
    /*ifstream cinp;
    cinp.open("input.txt");
    ofstream coutp;
    coutp.open("output.txt");
*/
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n>>m;
    inp.resize(n);

    for(int i=0;i<m;i++)
    {
        int a, b;
        cin>>a>>b;
        inp[--a].push_back(--b);
    }
    
    cout<<driver()<<"\n";
}


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

int dp[5002][5002];

map<int,int> make_zip(vector<int> v) {
    map<int,int> ret;
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i=0; i<(int)v.size(); ++i) {
        ret[v[i]] = i+1;
    }
    return ret;
}

int compress(map<int,int> &zip, int x, bool upper=true) {
    auto it = zip.lower_bound(x);
    if (it != zip.end() && it->first == x) return it->second;
    if (upper) {
        if (it == zip.end()) return -1;
        return it->second;
    } else {
        if (it == zip.end()) return zip.rbegin()->second;
        else if (it == zip.begin()) return -1;
        return (--it)->second;
    }
}

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

    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(n);
    for (int i=0; i<n; ++i) {
        cin >> x[i] >> y[i];
    }

    auto xzip = make_zip(x);
    auto yzip = make_zip(y);
    for (int i=0; i<n; ++i) {
        int ty = compress(yzip, y[i]);
        int tx = compress(xzip, x[i]);
        dp[ty][tx] ++;
    }
    for (int i=0; i<5001; ++i) {
        for (int j=0; j<5001; ++j) {
            dp[i+1][j+1] += dp[i+1][j] + dp[i][j+1] - dp[i][j];
        }
    }

    for (int i=0; i<m; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 = compress(xzip, x1, true);
        y1 = compress(yzip, y1, true);
        x2 = compress(xzip, x2, false);
        y2 = compress(yzip, y2, false);
        if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) {
            cout << 0 << endl;
        } else {
            int cnt = dp[y2][x2] - dp[y1-1][x2] - dp[y2][x1-1] + dp[y1-1][x1-1];
            cout << cnt << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 101396
#include <string>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int len_array, num_query;
  cin >> len_array;
  vector<int> v(len_array);

  int tmp;
  for (int i = 0; i < len_array; i++) {
    cin >> tmp;
    v[i] = tmp;
  }

  cin >> num_query;

  int cmd, b, e;
  int min, max;
  for (int i = 0; i < num_query; i++) {
    cin >> cmd >> b >> e;

    min = v[b];
    max = v[b];
    if (cmd) {
      for (int j = b; j < e; j++) {
        if (max < v[j]) {
          max = v[j];
        }
      }
      cout << max << endl;
    } else {
      for (int j = b; j < e; j++) {
        if (min > v[j]) {
          min = v[j];
        }
      }
      cout << min << endl;
    }
  }
}




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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int h, w, cnt = 0;
  cin >> h >> w;
  string s;
  rep(i, h) {
    cin >> s;
    rep(j, w) if (s[j] == '#') cnt++;
  }

  cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
  return 0;
}


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

using namespace std ;
                                                                                                  
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
                                                                                                                                       
    int n ; 
    cin >> n ; 
    string s ; 
    cin >> s ;
    set<int> b ; 
   	for(int i = 0 ; i< n  ; ++i)
  	{	
   		if(s[i] == 'B')
   			b.insert(i); 	
   	}
	int cnt = 0 ;
	int v = b.size() ; 
	for(int i = 0; i < n ; ++i)
	{
		if(s[i] == 'R')
		{
			for(int j = 0; j < n ; ++j)
			{
				if(s[j] == 'G')
				{
					int d = abs(i-j) ; 
					int temp = 0 ; 
					if(b.find(i - d) != b.end())
						temp++ ; 
					if(b.find(i + d) !=  b.end())
						temp++ ; 
					if(b.find(j - d) != b.end())
						temp++ ; 
					if(b.find(j + d) !=  b.end())
						temp++ ;
					if(d%2 == 0 && b.find(min(i,j) + d/2) != b.end())
						temp++ ;
					cnt += v - temp ; 	 

				}
			}
		}
	}
   	cout << cnt ;
                                                                                                                                       
}
                                      






Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
    int a,b,c; cin >> a >>b>>c;
	if(a == b and a != c) Yes
	if(a == c and a != b) Yes
	if(b == c and a != b) Yes
	No
}

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

#define LIKE_NUM 7
#define YET 1
#define NONE -1

int array[1000000];

int main()
{
    int k;
    int answer  = 1;
    long long int tmparray = LIKE_NUM;

    scanf("%d", &k);

    for (int i = 0; i<k; i++)
    {
        array[i] = NONE;
    }

    while (1)
    {
        
        for (; tmparray<k;)
        {
            tmparray = tmparray*10 + LIKE_NUM;
            answer ++;
        }

        if ((tmparray%k) == 0)
        {
            break;
        } else {
            tmparray = tmparray%k;

            if (array[tmparray] == YET)
            {
                answer = NONE;
                break;
            } else {
                array[tmparray] = YET;
            }

        } 

    }
    
    printf("%d", answer);

    return 0;
}

Measured memory_bytes: 5584
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string a,b,c;
  cin>>a>>b>>c;
  string s = {a[0], b[0], c[0]};
  transform(s.begin(), s.end(), s.begin(), ::toupper);
  cout << s << endl;

  return 0;
}


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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;
int a[3005];
int dp2[3005][3005];

int dp[3005][3005];
int n, s;
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}

int solve(int id, int sum, int selected) {
    // debug(id, sum, selected);
    if(id == n and sum == 0) {
        // debug("here", id, sum, selected);
        // return power(2, n - selected);
        return 1;
    }
    else if(id == n)
        return 0;
    if(dp2[id][sum] != -1)
        return dp2[id][sum];
    int ans = 0;
    if(a[id] > sum) {
        ans = (1LL * 2 * solve(id + 1, sum, selected)) % mod;
    }
    else {
        ans += solve(id + 1, sum - a[id], selected + 1);
        ans %= mod;
        ans += (1LL * 2 * solve(id + 1, sum, selected)) % mod;
        ans %= mod;
    }

    return dp2[id][sum] = ans;
}
int main() {
    input;
    
    cin >> n >> s;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= s; j++) {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= mod; 
            if(j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
    }
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= s; j++) {
            // cout << dp[i][j] << ' ';
        }
        // cout << endl;
    }
    //cout << dp[n][s] << endl;
    memset(dp2, -1, sizeof dp2);
    cout << solve(0, s, 0);
}


Measured memory_bytes: 74304
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N + 1);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));

    As.push_back(0); // 最後に座標0の点に戻る

    vector<ll> diffs;
    diffs.reserve(N + 1);
    adjacent_difference(
        begin(As), end(As),
        back_inserter(diffs));

    // 全ての観光スポットを訪れる場合の金額
    auto total_cost = accumulate(begin(diffs), end(diffs), 0LL,
        [](auto acc, auto n) {
            return acc + abs(n);
        });

    for (ll i = 0; i < N; ++i) {
        // 全ての観光スポットを訪れた場合から、
        // i番目とi+1番目へ移動する金額を引き、i-1番目からi+1番目へ移動する金額を足す
        auto ans = total_cost - abs(diffs[i]) - abs(diffs[i + 1]) + abs(diffs[i] + diffs[i + 1]);
        cout << ans << "\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>

int main(void)
{
	int W;
	int H;
	int x;
	int y;
	int r;

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

	if (x>=r && y>=r)
	{

		if (W >= x+r && H >= y+r)
		{
			printf("Yes\n");
		}

		else
		{
			printf("No\n");
		}
	}

	else
	{
		printf("No\n");
	}

	getchar();
	return 0;
}

Measured memory_bytes: 1016
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


int main() {
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int mod = 998244353;
int n, a[100005], t[100005];
long long ans = 1;
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if((i == 1 && a[i] != 0) || (i != 1 && a[i] == 0)) {
            cout << 0 << endl;
            return 0;
        }
    }
    sort(a + 1, a + n + 1);
	t[0]= 1;
	for(int i = 1; i <= n; i++) {
		ans = ans * t[a[i]] % 998244353, ++t[a[i] + 1];
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
h,w=[int(i) for i in input().split()]
s=[]
for i in range(h):
    s.append([j for j in input()])
for i in range(h):
    text=""
    for j in range(w):
        if s[i][j]!="#":
            cnt=0
            try:
                if s[i-1 if i-1>=0 else 100][j-1 if j-1>=0 else 100]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i-1 if i-1>=0 else 100][j]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i-1 if i-1>=0 else 100][j+1]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i][j-1 if j-1>=0 else 100]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i][j+1]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i+1][j-1 if j-1>=0 else 100]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i+1][j]=="#":
                    cnt+=1
            except:
                pass
            try:
                if s[i+1][j+1]=="#":
                    cnt+=1
            except:
                pass
            text+=str(cnt)
        else:
            text+="#"
    print(text)

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int H, W, D;
map<int, pair<int, int>> mp;
map<int, ll> val;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> H >> W >> D;
    REP(i, 0, H) {
        REP(j, 0, W) {
            int x;
            cin >> x;
            mp[x] = {i+1, j+1};
        }
    }

    REP(i, D, H*W+1) {
        int ad = abs(mp[i].ff - mp[i-D].ff) + abs(mp[i].ss - mp[i-D].ss);
        val[i] = val[i-D] + ad;
    }
  
    int q;
    cin >> q;
    while(q--) {
        int l, r;
        cin >> l >> r; 
        cout << val[r] - val[l] << "\n";
    }
    return 0;
}


Measured memory_bytes: 14880
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N+1);
	rep(i, N) cin>>A[i];
	ll yen = 1000, stock = 0;
	rep(i, N){
		if(A[i] < A[i+1]){ // buy
			ll m = yen / A[i];
			yen -= m * A[i];
			stock += m;
		}
		else if(A[i] > A[i+1]){ // sell
			yen += stock * A[i];
			stock = 0;
		}
	}
	cout<< yen <<endl;
}


Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val po = 1000000007L
    val comb = Array(n + 1) { Array(n + 1) { 0L } }
    for (i in 0..n) {
        comb[i][0] = 1
        for (j in 1..i) {
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % po
        }
    }

    for (i in 1..k) {
        val a = comb[n - k + 1][i]
        val b = comb[k - 1][i - 1]
        println((a * b) % po)
    }
}


Measured memory_bytes: 111636
let n, t, a = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let hs = Array.init n @@ fun i -> Scanf.scanf " %d" @@ fun h -> abs @@ 1000 * (t - a) - 6 * h, i + 1
let _ = Array.fold_left min (max_int, -1) hs |> snd |> Printf.printf "%d\n"

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 11 17:09:47 2020

@author: sd18016
"""

N = int(input())
a = [int(i) for i in input().split()]
ans = 100010001000

for i in range(-100, 101):
    total = 0
    for j in a:
        total += (j - i)**2
        
    ans = min(ans, total)
    
print(ans)
    
    
    
    
    

Measured memory_bytes: 3060
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

function gcd($a, $b) {
    if ($b == 0)  return $a;
    return gcd($b, $a % $b);
}

$min = gcd($A[0], $A[1]);
for ($i = 2; $i < $n; ++$i) {
    $min = gcd($min, $A[$i]);
}
echo $min;


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int n;
cin>>n;
int A[2][n];
rep(i,2){
  rep(j,n)
  cin>>A[i][j];
}if(n==1)
cout<<A[0][0]+A[1][0]<<endl;
else{
int M=0,i,a,b;
for(i=1;i<n;i++){
int count=0;
for(a=0;a<i;a++){
  count+=A[0][a];
 // cout<<count<<endl;
}
for(b=a-1;b<n;b++){
  count+=A[1][b];
  //cout<<count<<endl;
}
//cout<<count<<endl;
M=max(M,count);
}
cout<<M<<endl;
  }
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, X[200005], Y[200005];
char P[200005];

int main() {
    cin >> N;
    for_(i,0,N) cin >> X[i] >> Y[i] >> P[i];

    int ans = 1L << 30;
    {
        set<int> xs, ys;
        map<int, vector<int>> U, D, L, R;
        for_(i,0,N) {
            xs.insert(X[i]);
            ys.insert(Y[i]);
            if (P[i] == 'U') U[X[i]].push_back(Y[i]);
            if (P[i] == 'D') D[X[i]].push_back(Y[i]);
            if (P[i] == 'L') L[Y[i]].push_back(X[i]);
            if (P[i] == 'R') R[Y[i]].push_back(X[i]);
        }

        for (int x : xs) {
            sort(ALL(U[x]));
            sort(ALL(D[x]));
        }

        for (int y : ys) {
            sort(ALL(L[y]));
            sort(ALL(R[y]));
        }

        for (int x : xs) {
            for (int y : U[x]) {
                auto it = upper_bound(ALL(D[x]), y);
                if (it != D[x].end()) ans = min(ans, *it - y);
            }

        }
        for (int y : ys) {
            for (int x : R[y]) {
                auto it = upper_bound(ALL(L[y]), x);
                if (it != L[y].end()) ans = min(ans, *it - x);
            }
        }
    }

    // rotate
    {
        for_(i,0,N) {
            int x = X[i] - Y[i];
            int y = X[i] + Y[i];
            X[i] = x;
            Y[i] = y;
        }

        set<int> xs, ys;
        map<int, vector<int>> Ux, Uy, Dx, Dy, Lx, Ly, Rx, Ry;
        for_(i,0,N) {
            xs.insert(X[i]);
            ys.insert(Y[i]);
            if (P[i] == 'U') Ux[X[i]].push_back(Y[i]), Uy[Y[i]].push_back(X[i]);
            if (P[i] == 'D') Dx[X[i]].push_back(Y[i]), Dy[Y[i]].push_back(X[i]);
            if (P[i] == 'L') Ly[Y[i]].push_back(X[i]), Lx[X[i]].push_back(Y[i]);
            if (P[i] == 'R') Ry[Y[i]].push_back(X[i]), Rx[X[i]].push_back(Y[i]);
        }

        for (int x : xs) {
            sort(ALL(Ux[x]));
            sort(ALL(Dx[x]));
            sort(ALL(Lx[x]));
            sort(ALL(Rx[x]));
        }

        for (int y : ys) {
            sort(ALL(Uy[y]));
            sort(ALL(Dy[y]));
            sort(ALL(Ly[y]));
            sort(ALL(Ry[y]));
        }

        for (int x : xs) {
            for (int y : Ux[x]) {
                auto it = upper_bound(ALL(Lx[x]), y);
                if (it != Lx[x].end()) ans = min(ans, *it - y);
            }
            for (int y : Rx[x]) {
                auto it = upper_bound(ALL(Dx[x]), y);
                if (it != Dx[x].end()) ans = min(ans, *it - y);
            }
        }

        for (int y : ys) {
            for (int x : Ry[y]) {
                auto it = upper_bound(ALL(Uy[y]), x);
                if (it != Uy[y].end()) ans = min(ans, *it - x);
            }
            for (int x : Dy[y]) {
                auto it = upper_bound(ALL(Ly[y]), x);
                if (it != Ly[y].end()) ans = min(ans, *it - x);
            }
        }
    }
    
    if (ans == 1L << 30) puts("SAFE");
    else cout << ans * 5 << endl;
}

Measured memory_bytes: 160440
#include <stdio.h>
#include <string.h>

//함수의 인수를 int **array로 했을때 실행이 안되었었다. 하지만 int array[][2] 라던지 int order[][36]로 했더니 실행이 되고 답이됨..
//처음 정의를 할때 동적메모리로 정희하지 않았기에 메모리수가 정해진 배열이기 떄문에 그런건가? 아직 정확하게 이해가지않음.
int BubbleSort(int array[][2], int len);
int SelectionSort(int array[][2], int len);
int Check(int a[][2],int order[][36],int n);

int main()
{
    int i,j,n;
    scanf("%d%*c",&n);

    int a[36][2], copy[36][2], order[37][36], count[37] = {0}; // 37인 이유는 1~36의 숫자를 그래도 index로 사용할 것이기 떄문.
    for (i=0;i<n;i++)
    {
        scanf("%c%d%*c",&a[i][1],&a[i][0]);
        order[a[i][0]][count[a[i][0]]] = a[i][1];
        count[a[i][0]]++;
    }
    memcpy(copy,a,sizeof(a));
    int cntb,cnts;
    cntb = BubbleSort(a,n);
    for (i=0;i<n;i++)
    {
        printf("%c%d",a[i][1],a[i][0]);
        if (i < n-1) printf(" ");
    }
    printf("\n");
    if (Check(a,order,n) == -1) printf("Not stable\n");
    else printf("Stable\n");

    memcpy(a,copy,sizeof(copy));
    cnts = SelectionSort(a,n);
    for (i=0;i<n;i++)
    {
        printf("%c%d",a[i][1],a[i][0]);
        if (i<n-1) printf(" ");
    }
    printf("\n");
    if (Check(a,order,n) == -1) printf("Not stable\n");
    else printf("Stable\n");

    return 0;
}

int BubbleSort(int array[][2], int len)
{
    int i,j,cnt;
    int tmp;
    cnt = 0;
    for (i=0;i<len;i++)
    {
        for (j=(len-1);j>i;j--)
        {
            if (array[j][0] < array[j-1][0])
                {
        tmp = array[j-1][0];
        array[j-1][0] = array[j][0];
        array[j][0] = tmp;
        int buf;
        buf = array[j-1][1];
        array[j-1][1] = array[j][1];
        array[j][1] = buf;

                    cnt += 1;
                }
        }
    }
    return cnt;
}
int SelectionSort(int array[][2], int len)
{
    int i,j,tmp,cnt,mini;
    cnt = 0;
    for (i=0;i<len;i++)
    {
        mini = i;
        for (j=i;j<len;j++)
        {
            if (array[j][0] < array[mini][0])
            {
                mini = j;
            }
        }
        tmp = array[i][0];
        array[i][0] = array[mini][0];
        array[mini][0] = tmp;
        int buf;
        buf = array[i][1];
        array[i][1] = array[mini][1];
        array[mini][1] = buf;

        if (i != mini) cnt += 1;
    }
    return cnt;
}

int Check(int a[][2],int order[][36],int n)
{
    int count[37] = {0};
    int i,j;
    for (i=0;i<n;i++)
    {
        if (a[i][1] != order[a[i][0]][count[a[i][0]]]) return -1;
        count[a[i][0]]++;
    }
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll sqr(ll a)
{
    return ((a % MOD) * (a % MOD)) % MOD;
}
ll msub(ll a, ll b)
{
    return ((a - b) % MOD + MOD) % MOD;
}
ll madd(ll a, ll b)
{
    return (a + b) % MOD;
}
ll mmul(ll a, ll b)
{
    return ((a % MOD) * (b % MOD)) % MOD;
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll x;
    cin >> x;
    ll a = 100;
    ll d = 0;
    while(a < x)
    {
        a += (a / 100);
        d++;
    }
    cout << d;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> dp(N, vector<int>(3, 0));
    int value[3];
    for (int i = 0; i < N; i++) {
        cin >> value[0] >> value[1] >> value[2];
        if (i == 0) {
            for (int k = 0; k < 3; k++) {
                dp[i][k] = value[k];
            }
        } else {
            for (int k = 0; k < 3; k++) {
                dp[i][k] = max(dp[i - 1][(k + 1) % 3], dp[i - 1][(k + 2) % 3]) + value[k];
            }
        }
    }
    cout << max(max(dp[N - 1][0], dp[N - 1][1]), dp[N - 1][2]) << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> dp(n, inf);
    rep(i, n) {
        *lower_bound(all(dp), a[i]) = a[i];
    }
    cout << (lower_bound(all(dp), inf) - dp.begin()) << endl;
    return 0;
}



Measured memory_bytes: 4420
#include <stdio.h>
#include <string.h>

int main(void){
  int n;
  char s[5];
  int i;
  int a=0, b=0, c=0, d=0;
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    scanf("%s", s);
    if(strcmp(s, "AC")==0){
      a++;
    }else if(strcmp(s,"WA")==0){
      b++;
    }else if(strcmp(s,"TLE")==0){
      c++;
    }else if(strcmp(s,"RE")==0){
      d++;
    }
  }
  printf("AC x %d\n", a);
  printf("WA x %d\n", b);
  printf("TLE x %d\n", c);
  printf("RE x %d\n", d);
  
  return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,a,b,sum=0,cnt=0;
     string str;
     cin>>t>>a>>b;
     cin>>str;
     for(int i=0;i<str.size();i++)
     {
         if(str[i]=='a' && sum<a+b)
            {cout<<"Yes"<<endl;
            sum++;}
        else if(str[i]=='b' && sum<a+b && cnt<b)
        {
            cout<<"Yes"<<endl;
            sum++;cnt++;
        }
        else
            cout<<"No"<<endl;
     }
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<string,int> P;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
map<string, int>table;


bool mobility(int x, int y){
  return x>=0 && x<4 && y>=0 && y<2;
}

int bfs(string goal){
  int i;
  queue<P> que;
  que.push(P(goal,0));
  table[goal] = 0;
  
  while(!que.empty()){
    string now = que.front().first;
    int c = que.front().second;
    que.pop();

    int pos = now.find("0");
    int x = pos%4, y = pos/4;
    REP(i,4){
      int nx = x+dx[i], ny = y+dy[i];
      if(mobility(nx,ny)){
        string next = now;
        swap(next[pos],next[ny*4+nx]);
        if(table.count(next)==0){
          que.push(P(next,c+1));
          table[next] = c+1;
        }
      }
    }
  }
}

int main(void){
  string str;
  string goal = "01234567";
  bfs(goal);
  while(getline(cin,str)){
    int i;
    string input="";
    REP(i,str.length()){
      if(str[i] == ' ') continue;
      input+=str[i];
    }
    cout << table[input] << endl;
  }
  return 0;
}



Measured memory_bytes: 5240
#include<stdio.h>
#include<string.h>

#define N 100000
#define M 100000

void main(){
  long long int n, m, h[N], a[M], b[M], sum=0;
  int bad_tenbou[N]={0};
  scanf("%lld %lld",&n, &m);
  for(int i=0; i<n; i++){
    scanf("%lld",&h[i]);
  }
  for(int j=0; j<m; j++){
    scanf("%lld %lld",&a[j],&b[j]);
    a[j]--;
    b[j]--;
  }
  
  for(int j=0; j<m; j++){
    if( h[a[j]] <= h[b[j]] ){
      bad_tenbou[a[j]] = 1;
    }
    if( h[a[j]] >= h[b[j]] ){
      bad_tenbou[b[j]] = 1;
    }    
  }
  
  for(int i=0; i<n; i++){
//    printf("%lld\n", bad_tenbou[i]);
    if(bad_tenbou[i] == 0){
      sum++;
    }
  }
  printf("%lld",sum);
}

Measured memory_bytes: 4468