akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    int K, N;
    cin >> N >> K;
    vector<int> heights(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> heights[i];
    }
    sort(heights.begin(), heights.end());
    int minDiff = 2000000000;
    for (int i = 0; i <= N - K; ++i)
    {
        int diff = heights[i + K - 1] - heights[i];
        if (diff < minDiff)
        {
            minDiff = diff;
        }
    }
    cout << minDiff << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
#define pb(x) push_back(x)
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(int a, int b){
        return a>b;
    }
};

int n,s,mx=1e9,t;

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> s;
        t+=s;
        if(s%10 && s<mx) mx=s;
    }
    if(!(t%10)){
        if(mx==1e9) cout << 0;
        else cout << t-mx;
    }
    else cout << t;
}


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

int main(){
  vector<vector<int>>data(3,vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> data[i][j];
    }
  }
  int n;
  cin >> n;
  vector<int>a(n);
  rep(k,n) cin >> a[k];
  rep(k,n) {
    rep(i,3){
      rep(j,3){
        if ( a[k] == data[i][j] ) data[i][j] = 0;
      }
    }
  }
  string ans ="No";
  rep(i,3){
    rep(j,3){
      if( data[0][0] == 0 && data[0][1] == 0 && data[0][2] == 0) ans = "Yes";
      if( data[1][0] == 0 && data[1][1] == 0 && data[1][2] == 0) ans = "Yes";
      if( data[2][0] == 0 && data[2][1] == 0 && data[2][2] == 0) ans = "Yes";
      if( data[0][0] == 0 && data[1][0] == 0 && data[2][0] == 0) ans = "Yes";
      if( data[0][1] == 0 && data[1][1] == 0 && data[2][1] == 0) ans = "Yes";
      if( data[0][2] == 0 && data[1][2] == 0 && data[2][2] == 0) ans = "Yes";
      if( data[0][0] == 0 && data[1][1] == 0 && data[2][2] == 0) ans = "Yes";
      if( data[0][2] == 0 && data[1][1] == 0 && data[2][0] == 0) ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

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

  int m = min(X, Y);
  int ans = 0;

  if (A + B < 2 * C) {
    ans += (A + B) * m;
  } else {
    ans += C * m*2;
  }

  X -= m;
  Y -= m;

  ans += min(A, 2 * C) * X + min(B, 2 * C) * Y;

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


Measured memory_bytes: 256
let rec play cards alice bob =
    match cards with
        | []             -> alice - bob
        | [x]            -> (alice + x) - bob
        | x1 :: x2 :: xs -> play xs (alice + x1) (bob + x2)

let () =
    let _ = read_int () in
    let cards =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
		|> List.sort (fun m n -> compare n m)
    in print_endline (string_of_int (play cards 0 0))


Measured memory_bytes: 384
def mainFunc():
    N = int(input())
    arr = list(map(int, input().split(" ")))
    K = 1

    for i in range(len(arr)):
        if K == arr[i]:
            K += 1
    
    if K == 1:
        print(-1)
    else:
        print(N - K + 1)

mainFunc()

Measured memory_bytes: 26140
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, l;
    cin >> n >> l;
    int r = 1000000000, odp;
    int s = 0;
    for (int i = 1; i <= n; ++i)
        s += l + i - 1;
    for (int i = 1; i <= n; ++i)
    {
        if (abs(s - (s - (l + i - 1))) < r)
        {
            r = abs(s - (s - (l + i - 1)));
            odp = s - (l + i - 1);
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
// arc086_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n, k, cnt = 1, total = 0;
  cin >> n >> k;
  vector<int> a(n), ans;
  rep(i,n) cin >> a.at(i);
  sort(a.begin(), a.end());
  for (int i=1;i<n;++i){
    if(a.at(i-1) != a.at(i)) {
      ans.pb(cnt);
      cnt = 1;
    } else {
      cnt++;
    }
  }
  ans.pb(cnt);

  sort(ans.rbegin(), ans.rend());

  if (k >= ans.size()) {
    cout << 0 << endl;
  } else {
    for(int i=0;i<k;++i) {
      total += ans.at(i);
    }
    cout << n - total << endl;
  }
  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  int n,m;
  cin >> n >> m;
  if(m==0){
    if(n!=1)cout << pow(10,n-1) << endl;
    else cout << 0 << endl;
    return 0;
  }
  vector<int>b(m);
  vector<int>c(m);
  rep(i,m) cin >> b[i] >> c[i];
  for(int i=pow(10,n-1);i<pow(10,n);i++){
    string s=to_string(i); 
    bool ok=true;
    rep(j,m){
      if((s[b[j]-1]-'0')!=c[j]) ok=false;
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
  if(n==1){
    string s="0";
    rep(i,m){
      bool ok =true;
      if((s[b[i]-1]-'0')!=c[i]){
        ok=false;
        break;
      }
      if(ok){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  
}


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




int main(){
    int n;
    cin >>n;
    
    int a[n+5];
    int f=0;

    rep(i,n){
        cin >> a[i];
        if(a[i]==1){
            f=1;
        }
    }
    if(!f){
        cout << -1 << endl;
        return 0;
    }

    int c=0;
    int k=0;
    for(int i=1;i<n;i++){
        f=1;
        for(int j=k;j<n;j++){
            if(a[j]==i){
                k=j+1;
                f=0;
                break;
            }
            c++;
        }
        if(f){
            break;
        }
        if(k>=n){
            break;
        }
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc165/tasks/abc165_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    [[nodiscard]]
#elif defined(__GNUC__) && \
    (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
    __attribute__((warn_unused_result))
#endif
    FixPoint : private F {
 public:
  explicit constexpr FixPoint(F && f) noexcept : F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
      noexcept(noexcept(
          F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) makeFixPoint(F&& f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

void solve() {
  ll N, M, Q;
  cin >> N >> M >> Q;

  struct Const {
    ll a, b, c, d;
  };

  V<Const> cs(Q);

  rep(i, Q) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b;
    cs[i] = {a, b, c, d};
  }

  ll res = 0;

  auto dfs = makeFixPoint([&](auto f, VL& arr) -> void {
    ll len = arr.size();

    if (len == N) {
      ll sum = 0;

      for (auto c : cs) {
        if (arr[c.b] - arr[c.a] == c.c) sum += c.d;
      }

      chmax(res, sum);
      return;
    }

    ll last_value = len == 0 ? 1 : arr.back();

    for (ll v = last_value; v <= M; ++v) {
      arr.push_back(v);
      f(arr);
      arr.pop_back();
    }
  });

  VL arr(0);
  dfs(arr);

  cout << res << "\n";
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
   LL l,r;
   cin>>l>>r;
   LL mn=INF;
   for(LL i=l;i<=min(l+2019,r);i++)
   {
       for(LL j=i+1;j<=min(l+2019,r);j++)
       {
           LL mod=((i%2019)*(j%2019))%2019;
           mn=min(mod,mn);
       }
   }
   cout<<mn;
}


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;

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



string s;
void Input() {

    cin >> s;

}



void Solve() {


    if(s == "SUN") {

        cout << "7" << endl;
    }
    if(s == "MON") {

                cout << "6" << endl;

    }
    if(s == "TUE") {

                cout << "5" << endl;

    }
    if(s == "WED") {

                cout << "4" << endl;

    }
    if(s == "THU") {

                cout << "3" << endl;

    }
    if(s == "FRI") {

                cout << "2" << endl;

    }
    if(s == "SAT") {

                cout << "1" << endl;

    }



}

int main() {

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


  return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
 
 long long fa(long long s){
     
     if(s==1){
         return s;
     }else{
        if(s > (1000000000 + 7))
            s %= (1000000000 + 7);

        
         
        return (s* fa(s-1)) % (1000000000 + 7);
     }
 }

int main (){
    long long n,m;
    long long ans=0;
    scanf("%lld %lld",&n,&m);
    //printf("%lld %lld\n",fa(n),fa(m));
    if(n-m == 0 ){
        ans = fa(n)*fa(m)*2;
        if(ans > (1000000000 + 7))
            ans %= (1000000000 + 7);

        
        
        printf("%lld\n",ans);
    }else if (n-m==1 || n-m == -1){
        ans = fa(n)*fa(m);
        if(ans > (1000000000 + 7))
            ans %= (1000000000 + 7);

       
        
        printf("%lld\n",ans);
    }else{
        printf("0\n");
    }

    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,S,A[3010],dp[3010]={0},i,j,a,ans=0;
  scanf("%lld%lld",&N,&S);
  rep(i,N)scanf("%lld",&A[i]);
  dp[0]=1;
  rep(i,N)for(j=S-1;j>=0;j--){
    if(j+A[i]>S)continue;
    a=1;
    if(j==0)a*=i+1;
    if(j+A[i]==S)a*=N-i;
    dp[j+A[i]]+=dp[j]*a%MOD;
    dp[j+A[i]]%=MOD;
  }

  printf("%lld\n",dp[S]);
	return 0;
}


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

int main() {
    string s; cin >> s;

    int l = s.size() / 2;
    string t = s.substr(0, l);
    reverse(s.begin(), s.end());
    string u = s.substr(0, l);

    int hag = 0;
    for (int i = 0; i < l; i++) {
        if (t[i] != u[i]) ++hag;
    }

    cout << hag << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 10];
int head[MAXN],sumE;
int N,a,b;
int x[MAXN],y[MAXN],D,id[MAXN],cnt[MAXN];
pii p[MAXN],tmp[MAXN];
int st[MAXN],ed[MAXN];
int fa[MAXN];
int getfa(int x) {
    return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
void Merge(int x,int y) {
    fa[getfa(x)] = getfa(y);
}
void AddE(int on) {
    for(int i = 1 ; i <= N ; ++i) {
	id[i] = i;
    }
    sort(id + 1,id + N + 1,[](int a,int b){return p[a] < p[b];});
    memset(st,0,sizeof(st));memset(ed,0,sizeof(ed));
    
    for(int i = 1 ; i <= N ; ++i) {
	tmp[i] = p[id[i]];
    }
    for(int i = 1 ; i <= N ; ++i) {
	int l = lower_bound(tmp + 1,tmp + N + 1,mp(tmp[i].fi + D,tmp[i].se - D + on)) - tmp;
	int r = upper_bound(tmp + 1,tmp + N + 1,mp(tmp[i].fi + D,tmp[i].se + D - on)) - tmp - 1;
	if(l <= r) {
	    st[l]++;ed[r]++;
	    Merge(id[i],id[l]);
	    cnt[id[i]] += r - l + 1;
	}
    }
    int pre = 0;
    for(int i = 1 ; i < N ; ++i) {
	pre += st[i];pre -= ed[i];
	if(pre) Merge(id[i],id[i + 1]);
    }
}
void Solve() {
    read(N);read(a);read(b);
    for(int i = 1 ; i <= N ; ++i) {
	read(x[i]);read(y[i]);
	fa[i] = i;
    }
    
    D = abs(x[a] - x[b]) + abs(y[a] - y[b]);
    for(int i = 1 ; i <= N ; ++i) p[i] = mp(x[i] + y[i],x[i] - y[i]);
    AddE(0);
    for(int i = 1 ; i <= N ; ++i) swap(p[i].fi,p[i].se);
    AddE(1);
    int64 ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(getfa(i) == getfa(a)) ans += cnt[i];
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 7168
S = input()
even_1 = 0
odd_1 = 0
even_2 = 0
odd_2 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "1":
            even_1 += 1
        else:
            even_2 += 1
    else:
        if S[i] == "0":
            odd_1 += 1
        else:
            odd_2 += 1
print(min(even_1+odd_1, even_2+odd_2))


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>

int n;

typedef struct{
    char name[256];
    int cost;
    char used[100][256];
    int size;
} ITEM;

ITEM list[100];

int getCost(int vertex)
{
    int i, j;
    int ans;
    
    if (list[vertex].size == 0){
        return (list[vertex].cost);
    }
    else {
        ans = 0;
        for (i = 0; i < list[vertex].size; i++){
            for (j = 0; j < n; j++){
                if (strcmp(list[vertex].used[i], list[j].name) == 0){
                    ans += getCost(j);
                }
            }
        }
        list[vertex].cost = list[vertex].cost > ans ? ans : list[vertex].cost;
    }
    return (list[vertex].cost);
}

int main(void)
{
    int i, j, k;
    int m, kk;
    char key[256], temp[256];
    int look, sum;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%s%d", list[i].name, &list[i].cost);
            list[i].size = 0;
        }
        
        scanf("%d", &m);
        for (i = 0; i < m; i++){
            scanf("%s", key);
            for (j = 0; j < n; j++){
                if (strcmp(key, list[j].name) == 0){
                    look = j;
                }
            }
            scanf("%d", &kk);
            list[look].size = kk;
            for (j = 0; j < kk; j++){
                scanf("%s", temp);
                for (k = 0; k < n; k++){
                    if (strcmp(temp, list[k].name) == 0){
                        strcpy(list[look].used[j], temp);
                    }
                }
            }
        }
        scanf("%s", key);
        for (j = 0; j < n; j++){
            if (strcmp(key, list[j].name) == 0){
                look = j;
            }
        }
        
        printf("%d\n", getCost(look));
        
    }
    
    return (0);
}

Measured memory_bytes: 1204
//MISHON69
//DATE:6/22/2020
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  FOR(i,n)
  cin>>a[i];
  int count=0;
  FOR(i,n){
     if(a[i]>=k)
     count++;
  }
  cout<<count<<endl;
}  


Measured memory_bytes: 4012
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
#define sz(x) (int)(x.size())
#define all(x) (x).begin(),(x).end()
template<typename tp> void read(tp &x) {cin >> x;}
template<typename tp, typename... Args> void read(tp& x, Args&... args) {read(x);read(args...);}
const int mxN = (int)1e5,INF = (int)1e9,MOD = (int)1e9+7;

void solve()
{
	int k,x;
	read(k,x);
	cout << (k*500>=x?"Yes":"No");
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int test = 1;
	//read(test);
	while(test--)
		solve();
	return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;

int main()
{
  string s, t;
  cin >> s;
  cin >> t;

  s.push_back(t[t.size()-1]);

  cout << (s == t ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<ll> num(K + 1, 0);
    ll ans = 0;
    FOR(i, 1, N + 1) { num[i % K]++; }
    REP(a, K) {
        if ((a + a) % K == 0) {
            ans += num[a] * num[a] * num[a];
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,a[100002],visited[100002],n=1,cnt=0;
  REP(i,100002)visited[i] = 0;
  cin >> N;
  REP(i,N)cin >> a[i+1];
  while(!visited[n]){
    if(n == 2){
      cout << cnt << endl;
      return 0;
    }else{
      visited[n] = 1;
      cnt++;
      n = a[n];   
    }
  }
  cout << -1 << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

int main(){
    int n;
    cin>>n; 
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> b(n,0);
    int ans=0;
    for(int i=n-1;i>=0;i--){
        int now=i+1;
        int widt=now;
        int num=0;
        for(;now<=n;now+=widt){
            num+=b[now-1];
        }
        if(num%2==a[i]){
            b[i]=0;
        }else{
            b[i]=1;
            ans++;
        }
    }
    cout<<ans<<endl;
    for(int i=0;i<b.size();i++){
        if(b[i]) cout<<i+1<<" ";
    }
    cout<<endl;

}

Measured memory_bytes: 4836
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	char c;

	cin >> c;

	switch(c)
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			cout << "vowel" << endl;
			break;

		default:
			cout << "consonant" << endl;

	}

	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	unordered_map<int, int> v[2];
	for( int i = 0; i < n; ++i ) {
		int a;
		cin >> a;
		v[i&1][a] += 1;
	}

	int x[2][2] = {};
	for( int i = 0; i < 2; ++i ) {
		for( auto& p: v[i] ) {
			if( p.second > v[i][x[i][0]] ) {
				x[i][1] = x[i][0];
				x[i][0] = p.first;
			}
			else if( p.second > v[i][x[i][1]] ) {
				x[i][1] = p.first;
			}
		}
	}

	if( x[0][0] != x[1][0] ) {
		cout << n - v[0][x[0][0]] - v[1][x[1][0]] << endl;
	}
	else {
		cout << min( n-v[0][x[0][0]]-v[1][x[1][1]], n-v[0][x[0][1]]-v[1][x[1][0]] ) << endl;
	}

	return 0;
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> pref_year(m);
    vector<ll> yearPref[n+1];
    REP(i, m) {
        ll p, y; cin >> p >> y;
        pref_year[i] = make_pair(p, y);
        yearPref[p].push_back(y);
    }
    REP(i, n+1) sort(ALL(yearPref[i]));
    REP(i, m) {
        ll pref = pref_year[i].first;
        ll year = pref_year[i].second;
        ll num = lower_bound(ALL(yearPref[pref]), year) - yearPref[pref].begin() + 1;
        cout << setw(6) << setfill('0') << pref << setw(6) << setfill('0') << num << endl;
    }
    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>

int main(){
   int i, n, R, Rmin, diff_max;
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%d",&R);
      if(i==1||R-Rmin>diff_max) diff_max=R-Rmin;
      if(i==0||R<Rmin) Rmin=R;
   }
   printf("%d\n",diff_max);
   return 0;
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> cd(0);
  
  for(int i = min(A, B); i >= 1; i--) {
    if(A % i == 0 && B % i == 0) {
      if(K == 1) {
        cout << i << endl;
        break;
      }
      else {
        K--;
      }
    }
  }
}

Measured memory_bytes: 256
// ABC 147-D
// 2019.12.23 bal4u

#include <stdio.h>
#include <ctype.h>

typedef long long ll;

#define gc() getchar_unlocked()

ll in() {   // 非負整数の入力
	ll n = 0; int c;
	do c = gc();
	while (isspace(c));
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define M 1000000007
int N;
int f[64];

int main()
{
	int i, n;
	ll A, ans, b;
	
	N = (int)in();
	n = N; while (n--) {
		A = in();
		for (i = 0; A; A >>= 1, ++i) {
			if (A & 1) ++f[i];
		}
	}
	ans = 0, i = 61, b = 1LL << i;
	for ( ; i >= 0; b >>= 1, --i) if (f[i]) {
		ans = (ans + b % M * ((ll)f[i]*(N-f[i]) % M)) % M;
	}
	printf("%d\n", (int)ans);
	return 0;
}


Measured memory_bytes: 128
use std::cmp;
use whiteread::parse_line;

fn main() {
    let (n, k): (u64, u64) = parse_line().unwrap();
    let mut n: i128 = n as i128;
    let k: i128 = k as i128;
    while (n - k).abs() < n {
        n = cmp::min((n - k).abs(), n % k);
    }
    println!("{}", n);
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	double r;cin>>r;
	cout << 2.00000000 * r * 3.141592 << endl;
	return 0;
}

Measured memory_bytes: 3780
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#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 llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    ll N,a,b,c;
    vector<ll> A,B,C;
    cin >> N;
    llrep(i,N){
        cin >> a;
        A.push_back(a);
    }
    llrep(i,N){
        cin >> b;
        B.push_back(b);
    }
    llrep(i,N){
        cin >> c;
        C.push_back(c);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll cnt=0;
    llrep(i,N){
        b = B[i];
        auto cntA = lower_bound(A.begin(), A.end(), b);
        auto cntC = upper_bound(C.begin(), C.end(), b);
        ll cntA_ll = distance(A.begin(), cntA);
        ll cntC_ll = C.size() - distance(C.begin(), cntC);
        cnt += (cntA_ll * cntC_ll);
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3444
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  bool people[31]; FOR(i,0,31) people[i] = false;
  FOR(i,0,28) {
    int in; cin >> in;
    people[in] = true;
  }
  FOR(i,1,31) {
    if(!people[i]) cout << i << endl;
  }
  return 0;
}

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

int main() {
	double x, h;
	while (cin >> x >> h&&x != 0 && h != 0) {
		double root = sqrt((x*x/4)+(h*h));
		double y = x*x + 2 * x*root;
		cout <<fixed<<setprecision(6)<< y << endl;;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

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

    int r, c;
    cin >> r >> c;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    vector<vector<ll>> dist(r, vector<ll>(c, INF)), dp(r, vector<ll>(c, 0));
    queue<P> que;
    que.push(P(sx, sy));
    dist[sx][sy] = 0;
    dp[sx][sy] = 1;
    while (!que.empty())
    {
        int x = que.front().first, y = que.front().second;
        que.pop();
        int nx, ny;
        for (int i = 0; i < 4; i++)
        {
            nx = x + dx[i];
            ny = y + dy[i];
            if (nx < 0 || r <= nx || ny < 0 || c <= ny)
                continue;
            if (dist[nx][ny] < dist[x][y] + 1)
                continue;
            if (dist[nx][ny] == INF)
            {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
            dp[nx][ny] = (dp[nx][ny] + dp[x][y]) % MOD;
        }
        nx = x;
        ny = 0;
        if (dist[nx][ny] >= dist[x][y] + 1)
        {
            if (dist[nx][ny] == INF)
            {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
            dp[nx][ny] = (dp[nx][ny] + dp[x][y]) % MOD;
        }
        nx = x;
        ny = c - 1;
        if (dist[nx][ny] >= dist[x][y] + 1)
        {
            if (dist[nx][ny] == INF)
            {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
            dp[nx][ny] = (dp[nx][ny] + dp[x][y]) % MOD;
        }
        nx = 0;
        ny = y;
        if (dist[nx][ny] >= dist[x][y] + 1)
        {
            if (dist[nx][ny] == INF)
            {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
            dp[nx][ny] = (dp[nx][ny] + dp[x][y]) % MOD;
        }
        nx = r - 1;
        ny = y;
        if (dist[nx][ny] >= dist[x][y] + 1)
        {
            if (dist[nx][ny] == INF)
            {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
            dp[nx][ny] = (dp[nx][ny] + dp[x][y]) % MOD;
        }
    }
    cout << dist[gx][gy] << " " << dp[gx][gy] << endl;
}



Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
ll dp[2][3];
int main()
{
	ll i,j,sum = 0,n;
	cin>>n;
	ll a[n],b[n],c[n];
	for(i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	if(n == 1)
	{
		cout<<max(a[0],max(b[0],c[0]))<<endl;
		return 0;
	}
	for(i=1;i<n;i++)
	{
		dp[1][0] = a[i]+max(dp[0][1],dp[0][2]);
		dp[1][1] = b[i]+max(dp[0][0],dp[0][2]);
		dp[1][2] = c[i]+max(dp[0][0],dp[0][1]);
		for(j=0;j<3;j++)
			dp[0][j] = dp[1][j];
	}
	cout<<max(dp[1][0],max(dp[1][1],dp[1][2]))<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int A[N],j;

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

    for(j=0; j<30; j++){
        int count=0;
        for(int i=0; i<N; i++){
            if (A[i]%2==0) {
                count++;
                A[i]/=2;
            }
        else {break;}
        }
        if (count!=N) break;
    }
    cout << j << endl;
}

Measured memory_bytes: 256
n = int(input())
d,x = map(int,input().split())
a_L = []
for _ in range(n):
    a_L.append(int(input()))

choco = 0
for a in a_L:
    count_L = []
    for i in range(d):
        ans = a*i + 1
        if ans <= d:
            count_L.append(ans)
    #print(count_L)
    choco += len(count_L)

print(x+choco)

Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string str;
    char buff;
    int in, T = 0, F = 0, rev = 1;
    str.reserve(300000);
    cin >> str >> in;
    while (in-- > 0)
    {
        cin >> T;
        if (T == 1)
            rev *= -1;
        if (T == 2)
        {
            cin >> F >> buff;
            if (F == 1)
            {
                if (rev == 1)
                    str.insert(0, &buff);
                if (rev == -1)
                    str.push_back(buff);
            }
            if (F == 2)
            {
                if (rev == 1)
                    str.push_back(buff);
                if (rev == -1)
                    str.insert(0, &buff);
            }
        }
    }
    if (rev == -1)
        reverse(str.begin(), str.end());
    cout << str << endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "NO";
    if (b - a == c - b) ans = "YES";
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  
  private static void roop(int a, int b){
    for(int i = 0; i < a; i++){
      System.out.print(b);
    }
    System.out.println();
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    //char[] a = sc.nextLine().toCharArray();
    if(a < b){
      roop(b,a);
    }
    else
    {
      roop(a,b);
    }
  }
}

Measured memory_bytes: 20948
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, A, B;

int main()
{
    cin >> N >> A >> B;
    ll ab = A + B;
    ll cycle = N / ab;
    ll rest = min(A, N % ab);
    cout << A * cycle + rest << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n)cin >> a[i];
  int mx = 0;
  ll ret = 0;
  rep(i,n){
    if(mx > a[i]){
      ret += mx - a[i];
    }else{
      mx = a[i];
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 3896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    H, W = MAP()
    dx = [1, 0]
    dy = [0, 1]
    s = [input() for _ in range(H)]

    start = (0, 0)

    q = deque()
    q.append(start)

    cost = [[INF]*W for _ in range(H)]
    if s[0][0] == "#":
        cost[0][0] = 1
    else:
        cost[0][0] = 0
    while q:
        i, j = q.popleft()
        for k in range(2):
            y = i + dy[k]
            x = j + dx[k]
            if y < 0 or y > H-1 or x < 0 or x > W-1:
                continue
            if s[i][j] == "." and s[y][x] == "#":  # コストが増える
                if cost[y][x] > cost[i][j] + 1:
                    cost[y][x] = cost[i][j] + 1
                    q.append((y, x))
            elif s[i][j] == "#" and s[y][x] == "#":
                if cost[y][x] > cost[i][j]: 
                    cost[y][x] = cost[i][j]
                    q.append((y, x))
            elif s[i][j] == "." and s[y][x] == ".":
                if cost[y][x] > cost[i][j]:
                    cost[y][x] = cost[i][j]
                    q.append((y, x))
            else:  # # -> .
                if cost[y][x] > cost[i][j]:
                    cost[y][x] = cost[i][j]
                    q.append((y, x))
    # print(cost)
    print(cost[H-1][W-1])

 

if __name__ == '__main__':
    main()


Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
    ll h,w;
    cin >> h>> w;
    vector<string>mass;
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        bool flag = false;
        for(int j=0;j<w;j++){
            if(s[j]=='#'){
                flag = true;
                break;
            }
        }
        if(flag == true){
            mass.push_back(s);
        }
    }

    // cout << endl;
    // for(int i=0;i<mass.size();i++){
    //     for(int j=0;j<w;j++){
    //         cout << mass[i][j];
    //     }
    //     cout << endl << endl;
    // }

    vector<bool>flag(w);
    for(int i=0;i<w;i++){
        flag[i]==false;
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<mass.size();j++){
            if(mass[j][i]=='#'){
                flag[i] = true;
                break;
            }
        }
    }

    for(int i=0;i<mass.size();i++){
        for(int j=0;j<w;j++){
            if(flag[j]==true){
                cout << mass[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e6 + 5;
vector<int>divisors[N];
int n, ans, arr[N], frq[N];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i = 1;i < N;++i)
        for(int j = i;j < N;j += i)
            divisors[j].push_back(i);
    cin >> n;
    for(int i = 0;i < n;++i)
    {
        cin >> arr[i];
        ++frq[arr[i]];
    }
    for(int i = 0;i < n;++i)
    {
        bool valid = 1;
        --frq[arr[i]];
        for(auto &it : divisors[arr[i]])
            if(frq[it])
                valid = 0;
        ++frq[arr[i]];
        ans += valid;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 122484