akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef unordered_map<int, int> umpii;
typedef unordered_map<ll, ll> umpll;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}

bool prime(ll k) {
    for(ll i = 2; i <= sqrt(k); i++) {
        if(k % i == 0) return false;
    }
    return true;
}

int div(ll k) {
    int res = 0;
    for(int i = 1; i <= sqrt(k); i++) {
        if(k%i == 0) {
            if(prime(i)) res++;
            if(k/i != i && prime(k/i)) res++;
        }
    }
    return res;
}

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

    ll n, m; cin >> n >> m;
    ll k = gcd(n, m);
    cout << div(k) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string b;
  cin >> b;
  
  if(b == "A"){
    cout << "T" << endl;
  }
  if(b == "T"){
    cout << "A" << endl;
  }
  if(b == "G"){
    cout << "C" << endl;
  }
  if(b == "C"){
    cout << "G" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll d, n;
    cin >> d >> n;

    ll p = 1;
    rep(i, d) {
        p *= 100;
    }

    if(n < 100) {
        out(p*n);
    }
    else {
        out(101*p);
    }

    re0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n;cin>>n;

    unordered_map<string, int> mp;
    REP(i,n){
        string s;
        cin>>s;
        mp[s] ++ ;
    }

    int m = 0;

    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        m = max(m, itr->second);
    }
    vector<string> vs;

    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(m == itr->second){
            vs.push_back(itr->first);
        }
    }

    SORT_ASC(vs);

    REP(i,SIZE(vs)){
        cout << vs[i] << endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 25284
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

a,b,c = map(int,input().split())

if a%2==0 or b%2==0 or c%2==0:
   print(0)
   exit()

print( min( a*b, b*c, c*a ) )


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define db double
using namespace std;
int a,b,c,d,e,f,ans1=1,ans2=-1;
int main(){
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	a*=100,b*=100;
	int tot,dd;
	int maxa=f/a,maxb=f/b;
	for(int i=0;i<=maxa;i++)
		for(int j=0;j<=maxb&&i*a+j*b<=f;j++){
			if(!i&&!j) continue;
			tot=i*a+j*b;
			for(int k=0;k*c<=(f-tot)&&k*c<=tot/100*e;k++){
				dd=min((f-tot-k*c)/d,(tot/100*e-k*c)/d);
				if(ans2*(tot+k*c+dd*d)<ans1*(k*c+dd*d)) ans1=tot+k*c+dd*d,ans2=k*c+dd*d;
			}
		}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;	
} 

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n,k,q;
    cin>>n>>k>>q;
    V<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    multiset<ll> s;
    V<ll> tmp;
    ll ans=inf;
    for(int i=0;i<n;i++){
        s.clear();
        tmp.clear();
        for(int j=0;j<n;j++){
            if(a[j]>=a[i]){
                s.insert(a[j]);
                if(s.size()==k){
                    tmp.emplace_back(*s.begin());
                    s.erase(s.begin());
                }
            }else{
                s.clear();
            }
        }
        if(tmp.size()>=q){
            sort(all(tmp));
            chmin(ans,tmp[q-1]-a[i]);
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3752
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vpii = vector<pii>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
umap<string, vector<string>> buf;
umap<string, bool> used;
vector<pair<string,int>> names;
umap<string, int> bmap;
int ans;
void dfs(int pos, int b,int rest) {
	ans = max(ans, b);
	if (pos == names.size()) {
		return;
	}
	if (ans >= b + rest)return;
	vector<string> log;
	for (; pos < names.size(); pos++) {
		if (used[names[pos].first])continue;
		rest -= names[pos].second;
		used[names[pos].first] = 1;
		log.push_back(names[pos].first);
		vector<string> c;
		int rest1 = rest;
		for (auto &a : buf[names[pos].first]) {
			if (!used[a]) {
				c.push_back(a);
				used[a] = 1;
				rest -= bmap[a];
			}
		}
		dfs(pos + 1, b + names[pos].second,rest);
		for (auto &a : c) {
			used[a] = 0;
		}
		rest = rest1;
	}
	for (auto &a : log)used[a] = 0;
}
int main() {
	int n;
	int mb = 0;
	while (cin>>n,n) {
		buf.clear();
		used.clear();
		names.clear();
		bmap.clear();
		ans = 0;
		mb = 0;
		rep(i,n) {
			int k,b;
			string name;
			//vector<string> list;
			cin >> name >> b >> k;
			rep(j, k) {
				string a;
				cin >> a;
				//list.push_back(a);
				buf[name].push_back(a);
				//buf[a].push_back(name);
			}
			mb += b;
			used.insert(make_pair(name, 0));
			names.push_back(make_pair(name,b));
			bmap.insert(make_pair(name, b));
		}
		used[names[0].first] = 1;
		for (auto &a : buf[names[0].first]) {
			used[a] = 1;
			mb -= bmap[a];
		}
		dfs(1, names[0].second,mb-names[0].second);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3352
#include<stdio.h>
int main(void){
	int i,n;
	long debt = 100000;
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		debt *= 1.05;
		if(debt % 1000 != 0){
			debt -= debt % 1000;
			debt += 1000;
		}
	}
	printf("%ld\n",debt);
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define ll long long

int h, w;

int main(){
	scanf("%d%d", &h, &w);
	if (!(h % 3) || !(w % 3)){
		return printf("0\n"), 0;
	}
	ll min = INT_MAX;
	for (int i = 1; i < h; ++ i){
		ll s1 = 1ll * i * w;
		h -= i;
		int dif;
		if ((h & 1) && (w & 1)){
			dif = std::min(h, w);
		}
		else{
			dif = 0;
		}
		ll s2 = 1ll * h * w + dif >> 1, s3 = 1ll * h * w - dif >> 1;
		ll ans = std::max(std::max(s1, s2), s3) - std::min(std::min(s1, s2), s3);
		min = std::min(min, ans);
		h += i;
	}
	for (int i = 1; i < w; ++ i){
		ll s1 = 1ll * i * h;
		w -= i;
		int dif;
		if ((w & 1) && (h & 1)){
			dif = std::min(w, h);
		}
		else{
			dif = 0;
		}
		ll s2 = 1ll * w * h + dif >> 1, s3 = 1ll * w * h - dif >> 1;
		ll ans = std::max(std::max(s1, s2), s3) - std::min(std::min(s1, s2), s3);
		w += i;
		min = std::min(min, ans);
	}
	return printf("%d\n", min), 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k,r;
	scanf("%d",&r);
	if(r<1200)
	{
		printf("ABC");
	}
	else if(r>=1200&&r<2800)
	{
		printf("ARC");
	}
	else if(r>=2800)
	{
		printf("AGC");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>



int main()
{
    int32_t k;
    std::cin >> k;

    std::string s;
    std::cin >> s;

    std::string result = s.substr(0, k);

    if (s.size() > k)
    {
        result += "...";
    }

    std::cout << result;
}

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

int main() {
	int a,b,c,d;
    cin >> a >> b >> c >> d;
    int s = b-a;
    if(s<0){
      s = -s;
    }
    int t = c-b;
    if(t<0){
      t = -t;
	}
    int u = c-a;
    if(u<0){
      u = -u;
    }
    if((s <= d && t <= d) || (u <= d)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	ll n;
	cin >> n;
	if (n == 0) { 
		cout << "0" << endl; 
		exit(0);
	}


	vector<int> ans;

	while (n != 0) {
		int temp = abs(n) % 2;
		if (temp == 0)ans.push_back(0);
		else ans.push_back(1);
		n = ((n - temp) / 2)*(-1);
	}

	for (int i = ans.size() - 1; i >= 0; i--) { cout << ans[i]; }
	cout << endl;

	

	return 0;

}

Measured memory_bytes: 256
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 08/Dec/19 05:31:03 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)
		pr ("bust");
	else
		pr ("win");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	char s[100010];
	int x = 0;
	scanf("%s", s);
	for (int i = 1; s[i] != '\0'; i++)
	{
		if (s[i - 1] != s[i]) {
			x++;
		}
	}
	printf("%d", x);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
long long ans;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	ans=a+2*b+1;
	if(ans>b+c) ans=b+c;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    ABC = sorted(list(map(int, input().split())))

    for i in ABC:
        if i % 2 == 0:
            print(0)
            break
    else:
        print(ABC[0] * ABC[1])


if __name__ == '__main__':
    resolve()


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans;
    cin >> N;
    cin >> ans;
    rep(i, N - 1) {
        ll temp;
        cin >> temp;
        ans = ans / __gcd(ans, temp) * temp;
    }
    cout << ans << endl;
    return 0;
}


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

class Dtree {
public:
  vector<int> parent;

  Dtree(int size) {
    parent.resize(size, 0);
    for (int i = 0; i < parent.size(); i++)
      parent[i] = i;
  }
  int unite(int x, int y) {
    int l = label(x);
    while (1) {
      int pre = parent[y];
      parent[y] = l;
      if (y == pre)
        break;
      y = pre;
    }
  }
  bool same(int x, int y) { return label(x) == label(y); }
  int label(int x) {
    while (x != parent[x]) {
      x = parent[x];
    }
    return x;
  }
};

int main() {
  int n, nquery;
  cin >> n;
  cin >> nquery;
  Dtree dt = Dtree(n);
  for (int i = 0; i < nquery; i++) {
    int x, y, command;
    cin >> command >> x >> y;
    if (command == 0) {
      dt.unite(x, y);
    } else if (command == 1) {
      cout << (dt.same(x, y) ? 1 : 0) << endl;
    }
  }
}

Measured memory_bytes: 3088
#include<iostream>
#include<map>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    map<int,int> mp;
    ll sum=0;
    mp[0]++;
    rep(i,n){
        int x;cin>>x;
        (sum+=x)%=k;
        ans+=mp[sum]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3200
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: i32, b: i32);
    puts!("{}\n", 6 - a - b);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int k=0;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-i-1])
			k++;
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)


// 橋 (= 取り除くと連結成分が増える辺) 列挙
// グラフを適当な頂点を根とする dfs 木として以下の値を更新する
// order[v] := 行きがけ順, low[v] := 部分グラフでの min{order[i]}
// 各辺 e について, 子から order[親]以下に遷移できない <=> e は橋
// 各辺 e について, low[子] > order[親] <=> e は橋
// が, low[v] は陽に持たないで良い
// verified: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3382012
class LowLink
{
    using Graph = std::vector<std::vector<ll>>;
    std::vector<ll> order;
    ll next = 0;
    Graph G;
    std::set<P> bridges;

    void add(ll a, ll b)
    {
        bridges.insert(P(std::min(a, b), std::max(a, b)));
    }
    ll dfs(ll cur, ll pre)
    {
        ll res = order[cur] = next++;
        for (const auto &to : G[cur])
        {
            if (to == pre)
                continue;
            if (order[to] >= 0)
                res = std::min(res, order[to]);
            else
            {
                ll low = dfs(to, cur);
                if (low > order[cur])
                    add(cur, to);
                res = std::min(res, low);
            }
        }
        return res;
    }

  public:
    LowLink(ll _v) : order(_v, -1), G(_v, std::vector<ll>())  {}
    void addEdge(ll s, ll t)
    {
        G[s].push_back(t);
    }
    std::set<P> bridge()
    {
        dfs(0, -1);
        return bridges;
    }
};

/*
二重辺連結成分分解
- 二重辺連結 := どの辺を取り除いても連結である, すなわち橋を含まないようなグラフ
- 二重辺連結成分 := グラフの内二重辺連結な部分グラフであり, 極大 (= どの頂点集合を追加しても二重辺連結にならない)なもの
橋が列挙できたら適当に dfs すれば ok
*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int v,e;
    cin>>v>>e;
    LowLink link(v);
    FOR(i,0,e){
      ll in1,in2;
      cin>>in1>>in2;
      link.addEdge(in1,in2);
      link.addEdge(in2,in1);
    }
    set<P> res = link.bridge();
    FORs(i,res){
      cout<<i.first<<" "<<i.second<<endl;
    }
}



Measured memory_bytes: 5244
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("-13 3");
            //-10
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 -33");
            //34
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("13 3");
            //39
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[0];
        int B = wkArr[1];

        var Kouho = new List<int>();
        Kouho.Add(A + B);
        Kouho.Add(A - B);
        Kouho.Add(A * B);
        Console.WriteLine(Kouho.Max());
    }
}


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

int main()
{
  int n;
  scanf("%d",&n);
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&a[i],&b[i]);
  }
  vector<int> d(n);
  long long ans=0;
  for(int i=0;i<n;i++){
    d[i]=a[i]+b[i];
    ans-=b[i];
  }
  sort(d.begin(),d.end());
  for(int i=0;2*i<n;i++){
    ans+=d[n-2*i-1];
  }
  printf("%lld\n",ans);
  return 0;
}

		   


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

typedef pair<int,int> ii;

const string roulette = "abcdef";
int dx[] = {-1,-1,+0,+1,+1,+0};
int dy[] = {+1,+0,-1,-1,+0,+1};
string line1,line2;
int N;
vector<int> Index[2];

bool check(vector<ii> v1,vector<ii> v2)
{
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  rep(i,N)if(v1[i] != v2[i])return false;
  return true;
}

void compute()
{
  if(line1.size() != line2.size())
    {
      cout << "false" << endl;
      return;
    }
  N = line2.size();
  
  vector<ii> ori;
  int mx,my;
  ori.push_back(ii(0,0));
  
    int x = 0, y = 0;
    mx = my = 0;
    rep(i,N)
      {
	x += dx[line1[i]-'a'];
	y += dy[line1[i]-'a'];
	mx = min(mx,x);
	my = min(my,y);
	ori.push_back(ii(x,y));
      }
  

  rep(i,ori.size())ori[i].first -= mx, ori[i].second -= my;


  rep(j,7)//dir
    {
      vector<ii> cont;
      cont.push_back(ii(0,0));
      x = y = 0;
      mx = x, my = y;
      rep(i,N)
	{
	  x += dx[(line2[i]-'a'+j)%6];
	  y += dy[(line2[i]-'a'+j)%6];
	  mx = min(mx,x);
	  my = min(my,y);
	  cont.push_back(ii(x,y));
	}
      
      rep(i,cont.size())cont[i].first -= mx,cont[i].second -= my;
      
      if(check(ori,cont))
	{
	  cout << "true" << endl;
	  return;
	}
      
    }
      
    
  
  
  cout << "false" << endl;
}


int main()
{
  int n; 
  while(cin >> n)
    {
      cin.ignore();
      string blank;
      while(n--)
	{
	  line1.clear();
	  line2.clear();
	  char c;
	  while((c = getchar()) != '\n')line1 += c;
	  while((c = getchar()) != '\n')line2 += c;
	  cin >> blank;
	  cin.ignore();
	  compute();
	}
    }
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int N;
    cin >> N;


    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    map<ll,ll> mp;
    ll maxa=0;
    for (int i = 0; i < N; i++) {
        mp[A[i]]++;
        if (mp[A[i]] >= 2) {
            maxa = max(maxa, A[i]);
        }
    }

    unique(A);
    // printvector(A);

    if (mp[maxa] >= 4) {
        cout << maxa * maxa << endl;
        return;
    }
    for (int i = A.size()-2; i >= 0; i--) {
        if (mp[A[i]] >= 2 && A[i] != maxa) {
            // cout << maxa << " " << A[i] << endl;
            cout << maxa * A[i] << endl;
            return;
        }
    }

    cout << 0 << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 7296
// template {{{

#include <bits/stdc++.h>

// #define int long long

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP2(i, n) REP3(i, 0, n)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += s)
#define RREP2(i, n) RREP(i, 0, n)
#define RREP3(i, a, b) for (int i = (b) - 1; i >= (int)(a); i--)

#define rep(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, RREP3, RREP2)(__VA_ARGS__)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

template<typename T>
using maxpq = std::priority_queue<T, std::vector<T>, std::less<T>>;

template<typename T>
using minpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

using namespace std;

// }}}

int n;
int a[100010];

int main()
{
	cin >> n;
	rep(i, n){
		int x, y;
		cin >> x >> y;
		a[x]++; a[++y]--;
	}
	rep(i, 100002) a[i + 1] += a[i];
	int res = 0;
	rep(i, 100002){
		if (a[i] >= i - 1) res = i - 1;
	}
	cout << res << endl;
}

Measured memory_bytes: 3508
//一括include
#include <bits/stdc++.h>
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;

//TOP,FRONT,LEFT,RIGHT,BACK,BOTTOM
int dice[6] = {1, 2, 4, 3, 5, 6};

void rotN()
{
    swap(dice[TOP], dice[FRONT]);
    swap(dice[FRONT], dice[BOTTOM]);
    swap(dice[BOTTOM], dice[BACK]);
}

void rotS()
{
    rotN();
    rotN();
    rotN();
}

void rotE()
{
    swap(dice[TOP], dice[LEFT]);
    swap(dice[LEFT], dice[BOTTOM]);
    swap(dice[BOTTOM], dice[RIGHT]);
}

void rotW() { rotE(), rotE(), rotE(); }

/*void rotCW()
{
    swap(dice[FRONT], dice[RIGHT]);
    swap(dice[RIGHT], dice[BACK]);
    swap(dice[BACK], dice[LEFT]);
}

void rotCCW() { rotCW(), rotCW(), rotCW(); }
*/
int main()
{
    cin >> dice[TOP] >> dice[FRONT] >> dice[RIGHT];
    cin >> dice[LEFT] >> dice[BACK] >> dice[BOTTOM];

    string str;
    cin >> str;
    for (int i = 0; i < str.size(); i++)
    {
        if (str[i] == 'N')
            rotN();
        if (str[i] == 'S')
            rotS();
        if (str[i] == 'E')
            rotE();
        if (str[i] == 'W')
            rotW();
    }

    cout << dice[TOP] << endl;
}



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

int main() {
  int N,A;
  string S;
  cin >> N >> S;
  A = N/2;
  int count = 0;
  if(N%2 == 1){
          cout << "No" << endl;
          return 0;
      }
  for(int i = 1; i < A+1; i++){
      
      if(S.at(i-1) == S.at(A+i-1)){
           count++;
       }
  }
  if(count == A){
      cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
c_0=list(map(int,input().split()))
c_1=list(map(int,input().split()))
c_2=list(map(int,input().split()))

d=c_0[0]+c_1[1]+c_2[2]
e=c_1[0]+c_0[2]+c_2[1]
f=c_0[1]+c_1[2]+c_2[0]
if d==e==f:
    print("Yes")
else:
    print("No")

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

#define all(x) (x).begin(), (x).end()
#define make_unique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define dbg(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;

void solve(){
    string str; cin >> str;
    char ut = str[str.size() -1];
    if (ut == '3'){
        cout << "bon" << endl;
        return;
    }
    if (ut == '0' || ut == '1' || ut == '6' || ut == '8'){
        cout << "pon" << endl;
        return;
    }
    cout << "hon" << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int h, w;
	cin >> h >> w;
	vector<vector<char>> table(h+2, vector<char>(w+2, '.'));
	for (int i=1; i<h+1; i++)
	{
		for(int j=1; j<w+1; j++)
			cin >> table[i][j];
	}
	string ans = "Yes";
	for (int i=1; i<h+1; i++)
	{
		for(int j=1; j<w+1; j++)
		{
			if (table[i][j] == '#')
			{
				if (table[i-1][j]=='.' && table[i][j+1] == '.' &&
					table[i+1][j] == '.' && table[i][j-1] == '.')
					ans = "No";
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
int spotx[1001] = { 0 };
int spoty[1001] = { 0 };
using namespace std;
int main() {
	int w, h, n,count = 0;
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 1;i <= n;++i) scanf("%d%d", &spotx[i], &spoty[i]);
	int herex = spotx[1], herey = spoty[1];
	for (int i = 1;i <= n;++i) {
		while (true) {
			if (herex == spotx[i] && herey == spoty[i]) break;
			if (herex != spotx[i] && herey == spoty[i]) {
				if (herex < spotx[i]) {
					count++;
					herex += 1;
					goto end;
				}
				else {
					count++;
					herex -= 1;
					goto end;
				}
			}
			if (herex == spotx[i] && herey != spoty[i]) {
				if (herey < spoty[i]) {
					count++;
					herey += 1;
					goto end;
				}
				else {
					count++;
					herey -= 1;
					goto end;
				}
			}
			if (herex > spotx[i] && herey < spoty[i]) {
				count++;
				herey += 1;
				goto end;
			}
			else {
				if (herex < spotx[i] && herey > spoty[i]) {
					count++;
					herex+= 1;
					goto end;
				}
				else {
					if (herex > spotx[i] && herey > spoty[i]) {
						count++;
						herex -= 1;
						herey -= 1;
						goto end;
					}
					else {
						if (herex < spotx[i] && herey < spoty[i]) {
							count++;
							herex += 1;
							herey += 1;
							goto end;
						}
						else {
							count++;
							herey += 1;
							goto end;
						}
					}
				}
			}
			end:;
		}
	}
	printf("%d\n", count);
}


Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int A,B,Q;
ll s[100100],t[100100];
int main(){
	cin >> A >> B >> Q;
	for(int i=0;i<A;i++)cin >> s[i];
	for(int i=0;i<B;i++)cin >> t[i];
	for(int i=0;i<Q;i++){
		ll x;
		cin >> x;
		int a = lower_bound(s,s+A,x)-s;
		int b = lower_bound(t,t+B,x)-t;
		ll ans = LLINF;
		for(int j=max(0,a-1);j<=min(A-1,a);j++){
			for(int k=max(0,b-1);k<=min(B-1,b);k++){
				ans = min(ans,abs(x-s[j])+abs(s[j]-t[k]));
				ans = min(ans,abs(x-t[k])+abs(t[k]-s[j]));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
double GetRad(int an){
  return (double)an*(M_PI/180.0);
}
main(){

  int x,an;
  double rx=0,ry=0;
  int ra=90;
  while(1){
    scanf("%d,%d",&x,&an);
    if(x==0 && an==0) break;
    double rad=GetRad(ra);
    rx+=cos(rad)*(double)x;
    ry+=sin(rad)*(double)x;
    ra-=an;
  }
  printf("%d\n%d\n",(int)rx,(int)ry);
  
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int counter = 0;
	for (int i = 0; i < 6; i++) {
		if (s.at(i) == '1') {
			counter++;
		}
	}
	cout << counter << endl;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	
	int x, a, b;
	cin >> x >> a >> b;
	cout << min(b, x * a);
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

int main(){
	string s;
	int p;
	multimap<string,int> mp;
	while(cin >> s >> p){
		mp.insert(multimap<string,int>::value_type(s , p));
	}
	for(multimap<string,int>::iterator it=mp.begin();it!=mp.end();){
		vector<int> v;
		string tmp=(*(it)).first;
		cout << tmp << endl;
		do {
			v.push_back((*(it)).second);
			++it;
		} while(it!=mp.upper_bound(tmp));
			sort(v.begin() , v.end());
			for(int i=0;i<v.size()-1;++i){
				cout << v[i] << " ";
			}
			cout << v[v.size()-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
import sys
import random

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

def rdi():
        return [ int(x) for x in rd().split() ]

N = rd()
A = rdi()

def calc(s, sign, a):
        cnt = 0
        for i in range(len(a)):
                s += a[i]
                while s < 0 and sign < 0:
                        cnt += (1-s)
                        s = 1
                while s > 0 and sign > 0:
                        cnt += (s+1)
                        s = -1
                if s == 0:
                        cnt += 1
                        if sign < 0:
                                s = 1
                        else:
                                s = -1
                sign = s
        return cnt

if A[0] == 0:
        print 1+min(calc(1, 1, A[1:]), calc(-1, -1, A[1:]))
else:
        print min(calc(0, -1, A), calc(0, 1, A))


Measured memory_bytes: 11668
#include<stdio.h>
int main(void)
{
	int n, i, j;
	int ball[10], blast = 0, clast = 0, m = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 10; j++)
		{
			scanf("%d" , &ball[j]);
		}
		blast = ball[0];
		for (j = 1; j < 10; j++)
		{
			if (blast < ball[j])
				blast = ball[j];
			else if (clast < ball[j])
				clast = ball[j];
			else
			{
				m = 1;
				break;
			}
		}
		if (m == 1)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}
		m = 0;
		blast = 0;
		clast = 0;
	}
	return 0;
}

Measured memory_bytes: 2508
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long int lli;

int main() {
  int N;
  scanf("%d",&N);
  int ans=0;
  int cnt[100001];
  memset(cnt,0,sizeof(cnt));
  lli a[100000];
  lli mina=0, maxa=0;
  for (int i=0; i<N; i++) {
    scanf("%lld",&a[i]);
    if (a[i]>N) {
      ans++;
      i--;
      N--;
    } else {
      cnt[a[i]]++;
    }
    maxa=max(maxa,a[i]);
    mina=min(mina,a[i]);
  }
  for (int i=mina; i<=maxa; i++) {
    if (cnt[i]==0) {
      continue;
    }
    if(cnt[i]>i) {
      ans+=cnt[i]-i;
    } else if (cnt[i]!=i){
      ans+=cnt[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n, k; read(n, k);
  int ans = 0;
  while(n) {
    n /= k;
    ans++;
  }
  print(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstring>

#define ll long long

ll DFS(int v, std::vector<std::vector<ll>> &connection, std::vector<ll> &dp)
{
    if (dp[v] != -1)
        return dp[v];

    ll result = 0;
    for (auto& c : connection[v])
    {
        ll score = DFS(c, connection, dp) + 1;
        if (result < score)
            result = score;
    }

    dp[v] = result;
    return dp[v];
}

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

    std::vector<std::vector<ll>> graph(N);
    for (int i=0; i<M; ++i)
    {
        ll from, to;
        std::cin >> from >> to;
        from -= 1;
        to -= 1;
        graph[from].emplace_back(to);
    }

    // i番目からスタートしたときの最長経路
    std::vector<ll> dp(N, -1);
    ll max = 0;
    for (int i=0; i<N; ++i)
    {
        DFS(i, graph, dp);
        if (max < dp[i])
            max = dp[i];
    }

    std::cout << max << std::endl;
}

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

using namespace std;

int main(){
  char a[3];
  cin >> a[0] >> a[1] >> a[2];
  for(int i = 0;i < 3;i++){
    if(a[i] == '1') {
      cout << 9;
    }else if(a[i] == '9'){

      cout << 1;
    }else{
      cout << a[i];
    }

  }
  cout << endl;
  return 0;
}


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

struct Solver {
	void solve() {
		int N;
		cin >> N;

		vector<int> A( N );
		map<int, int> cnt;
		for( int i = 0; i < N; ++i ) {
			cin >> A[i];
			cnt[A[i]] += 1;
		}

		long x = 0;
		for( auto kv: cnt ) {
			x += (long)kv.second * (kv.second-1) / 2;
		}

		for( int i = 0; i < N; ++i ) {
			cout << x - (cnt[A[i]] - 1) << '\n';
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 8320
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	char c;
	scanf("%c",&c);
	if(c>='A' && c<='Z')	printf("A\n");
	else printf("a\n");
	return 0;
}

Measured memory_bytes: 1544
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int n;
    while(cin>>n){
        int count=0;
        if(n==0)break;
        while(n!=1){
            if(n%2==0)n/=2;
            else n=3*n+1;
            count++;
        }
        cout<<count<<endl;
    }
    return 0;
}

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

int prime[100001], cou[100001];

void solve(int n)
{
	prime[1] = 0;
	cou[1] = 0;
	cou[2] = 0;

	for (int i = 2; i <= n; i++)
	{
		prime[i] = 1; 
		cou[i] = 0;
	}

	for (int i = 2; i <= n / 2; i++)
	{
		for (int j = 2; j*i <= n; j++)
		{
			if (prime[i*j] == 1)
			{
				prime[i*j] = 0;
			}
		}
	}

	for (int i = 3; i <= n; i++)
	{
		if (prime[i] == 1 && prime[(i + 1) / 2] == 1)
		{
			cou[i] = cou[i - 1] + 1;
		}
		else
		{
			cou[i] = cou[i - 1];
		}
	}
}

int main()
{
	int q, l, r, ans[100001];

	cin >> q;

	solve(100000);

	for (int i = 1; i <= q; i++)
	{
		ans[i] = 0;
		cin >> l >> r;
		ans[i] = cou[r] - cou[l - 1];
	}

	for (int i = 1; i <= q; i++)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int l[] = new int[m];
    int r[] = new int[m];
    for(int i=0;i<m;i++){
      l[i]=sc.nextInt();
      r[i]=sc.nextInt();
    }
    Arrays.sort(l);
    Arrays.sort(r);
    int answer = r[0]-l[m-1]+1;
    if(answer<0){
      answer=0;
    }
    System.out.println(answer);
  }
}

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

int dp[100005];
int h[100005];
int inf=1e9;

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>h[i];
	dp[1]=0;
	for(int i=2;i<=n;++i){
		dp[i]=inf;
		for(int j=1;j<=k;++j)
			if(i-j>0){
				int cost=dp[i-j]+abs(h[i]-h[i-j]);
				dp[i]=min(dp[i],cost);
			}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans =0;

  if(k<=a){
    rep(i,k){
      ans++;
    }
  }else if(a<k && k<=(a+b)){
    rep(i,a){
      ans++;
    }
  }else if((a+b)<k && k<=(a+b+c)){
    rep(i,a){
      ans++;
    }
    int n = k-a-b;
    rep(i,n){
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
using namespace std;
int main(){
int N;
cin>>N;vector<int> A(N);
for(int i=0;i<N;i++) cin>>A[i];

vector<int> B(N);
for(int i=0;i<N;i++) B[A[i]-1]=i+1;
for(int i=0;i<N;i++) cout<<B[i]<<endl;
return 0;
}

Measured memory_bytes: 1664