akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

string s,t;
cin>>s>>t;
if(t.size()==s.size()+1)
{
  if(t.substr(0,s.size())==s)
  {
    cout<<"Yes";
    return 0;
  }
}
cout<<"No";

    return 0;
  }


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define ll long long
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

ll MOD = 1000000007;
const int MAX = 2000;
lli c[MAX+1][MAX+1];
void makec(lli n){
  c[0][0] = 1;
  FSG(i, 1, n+1){
    F(j, i+1){
      if(j == 0 && j == i){
        c[i][j] = 1;
      }
      else{
        c[i][j] = (c[i-1][j] + c[i-1][j-1])%MOD;
      }
    }
  }
}

int main(){
  int N, K;
  cin >> N >> K;
  makec(MAX);
  F(i, K){
    cout << (c[N-K+1][i+1] * c[K-1][i]) % MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 30080
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        sum += a[i] % MOD;
        sum %= MOD;
    }
    ll res = 0;
    for(int i=0;i<n;i++) {
        sum -= a[i];
        if(sum < 0) sum += MOD; 
        res += (a[i] * sum) % MOD;
        res %= MOD;
    }
    res %= MOD;
    cout << res << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 4760
import java.util.Scanner
import kotlin.math.*

fun main() {
	val scn = Scanner(System.`in`)
	val x = scn.nextLong()
	val k = scn.nextLong()
	val d = scn.nextLong()
	if (k<abs(x)/d) {
		println(abs(x)-(d*k))
	}else {
		val a = abs(x) % d
		val r = (k - abs(x)/d) % 2
		when(r){
			0L -> println(a)
			else -> println(d-a)
		}
	}
}


Measured memory_bytes: 36200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cins(int, 3, a);
    Sort(a);
    //Cout(() ? "Yes" : "No");
    Cout((a[0] == 5 && a[1] == 5 && a[2] == 7) ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	string x;
	bool flg=false;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x=="Y"){
			flg=true;
		}
	}
	cout<<((flg)?"Four":"Three")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    int m = n/100;
    m*=5;
    if(n%100<=m){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = int(input())
    W = list(map(int, input().split()))

    total = []
    for i in range(N):
        t = abs(sum(W[:i]) - sum(W[i:]))
        total.append(t)
    print(min(total))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <string>

using namespace std;

char s[110][110];
int a,b,c;

int main() {
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    cin >> a >> b >> c;
    if (c>=a && c<=b) cout << "Yes" << endl;
     else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
//used segment tree to maintain point set
//0 for ai-d*i, 1 for ai+d*i
//a for visited, b for not
struct SegmentT{
	int l,r;
	int al,ar;
	int bl,br;
	int bestL, bestR;
	SegmentT(){
		l = r = 0;
		al = ar = bl = br = bestL = bestR = -1;
	}
};
SegmentT t[800005];
long long D;
long long a[200005];
int vis[200005];
const long long inf = 1e18+7;

long long getSingle(long long p,long long tag){
	if(p==-1) return inf;
	else return a[p]+tag*D*p;
}

long long getPair(long long l,long long r){
	if(l==-1 || r==-1) return inf;
	else return a[l]+a[r]+D*(r-l);
}

SegmentT merge(SegmentT a, SegmentT b){
	SegmentT res;
	res.l = a.l, res.r = b.r;
	if(getSingle(a.al,-1)<getSingle(b.al,-1)) res.al = a.al;
	else res.al = b.al;
	if(getSingle(a.ar,1)<getSingle(b.ar,1)) res.ar = a.ar;
	else res.ar = b.ar;
	if(getSingle(a.bl,-1)<getSingle(b.bl,-1)) res.bl = a.bl;
	else res.bl = b.bl;
	if(getSingle(a.br,1)<getSingle(b.br,1)) res.br = a.br;
	else res.br = b.br;
	if(getPair(a.bestL,a.bestR)<getPair(b.bestL,b.bestR)) res.bestL = a.bestL, res.bestR = a.bestR;
	else res.bestL = b.bestL, res.bestR = b.bestR;
	if(getPair(a.al,b.br)<getPair(res.bestL,res.bestR)) res.bestL = a.al, res.bestR = b.br;
	if(getPair(a.bl,b.ar)<getPair(res.bestL,res.bestR)) res.bestL = a.bl, res.bestR = b.ar;
	return res;
}

void build(int p,int l,int r){
	t[p].l = l, t[p].r = r;
	if(l==r){
		if(l==1) t[p].al = t[p].ar = l;
		else t[p].bl = t[p].br = l;
	}
	else{
		int m = (l+r)/2;
		build(2*p,l,m);
		build(2*p+1,m+1,r);
		t[p] = merge(t[2*p],t[2*p+1]);
	}
}

void change(int p,int x){
	if(t[p].l==t[p].r){
		t[p].bl = t[p].br = -1;
		t[p].al = t[p].ar = t[p].l;
	}
	else{
		int m = (t[p].l+t[p].r)/2;
		if(x<=m) change(2*p,x);
		else change(2*p+1,x);
		t[p] = merge(t[2*p],t[2*p+1]);
	}
}

int main(){
	int n;
	scanf("%d%lld",&n,&D);
	for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
	build(1,1,n);
	vis[1] = 1;
	long long ans = 0;
	for(int i = 1; i <= n-1; i++){
		int l = t[1].bestL, r = t[1].bestR;
		long long add = getPair(l,r);
		//printf("l = %d, r = %d: %lld\n",l,r,add);
		ans += add;
		if(!vis[l])	change(1,l), vis[l] = 1;
		else change(1,r), vis[r] = 1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 29060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vector<vi> graph(N);
    int X, Y; cin >> X >> Y; X--; Y--; graph[X].pb(Y); graph[Y].pb(X);
    F0R(i, N-1) {
        graph[i].pb(i+1);
        graph[i+1].pb(i);
    }

    int dist[N][N]; F0R(i, N) F0R(j, N) dist[i][j] = -1;
    F0R(root, N) {
        dist[root][root] = 0;
        queue<int> q; q.push(root);
        while(!q.empty()) {
            int cur = q.front(); q.pop();
            F0R(i, sz(graph[cur])) {
                int nxt = graph[cur][i];
                if (dist[root][nxt] == -1) {
                    dist[root][nxt] = dist[root][cur] + 1;
                    q.push(nxt);
                }
            }
        }
    }

    int cnt[N]; F0R(i, N) cnt[i] = 0;
    F0R(i, N) F0R(j, N) cnt[dist[i][j]]++;

    FOR(i, 1, N) {
        cout << cnt[i] / 2 << '\n';
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
char s[200005];

int main(void)
{
	int n; cin >> n;
	scanf("%s", s+1);
	int r = 0;
	vector<int> R(n+1);
	for(int i=1;i<=n;i++) {
		if(s[i] == 'R') r++;
		R[i] = r;
	}
	int mini = 987654321;
	for(int i=0;i<=n;i++) {
		int a = R[i];
		int tmp ;
		if(a==i) {
			tmp= r - a;
		}
		else {
			int t = min(i - a, r - a);
			tmp = r + i - 2 * a - t;
		}
		if(tmp < mini) mini = tmp;
	}
	cout << mini << endl;

	return 0;
}

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

int main(){
    int a[3];
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    cout << a[2]*10 + a[1] +a[0] << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<unordered_map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<memory>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)   a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
void a(){
    ll N; cin >> N;
    auto A = v<>(3*N,0);
    rep(i,3*N) cin >> A[i];
    sort(all(A));
    ll sum =0;
    for(ll i = 1;i<=N;i++){
        sum += A[3*N-2*i];
    }
    cout << sum << endl;
}

int main(){
    a();
}

Measured memory_bytes: 5612
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N+1);
    rep(i,N) cin >> A[i+1];

    vector<int> check,B(N);
    ll val = -1;
    rep(i,N+1) {
        if (chmax(val,A[i])) check.emplace_back(i);
    }
    reverse(all(check));
    auto S = A;
    //vector<pii> S(N);
    //rep(i,N) S[i] = {A[i],i};
    sort(all(S)); reverse(all(S));
    //rep(i,N) B[S[i].second] = i;
    ll cur = 0, cnt = 0;
    vector<ll> ans(N+1);
    rep (i,check.size()-1) {
        if (i > 0) ans[check[i]] += cnt*(A[check[i]] - A[check[i+1]]);
        while (cur <= N && S[cur] > A[check[i+1]]) {
            ans[check[i]] += S[cur] - A[check[i+1]];
            cur++;
            cnt++;
        }
    }
    rep(i,N) cout << ans[i+1] << endl;

}

Measured memory_bytes: 4344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace problem001
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = ReadLine();
			int N = int.Parse(str);
			var S = ReadLine();

			int ans = 0;
			for(int i = 0; i < N - 2; i++)
			{
				if(S.Substring(i,3) == "ABC")
				{
					ans++;
				}
			}
			Write(ans);
		}
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

struct state {
    int x, y, d;
    state(int x, int y, int d) : x(x), y(y), d(d) {}
};

int h, w;
int sx, sy, gx, gy;
char c[1010][1010];
int dist[1010][1010];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main() {
    scanf("%d%d", &h, &w);
    scanf("%d%d%d%d", &sx, &sy, &gx, &gy);
    --sx;
    --sy;
    --gx;
    --gy;
    rep(i, h) rep(j, w) scanf(" %c", &c[i][j]);

    rep(i, h) rep(j, w) dist[i][j] = mod;
    deque<state> dq;
    dist[sx][sy] = 0;
    dq.emplace_back(sx, sy, 0);
    while (!dq.empty()) {
        auto s = dq.front();
        dq.pop_front();
        if (s.d > dist[s.x][s.y]) continue;
        rep(i, 4) {
            int nx = s.x + dx[i], ny = s.y + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && c[nx][ny] == '.') {
                if (chmin(dist[nx][ny], s.d)) {
                    dq.emplace_front(nx, ny, dist[nx][ny]);
                }
            }
        }
        for (int nx = s.x - 2; nx <= s.x + 2; ++nx) {
            for (int ny = s.y - 2; ny <= s.y + 2; ++ny) {
                if (0 <= nx && nx < h && 0 <= ny && ny < w &&
                    c[nx][ny] == '.') {
                    if (chmin(dist[nx][ny], s.d + 1)) {
                        dq.emplace_back(nx, ny, dist[nx][ny]);
                    }
                }
            }
        }
    }

    printf("%d\n", dist[gx][gy] == mod ? -1 : dist[gx][gy]);
}

Measured memory_bytes: 8664
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
A = []
for i in range(H):
    a = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    
ans = []

f = False
route = [0,0,0,0]
tmp = []
l = True

for h in range(H):
    for w in range(W):
        if h % 2 == 1:
            w = W-w-1
        if A[h][w] % 2 != 0:
            if not f:
                route[0],route[1] = h+1,w+1
                f = True
            else:
                route[2],route[3] = h+1,w+1
                tmp.append(route)
                route = [0,0,0,0]
                ans += tmp
                tmp = []
                f = False
        else:
            if f:
                route[2],route[3] = h+1,w+1
                tmp.append(route)
                route = [h+1,w+1,0,0]
print(len(ans))
for a,b,c,d in ans:
    print(a,b,c,d)

Measured memory_bytes: 31200
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    CD = [[int(i) for i in input().split()] for j in range(M)]
    for a, b in AB:
        mi = 10**20
        ans = -1
        for i, p in enumerate(CD):
            d = abs(p[0] - a) + abs(p[1] - b)
            if d < mi:
                mi = d
                ans = i+1
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int count = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        auto pi = s.find(to_string(i));
        if (pi != string::npos) {
          string si = s.substr(pi + 1);
          auto pj = si.find(to_string(j));
          if (pj != string::npos) {
            string sj = si.substr(pj + 1);
            auto pk = sj.find(to_string(k));
            if (pk != string::npos)
              count++;
          }
        }
      }
    }
  }

  cout << count << endl;
  
  return 0;
}

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

int main() {
    int n,a;
    cin >> n >> a;
    if(n%500<=a){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    bool isPrime[55556];
    for(int i=2;i<55556;i++)isPrime[i] = true;
    for(int i=2;i<55556;i++){
        if(isPrime[i]){
            int tmp = i;
            while(tmp+i<55556){
                tmp += i;
                isPrime[tmp] = false;
            }
        }
    }

    for(int i=0;i<55556;i++){
        if(isPrime[i]){
            if(i%5!=1)isPrime[i] = false;
        }
    }

    int j = 2;
    for(int i=0;i<n;i++){
        while(!isPrime[j])j++;
        cout << j << " ";
        j++;
    }
    cout << endl;

}


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

int main (void){
    int h, a;
    double b;
    cin >> h >> a;
    if (h % a == 0) {
        cout << h / a << endl;
    } else {
        cout << h / a + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
/*
??????????????????????????´??° a ??¨ b ??????????????°???????????????????????°?????????????????????????????????
???????????????????????° <= 200
*/

#include <iostream>
#include <string>

using namespace std;
 
int main()
{

	int a, b, calc, strCount = 0;
	string str = "";

	for ( int i = 0; i < 200;  i++ ) {
		a = b = 0;
		
		cin >> a >> b;

		if ( a == 0 && b == 0 ) {
			break;
		}

		calc = a + b;
		str = to_string( calc );
		strCount = str.size();
		
		cout << strCount << endl;
	}

    return 0;
}

Measured memory_bytes: 3240
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let (h, w) = input!(i32, i32);
    let mut s = Vec::<Vec<char>>::with_capacity(h as usize);
    for _ in 0..h {
        s.push(input!(String).chars().collect());
    }

    for i in 0..h {
        for j in 0..w {
            let up_and_down    = [-1, 0, 1, 0];
            let right_and_left = [0, -1, 0, 1];
            if s[i as usize][j as usize] == '.' {
                continue;
            }
            let mut black = false;
            for k in 0..4 {
                if (i as i32) + up_and_down[k] >= 0 && (i as i32) + up_and_down[k] < h {
                    if (j as i32) + right_and_left[k] >= 0 && (j as i32) + right_and_left[k] < w {
                        if s[(i + up_and_down[k]) as usize][(j + right_and_left[k]) as usize] == '#' {
                            black = true;
                        }
                    }
                }
            }
            if !black {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}

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

int main() {
    int N, K, i;
    uint64_t ans = 0, max, min, mod = 1e9+7;
    cin >> N >> K;
    for(i=K; i<=N+1; i++) {
        ans += ((uint64_t)N-i+1)*i+1;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;
class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int b = sc.nextInt();
        int ret = s - b * 2 < 0 ? 0 : s - b * 2; 
        System.out.println(ret);
        sc.close();
    }
}



Measured memory_bytes: 21844
#include <cstdio>

int main()
{
    int n, b, f, r, v;
    int count[4][3][10];

    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                count[i][j][k] = 0;
            }
        }
    }

    scanf("%d", &n);
    
    for(int i = 0; i < n; i++){
        scanf(" %d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1] += v;
    }
    
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 10; k++){
                if (k != 9){
                    printf(" %d", count[i][j][k]);
                }
                else {
                    printf(" %d\n", count[i][j][k]);
                }
            }
        }
        if (i != 3){
            printf("####################\n");
        }
    }

    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	int n=  s.length();
	for(int i = 0;i < n;i++){
		ans += s[i]-'0';
		ans %= 9;
	}
	if(ans == 0) cout<<"Yes";
	else cout<<"No";
}

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

int dp[11][10][2]; // dp[i][j][k]: i桁まで計算、j回忘れた、直前borrowならk=1
int main() {
	int a;
	int b;
	int k;
	cin >> a >> b >> k;
	
	for(int i = 0; i < 11; i++) {
		for(int j = 0; j < 10; j++) {
			dp[i][j][0] = dp[i][j][1] = -1;
		}
	}
	dp[0][0][0] = a;
	int a2 = a;
	int b2 = b;
	int keta = 1;
	int i;
	for(i = 0; b2 > 0 || a2 > 0; i++) {
//	cout << i << endl;
		int subb = b2 % 10;
		for(int j = 0; j <= k; j++) {
			for(int l = 0; l < 2; l++) {
				if (dp[i][j][l] > 0) {
//					cout << "dp[]" <<  i << j <<"," <<l<< ":"<< dp[i][j][l]<<endl;
					int suba = dp[i][j][l] / keta % 10;
					int diff = suba - subb - l;
					if(diff >= 0) {
						dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l] - (subb + l) * keta);
					}
					else {
						if (j != k) dp[i+1][j+1][0] = max(dp[i+1][j+1][0], dp[i][j][l] + (10 - subb - l) * keta);
						dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][l] + (10 - subb - l) * keta);
					}
				}
			}
		}
		a2 /= 10;
		b2 /= 10;
		keta *= 10;
	}
	int maxn = 0;
	for(int j = 0; j <= k; j++) {
		maxn = max(maxn, dp[i][j][0]);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
typedef long long ll;

int main(int argc, char** argv) {
	ll x, y;
	cin>>x>>y;
	int cnt = 1;
	x = x * 2;
	while(x <= y) {
		if(x < 0)break;
		cnt ++;
		x = x * 2;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let mut S = scan.list::<String>(N);

    S.sort();
    S.dedup();

    println!("{}", S.len());
}


Measured memory_bytes: 20992
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
signed main()
{
	lint n = in(), m = in();
	vector<lint>sum_mod(n + 1);
	sum_mod[1] = in() % m;
	for (lint i = 2; i <= n; i++)
	{
		scanf("%d", &sum_mod[i]);
		sum_mod[i] += sum_mod[i - 1];
		sum_mod[i] %= m;
	}
	map<lint, lint>mod_num;
	REPC(i, sum_mod)++mod_num[i];
	lint ans = 0;
	REPC(i, mod_num)ans += i.second * (i.second - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    a,b,c = map(int,input().split())
    if c <= a + b:
        print(b + c)
    else:
        print(a + 2*b + 1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	int res = 0;
	FOR(a, 1, n) {
		int ost = a % 10;
		int pom = a;
		int pier = -1;
		while (pom) {
			pier = pom % 10;
			pom /= 10;
		}
		// printf("a: %d, pier: %d, ost: %d\n", a, pier, ost);
		if (ost == 0 || pier == 0) {
			continue ;
		}
		// pier...ost
		if (pier == ost) {
			// consider 1 element
			// printf("adding: %d,%d\n", a, a);
			++res;
		}
		// int dl = 0;
		int mnoznik = 10;
		bool big = false;
		while (!big) {
			// pom..ost
			int nowa = ost * mnoznik + pier;
			REP(wew, mnoznik/10 ) {
				int b = nowa + wew * 10;
				if (b <= n) {
					// printf("adding: %d, %d\n", a, b);
					++res;
				} else {
					big = true;
					break;
				}
			}
			mnoznik *= 10;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func main() {
	var A, B, C, X, Y int
	fmt.Scan(&A, &B, &C, &X, &Y)

	ans := 0
	if C*2 <= A+B {
		m := min(X, Y)
		ans = (C * 2) * m
		X -= m
		Y -= m
	}

	ans += min(A*X, C*2*X)
	ans += min(B*Y, C*2*Y)

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
import string

S = input()

alphabet = string.ascii_lowercase

def least_char_notin(s):
    for c in alphabet:
        if c not in s:
            return c
    return None

def next_char(c):
    return chr(ord(c)+1)

def is_diverse(s):
    if len(s) == len(set(s)):
        return True
    return False

def next_diverse(s):
    if len(s) < 26:
        return s + least_char_notin(s)
    else:
        for i in range(1,len(s)+1):
            c = s[-i]
            prefix = s[:-i]
            d = next_char(c)
            while d in alphabet:
                if is_diverse(prefix + d):
                    return prefix + d
                d = next_char(d)
        return -1

print(next_diverse(S))

Measured memory_bytes: 3768
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int h[n], cnt = 0, ans = 0;
  scanf("%d", h);
  for (size_t i = 1; i < n; i++) {
    scanf("%d", h+i);
    if (h[i]<=h[i-1]) {
      cnt++;
      ans = (ans < cnt) ? cnt : ans;
    }else {
      cnt = 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IOS                      \
	ios::sync_with_stdio(false); \
	cin.tie(0)

// *start on @date: 2020-02-16 20:14

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

int main()
{
	IOS;
	int n, a, flag = 0;
	cin >> n;
	while (n--)
	{
		cin >> a;
		if (a % 2 == 0)
			if (!(a % 3 == 0 || a % 5 == 0))
				flag = 1;
	}
	if (flag)
		cout << "DENIED" << endl;
	else
		cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 200002
mt19937 myrand(time(0));

ll n,m,cur;
vector<ll> adj[mx];
bool vis[mx];

void dfs(ll u){
    if(vis[u]) return;
    vis[u]=1;
    cur++;
    for(auto& v:adj[u]){
        if(!vis[v]) dfs(v);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    cin>>n>>m;
    for(int i=0;i<m;i++){
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            cur=0;
            dfs(i);
            ans=max(ans,cur);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 21052
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;
// c++14 (atcoder環境)だとtupleは普通に動く


int count_area(map<tuple<int, int>, int> table, int a, int b){
    int count_n = 0;
    for(int j=-1; j<=1; ++j){
        for(int k=-1; k<=1; ++k){
            count_n += table[make_tuple(a+j,b+k)];
        }
    }
    return count_n;
}

int main()
{    
    unsigned long long h, w, n;
    cin >> h >> w >> n;
    // h = 4, w = 5, n = 8;
    // h = 1000000000, w = 1000000000, n = 0;


    int a[n], b[n];
    for(int i=0; i<n; ++i){
        cin >> a[i] >> b[i];
    }
    // a[0] = 1, b[0] = 1;
    // a[1] = 1, b[1] = 4;
    // a[2] = 1, b[2] = 5;
    // a[3] = 2, b[3] = 3;
    // a[4] = 3, b[4] = 1;
    // a[5] = 3, b[5] = 2;
    // a[6] = 3, b[6] = 4;
    // a[7] = 4, b[7] = 4;

    // map : 2つのキーを持つ
    map<tuple<int, int>, int> table;
    map<tuple<int, int>, int> count_table;
    int ans[10];
    for(int i=0; i<10; ++i) ans[i] = 0;
    // mapに0, 1を塗る
    for(int i=0; i<n; ++i){
        for(int j=-2; j<=2; ++j){
            for(int k=-2; k<=2; ++k){
                table[make_tuple(a[i]+j, b[i]+k)] = 0;
            }
        }
    }
    for(int i=0; i<n; ++i){
        table[make_tuple(a[i], b[i])] = 1;
    }    
    // 探索
    for(int i=0; i<n; ++i){
        for(int j=-1; j<=1; ++j){
            for(int k=-1; k<=1; ++k){
                // 端の場合処理は不要
                if (a[i]+j > 1 && a[i]+j < h && b[i]+k > 1 && b[i]+k < w){
                    // 作り直し
                    int count_n = 0;
                    for(int l=-1; l<=1; ++l){
                        for(int m=-1; m<=1; ++m){
                            count_n += table[make_tuple(a[i]+j+l,b[i]+k+m)];
                        }
                    }
                    count_table[make_tuple(a[i]+j, b[i]+k)] = count_n;
                    // count_table[make_tuple(a[i]+j, b[i]+k)] = count_area(table, a[i]+j, b[i]+k);
                }
            }
        }
    }
    // map内の全探索
    for(auto itr = count_table.begin(); itr != count_table.end(); ++itr){
        // cout << itr->first << endl; // tupleの時これが使用できない?
        ans[itr->second]++;
    }

    // 0のカウントは全パターンから引けばいい
    unsigned long long ans_0 = (h-2)*(w-2);

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

    return 0;
}

Measured memory_bytes: 213504
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

size_t N;
vector<int64_t> a, b, c;

auto dp = make_v(-1LL, int(1e5) + 10, 4);

int64_t rec(size_t idx, int yesterday) {
    if (idx >= N) return 0;
    if (~dp[idx][yesterday]) return dp[idx][yesterday];

    int64_t ret = 0;
    if (yesterday != 0) chmax(ret, rec(idx + 1, 0) + a[idx]);
    if (yesterday != 1) chmax(ret, rec(idx + 1, 1) + b[idx]);
    if (yesterday != 2) chmax(ret, rec(idx + 1, 2) + c[idx]);

    return dp[idx][yesterday] = ret;
}

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

    cin >> N;
    a.resize(N), b.resize(N), c.resize(N);

    for (size_t i = 0; i < N; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }

    cout << rec(0, 3) << "\n";

    return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n,m;
int h[100005],dp[100005];
int main()
{
	scanf("%d",&n);
	memset(dp,64,sizeof dp);
	dp[1]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
		if(i>1) dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));		
		if(i>2) dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	printf("%d",dp[n]);
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string S;
    int length, x = 0;

    cin >> S;

    length = S.length();

    for(int i = 0; i < length/2; i++){
        if(S[i] != S[length-1-i]) x++;
    }

    cout << x << endl;

    return 0;
}

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

char S[100001];
char *tbl[] = { "dream","erase","dreamer","eraser" };
int Len[] = {5,5,7,6};

int main(void)
{
	int len;
	int i;

	scanf("%s",S);
	len = strlen(S);

	while (len > 0) {
		for (i = 0; i < 4; i++) {
			if (len >= Len[i] && strcmp(tbl[i], &S[len - Len[i]]) == 0) {
				S[len - Len[i]] = '\0';
				break;
			}
		}
		if (i == 4) {
			printf("NO\n");
			return 0;
		}
		len -= Len[i];
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::{HashSet, HashMap, BinaryHeap};

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        k: isize,
        t: usize,
        a: [isize; t],
    }
    let x = a.iter().max().unwrap();
    let ans = max(x - (k - x) - 1, 0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

main(){
  int data[4][2];
  int i, j;
  double in1, in2;
  for(i=0;i<4;i++){
    for(j=0;j<2;j++){
      data[i][j]=0;
    }
  }
  while(1){
    if(scanf("%lf %lf", &in1, &in2)==EOF) break;
    if(in1>=1.1) data[0][0]++;
    else if(in1>=0.6) data[1][0]++;
    else if(in1>=0.2) data[2][0]++;
    else data[3][0]++;
    if(in2>=1.1) data[0][1]++;
    else if(in2>=0.6) data[1][1]++;
    else if(in2>=0.2) data[2][1]++;
    else data[3][1]++;
  }
  for(i=0;i<4;i++){
    printf("%d %d\n", data[i][0], data[i][1]);
  }
  return 0;
}

Measured memory_bytes: 0