akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;


int n;
int a, b, c;
int l[10];
int dfs(int now, int sa, int sb, int sc) {
	if (now == n) {
		if (min({sa, sb, sc}) > 0)return abs(sa - a) + abs(sb - b) + abs(sc - c) - 30;
		else return INF;
	}
	int res0 = dfs(now + 1, sa, sb, sc);
	int res1 = dfs(now + 1, sa + l[now], sb, sc) + 10;
	int res2 = dfs(now + 1, sa, sb + l[now], sc) + 10;
	int res3 = dfs(now + 1, sa, sb, sc + l[now]) + 10;
	return min({ res0, res1, res2, res3 });
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b >> c;
	rep(i, n)cin >> l[i];
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}


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

using namespace std;

template <class T> using V = vector<T>;

const int INF = 1e9;
struct R {
    int l, r;
    void ins(const R &p) {
        l = max(l, p.l);
        r = min(r, p.r);
    }
    bool inside(int x) { return l <= x && x <= r; }
    bool any() const { return r >= INF; }
    bool empty() const { return l > r; }
    void deb() const { fprintf(stderr, "[%d, %d]\n", l, r); }
};

const int MN = 123456;
int n, k;
int a[MN];
bool used[MN];
V<int> g[MN];
R rng[MN];

void imp() {
    puts("No");
    exit(0);
}

void dfs1(int v, int p) {
    if (!used[v]) {
        rng[v] = R{-INF, INF};
    } else {
        rng[v] = R{a[v], a[v]};
    }
    for (int u: g[v]) {
        if (u == p) continue;
        dfs1(u, v);
        if (!rng[v].any() && !rng[u].any() && abs(rng[v].l - rng[u].l) % 2 == 0) imp();
        rng[v].ins(R{rng[u].l - 1, rng[u].r + 1});
    }
    // rng[v].deb();
    if (rng[v].empty()) imp();
//    assert((rng[v].r - rng[v].l) % 2 == 0);
}

void dfs2(int v, int p) {
    if (p == -1) {
        a[v] = rng[v].l;
    }
    for (int u: g[v]) {
        if (u == p) continue;
        a[u] = (rng[u].inside(a[v] - 1)) ? a[v] - 1 : a[v] + 1;
        dfs2(u, v);
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
        int x, c;
        scanf("%d %d", &x, &c); x--;
        a[x] = c;
        used[x] = true;
    }
    dfs1(0, -1);
    dfs2(0, -1);

    puts("Yes");
    for (int i = 0; i < n; i++) {
        printf("%d\n", a[i]);
    }
    return 0;
}

Measured memory_bytes: 16000
#!/usr/bin/env python3
import sys
import numpy as np


def solve(a: int):
    print(a+a**2+a**3)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    solve(a)

if __name__ == '__main__':
    main()


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

using namespace std;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int N, M;
int A[1005], B[1005];
int C[1005][15];

int main() {
  const int INF = 1e9;

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    for (int j = 0; j < B[i]; j++) {
      cin >> C[i][j];
    }
  }

  vector<vector<int>> dp(1005, vector<int>(5000, INF));
  for (int i = 0; i <= M; i++) {
    dp[i][0] = 0;
  }
  for (int i = 0; i < M; i++) {
    int key = 0;
    for (int j = 0; j < B[i]; j++) {
      key |= (1 << (C[i][j] - 1));
    }
    for (int bits = 0; bits < (1 << N); bits++) {
      chmin(dp[i + 1][bits], dp[i][bits]);
      chmin(dp[i + 1][bits | key], dp[i][bits] + A[i]);
    }
  }
  int ans = dp[M][(1 << N) - 1];
  if (ans == INF) {
    ans = -1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19968
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}
static const ll INF = 1e18;

int main() {
  double a, b; cin >> a >> b;
  double h, m; cin >> h >> m;

  double angle =M_PI * abs(60 * h - 11 * m) / 360;
  double ans = sqrt(a*a + b * b - 2 * a * b *cos(angle));
  printf("%.12f\n", ans);
}


Measured memory_bytes: 4164
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define amen ;
#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;

const int maxn = 1e6 + 12, mod = 1e9 + 7;

int dp[maxn][13];

 main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    for (int i = 0; i < 1; i++)
        dp[0][i] = 1;
    for (int i = 1; i <= len(s); i++)
    {
        if (s[i-1] == '?')
        {
            for (int now = 0; now < 10; now++)
            {
                for (int last = 0; last < 13; last++)
                {
                    dp[i][(last * 10 + now) % 13] += dp[i-1][last];
                    dp[i][(last * 10 + now) % 13] %= mod;
                }
            }
        }
        else
        {
            int x = s[i-1] - '0';
            for (int last = 0; last < 13; last++)
            {
                dp[i][(last * 10 + x) % 13] += dp[i-1][last];
                dp[i][(last * 10 + x) % 13] %= mod;
            }
        }
    }
    cout << dp[len(s)][5];
    return 0;
}

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

int ar[100005];
int32_t main(){
	int n;cin>>n;
	int cur = 0;
	int tot = 0;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		tot += abs(cur-ar[i]);
		cur = ar[i];
	}
	tot += abs(cur);
	cur = 0;
	for(int i=1;i<=n;i++){
		cout<<tot-(abs(ar[i-1]-ar[i])+abs(ar[i]-ar[i+1]))+abs(ar[i-1]-ar[i+1])<<"\n";
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int K,A,B;
  cin>>K>>A>>B;

  bool flag=false;
  for(int i=1;K*i<=B;i++){
    if(K*i>=A){
      flag=true;
    }
  }
  if(flag){
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }
}


Measured memory_bytes: 3636
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

ll gcd(ll x, ll y) {
    if (x < y) {
        x ^= y;
        y ^= x;
        x ^= y;
    }
    return y ? gcd(y, x%y) : x;
}

void solve() {
    ll n; cin >> n;
    ll res = 0;
    FOR(i, 0, n) {
        ll tmp; cin >> tmp;
        res = gcd(res, tmp);
    }
    cout << res;
}

signed main() {
    solve();
    return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    dp[0][0] = 0;
    for (int i=0;i<N;i++){
        for (int j=0;j<=W;j++){
            if (j+w[i]<=W){
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]],dp[i][j] + v[i]);
            }
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[N][W] << "\n";
}

Measured memory_bytes: 80256
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int a[]=new int[N];
    int t[]=new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
      t[a[i]-1]=i;
    }
    for(int i=0;i<N;i++){
      System.out.println(t[i]+1);
    }

  }
}

Measured memory_bytes: 67080
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
}r[105],b[105];
int n;
bool cmp(node x, node y)
{
    if(x.x==y.x)
        return x.y<y.y;
    return x.x<y.x;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>r[i].x>>r[i].y;
    for(int i=0;i<n;i++)
        cin>>b[i].x>>b[i].y;
    sort(r,r+n,cmp);
    sort(b,b+n,cmp);
    int c[105];
    memset(c,0,sizeof(c));
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int max1=-1;int z=-1;
        for(int j=0;j<n;j++)
        {
            if(!c[j]&&r[j].x<b[i].x&&r[j].y<b[i].y&&r[j].y>max1)
            {
                max1=r[j].y;
                z=j;
            }

        }
        if(max1!=-1)
        {
            c[z]=1;
            ans++;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

int main(void) {
    int N; cin >> N;
    long long nowp = 1;
    for (int i = 0; i < N; i++) {
        (nowp *= (i + 1)) %= MOD;
    }
    cout << nowp << endl;
}


Measured memory_bytes: 256
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int a[maxn];
int Xiaobo()
{
	int n;
	cin>>n;
	int flag=1;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) {
		if(a[i]%2==0) {
			if(a[i]%3&&a[i]%5) {
				flag=0;
				break;
			} 
		}
	}
	if(flag) puts("APPROVED");
	else puts("DENIED");
	return 0;
}


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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int k=1000-(n%1000);
  if(n%1000==0){
    cout << 0 << endl;
  }
  
  else if(n%1000!=0){
    cout << k << endl;
  }

  return 0;

}

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

using namespace std;

int main() {
    string s;
    long long int k;

    cin >> s;
    scanf("%lld", &k);

    for(long long int i = 0; i < k; i++) {
        if(s[i] != '1' || i == k - 1) {
            printf("%c\n", s[i]);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

#define MOD ((lli)(1000000007))

char s[200005];
int main(void){
	int n;
	scanf("%d%s",&n,s);
	lli ans=1;
	int en=0;
	rep(i,n*2){
		if((en%2==0) == (s[i]=='W')){
			if(en<=0){
				puts("0");
				return 0;
			}
			else{
				ans=(ans*en)%MOD;
				en--;
			}
		}
		else en++;
		//printf("%d %d\n",i,en);
	}
	if(en>0){
		puts("0");
		return 0;
	}
	//printf("%lld %d\n",ans);
	reg(i,1,n){
		ans = (ans*i)%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t h, w;
  cin >> h >> w;
  
  vector<vector<bool>> odds(h, vector<bool>(w));
  for (auto i : irange(0L, h)) {
    for (auto j : irange(0L, w)) {
      int64_t a;
      cin >> a;
      odds[i][j] = (a % 2 > 0);
    }
  }

  bool flag = false;
  vector<vector<pair<int64_t, int64_t>>> ans;
  for (auto i : irange(0L, h)) {
    if (i % 2 == 0) {
      for (auto j : irange(0L, w)) {
        if (flag) {
          ans.back().emplace_back(i + 1, j + 1);
        }
        
        if (odds[i][j]) {
          flag = !flag;
          if (flag) {
            ans.resize(ans.size() + 1);
            ans.back().emplace_back(i + 1, j + 1);
          }
        }
      }
    } else {
      for (auto j : irange(0L, w) | reversed) {
        if (flag) {
          ans.back().emplace_back(i + 1, j + 1);
        }
        
        if (odds[i][j]) {
          flag = !flag;
          if (flag) {
            ans.resize(ans.size() + 1);
            ans.back().emplace_back(i + 1, j + 1);
          }
        }
      }
    }
  }
  
  if (flag) {
    ans.pop_back();
  }
  
  cout << accumulate(ans.begin(), ans.end(), 0, [](int64_t acc, const auto& p) { return acc + p.size() - 1; }) << endl;
  for (const auto& p : ans) {
    auto prev = p.front();
    for (auto pp : p | sliced(1, p.size())) {
      cout << prev.first << " " << prev.second << " " << pp.first << " " << pp.second << "\n";
      prev = pp;
    }
  }
}


Measured memory_bytes: 10928
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <numeric>
#include <functional>

using namespace std;

const int mod = 1000000007;

map<vector<int>, long long> dp[42];

int n;
int x, y, z;
int cond[3];
long long rec(int len, const vector<int> &last)
{
  int s = 0;

  int stage = 2;
  int stagesum = 0;
  for (int i = last.size(); i-- > 0;) {
    stagesum += last[i];
    if (stagesum > cond[stage])
      break;
    if (stagesum == cond[stage]) {
      stage--;
      stagesum = 0;
      if (stage < 0)
        return 0;
    }
  }
  if (len == n)
    return 1;
  int sum = accumulate(last.begin() + s, last.end(), 0);
  while (s < last.size())
  {
    if (sum >= x + y + z)
    {
      sum -= last[s];
      s++;
      continue;
    }
    int stage = 0;
    int stagesum = 0;
    bool ok = false;
    for (int i = s; i < last.size(); i++) {
      stagesum += last[i];
      if (stagesum > cond[stage]) {
        ok = true;
        s++;
        break;
      }
      if (stagesum == cond[stage]) {
        stagesum = 0;
        stage++;
      }
    }
    if (ok) continue;

    break;
  }
  vector<int> cur(last.begin() + s, last.end());
  if (dp[len].count(cur))
    return dp[len][cur];
  long long ans = 0;
  cur.push_back(0);
  for (int i = 1; i <= 10; i++) {
    cur.back() = i;
    ans += rec(len + 1, cur);
    ans %= mod;
  }
  cur.pop_back();
  dp[len][cur] = ans;
  return ans;
}

int main()
{
  scanf("%d%d%d%d", &n, &x, &y, &z);
  cond[0] = x;
  cond[1] = y;
  cond[2] = z;
  long long ans = -rec(0, vector<int>());
  long long p10 = 1;
  for (int i = 0; i < n; i++) p10 = p10 * 10 % mod;
  ans += p10;
  ans %= mod;
  ans += mod;
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 68608
#include <vector>
#include <iostream>
#include <complex>
#include <cstdio>

#define pb push_back
#define fs first
#define sc second

using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef pair<P, D> C;
const D EPS=1e-12;


namespace std{
  bool operator<(const P &a, const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

P unit(P p){ return p / abs(p);}

D dot(P x, P y){return real(conj(x)*y);}

D cross(P x, P y){return imag(conj(x)*y);}

P rotate(P v, double s){
  return P(real(v)*cos(s) - imag(v) * sin(s), real(v)*sin(s) + imag(v) * cos(s));
}

D arg(P a, P b, P c){ return acos(dot(b-a, c-a)/(abs(b-a)*abs(c-a)));}
D arg(D a, D b, D c){return acos((b*b+c*c-a*a)/(2*b*c));}

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < -EPS) return 2;
  if(abs(b) < abs(c)) return -2;
  return 0;
}

bool para(L a, L b){return abs(cross(a.fs - a.sc, b.fs-b.sc))<EPS;}

vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  D s = arg(b.sc, abs(b.fs -a.fs), a.sc);
  P x = a.sc * unit(b.fs - a.fs);
  v.pb(a.fs + rotate(x, s));
  v.pb(a.fs + rotate(x, -s));
  return v;
}

int main(){
  D x1, y1, x2, y2, xq, yq;
  while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)){
    P A = P(x1, y1);
    P B = P(x2, y2);
    P Q = P(xq, yq);
    D aq = abs(A-Q);
    D bq = abs(B-Q);
    vector<P> v = cp_cir_to_cir(C(A, aq), C(B, bq));
    if(abs(v[0] - Q) < EPS){
      printf("%.10lf %.10lf\n",  real(v[1]), imag(v[1]));
    }else{
      printf("%.10lf %.10lf\n",  real(v[0]), imag(v[0]));      
    }
  }
  return 0;
}





Measured memory_bytes: 3460
#include<stdio.h>
#include<string.h>
int main()
{
    char w[102];
    scanf("%s", w);
    int i;
    int n[30] = {};
    for (i = 0; i < strlen(w); i++)
        n[(int)(w[i] - 'a')] ++;
    for (i = 0; i < 30; i++)
        if (n[i] % 2 == 1)
        {
            printf("No\n");
            return 0;
        }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,k,nx[10][200005],a[200005];
int main(void){
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<10;i++)nx[i][n+1]=n+1;
    for(int i=n;i>=0;i--){
        for(int j=1;j<10;j++)nx[j][i]=nx[j][i+1];
        if(i<n)nx[a[i+1]][i]=i+1;
    }
    int p=0;
    while(n-p>k){
        for(int i=9;i>0;i--){
            if(nx[i][p]-p-1<=k){
                k-=(nx[i][p]-p-1);
                p=nx[i][p];
                break;
            }
        }
        if(p>n)break;
        cout<<a[p];
    }
    cout<<endl;
}



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

int main() {
	
	int a, b, c;

	cin >> a >> b >> c;
	if (a == b and b == c and a == c) {
		if (a + b > c and a + c > b and b + c > a)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        loop: while(true){
            int h = sc.nextInt(),w = sc.nextInt();
            if(w == 0 && h == 0) break loop;
            for(int i = 0;i < h;i++){
                for(int j = 0;j < w;j++){
                    if(i % 2 == 0) System.out.print(j % 2 == 0 ? "#" : ".");
                    else System.out.print(j % 2 == 0 ? "." : "#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}

Measured memory_bytes: 33236
'use strict'
const main = input => {
  const first = input[0].split(' ').map(val => parseInt(val, 10)), n = first[0], k = first[1], h = input[1].split(' ').map(val => parseInt(val, 10));
  // console.log(n, k, h);
  const ans = h.filter(number => number >= k);
  console.log(ans.length);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 28480
a, b, c = input().split()
a, b, c = int(a), int(b), int(c)

ans = 0

if a == b:
  ans += 1
if b == c:
  ans += 1
if c == a:
  ans += 1

if ans ==1:
  print("Yes")
else:
  print("No")

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int a,b,x;

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

	cin>>x>>a>>b;
	x-=a;
	cout<<x-(x/b)*b<<endl;

	return 0;
}


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

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var input = t.ReadInputOneLine();
            Console.WriteLine(input * 2 * 3.14);
        }


        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 18588
import sys


def input():
    return sys.stdin.readline()[:-1]


N, Q = map(int, input().split())

tree = {}
for i in range(1, N + 1):
    tree[i] = []
for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a] += [b]

count = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input().split())
    count[p] += x

stack = [1]
while stack:
    label = stack.pop()
    if tree.get(label):
        for next_label in tree[label]:
            count[next_label] += count[label]
        stack += tree[label]

ans = count[1:]
print(*ans)


Measured memory_bytes: 66524
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



//monoid,結合律が成り立ち,単位元が存在するものに対しての演算をクエリに対してO(logn)で
//1-indexed  n(親)->2n,2n+1(子)  k(子)->k/2(親)
//木が1-indexedだけど要素アクセスはseg[0]~seg[n-1]だよ
template< typename Monoid >
struct SegmentTree {
    //monoid型の2数を受け取りmonoidの型の値を返すような関数がF
  using F = function< Monoid(Monoid, Monoid) >;
  //sz:size->完全二分木なのでszはnよりも大きい最小の2のべき乗数
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
  /*宣言は
  int f(int a,int b){return min(a,b);}
  SegmentTree< int > seg(N, f, INT_MAX);
  のようにする。1引数目は要素数、2引数目は関数、3引数目は演算fの単位元
  fは2区間をマージする関数、RMQなら親は子の最小値なのでfは2数の最小値を返す関数
   */
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {

    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
 //setしてbuildするのかな
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
 
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
 //親へとさかのぼって更新し続ける
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    //for(;k>0;k=k>>1)と同義
    //これ最初のseg[k]の式に入るときにはkは一回k>>1されてる
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 //query聞くときは区間は[a,b)で(a<=x<b)
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    //>>1は/2だから子への遷移
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
 //szは木のサイズなのでこうすることで普通に配列の要素へのアクセスができる。
 //しかし親も更新しなきゃいけないから値変えるときはupdateでやりなさい
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};


ll f(ll a,ll b){if(a>b) return b;else return a;}
int main()
{
    int n;ll x;
    cin>>n>>x;
    SegmentTree<ll> seg(2*n, f, LINF);
    ll a[n];
    rep(i,n) cin>>a[i];
    rep(i,n) seg.set(i,a[i]);
    rep(i,n) seg.set(i+n,a[i]);
    seg.build();
    //魔法を放つ回数をkで固定
    ll ans=LINF;
    rep(k,n){
        ll tmp=x*k;
        rep(i,n){
            tmp+=seg.query(i,i+k+1);
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){

    vector<int> A;
    int K, temp;
    for(int i = 0; i < 3; i++){
        cin >> temp;
        A.push_back(temp);
    }
    cin >> K;
    
    sort(A.begin(), A.end());
    int sum = A[0] + A[1] + A[2] * pow(2, K);
    cout << sum << endl;
    
}





Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] arr = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }
        for (int i = 1; i < n; i++) {
            arr[i][0] += Math.max(arr[i-1][1],arr[i-1][2]);
            arr[i][1] += Math.max(arr[i-1][0],arr[i-1][2]);
            arr[i][2] += Math.max(arr[i-1][1],arr[i-1][0]);
        }
        System.out.println(Math.max(Math.max(arr[n-1][0],arr[n-1][1]),arr[n-1][2]));
    }
}


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

using namespace std;

int n, a, b, c;
vector <int> p, q;

void generate(vector <int> permutation, vector <int> taken)
{
    if (permutation.size() == n) 
    {
        c++;

        if (permutation == p)
            a = c;
        if (permutation == q)
            b = c;

        // for (int a: permutation)
        // {
        //     cout << a << " ";
        // }

        // cout << "\n";

        return;
    }

    for (int i = 1; i <= n; i++)
    {
        if (taken[i])
            continue;

        taken[i] = true;
        permutation.push_back(i);
        generate(permutation, taken);
        permutation.pop_back();
        taken[i] = false;
    }
}

int main()
{
    cin >> n;

    p.assign(n, 0);
    q.assign(n, 0);

    for (int i = 0; i < n; i++)
        cin >> p[i];

    for (int i = 0; i < n; i++)
        cin >> q[i];

    vector <int> permutation, taken;

    a = b = c = 0;

    taken.assign(n+1, 0);

    generate(permutation, taken);

    cout << abs(a - b) << "\n";

    return 0;
}

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

int main() {
    vector<int> a(3);
    for(int &x : a){
        cin >> x;
    }
sort(a.begin(), a.end());
cout << a.at(0) << " " << a.at(1) << " " << a.at(2) << endl;
    
  return 0;
}



Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
	int c[6];
	int goukei;
	
	scanf("%d %d %d %d %d %d", &c[0], &c[1], &c[2], &c[3], &c[4], &c[5]);
	
	goukei = c[0] + c[1] * 5 + c[2] * 10 + c[3] * 50 + c[4] * 100 + c[5] * 500;
	
	if (goukei >= 1000){
		printf("1\n");
	}
	else {
		printf("0\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
n = gets.to_i
slimes = [-1, *gets.split.map(&:to_i), -1]

color = 10000
count = 0

(1..n).each do |i|
  if slimes[i - 1] == slimes[i] && slimes[i] == slimes[i + 1]
    slimes[i] = color
    count += 1
    color -= 1
  end
end

(1..n).each do |i|
  if slimes[i - 1] == slimes[i] || slimes[i] == slimes[i + 1]
    slimes[i] = color
    count += 1
    color -= 1
  end
end

puts count




Measured memory_bytes: 3836
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var maxProfit = -2000000000 // 十分小さい値
    var minValue = readLine()!!.toInt()

    for (i in 0 until n - 1) {
        val value = readLine()!!.toInt()
        maxProfit = when {
            maxProfit < value - minValue -> value - minValue
            else -> maxProfit
        }
        minValue = when {
            minValue < value -> minValue
            else -> value
        }
    }
    println(maxProfit)
}


Measured memory_bytes: 44836
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int nMax=2100, MOD=1e9+7;
ULL inv[nMax], fct[nMax], ivf[nMax];
ULL Comb(int n, int r){ return (((fct[n]*ivf[r])%MOD)*ivf[n-r])%MOD; }

int main(){
inv[1]=fct[0]=fct[1]=ivf[0]=ivf[1]=1;
for(int i=2; i<nMax; i++){ 
  inv[i]=((MOD-MOD/i)*inv[MOD%i])%MOD;
  fct[i]=(fct[i-1]*i)%MOD; ivf[i]=(ivf[i-1]*inv[i])%MOD;
}
long S, ans=0; cin >> S;
for(int i=1; S-3*i>=0; i++){ ans=(ans+Comb(S-2*i-1, i-1))%MOD; }
cout << ans << "\n";
}

Measured memory_bytes: 3680
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
typedef long long ll;
int main(){
    ll N;
    scanf("%lld",&N);
    char ans[100];
    ll num=0;
    while(N){
       if(N%26 == 0)ans[num] = 'z'; 
       else ans[num] = 'a' + N % 26 - 1;
       N--;
       N /= 26;
       num++;
    }
    for(ll i=num-1;i>=0;i--)
        printf("%c",ans[i]);
}


Measured memory_bytes: 1660
n = int(input())
a = list(map(int, input().split()))
con = 0
var = 0
count = [1, 1, 1, 1, 1, 1, 1, 1]

for i in a:
    if(i < 400):
        con += count[0]
        count[0] = 0
    elif(i < 800):
        con += count[1]
        count[1] = 0
    elif(i < 1200):
        con += count[2]
        count[2] = 0
    elif(i < 1600):
        con += count[3]
        count[3] = 0
    elif(i < 2000):
        con += count[4]
        count[4] = 0
    elif(i < 2400):
        con += count[5]
        count[5] = 0
    elif(i < 2800):
        con += count[6]
        count[6] = 0
    elif(i < 3200):
        con += count[7]
        count[7] = 0
    else:
        var += 1

if(con > 0):
    print(con, con+var)
else:
    print(1, var)




Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e6 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll tp, x, y, cur, n;
ll tmp[maxn], len[maxn], head[maxn], nex[maxn], to[maxn];
ll a[maxn];
void add(ll u, ll v){
	nex[++cur] = head[u];
	to[cur] = v;
	head[u] = cur;
	return ;
}
void lis(ll now, ll fa){
	if(a[now] > tmp[tp]){
		tmp[++tp] = a[now];
		len[now] = tp;
//		cout << now << " ";
//	for(int i = 1;i <= tp;i++){
//		cout << tmp[i] << " ";
//	}
//	puts("");
		for(int i = head[now];i;i = nex[i]){
			ll t = to[i];
//			cout << t << " "; 
			if(t != fa){
				lis(t, now);
			}
		}
		tp--;
	} else {
		ll l = 1, r = tp, ind = 0;
		ind = lower_bound(tmp + 1, tmp + tp + 1, a[now]) - tmp;
		ll old = tmp[ind];
		if(ind) tmp[ind] = a[now];
		len[now] = tp;
//		cout << now << " " << ind << " ";
//		for(int i = 1;i <= tp;i++){
//		cout << tmp[i] << " ";
//	}
//	puts("");
		for(int i = head[now];i;i = nex[i]){
			ll t = to[i];
			if(t != fa){
				lis(t, now);
			}
		}
		tmp[ind] = old;
	
	}
	return ;
}
int main(){
	qread(n);
	for(int i = 1;i <= n;i++){
		qread(a[i]);
	}
	for(int i = 1;i <= n - 1;i++){
		qread(x);
		qread(y);
		add(x, y);
		add(y, x);
	}
	lis(1, -1);
	for(int i = 1;i <= n;i++){
		cout << len[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 28740
/*Bismillahir Rahmanir Raheem*/

#include <bits/stdc++.h>
using namespace std;

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) scanf("%d", &x)
#define sfc(x) scanf("%c", &x)
#define sfl(x) scanf("%lld", &x)
#define sflu(x) scanf("%llu", &x)
#define sfii(x, y) scanf("%d %d", &x, &y)
#define sfll(x, y) scanf("%lld %lld", &x, &y)
#define sfiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES");
#define pfno pf("NO");
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)

//defined for loop

//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair

//code start

int main()
{
    // freopen("/home/grimfirefly/Programming/input.txt","r",stdin);
    // freopen("/home/grimfirefly/Programming/output.txt","w",stdout);
    ll a, h;
    sfll(a, h);
    ull sum=0;
    int num;
    loopi(i,0,h){
        sfi(num);
        sum+=num;
    }
    pf(sum>=a ? "Yes\n":"No\n");
    return 0;
}

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

int n;
long long m = 0;
string s;
long long r[4000], g[4000], b[4000];

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

	r[0] = 0;
	g[0] = 0;
	b[0] = 0;

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			r[i] = r[i - 1];
			g[i] = g[i - 1];
			b[i] = b[i - 1];
		}

		if (s[i] == 'R')
			r[i]++;
		else if (s[i] == 'G')
			g[i]++;
		else
			b[i]++;
	}

	for (int i = 1; i < n - 1; i++) {
		if (s[i] == 'R')
			m += g[i - 1] * (b[n - 1] - b[i]) + b[i - 1] * (g[n - 1] - g[i]);
		else if (s[i] == 'G')
			m += b[i - 1] * (r[n - 1] - r[i]) + r[i - 1] * (b[n - 1] - b[i]);
		else
			m += r[i - 1] * (g[n - 1] - g[i]) + g[i - 1] * (r[n - 1] - r[i]);

		int a = min(i, n - 1 - i);
		for (int j = 1; j <= a; j++)
			if (s[i - j] != s[i + j] && s[i - j] != s[i] && s[i + j] != s[i])
				m--;
	}

	cout << m << endl;
}

Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");

		long a = Long.parseLong(line[0]);
		long b = Long.parseLong(line[1]);
		long x = Long.parseLong(line[2]);

		if(a%x!=0){
			System.out.println(b/x-a/x);
		}
		else{
			System.out.println(b/x-a/x+1);
		}
	}
}


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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const ll inf=1e18;
const int N=16;
int a[N][N];
int n;
ll price[1<<N];
ll dp[1<<N];

ll go(int done,int thismask,int p){
	if(!p&&~dp[done])return dp[done];
	if(p==n)return price[thismask]+(thismask?go(done|thismask,0,0):0);
	return dp[done]=max(go(done,thismask,p+1),(done&(1<<p))?0:go(done,thismask|(1<<p),p+1));
}

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			cin>>a[i][j];
	for(int i=1;i<(1<<n);++i)
		for(int j=0;j<n;++j)
			for(int k=j+1;k<n;++k)
				if(((1<<j)&i)&&((1<<k)&i))
					price[i]+=a[j][k];
	memset(dp,-1,sizeof(dp));
	dp[(1<<n)-1]=0;
	cout<<go(0,0,0)<<endl;
}


Measured memory_bytes: 4676
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>
#include <map>
#include<iomanip>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}


int main() {
	int N, Q;
	cin >> N >> Q;
	string Code;
	cin >> Code;
	auto *count = new int[N];
	count[0] = 0;
	for (int i = 1; i < N; i++) {
		count[i] = (Code[i - 1] == 'A'&&Code[i] == 'C') ? count[i - 1] + 1 : count[i - 1];
	}
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		cout << count[r - 1] - count[l - 1] << endl;
	}
}




Measured memory_bytes: 1472
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

const int MAX = 80 * 80 * 2 + 50;
bool dp[85][85][MAX];
int main() {
	const int fix = 80 * 80 + 25;
	int h, w; cin >> h >> w;
	int a[h][w]; rep(i,h)rep(j,w) cin >> a[i][j];
	int b[h][w]; rep(i,h)rep(j,w) cin >> b[i][j];
	dp[0][0][a[0][0] - b[0][0] + fix] = true;
	dp[0][0][-a[0][0] + b[0][0] + fix] = true;
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			for(int i = 0; i < MAX; ++i) {
				if(dp[y][x][i]) {
					if(y + 1 < h) {
						{
							int nxt = i + a[y + 1][x] - b[y + 1][x];
							if(0 <= nxt and i < MAX) dp[y + 1][x][nxt] |= dp[y][x][i];
						}
						{
							int nxt = i - a[y + 1][x] + b[y + 1][x];
							if(0 <= nxt and i < MAX) dp[y + 1][x][nxt] |= dp[y][x][i];
						}
					}
					if(x + 1 < w) {
						{
							int nxt = i + a[y][x + 1] - b[y][x + 1];
							if(0 <= nxt and i < MAX) dp[y][x + 1][nxt] |= dp[y][x][i];
						}
						{
							int nxt = i - a[y][x + 1] + b[y][x + 1];
							if(0 <= nxt and i < MAX) dp[y][x + 1][nxt] |= dp[y][x][i];
						}
					}
				}
			}
		}
	}
	int ans = INF;
	for(int i = 0; i < MAX; ++i) {
		if(dp[h - 1][w - 1][i]) {
			ans = min(ans, abs(i - fix));
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	long long int b,r,g,c,s,t,x,y;
	while(cin >> b >> r >> g >> c >> s >> t &&( b || r || g || c || s || t)){
		y = (t-s-b*5-r*3)*3+(b*5+r*3)*2;
		x = 100+(c*2+g*7+b*15+r*15+(r*3*15)+(b*5*15));
		cout << x-y <<endl;
	}
	return 0;
}

Measured memory_bytes: 0