akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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



main(){
  int n,s,g;
  while(cin>>n>>s>>g,n|s|g){
    s=s/100*60+s%100;
    g=g/100*60+g%100;
    vector<PI> cha;
    rep(i,n){
      int t;
      cin>>t;
      while(t--){
	int ts,tg;
	cin>>ts>>tg;
	ts=ts/100*60+ts%100;
	tg=tg/100*60+tg%100;
	cha.pb(mp(ts,tg));
      }
    }
    int ans=0;
    int tlen=0;
    for(int i=s;i<g;i++){
      int cm=0;
      rep(j,cha.size())if(cha[j].F<=i && i<cha[j].S)cm++;

      if(cm<n)++tlen;
      else tlen=0;
      ans=max(ans,tlen);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,j,k,l,m,n,x=0,y=0;
    cin>>n;
    int a[n],b[n],c[n];
    int dp[n],ap[n],cp[n],as[n];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    
    
    ap[0]=a[0];
    cp[0]=b[0];
    as[0]=c[0];
     dp[0]=max(ap[0],cp[0]);
 dp[0]=max(dp[0],as[0]);
    for(i=1;i<n;i++){
        ap[i]=a[i]+max(cp[i-1],as[i-1]);
        cp[i]=b[i]+max(ap[i-1],as[i-1]);
        as[i]=c[i]+max(cp[i-1],ap[i-1]);
        
 dp[i]=max(ap[i],cp[i]);
 dp[i]=max(dp[i],as[i]);
    }
    
    cout<<dp[n-1]<<"\n";
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	set<int>d;
	for(int i=0;i<n;++i){
		int D; cin>>D;
		d.insert(D);
	}
	cout<<d.size()<<"\n"s;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null) {
                Console.WriteLine(Euclid(input.Split().Select(q => int.Parse(q)).ToArray()));
            }
        }
        public static int Euclid(int[] value)
        {
            int big = value[0] > value[1] ? value[0] : value[1];
            int small = value[0] > value[1] ? value[1] : value[0];
            int result = small;
            while(big % small != 0) {
                result = big % small;
                big = small;
                small = result;
            }
            return result;
        }
    }
}

Measured memory_bytes: 5912
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define MOD 1000000007
vector <int> prime;
bool is[1000001];
int cnt[1000001];
void gen(){
	for (int i=0; i<=1000000; i++) is[i]=true;
	is[0]=is[1]=false;
	for (int i=2; i<=1000000; i++){
		for (int j=i+i; j<=1000000; j+=i){
			is[j]=false;
		}
	}
	for (int i=2; i<=1000000; i++){
		if (is[i]==true) prime.push_back(i);
	}
}
int main(){
	gen();
	int a;
	cin>>a;
	int arr[a];
	for (int i=0; i<a; i++) cin>>arr[i];
	for (int i=0; i<a; i++){
		int cur=arr[i];
		for (int i=0; i<prime.size(); i++){
			if (cur%prime[i]==0){
				cur/=prime[i];
				cnt[prime[i]]++;
			}
			while (cur%prime[i]==0) cur/=prime[i];
			if (is[cur]==true){
				cnt[cur]++;
				break;
			}
			if (cur==1){
				break;
			}
		}
	}
	int key1=0, key2=0;
	for (int i=1; i<=1000000; i++){
		if (cnt[i]>=2) key1=1;
		if (cnt[i]==a) key2=1;
	}
	if (key1==0) cout<<"pairwise coprime\n";
	else if (key2==0) cout<<"setwise coprime\n";
	else cout<<"not coprime\n";
}

Measured memory_bytes: 12444
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    int n,k,a[102]={0},a1,b;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>a1;
        for(int j=0;j<a1;j++){
            cin>>b;
            a[b]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]==0)ans++;
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define all(v) (v).begin(), (v).end()
using namespace std;



std::vector<ll> v;
void solve()
{
    ll n;
    cin >> n;
    v.resize(n);
    for(auto &i : v) cin >> i;
    ll m=1000,x;
    for(int i=0;i+1<n;i++)
    {
        x=m/v[i];
        m+=max(x*(v[i+1]-v[i]),0ll);
    }    
    cout<<m;
}


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


    int TESTS = 1;
    // cin >> TESTS;
    while(TESTS--)
    {
        solve();

    }
    return 0;
}

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

bool check_prime(int n);

int main() {
    int N;
    cin >> N;
    int a[N];
    for ( int i = 0; i < N; i++ ) cin >> a[i];

    int count = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( check_prime(a[i]) ) {
            count++;
        }
    }

    cout << count << endl;
}

bool check_prime(int n) {
    bool is_prime = true;
    double limit = sqrt(n);

    if ( n == 2 ) {
        return is_prime;
    } else if ( n % 2 == 0 || n == 1) {
        is_prime = false;
        return is_prime;
    }

    int check = 3;
    while ( check <= limit ) {
        if ( n % check == 0 ) {
            is_prime = false;
            break;
        }
        check += 2;
    }
    
    return is_prime;
}


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

using namespace std;

#define ll long long

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	int A[n], B[n], C[n];
	for(int i = 0; i < n; i++)
		cin >> A[i] >> B[i] >> C[i];
	int a = max(B[0], C[0]), b = max(A[0], C[0]), c = max(A[0], B[0]), x, y, z;
	for(int i = 1; i < n; i++)
	{
		x = a + A[i];
		y = b + B[i];
		z = c + C[i];
		a = max(y, z);
		b = max(z, x);
		c = max(x, y);
	}
	int ans;
	ans = max(a, max(b, c));
	cout << ans;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll px,py,pt;
int main(){
  cin >> N;
  px = 0;
  py = 0;
  pt = 0;
  rep(i,N){
    ll x,y,t;
    cin >> t >> x >> y;
    ll dist = abs(x-px) + abs(y-py);
    if(t-pt < dist){
      cout << "No" << endl;
      return 0;
    }
    if(((t-pt) - dist) % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
    px = x;
    py = y;
    pt = t;
  }
  cout << "Yes" << endl;
}


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

#define MN 20

using namespace std;
typedef long long ll;

int l, ans, L;
vector<pair<int, int> > adj[30];
set<int> used;

int check(int no, int val) {
    assert(val >= 0);
    assert(val < L);
    if(no == MN) {
        used.insert(val);
        return 1;
    }
    int dif = 0;
    for(auto p : adj[no]) {
        assert(p.first > no);
        dif += check(p.first, val + p.second);
    }
    return dif;
}

int main() {
    scanf("%d", &l); L = l; l--;

    int n = MN, m = 0, mult = 1;
    for(int i = n; i > 1; i--, mult *= 2) {
        if(2*mult > l) break;
        adj[i-1].emplace_back(i, mult);
        adj[i-1].emplace_back(i, 0);
        m += 2;
    }

    int i = MN, val = l;
    mult = 1;
    adj[1].emplace_back(MN, val); m++;

    while(l) {
        if(l & 1) {
            val -= mult;
            if(i > 1) {
                adj[1].emplace_back(i, val);
                m++;
            }
        }

        i--;
        l /= 2;
        mult *= 2;
    }

    printf("%d %d\n", n, m);
    for(int i = 1; i <= MN; i++) {
        for(auto p : adj[i]) {
            printf("%d %d %d\n", i, p.first, p.second);
        }
    }

    //int dif = check(1, 0);
    //printf("%d\n", dif);
    //printf("%d\n", used.size());

    return 0;
}


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

using namespace std;

int M, N;
vector<int> Price;
vector<pair<int, int> > BoxInfo;
int DpTotalOfBox[500][10001];
const int INF = 1000000000;

void solve() {
	int ans, curSum, curPrice;

	memset(DpTotalOfBox, 0, sizeof(DpTotalOfBox));
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j <= M; ++j) {
			DpTotalOfBox[i][j] = INF;
		}
	}

	ans = 0;
	curPrice = BoxInfo[0].second;
	curSum = min(M, BoxInfo[0].first);
	for (int i = 1; i <= curSum; ++i) {
		DpTotalOfBox[0][i] = curPrice;
		ans = max(ans, Price[i - 1] - DpTotalOfBox[0][i]);
	}

	for (int i = 1; i < N; ++i) {
		curPrice = BoxInfo[i].second;
		curSum = BoxInfo[i].first;
		for (int j = 1; j <= M; ++j) {
			DpTotalOfBox[i][j] = min(DpTotalOfBox[i - 1][j], curPrice + DpTotalOfBox[i - 1][max(0, j - curSum)]);
			ans = max(ans, Price[j - 1] - DpTotalOfBox[i][j]);
		}
	}

	cout << ans << endl;
}

int main() {
	int p, sum;

	cin >> M >> N;
	for (int i = 0; i < M; ++i) {
		cin >> p;
		Price.push_back(p);
	}
	for (int i = 0; i < N; ++i) {
		cin >> sum >> p;
		BoxInfo.push_back({ sum,p });
	}
	sort(Price.begin(), Price.end(), greater<int>());
	for (int i = 1; i < M; ++i) {
		Price[i] += Price[i - 1];
	}
	solve();

	return 0;
}


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

using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    int mini = 1000000000;
    for(int i = k; i <= n; i++){
        mini = min(mini, a[i - 1] - a[i - k]);
    }
    cout << mini << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int abs(int x){
    return x >= 0 ? x : -x;
}

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

    cout << min(a,b) << " " << (a+b-n > 0 ? a+b-n : 0) << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define deb(x) cout << "LINE: " << __LINE__ << " " << #x << ": " << x << endl;
#define STDIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define lu int64_t

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	// STDIO

    float h, a;
    cin >> h >> a;

    cout << ceil(h / a) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    string ans="";
    if(s.length()>k){
        for(int i=0;i<k;i++){
            ans+=s[i];
        }
        ans+="...";
    }else{
        ans=s;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,a,b,i,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a>>b;
        sum+=(b-a)+1;
    }
    cout<<sum<<endl;
    return 0;

}

Measured memory_bytes: 256
while True:
    [n, m] = [int(x) for x in raw_input().split()]
    if [n, m] == [0, 0]:
        break

    data = []
    for x in range(n, 2, -1):
        if 3 * x - 2 < m:
            break
        for y in range(x - 1, 1, -1):
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s < m:
                    break
                if s == m:
                    data.append(s)

    print(len(data))

Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };

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

	double L;
	cin >> L;
	printf("%0.7lf", (L/3)* (L / 3)* (L / 3));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int turn_no = 0;
    while (a > 0 && c > 0)
    {
        turn_no++;
        if (turn_no % 2 == 1)
        {
            c -= b;
        }
        else
        {
            a -= d;
        }
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
        else if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

double dis(const vector<double>& x,
           const vector<double>& y,
           const double p) {
  
  const int n = x.size();
  double d = 0.0;
  
  if (p == -1) {
    for(int i=0; i<n; i++) {
      d = max(d,abs(x[i]-y[i]));
    }
    return d;
  }
  
  for(int i=0; i<n; i++) {
    d += pow(abs(x[i]-y[i]),p);
  }
  return pow(d,1/p);
}

int main(void) {
  int n;
  cin >> n;
  vector<double> x,y;
  for (int i=0; i<n; i++) {
    double t;
    cin >> t;
    x.push_back(t);
  }
  for(int i=0; i<n; i++) {
    double t;
    cin >> t;
    y.push_back(t);
  }
  
  for(int i=1; i<=3; i++) {
    printf("%.6f\n",dis(x,y,i));
  }
  printf("%.6f\n",dis(x,y,-1));

}

Measured memory_bytes: 3464
// edpc_k
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int N, K;
vector<int> A;
vector<int> memo;

bool dp(int k){

    if (memo[k] != -1) return (bool)memo[k];

    bool g = false;
    REP(i, N){
        if (k - A[i] < 0) break;
        g |= not dp(k - A[i]);
    }

    return (bool)(memo[k] = g);
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> K;
    A.assign(N, 0);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    memo.assign(K+1, -1);

    memo[0] = 0;
    bool first = dp(K);

    if (first){
        print("First");
    } else {
        print("Second");
    }

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;
	cout << a[0] << b[0] << c[0] << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n;
  vector<ll> m(5, 0);
  cin >> n;
  for (ll i = 0; i < 5; ++i) {
    cin >> m[i];
  }
  sort(m.begin(), m.end());

  ll v = 0;
  if (n == m[0]) {
    v = 0;
  } else if (n % m[0] == 0) {
    v = n / m[0] - 1;
  } else {
    v = n / m[0];
  }

  cout << v+5 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    string s;
    cin>>s;
    int w;cin>>w;
    string ret="";
    rep(i,0,s.size())if(i%w==0)ret+=s[i];
    cout<<ret<<endl;
	return 0;
}



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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 50;

int n, m;
PII rec[M];
struct Pro
{
	int s, t, c;
	bool operator<(const Pro &t) const
	{
		return s < t.s;
	}
}pro[N];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ )
	{
		int s, t, c;
		scanf("%d%d%d", &s, &t, &c);
		pro[i] = {s, t, c};
	}
	sort(pro, pro + n);
	
	int cnt = 0;
	for (int i = 0; i < n; i ++ )
	{
		int s = pro[i].s, t = pro[i].t, c = pro[i].c;
		sort(rec, rec + cnt);

		bool flag = false;
		for (int j = cnt - 1; j >= 0; j -- )
			if (rec[j].S == c && rec[j].F == s || rec[j].F < s)
			{
				rec[j] = {t, c};
				flag = true;
				break;
			}
			
		if (!flag) rec[cnt ++ ] = {t, c};
	}
	
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
const int maxn=1e6+5;
ll n,ans,pre[maxn];
signed main()
{
    IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
    pre[0]=1;
    for(int i=1;i<=n;i++)
    {
        pre[i]=(pre[i-1]*(n+1-i))%mod;
        pre[i]=(pre[i]*qpowmod(i,mod-2,mod))%mod;
    }
    ans=(qpowmod(10,n,mod)-qpowmod(8,n,mod)+mod)%mod;
    for(int i=1;i<=n;i++)
    {
        ans=(ans-(pre[i]*qpowmod(8,n-i,mod))%mod+mod)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        ans=(ans-(pre[i]*qpowmod(8,n-i,mod))%mod+mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 11412
#include <stdio.h>
/*
recommend usage
initial 
*/

void solve(int a, int b){
    if( a==b ){
        printf("a == b\n");
    }
        else if( a>b )//if( a>b ){
        printf("a > b\n"); // b> a is ng
    else if( a < b ){ //}else{
        printf("a < b\n");
    }
    
}

int main(void){
    // Your code here!
    int a,b;
    scanf("%d %d",&a,&b);
    solve(a,b);
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  for(int i=1; i<=N; i+=2){
    int counter = 0;
    for(int j=1;j<=i;j++){
      if(0 == i%j) counter++;
    }
    
    if(8 == counter) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = str(input())
s_list = list(s)
ans_1 = 'no'
ans_2 = 'no'
ans_3 = 'ok'
check = 'no'
s_list_len = len(s_list)
if s_list[0] == 'A':
    ans_1 = 'ok'
count = 0
for i,j in enumerate(s_list[2:s_list_len-1]):
    if j == 'C':
        count += 1
        if check == 'no':
            s_list.pop(2+i)
        check = 'yes'
if count == 1:
    ans_2 = 'ok'
for i in s_list[1:]:
    if not i.islower():
        ans_3 = 'no'
if (ans_1 == 'ok') and (ans_2 == 'ok') and (ans_3 == 'ok'):
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x;
	cin>>x;
	ll now=100;
	ll ans=0;
	while(now<x){
		now*=1.01;
		ans++;
	}
	cout<<ans<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int h, w;
    cin >> h >> w;
    string s[52];
    s[0] = s[h+1] = "";
    for(int i=0;i<=w+1;i++){
        s[0].push_back('#');
        s[h+1].push_back('#');
    }

    int white = 0;
    for(int i=1;i<=h;i++){
        cin >> s[i];
        s[i] = "#" + s[i] + "#";
        for(int j=1;j<=w;j++){
            if(s[i][j]=='.') white++;
        }
    }

    const int di[4]={1,-1,0,0}, dj[4]={0,0,1,-1};
    int len[51][51];
    queue<pair<int,int>> Q;
    Q.push({1,1});
    len[1][1] = 1;
    s[1][1] = '#';

    if(h == 1 && w == 1) goto end;
    while(!Q.empty()){
        auto t = Q.front();
        Q.pop();
        for(int k=0;k<4;k++){
            if(s[t.first+di[k]][t.second+dj[k]] == '.'){
                s[t.first+di[k]][t.second+dj[k]] = '#';
                len[t.first+di[k]][t.second+dj[k]] = len[t.first][t.second]+1;
                Q.push({t.first+di[k], t.second+dj[k]});
                if(t.first+di[k] == h && t.second+dj[k] == w) goto end;
            }
        }
    }
    cout << -1 << endl;
    return 0;
    end: ;

    cout << white-len[h][w] << endl;
    
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n){
		ans += 800;
		if((i+1)%15 == 0) ans -= 200;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k1,k2,k3;
	cin>>a>>b;
	k1=(a+b)/2;
	k2=(a-b)/2;
	k3=(b-a)/2;
	if(fabs(a-k1)==fabs(b-k1)){
		printf("%d\n",k1);
	}
	else if(fabs(a-k2)==fabs(b-k2)){
		printf("%d\n",k2);
	}
	else if(fabs(a-k3)==fabs(b-k3)){
		printf("%d\n",k3);

	}
	else {
		puts("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
 
#define MAX 100000

bool prime[MAX + 1];
int count[MAX + 1];
int N, L, R;

int main() {
  // 素数配列をエラトステネスの篩を使って生成
  // 素数であれば false, 素数でなければ true
  for (int i = 2; i < sqrt(MAX); ++i)
    if (!prime[i])
      for (int j = i + i; j <= MAX; j += i)
        prime[j] = true;

  // N と (N + 1) / 2 が素数である要素配列を生成
  // 条件が成立すれば 1、成立しなければ 0
  for (int i = 3; i<= MAX; i += 2)
    if (!prime[i] && !prime[(i + 1) >> 1])
      count[i] = 1;

  // 累積和を生成
  for (int i = 3; i<= MAX; ++ i)
    count[i] += count[i - 1];

  scanf("%d", &N);
  while (N --) {
    scanf("%d%d", &L, &R);
    printf("%d\n", count[R] - count[L - 1]);
  }

  return 0;
}


Measured memory_bytes: 2224
// 想定解法賢スギィ！ 自分、絶望いいっすか！？

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> a(3*N);
    for (int i = 0; i < 3 * N; i++) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    for (int i = N; i < 3 * N; i += 2) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100;
int v[1 + nmax];

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  int result = 0, sum = 0;
  for(int i = 1;i <= n; i++){
    if(v[i] == v[i - 1])
      sum++;
    else {
      result += sum / 2;
      sum = 1;
    }
  }
  result += sum / 2;
  std::cout << result;
}


Measured memory_bytes: 3552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b=a;
  sortt(b);
  map<int,int> mp;
  rep(i,n) mp[b[i]]=i;
  int ans=0;
  rep(i,n){
    if(abs(mp[a[i]]-i)%2==1) ans++;
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 8816
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int x, y;
	while (true) {
		std::cin >> x >> y;
		if (x==0 && y==0) break;
		
		if (x>y) std::cout << y << " " << x << std::endl;
		else std::cout << x << " " << y << std::endl;
	}
	return 0;
}



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

using namespace std;

const int N = 2e5 + 5;

int a[N], b[N], c[N];

vector< int> v[N];

int main() {

	for (int i = 1; i < N; i ++) {
		for (int j = i; j < N; j += i) {
			v[j].push_back(i);
		}
	}
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

	vector< int> ans;
	for (int i = n; i >= 1; i --) {
		if (a[i] == b[i]) continue;
		ans.push_back(i);
		for (auto &j : v[i]) b[j] ^= 1;
	}

	cout << ans.size() << endl;
	for (const int &x : ans) printf("%d ", x);
}

Measured memory_bytes: 25336
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int as[110];
bool dp[100000+10];

int main(void) {
  int N, K;
  scanf("%d%d", &N, &K);
  REP(i, N) {
    scanf("%d", &as[i]);
  }
  REP(i, K) {
    if(!dp[i]) {
      REP(j, N) {
        if(i+as[j] > K) {
          continue;
        }
        dp[i+as[j]] = true;
      }
    }
  }
  puts(dp[K] ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 384
from math import gcd
K = int(input())
ans = 0

for i in range(1, K + 1):
    ans += gcd(gcd(i, i), i)
    temp = gcd(i, i)
    for j in range(1, K + 1):
        if i != j:
            ans += gcd(temp, j)*3

for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        for l in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), l)*6

print(ans)


Measured memory_bytes: 9204
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()



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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll INF = LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MAXN = 1e5+20;
const double EPS= 1e-10;

int n, W;
ll dp[MAXN][110];
ll V;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>> n >> W;

    pair<int, ll> pare[n];
    forn(i,n){
        ll a; int b;
        cin>> a>> b;
        pare[i+1]= make_pair(b,a);
        V+= b;
    }
    sort(pare, pare+n);
//    d(pare[1].fi);
    forn(i,V+1){
        forn(j,n+1){
            dp[i][j]= 1e11;
        }
    }
    for1(j,n){
        for1(i,V){
            dp[i][j]= min(dp[i][j], dp[i][j-1]);
//            d(pare[j].fi);
            if(pare[j].fi==i){
                dp[i][j]=  min(dp[i][j-1], pare[j].se);
            }else if(i-pare[j].fi>=0 && dp[i- pare[j].fi][j]!=1e11){
                dp[i][j]=  min(dp[i][j-1], pare[j].se + dp[i-pare[j].fi][j-1]);
            }
//            dp[i][j]=  min(dp[i][j-1], w[j] + ((dp[i-v[j]][j-1]==1e11) ? 0 : dp[i-v[j]][j-1]) ) : dp[i][j-1];
        }
    }
    int valor= 1;
//    for1(i,n){
//        for1(j,V){
//            if(dp[j][i]==1e11) cout<< "x ";
//            else cout<< dp[j][i]<< " ";
//        }
//        cout<<el;
//    }
//    d(V);
    for1(i,V){
        if(dp[i][n] && dp[i][n]<=W ){
            valor= max(i,valor);
        }
    }
    cout<< valor<<el;
}



Measured memory_bytes: 86144
import sys

def input():
    return sys.stdin.readline()

def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))
    kaishi = 0
    syuuryou = 0
    time = 0
    for i in t:
        if syuuryou < i:
            time += syuuryou - kaishi
            kaishi = i
        syuuryou = i + T
    time += syuuryou - kaishi 
    print(time)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 26744
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int s,ans=1;
    cin >> s;
    map<int,int> mp;
    while(1){
        mp[s]=1;
        s=(s%2)?3*s+1:s/2;
        ans++;
        if(mp.count(s))break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, k, h[MAX_N], dp[MAX_N];
    cin >> n >> k;
    REP(i,n) cin >> h[i];
    fill(dp,dp+n+1,IINF);
    dp[0] = 0;
    REP(i,n-1){
        REP(j,k){
            if(i+j+1<n)dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(h[i+j+1]-h[i]));
            else break;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

int main(){
	// sengen
	int a,b,c;
	// nyuryoku
	cin >> a >> b >> c;
	int count = 0;
	// keisan
	if(a == b) count++;
	if(b == c) count++;
	if(c == a) count++;
	if(count == 1){
		cout << "Yes";
	}else{
		cout << "No";
	}
	// syutsuryoku
}

Measured memory_bytes: 256
<?php
list($n, $m) = ints();
for ($i = 0; $i < $m; ++$i) {
    list($a, $b) = ints();
    --$a;
    --$b;
    $h[] = [$a, $b];
    $g[$a][] = $b;
    $g[$b][] = $a;
}
$ans = 0;
for ($i = 0; $i < $m; ++$i) {
    // BFS（幅優先探索）：最短経路アルゴリズムとして活用
    $q = new SplQueue(); // キューを用意
    $dist = array_fill(0, $n, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

    $dist[0] = 0; // 頂点0からの距離格納配列
    $q->enqueue(0); // キューに0を追加

    while (!$q->isEmpty()) {
        $v = $q->dequeue();

        foreach ($g[$v] as $next_v) {
            if ($h[$i][0] === $v && $h[$i][1] === $next_v) continue;
            if ($h[$i][1] === $v && $h[$i][0] === $next_v) continue;
            if ($dist[$next_v] !== -1) continue; // 発見済み

            $dist[$next_v] = $dist[$v] + 1;
            $q->enqueue($next_v);
        }
    }
    if (array_search(-1, $dist)) $ans++;
}
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  ll h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll ans = 0;
  if (w % 2 == 0) {
    ans = w / 2 * h;
    cout << ans << endl;
    return 0;
  }

  for (ll i = 0; i < h; i++) {
    if (i % 2 == 0) {
      ans += (w + 1) / 2;
    } else {
      ans += w / 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3548
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

int main(){
	int x,y;
	
	cin >> x >> y;

	switch(x){
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			switch(y){
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12:
					cout << "Yes" << endl;
					return 0;
					break;
			}
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			switch(y){
			case 4:
		case 6:
		case 9:
		case 11:
				cout << "Yes" << endl;
					return 0;
			}
			break;
		case 2:
			if(y == 2){
cout << "Yes" << endl;
					return 0;
			}
			break;
	}
//	cout << "Yes" << endl;
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll, ll>> VPI;
typedef pair<ll, ll> PLL;
typedef map<ll, ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    VL h(n + 1);
    FOR(i, 1, n + 1)
    {
        cin >> h[i];
    }
    VL dp(n + 1, -1);
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    FOR(i, 3, n + 1)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    int arr[32]={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};
    int k;
    cin>>k;
    cout<<arr[k-1];
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int data[10],i,j,temp;
  for(i=0;i<10;i++){
    cin >> data[i];
  }
  for(i=0;i<10;i++){
    for(j=1;j<10;j++){
      if(data[j]>data[j-1]){
        temp=data[j];
	data[j]=data[j-1];
	data[j-1]=temp;
      }
    }
  }
  cout << data[0] << endl << data[1] << endl << data[2] << endl;
  return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
/////////////////////////////
int main() {
  string s;
  cin>>s;
  s=s.substr(0,s.size()-8);
  cout<<s<<endl;
}
/////////////////////////////

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    vector<int> dp(n+2,INT_MAX);
    dp[0] = INT_MIN;
    for (int i = 0;i < n;++i) {
        int j = upper_bound(dp.begin(),dp.end(),-a[i])-dp.begin();
        dp[j] = -a[i];
    }
    // p_ary(dp,0,n+2,i);
    for (int i = 1;i < n+2;++i) if (dp[i] == INT_MAX) {
        cout << i-1 << endl;
        return 0;
    }
}

Measured memory_bytes: 1024
s=input()
t=input()
if len(s)==len(t):
    cm=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            cm+=1
else:
    cm=1000
    for i in range(len(s)-len(t)):
        cn=0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                cn+=1
        cm=min(cm,cn)

print(cm)


Measured memory_bytes: 8952
#include<iostream>
#include<algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n, K;
    cin >> n >> K;
    int v[n];
    rep(i, n) cin >> v[i];
    int ans = 0;
    rep(m, min(n, K) + 1){
        rep(i, m+1){
            int j = m - i;
            int value[m];
            int value_sum = 0;
            rep(k, i) value[k] = v[k];
            rep(k, j) value[i+k] = v[n-k-1];
            sort(value, value + m);
            rep(k, m){
                if (k < K - m && value[k] < 0) continue;
                value_sum += value[k];   
            }
            if (value_sum > ans) {
                ans = value_sum;
            }
            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  if (S[0] == S[N - 1]) {
    if (N % 2)
      cout << "Second" << endl;
    else
      cout << "First" << endl;
  } else {
    if (N % 2)
      cout << "First" << endl;
    else
      cout << "Second" << endl;
  }
  return 0;
}

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

using namespace std;

const int N = 100005;
const int MOD = 1000000007;

long long dp[N];

int main() {
  for (int i = 1; i < N; i++) {
    dp[i] = MOD;
  }
  int n, w, a, b;
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    for (int j = N; j >= b; j--) {
      dp[j] = min(dp[j], dp[j - b] + a);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (dp[i] <= w) ans = max(i, ans);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> cnt(n, 1), ans(n, 0);
    ans[0] = 1;
    while (m--) {
        int u, v; cin >> u >> v;
        u--, v--;
        if (ans[u] == 1)
            ans[v] = 1;
        cnt[u]--, cnt[v]++;
        if (cnt[u] == 0)
            ans[u] = 0;
    }
    int sum = 0;
    for (auto &v : ans)
        sum += v;
    cout << sum << '\n';
}


Measured memory_bytes: 1024
N,K,Q = map(int,input().split())

A = []

for i in range(Q):
    A.append(int(input()))

points = [K-Q]*N

for i in range(Q):
    points[A[i]-1] += 1

for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 10448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class Node {
		int parent;
		public Node(int x) {
			this.parent = x;
		}
	}
	
	class DisjointSet {
		Node[] p;
		int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		private int findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return x;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] > rank[y]) {
				p[x].parent = y;
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 62212
#include<iostream>

using namespace std;

int main(){

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

    int ans = 0;
    for(int i=0;i<n;i++){
        while(a[i]%2==0){
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())


nodes = [[0 for i in range(n)] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    nodes[a-1][b-1] += 1
    nodes[b-1][a-1] += 1

for i in range(n):
    print(sum(nodes[i]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
  	vector<bool> snuke(n);
	rep(i, k){
      	int kk, a;
		cin >> kk;
      	rep(j, kk) {
        	cin >> a; 
          	snuke[a-1] = true;
        }
	}
  	int cnt = 0;
  	rep(i, n) {
    	if(snuke[i] == false) 
      		cnt++;
    }
	cout << cnt << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int sides[3]; int tyoho = 0, para = 0;
	while (scanf("%d,%d,%d", &sides[0], &sides[1], &sides[2]) != EOF) {
		//????????¢???check
		if (sides[0] * sides[0] + sides[1] * sides[1] == sides[2] * sides[2]) {
			tyoho++;
		}
		//??????????????¢???check
		else if (sides[0] == sides[1]) {
			para++;
		}
	}
	cout << tyoho << endl << para << endl;
}

Measured memory_bytes: 3100