akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int main(void) {
	//Program Start

	int N, K;
	string S;

	cin >> N;
	cin >> S;
	cin >> K;

	char c = S[K - 1];

	for (int i = 0; i < N; i++) {
		cout << ((S[i] == c) ? c : '*');
	}

	cout << endl;






ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i],B[i] = map(int,input().split())
A.sort()
B.sort()

if N % 2 == 1:
    mid_ind = N//2
    lower = A[mid_ind]
    upper = B[mid_ind]
    print(upper-lower+1)

else:
    mid_a = N//2
    mid_b = mid_a-1
    lower = (A[mid_a]+A[mid_b])/2
    upper = (B[mid_a]+B[mid_b])/2
    print(int((upper-lower)*2+1))



Measured memory_bytes: 75668
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int solve(vector<tuple<int,int,int,int>>& vt, int n, int m, int i, int mn, vecint v) {
  if (i == n) {
    int score = 0;
    for (auto [a,b,c,d]:vt) {
      if (v[b] - v[a] == c) score += d;
    }
    return score;
  } else {
    int mx = 0;
    FOR(j,mn,m+1) {
      //auto nx = v;
      v.push_back(j);
      mx = max(mx, solve(vt, n, m, i+1, j, v));
      v.pop_back();
    }
    return mx;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m,q;
  cin>>n>>m>>q;
  vector<tuple<int,int,int,int>> vt;
  REP(i,q) {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    --a;--b;
    vt.emplace_back(a,b,c,d);
  }
  vecint v;
  cout<<solve(vt,n,m,0,1,v)<<endl;
  return 0;
}


Measured memory_bytes: 3616
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            1000002
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

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

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    int ans = 0;
    int n;
    cin >> n;
    ll a[n];
    int seen[MX_N];
    bool sieve[MX_N];
    memset(sieve, 0, sizeof(sieve));
    memset(seen, 0, sizeof(seen));
    for(int i=0;i<n;++i){
        cin >> a[i];
        ++seen[a[i]];
    }
    sort(a, a+n);
    for(int i=0;i<n;++i){
        if(sieve[a[i]] == 0){
            if(seen[a[i]] == 1){
                ++ans;
            }
            for(ll x=a[i];x<MX_N;x+=a[i]){
                sieve[x] = true;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 10084
s = input()
n = len(s) - 1
sum = 0

for i in range(2 ** n):
    op = [''] * n
    for j in range(n):
        if (i >> j) & 1:
            op[j] = '+'
    t = ""
    for st, nOp in zip(s, op + ['']):
        t += (st + nOp)
    sum += eval(t)

print(sum)  

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin >> N && N){
    int s[400], l[400], p[400];
    REP(i, N) cin >> s[i] >> l[i] >> p[i];
    const int W = 400;
    vector<int> dp(W + 400, -1);
    dp[0] = 0;
    REP(i, W){
      REP(j, N){
        for(int k = s[j]; k <= l[j]; k++){
          dp[i + k] = max(dp[i + k], dp[i] + p[j]);
        }
      }
    }
    int M; cin >> M;
    vector<int> ans;
    bool ok = true;
    REP(iter, M){
      int w; cin >> w;
      if(dp[w] >= 0) ans.push_back(dp[w]);
      else ok = false;
    }
    if(ok){
      REP(i, ans.size()) cout<<ans[i]<<endl;
    }else{
      cout<<-1<<endl;
    }
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for(int i = 0; i < n; i++) cin >> a.at(i) >> b.at(i) >> c.at(i);
  
  vector<vector<int>> dp(3, vector<int>(n));
  dp.at(0).at(0) = a.at(0);
  dp.at(1).at(0) = b.at(0);
  dp.at(2).at(0) = c.at(0);
  for(int i = 1; i < n; i++){
    dp.at(0).at(i) = max(dp.at(1).at(i-1), dp.at(2).at(i-1)) + a.at(i);
    dp.at(1).at(i) = max(dp.at(0).at(i-1), dp.at(2).at(i-1)) + b.at(i);
    dp.at(2).at(i) = max(dp.at(0).at(i-1), dp.at(1).at(i-1)) + c.at(i);
  }
  cout << max(dp.at(0).at(n-1), max(dp.at(1).at(n-1), dp.at(2).at(n-1))) << endl;
}

Measured memory_bytes: 5896
#include <iostream>
#include <limits.h>

using namespace std;

typedef long long int LL;

int main() {
    LL N;
    cin>>N;
    LL actualNumber;
    LL maxNumber=0;
    LL minNumber=0;
    for (int i=0; i<N; i++){
        cin>>actualNumber;
        if (i==0) {
            minNumber = actualNumber;
        }
        if (actualNumber > maxNumber) {
            maxNumber = actualNumber;
        }
        if (actualNumber < minNumber) {
            minNumber = actualNumber;
        }
    }
    cout<<maxNumber-minNumber<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    int s,ans;
    int b[1000000] = {};
    vector<int> a;
    cin >> s;
    a.push_back(s);
    b[s]++;
    for(int i = 0;;i++){
        if(a[i] %2 == 0){
            s = (a[i]/2);
            a.push_back(s);
            b[s]++;
            if(b[s] == 2){
                ans = i;
                break;
            }
        }else{
            s = (3*a[i]+1);
            a.push_back(s);
            b[s]++;
            if(b[s] == 2){
                ans = i;
                break;
            }
        }
    }
    
    cout << (ans+2) << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<math.h>
#include<string>
#include<cstdlib>

typedef long long ll;

using namespace std;

int main()
{
	int n, x ,t, count = 0;

	cin >> n >> x >> t;

	while(n > 0)
	{
		n = n - x;
		count++;
	}

	cout << count*t;
}



Measured memory_bytes: 3604
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
//#pragma GCC optimize ("trapv")

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
//#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) lli((x).size())
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
typedef long double C;

#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}

int main(){
	int a,b,c; cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

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

int main() {
  int n,m;cin>>n>>m;
  vector<int> a(n),b(n),c(m),d(m);
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,m)cin>>c[i]>>d[i];
  rep(i,n){
    int cnt=0,ans=1e9;
    rep(j,m){
      int e=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(e<ans){
        cnt=j+1;
        ans=e;
      }
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    int r;
    while ((r = a%b) > 0) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N, X;
    cin >> N >> X;

    vector<int> d(N);

    int first;
    cin >> first;
    int ans = abs(X-first);
    for (int i = 1; i < N; ++i) {
        int tmp;
        cin >> tmp;

        if (ans) {
            ans = min(ans, gcd(ans, abs(tmp-first)));
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>

int main(void){

	int i, n, a;
	long min, max, sum = 0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d", &a);
		sum +=a;
		if(i ==0){
		min = a;
		max = a;
		}
		else{
		if(max<a){
		max=a;
		}
		if(a<min){
		min=a;
		}
	}
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

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

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  cin >> n;
  int b[MXN];
  FOR(i, 0, n) {
    int x;
    cin >> x;
    a[i] = x;
    b[i] = x;
  }
  sort(b, b + n);
  for (int i = 0; i < n; ++i)
    if (b[n - 1] != a[i])
      cout << b[n - 1] << nl;
    else
      cout << b[n - 2] << nl;

  return 0;
}



Measured memory_bytes: 5224
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    s = sorted([int(input()) for _ in range(n)])
    score_max = sum(s)

    if score_max % 10 == 0:
        candidates = [si for si in s if si % 10 != 0]

        if len(candidates) == 0:
            score_max = 0
        else:
            score_max -= min(candidates)

    print(score_max)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N ,K;
 cin >> N >> K;
  long long total=0;
  vector<long long> H(N);
  for(int i=0; i < N;++i)
    cin >> H[i];
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());
  K =min(K,N);
  for(int i =K;i < N;++i){
  total += H[i];
  }
  cout << total << endl;
  
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}
int main(){
  int n,c=1,d[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&d[i]);
  qsort(d,n,sizeof(int),cmp);
  for(int i=1;i<n;i++)if(d[i-1]<d[i])c++;
  printf("%d",c);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var n = ReadLong();
		var a = ReadLongArray();

		var a0 = 0L;

		for (var i = 1; i < n; i++) {
			a0 = a0 ^ a[i];
		}

		var w = a[0] ^ a0;

		for (var i = 0; i < n; i++) {
			a[i] = a[i] ^ w;
		}

		Console.WriteLine(string.Join(" ", a));
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 66104
/* Fibonacci Number */
#include <stdio.h>

int dp[50];

int fib(int n)
{
    if(n == 0 || n == 1){
        return dp[n] = 1;
    }
    if(dp[n] != -1){
        return dp[n];
    }
    
    return dp[n] = fib(n-1) + fib(n -2);
}

int main()
{
    int n, i;
    for(i=0; i<50; i++){
        dp[i] = -1;
    }
    scanf("%d", &n);
    printf("%d\n", fib(n));

    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>

int main(void) {
	int a, b, c, k;
	scanf("%d%d%d", &a, &b, &c);
	k = 3;
	if (a == b && b == c) k -= 2;
	else if (a == b || b == c || c == a) k--;
	printf("%d\n", k);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(all(a));
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] <= x){
      x -= a[i];
      a[i] = 0;
      //cout << a[i] << " " << x << endl;
    }
  }
  a[a.size()-1]+=x;
  for(auto z: a)if(z == 0)ans++;
  cout << ans << endl;
  return 0;
}


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


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
ll a[505];
cin>>n;
rep(i,1,n)
{
	cin>>a[i];
}
ll ans=a[1];
rep(i,2,n)
{
	ll gg=__gcd(ans,a[i]);
	ans/=gg;
	ans*=a[i];
}
ol(ans);
return 0;
}



Measured memory_bytes: 256
from collections import deque

if __name__ == '__main__':
    N = int(input())
    matches = [[int(x) - 1 for x in input().split()] for _ in range(N)]
    q = deque(range(N))
    days = [0] * N
    pairs = [-1] * N
    while q:
        a = q.popleft()
        match = matches[a]
        if not match:
            continue
        b = match.pop(0)
        if pairs[b] == a:
            days[a] = days[b] = max(days[a], days[b]) + 1
            q.append(a)
            q.append(b)
        else:
            pairs[a] = b
    print(max(days) if not any(matches) else -1)


Measured memory_bytes: 35832
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

n = int(input())
v = list(map(int, input().split()))

dict0 = defaultdict(int)
dict1 = defaultdict(int)

for i in range(n//2):
	dict0[v[2*i]] += 1
	dict1[v[2*i + 1]] += 1

list0 = [(0, 0)]
list1 = [(0, 0)]
for num in dict0:
	bisect.insort(list0, (dict0[num], num))
for num in dict1:
	bisect.insort(list1, (dict1[num], num))

if list1[-1][1] != list0[-1][1]:
	print(n - list1[-1][0] - list0[-1][0])
else:
	print(min(n - list1[-1][0] - list0[-2][0], n - list1[-2][0] - list0[-1][0]))

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


int main()
{
    std::ios_base::sync_with_stdio(0);	
    cin.tie(0);
    cout.tie(0);
    
	
	ll H;
	cin>>H;
	
	ll co = 1;
	ll ans = 0;
	while(H>1)
	{
		ans += co;
		co = co*2;
		H = H/2;
	}
	
	if(H==1)
		ans += co;
	
	
	cout<<ans;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 100001;
int AB[SIZE][2],C[SIZE],slope[SIZE];
int BIT[SIZE];
void ins(int x){
    for(;x<SIZE;x+=x&-x)BIT[x]++;
}
int qq(int x){
    int ret=0;
    for(;x;x-=x&-x)ret+=BIT[x];
    return ret;
}
LL inv_pair(VI& d,int N){
    MS0(BIT);
    LL ret=0;
    REP(i,SZ(d)){
        ret+=qq(d[i]);
        ins(d[i]+1);
    }
    return ret;
}
double solve(int xy,int N){
    double ll=-1e9,rr=1e9;
    LL sum=N*(N-1LL)/2;
    {
        vector<pair<double,int>>pp;
        REP(i,N){
            pp.PB(MP(-AB[i][xy]*1./AB[i][xy^1],i));
        }
        sort(ALL(pp));
        REP(i,N)slope[pp[i].S]=i;
    }
    REP(ker,80){
        double mm=(ll+rr)*0.5;
        vector<pair<double,int>> pp;
        REP(i,N){
            pp.PB(MP((C[i]-AB[i][xy]*mm)/AB[i][xy^1],i));
        }
        sort(ALL(pp));
        VI d;
        REP(i,N){
            d.PB(slope[pp[i].S]);
        }
        LL v=inv_pair(d,N);
        if(v>=(sum+1)/2)rr=mm;
        else ll=mm;
    }
    return (ll+rr)*0.5;
}
int main(){
    DRI(N);
    REP(i,N){
        RIII(AB[i][0],AB[i][1],C[i]);
    }
    printf("%.15f %.15f\n",solve(0,N),solve(1,N));
    return 0;
}


Measured memory_bytes: 3288
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

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

    int v[3]; v[0] = v[1] = v[2] = 0;
    for (const char& ch : S) {
        v[ch-'a']++;
    }
    if (max(v[0], max(v[1], v[2])) - min(v[0], min(v[1], v[2])) > 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define   ll long long int
#define inf 1000000




int main(){

int h,w,m;
cin>>h>>w>>m;
map<int,int> r;
map<int,int> c;
map<int,map<int,int> > mat;
vector<pair<int,int> > tp;
for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    r[a]++;
    c[b]++;
    mat[a][b]++;
    tp.push_back({a,b});
}
int max1=0;
ll ans;
vector<int> px;
for(auto x: r){
    max1=max(max1,x.second);
}

for(auto x: r){
    if(x.second==max1){
        px.push_back(x.first);
    }
}
ans=max1;
sort(px.begin(),px.end());
max1=0;

vector<int> py;
for(auto x: c){
    max1=max(max1,x.second);
}

for(auto x: c){
    if(x.second==max1){
        py.push_back(x.first);
    }
}
ans+=max1;
sort(py.begin(),py.end());

ll totc= (ll)py.size()*px.size();

for(auto x: tp){
    int a=x.first;
    int b=x.second;
    if(binary_search(px.begin(),px.end(),a) && binary_search(py.begin(),py.end(),b) )
        totc--;
}

if(totc>0){
    cout<<ans<<endl;
}
else{
    cout<<ans-1<<endl;
}
}


Measured memory_bytes: 80300
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

void print (int dp[], int n) {
  for (int i = 1; i <= n; i++)
    cout << dp[i] << " ";
  cout << endl;
}

int solve (vector<int> C, int m) {
  int n = C.size();
  int dp[m + 1];

  for (int i = 0; i <= m; i++)
    dp[i] = 1 << 21;
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      if (j - C[i] >= 0)
        dp[j] = min(dp[j], dp[j - C[i]] + 1);
    }
    // print(dp, m);
  }

  return dp[m];
}

int main () {
  int n, m, k;
  vector<int> C;
  cin >> n >> m;
  for (int i = 0; i < m;i++) {
    cin >> k;
    C.push_back(k);
  }
  cout << solve(C, n) << endl;
  return 0;
}


Measured memory_bytes: 3332
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int now,al;
string s,str="abcdefghijk";

bool formula(void){
	
	if(isupper(s[now])){
		now++;
		return s[now-1]=='T';
	}
	
	if(islower(s[now])){
		now++;
		return (al>>(s[now-1]-'a'))&1;
	}
	
	if(s[now]=='('){
		now++;
		bool res1=formula();
		
		if(s[now]=='*'){
			now++;
			bool res2=formula();
			if(s[now]==')')now++;
			return res1&res2;
		}
		if(s[now]=='+'){
			now++;
			bool res2=formula();
			if(s[now]==')')now++;
			return res1|res2;
		}
		if(s[now]=='-' && s[now+1]=='>'){
			now+=2;
			bool res2=formula();
			if(s[now]==')')now++;
			if(res1==true && res2==false)return false;
			return true;
		}
	}
	
	if(s[now]=='-'){
		now++;
		bool res=formula();
		return !res;
	}
}

bool equation(void){
	bool res1=formula();
	now++;
	bool res2=formula();
	return (res1==res2);
}

int main(void){
	
	while(cin >> s,s!="#"){
		bool fg=true;
		for(al=0;al<(1<<11);al++)now=0,fg&=equation();
		if(fg)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int L =-1+sc.nextInt();
    int R =sc.nextInt();
    int d =sc.nextInt();
    int M =L/d;
    int N =R/d;
    System.out.println(N-M);
  }
}

Measured memory_bytes: 35728
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100
using namespace std;
int ans,sum;
char s[MAXN];
int main(){
    SF("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++)
        s[i]-='0';
    for(int i=0;i<n;i++){
        if(s[i]!=0)
            ans=max(ans,s[i]-1+sum+(n-i-1)*9);
        sum+=s[i];
    }
    ans=max(ans,sum);
    PF("%d",ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include <math.h>
using namespace std;

double noudo(double w, double s){
    return s/(w+s);
}


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

    int water=0, sugar=0;
    double ans = -1;
    double defaultNoudo = noudo(100, e);
    //cout << defaultNoudo << endl;

    int nw=0, ns=0;
    for(int i=0; 100*a*i<=f; i++){
        //cout << "a";
        for(int j=0; 100*b*j<=f; j++){
            //cout << "b";
            nw = 100*a*i+100*b*j;
            int max_sugar = e*(i*a+j*b);
            //cout << "(i,j)=" <<i<<" "<< j<<endl;
            //cout << "max_sugar = " << max_sugar << endl;
            for(int k=0; k*c<=max_sugar;k++){
                //cout << "c";
                for(int l=0;k*c+l*d<=max_sugar; l++){
                    //cout << "d";
                    ns = c*k+d*l;
                    //cout << "(i,j,k,l)=" <<i<<" "<< j<<" "<<k<<" "<<l<<endl;
                    if(nw+ns <= f){//総量＆＆濃度
                        double n = noudo((double)nw, (double)ns);
                        //cout << "e";       
                        //cout << n << " "<< nw << " "<<ns <<endl;
                        if(ans < n){
                          //  cout << "f";
                            ans = n;
                            water = nw;
                            sugar = ns;
                        }
                        // if(n==defaultNoudo){
                        //     i=3000;
                        //     j=3000;
                        //     k=3000;
                        //     l=3000;
                        // }
                    }
                }
            }
        }
    }
    cout << water+sugar << " " <<  sugar << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll i,o,t,j,l,s,z;
  cin>>i>>o>>t>>j>>l>>s>>z;
  ll ans=o;
  ll knum=0;
  if(i%2==1) knum++;
  if(j%2==1) knum++;
  if(l%2==1) knum++;
  if(knum==0||knum==3) ans+=i+j+l;
  else if(knum==1) ans+=i+j+l-1;
  else{
    if(i!=0&&j!=0&&l!=0) ans+=i+j+l-1;
    else ans+=i+j+l-2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	a := nextInts(n)

	a = append([]int{0}, a...)
	a = append(a, 0)

	p := 0
	for i := 0; i < len(a)-1; i++ {
		p += absInt(a[i] - a[i+1])
	}
	for i := 1; i < len(a)-1; i++ {
		ans := p
		if (a[i]-a[i-1])*(a[i]-a[i+1]) > 0 {
			ans -= minInt(absInt(a[i]-a[i-1]), absInt(a[i]-a[i+1])) * 2
		}
		fmt.Fprintln(out, ans)
	}

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	//fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 5120
//Tran Thuy Duong
#include <bits/stdc++.h>
#define maxn 400005
#define maxc 1000000009
#define MOD 1000000007
#define reset(x) memset(x, 0, sizeof x)
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;

int a, b, c;

int main()
{
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> a >> b >> c;
    int res = c + b - a;
    cout << (res < 0 ? 0 : res);
	return 0;
}


Measured memory_bytes: 256
// Tenka1_Beginner2019_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll K;
    cin >> K;
    
    // calculation
    char ch = S[K-1];
    REP(i, N) {
        if (S[i] != ch) S[i] = '*';
    }
    
    cout << S << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  scanf("%d %d %d %d", &A, &B, &C, &K);

  if(K <= A) printf("%d\n", K);
  else if(K <= A + B) printf("%d\n", A);
  else  printf("%d\n", A - (K - (A + B)));
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    if(S.at(K-1) == 'A'){
        S.at(K-1) = 'a';
    }
    if(S.at(K-1) == 'B'){
        S.at(K-1) = 'b';
    }
    if(S.at(K-1) == 'C'){
        S.at(K-1) = 'c';
    }
    cout << S << endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                ans+=1
print(ans)

Measured memory_bytes: 9176
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val ans = (1..n).filter { isExp(it) }.max()!!
    println(ans)
}


fun isExp(num:Int):Boolean {
    if(num == 1) {
        return true
    }
    for(i in (2..num)) {
        var cnt = 0
        var tmp = num
        if(i*i>num) {
            break
        }
        while (tmp % i == 0) {
            tmp /= i
            cnt++
        }
        if(tmp == 1 && cnt > 1) {
            return true
        }
    }
    return false
}

Measured memory_bytes: 35432
n, k = map(int, input().split())
a = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x:-x[1])
 
ans = 0
s = set()
q = []
 
for i in range(k):
    ans += a[i][1]
    if a[i][0] in s:
        q.append(a[i][1])
    s.add(a[i][0])
 
ans += len(s)**2
k1 = k
ans1 = ans
 
#はじめ0~k-1までの和がansなので、k~n-1でチェック
while k1 < n and q:
    if a[k1][0] not in s:
        ans1 = ans1+a[k1][1]-q.pop()-len(s)**2+(len(s)+1)**2
        ans = max(ans, ans1)
        s.add(a[k1][0])
    k1 += 1
 
print(ans)

Measured memory_bytes: 22164
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		String i = sc.next();

		if (i.equals("a")) {
			System.out.print("vowel");

		} else if (i.equals("i")) {

			System.out.print("vowel");

		} else if (i.equals("u")) {

			System.out.print("vowel");

		} else if (i.equals("e")) {

			System.out.print("vowel");

		} else if (i.equals("o")) {

			System.out.print("vowel");
		} else {

			System.out.print("consonant");
		}

	}
}


Measured memory_bytes: 23124
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  string str;
  getline(cin,str);
  for(int i = 0;i <str.size();i++){
    str[i]=toupper(str[i]);
    cout <<str[i];
  }
  cout <<endl;
  return 0;
}

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

using namespace std;

class node
{
public:
  int v;
  node *left,*right;

  node(int _v=0)
  {
      v=_v,left=right=NULL;
  }
};

node *root=NULL;

void ins(int a)
{
    node *tmp=new node(a);

    node *x=root,*y=NULL;

    while(x)
    {
        y=x;

        if(a<x->v)
        {
            x=x->left;
        }else
        {
            x=x->right;
        }
    }

    if(!y)
    {
        root=tmp;
    }else if(a<y->v)
    {
        y->left=tmp;
    }else
    {
        y->right=tmp;
    }
}

void in(node *r)
{
    if(!r)  return;

    in(r->left);
    printf(" %d",r->v);
    in(r->right);
}

void pre(node *r)
{
    if(!r)  return ;


    printf(" %d",r->v);
    pre(r->left);
    pre(r->right);
}

void print()
{
    in(root);
    printf("\n");
    pre(root);
    printf("\n");
}


int main()
{
    int n;

    cin>>n;

    string s;
    int a;

    while(n--)
    {
        cin>>s;

        if(s=="insert")
        {
            cin>>a;
            ins(a);
        }else
        {
            print();
        }
    }



    return 0;
}



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

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

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        bool pos=0;
        for(auto x:s)
        {
            pos|=(x=='7');
        }
        if(pos)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
    return 0;
}
















Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N),b(N);
  for(int i = 0; i < N; ++i){
    cin >> a[i];
  }
  int bSum = 0;
  for(int i = 0; i < N; ++i){
    cin >> b[i];
    bSum += b[i];
  }
  int res = bSum + a[0];
  int tmpMax = res;
  for(int i = 1; i < N; ++i){
    res = res - b[i-1] + a[i];
    if(tmpMax < res) tmpMax = res;
  }
  cout << tmpMax << endl;
  
}


Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-05-27
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> per(n), p(n), q(n);
    for (int i = 0; i < n; i++) {
        per[i] = i+1;
    }
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }
    
    int a = 0, b = 0, i = 1;
    do {
        bool ok1 = 1, ok2 = 1;
        for (int i = 0; i < n; i++) {
            if (p[i] != per[i]) ok1 = 0;
            if (q[i] != per[i]) ok2 = 0;
            if (!ok1 && !ok2) break;
        }
        if (ok1) a = i;
        if (ok2) b = i;
        if (a && b) break;
        i++;
    } while (next_permutation(per.begin(), per.end()));
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int[] num = new int[101];
		Arrays.fill(num, 0);
		int mode = 0;
		while(true){
			String tmp = br.readLine();
			//System.out.println("prg");
			if(tmp == null){
				break;
			}
			
			int n = Integer.parseInt(tmp);
			
			num[n]++;
			if(num[n] > mode){
				mode = num[n];
			}
		}
		
		for(int i = 1; i <= 100; i++){
			if(mode == num[i]){
				System.out.println(i);
			}
		}
	}

}

Measured memory_bytes: 24100
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll l[n];
  ll max = 0;
  ll go = 0;
  rep(i,n) {
    cin >> l[i];
    chmax(max,l[i]);
    go+=l[i];
  }
  if(max*2 < go ) {
    pri("Yes");
  }else{
    pri("No");
  } 
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    vec x(n),y(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    sort(all(x));
    sort(all(y));
    bool ok=true;
    if(y[0]<=x[n-1]) ok=false;
    if(x[n-1]>=Y) ok=false;
    if(y[0]<=X) ok=false;
    if(ok) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

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

using namespace std;
using ll=long long;

ll dp[101][100101];
int main()
{
    int n;ll w;cin >>n >>w;
    ll we[n],v[n];
    for(int i=0;i<n;i++)cin>>we[i]>>v[i];
    for(int i=0;i<100101;i++){
        dp[0][i]=1001001001;
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<100101;j++){
            if(j<v[i]){
                dp[i+1][j]=dp[i][j];
            }
            else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+we[i]);
        }
    }
    int ans;
    for(int i=0;i<100101;i++){
        if(dp[n][i]<=w)ans=i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 79232
S = input()
st = [(0, 0, -1)]
cur = 0; ma = 0
for i, c in enumerate(S):
    if c == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append((cur, s, i))
    elif c == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif c == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        ans.append(su)
print(sum(ans))
print(len(ans), *ans)


Measured memory_bytes: 8288
#include <iostream>
#include <string>

int main()
{
    int n;
    std::string s;
    std::cin >> n;
    std::cin >> s;

    for (auto itr = s.begin(); itr != s.end(); ++itr)
    {
        *itr = (*itr + n) > 'Z' ? (*itr + n - 26) : (*itr + n);
    }

    std::cout << s << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<tuple<string,int,int>>score(n);
    rep(i,n){
        string s;
        int p;
        cin>>s>>p;
        p = -p;
        score[i] = tie(s,p,i);
    }
    sort(score.begin(),score.end());
    rep(i,n)cout<<get<2>(score[i]) + 1 <<endl;

    return 0;
}


Measured memory_bytes: 3616