akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ld long double
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define mp map<ll, ll>
#define um unordered_map<ll, ll>
#define st set<ll> 
#define us unordered_set<ll>
#define vt vector<ll>
#define pll pair<ll, ll>
#define fl(i, x, y) for(ll i=x;i<y;++i)
#define flr(i, x, y) for(ll i=x;i>=y;--i)
 
int main()
{
    ll N; 
    cin>>N;
    vt data(N);
    fl(i,0, N)
    cin>>data[i];

    ll ans = 0;
    fl(bit,0, 60)
    {
        ll mul = (1ll << bit);
        ll count[2]; count[0] = 0; count[1] = 0;
        mul %= mod;
        int cur = 0;
        fl(i, 0, N)
        {
            cur = 0;
            if (data[i] & (1ll << bit)) cur = 1;
            count[cur]++;
        }
        ll prod = count[0] * count[1]; prod %= mod;
        prod *= mul; prod %= mod;
        ans += prod; ans %= mod;
    }
    cout<<ans<<endl;
	
	return 0;
}


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

/* Map使用 */
int main(){
  int N;
  cin >> N;

  map<string, int> mochi;
  string size;
  for(int i = 0; i < N; i++){
    cin >> size;
    if(!mochi.count(size))
      mochi[size] = 1;
  }
  
  cout << mochi.size() << endl;
}

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

int main() {
  int A,B,Counter=0,C5,C4,C3,C2,C1,Work ;
 cin >>A >>B;
   for (int i = A; i<B+1 ; i++) {
   Work = i;
   C1 = Work % 10, Work = (Work-C1)/10;
   C2 = Work % 10, Work = (Work-C2)/10; 
   C3 = Work % 10, Work = (Work-C3)/10;
   C4 = Work % 10, Work = (Work-C4)/10;
   C5 = Work;
   if(C1==C5 && C2==C4){Counter++;}
   } 
   cout << Counter <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;
using ll = long long;

int main() {
	double N, K;
	cin >> N >> K;

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int h;
		cin >> h;
		if (h >= K) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3736
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= b) {
            System.out.println("delicious");
        } else if (b - a <= x) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}


Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x - 1, A))

bukas = [ [] for i in range(N) ]
for i in range(1, N):
    bukas[A[i-1]].append(i)

for b in bukas:
    print(len(b))


Measured memory_bytes: 132032
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int k;
    string s;
    cin >> k >> s;
    cout << s.substr(0, min(k, (int)s.length()));
    if ((int)s.length() > k) cout << "...";
    cout << endl;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, std::vector<long long> V, std::vector<long long> C) {
  long long ans = 0;
  for(int i = 0 ; i < N ; i++){
    ans += max(0ll, V[i] - C[i]);
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> V(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &V[i]);
  }
  std::vector<long long> C(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &C[i]);
  }
  solve(N, std::move(V), std::move(C));
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	int a[110];
	int t;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0) printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import math
A,B,N = [int(i)for i in input().split()]

def func(A, B, N):
  if N>B-1:
    return math.floor(A*(B-1)/B)-A*math.floor((B-1)/B)
  else:
    return math.floor(A*N/B)-A*math.floor(N/B)


print(func(A,B,N))

Measured memory_bytes: 9020
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2 == 1){
    cout<<"No"<<endl;
    return 0;
  }
  bool flag = true;
  REP(i,n/2){
    if(s[i] == s[i+n/2]){
      continue;
    }else{
      flag = false;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0; 
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    int sx, sy;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == 'S') {
                sy = i;
                sx = j;
                break;
            }
        }
    }
    deque<pii> que;
    que.emplace_front(sy, sx);
    const int dx[4] = {-1, 1, 0, 0};
    const int dy[4] = {0, 0, -1, 1};

    for (int i = 0; i < k; ++i) {
        deque<pii> que2;
        while (que.size() != 0) {
            auto p = que.back();
            que.pop_back();
            for (int i = 0; i < 4; ++i) {
                int ny = p.first + dy[i];
                int nx = p.second + dx[i];
                if (0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.') {
                    que2.emplace_front(ny, nx);
                    a[ny][nx] = 'S';
                }
            }
        }
        if (que2.size() == 0)
            break;
        else
            swap(que, que2);
    }
    int ret = 100000;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == 'S') {
                chmin(ret, (i + k - 1) / k);
                chmin(ret, (h - i - 1 + k - 1) / k);
                chmin(ret, (j + k - 1) / k);
                chmin(ret, (w - j - 1 + k - 1) / k);
            }
        }
    }
    cout << ret + 1 << "\n";
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000.0

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

int main(){
    
	int N,K;
	cin>>N>>K;
	
	vector<int> A(N);
	int maxi = 0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		maxi = max(maxi,A[i]);
	}

	
	int g = 0;
	for(int i=0;i<N;i++){
		g = gcd(g,A[i]);
	}
	
	if(K%g!=0||maxi<K){
		cout<<"IMPOSSIBLE"<<endl;
	}
	else{
		cout<<"POSSIBLE"<<endl;
	}
	
	
	
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

class Doubling {
public:
  int N;
  int logK;
  vector<vector<int>> next;

  Doubling(int N, vector<int>& ini, ll K) {
    logK = log2(K);
    next = vector<vector<int>>(logK+1, vector<int>(N));
    rep(i, N) next[0][i] = ini[i];
    rep(k, logK) {
      rep(i, N) {
        next[k+1][i] = (next[k][i] == -1 ? -1 : next[k][next[k][i]]);
      }
    }
  }

  int query(int p, ll q) {
    for(int k=logK; k>=0; k--) {
      if(p == -1) break;
      if((q>>k)&1) p = next[k][p];
    }
    return p;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n); rep(i, n) cin >> X[i];
  ll l; cin >> l;
  vector<int> next(n);
  rep(i, n) next[i] = --upper_bound(all(X), X[i]+l) - begin(X);
  vector<int> rnext(n);
  rrep(i, n) rnext[i] = lower_bound(all(X), X[i]-l) - begin(X);
  Doubling dbl(n, next, n);
  Doubling rdbl(n, rnext, n);
  auto bsearch = [&](int s, int t) {
    int ok = n, ng = 0;
    while(ok-ng>1) {
      int mid = (ok+ng)/2;
      if(s < t) (dbl.query(s, mid)>=t ? ok : ng) = mid;
      else      (rdbl.query(s, mid)<=t ? ok : ng) = mid;
    }
    return ok;
  };
  int q; cin >> q;
  rep(_, q) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    cout << bsearch(a, b) << "\n";
  }
  return 0;
}


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

sunuke = [True for i in range(N)]
for i in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        sunuke[a - 1] = False

count = 0
for i in range(N):
    if sunuke[i] is True:
        count += 1

print(count)


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  ll ans = 0;
  for (ll b = 1; b <= n; ++b) {
    ll q = n / b, r = n % b;
    ans += max(0LL, q * (b - k)) + max(0LL, r + 1 - k);
    if (k == 0) { --ans; }
  }
  printf("%lld\n", ans);
  return 0;
}


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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
const ll MOD = 1e9+7;
const vi dx = {1, 0, -1, 0, 1, -1, -1, 1};
const vi dy = {0, 1, 0, -1, 1, 1, -1, -1};


int main() {
    vvi a(3,vi(3));
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    int n; cin>>n;
    vi b(n);
    rep(i,n){
        cin>>b[i];
    }

    vvi bac(3,vi(3,0));
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(b[k]==a[i][j]){
                    bac[i][j]++;
                }
            }
        }
    }

    bool can = false;
    if(bac[0][0]==bac[0][1]&&bac[0][1]==bac[0][2]&&bac[0][2]==1){
        can = true;
    }
    if(bac[1][0]==bac[1][1]&&bac[1][1]==bac[1][2]&&bac[1][2]==1){
        can = true;
    }
    if(bac[2][0]==bac[2][1]&&bac[2][1]==bac[2][2]&&bac[2][2]==1){
        can = true;
    }
    if(bac[0][0]==bac[1][0]&&bac[1][0]==bac[2][0]&&bac[2][0]==1){
        can = true;
    }
    if(bac[0][1]==bac[1][1]&&bac[1][1]==bac[2][1]&&bac[2][1]==1){
        can = true;
    }
    if(bac[0][2]==bac[1][2]&&bac[1][2]==bac[2][2]&&bac[2][2]==1){
        can = true;
    }
    if(bac[0][0]==bac[1][1]&&bac[1][1]==bac[2][2]&&bac[2][2]==1){
        can = true;
    }
    if(bac[0][2]==bac[1][1]&&bac[1][1]==bac[2][0]&&bac[2][0]==1){
        can = true;
    }
    cout<<(can==true?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int n;
  int v[51];
  int c[51];
  
  int ans = 0;
  scanf("%d", &n);

  for(int cnt = 0; cnt < n; cnt++){
    scanf("%d", &v[cnt]);
  }
  for(int cnt = 0; cnt < n; cnt++){
    scanf("%d", &c[cnt]);
  }

  for(int cnt = 0; cnt < n; cnt++){
    if(v[cnt] - c[cnt] > 0){
      ans += v[cnt] - c[cnt];
    }
  }

  printf("%d\n", ans);
  
}


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

using namespace std;

inline bool in_range(int x) { return 1 <= x and x <= 9; }

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

    if (in_range(a) and in_range(b))
    {
        cout << a * b << endl;
    }
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll a, b, c, d;

signed main(){
	cin >> a >> b >> c >> d;
	cout << max({ a*c,a*d,b*c,b*d }) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int dp1[2][1000000 + 1];
int dp2[2][1000000 + 1];
vector<int> cnt1;
vector<int> cnt2;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep2(i, 1, 200) {
        cnt1.push_back(i * (i + 1) * (i + 2) / 6);
        if ((i * (i + 1) * (i + 2) / 6)% 2 == 1) {
            cnt2.push_back(i * (i + 1) * (i + 2) / 6);
        }
    }
    int cur1 = 1, pre1 = 0;
    int cur2 = 1, pre2 = 0;
    rep(j, 1000000 + 1) {
        dp1[pre1][j] = INF;
        dp2[pre2][j] = INF;
    }
    dp1[0][0] = 0;
    dp2[0][0] = 0;
    rep(i, 200) {
        rep(j, 1000000 + 1) dp1[cur1][j] = INF;
        rep(j, 1000000 + 1) {
            dp1[cur1][j] = dp1[pre1][j];
            if (j - cnt1[i] >= 0) {
                dp1[cur1][j] = min(dp1[cur1][j], dp1[cur1][j - cnt1[i]] + 1);
            }
        }
        swap(cur1, pre1);
    }
    rep(i, cnt2.size()) {
        rep(j, 1000000 + 1) dp2[cur2][j] = INF;
        rep(j, 1000000 + 1) {
            dp2[cur2][j] = dp2[pre2][j];
            if (j - cnt2[i] >= 0) {
                dp2[cur2][j] = min(dp2[cur2][j], dp2[cur2][j - cnt2[i]] + 1);
            }
        }
        swap(cur2, pre2);
    }
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        cout << dp1[pre2][n] << " " << dp2[pre2][n] << endl;
    }
}

Measured memory_bytes: 18792
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int f( char a, char b, char c )
{
    if( a == b && b == c )
    {
        return 0;
    }
    else if( ( b == c && c != a ) ||
             ( c == a && a != b ) ||
             ( a == b && b != c ) )
    {
        return 1;
    }
    else
    {
        return 2;
    }
}

int main()
{
    int N;
    string S[ 3 ];
    cin >> N;
    REP( i, 3 ) cin >> S[ i ];
    int ans = 0;
    REP( i, N ) ans += f( S[ 0 ][ i ], S[ 1 ][ i ], S[ 2 ][ i ] );
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


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

	int n, i, j, k, ans;
	cin >> n;
	vector<vector<int>> c(n, vector<int>(3));
	for (i = 0; i < n; i++) cin >> c[i][0] >> c[i][1] >> c[i][2];

	vector<vector<int>> dp(n, vector<int>(3, -1000000000));
	dp[0] = c[0];
	for (i = 0; i < n - 1; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 3; k++) {
				if (j != k) dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + c[i + 1][k]);
			}
		}
	}

	ans = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	cout << ans << "\n";


	return 0;
}




Measured memory_bytes: 11136
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[][] a = new int[2][n];
		
		for(int i = 0; i < 2; i++) {
			for(int j = 0; j < n; j++) {
				a[i][j] = stdIn.nextInt();
				
			}
		}
		
		int  ans = 0;
		int base = 0;
		
		for(int i = 0; i < n; i++){
			int max = 0;
			base += a[0][i];
			
			max = base;
			
			for(int j = i; j < n; j++) {
				max += a[1][j];
				
			}
			
			ans = Math.max(ans,max);
			
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define MN 5000
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int n,ans=1e9;
vector<int> v1,v2;
char s[MN+5],t[MN+5];
inline int Abs(int x){return x>0?x:-x;}
int main()
{
    n=read();scanf("%s%s",s+1,t+1);
    for(int i=2;i<=n;++i) if(s[i]!=s[i-1]) v1.push_back(i-1);
    for(int i=2;i<=n;++i) if(t[i]!=t[i-1]) v2.push_back(i-1);
    if(n<=2)
    {
        int res=0;
        for(int i=1;i<=n;++i) res+=(s[i]!=t[i]);
        return 0*printf("%d",res);
    }
    int s1=v1.size(),s2=v2.size();
    //for(int i=0;i<s1;++i) printf("%d ",v1[i]);cout<<endl;
    //for(int i=0;i<s2;++i) printf("%d ",v2[i]);cout<<endl;
    for(int i=0-(s[v1[0]]!=t[v2[0]])-s1-(s1&1);i<=s2+1;i+=2)
    {
        int res=0;
        for(register int j=0;j<s1;++j)
        {
            int t=j+i,pos=t<0?0:(t>=s2?n:v2[t]);
            res+=Abs(v1[j]-pos);
        }
        //cout<<"preres="<<res<<endl;
        for(register int j=0;j<s2&&j<i;++j) res+=v2[j];
        for(register int j=s2-1;~j&&j-i>=s1;--j) res+=n-v2[j];
        ans=min(ans,res);
        //cout<<i<<" "<<ans<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readvec<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readlines<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
    }
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
            fn parse(s: &str) -> ($($t),*) {
                let mut tokens = s.split_whitespace();
                ($($t::parse(tokens.next().unwrap())),*)
            }
        }
    }
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn ok(a: Vec<Vec<i32>>) -> bool {
    let c1 = a[0][1] - a[0][0];
    let c2 = a[0][2] - a[0][1];
    let r1 = a[1][0] - a[0][0];
    let r2 = a[2][0] - a[1][0];

    for i in 0..3 {
        if a[i][1] - a[i][0] != c1 {
            return false;
        }
        if a[i][2] - a[i][1] != c2 {
            return false;
        }
        if a[1][i] - a[0][i] != r1 {
            return false;
        }
        if a[2][i] - a[1][i] != r2 {
            return false;
        }
    }
    true
}

fn main() {
    let mut a: Vec<Vec<i32>> = vec![];
    for i in 0..3 {
        a.push(readvec());
    }

    if (ok(a)) {
        println!("Yes");
    } else {
        println!("No");
    }



}

Measured memory_bytes: 4352
# import bisect
# import copy
# import fractions
# import math
import numpy as np
from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    H, W = map(int, input().split())
    maze = [input() for _ in range(H)]

    def bfs(maze, visited, sy, sx):
        queue = deque([[sy, sx]])

        visited[sy][sx] = 0
        while queue:
            y, x = queue.popleft()
            for dy, dx in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                ny, nx = y + dy, x + dx
                if 0<=ny<H and 0<=nx<W and \
                        maze[ny][nx] == "." and visited[ny][nx] == -1:
                    visited[ny][nx] = visited[y][x] + 1
                    queue.append([ny, nx])
        return np.amax(visited)

    ans=-1
    for i in range(H):
        for j in range(W):
            visited = [[-1] * W for _ in range(H)]

            sy,sx=i,j
            if maze[sy][sx]=='.':
                ans = max(ans,bfs(maze, visited, sy, sx))


    print(ans)
resolve()

Measured memory_bytes: 12488
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    int n;
    Solver(LL n):n(n){};
    void solve(){
        vector<vector<int>> a(6);
        int sum = 0;
        for(int i=2; i<=30000; ++i){
            int r = i%6;
            if(r==0 or r==2 or r==3 or r == 4){
                a[r].push_back(i);
                sum+=i;
            }
        }
        if(n<6){
            vector<int> ans;
            if(n==3) ans ={2,5,63};
            if(n==4) ans = {2,3,4,9};
            if(n==5) ans = {2,3,4,6,9};
            Writer wr;
            wr.appendln(ans);
        }else{
            int red = 20000-n;
            int w,x,y,z;
            w = min(1666,red/3);
            red-=w*3;
            x = min(1666,red/3);
            red -= x*3;
            y = min(2499,red/2);
            red -= y*2;
            z = red;
            assert(z<=5000);
            vector<int> ans;
            for(int i=0; i<5000-w*3; ++i){
                ans.push_back(a[2][i]);
            }
            for(int i=0; i<5000-x*3; ++i){
                ans.push_back(a[4][i]);
            }
            for(int i=0; i<5000-y*2; ++i){
                ans.push_back(a[3][i]);
            }
            for(int i=0; i<5000-z; ++i){
                ans.push_back(a[0][i]);
            }
            Writer wr;
            wr.appendln(ans);

        }
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Problem::Solver sol(n);
    sol.solve();
    Problem::Writer::write();
    return 0;
}



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

typedef long long ll;

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   
   int i;
   cin>>i;
   if(i<=999)cout<<"ABC"<<endl;
   else cout<<"ABD"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main (void)
{
  int n;
  scanf("%d\n",&n);
  int a[n];
  for(int i=0;i<n;++i)
  {
    scanf("%d\n",&a[i]);
  }
  scanf("\n");
  int chk=0;
  lli ans=0,sub=0;
  qsort(a,n,sizeof(int),compare_int);
  for(int i=1;i<n;++i)
  {
    if(a[i]==a[i-1])
    {
      ++chk;
      if(chk==2){
        ans = sub*a[i];
        printf("%lld\n",ans);
        return 0;
      }
      sub = a[i];
      ++i;
    }
  }
  puts("0");
  return 0;
}

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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if(a[0]+a[1]==a[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  
  

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

int main(){
    int H,W,h,w;
    int S,s;
    cin>>H>>W>>h>>w;
    S=H*W;
    s=h*W+w*H-h*w;
    cout<<S-s<<endl;
    return 0;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

int rec(int n)
{
	if(n==0) return 1;
	else if(n<0) return 0;
	return rec(n-4)|rec(n-7);
}

int main(){ FastIO;

int n;cin>>n;
int f=rec(n);
cout<<(f ? "Yes" : "No");


return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

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

    int n;
    cin >> n;
    vi a(n), b(n);
    fori(i, n) cin >> a[i];
    fori(i, n) cin >> b[i];
    reverse(all(b));
    int x = -1;
    fori(i,n){
        if(a[i]==b[i]){
            x = a[i];
        }
    }
    if(x==-1){
        cout << "Yes" << endl;
        for(int x:b){
            cout << x << ' ';
        }
        cout << endl;
        return 0;
    }
    vi foo, bar;
    fori(i,n){
        if(a[i]==b[i]){
            foo.pb(i);
        }
        else if(a[i]!=x and b[i]!=x){
            bar.pb(i);
        }
    }
    while(sz(foo) and sz(bar)){
        swap(b[foo.back()], b[bar.back()]);
        foo.pop_back();
        bar.pop_back();
    }
    if(sz(foo)){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int x:b)
            cout << x << ' ';
        cout << endl;
    }

    time_taken();
    return 0;
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	f1(i,n){
		sc(A[i]);
		
	}
	soA;
	f1(i,n){
		if(i>=2 and A[i]==A[i-1])sum=1;
	}
	if(sum)prN;
	else prY;
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 1792
print(({
[0]="pon",
[1]="pon",
[2]="hon",
[3]="bon",
[4]="hon",
[5]="hon",
[6]="pon",
[7]="hon",
[8]="pon",
[9]="hon"
})[tonumber(io.read():sub(-1,-1))])

Measured memory_bytes: 2576
def count(x):
    count = 0
    while x % 2 == 0:
        x //= 2
        count += 1
    return count


def lcm(l):
    from fractions import gcd
    x = l[0]
    for i in range(1, len(l)):
        x = (x * l[i]) // gcd(x, l[i])
    return x


N, M = map(int, input().split())
A = set(map(int, input().split()))
ans = 0

if len(set(map(count, A))) == 1:
    T = lcm(list(map(lambda x: x // 2, A)))
    ans = -(-(M // T) // 2)

print(ans)

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

using namespace std;
int main()
{
   int n,k;
   cin>>n>>k;
   int l=n;
   vector<bool>b(n,0);
   for (int i=0;i<k;i++)
   {
       int d;
       cin>>d;
       for (int j=0;j<d;j++)
       {
           int y;
           cin>>y;
           y--;
           if (b[y]==0)
            l--;
           b[y]=1;
       }
   }
   cout<<l;
   return 0;
}


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

int main() {
    int n;
    cin >> n;
    deque<int> dq;
    for(int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if(i % 2 == 0) dq.push_front(a);
        else dq.push_back(a);
    }

    if(n % 2 != 0) reverse(dq.begin(), dq.end());

    for(auto e : dq) {
        cout << e << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include <cstdio>

int main()
{
  long long a, b, c;
  scanf("%lld%lld%lld", &a, &b, &c);
  if (a + b >= c - 1)
  {
    printf("%lld\n", b + c);
  }
  else
  {
    printf("%lld\n", (a + b + 1) + b);
  }
  return 0;
}

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

int n;
int a;
int b;

int main(){
  cin >> n;
  cin >> a;
  cin >> b;
  int sub;
  if(a>b) sub = a - b;
  if(a<=b) sub = b - a;
  sub = sub -1 ;
  if(sub%2==1) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a + a - 1, b + b - 1}) << '\n';
  return 0;
}


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

using namespace std;

using int64 = long long;

template< typename Monoid >
struct SegmentTree
{
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }

  void build()
  {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const
  {
    return seg[k];
  }
};


int main()
{
  int N, Q;
  scanf("%d %d", &N, &Q);
  SegmentTree< int > seg(N, [](int a, int b) { return min(a, b); }, INT_MAX);
  while(Q--) {
    int T, X, Y;
    scanf("%d %d %d", &T, &X, &Y);
    if(T == 0) seg.update(X, Y);
    else printf("%d\n", seg.query(X, Y + 1));
  }
}



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

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

    double area = double(w)*double(h)/2;
    int canSplit;
    if(w == 2*x && h == 2*y) canSplit = 1;
    else canSplit = 0;
    cout << area << " " << canSplit << endl;
    return 0;
}


Measured memory_bytes: 256
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct

  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m = i then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(m);
        t.node.(m) <- tmp;
        max_heapify m
      end in
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    max_heapify 1;
    ret

  let push x t =
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      let p = parent i in
      if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(p);
        t.node.(p) <- tmp;
        doit p
      end in
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    doit t.size

end

module H = MakeBinaryHeap(struct type t = (int * int) let compare x y = snd x - snd y end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let d = Array.make n max_int in
  let b = Array.make n false in
  d.(0) <- 0;
  b.(0) <- true;
  H.push (0, 0) h;
  while not (H.empty_p h) do
    let (u, x) = H.pop h in
    b.(u) <- true;
    if d.(u) < -x then ()
    else
      List.iter (fun (v, c) ->
        if not b.(v) && d.(v) > d.(u) + c then begin
          d.(v) <- d.(u) + c;
          H.push (v, (-d.(v))) h;
        end) g.(u);
  done;
  d

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> assert false

let make_pair lst = make_pair [] lst

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let g = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> g.(u) <- make_pair l
    | _ -> assert false
  done;
  dijkstra g n |> Array.iteri (fun i e -> Printf.printf "%d %d\n" i e)

Measured memory_bytes: 3960
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    hs = sorted(LI(), reverse=True)
    if k >= n:
        print(0)
    else:
        print(sum(hs[k:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 81868
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if ((a * b) % 2 == 0)
		printf("Even");
	else printf("Odd");
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
struct Dice {
	int top, front, right_face;
	int bottom_face() const { return 7 - top; }
	Dice right() const {
		return Dice{ 7 - right_face, front, top };
	}
	Dice left() const {
		return Dice{ right_face, front, 7 - top };
	}
	Dice up() const {
		return Dice{ front, 7 - top, right_face };
	}
	Dice down() const {
		return Dice{ 7 - front, top, right_face };
	}
};
struct Coordinate {
	int i, j;
	Coordinate right() const {
		return Coordinate{ i, j + 1 };
	}
	Coordinate left() const {
		return Coordinate{ i, j - 1 };
	}
	Coordinate up() const {
		return Coordinate{ i - 1, j };
	}
	Coordinate down() const {
		return Coordinate{ i + 1, j };
	}
};
std::vector<std::pair<Coordinate, Dice>> neighbors(const std::pair<Coordinate, Dice> pair) {
	return std::vector<std::pair<Coordinate, Dice>> {std::make_pair(pair.first.right(), pair.second.right()), std::make_pair(pair.first.left(), pair.second.left()), std::make_pair(pair.first.up(), pair.second.up()), std::make_pair(pair.first.down(), pair.second.down())};
}
int main() {
	int height, width; std::cin >> height >> width;
	std::vector<std::string> state(height); for (auto& line : state) std::cin >> line;
	std::vector<std::vector<std::vector<std::vector<std::vector<bool>>>>> memo(height, std::vector<std::vector<std::vector<std::vector<bool>>>>(width, std::vector<std::vector<std::vector<bool>>>(6, std::vector<std::vector<bool>>(6, std::vector<bool>(6, false)))));
	std::stack<std::pair<Coordinate, Dice>> stack;
	memo[0][0][0][1][2] = true;
	stack.emplace(Coordinate{ 0, 0 }, Dice{ 1, 2, 3 });
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		for (const auto next : neighbors(top)) {
			if (0 > next.first.i || 0 > next.first.j || height <= next.first.i || width <= next.first.j) continue;
			if (memo[next.first.i][next.first.j][next.second.top - 1][next.second.front - 1][next.second.right_face - 1]) continue;
			if (state[next.first.i][next.first.j] - '0' == next.second.bottom_face()) {
				memo[next.first.i][next.first.j][next.second.top - 1][next.second.front - 1][next.second.right_face - 1] = true;
				stack.push(next);
			}
		}
	}
	bool can_reach = false;
	for (auto t = 0; t < 6; ++t) for (auto f = 0; f < 6; ++f) for (auto r = 0; r < 6; ++r) if (memo.back().back()[t][f][r]) can_reach = true;
	std::cout << (can_reach ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 31004
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	ll L, R;
	cin >> L >> R;
	ll res = 2018;

	for(ll i = L; i < R && res; i++) {
		for(ll j = i+1; j <= R && res; j++)
			res = min(res, (i*j) % 2019);
	}

	cout << res;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
#define NILL -1

struct Node{
  int p;
  int l;
  int r;
};
  
struct Node A[N];
int n,B[N];

  
  int rec(int x,int y){
    B[x] = y;
    if(A[x].r != NILL) rec(A[x].r,y);
    if(A[x].l != NILL) rec(A[x].l,y + 1);
  }
  

int main(){
  int i,j,d,v,c,l,r,n,op;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p = A[i].l = A[i].r = NILL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) A[v].l=c;
      else A[l].r = c;
      l=c;
      A[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(A[i].p == -1) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++){
   
    printf("node %d: parent = %d, depth = %d,",i,A[i].p,B[i]);
    if(A[i].p == -1) printf(" root,");
    else if(A[i].l == -1 ) printf(" leaf,");
    else printf(" internal node,");
    printf(" [");
    for(j=0,op=A[i].l;op != -1;j++,op = A[op].r){
      if(j != 0) printf(", ");
      printf("%d",op);
    }
    printf("]\n");  
  }

  return 0;
}



Measured memory_bytes: 6412
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        String[] numbers = new String[n];
        for (int i = 0; i < n; i++) {
            numbers[i] = scanner.next();
        }

        int q = scanner.nextInt();
        String[] patterns = new String[q];
        for (int i = 0; i < q; i++) {
            patterns[i] = scanner.next();
        }

        int count = 0;
        for (int i = 0; i < q; i++) {
            String pattern = patterns[i];
            for (int j = 0; j < n; j++) {
                if (pattern.equals(numbers[j])) {
                    ++count;
                    break;
                }
            }
        }

        System.out.println(count);
    }
}

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

#define M 200005
#define MOD 1000000007
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

int parent[M];
vector<int> adjList[M];
vector<int> Distance;	

void bfs(int source)
{
	queue<int> q;
	q.push(source);
	Distance[source] = 0;
	while(!q.empty())
	{
		int current = q.front();
		q.pop();
		for(int neighbor : adjList[current])
		{
			if(Distance[neighbor] == -1)
			{
				Distance[neighbor] = Distance[current] + 1;
				parent[neighbor] = current;
				q.push(neighbor);
			}
		}
	}

	// for(int i=1;i<=6;i++)
	// 	cout<<"i = "<<i<<"  d = "<<Distance[i]<<"\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,edges;
	cin>>n>>edges;
	
	for(int i=0;i<edges;i++)
	{
		int u,v;
		cin>>u>>v;
		adjList[u].ep(v);
		adjList[v].ep(u);
	}
	
	Distance.assign(n+1,-1);
	memset(parent,-1,sizeof(parent));

	bfs(1);				
	
	string ans = "Yes";
	for(int i=2;i<=n;i++)
	{
		if(parent[i]==-1)
		{
			ans = "No";
			break;
		}
	}

	cout<<ans<<"\n";
	if(ans == "Yes")
	{
		for(int i=2;i<=n;i++)
			cout<<parent[i]<<"\n";
	}

	
}

Measured memory_bytes: 13400
class Main{
    public static void main(String[] a){
    	
    	for (int i = 1;i <= 9;i++) {
    		for (int j = 1; j <= 9; j++) {
    			System.out.println(i + "x" + j + "=" + i*j);
    		}
    	}

    }
}

Measured memory_bytes: 24108