akhauriyash/Code-Regression huggingface dataset:
def main():
    """
    nCr の最大化
    2 <= n <= 10^5
        全組合せでは間に合わない
        sortして必要なものを選ぶ
    0 <= ai <= 10^9
        実際に場合の数を求めていては間に合わない
        階乗でO(N)は時間がかかる+数が大きくて処理時間が長い

    nCr = nPr / r!
        nが大きいほど大きい
        rが大きいほど大きい?
    nCr: 7C4 = 7C3
        if r > n // 2
            7C3: 7*6+5 / 3*2
            7C2: 7*6   /   2
        n-r が大きいほど大きい
    """
    n = int(input())
    *a, = map(int, input().split())

    a = sorted(a)
    m = a[-1]
    m2 = m // 2
    r, r_tmp = 0, 0
    for _a in a:
        tmp = _a
        if _a > m2:
            tmp = m - _a
        
        if tmp > r_tmp:
            r = _a
            r_tmp = tmp

    print(m, r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14424
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,k,i,j,cc=0;
    cin>>n>>k;
    double sum=0.0;
    double x=(1.0/(n*1.0));
    for(i=1;i<=n;i++){
        j=i;
        cc=0;
        while(j<k){
            j=j<<1;
            cc++;
        }
        //cout<<x<<spc<<j<<endl;
        sum+=x*pow(0.5,cc);
    }
    cout<<fixed<<setprecision(12)<<sum<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    rep(i,n){
        int h;
        cin >> h;
        if(h>=k)
            cnt++;
    }
    cout << cnt << endl;
}

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

int n;
int dp[100010];

int main(void){
	cin >> n;
	dp[0]=0;
	for(int i=1; i<=n; i++){
		dp[i]=100001;
		int power = 1;
		while(power<=i){
			dp[i] = min(dp[i], 1+dp[i-power]);
			power *= 6;
		}
		power = 1;
		while(power<=i){
			dp[i] = min(dp[i], 1+dp[i-power]);
			power *= 9;
		}
	}
	cout << dp[n] << endl;
}

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

int main()
{

        int A, B, C;
        cin >> A >> B >> C;

        if ((A == 5 && B == 5 && C == 7) ||
                (A == 5 && B == 7 && C == 5) ||
                (A == 7 && B == 5 && C == 5)) {

                cout << "YES" << endl;
        }
        else {
                cout << "NO" << endl;
        }


}


Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  
  s = 0
  c = 0
  while true
    c += 1
    s += N
    s %= 360
    if s == 0
      println(c)
      break
    end
  end
  
end

main()

Measured memory_bytes: 185424
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  cin >> A;
  if(A == "Sunny") {
    cout << "Cloudy" << endl;
  }
  if(A == "Cloudy") {
    cout << "Rainy" << endl;
  }
  if(A == "Rainy") {
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 3536
# coding: utf-8

def run():
    N, M = map(int, input().split())
    left1 = 1
    left2 = M
    right1 = N -M
    right2 = N
    for idx, i in enumerate((range(1,M,2))):
        print('{} {}'.format(left1+idx, left2-idx))
    for idx, _ in enumerate(range(M+1, 2*M+1, 2)):
        print('{} {}'.format(right1+idx, right2-idx))

if __name__ == "__main__":
    run()

Measured memory_bytes: 9224
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int N,sum=0;
    cin>>N;
    while(N)
    {
        sum+=N%10;
        N=N/10;
    }
    if(sum==1)
    sum=sum*10;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
int main () {
  ll sum = 0;
  ll n;
  cin >> n;
  for (ll i = 1; i < 100000; i++) {
    sum = sum + i;
    if (n <= sum) {
      cout << i<< endl;
      break;
    }
  }   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int siz[200010];
int par[200010];
int depth[200010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}
int siz2[200010];
int par2[200010];
int depth2[200010];
void init2(int n){
  for(int i=0;i<=n;i++){
      par2[i]=i;
      depth2[i]=0;
  }
  rep(i,n+1){
      siz2[i]=1;
  }
}
int root2(int x){
  return par2[x]==x?x:par2[x]=root2(par2[x]);
}
bool same2(int x,int y){
  return root2(x)==root2(y);
}
void unite2(int x,int y){
  x=root2(x);
  y=root2(y);
  ll sx=siz2[x];
  ll sy=siz2[y];
  if(x==y)return;
  if(depth2[x]<depth2[y]){
      par2[x]=y;
  }else{
      par2[y]=x;
      if(depth2[x]==depth2[y])depth2[x]++;
  }
  siz2[root2(x)]=sx+sy;
}
signed main(){
    ll n,k,l;cin>>n>>k>>l;
    init(n);
    init2(n);
    map<pll,ll>ma;
    rep(i,k){
        ll a,b;cin>>a>>b;
        a--;b--;
        unite(a,b);
    }
    rep(i,l){
        ll a,b;cin>>a>>b;
        a--;b--;
        unite2(a,b);
    }
    rep(i,n){
        ll a=root(i);
        ll b=root2(i);
        ma[mp(a,b)]++;
        //cout<<a<<' '<<b<<endl;
    }
    rep(i,n){
        ll a=root(i);
        ll b=root2(i);
        cout<<ma[mp(a,b)]<<' ';
    }
    cout<<endl;
}

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

int main() {
	int n, a, b, c, d;
	cin >> n;
	d = n%10;
	n /= 10;
	c = n%10;
	n /= 10;
	b = n%10;
	n /= 10;
	a = n;
	if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
	else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
int N,L;
  cin>>N>>L;
  string S[150];
  string ans ="";
  for(int i=0; i<N; ++i)
  cin>>S[i];
  
  sort(S,S+N);
  
	for (int i=0;i<N;i++)
      ans+=S[i];
  
  cout<<ans<<endl;
}

  


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

ll solve() {
    ll N, a;
    cin >> N;
    priority_queue<ll> qA;
    vector<ll> A;
    ll km = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        A.push_back(a);
        km += a - N + 1;
    }
    ll ans = 0;
    if ( km > 0 ) {
        for ( int i = 0; i < N; i++ ) {
            ll d = ( A[i] + km ) / ( N + 1 );
            ans += d;
            A[i] = A[i] - d*(N+1);
        }
    }
    for ( int i = 0; i < N; i++ ) {
        qA.push(A[i]);
    }

    for(;;) {
        a = qA.top();
        qA.pop();
        if ( a + ans < N ) break;
        ll d = ( a + ans ) / ( N + 1 );
        if ( d <= 0 ) d = 1;
        ans += d;
        ll aa = a - d*(N+1);
        qA.push(aa);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin >> s;
if (s== "Sunny" ){cout <<"Cloudy"<<endl;  }
else if (s== "Cloudy" ){cout <<"Rainy"<<endl; }
else {cout <<"Sunny"<<endl; }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var ABT = ReadLine().Split().Select(int.Parse).ToArray();
        var A = ABT[0];
        var B = ABT[1];
        var T = ABT[2];
        WriteLine(T / A * B);
    }
}


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

int main() {

	int N;
	string c;
	cin >> N >> c;

	int cntR = 0;
	for (int i = 0; i < N; i++) {
		if (c[i] == 'R') cntR++;
	}
	int ans = 0;
	for (int i = 0; i < cntR; i++) {
		if (c[i] == 'W') ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int X, A; cin >> X >> A;
  if(X<A) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const K = parseInt(input)
    if(K % 2 === 0){
        console.log(Math.pow((K / 2), 2))
    } else {
        let base = Math.floor(K / 2)
        console.log(base * (base + 1))
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2-y2+y1 << ' ' << y2+x2-x1 << ' ' << x1-y2+y1  << ' ' << y1+x2-x1 << endl; 
    return 0;
}

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

#define ll long long
typedef vector<ll> vi;


int main(){
    ll N, K, tmp;
    //ll max_v, min_v;
    ll ans = 10000000000;
    vi arr;

    cin >> N >> K;
    for(ll i = 0 ; i < N ; i++){
        cin >> tmp;
        arr.push_back(tmp);
    }
    sort(arr.begin(), arr.end());
    
    for(ll i = 0; i < N-K+1 ; i++){
        //cout << arr[i-1];
        if(ans > arr[i+K-1] - arr[i]){
            ans = arr[i+K-1] - arr[i];
        }
    }
    cout << ans << endl; 
}

Measured memory_bytes: 1400
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  string S;
  cin >> S;

  for (int bit = 0; bit < Bit(4); bit++) {
    string s = "";
    if (Bitcheck(bit, 0)) s += "A";
    s += "KIH";
    if (Bitcheck(bit, 1)) s += "A";
    s += "B";
    if (Bitcheck(bit, 2)) s += "A";
    s += "R";
    if (Bitcheck(bit, 3)) s += "A";

    if (S == s) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B;
  cin >> A;
  cin >> B;
  if(A <= 8 && B <= 8){
    cout << "Yay!\n";
  }else{
    cout << ":(\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<string> A(N);
  vector<int> B(N);
  map<string, int> m{};
  for (auto& a : A) {
    cin >> a;
    ++m[a];
  }
  for (int i = 0; i < N; ++i) {
    B[i] = m[A[i]];
  }
  auto cnt = *boost::max_element(B);
  set<string> res{};
  for (int i = 0; i < N; ++i) {
    if (B[i] == cnt) {
      auto it = res.find(A[i]);
      if (it == res.end()) {
        res.emplace(A[i]);
      }
    }
  }
  vector<string> ans(res.begin(), res.end());
  for (const auto& s : ans) {
    cout << s << CRLF;
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 37120
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int ct[110];
map<int,int>L;

int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int val=0;
	for(int i=0;i<a;i++){
		val^=p[i];
		int tmp=p[i];
		int t=0;
		while(tmp%2==0){t++;tmp/=2;}
		ct[t]++;
	}
	int sz=0;
	int H=15;
	for(int i=0;i<(1<<H);i++){
		bool ok=true;
		int now=0;
		int cnt=0;
		for(int j=0;j<H;j++){
			if(i&(1<<j)){
				cnt++;
				if(ct[j]==0)ok=false;
				now^=(1<<(j+1))-1;
			}
		}
		if(ok){
			if(L.count(now)){
		//		printf("%d: %d\n",now,cnt);
				L[now]=min(L[now],cnt);
			}else{
				L[now]=cnt;
			}
		}
	}
	int ret=mod;
	for(int i=0;i<(1<<H);i++){
		bool ok=true;
		int now=0;
		int cnt=0;
		for(int j=0;j<H;j++){
			if(i&(1<<j)){
				cnt++;
				if(ct[j+H]==0)ok=false;
				now^=(1<<(j+H+1))-1;
			}
		}
		if(ok){
			if(L.count(val^now)){
				ret=min(ret,cnt+L[val^now]);
			}
		}
	}
	if(ret==mod)ret=-1;
	printf("%d\n",ret);
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll x=5;
	vector<ll> a(x);
	
	for(int i=0;i<x;i++)
		cin>>a[i];
	ll k;
  	cin>>k;
  	if(a[4]-a[0]>k)
      	cout<<":(";
  	else
      	cout<<"Yay!";
  
	return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#define MAX 500001

int size;

int Left(int i){
  return 2*i;
}

int Right(int i){
  return (2*i)+1;
}

void maxHeapify(int A[],int id){
  int l = Left(id);
  int r = Right(id);
  int largest,temp;

  if(l<=size && A[l]>A[id]) largest = l;
  else largest = id;

  if(r<=size && A[r]>A[largest]) largest = r;

  if(largest!=id){
    temp = A[id];
    A[id] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
}

void builtMaxHeap(int A[]){
  int i;
  for(i=size/2 ; i>0 ; i--){
    maxHeapify(A,i);
  }
}

main(){
  int heap[MAX],id;
  
  scanf("%d",&size);
  for(id=1 ; id<=size ; id++){
    scanf("%d",&heap[id]);
  }

  builtMaxHeap(heap);

  for(id=1 ; id<=size ; id++){
    printf(" %d",heap[id]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const ll MOD = 1000000007;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

ll f(ll a, ll b){
    return a * b % MOD;
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> x, y;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        x.pb(tmp);
    }
    ll a = n - 1, b = 1;
    ll sx = 0;
    REP(i, n - 1){
        sx = (sx + f(f(a, b), (x[i + 1] - x[i]))) % MOD;
        a--; b++;
    }
    ll ans = 0;
    REP(i, m){
        ll tmp;
        cin >> tmp;
        y.pb(tmp);
    }
    a = m - 1; b = 1;
    REP(i, m - 1){
        ans = (ans + f(f(f(a, b), (y[i + 1] - y[i])), sx)) % MOD;
        a--; b++;
    }
    cout << ans << endl;
}

// 1 1 1 1 2 3 4
// 0 -1 -2 -3 -4 -4 -4

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C;
  cin >> N >> M >> C;
  int B[M];
  int A[N][M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
    cin >> A[i][j];
    }
  }
  int ans =0;
  
  for(int i=0;i<N;i++){
   int sum=0;
   for(int j=0;j<M;j++){
    sum += A[i][j]*B[j];
   }
   if(sum+C>0)ans+=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> namber(n);
  for (int i = 0;i<n;i++) cin >> namber.at(i);
  sort(namber.begin(), namber.end(),greater<int>());
  int count = 0;
  int below_length = 0;
  for (int i = 0;i < n;i++){
    if (below_length == namber.at(i)) continue;
    below_length = namber.at(i);
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
def cango(l,x):
    n=sum(l)
    if abs(x)>n:
        return False
    dp=[False]*(n+1)
    dp[0]=True
    for i in range(len(l)):
        dp1=[False]*(n+1)
        for j in range(n+1):
            if dp[j]:
                dp1[abs(j-l[i])]=True
                dp1[j+l[i]]=True
        for i in range(n+1):
            dp[i]=dp1[i]
    return dp[abs(x)]

l=eval("['"+input().replace('T',"','")+"']")
for i in range(len(l)):
    l[i]=len(l[i])
x,y=map(int,input().split())
if len(l)==1:
    print(['No','Yes'][x==l[0] and y==0])
elif len(l)==2:
    print(['No','Yes'][x==l[0] and abs(y)==abs(l[1])])
else:
    print(['No','Yes'][cango(l[2::2],x-l[0]) and cango(l[1::2],y)])

Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main() {
	ll N;
	cin >> N;
	ll A[N];
	vector<ll> v;
	for (ll i = 0; i < N; i ++) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (ll i = N - 2; i >= 0; i --) {
		if (A[i] == A[i + 1]) {
			v.push_back(A[i]);
			i --;
		} if (v.size() == 2) {
			cout << v[0] * v[1] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
using P = pair<ll, int>;
int main()
{
    int K;
    cin >> K;
    queue<P> q;
    rep2(i, 1, 10)
    {
        q.push({i, i});
    }
    ll cnt = 0, now = 0, idx = 9;
    while (1)
    {
        auto t = q.front();
        now = t.first;
        int last = now % 10;
        cnt = t.second;
        if (cnt == K)
        {
            cout << now;
            return 0;
        }
        q.pop();
        for (ll i = max(0, last - 1); i <= min(9, last + 1); i++)
        {
            q.push({now * 10 + i, ++idx});
        }
    }
    //   cout << now;
    return 0;
}

Measured memory_bytes: 3456
a,b,c=map(int,input().split())

def comp(a,b,c):
	if a<b and b>=c:
		temp=c
		c=b
		b=temp
	if a>b and b<c:
		temp1=a
		temp2=b
		b=c
		a=temp2
		c=temp1
	if a>=b and b>=c:
		temp=c
		c=a
		a=temp

	print(a,b,c)

comp(a,b,c)

Measured memory_bytes: 7800
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a >= k)
        cout << k << endl;
    else if (a + b >= k)
        cout << a << endl;
    else
        cout << a - (k - a - b) << endl;
}


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

int gcd(int a, int b)
{
    int r;

    r = a % b;

    if(r == 0) {
        return b;
    } else {
        return gcd(b, r);
    }
}

int main()
{
    int N;
    int *A;
    int i;
    int j;
    int answer;
    int g;
    int max_g;
    int left;
    int mid;
    int right;
    int left_g;
    int right_g;

    scanf("%d", &N);
    A = (int *)malloc(sizeof(int) * N);

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

    if(N == 2) {
        if(A[0] > A[1]) {
            answer = A[0];
        } else {
            answer = A[1];
        }
    } else if(N < 10) {
        answer = 0;
        for(i = 0; i < N; i++) {
            if(i == 0) {
                g = A[1];
            } else {
                g = A[0];
            }
            for(j = 0; j < N; j++) {
                if(i == j) {
                    continue;
                }
                if(g >= A[j]) {
                    g = gcd(g, A[j]);
                } else {
                    g = gcd(A[j], g);
                }
            }
            if(answer < g) {
                answer = g;
            }
        }
    } else {
        left = 0;
        right = N;
        mid = (left + right)/2;

        g = A[left];
        for(i = left+1; i < mid; i++) {
            if(g >= A[i]) {
                g = gcd(g, A[i]);
            } else {
                g = gcd(A[i], g);
            }
        }
        left_g = g;

        g = A[mid];
        for(i = mid+1; i < right; i++) {
            if(g >= A[i]) {
                g = gcd(g, A[i]);
            } else {
                g = gcd(A[i], g);
            }
        }
        right_g = g;

        while(1) {
            //printf("%d - %d - %d\n", left_g, answer, right_g);
            //printf("%d:%d:%d\n", left, mid, right);
            if(left_g == right_g) {
                answer = left_g;
                break;
            } else if(left_g > right_g) {
                answer = left_g;
                left = mid;
                mid = (left + right)/2;
            } else {
                answer = right_g;
                right = mid;
                mid = (left + right)/2;
            }
            if(left == mid) {
                break;
            }

            g = answer;
            for(i = left; i < mid; i++) {
                if(g >= A[i]) {
                    g = gcd(g, A[i]);
                } else {
                    g = gcd(A[i], g);
                }
            }
            left_g = g;

            g = answer;
            for(i = mid; i < right; i++) {
                if(g >= A[i]) {
                    g = gcd(g, A[i]);
                } else {
                    g = gcd(A[i], g);
                }
            }
            right_g = g;
        }

        // 前半と、後半にわける
        // 前半の最大公約数
        // 後半の最大公約数
        // を求める
        //
        // 前半と後半を比較し、小さい方に取り替えたい値がある。
        // ( 大きい方は、最大公約数として運用する )
    }

    printf("%d\n", answer);

    free((void *)A);

    return 0;
}

Measured memory_bytes: 512
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

D = INT()
C = LIST()
S = [[]] * D
for i in range(D):
    S[i]  = LIST()
T = [t-1 for t in LIST(D)]
M = 26

last = [0] * M
ans = 0
for i, t in enumerate(T):
    ans += S[i][t]
    for j in range(M):
        last[j] += 1
    last[t] = 0
    for j in range(M):
        ans -= C[j] * last[j]
    print(ans)


Measured memory_bytes: 9652
#include <stdio.h>
int main()
{
  int n,a,b,p=0,q=0,m=0;
  scanf("%d %d %d",&n,&a,&b);
  for(;n>=1;n--){
    q=n;
    
    for(p=0;q!=0;){
      p+=q%10;
      q/=10;
    }
    
   if(p>=a && p<=b){
      m+=n;
    }
  }
  printf("%d",m);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, L;
	cin >> N >> L;
	vector<cat> X(N+1, 0), T(N+1, 0);
	for(int i = 0; i < N; i++) cin >> X[i+1];
	for(int i = 0; i < N; i++) cin >> T[i+1];
	vector<cat> cost[4];
	for(int k = 0; k < 2; k++) {
		for(int l = 0; l < 2; l++) cost[2*k+l].resize(N+1);
		for(int i = 0; i <= N; i++) {
			int t = T[i] % (2*L), t1 = 2*(k ? X[i] : (L-X[i]));
			cost[2*k+k][i] = T[i] + (2*L-t) % (2*L);
			if(t <= t1) cost[2*k+(1-k)][i] = T[i] + t1-t;
			else cost[2*k+(1-k)][i] = T[i] + 2*L+t1-t;
		}
	}
	for(int i = 0; i <= N; i++) for(int j = 0; j < 2; j++) {
		cost[2*0+j][i] += X[i];
		cost[2*1+j][i] -= X[i];
		cost[2*j+0][i] -= X[i];
		cost[2*j+1][i] += X[i];
	}
	cat ans = cost[2][0] + cost[1][N];
	for(int i = 1; i < N; i++) {
		ans += min(cost[0][i], cost[3][i]);
		cost[1][i] -= min(cost[0][i], cost[3][i]);
		cost[2][i] -= min(cost[0][i], cost[3][i]);
//		cerr << cost[1][i] << " " << cost[2][i] << "\n";
	}

	int neg = 0, negpos = 0, negpos_used = 0;
	for(int i = N-1; i > 0; i--) {
		if(cost[2][i] < 0) {
			if(cost[1][i] > 0 && neg > 0) {
				neg--;
				ans -= 2*L;
			}
			else if(cost[1][i] > 0 && negpos_used) {
				negpos++;
				negpos_used--;
			}
			else if(neg > 0) {
				neg--;
				ans -= 2*L;
				negpos_used++;
			}
			else if(negpos > 0 && cost[1][i] > 0) {
				negpos--;
				ans -= 2*L;
			}
			else if(cost[1][i] <= 0) negpos++;
		}
		else if(cost[1][i] <= 0) neg++;
	}
	ans -= (negpos/2) * 2LL * L;

	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 14336
k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("-1")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break


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

int a[9][9],n,b[19];
bool ok[9][9];

int main()
{
	for(int i = 0;i<3;i++)
	{
		for(int j = 0;j<3;j++)cin >> a[i][j];
	}
	cin >> n;
	for(int i = 0;i<n;i++)cin >> b[i];
	for(int i = 0;i<3;i++)
	{
		for(int j = 0;j<3;j++)
		{
			for(int k = 0;k<n;k++)if(a[i][j]==b[k])
			{
				ok[i][j] = 1;
				break;
			}
		}
	}
	cout << ((ok[0][0] and ok[0][1] and ok[0][2]) 
	or (ok[1][0] and ok[1][1] and ok[1][2]) 
	or (ok[2][0] and ok[2][1] and ok[2][2]) 
	or (ok[0][0] and ok[1][0] and ok[2][0]) 
	or (ok[0][1] and ok[1][1] and ok[2][1]) 
	or (ok[0][2] and ok[1][2] and ok[2][2]) 
	or (ok[0][0] and ok[1][1] and ok[2][2]) 
	or (ok[0][2] and ok[1][1] and ok[2][0])?"Yes":"No");
	return 0;
}

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

long double abs(long double x)
{
  return (x < 0.0 ? -x : x);
}

long double sqrt(long double x)
{
  const long double EPS = 1e-8;
  long double x0 = x / 2.0, nx = 0.0;

  while (abs(nx - x0) > EPS){
    nx = x0;
    x0 = (x0 + x / x0) / 2.0;
  }

  return x0;
}

long double pi(int n = 1024)
{
  long double a = 1.0, b = 1.0 / sqrt(2.0), t = 1.0 / 4.0, p = 1;

  for (int i = 1; i < n; i++){
    long double na, nb, nt, np;
    na = (a + b) / 2.0;
    nb = sqrt(a * b);
    nt = t - p * (a - na) * (a - na);
    np = 2.0 * p;

    a = na;
    b = nb;
    t = nt;
    p = np;
  }

  return (a + b) * (a + b) / (4.0 * t);
}

long double fact(int n)
{
  long double ret = 1.0;
  for (int i = 1; i <= n; i++)
    ret *= (long double)i;
  return ret;
}

long double pow(long double x, int n)
{
  if (n == 0) return 1.0;
  long double a = pow(x, n / 2);
  if (n & 1){
    return a * a * x;
  } else {
    return a * a;
  }
}

long double sin(int x, int n = 1000)
{
  long double m_pi = pi();
  long double r = ((long double)x * m_pi) / 180.0;

  //printf("pi : %.15lf\n", (double)m_pi);
  long double ret = 0.0;
  for (int i = 0; i < n; i++){
    long double p = pow(r, 2 * i + 1);
    long double f = fact(2 * i + 1);

    //printf("pow : %lf\nfact : %lf\n", (double)p, (double)f);
    ret += ((long double)pow(r, 2 * i + 1) / (long double)fact(2 * i + 1)) * (i & 1 ? -1.0 : 1.0);
  }

  return ret;
}

long double cos(int x, int n = 1000)
{
  long double m_pi = pi();
  long double r = ((long double)x * m_pi) / 180.0;

  long double ret = 0.0;
  for (int i = 0; i< n; i++){
    ret += ((long double)pow(r, 2 * i) / (long double)fact(2 * i)) * (i & 1 ? -1.0 : 1.0);
  }

  return ret;
}

int main()
{
  long double x, y;
  int d, a;
  x = y = 0.0;

  int r = 90;
  while(true){
    int d, a;
    scanf("%d,%d", &d, &a);
    if (d == 0 && a == 0){
      break;
    }

    x += cos(r) * (double)d;
    y += sin(r) * (double)d;

    r -= a;
  }

  printf("%d\n%d\n", (int)x, (int)y);
}

Measured memory_bytes: 3180
/*
ID: flashysport101
LANG: C++
TASK:
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define F0R(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define F0RR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define FORR(i, a) for (int i = (a) - 1; i >= 0; i--)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define n << "\n"
#define k << " " <<

const int MOD = 1000000007;
const ll INF = 1e18;
const int MAXN = 1e5;
const string name = "drink";

int N, height[MAXN];
ll dp[MAXN];

int main() {
  cin >> N;
  FOR(i,N) cin >> height[i];
  dp[1] = dp[0] + abs(height[1] - height[0]);
  F0R(i,2,N) dp[i] = min(dp[i-1] + abs(height[i] - height[i-1]), dp[i-2] + abs(height[i] - height[i-2]));
  cout << dp[N-1] n;
}





Measured memory_bytes: 1408
const fs = require("fs");
const buffer = fs.readFileSync(0); // STDIN_FILENO = 0
const K = parseInt(buffer.toString());


function* combinations(elements, length) {
  for (let i = 0; i < elements.length; i++) {
    if (length === 1) {
      yield [elements[i]];
    } else {
      let remaining = combinations(elements.slice(i, elements.length), length - 1);
      for (let next of remaining) {
        yield [elements[i], ...next];
      }
    }
  };
}


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

function solve(K) {
  const numbers = Array(K).fill().map((_, i) => i + 1)
  const combs = Array.from(combinations(numbers, 3));
  let result = 0;
  for (let comb of combs) {
    if (comb[0] === comb[1] && comb[1] === comb[2]) {
      result += comb[0]
    } else if(comb[0] === comb[1] || comb[1] === comb[2]) {
      result += 3 * gcd(comb[0], gcd(comb[1], comb[2]));
    }else{
      result += 6 * gcd(comb[0], gcd(comb[1], comb[2]));
    }
  }
  console.log(result)
}

solve(K)

Measured memory_bytes: 354056
/* god is with you dont worry */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define input() ios_base::sync_with_stdio(false);cin.tie(0);
const ll mod=1e9+7;
/*ll power(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1){
			res=res*x;
		}
		x=x*x;
		y=y/2;
	}
	return res;
}*/
void solve(){
    ll a,b,n,z;
    cin>>a>>b>>n;
    ll k=min(b-1,n);
    cout<<(a*k)/b-a*(k/b);
}
int main(){
    input();
    solve();
    return 0;
}

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

int main(){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    int x[N],y[M];
    REP(i,N){
      cin>>x[i];
    }
    REP(i,M){
      cin>>y[i];
    }
    sort(x,x+N);
    sort(y,y+M);
    bool flag=(X<Y) and (x[N-1]<y[0]) and (X<y[0]) and (x[N-1]<Y);
    if(flag){
      cout<<"No War"<<endl;
    }else{
      cout<<"War"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using v = vector<ll>;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T> void chmax(T &a, T b){ a = max(a,b);}
template<typename T> void chmin(T &a, T b){ a = min(a,b);}
const ll INF = (ll)1e9;
void c(){
  ll d,g;
  cin >> d >> g;
  g/=100;

  auto p = v(d,0);
  auto c = v(d,0);
  rep(i,d) {
    cin >> p[i] >> c[i];
    c[i]/=100;
  }

  auto dp = vector<v>(d+1,v(g+1,INF));
  dp[0][0]=0;

  rep(i,d)
    rep(pp,g+1){
      rep(j,p[i]) chmin(dp[i+1][min(g,pp+(i+1)*j)],dp[i][pp]+j);
      chmin(dp[i+1][min(g,pp+(i+1)*p[i]+c[i])],dp[i][pp]+p[i]);
    }
  cout << dp[d][g];
}


int main(){
    c();
    return 0;
}


Measured memory_bytes: 10112
#include <iostream>

main(){
        int x, h, m, s;

        std::cin >> x;  

        h = x/(60*60);
        x = x - 60*60*h;
        m = x/60;
        s = x - 60*m;

        std::cout << h << ":" << m << ":" << s << std::endl;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;

#define int long long 
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)
 
const ll INF = 2e9;
const ll large_P = 1e9 + 7;


signed main(){
  string S, T;
  cin >> S >> T;
  cout << T + S << endl;
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int N, M, Q;

int L, R;

int c[502][502];

int p, q;

int main(){
	cin.tie(0);
	
	cin>>N>>M>>Q;
	
	rep(i, M) {
		cin>>L>>R;
		rep(j, L+1) {
			rep(k, N-R+1) {
				c[j][k+R]++;	
			}
		}
	}
	
	
	rep(i, Q) {
		cin>>p>>q;
		cout<<c[p][q]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 10015
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,M;

struct coin{
  int n; //数字の数
  int c[10]; //コインの各枚数
};

coin dp[SIZE];
int A[9];
int C[9] = {2,5,5,4,5,6,3,7,6};

int main(){
  cin >> N >> M;
  rep(i,0,M){
    int u;
    cin >> u;
    A[i] = u-1;
  }

  rep(i,1,N+1){
    dp[i].n = -1;
  }

  rep(i,0,M){
    rep(j,1,N+1){
      //j本の使い方の最良法
      //A[i]番のコイン

      if(j-C[A[i]] < 0)continue; //A[i]が使えない

      //j-C[A[i]]が作れない
      if(dp[j-C[A[i]]].n == -1)continue;


      if(dp[j].n < dp[j-C[A[i]]].n+1){ //A[i]を使ったほうが枚数が多い
        dp[j] = dp[j-C[A[i]]];
        dp[j].n++;
        dp[j].c[A[i]]++;
      }else if(dp[j].n == dp[j-C[A[i]]].n+1){ //枚数は同じ
        
        //大きい整数から、コイン枚数の大小比較
        bool change = false;
        for(int k=8;k>=0;k--){
          if(k==A[i]){
            if(dp[j].c[k] < dp[j-C[A[i]]].c[k]+1){
              change = true;break;
            }else if(dp[j].c[k] > dp[j-C[A[i]]].c[k]+1){
              change = false;break;
            }
          }else{
            if(dp[j].c[k] < dp[j-C[A[i]]].c[k]){
              change = true;break;
            }else if(dp[j].c[k] > dp[j-C[A[i]]].c[k]){
              change = false;break;
            }
          }
        }
        if(change){
          dp[j] = dp[j-C[A[i]]];
          dp[j].n++;
          dp[j].c[A[i]]++;
        }
      }
    }
  }

  for(int i=8;i>=0;i--){
    rep(j,0,dp[N].c[i])cout << i+1;
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
ll LCM(ll x, ll y) { 
  return x / GCD(x, y) * y;
}

int main(){
  int n; cin >> n; cout << pow(n, 3) << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main() {
	int H,W,i,a;
	while(1) {
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		if(1 <= H && H <=300 && 1 <= W && W <= 300) {
			for(i=0;i<H;i++) {
				for(a=0;a<W;a++) {
					printf("#");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second

vector<vecl> dp;

int main()
{
    ios::sync_with_stdio(false);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    int n, p;
    cin >> n >> p;

    dp.clear();
    dp.resize(n+1,vecl(n+1,0));
    for (int i=0; i<=n; ++i)
        dp[0][i] = 0;
    for (int i=0; i<=n; ++i)
        dp[i][0] = 1;

    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=n; ++j) {
            dp[i][j] = dp[i-1][j]+dp[i-1][j-1];
        }
    }

    int odd = 0;
    int num;
    for (int i=0; i<n; ++i) {
        cin >> num;
        if (num%2)
            odd++;
    }

    int even = n-odd;

    ll res = 0;
    for (int i=p; i<=odd; i+=2) {
        res += dp[odd][i] * (1LL<<even);
    }

    cout << res << endl;
}}

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

int main(){
	int A,B,X;cin >> X >> A >> B;
	int ans=X-A;
	while(ans>=B){
		ans -=B;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define rr pow(10,9)+7
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    ll f = pow(10,9)+7;
    ll n,x,c = 0,y,m;
    cin >>n;
    vector<ll>a,b;
    for (ll i = 0; i < n; i++)
    {
        cin >> x;
        a.push_back(x%f);
    }
    b.push_back(a[n-1]);
    for (ll i = 1; i < n; i++)
    {
        b.push_back(b[i-1]+a[n-i-1]);
    }
    //cout << endl;
    for (ll i = 0; i < n-1; i++)
    {
        c += (a[i] % f)*(b[n-i-2]%f);
        c = c%f;
    }
    cout << c << endl;
    
    
}

Measured memory_bytes: 7952