akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll 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() {
    string s;
    cin >> s;
    vi n(3, 0);
    for (int i = 0; i < 3; ++i) {
        n[s[i] - 'a']++;
    }
    bool ok = true;
    for (int i = 0; i < 3; ++i) {
        if (n[i] != 1)
            ok = false;
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  
        static void Main(string[] args)
        {
          //入力を受け取る
          int[] AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          int A = AB[0];
          int B = AB[1];
          if(A-2*B < 0){
            Console.Write(0);
          }else{
            Console.Write(A-2*B);
          }
          
        }
  
 }

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
#define INF 1e9
using namespace std;
using  namespace boost;
#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

typedef long long ll;


int main() {
    string S;
    cin >> S;
    vector<string> exp(1 << (S.size() - 1));
    ll score = 0;
    REP(i, 1 << (S.size() - 1)) {
        string now;
        now += S[0];
        REP(j, S.size() - 1) {
            if (i & (1 << j)) now += "+";
            now += S[j+1];
        }
        vector<string> splited;
        algorithm::split(splited,now,is_any_of("+"));
        vector<ll> isp(splited.size());
        REP(p,splited.size()) isp[p]=stoll(splited[p]);
        score += accumulate(ALL(isp),ll(0));
    }
    cout << score << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
int main() {
    string s;
    cin >> s;
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s[i] != ',')
        {
            cout << s[i];
        }
        else
        {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int deduction,poll_sum=0,winner_poll=0,athlete_sum,winner_num,poll,i;

	while(1){
		scanf("%d %d %d",&athlete_sum, &winner_num, &deduction);
		poll_sum=0;
		winner_poll=0;
		
		if(athlete_sum==0 && winner_num==0 && deduction==0)break;

		for(i=1;i<=athlete_sum;i++){
			scanf("%d",&poll);
			poll_sum+=poll;
			if(winner_num==i)
				winner_poll=poll;
		}

		printf("%d\n",winner_poll?poll_sum*100*(100-deduction)/100/winner_poll:0);

		}

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int d[8]={1,2,4,8,16,32,64,101};
    int ans=0,i=-1;
    while(ans<=n){
        i++;
        ans=d[i];
        }
    cout<<d[i-1]<<endl;
    }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N, M;
int L[100010], R[100010];

void solve() {

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
		L[i]--; R[i]--;
	}

	int ansL = 0, ansR = N - 1;
	for (int i = 0; i < M; i++) {
		ansL = max(ansL, L[i]);
		ansR = min(ansR, R[i]);
	}

	cout << max(ansR - ansL + 1, 0) << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 1024
n = gets.chomp.to_i
t, a = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
arr = []
h.each do |i|
    shiki = t * 1000- i * 6
    arr << shiki
end
arr_2 = []
arr.each do |item|
    kizyun = (item - a * 1000).abs
    arr_2 << kizyun
end
mezirusi = arr_2.min
arr_2.each_with_index do |item ,j|
    if mezirusi == item
        puts j + 1
        break
    end    
end

Measured memory_bytes: 14420
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
typedef long long LL;

int main()
{
    int n;
    cin>>n;
    int res=0;
    for(int i=1;i<=n;i++)
        if(i>=0&&i<=9||i>=100&&i<=999||i>=10000&&i<=99999&&i>=10000&&i<=99999)
            res++;
    cout<<res<<endl;
}

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

int main() {
	int A, B, C;
	cin >> A >> B;
	if (A % 2 != 0 && B % 2 != 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m,x;
    cin>>n>>m>>x;
    vector<ll>a(m);
    ll ans=0;
    rep(0,i,m){
        cin>>a[i];
        if(x<a[i]){
            ans=i;
            break;
        }
    }
    cout<<min(ans,m-ans);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1,M1,H2,M2,K,ans=0;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ans = (H2-H1)*60+M2-M1;
  if(ans-K >= 0) cout << ans-K << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>

using namespace std;

typedef long long ll;

int main(void){
    string s;
    cin >> s;
    map<char, ll> mp;
    for(ll i = 0;i < s.size(); i++){
        mp[s[i]]++;
    }
    for(auto x : mp){
        if(x.second != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
    // 入力
    int n,m,k;
    std::cin >> n >> m >> k;
    std::vector<long long> A(n),B(m);
    for(int i = 0;i < n;i++) std::cin >> A.at(i);
    for(int i = 0;i < m;i++) std::cin >> B.at(i);

    // 累積和
    std::vector<long long> sumA(n+1,0),sumB(m+1,0);
    for(int i = 0;i < n;i++) sumA.at(i+1) = sumA.at(i) + A.at(i);
    for(int i = 0;i < m;i++) sumB.at(i+1) = sumB.at(i) + B.at(i);

    int ans = 0;
    // しゃくとり法
    int j = m;
    for(int i = 0;i < n+1;i++){
        while(j >= 0 and sumA.at(i) + sumB.at(j) > k) j -= 1;
        if(j < 0) break;
        ans = std::max(ans, i+j);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 9512
### constant

MAX_BSW = 1500000

### subroutines

def shelf(m, bi)
  return 0 if bi >= $bn

  return $scache[m][bi] if ! $scache[m][bi].nil?

  if m == 1
    bsw = $books[bi...$bn].inject(0){|s, b| s + b}
    return ($scache[m][bi] = bsw)
  end

  min_bsw = MAX_BSW
  bsw0 = 0
  max_bi = $bn - m + 1

  for bi0 in (bi..max_bi)
    bsw1 = shelf(m - 1, bi0)
    bsw = [bsw0, bsw1].max
    if min_bsw > bsw
      min_bsw = bsw
    end

    bsw0 += $books[bi0]
    break if min_bsw <= bsw0
  end

  $scache[m][bi] = min_bsw
end

### main

while true
  m, n = gets.strip.split(' ').map{|s| s.to_i}
  break if m == 0 && n == 0

  $bn = n
  $books = []
  n.times.each do
    w = gets.strip.to_i
    $books << w
  end
  #p $books

  $scache = (m + 1).times.map{[]}

  bsw = shelf(m, 0)
  puts bsw
end

Measured memory_bytes: 6140
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=998244353
input=lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self,n):
        fact=[1]*(n+1); invfact=[1]*(n+1)
        for i in range(1,n+1): fact[i]=i*fact[i-1]%MOD
        invfact[n]=pow(fact[n],MOD-2,MOD)
        for i in range(n-1,-1,-1): invfact[i]=invfact[i+1]*(i+1)%MOD
        self.__fact=fact; self.__invfact=invfact

    def inv(self,n):
        assert(n>0)
        return self.__fact[n-1]*self.__invfact[n]%MOD

    def fact(self,n):
        return self.__fact[n]

    def invfact(self,n):
        return self.__invfact[n]

    def comb(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[k]*self.__invfact[n-k]%MOD

    def perm(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[n-k]%MOD

from fractions import gcd
def resolve():
    n,a,b,k=map(int,input().split())

    # k=ax+by の不定方程式を解く
    g=gcd(a,b)
    if(k%g):
        print(0)
        return
    k//=g; a//=g; b//=g

    # k=ax+byの解は0<=x<b に1つだけある
    for x in range(b):
        if((k-a*x)%b==0):
            y=(k-a*x)//b
            break
    # 現在 x,y は k=ax+byを満たす x のうち、非負で最小のものとなっている
    # これを x,y -> x+b,y-a として iterate していく
    ans=0
    mf=modfact(n)
    while(y>=0):
        ans+=mf.comb(n,x)*mf.comb(n,y)
        x,y=x+b,y-a

    print(ans%MOD)
resolve()

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, K;
  cin >> N >> K;

  if(K == 0){
	cout << N*N << endl;
	return 0;
  }

  LL ans = 0;
  for(LL b=K+1;b<=N;++b){
	ans += b - K;
	LL r = N - b + 1;
	ans += (r/b) * (b-K);
	r %= b;
	ans += max(0ll, r-K);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$
**/

#include <bits/stdc++.h>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <cmath>

using namespace std;

//typedef
typedef string STR;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef priority_queue<int> PQI;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<STR> VS;
typedef vector<char> VC;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<STR,int> PSI;
typedef pair<int,STR> PIS;
typedef vector<PII> VII;
typedef map<int,int> MII;
typedef map<LL,LL> MLL;
typedef map<STR,int> MSI;
typedef map<char,int> MCI;
typedef map<int,STR> MIS;
typedef set<STR> SS;
typedef set<int> SI;
typedef set<LL> SLL;

//symbolic const
#define MOD 1000000007
#define MAXN 1e9
#define SIZE 10000

//STL keywords
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
#define all(v) v.begin(), v.end()

//functions
#define dec(n) cout<<fixed<<setprecision(n);
#define f(i, n)   for(LL i=0; i<n; i++)
#define fa(i,a,n) for(LL i=a; i<n; i++)

//IO
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test int t;cin>>t;while(t--){solve();}

LL maxLL(LL a, LL b){return (a>b?a:b);}
LL minLL(LL a, LL b){return (a<b?a:b);}

void solve() {
  int n;
  cin>>n;
  VI h(n), a(n, 0);
  int c=0;
  f(i, n){
      cin>>h[i];
      if(i==0) a[i]=h[i];
      else a[i]=max(h[i], a[i-1]);
      if(a[i]==h[i]) c++;
  }
  cout<<c;
}

int main() {
    sync;
    //test;
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def print_ans(input_line):
    """Test Case
    >>> print_ans("2 5")
    10
    >>> print_ans("5 10")
    -1
    >>> print_ans("9 9")
    81
    """
    A,B = input_line.split()
    if len(A) == 1 and len(B) == 1:
        print(int(A) * int(B))
    else:
        print("-1")


if __name__ == '__main__':
    print_ans(input())


Measured memory_bytes: 2940
import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
# n = int(input())
# l = list(map(int, input().split()))
l.sort()

def bin_search(x, ok, ng, l):
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if l[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok + 1

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bin_search(l[i] + l[j], -1, n - j - 1, l[j + 1:])
print(ans)

Measured memory_bytes: 52188
#include <stdio.h>

int main()
{
    int k, a, b;
    scanf("%d", &k);
    scanf("%d%d", &a, &b);

    int i = 1, is_possible = 0;

    while(i*k <= b)
    {
        if(i*k >= a)
        {
            is_possible = 1;
            break;
        }

        i++;
    }

    if(is_possible == 1)
        printf("OK\n");

    else
        printf("NG\n");


    return 0;
}


Measured memory_bytes: 1644
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
ll mod=1e9+7;
int main()
{
	ll n,m,i,j;
   string s,ss,sss;
   cin>>s>>ss;
    cin>>n>>m;
	cin>>sss;
	if(sss==s)
	printf("%d %d\n",n-1,m);
	else
	printf("%d %d\n",n,m-1);
   
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class CForbiddenList {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int x,n;
        cin>>x>>n;
        int a[102]={0};
        for (int i=0;i<n;i++){
            int j;
            cin>>j;
            a[j]=1;
        }
//        sort(a,a+n);
        int dif=INT_MAX,ans;
        for (int i=0;i<=101;i++){
            if (a[i]!=1){
                if (abs(x-i)<dif){
                    ans=i;
                    dif=abs(x-i);
                }
            }
        }
        cout<<ans;
	}
};


int main() {
	CForbiddenList solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

int main(void) {
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  int N,count,MAX,l;
  long long H[100000];
  cin >> N;
  
  rep (i,N){
    cin >> H[i];
  }
 count = 0;
  MAX = 0;
  for (int i = 0; i < N-1; i++){
    if ( H[i] >= H[i+1] ){
      count++;
      if (MAX <= count ){
        MAX = count;
      }
    }
    else if ( H[i] < H[i+1] ){
    count = 0;
    }
  }
   
  cout << MAX << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

void push(int);
int pop();

int top=0,S[100];

int main(){
  int m,n;
  char x[7];

  while(scanf("%s",x)!=EOF){
    if(x[0]>=49&&x[0]<=57) push(atoi(x));
    else{
      m=pop();
      n=pop();

      if(x[0]==42) push(n*m);
      else if(x[0]==43) push(n+m);
      else push(n-m);
    }
  }

  printf("%d\n",S[1]);
  
  return 0;
}

void push(int x){
  top++;
  S[top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define MP(a,b) make_pair(a,b)
#define debug(x)       cerr<< #x << " : " << x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[i].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll gcd (ll x , ll y){
    if (x < y) swap (x , y);
    while (y){
        ll temp = y;
        y = x % y;
        x = temp; 
    }
    return x;
}

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
   int K;
   string s;
   cin >> K >> s;

   if (int(s.length()) <= K){
    cout << s << endl;
   } else{
    cout << s.substr(0 , K) << "...\n";
   }
}
int main(){
    IOS;
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double

int iskaibun(string s) {
  string r=s;
  reverse(r.begin(),r.end());
  int cj=1;
  for (size_t i = 0; i < s.size(); i++)
  {
    if (r[i]!=s[i]) {
      cj=0;
      break;
    }
  }
  return cj;
}

int main()
{
  string s;
  cin>>s;
  string s1,s2;
  int n=s.size();
  s1 = s.substr(0, (n - 1) / 2);
  s2 = s.substr((n + 3) / 2 - 1, (n - 1) / 2);

  int js;
  js=iskaibun(s);
  js*=iskaibun(s1);
  js*=iskaibun(s2);
  if (js) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

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

	set<int> s;
	rep(i,n){
		int a;
		cin >> a;
		if(s.find(a)==end(s))
			s.insert(a);
		else
			s.erase(a);
	}

	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 4864
class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.k_init = 2 ** (self.n - 1).bit_length()

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i


def get_invnum(li):
    n = len(li)
    t = FenwickTree(2)
    res = 0
    for i in range(n):
        if li[i] == "A":
            t.add(2, 1)
        else:
            res += t.sum(2)
    return res


S = input()
S = list(S.replace("BC", "D"))
N = len(S)
li = []
ans = 0
for c in S + ["B"]:
    if c not in ("A", "D"):
        ans += get_invnum(li)
        li = []
    else:
        li.append(c)
print(ans)


Measured memory_bytes: 13564
#include <bits/stdc++.h>
using namespace std;
constexpr int M = 1e9 + 7;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &xs) {
    os << '[';
    for (auto i = xs.cbegin(); i != xs.cend(); ++i) {
        if (i != xs.cbegin()) os << ' ';
        os << *i;
    }
    os << ']';
    return os;
}

int solve(const int s) {
    if (s < 3) return 0;

    // number of sequences [whose sum is i]
    vector<int> dp(s + 1, 0);
    dp[0] = 1;
    dp[3] = 1;

    for (int i = 4; i <= s; ++i) {
        for (int j = 3; j <= s; ++j) {
            if (i - j >= 0) {
                dp[i] += dp[i - j];
                dp[i] %= M;
            }
        }
    }

    return dp[s];
}

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

    int s;
    cin >> s;
    cout << solve(s) << '\n';

    return 0;
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, M;
    cin>>N>>M;
    vector<pint> W(N);
    REP(i, 0, N){
        int a, b;
        cin >> a >> b;
        W[i] = {a, b};
    }
    sort(W.begin(), W.end());
    priority_queue<int> que;
    int count = 0, ans = 0;
    REP(i, 1, M+1){
        while(W[count].first == i && count < N){
            que.push(W[count].second);
            count++;
        }
        
        int q;
        if(!que.empty()){
            q = que.top(); 
            que.pop();
        }else{
            q = 0;
        }
        ans += q;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl;
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl;
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl;
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl;
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl;
#define pb push_back
#define pf push_front
#define oo (ll)1e18
#define inf (int)1e10
#define ll long long 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
typedef tuple<ll,ll,ll> tl3;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
const int MAXN = 305;
template <typename T> void maxself(T& a, T b) {
    a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
    a = min(a, b);
}

//#define cerr if(0)cout

vector <pi> A[15];
int honest[15];
int main() {
    IAMSPEED
	int n; cin >> n;
	FOR(i,0,n-1) {
		int x; cin >> x;
		FOR(j,1,x) {
			int a,b; cin >> a >> b;
			--a;
			A[i].pb(pi(a,b));
		}
	}
	int ans = 0;
	for (int i = 0; i < (1<<n); ++i) {
		bool valid = 1;
		for (int j = 0; j < n; ++j) {
			if ((1<<j) & i) {
				for (auto it : A[j]) {
					if (it.s + 1==2 && !((1<<it.f) & i)) valid = 0;
					if (it.s + 1==1 && ((1<<it.f)&i)) valid = 0;
				}
			}
		}
		if (valid) {
			db(i)
			int sum = 0;
			for (int j = 0; j < n; ++j) {
				if (i & (1<<j)) ++sum;
			}
			maxself(ans, sum);
		}
	}
	cout << ans;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string o;
    string e;
    cin >> o >> e;

    // 処理
    // 出力
    for (int i = 0; i < o.size(); i++) {
        cout << o[i];
        if (i < e.size()) cout << e[i];
    }


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> calc(N);
  for(int i = 0; i < N; i++) {
    cin >> calc.at(i);
  }
  
  int all = calc.at(0);
  for(int i = 1; i < N; i++) {
    all ^=calc.at(i);
  }
  
  for(int i = 0; i < N; i++) {
    cout << (all ^ calc.at(i)) << endl;
  }
}


Measured memory_bytes: 4000
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, s, d, t;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    ll ans = 0;
    scanf("%lld%lld", &s, &d);
    while(s != d) {
      if(s % 2) ans++, s++;
      if(d % 2) ans++, d--;
      s /= 2, d /= 2; 
    }
    printf("%lld\n", ans);
  }
  return 0;
}


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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(k>=a)
    {
        sum=a;
        k-=a;
    }
    else{
        sum=k;
        k=0;
    }
    k-=min(k,b);
    if(k>0)
        sum-=k;

    cout<<sum;

    return 0;
}


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

#define int long long

int dp[50];
int n;

void init() {
  dp[1] = dp[2] = dp[3] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int day = (dp[n] + 3650 - 1) / 3650;
    cout << day << endl;
  }

  return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))



int main(void){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),c(m);
  
  rep(i,m){
	cin >> a[i] >> b[i];
	rep(j,b[i]){
	  int tmp;
	  cin >> tmp;
	  tmp--;
	  c[i] += (1<<tmp);
	}
  }
  
  int size = 1<<n;
  //cout << "size:" << size << endl;
  vector<ll> dp(size,MAX);
  dp[0] = 0;
  rep(i,size){
	rep(j,m){
	  int tmp = i+1-((i+1) & c[j]);
	  //cout << i+1 << "," << c[j] << "," << tmp << endl;
	  if(a[j]+dp[tmp] < dp[i+1]) dp[i+1] = a[j]+dp[(i+1)-((i+1) & c[j])];
	}
	//cout << dp[i+1] << endl;
  }

  
  if(dp[size-1] == MAX) cout << -1 << endl;
  else cout << dp[size-1] << endl;

  return 0;
}


Measured memory_bytes: 256
N =int(input())
A = list(map(int,input().split()))
cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1
if cnt2 >= 2:
    com = N - cnt2 + 1
else:
    com = N
if com // 2 <= cnt4:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//    if(n==1)return false;
//    T i = 2;
//    while(i*i<=n){
//       if(n%i==0)return false;
//       i+=1;
//    }
//    return true;
//}

// bool prime[100005];
// void seive()
// {
//     memset(prime,true,sizeof(prime));
//     prime[0]=0;
//     prime[1]=0;
//     for(ll p=2;p*p<=100000;p++)
//     {
//         if(prime[p]==true)
//         {
//             for(ll i=p*2;i<=100000;i+=p)
//             prime[i]=false;
//         }
//     }    
// }

// ll power(ll n,ll k, ll mod){
//     if(k==0)
//         return 1;
//     if(k==1)
//         return n%mod;

//     ll get=power(n,k/2,mod);
//     ll ret = ((get%mod)*(get%mod))%mod;

//     if(k%2)
//         ret = ((ret%mod)*(n%mod))%mod;

//     return ret%mod;
// }

ll dp[105][SIZE];
int val[SIZE];
int wt[SIZE];

int main(){
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    FAST;
    
    int n,w; cin>>n>>w;
    repp(i,1,n+1){
        cin>>wt[i]>>val[i];
    }

    rep(i,n+1){
        rep(j,w+1){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }else{
                if(wt[i]<=j){
                    dp[i][j] = max(dp[i-1][j-wt[i]]+val[i], dp[i-1][j]);
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    pn(dp[n][w]);
}

Measured memory_bytes: 79360
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
long long dp[100005],x[100005];
deque<int> q1,q2;
int n;
long long e,t;
void ins1(int xx)
{
	while(!q1.empty()&&dp[q1.front()]-2*x[q1.front()+1]>=dp[xx]-2*x[xx+1]) q1.pop_back();
	q1.push_back(xx);
}
void ins2(int xx)
{
	while(!q2.empty()&&dp[q2.front()]>=dp[xx]) q2.pop_back();
	q2.push_back(xx);
}
long long r1(int i)
{
	if(!q1.empty())return dp[q1.front()]+2*(x[i]-x[q1.front()+1]); else return 1e18;
}
long long r2(int i)
{
	if(!q2.empty())return dp[q2.front()]+t; else return 1e18;
}
int main()
{
	cin>>n>>e>>t;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		dp[i]=1e18;
	}
	dp[0]=0;
	q2.push_back(0);
	int l=0;
	for(int i=1;i<=n;i++)
	{
		//	dp[i]=min(dp[i],dp[j]+max(2*(x[i]-x[j+1]),t));
			while(l<i&&2*(x[i]-x[l+1])>=t)
			{
				ins1(l);
				if(q2.front()==l) q2.pop_front();
				l++;
			}
			dp[i]=min(r1(i),r2(i));
//			cout<<((!q1.empty())? q1.front():100)<<" "<<r1(i)<<" "<<" "<<((!q2.empty())? q2.front():100)<<" "<<r2(i)<<" "<<dp[i]<<endl;
			ins2(i);
	}
	cout<<e+dp[n];
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

namespace mapping{
	template<class t>
		auto collect(int n,t f){
			vector<decltype(f())> res(n);
			for(auto &i:res){
				i = f();
			}
			return res;
		}

	template<class t,class f>
		auto mapcar(t x,f func){
			int n = x.size();
			vector<typename t::value_type> res(n);
			auto itr = res.begin();
			for(auto &i:x){
				*itr = func(i);
				++itr;
			}
			return res;
		}
	template<class t,class f>
		void mapc(t x,f func){
			for(auto &i:x){
				func(i);
			}
		}
	template<class t,class u>
		auto sellect(t x,u f){
			vector<typename t::value_type> res;
			for(auto &i:x){
				if(f(i)){
					res.push_back(i);
				}
			}
			return res;
		}

}

using namespace mapping;

ll in(){
	ll res;
	scanf("%lld",&res);
	return res;
}

int main(){
	ll n = in();
	vector<ll> line = collect(n, in);
	if((int)sellect(line, [&](ll x){return x==line[0];}).size()==n){
		cout << ((line[0]==n-1||line[0]*2<=n)?"Yes":"No") << endl;
		return 0;
	}
	ll value_max = *max_element(all(line));
	ll value_min = *min_element(all(line));
	if(value_max-value_min!=1){
		cout << "No" << endl;
		return 0;
	}
	ll min_cnt = sellect(line, [&](ll x){return x==value_min;}).size();
	ll max_cnt = n - min_cnt;
	if((value_max!=min_cnt)&&(max_cnt/(value_max-min_cnt)>=2)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c, max(a*d, max(b*c, b*d)));
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(2*N);
  for (int i = 2; i < N+1; i++) {
    cin >> A.at(i);
  }
  map<int, int> cnt;
  for (int i = 1; i < N+1; i++) {
   cnt[i] = 0;
  }
  for (int x : A) {
    if (cnt.count(x)) { 
      cnt.at(x)++;
    } else {
      cnt[x] = 1; 
    }
  }
  
  for (int i = 1; i < N+1; i++) {
   cout << cnt.at(i) << endl;
  }
    
}

Measured memory_bytes: 14016
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int N;
ll h[112345];
ll dp[112345];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>N;
  repeat(i,N){
    cin>>h[i];
  }
  fill(dp+1,dp+N,INF);
  repeat(i,N){
    repeat(j,2){
      dp[i+1+j] = min(dp[i+1+j],dp[i]+abs(h[i+1+j]-h[i]));
    }
  }
  //debugArray(dp,N);
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod 998244353
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 1000005


// Driver code to test above functions
int32_t main()
{
  
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, ans = 0;
    cin >> n;
    map<int, int> mp;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;

        ans += mp[i-x];

        mp[i+x]++;
    }

    cout << ans;

    return 0;

} 


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

struct unionFind{

	int n;
	vector<int> pr,sz;

	unionFind(){};
	unionFind(int _n){
		n=_n;
		pr.resize(n,-1);
		sz.resize(n,1);
	};
	int root(int a){
		if(pr[a]==-1)return a;
		else return pr[a]=root(pr[a]);}

	void unite(int a,int b){
		a=root(a);b=root(b);
		if(a==b)return;
		if(sz[a]>sz[b])swap(a,b);
		pr[a]=b;
		sz[b]+=sz[a];
	};

	
	int size(int a){
		return sz[root(a)];}

	int same(int a,int b){
		return root(a)==root(b);
	}

};

signed main(){
	int n,m;cin>>n>>m;
	unionFind uf(n);
	vector<int> a(m),b(m),ans(m);
for(int i=0;i<m;i++){
	cin>>a[i]>>b[i];
	a[i]--;b[i]--;
}

//	ans[m-1]=uf.isolated();
	ans[m-1]=n*(n-1)/2;
	for(int i=m-1;i>0;i--){
	
	ans[i-1]=ans[i];
	if(uf.same(a[i],b[i]))continue;		
    ans[i-1]-=uf.size(a[i])*uf.size(b[i]);
	uf.unite(a[i],b[i]);
	}
	for(auto&& w:ans)cout<<w<<endl;

}


Measured memory_bytes: 5248
/**
 * author: Surendra Dhaakad
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    int x ,y ,z;
    
    cin >> x >> y >> z;
    
    swap(x, y);
   
   
    swap(x,z);
    
    cout << x <<" "<< y<<" " << z<<"\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll a,b;
    cin >> a >> b;
    auto f = [](ll n){
        if(n==1) return (ll)1;
        if(n==2) return (ll)0;
        return n-2;
    };
    pr(f(a)*f(b));
}

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

int main()
{
    int n,m,cl,cr;
    cin >> n >> m;
    int l=1, r=n;
    bool cancel = false;
    for(int i=0; i<m; i++){
        cin >> cl >> cr;
        if(l<cl)l=cl;
        if(cr<r)r=cr;
      	if(r<l){
          cancel = true;
          break;
        }
    }
    if(cancel){
      cout << 0 << endl;
    }else{
    	cout << r-l+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	cout << ((n == m) ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main (){
    string n;
    cin >> n;
    int l = n.length();
    int x[l];
    for(int i=0; i<l; i++) {
        x[i] =  (n[i] - '0');
    }
    for(int j=l-1; j>0; j--){
        if(x[j] != 9){
            x[j-1] -= 1;
            x[j] = 9;
        }
    }
    int sum=0;
    for(int i=0; i<l; i++){
        sum += x[i];
    }
    cout << sum << endl;
    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,k; cin >> a >> b >> k;
  set<int> ans;
  
  for(int i = a;i<a+k;i++)
    if(i<=b)
      ans.insert(i);

  for(int i = b;i>b-k;i--)
    if(i>=a)
      ans.insert(i);

  //sort(ans.begin(),ans.end());
  for(auto itr = ans.begin(); itr != ans.end(); itr++)
    cout << *itr << endl;
  
  return 0;
}


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

int main (void) {
    int a, b;
    scanf("%d%d", &a, &b);

    int large, small;
    if ( a>b ) {
        large = a;
        small = b;
    } else {
        large = b;
        small = a;
    }
    long long ans = large;
    while ( ans%small != 0 )
        ans += large;

    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split(" ").map!{|i| i.to_i}
sum = 0;frag = true
while frag == true
  a.length.times do |k|
    if a[k] % 2 == 0
      a[k] = a[k]/2
    else frag = false
    end
  end
  sum += 1
end
puts sum-1


Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var S = ReadLine();
            // jを動かしていく
            var dct = new Dictionary<char, int>() { { 'R', 0 }, { 'G', 1 }, { 'B', 2 } };
            var numsi = new long[3];
            var numsk = new long[3];
            for (var k = 1; k < N; ++k)
                ++numsk[dct[S[k]]];
            ++numsi[dct[S[0]]];
            var ans = 0L;
            for (var j = 1; j < N - 1; ++j)
            {
                var sj = dct[S[j]];
                --numsk[sj];
                ans += numsi[(sj + 1) % 3] * numsk[(sj + 2) % 3];
                ans += numsi[(sj + 2) % 3] * numsk[(sj + 1) % 3];
                ++numsi[sj];
                for (var l = 1; l < Min(j + 1, N - j); ++l) 
                {
                    var si = S[j - l];
                    var sk = S[j + l];
                    if (si != S[j] && S[j] != sk && sk != si)
                        --ans;
                }
            }
            WriteLine(ans);
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, q,b,c;
    ll a,sum=0;
    cin >> n;
    map<ll,ll>mp;
    rep(i, n) {
        cin >> a;
        mp[a]++;
        sum += a;
    }
    cin >> q;
    rep(i, q) {
        cin >> b >> c;
        sum -= mp[b] * b;
        sum += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;

        cout << sum << endl;
    }


    return 0;

}


Measured memory_bytes: 9528