akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(){

    int i, j;
    char dammy;
    int a = 0, b = 0;

    scanf("%d %d", &a, &b);

    // printf("%d %d", a, b);

    char moji[5];
    int count = 0;

    for (i = a; i < b + 1; i++){
        moji[0] = i / 10000;
        moji[1] = (i / 1000) % 10;
        moji[2] = (i / 100) % 10;
        moji[3] = (i / 10) % 10;
        moji[4] = i % 10;

        if(moji[0]==moji[4] && moji[1]==moji[3]){
            count++;
        }
    }        
    
    printf("%d", count);

    return 0;
}



int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=10010010;
const double PI=3.141592653589;


int main(){
  double w,h,x,y; cin>>w>>h>>x>>y;
  double jx=w/2;
  double jy=h/2;
  cout<<fixed<<setprecision(6)<<h*w/2<<" "<<((jx==x&&jy==y)?"1":"0")<<endl;


  return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int dp[100][100][100] = {};    // a,b,c から見て何ステップで到達できるか
    for(int i =0; i<100; i++){
        for(int j =0; j<100; j++){
            for(int k =0; k<100; k++){
                dp[i][j][k] = 10000;
            }
        }
    }
    dp[a][b][c] = 0;
    for(int i=a; i <98; i++){
        for(int j=b; j <98; j++){
            for(int k=c; k<98; k++){
                dp[i+2][j][k] = min(dp[i][j][k]+1, dp[i+2][j][k]);
                dp[i][j+2][k] = min(dp[i][j][k]+1, dp[i][j+2][k]);
                dp[i][j][k+2] = min(dp[i][j][k]+1, dp[i][j][k+2]);
                dp[i+1][j+1][k] = min(dp[i][j][k]+1, dp[i+1][j+1][k]);
                dp[i][j+1][k+1] = min(dp[i][j][k]+1, dp[i][j+1][k+1]);
                dp[i+1][j][k+1] = min(dp[i][j][k]+1, dp[i+1][j][k+1]);
                //cout << dp[i][j][k];
            }
        }
    }
    int ans = 10000;
    for(int i =max(a,max(a,b)); i<100; i++){
        ans = min(ans, dp[i][i][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

void Main(){
    ll K, N, a;
    cin >> N >> K;
    vector<ll> as(N,0);
    vector<ll> add_n(N+1,0);

    rep(i, N){
        sll(a);
        as[i] = a;
    }


    rep(i, K){
        fill(add_n.begin(), add_n.end(), 0);
        rep(j, N){
            ll range = as[j];
            ll left = max(j-as[j], (ll)0);
            ll right = min(j+as[j]+1, N);
            ++add_n[left];
            --add_n[right];
        }
        bool is_all_max = true;
        rep(j, N){
            add_n[j+1] += add_n[j];
            as[j] = add_n[j];
            is_all_max = is_all_max && add_n[j] == N;
        }
        // cout << "num = " << i << " is allm ax:" << is_all_max <<endl;
        if(is_all_max){
            break;
        }
    }

    printf("%lld", add_n[0]);
    rep(i, N-1){
        printf(" %lld", add_n[i+1]);
    }
    printf("\n");

}

int main(){
    Main();
}

Measured memory_bytes: 6000
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int n, m;
int memo[1000000];

void dfs(vector<vector<int>> g, vector<bool> used, int room, int cnt, int pre) {
    cout << room << endl;
    if(used[room]) {
        return;
    }
    // 訪れていない部屋なら
    used[room] = true;
    cnt++;
    if(memo[room]!=0) {
        memo[room] = pre;
    };
    if(g[room].empty()) {
        return;
    }
    for(auto node:g[room]) {
        dfs(g, used, node, cnt, room);
    }
    return;
}

int main() {
    cin >> n >> m;
    vector<vector<int>> g(n+1);
    for(int i=0; i<m; i++) {
        int ai, bi; cin >> ai >> bi;
        g[ai].push_back(bi);
        g[bi].push_back(ai);
    }
    vector<bool> used(n+1, false);
    queue<int> q;
    q.push(1);
    vector<int> m(n+1, -1);
    while(!q.empty()) {
        int node = q.front();
        q.pop();
        for(auto ni:g[node]) {
            if(used[ni]) continue;
            used[ni] = true;
            q.push(ni);
            m[ni] = node;
        }
    }
    m[1]=0;
    for(int i=1; i<n+1; i++) {
        if(m[i]==-1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=2; i<n+1; i++) {
        cout << m[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10224
import java.io.*;
import java.util.*;
 
public class Main{
	
 
	int N;
	int[] memo;
	long mod = 1000000007;
	public void solve(){
		N = nextInt();
		memo = new int[N + 1];
		for(int i = 2; i <= N; i++){
			int num = i;
			for(int j = 2; j <= num; j++){
				while(num % j == 0){
					memo[j]++;
					num /= j;
				}
			}
		}
		long ans = 1;
		for(int i = 0; i < memo.length; i++){
			ans = (ans * (memo[i] + 1)) % mod;
		}
		out.println(ans);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 8400
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        bool hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

//leftは条件を満たさない最大の値、rightは条件を満たす最小の値になっている

string query(int index){
    cout << index << endl;
    fflush(stdout);
    string result;cin >> result;
    if(result == "Vacant"){
        //main()に戻らずにプログラムを終了する
        exit(0);
    }
    else {
        return result;
    }
}

int main() {
    int N;cin >> N;
    string L = query(0);
    string R = query(N-1);
    int left = 0;
    int right = N-1;
    for(int i = 0;i<20;i++){
        int mid = left+(right-left)/2;
        string M = query(mid);
        //左の区間が偶数個かつ両端が同じ　または　左の区間が奇数個かつ両端が異なる
        //ならば左の区間に必ず空席が含まれるので左の区間に合わせる
        if((mid-left) % 2 == 1 && M == L || (mid-left) % 2 == 0 && M != L){
            right = mid;
            R = M;
        }
        else{
            left = mid;
            L = M;
        }
    }
}


Measured memory_bytes: 852
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
  string str,a,b;
  int count=0;
  cin >> str; 
  int size=str.size();
  for(int i = 0; i<size/2; i++){
    a=str.at(i);
    b=str.at(size-i-1);    
    if(a!=b){
      count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;

#define ll long long
#define rg register
#define In inline

const int N = 262144;
const ll mod = 998244353;
const ll iv2 = 499122177;

In ll read(){
	ll s = 0,ww = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')ww = -1;ch = getchar();}
	while('0' <= ch && ch <= '9'){s = 10 * s + ch - '0';ch = getchar();}
	return s * ww;
}

In void write(ll x){
	if(x < 0)putchar('-'),x = -x;
	if(x > 9)write(x / 10);
	putchar('0' + x % 10);
}

namespace ModCalc{
	In void Inc(ll &x,ll y){
		x += y;if(x >= mod)x -= mod;
	}
	In void Dec(ll &x,ll y){
		x -= y;if(x < 0)x += mod;
	}
	In ll Add(ll x,ll y){
		Inc(x,y);return x;
	}
	In ll Sub(ll x,ll y){
		Dec(x,y);return x;
	}
}
using namespace ModCalc;

In ll power(ll a,ll n){
	ll s = 1,x = a;
	while(n){
		if(n & 1)s = s * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return s;
}

ll n,deg;
ll p[N+5],q[N+5],temp[N+5];

In void calc(ll &x,ll &y,int opt){
	if(opt == 1){
		ll X = Add(x,y),Y = Sub(x,y);
		x = X,y = Y;
	}
	else{
		ll X = Add(x,y) * iv2 % mod,Y = Sub(x,y) * iv2 % mod; 
		x = X,y = Y;
	}
}

void FWT(ll a[],ll deg,int opt){
	for(rg int n = 2;n <= deg;n <<= 1){
		int m = n >> 1;
		for(rg int i = 0;i < deg;i += n){
			for(rg int j = 0;j < m;j++)calc(a[i+j],a[i+j+m],opt);
		}
	}
}

int main(){
//	freopen("AGC034F.in","r",stdin);
//	freopen("AGC034F.out","w",stdout);
	n = read();
	deg = 1ll << n;
	ll s = 0;
	for(rg int i = 0;i < deg;i++)p[i] = read(),s += p[i];
	ll iv = power(s,mod - 2);
	for(rg int i = 0;i < deg;i++)p[i] = p[i] * iv % mod;
	Dec(p[0],1);
//for(rg int i = 0;i < deg;i++)cout<<p[i]<<" ";cout<<endl;
	FWT(p,deg,1);
//cout<<"p[]:"<<endl;
//for(rg int i = 0;i < deg;i++)cout<<p[i]<<" ";cout<<endl;
	for(rg int i = 0;i < deg;i++)q[i] = (i == 0 ? deg - 1 : -1);
	FWT(q,deg,1);
//cout<<"q[]:"<<endl;
//for(rg int i = 0;i < deg;i++)cout<<q[i]<<" ";cout<<endl;
	for(rg int i = 1;i < deg;i++)q[i] = q[i] * power(p[i],mod - 2) % mod;
//cout<<"q[]:"<<endl;
//for(rg int i = 0;i < deg;i++)cout<<q[i]<<" ";cout<<endl;	
	memcpy(temp,q,sizeof(temp));
	FWT(temp,deg,-1);
	Dec(q[0],temp[0] * deg % mod);
//cout<<endl;
	FWT(q,deg,-1);
	for(rg int i = 0;i < deg;i++)write(q[i]),putchar('\n');
	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)

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

    if(S[0]=='R' && S[1] == 'R' && S[2] == 'R'){
        cout << "3" << endl;
        return 0;
    }
    if(S[0]=='S' && S[1] == 'S' && S[2] == 'S'){
        cout << "0" << endl;
        return 0;
    }
    int cnt=0;
    REP(i,2){
        if(S[i] == 'R' && S[i+1]=='R') cnt++;
    }
    cout << cnt+1 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

//modの値の確認をすること
int main(){
    ll n;
    vector<ll> a(0);
    string s,t;
    cin >> n >> s >> t;
    rep0(i, n){
        if(s[i] == t[i])a.push_back(1);
        else{
            a.push_back(2);
            ++i;
        }
    }
    ll ans = (a[0] == 1? 3:6);
    rep1(i, a.size() - 1){
        if(a[i] == 1){
            if(a[i - 1] == 1)ans *= 2;
            ans %= mod;
        }else{
            if(a[i - 1] == 1)ans *= 2;
            else ans *= 3;
            ans %= mod;
        }
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll A, B;
    cin >> A >> B;
    --A;

    ll fa = (A + 1) / 2 % 2, fb = (B + 1) / 2 % 2;
    int M = 41;
    REP(i, M-1) {
        ll v = 1LL << (M - i - 1);

        if (A & v) {
            A -= v;
            if (A % 2 == 0) fa += v;
        }

        if (B & v) {
            B -= v;
            if (B % 2 == 0) fb += v;
        }
    }
    
    cout << fixed << setprecision(20);
    cout << ll(fb ^ fa) << endl;

}


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

struct node{
	int Next,y,v;
}Pth[200005];
int cnt,head[100005];
inline void add(int x,int y,int v){
	cnt++;
	Pth[cnt]={head[x],y,v};
	head[x]=cnt;
}

struct Edge{
	int x,y,dir; //dir {1: x->y  -1: y->x}
}E[100005];
int n,m;
bool tg[100005],vis[100005];

void dfs(int x,int inid,int pr){
	vis[x]=1;
	for (int i=head[x];i;i=Pth[i].Next){
		if (vis[Pth[i].y]) continue;
		dfs(Pth[i].y,Pth[i].v,x);
	}
	if (tg[x]){
		tg[x]^=1; tg[pr]^=1;
		E[inid].dir=-E[inid].dir;
	}
}

int main(){
	cin>>n>>m;
	if (m%2==1){
		cout<<-1<<endl;
		return 0;
	}
	for (int i=1;i<=m;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y,i); add(y,x,i);
		E[i]={x,y,1}; tg[x]^=1;
	}
	dfs(1,0,0);
	for (int i=1;i<=m;++i){
		if (E[i].dir==-1) swap(E[i].x,E[i].y);
		printf("%d %d\n",E[i].x,E[i].y);
	}
	return 0;
}

Measured memory_bytes: 10240
#include<stdio.h>
int main(void){
    char S[6+1];
    scanf("%s",S);
    if((S[2]==S[3])&&(S[4]==S[5])){
        printf("Yes\n");
    }else if((S[2]!=S[3])||(S[4]!=S[5])){
        printf("No\n");
    }
}

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


int main() {
  string r, g, b;
  cin >> r >> g >> b;
  if (stoi(r + g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] strA = br.readLine().split(" ");
        int[] A = Stream.of(strA).mapToInt(Integer::parseInt).toArray();
        
        // ボールを入れるか入れないか
        int[] B = new int[N];
        List<Integer> list = new ArrayList<>();
        
        for(int i = N; i >= 1; i--){
            int baisuu = 2;
            int ballCount = 0;
            while( i * baisuu <= N ) {
                ballCount += B[i*baisuu-1];
                ++baisuu;
            }

            if ( A[i-1] == ballCount % 2 ) continue;
            B[i-1] = 1;
            list.add(i);
        }
        
        System.out.println(list.size());
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < list.size(); i++){
            sb.append(list.get(i));
            if (i != list.size() -1) sb.append(" ");
        }
        
        System.out.println(sb);
    }
}


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

int N;
int x[8], y[8];
double ans = 0;
int dep;
void dfs(int d, int n) {
    if(n == 0) {
        dep = d;
        return;
    }
    for(int i = d; i < N; ++i) {
        ans += sqrt((x[d] - x[i])*(x[d] - x[i]) + (y[d] - y[i])*(y[d] - y[i]));
    }
    dfs(d+1, n-1);
}

int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> x[i] >> y[i];
    dfs(0, N);
    printf("%.10f\n", 2 * ans / dep);
}


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

using namespace std;

typedef long long ll;

const int maxN = 1e5 + 2;

int n;
ll a[maxN];
ll b[maxN];

ll s = 0;
ll p = 0;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n + 1; ++i)
    {
        cin >> a[i];
        s += a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        cin >> b[i];
        ll k = min(b[i], a[i]);
        a[i] -= k;
        b[i] -= k;
        k = min(b[i], a[i + 1]);
        a[i + 1] -= k;
        b[i] -= k;
    }
    for (int i = 1; i <= n + 1; ++i)
    {
        p += a[i];
    }
    cout << s - p;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
#include<vector>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main() {

	int a, b;
	cin >> a >> b;
	if (a >= b)cout << a - b << endl;
	else cout << 0 << endl;
	

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

import math
A_=list(set(A))

def lcm(a,b):
    gcd_= math.gcd(a,b)
    return int(a*b//gcd_)

lcm_ = A_[0]

for a_idx in range(1,len(A_)):
    lcm_ = lcm(lcm_,A_[a_idx])
    
lcm_ = lcm_-1
lcm_

ans=0
for a in A:
#     print(lcm_%a)
    ans+=lcm_%a
    
print(ans)

Measured memory_bytes: 73828
#!/usr/bin/env python
import sys
from collections import deque
sys.setrecursionlimit(10 ** 9)
inf = float("inf")
readline = sys.stdin.buffer.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
nt = lambda: tuple(map(int, readline().split()))

# BFS
def main():
    N, M = nm()
    edges = [[] for _ in range(N)]
    for _ in range(M):
        a, b = nm()
        a, b = a-1, b-1
        edges[a].append(b)
        edges[b].append(a)

    ans = [-1] * N
    deq = deque([0])
    while deq:
        node = deq.popleft()
        for next_node in edges[node]:
            # ans[next_node] == -1 -> not seen
            if ans[next_node] == -1:
                ans[next_node] = node
                deq.append(next_node)
    print("Yes")
    [print(i+1) for i in ans[1:]]

if __name__ == '__main__':
    main()



Measured memory_bytes: 96208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int a[3];
  rep(i,3)cin >> a[i];
  int sum=0;
  rep(i,3) sum+=a[i];
  if(sum>=22) cout << "bust" << endl;
  else cout << "win" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
/**
 * ????¨?
?§???????????????? S ???????????????????????§???h:m:s
?????¢?????????????????????????????????????????????????????§???h ????????????m ??? 60 ???????????????s ??? 60
??????????§???¨????????????

Input
S ?????????????????????????????????

Output
h???m???s ??? :??????????????????????????§??????????????????????????????????????°?????????????????´??????0
????????????????????¨???????????????????????????????????????

Constraints
0???S<86400

Sample Input
46979

Sample Output
13:2:59

 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int h, m, s, S = 0;

  while (true) {
    std::string param;

    getline(std::cin, param);
    std::istringstream iss(param);
    iss >> S;

    if (S > 86400) {
      std::cout << "Error: 0 <= S <= 86400" << std::endl;
    } else {
      break;
    }
  }
  s = S % 60;
  m = ((S - s) / 60) % 60;
  h = ((S - s - m * 60) / 3600) % 60;

  std::cout << h << ":" << m << ":" << s << std::endl;

  return 0;
}

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

int main() {
    int ans = 0;
    int N, M;
    cin >> N >> M;
    for (int i=0; i<N; ++i) {
        for (int j=i; j<N; ++j) {
            if (i != j) {
                ++ans;
            }
        }
    }
    for (int i=0; i<M; ++i) {
        for (int j=i; j<M; ++j) {
            if (i != j) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
        	String s = in.next();
        	out.println(s.charAt(0) == s.charAt(1) || 
        			s.charAt(1) == s.charAt(2) ||
        			s.charAt(2) == s.charAt(3) ? "Bad" : "Good");
        }
    }
    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        
        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  ll ans = 0;
  repr(i, n - 1) {
    if ((a[i] + ans) % b[i] != 0) {
      ans += b[i] - (a[i] + ans) % b[i];
    }
  }
  cout << ans << '\n';




  
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
long long ab(long long x){return max(x,-x);}
int main(){
    long long a,b;
    cin>>a>>b;
    if(ab(a-b)<=1) printf("Brown\n");
    else printf("Alice\n");
    return 0;
}


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

using namespace std;
int main(){
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		cnt+=s[i]=='x';
	}
	if(cnt<8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  uint64_t ans = 3, a = 2, b = 1;
  int N;
  cin >> N;
  if(N == 0) {
    ans = 2;
  }
  if(N == 1) {
    ans = 1;
  }
  if(N > 1) {
    for(int i = 2; i < N; i++) {
      a = b;
      b = ans;
      ans = a + b;
    }
  }
  printf("%ld", ans);
}

Measured memory_bytes: 3748
import math
X = int(input())
# maximum base b comes with minimum power p = 2, b**2 <= X
max_base = int(X**(1.0/2.0))
# maximum power p comes with minimum base b = 1, no limit. next min: b = 2
max_power = int(math.log(X)/math.log(2))
perfect_powers = [b**p for p in range(2,max_power+1) for b in range(1,max_base+1) if b**p <= X]
if perfect_powers:
    print(max(perfect_powers))
else: 
    print(1)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, N, SR, SC;
    cin >> H >> W >> N >> SR >> SC;
    string S, T;
    cin >> S >> T;
    // up
    int t_cnt = 0, a_cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'D') t_cnt++;
        if (SR + t_cnt - a_cnt > H) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'U' && SR + t_cnt - a_cnt > 2) a_cnt++;
    }
    t_cnt = a_cnt = 0;
    // down
    for (int i = 0; i < N; i++) {
        if (S[i] == 'U') t_cnt++;
        if (SR - t_cnt + a_cnt < 1) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'D' && SR - t_cnt + a_cnt < H) a_cnt++;
    }
    t_cnt = a_cnt = 0;
    // right
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') t_cnt++;
        if (SC + t_cnt - a_cnt > W) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'L' && SC + t_cnt - a_cnt > 2) a_cnt++;
    }
    t_cnt = a_cnt = 0;
    // left
    for (int i = 0; i < N; i++) {
        if (S[i] == 'L') t_cnt++;
        if (SC - t_cnt + a_cnt < 1) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'R' && SC - t_cnt + a_cnt < W) a_cnt++;
    }
    cout << "YES" << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

void pudge(){
    int n, ans = 0;
    cin >> n;
    vector<pair<string, int> > a(n);
    for (auto& i : a)
        cin >> i.X >> i.Y;
    string s;
    cin >> s;
    int i = 0;
    for (; i < n; ++i) 
        if (a[i].X == s) break;
    i++;
    for (; i < n; i++)
        ans += a[i].Y;
    cout << ans;
}

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

    int q = 1;
    //cin >> q;
    while(q--) pudge();

    return 0;
}


Measured memory_bytes: 256
N=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
cp=[i-j for i, j in zip(v,c)]
ans=0
for a in sorted(cp,reverse=True):
    if a>=0:
        ans+=a
    else:
        break
print(ans)
    

Measured memory_bytes: 3060
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <stack>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  string s;
  cin >> n >> s;

  int l = 0, r = 0;
  stack<int> st;
  
  REP(i, n){
    if(s[i] == ')'){
      if(r>0) {
	r--;
      }
      else l++;
    }
    else{
      r++;
    }
    //cerr << "i: " << i << " "<< l << " " << r << endl;    
  }

  REP(i, l) cout << "(";  
  cout << s;
  REP(i, r) cout << ")";
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	vector<int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	
	sort(ALL(v));
	
	if(v[0] == 5 && v[1] == 5 && v[2] == 7)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else
    cout << "Sunny" << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N;
  cin >> N;
  vector<pair<pair<string, ll>, ll>> SP(N);
  rep(i, 0, N){
    iikae youso = SP.at(i);
    ll tokuten;
    cin >> youso.first.first >> tokuten;
    youso.first.second = -tokuten;
    youso.second = i + 1;
  }
  sort(SP.begin(), SP.end());
  for(auto&& youso : SP){
    cout << youso.second << rt;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<queue>
#include<unordered_map>
using namespace std;

int main() {
    string S;
    string T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int H = scn.nextInt();
		int W = scn.nextInt();
		int h = scn.nextInt();
		int w = scn.nextInt();
		System.out.println((H-h)*(W-w));
	}

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int a[100010];
int c[3];
int main() {
	int n;
	cin >> n;
	rep(i,n) cin >> a[i];

	ll ans = 1;
	rep(i,n) {
		int cnt = 0, id = -1;
		if (a[i] == c[0]) {
			cnt++; id = 0;
		}
		if (a[i] == c[1]) {
			cnt++; id = 1;
		}
		if (a[i] == c[2]) {
			cnt++; id = 2;
		}
		
		if (id == -1) {
			cout << 0 << endl;
			return 0;
		}
		c[id]++;
		ans *= cnt;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


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

    int a,b,c; 
    cin >> a >> b >> c;
    if (c>=a && c<=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;   
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
  public static void main(String[]args) {
      Scanner sc=new Scanner(System.in);
      int a=sc.nextInt();
      int h=a/3600;
      int m=(a%3600)/60;
      int s=a%60;
      System.out.println(h+":"+m+":"+s);
  }
}


Measured memory_bytes: 26248
n, y = map(int, input().split())
x = 0
for i in range(n + 1):
    # if 10000*i > y:break
    for j in range(n - i + 1):
        # if 10000 * i + 5000 * j > y:
        #     break
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n - i - j)
            x = 1
            break

    if x == 1:
        break

if x == 0:
    print(-1,-1,-1)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    std::cin >>x>>y>>z;
    if(x*y<z)cout<<x*y;
    else cout << z;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int a[100][100],b[100],i,j,n,m,c;

        scanf("%d %d",&n,&m);
        for(i=0;i<n;i++){
                for(j=0;j<m;j++)
                        scanf("%d",&a[i][j]);
        }
        for(i=0;i<m;i++)
                scanf("%d",&b[i]);
        for(i=0;i<n;i++){
                c=0;
                for(j=0;j<m;j++)
                        c+=(a[i][j]*b[j]);
                printf("%d\n",c);
        }
        return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int main(){
    ll n,k;
    cin >> n >> k;
    vector<P> vp(n);
    rep(i,n){
        cin >> vp[i].first >> vp[i].second;
    }
    sort(ALL(vp));
    rep(i,n){
        k -= vp[i].second;
        if(k <= 0){
            cout << vp[i].first << endl;
            return 0;
        }
    }
}

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

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn abs(a: usize, b: usize) -> usize {
    if a > b {
        a - b
    } else {
        b - a
    }
}

fn main() {
    let hwd: Vec<usize> = read_vec();
    let h = hwd[0];
    let w = hwd[1];
    let d = hwd[2] as usize;
    let mat: Vec<Vec<usize>> = read_vec2(h);
    let hw = h * w;
    let mut axis: Vec<(usize, usize)> = vec![(0, 0); hw];
    for i in 0..h {
        for j in 0..w {
            axis[mat[i][j] - 1] = (i, j);
        }
    }

    let mut mp: Vec<u32> = vec![0; hw];

    for i in 0..d {
        let mut j = i;
        let mut tmp = 0;
        loop {
            let nj = j + d;
            if nj >= hw {
                break;
            }
            tmp += abs(axis[nj].0, axis[j].0) + abs(axis[nj].1, axis[j].1);
            mp[nj] = tmp as u32;
            j = nj;
        }
    }

    let q: usize = read();
    let mut ans = vec![0; q];
    for i in 0..q {
        let lr: Vec<usize> = read_vec();
        let l = lr[0] - 1;
        let r = lr[1] - 1;
        ans[i] = mp[r] - mp[l];
    }

    for a in ans {
        println!("{}", a);
    }
}


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

using namespace std;
typedef long long ll;

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H ; i++) {
        cin >> s[i];
    }

    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[0][0] = 0;
    queue<pair<int, int>> q;
    q.push(make_pair(0,0));
    while (!q.empty()) {
        pair<int, int> v = q.front(); q.pop();
        int x = v.first, y = v.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= H) continue;
            if (ny < 0 || ny >= W) continue;
            if (s[nx][ny] == '#') continue;
            if (dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[x][y] + 1;
            q.push(make_pair(nx, ny));
        }
    }

    if (dist[H-1][W-1] == -1) {
        cout << -1 << endl;
        return 0;
    }

    int tot = H * W;
    int cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') cnt++;
        }
    }
    cout << tot - cnt - dist[H-1][W-1] - 1 << endl;
}


Measured memory_bytes: 256
N = input()
for i in range(N):
    s = map(int, raw_input().split())
    x = s[0]
    y = s[1]
    bath = s[2]
    pool = s[3]
    fee = x * bath + y * pool
    disc_fee = max(bath, 5) * x + max(pool, 2) * y
    disc_fee = disc_fee * 4 / 5
    print "%d" % min(fee, disc_fee)

Measured memory_bytes: 6468
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int cnt=0;
    string s;
    cin >> s;
    char c[s.length()];

    REP(i, s.length()) c[i] = s[i];

    REP(i, s.length()-1){
        if(c[i] == c[i+1]){
            cnt++;
            if(c[i+1] == '0') c[i+1] = '1';
            else c[i+1] = '0';
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,k; cin>>a>>b>>k;
  if(b-a+1<2*k){
    for(int i=a;i<=b;i++)
    cout<<i<<endl;
  }else{
    for(int i=a;i<a+k;i++)
    cout<<i<<endl;
    for(int i=b-k+1;i<=b;i++)
    cout<<i<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s="",a,b;
	cin>>n;
	cin>>a>>b;
	for(int i=0;i<n;i++){
		s+=a[i];
		s+=b[i];
	}
	cout<<s<<"\n";
	return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Io.Read<int>();
            var Hlist = Io.ReadSplit<int>();

            var maxCount = 0;
            var count = 0;
            var prevH = 0;
            foreach (var H in Hlist)
            {
                if (H <= prevH)
                {
                    count++;
                }
                else
                {
                    maxCount = Math.Max(maxCount, count);
                    count = 0;
                }

                prevH = H;
            }

            maxCount = Math.Max(maxCount, count);

            Console.WriteLine(maxCount);
        }
    }

    class Io
    {
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IEnumerable<string> ReadRepeat(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read());
        }

        public static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        public static IEnumerable<T> ReadRepeat<T>(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read<T>());
        }

        public static string[] ReadSplit(char devide = ' ')
        {
            return Read().Split(devide);
        }

        public static T[] ReadSplit<T>(char devide = ' ')
        {
            return ReadSplit(devide)
                .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                .ToArray();
        }

        public static IEnumerable<T[]> ReadSplitRepeat<T>(int count, char devide = ' ')
        {
            return Enumerable.Range(0, count).Select(_ => ReadSplit<T>(devide));
        }
    }
}


Measured memory_bytes: 30300
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	while(sc.hasNext()){
    		new aoj0090().doIt();
    	}
    }
    class aoj0090{
    	int cnt = 0;
    	boolean num[] = new boolean [10];
    	void dfs(int n,int s,int c){
//    		System.out.println(s+" "+c+" "+cnt);
    		if(c == n && s == 0)cnt++;
    		if(c < n && s >= 0){
    			for(int i = 0;i <= 9;i++){
    				if(!num[i]){
    					if(s - (i*c) < 0)break;
    					num[i] = true;
    					dfs(n,s-(i*c),c+1);
    					num[i] = false;
    				}
    			}
    		}
    	}
    	void doIt(){
    		int n = Integer.parseInt(sc.next());
    		int s = Integer.parseInt(sc.next());
    		int max = 0;
    		for(int i = 0;i < 10;i++)max += i*(i+1);
    		cnt = 0;
    		if(n > 10 || s > max)System.out.println(0);
    		else{
    			if(s <= max){
    				dfs(n+1,s,1);
    				System.out.println(cnt);
    			}
    		}
    	}
    }
}

Measured memory_bytes: 26428