akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut left = vec![0; n + 2];
    let mut right = vec![0; n + 2];
    let mut ip = vec![0; n + 1];
    left[n + 1] = n;
    right[0] = 1;
    for i in 1..(n + 1) {
        let p: usize = it.next().unwrap().parse().unwrap();
        ip[p] = i;
        left[i] = i - 1;
        right[i] = i + 1;
    }
    let mut ans = 0;
    for i in 1..n {
        let x = ip[i];
        let l = left[x];
        let r = right[x];
        if l > 0 {
            ans += i * (l - left[l]) * (r - x);
        }
        if r <= n {
            ans += i * (x - l) * (right[r] - r);
        }
        right[l] = r;
        left[r] = l;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,m;
cin>>n>>m;
if(n==m)
cout<<"Yes";
else
cout<<"No";





}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i=0;i<n;++i) cin >> arr[i];
    sort(arr.begin(), arr.end(), greater<int>());

    long long ans = 0;
    for(int i=0;i<n-1;++i){
        ans += arr[(i+1)/2];
    }
    cout << ans << endl;
}


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

int main(){
    int N;
    cin>>N;
    
    switch(N%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;
        case 3:
            cout<<"bon"<<endl;
            break;
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define N (100009)
using namespace std;
int n,a[N],b[N],c[N],d[N],cnum,dnum,cnt;
bool cmp(int a,int b) {return a>b;}
int main()
{
	cin>>n;
	for (int i=1; i<=n; ++i) cin>>a[i];
	for (int i=1; i<=n; ++i) cin>>b[i];
	
	for (int i=1; i<=n; ++i)
	{
		if (a[i]==b[i]) continue;
		if (a[i]>b[i]) c[++cnum]=a[i]-b[i];//多余 
		else d[++dnum]=b[i]-a[i], cnt++;//缺少 
	}
	sort(c+1,c+cnum+1,cmp);
	int p=0;
	for (int i=1; i<=dnum; ++i)
	{
		while (d[i])
		{
			if (c[p]>=d[i]) {c[p]-=d[i]; break;}
			else {d[i]-=c[p], p++;}
			if (p>cnum) {puts("-1"); return 0;}
		}
	}
	cout<<p+cnt<<endl;
}

Measured memory_bytes: 1408
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        List<String> S = new ArrayList<String>();
        for (int i = 0 ; i < N; i++) {
            S.add(sc.next());
        }
        Collections.sort(S);

        StringBuilder ans = new StringBuilder();
        for (String s :S) {
            ans.append(s);
        }
        System.out.println(ans.toString());

        return;
    }

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;

int dfs(int now, vector<Tree> &a, ll d, vector<ll> &ans)
{
    ans[now] = d % 2;
    for (auto b : a[now])
    {
        if (ans[b.first] == -1)
            dfs(b.first, a, d + b.second, ans);
    }
}

int main()
{
    int n;
    cin >> n;
    vector<Tree> a(n);
    vector<ll> ans(n, -1);
    for (int i = 0; i < n - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        a[u].push_back(make_pair(v, w));
        a[v].push_back(make_pair(u, w));
    }
    dfs(0, a, 0, ans);
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 8576
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <stack>

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

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    ull x;
    scanf("%lld", &x);
    for (int64_t a = -1000; a < 1000; ++a)
        for (int64_t b = -1000; b < 1000; ++b)
        {
            if (a * a * a * a * a - b * b * b * b * b == x)
            {
                printf("%lld %lld", a, b);
                return 0;
            }
        }
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, n) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end(), [](auto const& l, auto const& r) {
    return l.second == r.second ? l.first < r.first : l.second < r.second;
  });
  dump(a);
  vi lr(n), rl(n);
  P p = P(0, INF);
  rep(i, n) {
    if (p.first < a[i].first) p.first = a[i].first;
    if (a[i].second < p.second) p.second = a[i].second;
    lr[i] = max(0, p.second - p.first + 1);
  }
  p = P(0, INF);
  for (int i = n - 1; 0 <= i; i--) {
    if (p.first < a[i].first) p.first = a[i].first;
    if (a[i].second < p.second) p.second = a[i].second;
    rl[i] = max(0, p.second - p.first + 1);
  }
  dump(lr);
  dump(rl);
  ll ans = 0;
  ll sum = 0;
  rep(i, n - 1) {
    sum = lr[i] + rl[i + 1];
    maxs(ans, sum);
  }
  sum = 0;
  int mxi = -1;
  rep(i, n) {
    if (sum < a[i].second - a[i].first + 1) {
      sum = a[i].second - a[i].first + 1;
      mxi = i;
    }
  }
  p = P(0, INF);
  rep(i, n) {
    if (i == mxi) continue;
    if (p.first < a[i].first) p.first = a[i].first;
    if (a[i].second < p.second) p.second = a[i].second;
  }
  sum += max(0, p.second - p.first + 1);
  maxs(ans, sum);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

class card {
  public:
  char s;
  int n;

  card(char s = '0', int n = 0): s(s), n(n) {}

  bool operator < (const card& c) const {
    return n < c.n;
  }
  bool operator == (const card& c) const {
    return (s == c.s && n == c.n);
  }
  bool operator != (const card& c) const {
    return (s != c.s || n != c.n);
  }
  
};

int partition(vector<card>& t, int p, int r) {
  int x = t[r].n, i = p;
  FOR(j, p, r) {
    if (t[j].n <= x) {
      swap(t[i++], t[j]);
    }
  }
  swap(t[i], t[r]);
  return i;
}

void quicksort(vector<card>& t, int p, int r) {
  if (p < r) {
    int q = partition(t, p, r);
    quicksort(t, p, q-1);
    quicksort(t, q+1, r);
  }
}

int main() {
  int n;
  cin >> n;
  vector<card> t(n), ct(n);
  rep(i, n) {
    cin >> t[i].s >> t[i].n;
    ct[i] = t[i];
  }

  stable_sort(ct.begin(), ct.end());
  quicksort(t, 0, n-1);

  bool same = true;
  rep(i, n) {
    if (t[i] != ct[i]) {
      same = false;
      break;
    }
  }
  if (same) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  rep(i, n) {
    cout << t[i].s << " " << t[i].n << endl;
  }


  
  return 0;
}



Measured memory_bytes: 5228
import sys
a=[ [int(i) for i in input().split() ]for _ in range(3)]
#print(a)
n=int(input())
mat=[([0]*3) for _ in range(3) ]
#print(mat)
b=[]
for _ in range(n):
  x=int(input())
  for i in range(3):
    for j in range(3):
      if x==a[i][j] and mat[i][j]==0:
        mat[i][j]=1
#print(mat)
flag=False
for i in range(3):
  s=0
  for j in range(3):
    s+=mat[i][j]
  if s==3:
    print("Yes")
    sys.exit()
for j in range(3):
  s=0
  for i in range(3):
    s+=mat[i][j]
  if s==3:
    print("Yes")
    sys.exit()
if mat[0][0]+mat[1][1]+mat[2][2]==3 or mat[0][2]+mat[1][1]+mat[2][0]==3:
  print("Yes")
  sys.exit()
print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2222;

void check(const string &a, const string &b, bool same[MAX]) {
    REP(i, a.size()) {
        bool ok = true;
        REP(j, b.size()) {
            if (i + j >= a.size()) break;
            if (a[i + j] != b[j] && a[i + j] != '?' && b[j] != '?') {
                ok = false;
                break;
            }
        }
        same[i] = ok;
    }
}

bool same_ab[MAX], same_bc[MAX], same_ac[MAX];
int solve(const string &a, const string &b, const string &c) {
    memset(same_ab, true, sizeof(same_ab));
    memset(same_bc, true, sizeof(same_bc));
    memset(same_ac, true, sizeof(same_ac));

    check(a, b, same_ab);
    check(b, c, same_bc);
    check(a, c, same_ac);

    int ans = INF;
    REP(ab, MAX) {
        REP(bc, MAX) {
            const int ac = ab + bc;
            if (same_ab[ab] && same_bc[bc] && (ac >= MAX || same_ac[ac])) {
                const int cur = max({(int)a.size(), ab + (int)b.size(), ab + bc + (int)c.size()});
                chmin(ans, cur);
            }
        }
    }

    return ans;
}

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;
    string s[] = {a, b, c};

    int ans = INF;
    VI v(3);
    iota(ALL(v), 0);
    do {
        chmin(ans, solve(s[v[0]], s[v[1]], s[v[2]]));
    } while (next_permutation(ALL(v)));

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    int n;
    cin >>n;
    string s,t;
    cin >> s >> t;
    for(int i = 0; i <n; i++){
        cout << s[i]<<t[i];
    }
    cout <<endl;
  return 0;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, K, Q, As):
    rev_point = [0] * (N + 1)
    for A in As:
        rev_point[A] += 1
    for rp in rev_point[1:]:
        if K - (Q - rp) > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    N, K, Q = map(int, input().split())
    As = [int(input()) for _ in range(Q)]
    # Bs = [int(i) for i in input().split()]
    solve(N, K, Q, As)


Measured memory_bytes: 14424
nn = 200200
P = 998244353

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P

C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] % P if 0 <= b <= a else 0
N, M, K = map(int, input().split())
if M == 1:
    print(1 if K == N - 1 else 0)
    exit()
ans = 0
t = pow(M-1, N-1, P)
m = pow(M-1, P-2, P)
for i in range(K+1):
    ans = (ans + t * C(N-1, i)) % P
    t = t * m % P
print(ans * M % P)

Measured memory_bytes: 24484
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 605;
int n, d[N], fac[N], ifac[N], dp[305][305][N], fixedDetominator = 1, sumOfAllDegrees = 0;
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fpow(int a, int p) {
	if (!p) return 1;
	int tmp = fpow(a, p >> 1);
	tmp = mul(tmp, tmp);
	if (p & 1) tmp = mul(tmp, a);
	return tmp;
}
int inv(int a) {
	return fpow(a, mod - 2);
}
int calc(int sz, int sumOfDegrees, int productOfDegrees) {
	sumOfDegrees -= 2 * sz;
	int numerator = 1, detominator = 1;
	numerator = mul(numerator, fac[n - sz - 1]);
	numerator = mul(numerator, sumOfDegrees);
	numerator = mul(numerator, fac[sz - 1]);
	numerator = mul(numerator, productOfDegrees);
	
	detominator = fixedDetominator;
	return mul(numerator, detominator);
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1;
	fw (i, 1, N) fac[i] = mul(fac[i - 1], i);
	fw (i, 0, N) ifac[i] = inv(fac[i]);
	cin >> n;
	fw (i, 0, n) cin >> d[i], sumOfAllDegrees += d[i];
	bool allCycle = 1;
	fw (i, 0, n) if (d[i] != 2) allCycle = 0;
	if (allCycle) {
		//Permute (n!), divide by rotations (n) and reverses (2). So (n - 1)! / 2.
		int ans = fac[n - 1];
		ans = mul(ans, inv(2));
		cout << ans;
		return 0;
	}
	//We have a formula if the cycle vertexes are fixed, depending on sum of degrees, number of vertexes and
	//product of degrees.
	fixedDetominator = 2;
	fw (i, 0, n) fixedDetominator = mul(fixedDetominator, fac[d[i] - 1]);
	fixedDetominator = inv(fixedDetominator);
	//dp[i][sz][deg]: Sum of product of degrees within sz of the first i vertexes, deg is sum of degrees.
	dp[0][0][0] = 1;
	fw (i, 0, n) fw (sz, 0, i + 2) fw (deg, 0, sumOfAllDegrees + 1) if (dp[i][sz][deg]) {
//		cout << "dp[" << i << "][" << sz << "][" << deg << "] = " << dp[i][sz][deg] << "\n";
		add(dp[i + 1][sz][deg], dp[i][sz][deg]);
		if (d[i] > 1) {
			//Add i into the cycle
			add(dp[i + 1][sz + 1][deg + d[i]], mul(dp[i][sz][deg], d[i] - 1));
		}
	}
	int ans = 0;
	fw (sz, 3, n + 1) fw (deg, 0, sumOfAllDegrees + 1) if (dp[n][sz][deg]) {
//		cout << "dp[" << n << "][" << sz << "][" << deg << "] = " << dp[n][sz][deg] << "\n";
		add(ans, calc(sz, deg, dp[n][sz][deg]));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 215424
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if(a != b) ans++;
	if(b != c) ans++;
	if(c != a) ans++;
	if(ans == 0) ans++;
	cout << ans << endl;
	return 0;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int64_t> v(n),c(n);
  rep(i,n){
    cin >> v.at(i);
  }
  rep(i,n){
    cin >> c.at(i);
  }
  int64_t totalvc = 0;
  rep(i,n){
    if(v.at(i) - c.at(i) > 0){
      totalvc += v.at(i) - c.at(i);
    }
  }
  cout << totalvc << endl;
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,m = map(int,input().split())
	sk = []
	for i in range(m):
		sk.append(list(map(int,input().split())))
	p = list(map(int,input().split()))
	ans=0
	for status in range(0,2**n):
		x2status =  base_10_to_n(status,2)
		for i in range(n-len(x2status)):
			x2status = '0'+ x2status
		flag=True
		for i in range(m):
			st = 0
			for j in sk[i][1:]:
				j-=1
				if(x2status[j]=='1'):
					st+=1
			if(st%2!=p[i]):
				flag = False
		if flag:
			ans+=1
	print(ans)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 68184
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
int dp[100001]={};
int dp2[100001]={};

int main() {
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	if(a1+a2+a3>21){
		printf("bust");
	}else{
		printf("win");
	}

	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
int main(){
 int n,i,j;
 long num,maxv,min;
 long R[200001];

 maxv=-1000000000;

 scanf("%d",&n);

 for(i=1;i<=n;i++){
  scanf("%ld\n",&R[i]);
 }

 min=R[1];

 for(i=2;i<=n;i++){

  maxv=fmax(maxv,R[i]-min);
  min=fmin(min,R[i]);

}


 printf("%ld\n",maxv);

return 0;
}

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

typedef long long ll;
// int = ll;

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

	ll a;
	
	cin >> a;
	
	cout << (a*a) << endl;

return 0;	
}


Measured memory_bytes: 3656
//
//  main.cpp
//  ABC175B
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    int l;
    map<int,int>mp;
    rep(i,n){
        cin>>l;
        if(mp.find(l)==mp.end()){
                 mp[l]=1;
        } else{
            int tmp=mp[l];
            mp[l]=++tmp;
        }
    }
    vector<P>stk;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        stk.emplace_back(itr->first,itr->second);
    }
    sort(stk.rbegin(),stk.rend()); // 棒を長い順にソート
    /*rep(i,stk.size()){
        cout<<stk.at(i).first<<" "<<stk.at(i).second<<endl;
    }*/
    ll ans=0;
    int lmt=(int)stk.size();
    for(int i=0;i<lmt;i++){
        for(int j=i+1;j<lmt;j++){
            for (int k=j+1; k<lmt; k++) {
                if(stk.at(k).first+stk.at(j).first>stk.at(i).first){
                    ans+=stk.at(k).second*stk.at(j).second*stk.at(i).second;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 201000;
int n,ans[N];
vector<int> e[N];
struct segment_tree{
	int tag[N*40],s[N*40],lc[N*40],rc[N*40],rt[N],tot;
	void pushdown(int x){
		s[lc[x]]=s[rc[x]]=0;
		tag[lc[x]]=tag[rc[x]]=1;
		tag[x]=0;
	}
	void insert(int &x,int w,int k,int l=1,int r=n){
		if(!x) x=++tot;
		if(l==r){s[x]=k;return;}
		if(tag[x]) pushdown(x);
		int mid=l+r>>1;
		if(w<=mid) insert(lc[x],w,k,l,mid);
		else insert(rc[x],w,k,mid+1,r);
		s[x]=s[lc[x]]+s[rc[x]];
	}
	int query(int &x,int w,int l=1,int r=n){
		if(!x) return 0;
		if(r<=w) return s[x];
		if(tag[x]) pushdown(x);
		int mid=l+r>>1;
		if(w<=mid) return query(lc[x],w,l,mid);
		else return query(lc[x],w,l,mid)+query(rc[x],w,mid+1,r);
	}
	int merge(int x,int y,int l=1,int r=n){
		if(!x||!y) return x+y;
		if(l==r){s[x]+=s[y];return x;}
		int mid=l+r>>1;
		if(tag[x]) pushdown(x);
		if(tag[y]) pushdown(y);
		lc[x]=merge(lc[x],lc[y],l,mid);
		rc[x]=merge(rc[x],rc[y],mid+1,r);
		s[x]=s[lc[x]]+s[rc[x]];
		return x;
	}
	void modify(int&x,int w,int l=1,int r=n){
		if(!x) return;
		if(r<=w){tag[x]=1;s[x]=0;return;}
		int mid=l+r>>1;
		if(tag[x]) pushdown(x);
		modify(lc[x],w,l,mid);
		if(w>mid) modify(rc[x],w,mid+1,r);
		s[x]=s[lc[x]]+s[rc[x]];
	}
	void Modify(int &x,int w){
		insert(x,w,query(x,w)+1);
		if(w>1) modify(x,w-1);
	}
}t;
void dfs(int x,int dad,int mx){
	for(int v:e[x]) if(v!=dad){
		dfs(v,x,max(mx,x));
		ans[v]-=t.query(t.rt[v],mx);
		t.rt[x]=t.merge(t.rt[x],t.rt[v]);
	}
	if(x==1) return;
	ans[x]=1+t.query(t.rt[x],mx);
	t.Modify(t.rt[x],x);
}
void getans(int x,int dad){
	ans[x]+=ans[dad];
	for(int v:e[x]) if(v!=dad) getans(v,x);
}
int main(){
	read(n);
	for(int i=1;i<n;i++){
		int x,y;read(x);read(y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,0,0);
	getans(1,0);
	for(int i=2;i<=n;i++) cout<<ans[i]<<' ';
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 86016
let n = Scanf.scanf " %d" (+) 0
let cs, ss, fs = Array.(make (n - 1) 0, make (n - 1) 0, make (n - 1) 0)
let _ = for i = 0 to n - 2 do Scanf.scanf " %d %d %d" @@ fun a b c -> cs.(i) <- a; ss.(i) <- b; fs.(i) <- c done;
  for j = 0 to n - 1 do let t = ref 0 in for i = j to n - 2 do t := ss.(i) + max 0 ((!t - ss.(i) + fs.(i) - 1) / fs.(i)) * fs.(i) + cs.(i) done; Printf.printf "%d\n" !t done

Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))
res = 0
for x in A:
    res ^= x

for i in range(60):
    if (res >> i) & 1:
        for j in range(N):
            if A[j] >> i & 1:
                A[j] ^= 1 << i
start_point = 0
for i in range(60, -1, -1):
    X = 1 << i
    for j in range(start_point, N):
        if A[j] >> i & 1:
            A[start_point], A[j] = A[j], A[start_point]
            for k in range(N):
                if A[k] >> i & 1 and k!=start_point:
                    A[k] ^= A[start_point]
            start_point += 1
            break
plus=0
for x in A:
    plus ^=x
print(res+plus*2)

Measured memory_bytes: 22896
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7;
int n,ans=0;
int a[4007][4007],ps[200007][2],fac[8007],fiv[8007];
void inc(int&a,int b){
	a+=b-P;
	a+=a>>31&P;
}
int pw(int a,int n){
	int v=1;
	for(;n;n>>=1,a=i64(a)*a%P)if(n&1)v=i64(v)*a%P;
	return v;
}
int C(int a,int b){
	return fac[a+b]*i64(fiv[a])%P*fiv[b]%P;
}
int main(){
	for(int i=fac[0]=1;i<=8000;++i)fac[i]=i64(i)*fac[i-1]%P;
	fiv[8000]=pw(fac[8000],P-2);
	for(int i=8000;i;--i)fiv[i-1]=i64(i)*fiv[i]%P;
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;++i){
		scanf("%d%d",&x,&y);
		++a[2000+x][2000+y];
		ps[i][0]=x,ps[i][1]=y;
		inc(ans,C(x*2,y*2));
	}
	ans=(P-ans)%P;
	for(int i=4000;i>=0;--i){
		for(int j=4000;j>=0;--j){
			inc(a[i][j],a[i+1][j]);
			inc(a[i][j],a[i][j+1]);
		}
	}
	for(int i=1,x,y;i<=n;++i){
		x=ps[i][0],y=ps[i][1];
		inc(ans,a[2000-x][2000-y]);
	}
	printf("%d\n",ans*i64(P+1)/2%P);
	return 0;
}

Measured memory_bytes: 64512
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

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

int main(void) {
	int n; cin >> n;
	vi a(n); rep(n) cin >> a[i];
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((a[i] > a[i - 1] && a[i + 1] > a[i])|| (a[i] < a[i - 1] && a[i + 1] < a[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val (H, W) = listOfInt()
    val (h, w) = listOfInt()
    println((H - h) * (W - w))
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

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

int main()
{
	
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int flag=0,mi;
	if(m2<m1)
	{
		mi=60+m2-m1;
		flag=1;
	}
	else
	{
		mi=m2-m1;
	}

	int hr=h2-h1-flag;
	int time=60*hr+mi;

	int ans=time-k;

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

Measured memory_bytes: 3636
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    // 整数の入力
    string s;
    cin >> s ;
    // 出力
    int count = 0;
    for(int i = 0; i<3; i++){
    	// cout << s[i] << endl;
	if(s[i] == '1'){
	    count += 1;
	}
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const long long MOD = 1000000007;

ll N, K;
ll A[200010];


signed main(){
    cin >> N >> K;
    REP(i, N) cin >> A[i];
    FOR(i, K, N){
        if(A[i - K] < A[i]) PRINT("Yes");
        else PRINT("No");
    }
    return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
 
int main(){
    int A,B;
    cin >> A >> B;
    vector<int> S(A);
    for(int i = 0; i < A; i++){
        cin >> S.at(i);
    }
    int sum = B;
    int count = 0;

    sort(S.begin(), S.end());
    for(int i = 0; i < A; i++){
        sum -= S.at(i);
        count++;
    }
    if(sum >= S.at(0)){
        count = count + (sum/S.at(0));
    }
    cout << count << endl;
}

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

int main()
{
    int n,q;
    cin>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    cin>>q;
    REP(i,q)
    {
        int k;
        cin>>k;
        auto re = equal_range(a.begin(),a.end(),k);
        cout<<re.first-a.begin()<<" "<<re.second-a.begin()<<endl;
    }
}


Measured memory_bytes: 3076
#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;

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

    string ch;
    int n;
    while(cin>>n)
    {
        cin>>ch;
        int sz=ch.size();
        for(int i=0;i<sz;i++)
        {
            ch[i] += n;
            ch[i] -=65;
            ch[i] %= 26;
            ch[i] +=65;
            //cout<<(int)ch[i]<<endl;
        }
        cout<<ch<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  string S,T;
  cin >> N >> M >> S >>T;
  
  long long gcd,lcm,m;
  m = min(N,M);
  for (long long i=m;i>0;i--) {
    if (N%i==0 && M%i==0) {
      gcd = i;
      break;
    }
  }
  
  lcm = N*M/gcd;
  
  bool exist = true;
  long long x=N/gcd, y=M/gcd;
  for (long long i=0;i<gcd;i++) {
    if (S.at(i*x) != T.at(i*y)) {
      exist = false;
      break;
    }
  }
  
  if (exist) {
    cout << lcm << endl;
  }
  else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
typedef long long ll;
int main(){
    int N;
    cin >> N;
    int ans;
    if(N%2==0){
        ans = N;
    }else{
        ans = N*2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

k, n = map(int, input().split())
A = list(map(int, input().split()))


longest_dist = (k - A[n-1]) + A[0]

for i in range(n-1):
    if longest_dist < A[i+1] - A[i]:
        longest_dist = A[i+1] - A[i]

print(k-longest_dist)


Measured memory_bytes: 26060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<int> Scount[30],Tcount[30];
bool check[26];

int main()
{
	string S,T;
	cin >> S >> T;
	for (int i = 0; i < S.size(); ++i)
	{
		Scount[S[i] - 'a'].push_back(i);
		Tcount[T[i] - 'a'].push_back(i);
	}

	int idx;
	bool ok = false;
	for (int i = 0; i < 26; ++i)
	{
		ok = false;
		//cout << "a" << endl;
		if (Scount[i].size() == 0) continue;

		for (int j = 0; j < 26; ++j)
		{
			if (Tcount[j].size() != 0 && Scount[i][0] == Tcount[j][0])
			{
				//cout << "b" << endl;
				ok = true;
				idx = j;
				break;
			}
		}

		if (!ok)
		{
			cout << "No" << endl;
			return 0;
		}

		//cout << i << " " << idx << endl;

		if (Scount[i].size() != Tcount[idx].size())
		{
			cout << "No" << endl;
			return 0;
		}
		else
		{
			rep(j,Scount[i].size())
			{
				if (Scount[i][j] != Tcount[idx][j])
				{

					//cout << Scount[i][j] << "c" << Tcount[idx][j] << endl;
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
string s[107];
int main(){

    int n=read(),l=read();
    for(int i = 1;i <= n;++i)cin>>s[i];
    sort(s+1,s+n+1);
    for(int i=1;i<=n;++i)cout<<s[i];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LLINF 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 200026
#define MAXK 26
#define MAXX 15000006
#define rep(kk, l1, l2)for(long long kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(long long kk = l1; kk <= l2; kk++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define ph push
#define all(x) x.begin(), x.end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n, a, ans, found[2], times[MAXN], co, prevmax;
priority_queue <spi> pq;
vector <ll> A[2];//,[MAXN]
ll solve()
{
	memset(times, 0, sizeof times);
	co = 0;
	rep(i, 0, A[0].size())times[A[0][i]]++;
	rep(i, 1, 100000+1)
	{
		if(times[i] > times[co])co = i;
	}
	prevmax = co;
	ll sum = (n/2) - times[co]; //use co
	memset(times, 0, sizeof times);
	co = 0;
	rep(i, 0, A[1].size())times[A[1][i]]++;
	rep(i, 1, 100000+1)
	{
		if(times[i] > times[co])co = i;
	}
	if(co == prevmax)
	{
		memset(times, 0, sizeof times);
		co = 0;
		rep(i, 0, A[1].size())times[A[1][i]]++;
		times[prevmax] = 0;
		rep(i, 1, 100000+1)
		{
			if(times[i] > times[co])co = i;
		}
	}
	sum += (n/2) - times[co];
	return sum;
}
int main()
{
	cin >> n;
	ans = n;
	rep(i, 0, n)
	{
		cin >> a;
		if(i%2)A[1].pb(a);
		else A[0].pb(a); 
	}
	ans = solve();
	swap(A[0], A[1]);
	ans = min(ans, solve());
	cout << ans << "\n";
}
/*
14
3 3 3 3 3 3 2 1 2 5 2 6 3 4
* */


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    string a, b;
    cin >> a >> b;
    int n = a.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i])ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
typedef vector<vector<int> > Matrix;

const int INF = 1000000000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
		  // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n) { // nは頂点数
	for (int i = 0; i < n; i++)      // 経由する頂点
		for (int j = 0; j < n; j++)    // 開始頂点
			for (int k = 0; k < n; k++)  // 終端
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}
vector<int> a;
vector<int> b(8, 0);
int r;
int res = (int)1 << 60;
void dfs(int x,int score) {
	b[x] = 1;
	bool f=false;
	for (int i = 0; i < r; i++) {
		if (b[i] == 0) {
			dfs(i, score + d[a[x]][a[i]]);
			f = true;
		}
	}
	if (!f) {
		res = min(res, score);
	}
	b[x] = 0;
}
signed main() {
	int n, m;
	cin >> n;

	d = Matrix(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) d[i][i] = 0;

	cin >> m;
	cin >> r;
	a.resize(r);
	for (int i = 0; i < r; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < m; i++) {
		int from, to, cost;
		
		
		cin >> from >> to >> cost;
		from--;
		to--;
		d[from][to] = cost;
		d[to][from] = cost;
	}

	warshall_floyd(n);

	
	for (int i = 0; i < r; i++) {
		dfs(i, 0);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cmath>
#include <vector> 

 
#define fastio()                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll                      long long int
#define ull                     unsigned long long int
#define inp(n)                  ll n; cin >> n
#define inpc(c)                 char c; cin >> c
#define inps(s)                 string s; cin >> s
#define print(x)                cout << x << " "
#define nl                      cout << '\n'
#define pyes                    cout << "YES"
#define pno                     cout << "NO"
#define fr(i,a,b)               for(ll i=a; i<b; ++i)
#define frrev(i,b,a)            for(ll i=b; i<=a; --i)
#define strrev(s)               reverse(s.begin(), s.end())
#define pb(x)                   push_back(x)
#define vin(A, n)               vector<ll> A; fr(i,0,n){ ll x; cin >> x; A.pb(x); }
#define vinc(A, n)              vector<char> A; fr(i,0,n){ char x; cin >> x; A.pb(x); }
#define vpairin(A, n, t1, t2)   vector<pair<t1,t2> > A; fr(i,0,n) {t1 x; t2 y; cin >> x >> y; A.pb(make_pair(x,y));}
#define srt(A)                  sort(A.begin(), A.end())
#define vout(A, n)              fr(i,0,n){ print(A[i]); }
#define vpairout(A, n)          fr(i,0,n){ print(A[i].first); print(A[i].second); nl; }
 
using namespace std;

void solve()
{
	inp(n);
	int min = 1000000;
	for (int i = 0; i< n; i++)
	{
		int temp;
		cin >> temp;
		if (temp%2 == 0)
		{
			int temp2 = 0;
			while(temp%2 == 0)
			{
				temp2++;
				temp = temp/2;
			}
			if (temp2 < min)
				min = temp2;
		}
		else
		{
			min = 0;
		}
		
	}
	if (min == 1000000)
	{
		cout << "0";
	}
	else
	{
		cout << min;
	}
	


}
 
int main()
{
 
   fastio();
   solve();
   return 0;
}
 

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

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

void solve()
{
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while (X <= Y)
    {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{   //入力
        string s = Console.ReadLine();
        string flg = "No";
		for (int i = 0; i < s.Length; i++)
        {
         if (s[i] == '7')
          {
           flg = "Yes";
          }
        }
      Console.WriteLine(flg);
	}
}

Measured memory_bytes: 25780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256