akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

string s, t;
string res = "";

int operator-(const pair<int,int> &a, const  pair<int,int> &b){
        return (a.first - b.first) + (a.second - b.second);
    }

void printpath(vector<vector<pair<int, int>>>& p, pair<int, int> x){
    if(x.first == 0 || x.second == 0) return;
    if(x - p[x.first][x.second] == 2){
        res += s[x.first-1];
    }
    printpath(p, p[x.first][x.second]);
}

int main() {
    cin>>s>>t;
    int m = s.length(), n = t.length();
    vector<vector<int>> dp(m+1, vector<int>(n+1, 0));
    vector<vector<pair<int, int>>> p(m+1, vector<pair<int, int>>(n+1, {0, 0}));
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(s[i-1] != t[j-1]){
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                p[i][j] = dp[i][j] == dp[i-1][j] ? make_pair(i-1, j) : make_pair(i, j-1);
            }else{
                dp[i][j] = dp[i-1][j-1] + 1;
                p[i][j] = {i-1, j-1};
            }
        }
    }
    printpath(p, {m, n});
    reverse(res.begin(), res.end());
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 106112
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let v: Vec<i32> = line.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();

    let mut ans = std::i32::MAX;
    for i in 0..3 {
        for j in (i + 1)..3 {
            ans = std::cmp::min(ans, v[i] + v[j])
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, open;
    cin >> A >> B;
    open = A - (2 * B);
    cout << (open >= 0 ? open : 0) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
int main(){
	ll Y;
	long double X=100;
	int i;
	cin>>Y;
	for( i = 1;X<=Y;i++)
	     X=(ll)X*1.01;
	cout<<i-1;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e14
#define N 500001
#define K 4
#define ALPHA 1.5
#define BETA 1.0



int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int d;
    cin >> d;
    vector<int> c(26);
    double average = 0.0;

    for(int i = 0;i < 26;i++)
        cin >> c[i];
    vector<vector<int>> v(d,vector<int>(26,0));
    for(int i = 0;i < d;i++)
    {
        for(int j = 0;j < 26;j++)
        {
            cin >> v[i][j];
            average += v[i][j];
        }
    }
    average /= (d * 26);
    vector<int> last(26,-1);
    for(int i = 0;i < d;i++)
    {
        double mxgain = -inf;
        int ind = -1;

        for(int j = 0;j < 26;j++)
        {
            double gain = pow(v[i][j],BETA) + pow((i - last[j]) * c[j],ALPHA);
            // cerr << j << " " << gain << endl;
            if(gain > mxgain)
            {
                mxgain = gain;
                ind = j;
            }
        }
        last[ind] = i;
        cout << ind + 1 << endl;
    }

    
    return 0;    
} 



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

using namespace std;

typedef long long int ll;

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

  int N, D;
  cin >> N >> D;
  vector<vector<int> > X;
  for (int i = 0; i < N; i++) {
    X.push_back(vector<int>());
    for(int j = 0; j < D; j++) {
      int buf;
      cin >> buf;
      X[i].push_back(buf);
    }
  }

  const double eps = 1e-8;
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      double d = 0.0;
      for (int k = 0; k < D; k++) {
        d += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k]);
      }
      d = sqrt(d);
      if (abs(d - round(d)) < eps) count++;
    }
  }

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


Measured memory_bytes: 512
#include <stdio.h>

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

void InsertionSort(int A[], int N) {
	int i, j;
	int esc;
	
	for ( i = 1; i < N; i++ ) {
		j = i - 1;
		esc = A[i];
		
		while ( j >= 0 && A[j] > esc ) {
			A[j + 1] = A[j];
			j--;
		}
		
		A[j + 1] = esc;
		output(A, N);
	}
	
}

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

	output(A, N);
	InsertionSort(A, N);

	return 0;
}

Measured memory_bytes: 604
/**
 * @Author:      WeakestRookie
 * @Email:       1311053296@qq.com
 * @DateTime:    2019-07-20 19:59:47
 * @Description: Description 
 */
#include<bits/stdc++.h>
using namespace std;

#define rep(x, y, z) for(int x = y; x < z; ++x)
#define dwn(x, y, z) for(int x = y; x >= z;--x)
#define mst(a, b) memset(a, b, sizeof(a));
#define clr(a) mst(a, 0);
#define lbit(x) (x & (-x))
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int MOD = 1e9+7;
const int MAXN = 1e5+10;
int n;
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cout << 3*n*n << endl;
    system("pause");
    return 0;
}


Measured memory_bytes: 504
#include <stdio.h>
int main(void){
    int n, a[4][3][10]={{{0}}}, b, f, r, v, i, j, k, l;
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b-1][f-1][r-1] = a[b-1][f-1][r-1] + v;
    }
    
    for(j=0; j<4; j++){
        for(k=0; k<3; k++){
            for(l=0; l<10; l++){
                printf("%2d", a[j][k][l]);
            }
            printf("\n");
        }
        if(j<3){
            for(i=0; i<20; i++){
            printf("#");
            }
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2076
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back

vector<ll> fibVec = {1, 1};
ll mod = 1000000007;

ll fib(int n){
    int size = fibVec.size();
    if (n < size){
        return fibVec[n];
    }

    for(int i = size; i <= n; i++){
        fibVec.push_back((fibVec[i - 1] + fibVec[i - 2]) % mod);
    }

    return fibVec[n];
}

int main(){
    int N, M;
    cin >> N >> M;

    ll total = 1;

    vector<int> as;
    int a;
    for (int i = 0; i < M; i++){
        cin >> a;
        as.push_back(a);
    }
    as.push_back(N+1);

    int preA = -1;
    for (int i = 0; i < M+1; i++)
    {
        int d = as[i] - preA;
        if(d == 1){
            cout << 0 << endl;
            return 0;
        }
        preA = as[i];

        int f = fib(d - 2);
        total = (total * f) % mod;
        // cout << i << ": " << total << endl;
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 1400
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e5+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

char a[111],b[111];

LL check(LL x){
	LL i,j,k,l;
	for(i=x,j=n;i>0;i--,j--){
		if(a[j]!=b[i])return 0;
	}
	return 1;
}

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>n>>a+1>>b+1;
	for(i=n;i>0;i--){
		if(check(i))return cout<<n*2-i<<endl,0; 
	}
	cout<<n*2<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K; cin >> N >> K;
  ll ans = N % K;
  ans = min(ans, abs(ans-K));
  cout << ans << endl;
}

Measured memory_bytes: 256
L,R=map(int,input().split())
l=L%2019
r=R%2019
if R-L>=2019:
  print(0)
else:
  minlr=min(l,r)
  maxlr=max(l,r)
  ans=2020
  for i in range(minlr,maxlr+1):
    for j in range(i+1,maxlr+1):
      if i*j%2019<ans:
        ans=i*j%2019
  print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

#define ull unsigned long long
#define REP(i, n) for(int i = 0; i < (n); ++i)

int main () {
  ull N;
  std::cin >> N;
  std::string result = "";
  while (N > 0) {
      --N;
      char c = 'a' + (N % 26);
      result = c + result;
      N = N / 26;
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int a, b;
    cin >> a >> b;

    int large = max(a, b);
    int small = min(a, b);

    for (int i = 0; i < large; i++) {
        printf("%d", small);
    }
    printf("\n");
    
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,d,x; cin >> n >> d >> x;
    vl a(n);
    rep(i,n)cin >> a[i];
    ll res = n;
    //n人について調べる
    for(int j=0;j<n;j++){
        for(int k=a[j]+1;k<=d;k+=a[j]){
            res+=1;
        }
    }
    cout << res + x << endl;
}


Measured memory_bytes: 256
s = input()
q_num = int(input())
head = []
tail = []
flip = 0
for i in range(q_num):
    q = tuple(input().split())
    if q[0] == '1':
        flip ^= 1
    else:
        f = int(q[1]) - 1
        c = q[2]
        if f ^ flip == 0:
            head.append(c)
        else:
            tail.append(c)
if flip:
    head, tail = tail, head
    s = s[::-1]
head = ''.join(head)
tail = ''.join(tail)
print(head[::-1] + s + tail)

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;






int main() {
    int n;
    cin>>n;
    if(n<600)fin(8);
    else if(n<800)fin(7);
    else if(n<1000)fin(6);
    else if(n<1200)fin(5);
    else if(n<1400)fin(4);
    else if(n<1600)fin(3);
    else if(n<1800)fin(2);
    else if(n<2000)fin(1);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using pii = pair<int, int>;

int t[1 << 20];
int a[300300];

void build(int v, int tl, int tr) {
    if (tl == tr) t[v] = a[tl];
    else {
        int tm = (tl + tr) >> 1;
        build(v * 2, tl, tm);
        build(v * 2 + 1, tm + 1, tr);
    }
}

inline void push(int v, int tl, int tr) {
    if (t[v] && tl != tr) {
        t[v * 2] = max(t[v * 2], t[v]);
        t[v * 2 + 1] = max(t[v * 2 + 1], t[v]);
        t[v] = 0;
    }
}

void update(int v, int tl, int tr, int l, int r, int val) {
    if (l > r) return;
    if (tl == l && tr == r) {
        t[v] = max(t[v], val);
        return;
    }
    int tm = (tl + tr) >> 1;
    update(v * 2, tl, tm, l, min(r, tm), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
}

int get(int v, int tl, int tr, int idx) {
    push(v, tl, tr);
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) >> 1;
    if (idx <= tm)
        return get(v * 2, tl, tm, idx);
    return get(v * 2 + 1, tm + 1, tr, idx);
}

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

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int cur = get(1, 0, 300000, a[i]) + 1;
        ans = max(ans, cur);
        update(1, 0, 300000, max(a[i] - k, 0), min(a[i] + k, 300000), cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8924
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

class UnionFind{
public:
    vi data;
	UnionFind(int size):data(size,-1){}
	bool unite(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x])swap(x,y);
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool find(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int size(int x){
		return -data[root(x)];
	}
};

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    vi p(n);
    cin>>p;
    UnionFind uf(n);
    REP(i,m){
        int x,y;
        cin>>x>>y;
        uf.unite(x-1,y-1);
    }
    ll ans=0;
    map<int,set<int>> s;
    REP(i,n){
        s[uf.root(i)].insert(i);
    }
    for(const auto&a:s){
        const set<int>& x=a.S;
        for(int j:x)if(x.find(p[j]-1)!=x.end())ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	s.Scan()
	n, _ := strconv.Atoi(s.Text())

	h := make([]int, n+1)
	for i := 0; i < n; i++ {
		s.Scan()
		h[i], _ = strconv.Atoi(s.Text())
	}

	dp := make([]int, n+1)
	dp[1] = abs(h[1] - h[0])
	for i := 1; i < n; i++ {
		dp[i+1] = min(abs(h[i+1]-h[i])+dp[i], abs(h[i+1]-h[i-1])+dp[i-1])
	}

	fmt.Println(dp[n-1])
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 3796
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}


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

int main(void) {
	int n, m;
	cin >> n>>m;
	int max = 4 * n;
	int min = 2 * n;
	if (min <= m && m <= max&&m%2==0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

/*

*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    string st;
    cin >> st;
    int s = 0, t = 0;
    rep(i,st.size()) {
        if (st[i] == 'S') s++;
        if (st[i] == 'T') {
            if (s > 0) s--;
            else t++;
        }
    }
    cout << s + t << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 40
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,double> P;

ll n, m;
ll dp[(1<<20)];
P a[20];
vector<P> b;

ll gcd(ll x, ll y){
    while(y){
        x %= y;
        swap(x,y);
    }
    return x;
}

int main(){
    cin >> n >> m;
    rep(i,n) cin >> a[i].first;
    rep(i,n) cin >> a[i].second;
    rep(i,n) a[i].second /= 100;
    sort(a,a+n);
    ll sanu = -1;
    double prob = 1.0;
    rep(i,n){
        if(i == 0){
            sanu = a[i].first;
            prob *= (1-a[i].second);
            continue;
        }
        if(a[i].first == sanu){
            prob *= (1-a[i].second);
        } else{
            b.push_back(P(sanu,1-prob));
            sanu = a[i].first;
            prob = 1-a[i].second;
        }
    }
    b.push_back(P(sanu,1-prob));
    n = b.size();
    rep(i,(1<<n)){
        if(i == 0) continue;
        int cnt = 0;
        ll hoge = 1;
        bool ok = true;
        rep(j,n){
            if(i&(1<<j)){
                cnt++;
                ll g = gcd(hoge,b[j].first);
                hoge /= g;
                if(INF/hoge < b[j].first){
                    ok = false;
                    break;
                }
                hoge = hoge*(b[j].first);
            }
        }
        if(!ok) dp[i] = 0;
        else dp[i] = m/hoge;
        if(cnt%2 == 0) dp[i] *= -1;
    }
    rep(i,n) rep(j,(1<<n)){
        if(j&(1<<i)){
            dp[j] += dp[(j^(1<<i))];
        }
    }
    double ans = 0.0;
    rep(i,(1<<n)){
        prob = 1.0;
        rep(j,b.size()){
            if(i&(1<<j)){
                prob *= b[j].second;
            } else{
                prob *= (1-b[j].second);
            }
        }
        ans += prob*dp[i];
    }
    printf("%.9f\n",ans);
}

Measured memory_bytes: 11484
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int Q = sc.nextInt();
		boolean isreverse = false;
		StringBuilder ans = new StringBuilder(S);
		StringBuilder head = new StringBuilder();
		StringBuilder tail = new StringBuilder();
		for(int i = 0; i < Q; i++) {
			if(sc.nextInt() == 1) {
				if(isreverse)
					isreverse = false;
				else
					isreverse = true;
			}
			else {
				int F = sc.nextInt();
				String C = sc.next();
				if(F == 1) {
					if(isreverse)
						tail.append(C);
					else
						head.append(C);
				}
				else {
					if(isreverse)
						head.append(C);
					else
						tail.append(C);
				}
			}
		}
		ans.insert(0, head.reverse());
		ans.append(tail);
		System.out.println(isreverse ? ans.reverse() : ans);

	}

}

Measured memory_bytes: 121520
S = input()
N = len(S)
A = [int(S[i]) for i in range(N)]
cnt = [0] * 2019
cnt[0] = 1
p = 1
dp = 0

for i in reversed(range(N)):
    dp = (dp + A[i]*p) % 2019
    cnt[dp] += 1
    p = 10 * p % 2019
ans = 0

for i in cnt:
    ans += i*(i-1)//2

print(ans)

Measured memory_bytes: 75772
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
int n,a[N],q[N];

inline int abs(int x)
{
	if(x<0) return -x;
	return x; 
}

int main(){
	int i,j;long long sum=0;
	cin>>n;
	for(i=1;i<=n;++i) cin>>a[i];
	if(n==2){
		cout<<abs(a[2]-a[1]);
		return 0;
	}
    sort(a+1,a+n+1);
    long long ans;
    if(n&1){
	   for(i=1;i<=n/2;++i) sum-=a[i];
       for(i=n/2+1;i<=n;++i) sum+=a[i];
       sum<<=1;
       sum-=a[n/2+1];sum-=a[n/2+2];
       ans=sum;sum=0;
       for(i=1;i<=n/2+1;++i) sum-=a[i];
       for(i=n/2+2;i<=n;++i) sum+=a[i];
       sum<<=1;
       sum+=a[n/2+1];sum+=a[n/2];
       ans=max(ans,sum);
	}else{
	   for(i=1;i<=n/2;++i) sum-=a[i];
       for(i=n/2+1;i<=n;++i) sum+=a[i];
       sum<<=1;
       sum-=a[n/2+1];sum+=a[n/2];
       ans=sum;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
def culc_sum(i_a,i_b,i_c):
    return (500 * i_a + 100 * i_b + 50 * i_c)


a_n = int(input())
b_n = int(input())
c_n = int(input())

X = int(input())

result = 0

for i_a in range(a_n + 1):
  if (500 * i_a) > X:
    break
  for i_b in range(b_n + 1):
    if (500 * i_a + 100 * i_b) > X:
      break
    for i_c in range(c_n + 1):
      #print(500 * i_a + 100 * i_b + 50 * i_c)
      if culc_sum(i_a,i_b,i_c) == X:
        result = result + 1
        break

print(result)

        

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int kakkonum,nowkakko;
	char kakko[4];
	int n,i;
	scanf("%d",&n);
	kakkonum=0;
	for(i=0;i<n;i++) {
		scanf("%s%d",kakko,&nowkakko);
		if(kakko[1]==0) {
			if(kakko[0]=='(')kakkonum+=nowkakko;
			else if(kakko[0]==')')kakkonum-=nowkakko;
		}
		if(kakkonum<0) {
			puts("NO");
			return 0;
		}
	}
	puts(kakkonum==0?"YES":"NO");
	return 0;
}

Measured memory_bytes: 584
#include <cstdio>

char S[1010];
bool isExist['W'+1];

int main () {
    scanf("%s", S);

    for(char *ptr = S; *ptr; ptr++)
        isExist[*ptr] = true;

    printf("%s\n", (isExist['E'] == isExist['W']) && (isExist['S'] == isExist['N']) ? "Yes": "No");

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> query;

ll constPref[200005];
ll linearPref[200005];
ll ret;
int n, m;
int l[200005];

void constLift(int a, int b, int inc) {
  if(a > b) return;
  constPref[a] += inc;
  constPref[b+1] -= inc;
}
void linearLift(int a, int b, int inc) {
  if(a > b) return;
  linearPref[a] += inc;
  linearPref[b+1] -= inc;
}

void upd(int lhs, int rhs) {
  if(lhs < rhs) {
    int fullCost = rhs - lhs;
    // 1 through lhs incur full cost
    constLift(1, lhs, fullCost);
    // rhs+1 to m incur full cost
    constLift(rhs+1, m, fullCost);
    // 0 incurs rhs + 1
    // rhs incurs 1
    linearLift(lhs+1, rhs, -1);
    constLift(lhs+1, rhs, rhs + 1);
    return;
  }
  assert(lhs > rhs);
  // rhs ... lhs
  int fullCost = m - (lhs - rhs);
  assert(fullCost >= 1 && fullCost < m);
  // everything from rhs+1 to lhs incurs full cost
  constLift(rhs+1, lhs, fullCost);
  // lhs+1 incurs full cost
  // 1 incurs fullcost + lhs
  // 0 incurs fullcost + lhs + 1
  constLift(lhs+1, m, fullCost + lhs + 1);
  linearLift(lhs+1, m, -1);
  // rhs incurs 1
  // 1 incur rhs
  // 0 incurs rhs + 1
  constLift(1, rhs, rhs+1);
  linearLift(1, rhs, -1);
}

void collapse() {
  ret = 1e18;
  for(int i = 1; i <= m; i++) {
    linearPref[i] += linearPref[i-1];
    constPref[i] += constPref[i-1];
    ret = min(ret, linearPref[i] * i + constPref[i]);
  }
}

void solve() {
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }
  for(int i = 1; i < n; i++) {
    upd(l[i-1], l[i]);
  }
  collapse();
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

// less - decsend - pos - residual - val
int dp[2][2][501][500][10];
const int mod = 10000;

int calc(string s, int m){
    if(s == "0")    return 0;
    memset(dp, 0, sizeof(dp));
    int n = s.length();
    for(int i = 0; i < n; i++){
        for(int less = 0; less < 2; less++){
            for(int dec = 0; dec < 2; dec++){
                for(int res = 0; res < m; res++){
                    for(int val = 0; val < 10; val++){
                        if(dp[less][dec][i][res][val] == 0) continue;
                        for(int nval = 0; nval < 10; nval++){
                            if(less == 0 && nval > s[i]-'0')    break;
                            if(val == nval || dec == (val > nval)) continue;
                            int nless = less || (s[i]-'0' > nval);
                            int ndec = 1-dec;
                            int nres = (res*10+nval)%m;
                            (dp[nless][ndec][i+1][nres][nval] += dp[less][dec][i][res][val]) %= mod;
                        }
                    }
                }
            }
        }
        // begin number here
        for(int nval = 1; nval <= 9; nval++){
            if(i == 0 && nval > s[i]-'0')   break;
            int less = (i==0&&nval==s[i]-'0' ? 0 : 1);
            for(int dec = 0; dec < 2; dec++){
                dp[less][dec][i+1][nval%m][nval]++;
            }
        }
    }
    int ret = 0;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 10; k++){
                (ret += dp[i][j][n][0][k]) %= mod;
            }
        }
    }
    int ma = 9;
    if(s.length() == 1) ma = stoi(s);
    for(int i = 1; i <= ma; i++){
        if(i%m == 0)    ret--;
    }
    ret = (ret + mod) % mod;
    return ret;
}

int main(){
    string a, b;
    cin >> a >> b;
    int m;
    cin >> m;
    for(int i = a.length()-1; i >= 0; i--){
        if(a[i] != '0'){
            a[i]--;
            break;
        }else{
            a[i] = '9';
        }
    }
    reverse(a.begin(), a.end());
    while(a.size() > 1 && a.back() == '0')  a.pop_back();
    reverse(a.begin(), a.end());
    cout << (calc(b,m)-calc(a,m)+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 42284
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
v = iil()
c = iil()
cal = zip(v,c)
ans = 0
for i in cal:
    ans += max(0,i[0]-i[1])
print(ans)

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    vi h(n);
    rep(i, n) {
        std::cin >> h[i];
    }
    bool ok = true;
    for (int i = n-2; i > 0; i--) {
        if (h[i+1] >= h[i]) continue;
        if(h[i]-h[i+1] > 1) ok = false;
        h[i] = h[i+1];
    }
    std::cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 640
#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>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		int a; cin >> a;
		ans += a;
	}
	ans -= n;
	cout << ans << endl;
	return 0;
}

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

int main(){
  long long int n, a, b;
  cin >> n >> a >> b;
  long long int ans = n / (a + b) * a;
  long long int rem = n % (a + b);
  ans += min(rem, a);
  cout << ans << endl;
  return 0;
}


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

#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

ll head_tail_num[10][10] = {};

int main() {
  int n;
  cin >> n;
  int num = n;
  int d = 0;
  int maxbit;
  while (num != 0) {
    maxbit = num;
    num /= 10;
    d++;
  }
  ll cnt = 0LL;
  int ten=1, tmpmax, tmpmin;
  rep2(i, 1, d+1){
      int lim = min(ten*10, n+1);
      rep2(j, ten, lim){
        //   cout << j << endl;
          tmpmax = j / ten;
          tmpmin = j % 10;
          head_tail_num[tmpmax][tmpmin]++;
      }
      ten*=10;
  }
  rep2(i, 1, 10){
    rep2(j, 1, 10) { 
      cnt += head_tail_num[i][j] * head_tail_num[j][i]; 
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3616
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int[] a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		System.out.println(a[ni() - 1]);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
import java.util.HashMap;
import java.util.Map;

public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);

    int[] b = new int[n];
    int[] c = new int[n];
    for (int i = 0; i < n; i++) {
      b[i] = a[i] - i;
      c[i] = a[i] + i;
    }

    Map<Integer, Integer> cnt = new HashMap<>();
    long ret = 0;
    for (int i = 0; i < n; i++) {
      if (cnt.containsKey(-b[i])) {
        ret += cnt.get(-b[i]);
      }
      cnt.putIfAbsent(c[i], 0);
      cnt.put(c[i], cnt.get(c[i]) + 1);
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 67084
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;

// 遅延評価セグメント木をソラで書きたいあなたに
// http://tsutaj.hatenablog.com/entry/2017/03/30/224339
//　区間に対して更新が必要な時に用いる

struct LazySegmentTree {
  private:
    int n;
    vector<ll> node, lazy;

  public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        // node
        node.resize(2 * n - 1);
        //遅延評価用
        lazy.resize(2 * n - 1, 0);

        for(int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = node[i * 2 + 1] + node[i * 2 + 2];
        }
    }

    // k番目のノードについて遅延評価を行う
    //ノードの示す範囲をlとrでもつ
    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            //下のノードに伝搬させる
            if(r - l > 1) {
                lazy[2 * k + 1] += lazy[k] / 2;
                lazy[2 * k + 2] += lazy[k] / 2;
            }
            // 伝播が終わったので，自ノードの遅延配列を空にする
            lazy[k] = 0;
        }
    }

    //区間にたいするadd
    //したから上がってくる
    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if(r < 0) {
            r = n;
        }
        // k番目のノードに対して遅延評価を行う
        eval(k, l, r);
        if(b <= l || r <= a) {
            //[a, b) と[l, r)がdisjoint
            return;
        }
        if(a <= l and r <= b) {
            //[l,r] \subset [a, b)
            lazy[k] += (r - l) * x;
            //ここでの遅延評価本当に必要なのか？
            eval(k, l, r);
        }
        //子供ノードの値を再帰的に計算する
        else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
        if(r < 0) {
            r = n;
        }
        if(b <= l || r <= a) {
            return 0;
        }
        eval(k, l, r);
        if(a <= l and r <= b) {
            //[l,r) \subset [a, b)
            return node[k];
        }
        ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    LazySegmentTree seg(vector<ll>(N, 0));
    for(int i = 0; i < Q; i++) {
        int query;
        cin >> query;
        if(query == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            seg.add(s - 1, t, x);
        } else {
            int s, t;
            cin >> s >> t;
            cout << seg.getsum(s - 1, t) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7496
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define ll int64_t
#define all(v) (v).begin(),(v).end()
#define P pair<int,int>
using namespace std;

int main() {
    int a,b; cin>>a>>b;
    int ans=a-2*b;
    if(ans>=0) cout<<ans<<endl;
    else cout<<0<<endl;
    return 0;
}

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

string range(int a, int b, int c) {
    if (a < b && b < c)
        return "Yes";
    else
        return "No";
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << range(a, b, c) << endl;
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << "A" << s2.at(0) << "C" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	int a = n/1000;
	int b= (n/100)%10;
	int c= (n/10)%10;
	int d= (n)%10;
	if(a+b+c+d==7){
		cout << a <<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout << a <<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout << a <<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout << a <<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout << a <<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout << a <<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout << a <<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout << a <<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    
    int[][] weights = new int[n][3];
    
    for (int i = 0; i < n; i++) {
      	for (int j = 0; j < 3; j++) {
          	weights[i][j] = scan.nextInt();
        }
    }
    scan.close();

    int result = solve(n, weights);
    System.out.println(result);
  }
  
  private static int solve(int n, int[][] weights){
    int[][] dp = new int[n][3];
    
    dp[0] = weights[0];
    for (int i = 1; i < n; i++) {
      	for (int j = 0; j < 3; j++) {
    		List<Integer> idx = new ArrayList<>(Arrays.asList(0, 1, 2));
          	idx.remove(j);
          	
          	dp[i][j] = Math.max(dp[i - 1][idx.get(0)] + weights[i][j],
                dp[i - 1][idx.get(1)] + weights[i][j]);
        }
    }
    return Math.max(dp[n-1][0], Math.max(dp[n-1][1],dp[n-1][2]));
  }
}

Measured memory_bytes: 101652
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
	
	int a,b[1001],c[1001],d[1001],e[1001],l[1001];
	int f,g,h,k,flg;
	
	cin >> a;
	
	while(a!=0){
	
		flg=0;
		
		for(int i=0;i<a;i++) cin >> b[i] >> c[i] >> d[i] >> e[i];
		
		cin >> f >> g >> h >> k;
		
		for(int i=0;i<a;i++){
			l[i]=(c[i]*4)+(d[i]*9)+(e[i]*4);
			if(c[i]<=f && d[i]<=g && e[i]<=h){
				if(k>=l[i]){
					printf("%d\n",b[i]);
					flg=1;
				}
			}
		}
		
		if(flg==0) printf("NA\n");
		
			cin >> a;
		
	}
	return 0;
}

Measured memory_bytes: 1164