akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

using namespace std;

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const db PI = acos(-1);
const db ERR = 1e-12;

const int MX = 100005;

int main()
{
	string D;
	cin >> D;
	cout << D.substr(0, D.size()-8) << "\n";
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

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

    int cnt0 = 0;
    int cnt1 = 0;
    REP(i, S.length())
    {
        if (S[i] == '0')
            cnt0++;
        else
            cnt1++;
    }

    cout << min(cnt0, cnt1) * 2 << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read() {
	int x; scanf("%lld", &x); return x;	
}
const int maxn = 1e6 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
#define ll long long 
int n, m, k;
int f[3005][3005][4];
int g[3005][3005];
main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	n = read(), m = read(), k = read();
	for (int i = 1; i <= k; ++i) {
		int x = read(), y = read(), v = read();
		g[x][y] = v;
	} 
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			for (int k = 0; k <= 3; ++k) {
				f[i][j][k] = max(f[i][j][k], f[i][j - 1][k]);
				for (int p = 0; p <= 3; ++p) f[i][j][k] = max(f[i][j][k], f[i - 1][j][p]);
			}
			if (g[i][j]) {
				for (int k = 2; k >= 0; --k)
					f[i][j][k + 1] = max(f[i][j][k + 1], f[i][j][k] + g[i][j]);
			}
		}
	}
	int ans = 0;
	for (int k = 0; k <= 3; ++k) ans = max(ans, f[n][m][k]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 355512
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	ll pas[51][52];
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

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

	const ll nmax = 41,abmax = 401;
	ll dp[nmax][abmax][abmax];

	int main(){
		IOS;
		Fill(dp,INF);
		ll n, ma, mb;
		cin >> n >> ma >> mb;
		dp[0][0][0] = 0;
		vec<ll> a(n),b(n),c(n);
		REP(i,n)cin >> a[i] >> b[i] >> c[i];
		REP(i,n)REP(j, abmax + 1)REP(k, abmax + 1){
			if(j >= a[i] && k >= b[i] && dp[i][j - a[i]][k - b[i]] != INF){
				dp[i + 1][j][k] = min(dp[i][j - a[i]][k - b[i]] + c[i],dp[i][j][k]);				
			}
			else dp[i + 1][j][k] = dp[i][j][k];
		}

		ll ans = INF;
		for(int i = 1;i * ma <= abmax && i * mb <= abmax;i++){
			ans = min(dp[n][i * ma][i * mb],ans);
		}
		if(ans == INF)dump(-1);
		else dump(ans);
	}

Measured memory_bytes: 51712
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def insertion_sort(A, N, G):
    cnt = 0
    for i in range(G, N):
        v = A[i]
        j = i - G
        while j >= 0 and A[j] > v:
            A[j + G] = A[j]
            j = j - G
            cnt += 1
        A[j + G] = v
    return cnt


def shell_sort(A, N, G, m):
    cnt = 0
    for i in range(m):
        cnt += insertion_sort(A, N, G[i])
    return cnt


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [ii() for _ in range(N)]

    G = [1]
    for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
    m = len(G)
    G = G[::-1]
    cnt = shell_sort(A, N, G, m)

    print(m)
    print(*G)
    print(cnt)
    print(*A, sep='\n')


if __name__ == '__main__':
    main()



Measured memory_bytes: 54948
#include<bits/stdc++.h>                
using namespace std;
typedef long long lint;
#define FOR(i,o,n) for(auto i = (o); (i) < (n); ++(i))
#define REP(i,n) FOR(i,0,n) 
#define REPR(i,n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr,v) for(auto itr=v.begin(); itr != v.end(); ++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define Vi2(name,h,w)  vector< vector<int> > name((h), vector<int>(w));

int main(void){
	int N; cin >> N;
	vector<int> v(N); REP(i, N)cin >> v[i];

	sort(v.begin(), v.end());
	int sum; for(int i = 0; i < N-1; ++i) sum += v[i];

	if(v[N-1] < sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
    A = str(A)
    B = str(B)
    print(A+' '+B)
else :
    B -= 1
    A = str(A)
    B = str(B)
    print(A+' '+B)

Measured memory_bytes: 9160
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


xnk = input().split()
D = int(xnk[0])
T = int(xnk[1])
S= int(xnk[2])

time = D/S

if time > T:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 9280
#include<cstdio>
#include<algorithm>
using namespace std;
int a[205];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
	{
        int l,cnt=0;
        scanf("%d",&l);
        while(l%2==0)
		{
            cnt++;
            l/=2;
        }
        a[i]=cnt;
    }
    sort(a+1,a+n+1);
    printf("%d\n",a[1]);
    return 0;
}

Measured memory_bytes: 128
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

void Add(VVI &ans, int h, int w) {
	FOR(i, 0, 8) {
		int nowh = h + dxx[i];
		int noww = w + dyy[i];
		if (nowh >= 0 && noww >= 0 && nowh < ans.size() && noww < ans[0].size()) {
			ans[nowh][noww]++;
		}
	}
}

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	int H, W;
	cin >> H >> W;
	vector<string> VS;
	VVI ans(H, VI(W, 0));
	FOR(i, 0, H) {
		VS.push_back(IN<string>());
	}
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			if (VS[i][j] == '#') {
				Add(ans, i,j);
			}
		}
	}
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			if (VS[i][j] == '#')
				cout << '#';
			else
				cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,a[105];
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++)
        cin>>a[i];

    ll ans=9999999;
    for(int k=1;k<=200;k++)
    {
        ll t=0;
        for(int i=0;i<n;i++)
        {
            t+=abs(a[i]-k)*abs(a[i]-k);
        }
        ans=min(ans,t);
    }

    cout<<ans<<endl;
    return 0;
}


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

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var N = nk[0];
			var K = nk[1] + 1;
			var V = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

			var ans = 0;
			foreach (var a in Enumerable.Range(0, K))
			{
				var queueA = V.Take(a).ToList();
				foreach (var b in Enumerable.Range(0, K - a))
				{
					var queueB = queueA.Concat(V.Skip(Math.Max(a, N - b))).ToList();
					queueB.Sort();
					foreach (var c in Enumerable.Range(0, Math.Min(K - (a + b), queueB.Count() + 1)))
					{
						var queueC = queueB.Skip(c);
						ans = Math.Max(ans, queueC.Sum());
					}
				}
			}
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 17604
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

	vector<int> a(n + 2);
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += abs(a[i] - a[i - 1]);
	}
	sum += abs(a[n + 1] - a[n]);

	for (int i = 1; i <= n; i++) {
		cout << sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << endl;
	}


	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Linq;

namespace _0032
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0;
            int b = 0;
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                int[] x = s.Split(',').Select(int.Parse).ToArray();
                if (x[0] * x[0] + x[1] * x[1] == x[2] * x[2])
                {
                    a++;
                }
                if (x[0] == x[1])
                {
                    b++;
                }
            }
            Console.WriteLine(a);
            Console.WriteLine(b);
        }
    }
}

Measured memory_bytes: 9400
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////


int main() {
	
	ll T;
	cin >> T;
	repn(t, T) {
		ll N;
		cin >> N;

		vector <vector<pair<ll, ll>>> cam(N + 1);
		ll sum = 0;

		repn(i, N) {
			ll k, l, r;
			cin >> k >> l >> r;
			cam[k].push_back({ l,r });
		}

		priority_queue<ll> q;

		repn(i, N) {
			for (auto p : cam[i]) {
				ll l = p.first;
				ll r = p.second;
				if (l > r) { q.push(r - l); sum += l; }
			}

			while (q.size() > i) { sum += q.top(); q.pop(); }
		}

		priority_queue<ll> q2;

		for(ll i=N;i>=1;i--) {
			for (auto p : cam[i]) {
				ll l = p.first;
				ll r = p.second;
				if (l <= r) { q2.push(l-r); sum += r; }
			}

			while (q2.size() > N-i) { sum += q2.top(); q2.pop(); }
		}

		

		cout << sum << endl;
	}

}

Measured memory_bytes: 15320
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}

	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, x;
	string com;

	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	free(root);
	free(NIL);
}


Measured memory_bytes: 22076
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<string>
#include<iostream>
#define M 100000000
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;
int main(void)
{
	int n,m,i,j,k;
	int cost[101][101],time[101][101];
	int a,b,c,t;
	while(1) {
		cin>>n>>m;
		if(n==0&&m==0) break;
		rep(i,m)rep(j,m){cost[i][j]=M;time[i][j]=M;}
		rep(i,m){cost[i][i]=0;time[i][i]=0;}
		rep(i,n) {
			cin>>a>>b>>c>>t;
			a--;b--;
			cost[a][b]=c;cost[b][a]=c;
			time[a][b]=t;time[b][a]=t;
		}
		rep(k,m)rep(i,m)rep(j,m) {
			cost[i][j]=min(cost[i][k]+cost[k][j],cost[i][j]);
			time[i][j]=min(time[i][k]+time[k][j],time[i][j]);
		}
		int q,s,g,kk;
		cin>>kk;
		rep(i,kk) {
			cin>>s>>g>>q;
			s--;g--;
			if(q==0) cout<<cost[s][g]<<endl;
			else cout<<time[s][g]<<endl;
		}
	}
	return 0;
}
		
	
	

Measured memory_bytes: 3152
'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(x => x*1);
  
  let ans = 1;
  if(inp[0] != 1 && inp[1] != 1){
	ans = Math.ceil((inp[0]*inp[1])/2);
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main(){
  string Sa,Sb,Sc;
  cin >> Sa >> Sb >> Sc;
  Sa += "e";
  Sb += "e";
  Sc += "e";
  int ia=1, ib=0, ic=0;
  char c = Sa[0];
  while(true){
    switch(c){
      case 'a':
        c = Sa[ia];
        ia++;
        if (c=='e'){
          cout << "A" << endl;
          return 0;
        }
        break;
      case 'b':
        c = Sb[ib];
        ib++;
        if (c=='e'){
          cout << "B" << endl;
          return 0;
        }
        break;
      case 'c':
        c = Sc[ic];
        ic++;
        if (c=='e'){
          cout << "C" << endl;
          return 0;
        }
        break;
    }
  }
  return 0;
}
        

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let s: String = read();

    if a >= 3200 {
        println!("{}",s);
    }else{
        println!("red");
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X[1000], Y[1000], S[1000];
  cin >> N;
  FOR(i,0,N) {
    cin >> X[i] >> Y[i];
    S[i] = X[i] + Y[i];
    if((S[i] - S[0]) % 2 != 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  vector<int> values;
  for(int i=30;i>=0;i--) values.push_back(1<<i);
  if(S[0] % 2 == 0) values.push_back(1);
  int M = values.size();
  cout << M << endl;
  FOR(i,0,M) cout << values[i] << " \n"[i==M-1];
  FOR(i,0,N) {
    int xpy = X[i] + Y[i], xmy = X[i] - Y[i];
    for(auto& v : values) {
      if(xpy >= 0) {
        if(xmy >= 0) {
          cout << "R";
          xpy -= v;
          xmy -= v;
        } else {
          cout << "U";
          xpy -= v;
          xmy += v;
        }
      } else {
        if(xmy >= 0){
          cout << "D";
          xpy += v;
          xmy -= v;
        }else{
          cout << "L";
          xpy += v;
          xmy += v;
        }
      }
    }
    cout << endl;
  }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m; cin >> n >> m;
    bool rev = false;
    if(n <= m) {
        swap(n, m);
        rev = true;
    }
    
    int N = 1 << n;
    int M = 1 << m;
    vvi sum(N, vi(N, 0)), sum_i(N, vi(N, 0)), ans(N, vi(N, 0));
    
    rep(i, N){
        rep(j, N){
            sum[i][j] = __builtin_popcount(i & j) % 2; 
        }
    }

    rep3(i, 1, N-1){
        rep(j, N){
            sum_i[i][j] = (sum[i][j] - sum[i-1][j]) % 2;
        }
    }

    rep(i, N){
        rep3(j, 1, N-1){
            ans[i][j] = (sum_i[i][j] - sum_i[i][j-1]) % 2;
        }
    }
    
    /*
    rep(i, N){
        rep(j, M){
            cout << sum[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    
    rep(i, N){
        rep(j, M){
            cout << sum_i[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    
    if(rev) swap(N, M);
    
    rep3(i, 1, N-1){
        rep3(j, 1, M-1){
            cout << (ans[i][j] + 2) % 2;
        }
        cout << endl;
    }
    return;
}

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

Measured memory_bytes: 15584
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   	ll n;
   	cin >> n;
   	vector <ll> arr(n);
   	for (int z=0;z<n;z++){
   		cin >> arr[z];
   	}
   	vector <ll> dp(n);
   	dp[0] = 0;
   	dp[1] = abs(arr[1]-arr[0]);
   	for (int z=2;z<n;z++){
   		dp[z] = min(dp[z-1]+abs(arr[z-1]-arr[z]),dp[z-2]+abs(arr[z-2]-arr[z]));
   	}
   	cout << dp[n-1] << endl;
   	cin >> n;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
int main()
{
  long long n,tmp;
  scanf("%lld",&n);
  long i;
  long long answ=n-1;
  for(i=2;i<3000000;i++)
  {
    if(n%i==0)
    {
      tmp=i+(n/i)-2;
      if(tmp<answ)
        answ=tmp;
    }
  }
  printf("%lld",answ);
  return 0;
}

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

int main(){
    int H, W, K;
    std::cin >> H >> W >> K;
    std::vector< std::vector< bool > > HV(H, std::vector< bool >(W, false));
    for(int i=0; i<H; i++){
        std::string tmp;
        std::cin >> tmp;
        for(int j=0; j<W; j++){
            if(tmp[j] == '#'){
                HV[i][j] = true;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<(int)std::pow(2,H); i++){
        for(int j=0; j<(int)std::pow(2,W); j++){
            int cnt = 0;
            for(int ci=0; ci<H; ci++){
                int mask_i = 1 << ci;
                for(int cj=0; cj<W; cj++){
                    int mask_j = 1 << cj;
                    if(HV[ci][cj] && !((i & mask_i) || (j & mask_j))){
                        cnt++;
                    }
                }
            }
            if(cnt == K){
                ans++;
            }
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}



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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char ch; cin>>ch;
    if(ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o'){
        print("vowel");
    } else print("consonant");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
HT = list(map(lambda x: T - x*0.006, H))
answer = 0
for i in range(len(HT)):
    if abs(HT[i] - A) < abs(HT[answer]-A):
        answer = i
print(answer + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int

int main()
{
 	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	//ll tt;	cin>>tt;	while(tt--)
  	{
  		ll n,m;
  		cin>>n>>m;

  		cout<<(n==m ? "Yes" : "No")<<endl;
  	}
 	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;
  		
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> perm(N);
    for(int i = 0;i < N;i++)perm[i] = i;
    for(auto &x:a)cin >> x;
    for(auto x:a){
        swap(perm[x-1],perm[x]);
    }
    int ans = 1e9;
    sort(a.begin(),a.end());
    do{
        vector<int> perm2(N);
        for(int i = 0;i < N;i++)perm2[i] = i;
        for(auto x:a){
            swap(perm2[x-1],perm2[x]);
        }
        if(perm != perm2)continue;
        vector<int> lower(N+1,0);
        reverse(a.begin(),a.end());
        for(auto x:a){
            int tmp = max(lower[x-1],lower[x]) + 1;
            lower[x-1] = tmp;
            lower[x] = tmp;
        }
        reverse(a.begin(),a.end());
        ans = min(ans,*max_element(lower.begin(),lower.end()));
    }while(next_permutation(a.begin(),a.end()));
    cout << ans << endl;
}


Measured memory_bytes: 3148
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 3010
#define MO 1000000007
int f[MAXN][MAXN],dp[MAXN][MAXN],n,m,a[MAXN];
struct node
{
	int l,r;
}p[MAXN];
bool cmp(node a,node b)
{
	return a.l<b.l||(a.l==b.l&&a.r<b.r);
}
void Pre()
{
	f[0][0]=1;
	for(int i=1;i<n;i++)
	{
		f[i][0]=1;
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j]+f[i-1][j-1])%MO;
	}
}
char s[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	for(int i=0;i<n;i++)
		a[i+1]=a[i]+s[i]-'0';
	Pre();
	for(int i=1;i<=m;i++)
		scanf("%d%d",&p[i].l,&p[i].r);
	sort(p+1,p+1+m,cmp);
	int mx=0,tmp=m;
	for(int i=1;i<=m;i++)
		if(p[i].l==p[i+1].l||p[i].r<=mx)
			p[i].l=n+1,tmp--;
		else mx=max(p[i].r,mx);
	sort(p+1,p+1+m,cmp);
	m=tmp;
	dp[p[1].l-1][a[p[1].l-1]]=1;
	p[m+1].l=n+1;
	for(int i=1;i<=m;i++)
	{
		int l=p[i].l,r=p[i].r,x=p[i+1].l;
		for(int j=0;j<l;j++)
		{
			if(!dp[l-1][j]) continue;
			int s=a[r]-j,st=max(0,s-(r-x+1)),ed=min(s,x-l);
			if(x>r)
			{
				dp[x-1][a[x-1]]+=1LL*dp[l-1][j]*f[r-l+1][s]%MO;
				dp[x-1][a[x-1]]%=MO;
				continue;
			}
			for(int k=st;k<=ed;k++)
			{
				dp[x-1][j+k]+=1LL*dp[l-1][j]*f[x-l][k]%MO;
				dp[x-1][j+k]%=MO;
			}
		}
	}
	printf("%d\n",dp[n][a[n]]);
}

Measured memory_bytes: 69120
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

int a[N],dp[N];
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    dp[0]=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            if(a[j]>i) continue;
            dp[i]=max(dp[i-a[j]]^1,dp[i]);
        }
//        cout<<dp[i]<<' ';
    }
    if(dp[k]) puts("First");
    else puts("Second");

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 640
#include <stdio.h>

int main() {
  int a, b, c, x, count = 0;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  for(int i=0;i<=a;i++) {
    for(int j=0;j<=b;j++) {
      int d = x - i * 500 - j * 100;
      if(d % 50 == 0 && 0 <= d && d / 50 <= c) {
        count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	string s, t, u;
	int a, b; cin >> s >> t >> a >> b >> u;
	cout << a - (s == u) << " " << b - (t == u);


	return 0;
}


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

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

  

  if((d+(s-1))/s<=t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B,C;
  cin>>A>>B>>C;
  int a=A.size(),b=B.size();
  if(A.at(a-1)==B.at(0) && B.at(b-1)==C.at(0)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = input()
q_number = int(input())
reverse_flag = 1
head = ""
tail = ""
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    headstails = int(temp[1])*reverse_flag 
    if headstails == 1 or headstails == -2:
      head = temp[2] + head
    else:
      tail = tail + temp[2]
      
if reverse_flag == 1:
  print(head+s+tail)
else:
  print(tail[::-1]+s[::-1]+head[::-1])
        
       

Measured memory_bytes: 4548
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

vector<int> v{0,111,222,333,444,555,666,777,888,999};
int main()
{
    string s;
    cin>>s;
    for(char c:s) if(c=='1') cout<<9;else if(c=='9') cout<<1;else cout<<c;
    cout<<endl;
}

Measured memory_bytes: 256
/*input
1 2019
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=2505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int32_t main(){
    ll a,b;
    cin>>a>>b;
    set<ll> s;
    map<ll,bool> mp,mp2;
    for(int i=2;i<=sqrt(a);i++){
        while(a%i==0){
            a/=i;
            s.insert(i);
            mp[i]=true;
        }
    }
    if(a>1){
        s.insert(a);
        mp[a]=true;
    }
    a=b;
    for(int i=2;i<=sqrt(a);i++){
        while(a%i==0){
            a/=i;
            s.insert(i);
            mp2[i]=true;
        }
    }
    if(a>1){
        s.insert(a); 
        mp2[a]=true;
    }
    ll ans=1; 
    for(auto x:s){
        if(mp[x] and mp2[x]) ++ans;
    }
    cout<<ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FU(i, l, r) for (register int i = (l), _end_ = (int)(r); i <= _end_; ++ i)
#define FD(i, r, l) for (register int i = (r), _end_ = (int)(l); i >= _end_; -- i)
#define X first
#define Y second
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a).size())
#define lowbit(x) x & (-x)
#define pii pair<int, int>
#define LL long long
#define INF 0x3f3f3f3f
#define file(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
using namespace std;

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

template <typename T> inline T read() {
    static T  __; static char c_; static bool flag_;
    __ = 0; c_ = getchar(); flag_ = false;
    while (c_ > '9' || c_ < '0') {flag_ |= c_ == '-';  c_ = getchar();}
    while (c_ >= '0' && c_ <= '9') {__ = (__ << 1) + (__ << 3) + (c_ ^ 48); c_ = getchar();}
    return flag_ ? -__ : __;
}

template <typename T> inline T write(T a) {
        if (a < 0) {putchar('-'); a = -a;}
        if (a > 9) write(a / 10);
        putchar(a % 10 + '0');
	return 0;
}

const int maxN = 40 + 4;

int n, m, sum[maxN][maxN], dp[maxN][maxN][maxN][maxN], dx, dy, ans;
char tmp;

inline int getsum(int x, int y, int u, int v)
{
    if (x > u || y > v)
        return 0;
    return sum[u][v] - sum[x-1][v] - sum[u][y-1] + sum[x-1][y-1];
}

inline void Input()
{
    ios::sync_with_stdio(false);
	cin >> n >> m;
	for (register int i = 1; i <= n; ++ i)
	{
		for (register int j = 1; j <= m; ++ j)
		{
			cin >> tmp;
			sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + (tmp == '#');
			if (tmp == 'P')
				dx = i, dy = j;
		}
	}
	memset (dp, 0x3f, sizeof(dp));
    ans = dp[0][0][0][0];
	return;
}

inline void Solve()
{
	dp[1][1][n][m] = 0;
	for (register int i = 1; i <= dx; ++ i)
	for (register int j = 1; j <= dy; ++ j)
	for (register int k = n; k >= dx; -- k)
	for (register int l = m; l >= dy; -- l)
	{
		chkmin(ans, dp[i][j][k][l] + min(min(getsum(i,j,dx,dy), getsum(i,dy,dx,l)), min(getsum(dx,j,k,dy), getsum(dx,dy,k,l))));
		for (register int s = i; s <= k; ++ s)
		for (register int t = j; t <= l; ++ t)
		{
			if (s <= dx && t <= dy)
				chkmin(dp[s][t][k][l], dp[i][j][k][l] + getsum(i,t,s-1,l) + getsum(s,j,k,t-1));
			if (s >= dx && t <= dy)
				chkmin(dp[i][t][s][l], dp[i][j][k][l] + getsum(i,j,s,t-1) + getsum(s+1,t,k,l));
			if (s >= dx && t >= dy)
				chkmin(dp[i][j][s][t], dp[i][j][k][l] + getsum(i,t+1,s,l) + getsum(s+1,j,k,t));
			if (s <= dx && t >= dy)
				chkmin(dp[s][j][k][t], dp[i][j][k][l] + getsum(i,j,s-1,t) + getsum(s,t+1,k,l));
		}	
	}
	return;
}

inline void Output()
{
    write(ans);
    putchar('\n');
	return;
}

int main()
{
	Input();
	Solve();
	Output();
    return 0;
}


Measured memory_bytes: 14976
import itertools
import math
import fractions
import functools
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse=True)
if k < n:
    for i in range(k):
        h[i] = 0
else:
    h = [0] * len(h)
print(sum(h))


Measured memory_bytes: 113616
#include <stdio.h>
const int maxn=2005;
int e[2][maxn][maxn],a[maxn][maxn];char s[maxn][maxn];
int main(){
	int n,m,Q,i,j;scanf("%d%d%d",&n,&m,&Q);
	for(i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for(j=1;j<=m;j++){
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+s[i][j]-'0';
			if(s[i][j]=='1'){
				if(s[i-1][j]=='1')e[0][i][j]++;
				if(s[i][j-1]=='1')e[1][i][j]++;
			}
			e[0][i][j]=e[0][i-1][j]+e[0][i][j-1]-e[0][i-1][j-1]+e[0][i][j];
			e[1][i][j]=e[1][i-1][j]+e[1][i][j-1]-e[1][i-1][j-1]+e[1][i][j];
		}
	}
	while(Q--){
		int a1,a2,b1,b2,node,edge;
		scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
		node=a[a2][b2]+a[a1-1][b1-1]-a[a2][b1-1]-a[a1-1][b2];
		edge =e[0][a2][b2]+e[0][a1][b1-1]-e[0][a2][b1-1]-e[0][a1][b2];
		edge+=e[1][a2][b2]+e[1][a1-1][b1]-e[1][a2][b1]-e[1][a1-1][b2];
		//printf("node=%d edge=%d\n",node,edge);
		printf("%d\n",node-edge);
	}
}

Measured memory_bytes: 52736
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        char[][] s = new char[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next().toCharArray();
        }

        // 全ての座標をスタートとしてゴールまでにかかる移動回数の最大を求める
        int result = 0;
        for (int k = 0; k < h; k++) {
            for (int l = 0; l < w; l++) {
                int maxDistance = getDistance(s, k, l);
                result = Math.max(result, maxDistance);
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }

    private static int getDistance(char[][] map, int startY, int startX) {

        // スタート座標が壁の場合0を返す
        if (map[startY][startX] == '#') {
            return 0;
        }

        // 探索対象を設定
        Deque<int[]> todo = new ArrayDeque<>();
        todo.add(new int[] { startY, startX }); // スタート座標を設定

        // 探索済みの座標を移動回数として保持する
        // スタート座標の初期値を1とし、0を未探索の座標と判定する
        int h = map.length;
        int w = map[0].length;
        int[][] distance = new int[h][w];
        distance[startY][startX] = 1; // スタート座標を設定

        // 探索対象の相対座標を設定（上下左右）
        // 探索をforループで実施するために必要となる
        int[] x = new int[] { 0, 0, -1, 1 };
        int[] y = new int[] { -1, 1, 0, 0 };

        // 探索を開始
        int maxDistance = 0; // スタートからゴールまでの移動回数が格納される
        while (!todo.isEmpty()) {

            // 探索元の位置を設定
            int[] point = todo.poll();
            int pointY = point[0];
            int pointX = point[1];

            // 上下左右を探索する
            for (int i = 0; i < 4; i++) {

                // 探索対象の位置
                int nextPointY = pointY + y[i];
                int nextPointX = pointX + x[i];

                // 場外判定
                boolean isOutside = nextPointX < 0 || w <= nextPointX || nextPointY < 0 || h <= nextPointY;
                if (isOutside) {
                    continue;
                }

                // 探索要否を判定
                boolean wasVisit = 0 < distance[nextPointY][nextPointX]; // 探索済み判定
                boolean isWall = map[nextPointY][nextPointX] == '#'; // 壁判定
                if (wasVisit || isWall) {
                    continue;
                }

                // 探索対象に追加
                todo.add(new int[] { nextPointY, nextPointX });
                distance[nextPointY][nextPointX] = distance[pointY][pointX] + 1;
                maxDistance = distance[nextPointY][nextPointX] - 1; // 初期値の1を引く
            }
        }
        return maxDistance;
    }
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int r,d,x; cin >> r >> d >> x;
  rep(i,10){
    x = r*x-d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
ll bg = 10000020930000;
int main()
{ 
	ll t;
	t=1;
	while(t--)
	{
		ll x,y;
		cin>>x>>y;
		if(y%2!=0)
		{
			cout<<"No";
			return 0;
		}
		else
		   y=y/2;
		if(y>=x && y<=2*x)
		    cout<<"Yes"<<endl;
		else
		    cout<<"No"<<endl;		
	}
	return 0;
}

Measured memory_bytes: 3596
n, a, b = map(int, input().split())
total = 0
for i in range(1, n + 1):
    num = 0
    str_i = str(i)
    list_i = list(str_i)
    for j in range(len(list_i)):
        num += int(list_i[j])
    if a <= num and num <= b:
        total += i
print(total)


Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if(a == 0){
  cout << 1;
  return 0;
  }
  if(b == 0){
  cout << 2;
  return 0;
  }
  if(c == 0){
  cout << 3;
  return 0;
  }
  if(d == 0){
  cout << 4;
  return 0;
  }
  if(e == 0){
  cout << 5;
  return 0;
  }
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef vector<ll> vl;
typedef pair<vl,vl> t;

int main(){
	ll a,b,k; cin >> a >> b >> k;
	cout << max(0ll,a-k) << " " << max(0ll,a+b-k-max(0ll,a-k)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

#define all(c) (c).begin(), (c).end()

int solve(int n, int k, int m){
    k--; m--;
    vector<int> stones(n);
    iota(all(stones), 1);
    while(n != 1){
        stones.erase(stones.begin() + m);
        (m += k) %= --n;
    }
    return stones[0];
}

int main(){
    int n, k, m;
    while(cin >> n >> k >> m, n|k|m)cout << solve(n, k, m) << '\n';
    return 0;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    
int a[510][510];

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h,w;
    cin>>h>>w;
    vector<pair<ii,ii>> moves;
    f(h){
        f2(w){
            int x;
            cin>>x;
            a[i][j]+=x;
            if(a[i][j]&1){
                if(j<w-1){
                    ++a[i][j+1];
                    moves.pb({{i+1,j+1},{i+1,j+2}});
                }
                else if(i<h-1){
                    ++a[i+1][j];
                    moves.pb({{i+1,j+1},{i+2,j+1}});
                }
            }
        }
    }
    cout<<sz(moves)<<endl;
    fa(xx,moves) cout<<xx.ff.ff<<" "<<xx.ff.ss<<" "<<xx.ss.ff<<" "<<xx.ss.ss<<endl;
    return 0;
}



Measured memory_bytes: 5232
x1, y1, x2, y2 = map(int, input().split())
vec = (x2 - x1, y2 - y1)

x3, y3 = x2 - vec[1], y2 + vec[0]
x4, y4 = x1 - vec[1], y1 + vec[0]
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll A[200005];
int main()
{
    ll N, T, res = 0;
    cin >> N >> T;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    A[N] = INT_MAX;
    for(int i = 0; i < N; i++){
        res += min(A[i+1] - A[i], T);
    }
    cout << res << "\n";
    return 0;
}


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

#define INF (INT32_MAX)
#define MOD (1000000000+7)
#define MAX 8

int main() {
	int A, B, C;

	cin >> A >> B >> C;

	int ans = 0;
	if( A == B ) {
		if( A == 5 && C == 7 ) {
			ans = 1;
		}
	}
	else if( B == C ) {
		if( B == 5 && A == 7 ) {
			ans = 1;
		}
	}
	else if( C == A ) {
		if( C == 5 && B == 7 ) {
			ans = 1;
		}
	}

	if( ans ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define kuri(i,n) FOR(int i=0;i!=n;i++)

using namespace std;

int main(){
	long long int x,y;
	cin >> x >> y;
	int ans=0;
	while(1){
		x=x*2;
		if(x>y){
			break;
		}
		else{
			ans++;
		}
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 256