akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>
#include <future>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


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



int main() {
    srand(1231);


#ifdef LOCAL
	//gen();
	//return 0;
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

	//ofstream out("a.out");
	
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans ^= x;
	}
	if (ans & 1) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}

	
	
    return 0;
}


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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.14159265358979323846;

int R;

int main(void)
{
    cin >> R;
    
    cout << fixed << setprecision(16) << 2 * R * PI << endl;
    return 0;
}

Measured memory_bytes: 3720
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int A, B, K;
	int  A_div, B_div = 0;
	int i, j;
	int ans[104] = {};
	int res = 0;
	cin >> A >> B >> K;
	
	for (i = 1; i < 104; ++i) {
		A_div = A % i;
		B_div = B % i;
		if (A_div==0&&B_div==0) {
			ans[res] = i;
			++res;
			//cout << i << endl;
		}

	}

	cout << ans[res - K] << endl;




}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string A,B; cin >> A >> B;
  string ans = "EQUAL";
  int a_size = A.size();
  int b_size = B.size();
  if(a_size > b_size) {
    ans = "GREATER";
  } else if (a_size < b_size) {
    ans = "LESS";
  } else {
    for(int i = 0; i < a_size; i++) {
      if(A[i] > B[i]) {
        ans = "GREATER"; break;
      } else if (A[i] < B[i]) {
        ans = "LESS"; break;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char *argv[])
{
	char a[100];
	int x,y,s=1;
	scanf("%d %d",&x,&y);
	scanf("%s",a);
	int len=strlen(a);
	if(len==x+y+1&&a[x]=='-')
	{
	    for(int i=0;i<len;i++)
		{
		if(i==x)
			continue;
			if(a[i]=='-')
			{
				s=0;
				break;
			}
		
			
	
			
		}	
		if(s==1)
		printf("Yes\n");
		else
		printf("No\n");
	}
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[n - 1 - i];
    for(int i = 0; i < n; i++){
        cout << a[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
int main()
{
  char S[100];
  int i,num,len;
  scanf("%s",&S);
  len=strlen(S);
  num=0;
  for(i=0;i<=len/2-1;i++)
    {
      if(S[i]!=S[len-i-1])
      {
        num=num+1;
      }
    }
  printf("%d",num);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a<b && b<c){
        	System.out.println("Yes");
        }
        else
		System.out.println("No");

	}

}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


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

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

const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int i){
    if (n < i) return 0;
    if (n < 0 || i < 0) return 0;
    return fac[n] * (finv[i] * finv[n - i] % mod) % mod;
}
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    int n;
    cin>>n;
    long long ans[n+1]={};
    bool used[n+1]={};
    map<int,int> m;
    pair<int,int> p;
    
    for(int i=0;i<=n;i++){
        int a;
        cin>>a;
        if(used[a]){
            p = make_pair(m[a],i);
        }
        m[a]=i;
        used[a]=1;
    }
    COMinit();
    int a=p.first,b=p.second;
    for(int i=1;i<=n+1;i++){
        if(i==1){
            cout<<n<<endl;
            continue;
        }
        if(i==n+1){
            cout<<1<<endl;
            continue;
        }
        long long ans = COM(n+1,i) - COM(a+n-b,i-1);
        ans += mod;
        ans %= mod;
        
        cout<<ans<<endl;

    }

}

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

int f(string a, string b) {
 int n = (int) a.size();
 int ans = 0;
 for(int i = 0; i < n; i++) {
  ans += (a[i] != b[i]);
 }
 return ans;
}

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 string a, b;
 cin >> a >> b;
 int n1 = (int) a.size();
 int n2 = (int) b.size();
 int ans = n2;
 for(int i = 0; i <= n1-n2; i++) {
  ans = min(ans, f(a.substr(i, n2), b));
 }
 cout << ans << '\n';
 return 0;
}


Measured memory_bytes: 3616
N,A,B=map(int,input().split())
counter=0
for i in range(N):
  n=str(i+1)
  s=len(n)
  n_total=0
  for t in range(s):
    n_total+=int(n[t])
  if A<= n_total <=B:
    counter+=int(i+1)
print(counter)

Measured memory_bytes: 3060
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n) for(int i = 1; i < n; ++i)

int main(void) {
  int n, i, j;
  scanf("%d", &n);
  int a[n];
  rep(i, n)scanf("%d", &a[i]);
  repi(i, n) {
    rep(j, n) {
      if(j) printf(" %d", a[j]);
      else printf("%d", a[j]);
    }
    printf("\n");
    int v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      --j;
    }
    a[j + 1] = v;
  }
  rep(j, n) {
    if(j) printf(" %d", a[j]);
    else printf("%d", a[j]);
  }
    printf("\n");
  return 0;
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()

int read(){
	int a = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c)){f = c == '-'; c = getchar();}
	while(isdigit(c)){
		a = a * 10 + c - 48; c = getchar();
	}
	return f ? -a : a;
}

#define ll long long
struct node{int plc , val , l , r;};
struct cmp1{bool operator ()(node a , node b){return a.plc < b.plc;}};
struct cmp2{bool operator ()(node a , node b){return a.val < b.val || a.val == b.val && a.plc < b.plc;}};
set < node , cmp1 > N1; set < node , cmp2 > N2;
int N , L; ll ans;

ll calc(vector < node > &cur){
	ll sum = 0 , all = 0;
	for(int i = 0 ; i + L - 1 < sz(cur) ; ++i){
		sum += cur[i].l;
		all += sum * cur[i + L - 1].r;
	}
	return all;
}

int main(){
	N = read(); L = read();
	for(int i = 1 ; i <= N ; ++i){
		node now; now.plc = i; now.val = read(); now.l = now.r = 1;
		N1.insert(now); N2.insert(now);
	}
	while(!N2.empty()){
		int val = N2.begin()->val; vector < node > mn;
		while(N2.begin()->val == val){mn.push_back(*N2.begin()); N2.erase(*N2.begin());}
		for(int i = 0 , pi = 1 ; i < sz(mn) ; i = pi , pi = i + 1){
			while(pi < sz(mn) && ++N1.find(mn[pi - 1]) == N1.find(mn[pi])) ++pi;
			vector < node > tmp; tmp.insert(tmp.end() , mn.begin() + i , mn.begin() + pi);
			int len = pi - i , cnt = len / L;
			if(cnt){
				ans += calc(tmp); vector < node > ntmp;
				for(auto t : tmp) N1.erase(t);
				for(int j = 0 ; j < cnt ; ++j) ntmp.push_back((node){tmp[0].plc + j , val + 1 , 0 , 0});
				for(int j = 0 ; j + L - 1 < sz(tmp) ; ++j) ntmp[cnt - (sz(tmp) - j) / L].l += tmp[j].l;
				for(int j = L - 1 ; j < sz(tmp) ; ++j) ntmp[(j + 1) / L - 1].r += tmp[j].r;
				ans -= calc(ntmp);
				for(auto t : ntmp){N1.insert(t); N2.insert(t);}
			}
		}
	}
	cout << ans + N;
	return 0;
}


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

using namespace std;

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

    vector<int> a(A), b(B);
    for (int i = 0; i < A; ++i) cin >> a[i];
    for (int i = 0; i < B; ++i) cin >> b[i];

    int mina = INT_MAX;
    for (int i = 0; i < A; ++i)
        mina = min(mina, a[i]);

    int minb = INT_MAX;
    for (int i = 0; i < B; ++i)
        minb = min(minb, b[i]);

    int ans = mina + minb;
    int x, y, c;
    for (int i = 0; i < M; ++i) {
        cin >> x >> y >> c;
        x -= 1;
        y -= 1;
        int tmp = a[x] + b[y] - c;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(){
  string num;

  char op[3];
  cin >> num;
  string sumStr;
  int sum;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 2; k++){
        sum = num[0] - '0';
        sumStr = "";
        sumStr = sumStr + num[0];
        if(i == 0){
          sum += num[1] - '0';
          op[0] = '+';
        }
        else {
          sum -= num[1] - '0';
          op[0] = '-';
        }
        if(j == 0){
          sum += num[2] - '0';
          op[1] = '+';
        }
        else {
          sum -= num[2] - '0';
          op[1] = '-';
        }
        if(k == 0){
          sum += num[3] - '0';
          op[2] = '+';
        }
        else {
          sum -= num[3] - '0';
          op[2] = '-';
        }
        if(sum == 7){
          for(int x = 0; x < 3; x++) cout << num[x] << op[x];
          cout << num[3] <<"=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	long long sum = 0;
	for(int i = 0; i < n; i++) cin >> a[i], sum += a[i];
	long long ans = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
	for(int i = 0; i < n - 1; i++) sum -= 2 * a[i], ans = min(ans, llabs(sum));
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    double ans = 0.0;
    while (n--){
        double x;
        string s;
        cin >> x >> s;
        if (s == "JPY") ans += x;
        else ans += 380000.0 * x;
    }
    printf("%.15f\n", ans);
    return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 205;
const int maxk = 60;

ll a[maxn];
ll b[maxn];
int n;
char s[maxn];

void solve()
{
	scanf("%d", &n);
	for (int i =0; i < n; i++) scanf("%lld", &a[i]);
	reverse(a, a + n);
	scanf("%s", s);
	reverse(s, s + n);
	for (int i = 0; i < maxk; i++) b[i] = -1;
	bool onewins = false;
	for (int i = 0; i < n; i++)
	{
		ll cur = a[i];
		for (int j = 0; j < maxk; j++) if (cur & (1LL << j))
		{
			if (b[j] == -1)
			{
				b[j] = cur;
				break;
			} else cur ^= b[j];
		}
		//cout << s[i] << ' ' << cur << endl;
		if (s[i] == '1' && cur != 0)
		{
			onewins = true;
			break;
		}
	}
	printf("%d\n", (int)onewins);
}

int main()
{
	int NT;
	scanf("%d", &NT);
	for (int T =0 ; T < NT; T++)
	{
		solve();
	}
    return 0;
}


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

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


int main() {
	int k,sum=0;
cin>>k;
	for(int a=1;a<=k;a++){
		for(int b=1;b<=k;b++){
			for(int c=1;c<=k;c++){
				sum+=gcd(c,gcd(a,b));
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main(){
	int k,x;
	cin >> k >> x;
	memset(a,0,sizeof(a));
	int maxn=x+k-1;
	int minn=x-k+1;
	int len=maxn-minn;
	int t=minn;
	for(int i=0;i<=len;i++){
		a[i]=t++;
	}
	for(int i=0;i<=len;i++){
		cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

ll to_N[NUM+1],from_1[NUM+1],ans[NUM+1];


int main(){

	ll N;
	scanf("%lld",&N);

	to_N[N] = 0;
	//右端にかけてのクエリを投げる<ans[left]より右にある小さい数の個数>
	for(ll left = N-1; left >= 1; left--){
		printf("? %lld %lld\n",left,N); fflush(stdout);
		scanf("%lld",&to_N[left]);
	}

	from_1[1] = 0;
	//左端からのクエリを投げる
	for(int right = 2; right <= N; right++){
		printf("? 1 %d\n",right); fflush(stdout);
		scanf("%lld",&from_1[right]);
	}

	ans[1] = to_N[1]-to_N[2]+1;	 //自分の右にある、自分より小さい数の個数+1
	for(int i = 2; i <= N-1; i++){
		ans[i] = (to_N[i]-to_N[i+1])+((ll)i-(from_1[i]-from_1[i-1]+1))+1; //自分の右にある、自分より小さい数の個数+自分の左にある、自分より小さい数の個数+1
	}
	ans[N] = N-(from_1[N]-from_1[N-1]+1)+1;

	printf("!");
	for(int i = 1; i <=N; i++)printf(" %lld",ans[i]);
	printf("\n");

	return 0;
}



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

int main() {
    int N, ans;
    string S;
    cin >> N >> S;
    ans = 0;

    for (int i = 0; i < N - 2; i++) {
        if(S.at(i) != 'A') {
            continue;
        }
        else if(S.at(i+1) != 'B') {
            continue;
        }
        else if(S.at(i+2) != 'C') {
            continue;
        }
        ans++;

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

long long int dp[3010][3010];

int main(){
  long long int N, T, tmp1, tmp2;
  std::vector<std::pair<long long int, long long int> > meal;
  
  scanf("%lld%lld", &N, &T);
  for(long long int i = 0; i < N; i++){
    scanf("%lld%lld", &tmp1, &tmp2);
    meal.push_back(std::make_pair(tmp1, tmp2));
  }
  
  std::sort(meal.begin(), meal.end());
  
  for(long long int t = 0; t < T; t++){
    dp[0][t] = 0;
  }
  long long int ans = 0;
  for(long long int i = 0; i < N; i++){
    for(long long int t = 0; t < meal[i].first; t++)dp[i+1][t]=dp[i][t];
    for(long long int t = meal[i].first; t < T; t++){
      dp[i+1][t] = std::max(dp[i][t-meal[i].first] + meal[i].second, dp[i][t]);
    }
    ans = std::max(ans, dp[i][T-1]+meal[i].second);
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 70912
//
//AtCoder Beginner Contest `136
//A - Transfer
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c-(a-b);
    if (ans<0) ans = 0;

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


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    vector<vector<int>> dp(N+1, vector<int>(N+1, 0));
    for(int i=N-1;i>=0;i--){
        for(int j=N-1;j>i;j--){
            if(S[i] == S[j]){
                dp[i][j] = max(dp[i][j], dp[i+1][j+1]+1);
            }
            res = max(res, min(dp[i][j], j-i));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 98176
/*
 *  I wish I could travel by the road that crosses baby's mind,
 *  And out beyond all bounds;
 *  Where messengers run errands for no cause
 *  between the kingdoms of kings of no history;
 *  Where Reason makes kites of her laws and flies them,
 *  And Truth sets Fact free from its fetters.
 *                                           Rabindranath Tagore
 */
 
#include <bits/stdc++.h>
using namespace std;
 
#ifndef ORZ_EVERYBODY_BUT_ME
#define ORZ_EVERYBODY_BUT_ME
#endif
 
typedef long long ll;
 
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
 
void work() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    bool ok;
    if (B > A) {
        ok = false;
    } else {
        A %= B;
        ll g = gcd(B, D);
        ok = A % g + D >= B && C >= (A % g ? A + (B - A) / g * g : B - g);
    }
    puts(ok ? "Yes" : "No");
}
 
int main() {
    int n;
    cin >> n;
    while (n--) work();
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    while(cin >> n, n){
	int len[] = {5, 7, 5, 7, 7};
	string w[44];
	for(int i = 0; i < n; i++) cin >> w[i];
	int ans = 0;
	for(int i = 0; i < n; i++){
	    int cnt = 0, idx = 0;
	    for(int j = i; j < n; j++){
		cnt += w[j].size();
		if(cnt == len[idx]){
		    cnt = 0, idx++;
		    if(idx == 5) break;
		}else if(cnt > len[idx]){ idx = -1; break;}
	    }
	    if(idx == 5){ ans = i; break;}
	}
	cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ipa pair<lld,lld>
#define lld long long int
#define x first
#define y second
#define ld long double
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI (atan(1)*4)
#define mp make_pair
#define mlog 21
#define mod 1000000000
using namespace std;
const int maxn=1e6+2;
main()
{
	fastread;
	lld i,j,n;
	cin>>n;
	double arr[n+1],dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;++i)
		cin>>arr[i];

	dp[1][0]=arr[0];
	dp[1][1]=(1-arr[0]);
	for(i=2;i<=n;++i)
	{
		for(j=0;j<=i;++j)
		{
			if(j==0)
				dp[i][j]=dp[i-1][j]*arr[i-1];
			else
			dp[i][j]=dp[i-1][j]*arr[i-1]+dp[i-1][j-1]*(1-arr[i-1]);
		//cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
		}
	}
	double ans=0;
	for(i=0;i<=n/2;++i)
	{
		ans+=dp[n][i];
	}
	if(n%2==0)
		ans-=dp[n][n/2];
	printf("%.9f",ans);
}

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	map<int, int> m;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		m[a - 1]++; m[a + 1]++;
		m[a]++;
	}
	int ans = 0;
	for (auto it : m)ans = max(it.second, ans);
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 7944
x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


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

struct Edge {
    int to;
    int c;
    long long d;
    Edge() {}
    Edge(int t, int c, long long d) : to(t), c(c), d(d) {}
};
using Graph = vector<vector<Edge>>;

struct LCA {
    vector<vector<int> > parent; // parent[d][v] := 2^d-th parent of v
    vector<int> depth;
    LCA() { }
    LCA(const Graph &G, int r = 0) { init(G, r); }
    void init(const Graph &G, int r = 0) {
        int V = (int)G.size();
        int h = 1;
        while ((1<<h) < V) ++h;
        parent.assign(h, vector<int>(V, -1));
        depth.assign(V, -1);
        dfs(G, r, -1, 0);
        for (int i = 0; i+1 < (int)parent.size(); ++i)
            for (int v = 0; v < V; ++v)
                if (parent[i][v] != -1)
                    parent[i+1][v] = parent[i][parent[i][v]];
    }
    void dfs(const Graph &G, int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (auto e : G[v]) if (e.to != p) dfs(G, e.to, v, d+1);
    }
    int get(int u, int v) {
        if (depth[u] > depth[v]) swap(u, v);
        for (int i = 0; i < (int)parent.size(); ++i)
            if ( (depth[v] - depth[u]) & (1<<i) )
                v = parent[i][v];
        if (u == v) return u;
        for (int i = (int)parent.size()-1; i >= 0; --i) {
            if (parent[i][u] != parent[i][v]) {
                u = parent[i][u];
                v = parent[i][v];
            }
        }
        return parent[0][u];
    }
};

int N, Q;
Graph G;

struct Query {
    int id;
    int c;
    long long d;
    Query() {}
    Query(int i, int c, long long d) : id(i), c(c), d(d) {}
};

vector<vector<Query>> ps, ms;
void rec(int v, int p, long long all, vector<long long> &res, vector<long long> &cnum, vector<long long> &call) {
    for (auto q : ps[v]) res[q.id] += all - call[q.c] + cnum[q.c] * q.d;
    for (auto q : ms[v]) res[q.id] -= (all - call[q.c] + cnum[q.c] * q.d) * 2;
    for (auto e : G[v]) {
        if (e.to == p) continue;
        cnum[e.c]++, call[e.c] += e.d;
        rec(e.to, v, all+e.d, res, cnum, call);
        cnum[e.c]--, call[e.c] -= e.d;
    }
}

int main() {
    cin >> N >> Q;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int a, b, c; long long d; cin >> a >> b >> c >> d;
        --a, --b;
        G[a].push_back(Edge(b, c, d));
        G[b].push_back(Edge(a, c, d));
    }
    LCA lca(G);
    ps.assign(N, vector<Query>());
    ms = ps;
    for (int q = 0; q < Q; ++q) {
        int c, d, u, v; cin >> c >> d >> u >> v;
        --u, --v;
        int l = lca.get(u, v);
        ps[u].push_back(Query(q, c, d));
        ps[v].push_back(Query(q, c, d));
        ms[l].push_back(Query(q, c, d));
    }
    vector<long long> res(Q, 0), cnum(N, 0), call(N, 0);
    rec(0, -1, 0, res, cnum, call);
    for (auto r : res) cout << r << endl;
}


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

int main()
{
	int N;
	cin >> N;
	vector<string> S( N );
	for( int i = 0; i < N; i++ ) {
		cin >> S[i];
	}

	vector<vector<int>> g( N );
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( S[i][j] == '1' ) {
				g[i].push_back( j );
				g[j].push_back( i );
			}
		}
	}
	vector<int> color( N );

	auto dfs = [&]( auto dfs, int v, int c ) -> bool
	{
		color[v] = c;
		for( int e : g[v] ) {
			if( color[e] == color[v] ) {
				return false;
			}
			else if( color[e] == 0 && dfs( dfs, e, -c ) == false ) return false;
		}
		return true;
	};
	if( dfs( dfs, 0, 1 ) == false ) {
		cout << -1 << endl;
		return 0;
	}
	const int INF = 201;
	vector<vector<int>> mat( N, vector<int>( N, INF ) );
	for( int i = 0; i < N; i++ ) mat[i][i] = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( S[i][j] == '1' ) {
				mat[i][j] = 1;
				mat[j][i] = 1;
			}
		}
	}
	int ans = 0;
	for( int k = 0; k < N; k++ ) {
		for( int i = 0; i < N; i++ ) {
			for( int j = 0; j < N; j++ ) {
				mat[i][j] = min( mat[i][j], mat[i][k] + mat[k][j] );
			}
		}
	}
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( mat[i][j] == INF ) continue;
			ans = max( ans, mat[i][j] );
		}
	}
	ans++;

	cout << ans << endl;
}


Measured memory_bytes: 4100
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder.ABC141
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();

            switch(s)
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    return;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    return;
                default:
                    Console.WriteLine("Sunny");
                    return;
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> V(n + 1), W(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> V[i] >> W[i];
    }
    lint q;
    cin >> q;
    vector<lint> v(q), l(q);
    lint L = 0;
    for (int i = 0; i < q; ++i) {
        cin >> v[i] >> l[i];
        chmax(L, l[i]);
    }
    int up = min(1LL << 9, n + 1);
    vector<vector<lint>> dp(up, vector<lint>(L + 1, 0));
    for (int i = 1; i < up; ++i) {
        int p = i / 2;
        for (int j = 0; j <= L; ++j) {
            chmax(dp[i][j], dp[p][j]);
            if (j - W[i] >= 0)
                chmax(dp[i][j], dp[p][j - W[i]] + V[i]);
        }
    }
    for (int i = 1; i < up; ++i) {
        for (int j = 1; j <= L; ++j) {
            chmax(dp[i][j], dp[i][j - 1]);
        }
    }
    for (int i = 0; i < q; ++i) {
        if (v[i] < (up)) {
            cout << dp[v[i]][l[i]] << "\n";
        } else {
            vector<lint> vv, ww;
            lint c = v[i];
            while (c >= (up)) {
                vv.push_back(V[c]);
                ww.push_back(W[c]);
                c /= 2;
            }
            int k    = vv.size();
            lint ret = 0;
            for (int j = 0; j < 1 << k; ++j) {
                lint vs = 0;
                lint ws = 0;
                for (int x = 0; x < k; ++x) {
                    if (j >> x & 1) {
                        vs += vv[x];
                        ws += ww[x];
                    }
                }
                if (ws <= l[i]) {
                    chmax(ret, vs + dp[c][l[i] - ws]);
                }
            }
            cout << ret << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 411080
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    H, N = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    a_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # a_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    s = sum(a_list)

    if s >= H:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10 3
4 5 6"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 3
4 5 6"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """210 5
31 41 59 26 53"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """211 5
31 41 59 26 53"""
        output = """No"""
        self.assertIO(input, output)


Measured memory_bytes: 14736
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
const int64_t mod=1e9+7;

int main(){
    int N;
    cin>>N;
    int A[100010]={};
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        A[x]++;
    }
    int64_t res=1;
    for(int i=0;i<N/2;i++){
        res = res*2%mod;
    }
    bool flag = true;
    if(N%2==0){
        for(int i=1;i<=N-1;i+=2){
            if(A[i]!=2){
                flag=false;
                break;
            }
        }
    }else{
        for(int i=2;i<=N-1;i+=2){
            if(A[i]!=2){
                flag=false;
                break;
            }
        }
        if(A[0]!=1){
            flag=false;
        }
    }
    if(flag){
        cout<<res<<endl;
    }else{
        cout<<0<<endl;
    }
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int a,b;
              cin >> a >> b;//.at(0) >> s.at(1) >> s.at(2) >> s.at(3);
              //sort(s.begin(),s.end());
              
              //for(int i=0; i<6; i++)
              //if(s.at(i)=='1') ans++;
              cout << a-b+1 << endl;
              return 0;
            }

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int base[3] = {0, 0, 0};

void Hit()
{
	if (base[2] == 1)
	{
		base[2] = 0;
	}
	if (base[1] == 1)
	{
		base[2] = 1;
	}
	if (base[0] == 1)
	{
		base[1] = 1;
	}
	else if (base[0] == 0)
	{
		base[0] = 1;
	}

}

void Homerun()
{
	for (int i = 0; i < 3; i++)
	{
		base[i] = 0;
	}
	
}

int main()
{
	int out = 0;
    int score = 0;
	int n;
	string s;
    vector <string> event;
	int eventnum = 0;

	cin >> n;
	int a = 0;
	for (int i = 0; i < 3 * n; i++)
	{
		while (true)
		{
			cin >> s;
			event.push_back(s);
			if (event.at(a) == "OUT")
			{
				a += 1;			
				eventnum += 1;
				break;
			}
			else
			{
				a += 1;
				eventnum += 1;
			}

		}
	}

	for (int i = 0; i < eventnum; i++)
	{
		if (event.at(i) == "HIT")
		{
			if (base[2] == 1)
			{
				score += 1;
			}
			Hit();
		}
		else if (event.at(i) == "HOMERUN")
		{
			score += base[0] + base[1] + base[2] + 1;
			Homerun();
		}
		else
		{
			out += 1;
			if (out == 3)
			{
				cout << score << endl;
				for (int i = 0; i < 3; i++)
				{
					base[i] = 0;
				}
				score = 0;
				out = 0;
			}
		}
	}

	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 592
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*(n+1));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  int cnt=0;
  for(i=1;i<=n;i++) if(a[i]>i && a[a[i]]==i) cnt++;
  printf("%d\n",cnt);
}

int main(void){
  run();
  return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    vector<int> res;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    rep(i, n - 1) {
        if (h[i] >= h[i + 1]) {
            cnt++;
        } else {
            res.push_back(cnt);
            cnt = 0;
        }
    }
    res.push_back(cnt);
    sort(res.begin(), res.end());
    cout << res.back() << endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
	cin>>a>>b;
	if(a.size()>b.size())cout<<"GREATER"<<"\n";
	else if(a.size()<b.size())cout<<"LESS"<<"\n";
	else if(a>b)cout<<"GREATER"<<"\n";
	else if(a<b)cout<<"LESS"<<"\n";
	else cout<<"EQUAL"<<"\n";
	return 0;
}

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

int main() {
	int a,b;
	char o;
	while (true){
		cin>> a >> o >> b;
		if (o == '?') break;
		else if (o == '+') {cout<< a+b <<endl;}
		else if (o == '-') {cout<< a-b <<endl;}
		else if (o == '*') {cout<< a*b <<endl;}
		else if (o == '/') {cout<< a/b <<endl;}
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmin(x,y) x=min(x,y)

int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> V(n);
    rep(i,n) cin>>V[i];
    int ans=0;
    //Aをl回、Bをr回行った後、小さいほうから
    //0より小さいものをk-l-r個まで戻す
    rep(l,n+1) rep(r,n+1){
        if(l+r>n || l+r>k) continue;
        vector<int> temp;
        int sum=0;
        rep(i,l) temp.push_back(V[i]), sum+=V[i];
        rep(i,r) temp.push_back(V[n-1-i]), sum+=V[n-1-i];
        sort(temp.begin(),temp.end());
        int m=temp.size();
        //itrにtempのうち0より小さいものの個数を代入
        auto itr=lower_bound(temp.begin(),temp.end(),0)-temp.begin();
        /*cout<<l<<" "<<r<<" "<<itr<<" "<<sum<<endl;
        rep(i,m) cout<<temp[i]<<" ";
        cout<<endl;*/
        if(itr>k-l-r) itr=k-l-r;
        rep(i,itr) sum-=temp[i];
        //cout<<sum<<endl<<endl;
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    int a[11][11],b[10]={},c[10]={},d=0;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	cin>>a[i][j];
    
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	b[i]+=a[i][j];
	c[i]+=a[j][i];
      }
    for(int i=0;i<n;i++)
      d+=b[i];
    for(int i=0;i<n+1;i++){
      a[i][n]=b[i];
      a[n][i]=c[i];
      a[n][n]=d;
    }
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1;j++)
	printf("%5d",a[i][j]);
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <unordered_map>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    vector<int> h(n),e(n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    e[0]=0;
    e[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        e[i]=min(e[i-1]+abs(h[i-1]-h[i]),e[i-2]+abs(h[i-2]-h[i]));
    }
    printf("%d",e[n-1]);
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	vector<vint> g(N), rg(N);
	vint p(N);
	vint grundy(N, 0);
	vector<bool> notloop(N);
	vint in(N, 0);

	for (int i = 0; i < N; i++) {
		cin >> p[i]; --p[i];
		g[p[i]].push_back(i);
		rg[i].push_back(p[i]);
		in[p[i]]++;
	}

	queue<int> que;
	for (int i = 0; i < N; i++) if (in[i] == 0) que.push(i);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		notloop[u] = true;
		set<int> st;
		for (auto &to : g[u]) st.insert(grundy[to]);
		while (st.count(grundy[u])) grundy[u]++;
		for (auto &r : rg[u]) if (--in[r] == 0) que.push(r);
	}
	
	int s;
	for (int i = 0; i < N; i++) if (!notloop[i]) { s = i; break; }

	vector<int> tr;
	{
		set<int> st;
		for (auto &to : g[s]) if (notloop[to]) st.insert(grundy[to]);
		while (st.count(grundy[s])) grundy[s]++;
		tr.push_back(grundy[s]);
		grundy[s]++;
		while (st.count(grundy[s])) grundy[s]++;
		tr.push_back(grundy[s]);
	}

	for (auto &x : tr) {
		vector<bool> used = notloop;
		vint gr = grundy, in2 = in;
		gr[s] = x;

		used[s] = true;
		int u = s;
		for (auto &r : rg[s]) if (!used[r] && --in2[r] == 0) { u = r; break; }
		while (!used[u]) {
			used[u] = true;
			set<int> st;
			for (auto &to : g[u]) if (used[to]) st.insert(gr[to]);
			while (st.count(gr[u])) gr[u]++;
			for (auto &r : rg[u]) if (!used[r] && --in2[r] == 0) { u = r; break; }
		}
		set<int> st;
		int v = 0;
		for (auto &to : g[s]) st.insert(gr[to]);
		while (st.count(v)) v++;
		if (v == gr[s]) {
			cout << "POSSIBLE" << endl;
			return (0);
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return (0);
}


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

int main(){
  string w;
  vector<int> v(30,0);
  cin>>w;
  for(int i=0;i<w.length();i++){
    v[w[i]-'a']++;
  }
  bool flag=true;
  for(int i=0;i<30;i++){
    if(v[i]%2==1){
      flag=false;
      break;
    }
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    double N; cin >> N;
    pt(N * 2 * 3.1415);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repr(i, n) for(int i = int(n) - 1; i >= 0; i--)

struct road{
    int to, num;
};

vector<vector<road>> roads;
vector<int> number, movable;
vector<bool> is_bridge;

int num = 0;

void lowlink_dfs(int at, int back){
    number[at] = movable[at] = num;
    num++;
    for(road e: roads[at]){
        if(e.to == back){
            continue;
        }
        if(number[e.to] == -1){
            lowlink_dfs(e.to, at);
        }
        movable[at] = min(movable[at], movable[e.to]);
        is_bridge[e.num] = (number[at] < movable[e.to]);
    }
}

vector<int> group;
int group_num = 0;

void grouping_dfs(int at){
    group[at] = group_num;
    for(road e: roads[at]){
        if(!is_bridge[e.num] && group[e.to] == -1){
            grouping_dfs(e.to);
        }
    }
}

vector<int> v_grouped;
vector<vector<int>> roads_grouped;
int ans = 0;

int most_valuable_path(int at, int back){
    vector<int> child_path;
    for(int to: roads_grouped[at]){
        if(to == back){
            continue;
        }
        child_path.push_back(most_valuable_path(to, at));
    }
    sort(all(child_path), greater<>());
    if(child_path.size() == 0){
        ans = max(ans, v_grouped[at]);
        return v_grouped[at];
    }
    if(child_path.size() == 1){
        ans = max(ans, v_grouped[at] + child_path[0]);
    }else{
        ans = max(ans, v_grouped[at] + child_path[0] + child_path[1]);
    }
    return v_grouped[at] + child_path[0];
}

int main(){
    int N, M;
    cin >> N >> M;
    int v[N];
    rep(i, N){
        cin >> v[i];
    }
    roads.resize(N);
    int s[M], t[M];
    rep(i, M){
        cin >> s[i] >> t[i];
        s[i]--, t[i]--;
        roads[s[i]].push_back({t[i], i});
        roads[t[i]].push_back({s[i], i});
    }
    number.resize(N, -1);
    movable.resize(N);
    is_bridge.resize(M);
    lowlink_dfs(0, -1);
    
    group.resize(N, -1);
    rep(i, N){
        if(group[i] == -1){
            grouping_dfs(i);
            group_num++;
        }
        //cout << group[i] << " ";
    }
    //cout << endl;
    
    v_grouped.resize(group_num, 0);
    roads_grouped.resize(group_num);
    rep(i, N){
        v_grouped[group[i]] += v[i];
    }
    rep(i, M){
        //cout << is_bridge[i];
        if(is_bridge[i]){
            int s2 = group[s[i]], t2 = group[t[i]];
            roads_grouped[s2].push_back(t2);
            roads_grouped[t2].push_back(s2);
        }
    }
    //cout << endl;
    most_valuable_path(0, -1);
    cout << ans << endl;
}



Measured memory_bytes: 25824