akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(auto i=(v).begin(); i!=(v).end(); ++i)
#define ALL(x) (x).begin(),(x).end()

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; }

typedef long long ll;
#define vv(t) vector<t>

#define CHC(mp, x) if(mp.end() != mp.find(x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#pragma endregion

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int main(void){
    ll X;
    cin >> X;
    ll xx = 100;
    int cnt = 0;
    while(xx < X){
        xx += xx/100;
        cnt++;
        debug(xx);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int x,y;
    cin >> x >> y;
    REP(i,x+1){
        if(y == 2*i + 4*(x-i)){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
int main() 
{
	int t;cin>>t;
	string s[t];
	int a[t];
	int ans=0;
	for(int i=0;i<t;i++)
	{
		cin>>s[i]>>a[i];
	}
	string str;
	cin>>str;
	int itr=0;
	while(itr<t && s[itr]!=str)
	{
		itr++;
	}
	itr++;
	for(;itr<t;itr++)
	{
		ans+=a[itr];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())

counter = [0] * 10001
for x in range(1, N+1):
    n1 = x * x
    if n1 >= N:
        continue
    for y in range(x, N+1):
        n2 = n1 + y * y + x * y
        if n2 >= N:
            continue
        for z in range(y, N+1):
            n = n2 + z * z + y * z + z * x
            if 1 <= n <= 10000:
                s = len(Counter([x, y, z]))
                if s == 1:
                    counter[n] += 1
                elif s == 2:
                    counter[n] += 3
                elif s == 3:
                    counter[n] += 6
for i in range(1, N+1):
    print(counter[i])


Measured memory_bytes: 71144
input_lines = str(input())

W = int(input_lines.split(' ')[0])
a = int(input_lines.split(' ')[1])
b = int(input_lines.split(' ')[2])

if a < b:

    saidai = a + W

    if saidai >= b:
        print('0')
    else:
        print(b - saidai)

elif a > b:

    saidai = b + W

    if saidai >= a:
        print('0')
    else:
        print(a - saidai)

else:
    print('0')

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

int main() {
    int A, B; 

    cin >> A >> B; 

    if (A == B) { 
        cout << "Draw" << endl; 
    } 
    else if (A>B && B!=1) { 
        cout << "Alice" << endl; 
    } 
    else if (A==1 && B!=1) {
        cout << "Alice" << endl; 
    }
    else {
        cout << "Bob" << endl; 
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
  ll n,d;
  cin >> n >> d;
  ll a,b;
  int count=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a*a + b*b <= d*d){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 0.00001
const int maxn=1e5+10;
int x[maxn],y[maxn];
char d[maxn];
int n;
double f(double xx)
{
    double xmin=1e12,xmax=-1e12,ymin=1e12,ymax=-1e12;
    rep(i,1,n)
    {
        double cx=x[i],cy=y[i];
        if(d[i]=='R')
        {
            cx+=xx;
        }
        else
            if(d[i]=='L')
        {
            cx-=xx;
        }
        else
            if(d[i]=='U')
        {
            cy+=xx;
        }
        else
            if(d[i]=='D')
        {
            cy-=xx;
        }
        xmin=min(xmin,cx);
        xmax=max(xmax,cx);
        ymin=min(ymin,cy);
        ymax=max(ymax,cy);
    }
    return (xmax-xmin)*(ymax-ymin);
}
double ts(double l,double r)
{
    rep(i,1,500)
    {
        double m1=(l*2 + r)/3;
        double m2=(l + r*2)/3;
        double f1=f(m1);double f2=f(m2);
        if(f1>=f2)
        {
            l=m1;
        }
        else
        {
            r=m2;
        }
    }
    return f(l);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    rep(i,1,n)
    {
        cin>>x[i]>>y[i]>>d[i];

    }
    cout<<fixed<<setprecision(12)<<ts(0,2e8)<<"\n";

    return 0;

    //check for long long or int
}


Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main()
{
  std::string s;
  std::cin >> s;
  
  for (unsigned i = 0; i < s.size(); i += 2) {
    std::cout << s[i];
  }
  std::cout << std::endl;
  
  return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()){
        if(s[i]+n > 90){
            s[i] -= 26;
        }
        s[i] += n;
    }

    for(auto i : s){
        cout << i;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
}
        

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

int n,a,b,ans;

int padu(int k){
    int t=k,ok=0;
    while(t)
        ok+=t%10,t/=10;
    return ok>=a&&ok<=b;
}

int main(){
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
        if(padu(i)) ans+=i;
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007;

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; }


void Main(){
    string s;
    cin >> s;
    int n = s.size();
    if (s[n-1] == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << 's' << endl;
    }
}   

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}



Measured memory_bytes: 3684
import math

def main():
    n = int(input())
    m = math.sqrt(n)
    ans = []
    for i in range(1, int(m) + 1):
        div = n / i
        if not float.is_integer(div):
            continue
        ans.append((div+i)-2)

    print(int(min(ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	for (int x, y; cin >> x >> y;) {
		cout << gcd(x, y) << endl;
	}
	return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <vector>

int main() {
    std::size_t n;
    std::cin >> n;
    std::vector<std::uint64_t> v;
    v.reserve(n);
    for (std::size_t i = 0; i != n; ++i) {
        std::uint64_t a;
        std::cin >> a;
        v.emplace_back(a);
    }
    auto it = v.begin();
    auto end = v.end();
    std::uint64_t prev = *it++;

    enum class direction {
        undetermined,
        up,
        down
    };
    direction d = direction::undetermined;

    std::size_t count = 1;

    for (; it != end; ++it) {
        auto current = *it;
        if (prev == current) continue;
        if (prev < current) {
            if (d == direction::down) {
                ++count;
                d = direction::undetermined;
            }
            else {
                d = direction::up;
            }
            prev = current;
        }
        else {
            if (d == direction::up) {
                ++count;
                d = direction::undetermined;
            }
            else {
                d = direction::down;
            }
            prev = current;
        }
    }
    std::cout << count << std::endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}

const int maxn = 5e2 + 5;
int n;
int a[maxn][maxn];
int sumcol[maxn];

int func(int row) {
    int res = 0;
    FOR(j, 0, n) {
        if (!a[row][j]) {
            res++;
        }
    }
    int ok = 0;
    FOR(i, 0, n) {
        if (a[i][row]) {
            ok = 1;
        }
    }
    if (!ok) res++;
    FOR(j, 0, n) {
        if (sumcol[j] != n) {
            res++;
        }
    }
    return res;
}

void solve() {
    cin >> n;
    int tot = 0;
    FOR(i, 0, n) {
        string s; cin >> s;
        FOR(j, 0, n) {
            a[i][j] = s[j] == '#';
            tot += a[i][j];
            sumcol[j] += a[i][j];
        }
    }
    if (!tot) {
        cout << -1 << "\n";
        return;
    }
    int ans = INF;
    FOR(i, 0, n) chkmin(ans, func(i));
    cout << ans << "\n";
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0);
#endif
    solve();
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    int n,a[20][105];
    cin>>n;
    for (int i=0;i<=2;i++)
        for (int j=0;j<=n;j++)
            a[i][j]=0;
    for (int i=1;i<=2;i++)
        for (int j=1;j<=n;j++)
    {
        cin>>a[i][j];
    }
    for (int i=1;i<=n;i++)
        a[1][i]=a[1][i]+a[1][i-1];
    for (int i=1;i<=n;i++)
        a[2][i]=max(a[2][i-1]+a[2][i],a[1][i]+a[2][i]);
    cout<<a[2][n]<<endl;
    return 0;
}


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

// [               1              ]
// [       2      ][       3      ]
// [   4  ][   5  ][   6  ][   7  ]
// [ 8][ 9][10][11][12][13][14][15]
// - root が 1 の完全二分木
// - ある頂点の番号を k とすると左の子は 2*k, 右の子は 2*k+1, 親は k/2 
// - 最下段の左端の番号 == 最下段の長さ == n
// 区間に一様に足すという操作のためにその区間に一様に足されている値を持つ
const ll INF = 1LL << 61;
struct RangeMinRangeAdd {
  typedef ll Val;
  int n;
  vector<Val> vs;
  vector<Val> ws; // 区間に一様に足されている値

  void clear(int N) {
    for (n = 1; n < N; n <<= 1);
    vs.assign(n * 2, 0);
    ws.assign(n * 2, 0);
  }

  // [l, r) の最小値
  Val getMin(int l, int r) {
    if (r - l <= 0) return INF;
    return getMin(0, n, 1, l, r);
  }
  Val getMin(int nl, int nr, int k, int l, int r) {
    if (r <= nl || nr <= l) return INF;
    if (l <= nl && nr <= r) return vs[k] + ws[k];
    Val x = getMin(nl, (nl+nr)/2, 2*k  , l, r);
    Val y = getMin((nl+nr)/2, nr, 2*k+1, l, r);
    return min(x, y) + ws[k];
  }

  // [l, r) の全てに val を加算
  void addRange(int l, int r, Val val) {
    addRange(0, n, 1, l, r, val);
  }
  Val addRange(int nl, int nr, int k, int l, int r, Val val) {
    if (r <= nl || nr <= l) return INF;
    if (l <= nl && nr <= r) { ws[k] += val; return vs[k] + ws[k]; }
    Val x = addRange(nl, (nl+nr)/2, 2*k  , l, r, val);
    Val y = addRange((nl+nr)/2, nr, 2*k+1, l, r, val);
    Val p = getMin(nl, nr, k, nl, l);
    Val q = getMin(nl, nr, k, r, nr);
    vs[k] = min(min(x, y), min(p, q) - ws[k]);
    return vs[k] + ws[k];
  }

  // pos の値を強制的に val にする
  void update(int pos, Val val) {
    Val now = getMin(pos, pos + 1);
    addRange(pos, pos+1, val - now);
  }
};


const int MAX_N = 212345;
struct Item {
  int l, r, a;
};
vector<Item> is[MAX_N];

int main2() {
  REP(i, MAX_N) is[i].clear();

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int l = nextInt();
    int r = nextInt();
    int a = -nextInt(); // スコアの最小値を求める問題に変えておく
    Item item = {l, r, a};
    is[r].push_back(item);
  }

  RangeMinRangeAdd dp;
  dp.clear(N+10);
  dp.update(0, 0);

  for (int i = 1; i <= N; i++) {
    ll best = dp.getMin(0, i);
    dp.update(i, best);
    for (Item item : is[i]) {
      dp.addRange(item.l, item.r + 1, item.a);
    }
  }
  ll ans = dp.getMin(0, N+1);
  cout << -ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 21760
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 998244353

const int sz=1e6+5;
ll inf=1e15;

ll tree[4*sz];

// ll ar[sz];

// void build(int st,int en,int no)
// {
//     if(st==en)
//     {
//         tree[no]=ar[st];
//         return ;
//     }
//     ll mid=st+(en-st)/2;
//     build(st,mid,2*no+1);
//     build(mid+1,en,2*no+2);
//     tree[no]=tree[2*no+1]+tree[2*no+2];
// }

void update(int st,int en,int no,int pos,ll val)
{
    if(st==en)
    {
        tree[no]+=val;
        return;
    }
    ll mid=st+(en-st)/2;
    if(pos<=mid)
        update(st,mid,2*no+1,pos,val);
    else
        update(mid+1,en,2*no+2,pos,val);

    tree[no]=tree[2*no+1]+tree[2*no+2];
}

ll query(int st,int en,int no,int l,int r)
{
    if(l>r or st>en or en<l or r<st)
        return 0;
    if(l<=st and r>=en)
        return tree[no];
    ll mid=st+(en-st)/2;
    ll x1=query(st,mid,2*no+1,l,r);
    ll x2=query(mid+1,en,2*no+2,l,r);
    return x1+x2;
}

struct st{
    ll l,r;
};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        st ar[k];
        for(int i=0;i<k;i++){
            cin>>ar[i].l>>ar[i].r;
        }
        ll dp[n+1];
        memset(dp,0,sizeof(dp));
        dp[0]=1;
        update(0,sz,0,1,1);
        for(ll i=2;i<=n;i++){
            for(int j=0;j<k;j++){
                int left=max(0ll,i-ar[j].r);
                int right=min(i-1,i-ar[j].l);
                dp[i]+=query(0,sz,0,left,right);
                dp[i]%=mod;
            }
            update(0,sz,0,i,dp[i]);
        }

        cout<<dp[n];
    }

    return 0;
}

Measured memory_bytes: 8456
# coding: utf-8
# Your code here!
import numpy as np
import itertools
def kyori(x1,y1,x2,y2):
    dis = ((x1-x2)**2+(y1-y2)**2)**0.5
    return dis
N = int(input())
xy = []
for n in range(N):
    xy.append(list(map(int, input().split())))
diss = np.zeros((N,N))
c = list(itertools.permutations(range(N), N))
s = 0
for n in range(len(c)):
    for d in range(N-1):
        if diss[c[n][d]][c[n][d+1]]==0:
            diss[c[n][d]][c[n][d+1]] = kyori(xy[c[n][d]][0],xy[c[n][d]][1],xy[c[n][d+1]][0],xy[c[n][d+1]][1])
            diss[c[n][d+1]][c[n][d]] = diss[c[n][d]][c[n][d+1]]
        s += diss[c[n][d]][c[n][d+1]]
print(s/len(c))


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

int main(){
  int N; cin>>N;
  vector<int> sc(N,0);
  rep(i,N*(N-1)/2){
    int a,b,c,d; cin>>a>>b>>c>>d; 
    if(c>d) sc[a-1]+=3;
    else if(c<d) sc[b-1]+=3;
    else{ ++sc[a-1]; ++sc[b-1]; }
  }
  rep(i,N){
    int x=1;
    rep(j,N) if(sc[i]<sc[j]) ++x;
    cout<<x<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    //num[i]:=iが何回登場するか、cnt[i]:=i回登場する数字が何個あるか
    int num[N], cnt[N+1];
    fill(num, num+N, 0), fill(cnt, cnt+N+1, 0);
    rep(i, N){
        int A; cin >> A; A--;
        num[A]++;
    }
    rep(i, N) cnt[num[i]]++;
    //sum1[i]:=cnt[0]+cnt[1]+...+cnt[i-1]、sum2[i]:=0*cnt[0]+1*cnt[1]+...+(i-1)*cnt[i-1]
    int sum1[N+2], sum2[N+2];
    sum1[0] = sum2[0] = 0;
    rep(i, N+1){
        sum1[i+1] = sum1[i]+cnt[i];
        sum2[i+1] = sum2[i]+(i*cnt[i]);
    }
    //lim[i]:=i回操作できる最大のK
    int lim[N+2];
    lim[0] = N, lim[N+1] = 0;
    rep2(i, 1, N){
        int all = sum2[i]+i*(N-sum1[i]);
        lim[i] = all/i;
    }
    rep3(i, N, 0){
        rep(j, lim[i]-lim[i+1]) cout << i << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> H(N, vector<int>(N, -1));
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    while (A--)
    {
      int x, y;
      cin >> x >> y;
      --x;
      H[i][x] = y;
    }  
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++)
  {
    int temp = 0;
    vector<bool> x(N);
    for (int i = 0; i < N; i++)
    {
      if (bit & (1 << i))
      {
        x[i] = true;
        temp++;
      }
      
    }
    
    bool honest = true;
    for (int i = 0; i < N; i++)
    {
      if (!x[i])
      {
        continue;
      }
      
      for (int j = 0; j < N; j++)
      {
        if (H[i][j] == -1)
        {
          continue;
        }
        if ((H[i][j] && !x[j]) || (!H[i][j] && x[j]))
        {
          honest = false;
          break;
        }
        
      }
      if (!honest)
      {
        break;
      }
      
    }
    if (honest)
    {
      ans = max(temp, ans);
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    int g = min(2*c, a+b);

    int ans = 0;
    ans += min(x, y)*g;
    if (x>y) ans += (x-y)*min(a, g);
    if (y>x) ans += (y-x)*min(b, g);

    cout << ans << endl;
}


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

int main(void){
	int n;
	cin >> n;
	for (int i = 0; i <= n; ++i){
		if (i*i <= n && n < (i+1)*(i+1)){
			cout << i*i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
ostream &operator<<(ostream &os, const pint &a) { os << "(" << a.fi << "," << a.se << ")"; return os; }
ostream &operator<<(ostream &os, const vector<pint> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
#define N 30755228
lint dp[N];
lint cal(lint a,vector<pint> p){
	memset(dp,0,sizeof(dp));
	rep(i,a){
		dp[i+1]=max(dp[i+1],dp[i]+1);
		rep(j,p.size()){
			dp[i+p[j].fi]=max(dp[i+p[j].fi],dp[i]+p[j].se);
		}
	}
	return dp[a];
}
int x[5],y[5];
int main()
{
	vector<pint> p,q;
	int a;cin>>a;
	rep(i,3) cin>>x[i];
	rep(i,3) cin>>y[i];
	rep(i,3){
		if(x[i]<y[i]) p.pb(mp(x[i],y[i]));
		if(x[i]>y[i]) q.pb(mp(y[i],x[i]));
	}
	//cout<<p<<endl;
	//cout<<q<<endl;
	cout<<cal(cal(a,p),q)<<endl;
}


Measured memory_bytes: 240640
#include <bits/stdc++.h>
#define Pct puts("------ Yes ------");
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
#define fir first
#define sec second
#define ls son[u][0]
#define rs son[u][1]
#define eps 1e-8
#define PI acos(-1.0)
using namespace std;
template <class T> void rd(T &x){ x = 0; int f = 1; char ch = getchar(); while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); x *= f; }

int main(){
	int n, m, a, b;
	rd(n), rd(m), rd(a), rd(b);
	printf("%d\n", (n - a) * (m - b));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void chmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void chmin(T& a, U b) { if (a>b) a = b; }

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

  vector<int> a(4);
  rep(i, 4) cin >> a[i];
  sort(a.begin(), a.end());
  if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int ans = 0;
	int n;
	cin >> n;
	int prev;
	for(int i = 0 ; i < n; i++){
		int x;
		cin >> x;
		int curr;
		if(i){
			curr = max(0ll, prev - x);
		}
		prev = x + curr;
		ans += curr;
	}
	cout << ans;
}

Measured memory_bytes: 3568
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, M = MAP()
a = deque([INT() for _ in range(M)])
a.append(0)

dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1

if a[0] == 1:
	dp[1] = 0
	a.popleft()

q = a.popleft()
for i in range(2, N+1):
	if i == q:
		dp[i] = 0
		q = a.popleft()
	else:
		dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[N])



Measured memory_bytes: 9860
#include <bits/stdc++.h>
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pi;
 
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void solve()
{
    ll n, m;
    cin >> n >> m;

    ll sum = 0;

    while(m--){
        ll temp;
        cin >> temp;
        sum += temp;
    }

    if(n-sum>=0) cout << n-sum;
    else cout << -1;

    return;
}

int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fastio

    ll t = 1;
    // cin >> t;

    FOR(i, 1, t){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    ll a,b;
    cin >> a >> b;
    ll ans=0;
    if(b>=2*a){
        ans+=a;
        b-=2*a;
        ans+=b/4;
    }
    else{
        ans+=b/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
n, k = map(int, input().split())

for x in range(min(n, int(k / 10000)) + 1):
    for y in range(min((n - x), int((k - 10000 * x)/ 5000)) + 1):
        z = n - x - y
        if 10000 * x + 5000 * y + 1000 * z == k:
            print("{} {} {}".format(x,y,z))
            sys.exit()

print("{} {} {}".format(-1,-1,-1))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int even=0,odd=0;
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        if(t%2==0) even++;
        else odd++;
    }
    if(odd%2==0){
        even+=odd/2;
        odd=0;
    }
    else{
        even+=odd/2;
        odd=1;
    }
    even=1;
    if(even+odd==1) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    int n;cin>>n;
    ll ans=0;
    rep(i,0,n)
    {
        ll c=0;
        ll a;cin>>a;
        while(a%2==0)
            a/=2,c++;
        ans+=c;
    }
    cout<<ans;
}


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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll>L(2*N);
    for (int i = 0; i < 2*N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += L[2*i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
List = [int(input()) for _ in range(M)]

P = 10**9+7
dp = [1]*(N+1)

for i in List:
    dp[i]=0

for j in range(1, N):
    if dp[j+1]!=0:
        dp[j+1] = dp[j]+dp[j-1]
        
print(dp[N]%P)

Measured memory_bytes: 460020
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>

using namespace std;

typedef vector<int> vi;
auto ok = [](const vi & v){
    for (int i = 1; i < v.size(); i++){
        if (v[i] != v[0]) return false;
    }
    return true;
};

struct state {
    vi v;
    int n;
};

namespace std{
    ostream & operator<<(ostream & os, const vi & v){
        os << '(';
        for (int i = 0; i < v.size(); i++){
            cout << v[i] << ',';
        }
        os << ')';
        return os;
    }
}

int main(){
    string s;
    while (cin >> s, s!="0"){
        vi init(s.size());
        for (int i = 0; i < s.size(); i++){
            if (s[i] == 'r') init[i] = 0;
            else if (s[i] == 'g') init[i] = 1;
            else init[i] = 2;
        }
        queue<state> q;
        set<vi> dp;
        q.push({ init, 0 });

        int ans = -1;
        while (q.size()){
            state sta = q.front();
            q.pop();
            vi & sv = sta.v;
            //cout << sv << endl;
            auto pr = dp.insert(sv);
            if (!pr.second){
                continue;
            }
            if (ok(sv)){
                ans = sta.n;
                break;
            }
            for (int i = 1; i < sv.size(); i++){
                if (sv[i] != sv[i - 1]){
                    int a = sv[i];
                    int b = sv[i - 1];
                    sv[i] = sv[i - 1] = 3 - (a + b);
                    q.push({ sv, sta.n + 1 });
                    sv[i] = a;
                    sv[i - 1] = b;
                }
            }
        }
        if (ans == -1){
            cout << "NA" << endl;
        }
        else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3460
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner (System.in);
		StringBuilder str = new StringBuilder();

		boolean [][] cards = new boolean [4][13] ;
		//自分の手持ちカード枚数
		int myCards = scan.nextInt();
            //手持ちカード枚数まで入力する
		for(int i = 0 ; i < myCards ; i++){

	    //マークと数字を入れる
		String mark = scan.next();   int number = scan.nextInt();

		//該当数るマークと数字の配列にtrueを入れる
		if(mark.equals("S")) cards [0][number-1] = true;
		else if(mark.equals("H")) cards [1][number-1] = true;
		else if(mark.equals("C")) cards [2][number-1] = true;
		else cards [3][number-1] = true;

		}


       //cards[i][j]==falseだったら、出力
		for(int i = 0 ; i < 4 ; i++){
			for(int j= 0 ; j < 13 ; j++){
		            if(!cards[i][j]) {if(i == 0) System.out.println("S "+ (j+1));
                                              else if(i == 1) System.out.println("H "+ (j+1));
                                              else if(i == 2) System.out.println("C "+ (j+1));
                                              else System.out.println("D "+ (j+1));
				}
			}
		}

	}
}

Measured memory_bytes: 18216
use proconio::{input, fastout};

fn is_prime(i: f64) -> bool {
    let i_int = i as i64;
    let end = i.sqrt() as i64;
    let mut flag = true;
    for j in 2..end {
        if i_int % j == 0 {
            flag = false;
            break;
        }
    }

    return flag;
}
fn prime_factorization(n: f64) -> i64 {
    let mut _n = n;
    let mut i = 2.0_f64;
    let mut count = 0;
    while _n.sqrt() > i {
        if _n % i == 0.0 && is_prime(i) {
            let mut c = 0;
            let mut thresh = 1;
            while _n % i == 0.0 {
                _n = _n / i;
                c += 1;

                if thresh == c {
                    thresh += 1;
                    count += 1;
                    c = 0;
                }

            }
        }
        i += 1.0;
    }

    if _n != 1.0 {
        count += 1;
    }

    return count;
}

#[fastout]
fn main() {
    input!{
        n: f64,
    }
    println!("{}", prime_factorization(n));

}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++){
    int num = s[i] - 'A';
    num += n;
    num %= 26;
    s[i] = (char)(num + 'A');
  }
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = solve(n, a)
    print(*ans)


def solve(n, a):
    m = 8
    colors = [0 for i in range(m + 1)]
    for i in range(n):
        for j in range(m):
            if a[i] < 400 * (j + 1):
                colors[j] += 1
                break
        else:
            colors[m] += 1
    usedcolors = sum([1 for i in colors[:m] if i > 0])
    ans = [max(1,usedcolors), usedcolors + colors[m]]

    return ans


if __name__ == '__main__':
    main()

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

using namespace std;

const int MAXN = 100100;

int arr[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i;
	int x, sol = 0;
	
	cin>>n;
	
	for (i = 0; i < n; ++i)
	{
		cin>>x;
		++arr[x];
	}
	
	for (i = 1; i + 1 < MAXN; ++i)
		sol = max(sol, arr[i - 1] + arr[i] + arr[i + 1]);
	
	cout<<sol<<'\n';
}


Measured memory_bytes: 640
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t K, A, B;

	scanf("%zu %zu %zu", &K, &A, &B);

	if (B <= A + 2) {
		printf("%zu\n", K + 1);
	}
	else {
		uint64_t sum = 1;

		if (sum < (uint64_t)A) {
			sum = (uint64_t)A;
			K -= (size_t)(A - 1);
		}

		sum += (uint64_t)(B - A)*(uint64_t)(K / 2);

		if (K % 2 == 1) {
			sum++;
		}

		printf("%"PRIu64"\n", sum);
	}

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int selectionSort(int A[], int N) {
    int i, j, t, sw = 0, minj;
    for(i = 0; i < N - 1 ; i++)
    {
        minj = i;
        for(j = i; j < N; j++)
        {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        t = A[i]; 
        A[i] = A[minj];
        A[minj] = t;
        if (i != minj) {
            sw++;
        }
    }
    return sw;
}

int main() {
    int A[100], N, i, sw;
    scanf("%d", &N);
    for(i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    sw = selectionSort(A, N);

    for(i = 0; i < N; i++)
    {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", A[i]);
    }

    printf("\n");
    printf("%d\n", sw);
    
    return 0;
}



Measured memory_bytes: 2740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

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

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

ll H,W,N;
cin >> H >> W >> N;
map<pii, ll> mp;
rep(i,N) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    rep(j,9) {
        int h = a + dx[j], w = b + dy[j];
        if(0 < h && h < H-1 && 0 < w && w < W-1) mp[{h,w}]++;
    }
}

map<int, ll> ans;
rep(i,10) {
    if(i == 0) ans[i] = (H-2)*(W-2);
    else ans[i] = 0;
}
for(auto x : mp) {
    ans[x.second]++;
    ans[0]--;
}
for(auto y : ans) cout << y.second << endl;
return 0;
}

Measured memory_bytes: 56576
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  100005
using namespace std;
// Solution to problem: UVa 11504
ll n,m;
vector<ll>g[MAXN];
vector<vector<ll> >comps;
ll dfn[MAXN],lowLink[MAXN],comp[MAXN],inStack[MAXN];
ll ndfn;
stack<ll>stk;
ll ans=0;

void tarjan(ll node,ll par){
    dfn[node]=lowLink[node]=ndfn++;
    inStack[node]=1;
    stk.push(node);
    for(auto it=g[node].begin();it!=g[node].end();it++){
        if(dfn[*it]==-1){
            tarjan(*it,node);
            lowLink[node]=min(lowLink[node],lowLink[*it]);
        }
        else if(*it!=par){
            lowLink[node]=min(lowLink[node],dfn[*it]);
        }
    }
    if((dfn[node]==lowLink[node])&&par!=-1){
        ans++;
    }

    if(dfn[node]==lowLink[node]){
        comps.pb(vector<ll>());
        ll x=-1;
        while(x!=node){
            x=stk.top();
            stk.pop();
            inStack[x]=0;
            comp[x]=comps.size();
        }
    }
}

void scc(){
    memset(dfn,-1,sizeof(dfn));
    memset(inStack,0,sizeof(inStack));
    comps.clear();
    ndfn=0;
    for(ll i=1;i<=n;i++){
        if(dfn[i]==-1){
            tarjan(i,-1);
        }
    }
        
}
vector<vector<ll> >dagList;
vector<ll>inDeg,outDeg;

ll createMetaGraph(){
    ll siz=comps.size();
    ll cntSrc=siz,cntSnk=siz;
    dagList.clear();
    dagList.resize(siz+1);
    outDeg.clear(); outDeg.resize(siz+1);
    inDeg.clear(); inDeg.resize(siz+1);
    for(ll i=1;i<=n;i++){
        for(auto it=g[i].begin();it!=g[i].end();it++){
            if(comp[*it]!=comp[i]){
                if(find(all(dagList[comp[i]]),comp[i])==dagList[comp[i]].end()){
                    // ^^ for removing parallel edges. Additional log(n) operation
                    // could be removed if we dfs by keeping visit for DAG graph
                    dagList[comp[i]].pb(comp[*it]);
                    if(!(inDeg[comp[*it]]++))
                        cntSrc--;
                    if(!(outDeg[comp[i]]++))
                        cntSnk--;
                }
            }
        }
    }
    ll cyc; //Min edges to convert DAG to one cycle
    if(comps.size()==1)
        cyc=0;
    else cyc=max(cntSrc,cntSnk);
    return siz;
}
ll visit[MAXN];
void dfs(ll node){
    visit[node]=1;
    for(auto it=dagList[node].begin();it!=dagList[node].end();it++){
    if(visit[*it]==0)
      dfs(*it);
    }
}

ll solve(){
    scc();
    ll siz;
    siz=createMetaGraph();
    memset(visit,0,sizeof(visit));
    ll count=0;
    for(ll i=siz;i>0;i--){
        if(visit[i]==0){
            dfs(i);
            count++;
        }
    }
    return count;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
        cin>>n>>m;
        for(ll j=0;j<m;j++){
            cin>>a>>b;
            g[a].pb(b);
            g[b].pb(a);
        }
        solve();
        cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 6016