akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/**Classes and Structs**/
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/**End**/
                                       /**Definitions**/
                                       const long long int mod1=1000000007;
                                       const int MAX=100005;
                                       #define pb push_back
                                       #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
                                       typedef long long int ll;
                                       typedef unsigned long long int ull;
                                       typedef unordered_map<int,int,custom_hash> mii;
                                       typedef unordered_map<ll,int,custom_hash> mli;
                                       typedef unordered_map<int,ll,custom_hash> mil;
                                       typedef unordered_map<ll,ll,custom_hash> mll;
                                       /**End**/
/**Custom Functions**/
ll gcd(ll a,ll b){
    ll c;
     while(b){
        c=b;
        b=a%b;
        a=c;
     }
     return a;
}
ll power1(ll a,ll b){
     if(b==0) return 1;
     else if(b%2) return a*power1(a,b-1);
     else {
        ll temp=power1(a,b/2);
        return temp*temp;
     }
}
ll power2(ll a,ll b,ll m){
     if(b==0) return 1;
     else if(b%2) return (a*power2(a,b-1,m))%m;
     else{
        ll temp=power2(a,b/2,m);
        return (temp*temp)%m;
     }
}
/**End**/
ull power(ull x, ull y, ull p)
{
    ull res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ull modInverse(ull n, ull p)
{
    return power(n, p-2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
long long int fac[2010]={1};


ull nCrModPFermat(ull n, ull r, ull p)
{
   // Base case
   if (r==0)
      return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r


    return (    (fac[n]* modInverse(fac[r], p)) % p *
            (modInverse(fac[n-r], p) % p)) % p;
}
int main()
{
fast;
for (ll i=1 ; i<=2004; i++)
        fac[i] = fac[i-1]*i%mod1;
ll t=1;
//cin>>t;
while(t--){
   ll n,k;
   cin>>n>>k;
   for(int i=1;i<=k;i++){
        if(i<=n-k+1){
    cout<<(nCrModPFermat(n-k+1,i,mod1)*nCrModPFermat(k-1,i-1,mod1))%mod1<<endl;
   }
   else{cout<<0<<endl;}
}}
}


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

#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define debug(x)                                                               \
    { cerr << #x << " = " << x << endl; }
#define IO                                                                     \
    {                                                                          \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    }
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const int N = 500005;
int tree[4 * N];

void update(int node, int l, int r, int idx, int val) {
    if (idx < l or idx > r)
        return;
    if (l == r) {
        tree[node] = val;
        return;
    }
    int m = (l + r) / 2;
    update(2 * node, l, m, idx, val);
    update(2 * node + 1, m + 1, r, idx, val);
    tree[node] = tree[2 * node] + tree[2 * node + 1];
}

int queryd(int node, int l, int r, int s, int e) {
    if (e < l or s > r)
        return 0;
    if (s <= l and r <= e)
        return tree[node];

    int m = (l + r) / 2;
    return queryd(2 * node, l, m, s, e) + queryd(2 * node + 1, m + 1, r, s, e);
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    pair<int, int> query[q];
    map<pair<int, int>, int> q_ans;

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        query[i] = {r, l};
    }
    pair<int, int> q2[q];
    for (int i = 0; i < q; i++)
        q2[i] = query[i];
    sort(query, query + q);
    int last_occur[n + 1]; // index
    int last_pos[n + 1];
    for (int i = 0; i <= n; i++) {
        last_pos[i] = -1;
        last_occur[i] = 0;
    }
    int idx = 0;
    for (int i = 0; i < q; i++) {
        int l = query[i].second, r = query[i].first;
        while (idx < r) {
            update(1, 0, n, idx, 1);
            if (last_pos[arr[idx]] != -1)
                update(1, 0, n, last_pos[arr[idx]], 0);
            last_pos[arr[idx]] = idx;
            idx++;
        }
        int ans = 0;
        ans = queryd(1, 0, n, l - 1, r - 1);
        q_ans[query[i]] = ans;
    }

    for (int i = 0; i < q; i++) {
        cout << q_ans[q2[i]] << endl;
    }
}

Measured memory_bytes: 52832
import itertools
import math


def find_path_len(p, distances):
    dist = 0
    for i in range(1, n):
        dist += distances[p[i]][p[i-1]]
    return dist


n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

pathes = list(itertools.permutations(range(0,n)))

distances = [[0 for _ in range(n)] for _ in range(n)]

for i in range(n):
    for j in range(n):
        s = a[i]
        f = a[j]
        d = math.sqrt((s[0] - f[0]) ** 2 + (s[1] - f[1]) ** 2)
        distances[i][j] = d
        distances[j][i] = d

pathes_length = list(map(lambda x: find_path_len(x, distances), pathes))

print(sum(pathes_length) / len(pathes_length))


Measured memory_bytes: 9252
<?php
list($A,$B,$K)=sscanf(trim(fgets(STDIN)),"%d %d %d");
$A -= $K;
if($A < 0) {
    $B += $A;
    $A = 0;
}
if($B < 0) $B = 0;
printf("%d %d",$A,$B);


Measured memory_bytes: 5368
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

ll N;



class DisjointSet {
public:
	vector<int> p, rank, num;


	DisjointSet() {}

	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.resize(size, 0);
		rep(i, size) { p[i] = i; rank[i] = 0; num[i] = 1; }
	}

	bool same(int x, int y) {

		return findSet(x) == findSet(y);

	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {

			p[y] = x;
			num[x] += num[y];

		}

		else {
			p[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y]) {

				rank[y]++;
			}

		}


	}


	ll NumberOfElements(int x) {

		return num[findSet(x)];

	}


	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
			num[x] = 1;
		}

		return p[x];
	}



};
ll check[100005];
int main() {

	ll N, M;
	cin >> N >> M;

	DisjointSet ds = DisjointSet(N+1);

	rep(i, M) {
		ll X, Y, Z;
		cin >> X >> Y >> Z;

		if (!ds.same(X, Y)) {
			ds.unite(X, Y);
		}

	}

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		if (check[ds.findSet(i)] == 0) {

			ans += 1;
			check[ds.findSet(i)] = 1;
		}

	}


	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 2176
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

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


int main() {

    int a;
    string s;
    cin >> a >> s;

    if(a >= 3200)cout << s << endl;
    else cout << "red" <<endl;

}
























Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long long int a[3];
  long long int i,j;
  long long int temp;
  scanf("%lld %lld %lld",&a[0],&a[1],&a[2]);
  for(i=0;i<2;i++){
    for(j=2;j>i;j--){
      if(a[j-1]>a[j]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
      }
    }
  }
  if(a[0]%2==0 ||a[1]%2==0||a[2]%2==0)printf("0\n");
  else {
    printf("%lld\n",a[0]*a[1]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
  int mm;
  int hp=0;
  int f1=0;
  int f2=0;
  int i1,i2,i3;
  scanf("%d",&mm);
  i1=mm/500;
  i2=mm%500;
  hp=i1*1000;
  i3=i2/5;
  hp=hp+(i3*5);
  printf("%d",hp);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


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

 int N, cnt=0, cnt1=0;
 string moji;

 cin >> N;
 REP(i, N){
   cin >> moji;
   if(moji == "A") cnt++;
   else cnt--;
   if(cnt < 0){
     cnt1=-1;
   }
 }
 if(cnt==0 && cnt1==0) cout << "YES" << endl;
 else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N;
    cin >> N;
    map<int64_t, int>n;
    bool distinct = true;
    for (int64_t i=0; i<N; i++) {
        int64_t num;
        cin >> num;
        if (n.count(num) > 0) {
            distinct = false;
            break;
        }

        n[num] = 1;
    }

    if (distinct) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 12800
N,M = map(int,input().split())

one = 0
oneflag = 0

two = 0
twoflag = 0

three = 0
threeflag = 0

if N == 1:
    for i in range(M):
        s,c = map(int,input().split())
        
        if s == 1:
            if oneflag == 0:
                one = c
                oneflag = 1    
            else:
                if one != c:
                    print(-1)
                    exit()

    print(str(one))

if N == 2:
    for i in range(M):
        s,c = map(int,input().split())
        
        if s == 1:
            if oneflag == 0:
                one = c
                oneflag = 1    
            else:
                if one != c:
                    print(-1)
                    exit()
        
        elif s == 2:
            if twoflag == 0:
                two = c
                twoflag = 1    
            else:
                if two != c:
                    print(-1)
                    exit()
    
    #答えの出力
    if oneflag == 0:
        one = 1

    if one == 0:
        print(-1)
        exit()

    print(str(one)+str(two))



if N == 3:
    for i in range(M):
        s,c = map(int,input().split())
        
        if s == 1:
            if oneflag == 0:
                one = c
                oneflag = 1    
            else:
                if one != c:
                    print(-1)
                    exit()
        
        elif s == 2:
            if twoflag == 0:
                two = c
                twoflag = 1    
            else:
                if two != c:
                    print(-1)
                    exit()

        elif s == 3:
            if threeflag == 0:
                three = c
                threeflag = 1    
            else:
                if three != c:
                    print(-1)
                    exit()
    
    if oneflag == 0:
        one = 1

    #答えの出力
    if one == 0:
        print(-1)
        exit()

    print(str(one)+str(two)+str(three))



Measured memory_bytes: 3188
#include<stdio.h>

int main(){
    int A, B, K;
    int i, j, k;
    int tmp;

    scanf("%d %d %d", &A, &B, &K);
    tmp=A;

    while(A<(K+tmp) && A<=B){
        printf("%d\n", A);
        A++;
    }

    if(B-K < A){
        tmp = A;
    }else{
        tmp = B-K+1;
    }

    while(tmp <= B){
        printf("%d\n", tmp);
        tmp++;
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;

int main(){
    string s; cin >> s;
    int l=s.length();
    string ans="";
    ll cnt = 0;
    rep(i,l){
        if(s[i]=='?'){
            // if(s[i+1]=='D'||(ans[i-1]=='D'&&s[i+1]=='?'))ans+='P';
            // else if(i && (ans[i-1]=='D'&&s[i+1]=='?'))ans+='P';
            // else if(!i && s[i+1]=='?')ans+='P';
            // else ans +='D';
            if(s[i+1]=='?'){
                if(!i)ans+='P';
                else if(ans[i-1]=='P')ans+='D';
                else ans+='P';
                
            }else{
                if(!i){
                    if(s[i+1]=='D')ans+='P';
                    else ans+='D';
                }else{
                    if(ans[i-1]=='D'&&s[i+1]=='D')ans+='P';
                    else ans+='D';
                }
            }    
            
        }else{
            ans+=s[i];
        }

        // if(s[i]=='D'){
        //     cnt++;
        //     if(!i && s[i-1]=='P')cnt++;
        // }
       
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;cin>>x;
  print((x>=30)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 3660
// 間隔が大きい順に範囲を分けて使っていく方針だが実装がわからん
// 範囲を取るのは2割正解 以下間隔の概念はできてるものとして、
// |---|....|--|..|---|...|-| としてこの.....の部分は間隔が空いてるところで、踏破しない部分になる
// 全体の範囲からこの間隔の和を引けばいい
// 全体の範囲はソートして先頭と末尾の差から分かる
// こんな発想できんわ

package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	X := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&X[i])
	}
	if N >= M {
		fmt.Println(0)
		return
	}
	sort.Ints(X)
	difs := make([]int, M-1)
	for i := 0; i < M-1; i++ {
		difs[i] = X[i+1] - X[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(difs)))
	difs = difs[:N-1]
	ans := abs(X[M-1] - X[0])
	for _, d := range difs {
		ans -= d
	}
	fmt.Println(ans)
}

func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}


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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i=0; i<h; i++)
    cin >> s.at(i);
  
  vector<string> t(h+2); // 枠を追加 (h+2) * (w+2)
  for (int i=0; i<h+2; i++) {
    for (int j=0; j<w+2; j++) {
      if (i==0 || i==h+1) t.at(i).push_back('.');
      else if (j==0 || j==w+1) t.at(i).push_back('.');
      else t.at(i).push_back(s.at(i-1).at(j-1));
    }
  }

  
  
  for (int i=1; i<h+1; i++) {
    for (int j=1; j<w+1; j++) {
      int cnt = 0;
      if (t.at(i).at(j) == '.') {
        if (t.at(i-1).at(j-1) == '#') cnt++;
        if (t.at(i-1).at(j) == '#') cnt++;
        if (t.at(i-1).at(j+1) == '#') cnt++;
        if (t.at(i).at(j-1) == '#') cnt++;
        if (t.at(i).at(j+1) == '#') cnt++;
        if (t.at(i+1).at(j-1) == '#') cnt++;
        if (t.at(i+1).at(j) == '#') cnt++;
        if (t.at(i+1).at(j+1) == '#') cnt++;
        cout << cnt;
      }
      else
        cout << "#";
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;




int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mi = 1e9;
    int ma = -1e9;
    rep (i, n) {
        cin >> a[i];
    }
    sort(all(a));
    int M = a[a.size()-1];
    int m = a[0];
    vector<int> x, y;
    rep (i, 1, n-1) {
        if (a[i] < 0) {
            x.push_back(M);
            y.push_back(a[i]);
            M -= a[i];
        } else {
            x.push_back(m);
            y.push_back(a[i]);
            m -= a[i];
        }
    }
    x.push_back(M);
    y.push_back(m);
    M -= m;
    cout << M << endl;
    rep (i, n-1) {
        cout << x[i] << " " << y[i] << endl;
    }

}




Measured memory_bytes: 4648
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

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

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    sort(ALL(A), greater<ll>());

    ll alice = 0;
    ll bob = 0;

    FOR(i, 0, N){
        if(i%2==0){
            alice += A[i];
        }else{
            bob += A[i];
        }
    }

    p(alice - bob);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int ac = 0;
    long wa = 0l;
    long[] problems = new long[n+2];
    boolean[] end = new boolean[n+2];
    for(int i = 0;i<m;i++){
      int p = sc.nextInt();
      String s = sc.next();
      if(end[p]){
        continue;
      }else if(s.equals("AC")){
        end[p] = true;
        ac++;
      }else{
        problems[p]++;
      }
    }
    for(int i = 1;i<n+1;i++){
      if(end[i]){
        wa += problems[i];
      }
    }
    System.out.println(ac);
    System.out.println(wa);
  }
}


Measured memory_bytes: 59916
S=input()
T=input()
R=[-1]*26
R2=[-1]*26
flag=1

for i in range(len(S)):
    a=ord(S[i])-97
    b=ord(T[i])-97
    if R[a]!=-1 or R2[b]!=-1:
        if R[a]!=b or R2[b]!=a:
            flag=0
            break
    else:
        R[a]=b
        R2[b]=a
if flag==0:
    print('No')
else:
    print('Yes')

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

int main()
{
    int a,b;
    string str;
    cin>>a>>b;
    cin>>str;


    for(int i=0;i<str.size();i++)
    {
        if(i==a)
        {
            if(str[i]!='-')
                {
                    printf("No\n");
                    return 0;
                }


            continue;


        }

        if(str[i]=='-')
        {
                    printf("No\n");
                    return 0;

        }

    }


    printf("Yes\n");

}


Measured memory_bytes: 256
import java.util.*;


public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
 
        int[] A = new int[N+1];		//?????????index?????? 1~N+1?????????
        for(int i=0; i<N; i++)		
            A[1+i] = sc.nextInt();	
 
 		for(int i=1; i<N+1; i++){	
	        int parent = i/2;
	        int left = 2*i;
	        int right = 2*i +1;

	        String id,k,pk,lk,rk;
	        id = "node "+i+": ";
	        k  = "key = "+ A[i] + ", ";
	        pk = ( (i!=1)? "parent key = " + A[parent] + ", " : "" );
	      	lk = ( (left<=N)?  "left key = "+A[left] + ", " : "");
                rk = ( (right<=N)? "right key = "+A[right] + ", " : "");
            
                System.out.print(id + k + pk + lk + rk + "\n");
	}
 
    }
}

Measured memory_bytes: 27416
N,*f = map(int, open(0).read().split())
F = [f[i*10:i*10+10] for i in range(N)]
P = [f[N*10+i*11:N*10+i*11+11] for i in range(N)]
ans = -1 * pow(10,10)
opened = [0] * 10
for i in range(1,2**10):
    temp = 0
    for j in range(10):
        if i >> j & 1:
            opened[j] = 1
        else:
            opened[j] = 0
    for j in range(N):
        c = sum(opened[k]*F[j][k] for k in range(10))
        temp += P[j][c]
    ans = max(ans,temp)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

int main() {
    char input[3];
    scanf("%s", input);
    set<char> chars;
    for (int i = 0; i < 3; i++) {
        chars.insert(input[i]);
    }
    if (chars.size() == 3) {
        printf("Yes");
    } else {
        printf("No");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 768
# SPDX-License-Identifier: X11
# 2020-08-31
# One Quadrillion and One Dalmatians (300pt)

const BASE = 26

function main()
  N = parse(Int64, readline())

  exp = 1
  upper = BASE
  while upper < N
    exp += 1
    upper += BASE^exp
  end
  N -= upper - BASE^exp + 1

  name = Vector{Char}(undef, exp)

  for i ∈ exp:-1:1
    N, c = divrem(N, BASE)
    name[i] = 'a' + c
  end

  println(string(name...))
end

main()


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

int main(){
  int n,l;
  string s[110];
  cin>>n>>l;
  for(int i=0;i<n;i++) cin>>s[i];
  sort(s,s+n);
  for(int i=0;i<n;i++) cout<<s[i];
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 25005120

ll dp[MX];

void run_dp(int n, const vpii &offs)
{
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i-1]+1;
        for (const pii &of : offs) {
            ctif(i < of.fir);
            dp[i] = max(dp[i], dp[i-of.fir]+of.sec);
        }
    }
}

int main()
{
    canhazfast();

    int n, k;
    int p[2][4];
    vpii ab, ba;
    ll ans;

    cin >> n;
    for (int i : {0, 1}) {
        for (int j : {0, 1, 2}) cin >> p[i][j];
    }
    for (int j : {0, 1, 2}) {
        if (p[0][j] < p[1][j]) ab.empb(p[0][j], p[1][j]);
        if (p[0][j] > p[1][j]) ba.empb(p[1][j], p[0][j]);
    }
    run_dp(n, ab);
    //cerr << "dp_ab ="; for (int i = 0; i <= n; ++i) cerr << ' ' << dp[i]; cerr << '\n';
    k = dp[n];
    run_dp(k, ba);
    //cerr << "dp_ba ="; for (int i = 0; i <= k; ++i) cerr << ' ' << dp[i]; cerr << '\n';
    ans = dp[k];
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

ll oca[50],ocb[50];

int main(){
    ll a,b;cin>>a>>b;
    a--;
    rep(i,1,50){
        if(2*(a+1)<pow(2,i))break;
        oca[i]+=(a+1)/((ll)pow(2,i))*(ll)pow(2,i-1)+max((ll)0,(a+1)%(ll)pow(2,i)-(ll)pow(2,i-1));
    }
    rep(i,1,50){
        if(2*(b+1)<pow(2,i))break;
        ocb[i]+=(b+1)/((ll)pow(2,i))*(ll)pow(2,i-1)+max((ll)0,(b+1)%(ll)pow(2,i)-(ll)pow(2,i-1));
    }
    ll an=0;
    rep(i,1,50){
        an+=(ll)pow(2,i-1)*((ocb[i]-oca[i])%2);
    }
    cout<<an<<endl;

}







Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        long res = 0;
        foreach (var item in PrimeFactors(n).GroupBy(x => x))
        {
           var count = item.Count();
            for (int i = 1; i <= count; i++)
            {
                res++;
                count -= i;
            }
        }
        Console.WriteLine(res);
    }


    static IEnumerable<long> PrimeFactors(long n)
    {
        while ((n & 1) == 0)
        {
            n >>= 1;
            yield return 2;
        }
        for (long i = 3; i * i <= n; i += 2)
        {
            while (n % i == 0)
            {
                n /= i;
                yield return i;
            }
        }
        if (n != 1) yield return n;
    }
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    rep(i, M)
    {
        cin >> B[i];
    }
    int A[N][M];
    rep(i, N)
    {
        rep(j, M)
        {
            cin >> A[i][j];
        }
    }
    int ans = 0;
    rep(i, N)
    {
        int calc = 0;
        rep(j, M)
        {
            calc += A[i][j] * B[j];
        }
        if (calc + C > 0)
        {
            ans++;
        }
        calc = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    while (scanner.hasNext()) {
      double w = scanner.nextDouble();
      if (91.00 < w) {
        out += "heavy";
      } else if (81.00 < w && w <= 91.00) {
        out += "light heavy";
      } else if (75.00 < w && w <= 81.00) {
        out += "middle";
      } else if (69.00 < w && w <= 75.00) {
        out += "light middle";
      } else if (64.00 < w && w <= 69.00) {
        out += "welter";
      } else if (60.00 < w && w <= 64.00) {
        out += "light welter";
      } else if (57.00 < w && w <= 60.00) {
        out += "light";
      } else if (54.00 < w && w <= 57.00) {
        out += "feather";
      } else if (51.00 < w && w <= 54.00) {
        out += "bantam";
      } else if (48.00 < w && w <= 51.00) {
        out += "fly";
      } else if (w <= 48.00) {
        out += "light fly";
      }
      out += "\n";
    }
    System.out.print(out);
  }
}

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

int main() {
    int X;
    cin >> X;
    if( 400 <= X && X <= 599){
        cout << 8 << endl;
    }
    else if( 600 <= X && X <= 799){
        cout << 7 << endl;
    }
    else if( 800 <= X && X <= 999){
        cout << 6 << endl;
    }
        else if( 1000 <= X && X <= 1199){
        cout << 5 << endl;
    }
        else if( 1200 <= X && X <= 1399){
        cout << 4 << endl;
    }
        else if( 1400 <= X && X <= 1599){
        cout << 3 << endl;
    }
        else if( 1600 <= X && X <= 1799){
        cout << 2 << endl;
    }
        else if( 1800 <= X && X <= 1999){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int N, k;

int f(int n, int x){
    if(n == 0) return x;
    else if(x%k == 0) return f(n, x+1);
    return f(n-1, x - x/k - 1);
}

signed main(){
    cin >> N >> k;
    int lb = 0, ub = 2e18;
    while(lb + 1 < ub){
        int x = (lb + ub) / 2;
        (f(N-1, x) ? ub : lb) = x;
    }
    cout << lb << endl;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	map<string, int>f;
	f["AC"] = f["RE"] = f["TLE"] = f["WA"] = 0;
	for(int i = 0; i < n;i++){
		string s;
		cin >> s;
		f[s]++;
	}
	string a[] = {"AC" , "WA", "TLE" , "RE"};
	for(int i = 0; i < 4;i++){
		cout <<a[i] << " x " << f[a[i]] <<"\n";
	}
}

Measured memory_bytes: 3668
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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

// flip pair
template <typename A, typename B>
pair<B, A> flip_pair(pair<A, B> src) {
	return pair<B, A> (src.second, src.first);
}

// flip map
template <typename A, typename B>
multimap<B, A> flip_map(map<A, B> src) {
	multimap<B, A> dst;
	for(auto it = src.begin(); it != src.end(); ++it) {
		auto a = flip_pair(*it);
		dst.insert(a);
	}
	return dst;
}

// get frequency mapping from vector
template <typename Tval>
multimap<int, Tval> freq(vector<Tval> src) {
	map<Tval, int> counter;
	for(auto it = src.begin(); it != src.end(); ++it) {
		auto it2 = counter.find(*it);
		if(it2 != counter.end()) counter[*it]++;
		else counter[*it] = 1;
	}
	auto dst = flip_map(counter);
	return dst;
}

int main(){
	int X;
	cin >> X;
	if (X==3 || X==5 || X==7) cout << "YES" << endl;
	else cout << "NO" << endl;
	
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a=I()
    b=I()
    
    if a==b:
        print("EQUAL")
    elif a>b:
        print("GREATER")
    else:
        print("LESS")

main()


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

int main(){
  int h, w;
  cin >> h >> w;
  int ahw[h][w], bhw[h][w];
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      cin >> ahw[i][j];
    }
  }
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      cin >> bhw[i][j];
    }
  }
  
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>((h+w)*80+1, false)));
  dp[0][0][abs(ahw[0][0]- bhw[0][0])] = true;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      for(int k=0; k<(h+w)*80; ++k){
        int da, db;
        da=abs(k-abs(ahw[i][j]- bhw[i][j]));
        db=k+abs(ahw[i][j]- bhw[i][j]);
        if(i && dp[i-1][j][da]) dp[i][j][k] = true;
        if(j && dp[i][j-1][da]) dp[i][j][k] = true;
        if(db > (h+w)*80) continue;
        if(i && dp[i-1][j][db]) dp[i][j][k] = true;
        if(j && dp[i][j-1][db]) dp[i][j][k] = true;
      }
    }
  }
  for(int i=0; i<(h+w)*80+1; ++i){
    if(dp[h-1][w-1][i]){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 10752
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    int a,  b;
    cin >> a  >> b;
    if( a < b)swap(a , b);
    for(int i = 1; i <= a;i++){
        cout << b;
    }
    
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto nmx = readNums!int;
  auto ca = new int[][](nmx[0], nmx[1]+1);

  foreach(i; 0 .. nmx[0]){
    ca[i] = readNums!int;
  }

  int ret = -1;

  foreach(i; 0.. 2^^nmx[0]){
    int[] t = new int[](nmx[1]+1);
    foreach(j; 0 .. nmx[0]){
      if(i & (1<<j)){
        t[] += ca[j][];
      }

      bool ok = true;
      foreach(e; t[1 .. $]){
        if(e < nmx[2]){
          ok = false;
          break;
        }
      }

      if(ok && (ret == -1 || t[0] < ret)){
        ret = t[0];
      }
    }
  }

  writeln(ret);
}


Measured memory_bytes: 3208
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	vll fac(100001,1) ;
	for(int i=2;i<=100000;i++) fac.at(i) = fac.at(i-1)*i%mod ;
	ll n,m ;
	cin >> n >> m ;
	if(n==m){
		cout << 2*fac.at(n)%mod*fac.at(m)%mod << endl ;
	}else if(sa(n,m)==1){
		cout << fac.at(n)*fac.at(m)%mod << endl ;
	}else{
		cout << 0 << endl ;
	}
}


Measured memory_bytes: 1024
import qualified Data.Vector.Unboxed as VU

runrun::[Int]
runrun = [1..9] ++ [x*10+i | x <- runrun,let digit = mod x 10, i <- [digit-1,digit,digit+1],0 <= i && i <= 9]

main = do
  k <- readLn
  print $ runrun !! (k-1)

Measured memory_bytes: 4988
import Control.Monad
import Control.Applicative
import Data.List

main = do
	n <- readLn
	l <- map (map (read :: String -> Int) . words) <$> replicateM ((n * (n - 1)) `div` 2) getLine
	mapM_ print $ solve n l

point :: [(Int, Int)] -> [Int] -> [(Int, Int)]
point x [a, b, c, d]
	| c < d = (b, 3):x
	| c == d = (a, 1):(b, 1):x
	| c > d = (a, 3):x

func :: Int -> Int -> [(Int, Int)] -> [(Int, Int)]
func a b [] = [(b, a)]
func a b ((x, y):z)
	| a == -1 = func x y z
	| x == a = func a (b + y) z
	| otherwise = (b, a):(func x y z)

func2 :: Int -> Int -> Int -> [(Int, Int)] -> [(Int, Int)]
func2 a b c [] = []
func2 a b c ((x, y):z)
	| a == -1 = (y, 1):(func2 x 1 2 z)
	| a == x = (y, b):(func2 x b (c + 1) z)
	| otherwise = (y, c):(func2 x c (c + 1) z)

func3 :: [(Int, Int)] -> [Int]
func3 l = map (\(x, y) -> y) $ sort l

solve :: Int -> [[Int]] -> [Int]
solve n l = func3 $ func2 (-1) (-1) (-1) $ reverse $ sort $ func (-1) (-1) $ sort $ foldl point [(x, 0) | x <- [1..n]] l

Measured memory_bytes: 8300
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int[11] NS = [59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6];

void  main()
{
    auto N = readln.chomp.to!int;

    int[int][11] memo;
    int solve(int i, int n) {
        if (n == 0) return 0;
        if (i == 11) return n;
        if (n in memo[i]) return memo[i][n];

        if (n < NS[i]) {
            return memo[i][n] = solve(i+1, n);
        } else {
            return memo[i][n] = min(solve(i+1, n), solve(i, n - NS[i]) + 1);
        }
    }

    writeln(solve(0, N));
}

Measured memory_bytes: 6268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();

      int[] seqA = new int[n/2];
      int[] seqB = new int[n/2];

      Integer num = 0;
      List<Integer> listA = new ArrayList<>();
      List<Integer> listB = new ArrayList<>();
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      int offset=0,next=0;
      char regx = ' ';
      for(int i=0, j=0; i<n; i++, j= i >> 1) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = Integer.parseInt(line.substring(offset, next));
        offset = ++next;

        if((i & 1) == 0) {
          seqA[j] = num;
          if(mapA.containsKey(num)) {
            mapA.replace(num, mapA.get(num) + 1);
          } else {
            mapA.put(num, 1);
            listA.add(num);
          }
        }
        else {
          seqB[j] = num;
          if(mapB.containsKey(num)) {
            mapB.replace(num, mapB.get(num) + 1);
          } else {
            mapB.put(num, 1);
            listB.add(num);
          }
        }
      }

      int vma,vmb,xa,xb;
      vma = vmb = xa = xb =0;
      for (Integer var : listA) {
        int ma = mapA.get(var);
        if(vma < ma) {
          vma = ma;
          xa = var;
        }
      }
      for (Integer var : listB) {
        int mb = mapB.get(var);
        if(vmb < mb) {
          vmb = mb;
          xb = var;
        }
      }

      int cca,ccb;
      cca = ccb = 0;
      for (int i : seqA) {
        if(i != xa) cca++;
      }
      for (int i : seqB) {
        if(i != xb) ccb++;
      }

      int vma2,vmb2,xa2,xb2;
      vma2 = vmb2= xa2 = xb2 =0;
      int cca2,ccb2;
      cca2 = ccb2 = 0;
      int ans = 0;
      if(xa == xb) {
        for (Integer var : listA) {
          int ma = mapA.get(var);
          if(var != xa && vma2 < ma) {
            vma2 = ma;
            xa2 = var;
          }
        }
        for (Integer var : listB) {
          int mb = mapB.get(var);
          if(var != xb && vmb2 < mb) {
            vmb2 = mb;
            xb2 = var;
          }
        }
      
        for (int i : seqA) {
          if(i != xa2) cca2++;
        }
        for (int i : seqB) {
          if(i != xb2) ccb2++;
        }

        ans = cca2 > ccb2 ? cca + ccb2 : cca2 + ccb;
      }
      else {
        ans = cca + ccb;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int mod = 0;
struct mint {
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void Main()
{
    long n;
    int x;
    cin >> n >> x >> mod;
    vector<mint> a(mod);
    vector<long> aa(mod+1);
    vector<int> s(mod, -1);
    mint c = x;
    long i;
    for (i = 0; i < n; i++)
    {
        a[i] = c;
        aa[i+1] = c.x + aa[i];
        s[c.x] = i;
        c *= c;
        if (s[c.x] != -1) break;
    }
    int ss = s[c.x];
    if (i == n) { cout << aa[n] << endl; return; }
    cout << aa[i+1] 
            + (aa[i+1]-aa[ss])*((n-i-1)/(i-ss+1)) 
            + aa[(n-i-1)%(i-ss+1)+ss]-aa[ss]
        << endl;
        
    // x + x^2%m + x^4%m + x^8%m ... x^(2^i)%m
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 5308
S = input()
ACTG = ["A","C","T","G"]
TF = [False]*len(S)
for i,s in enumerate(S):
    if s in ACTG:
        TF[i] = True
cnt = 0
ans = 0
for tf in TF:
    if tf:
        cnt+=1
    else:
        cnt = 0
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws NumberFormatException, IOException {
    int[] array = {64, 32, 16, 8, 4, 2, 1};
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int num = Integer.parseInt(br.readLine());
    
    for (int i = 0; i < array.length; i++) {
      if (num >= array[i]) {
        System.out.println(array[i]);
        break;
      }
    }
  }

}


Measured memory_bytes: 21204
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	int ans=0;
	for(int i=1;i<=n;i+=2) {
		int cnt = 0;
		for(int j=1;j<=i;j++) {
			if (i%j == 0) cnt++;
		}
		if (cnt == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b;
  cin>>n>>m;
  map<int,int> mp;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    if(a==1){
      mp[b]++;
    }else if(b==n){
      mp[a]++;
    }
  }
  for(pair<int,int> p:mp){
    if(p.second==2){
      cout<<"POSSIBLE";
      return 0;
    }
  }
  cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 9728
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>

using namespace std;

#define spc " "
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;
typedef tuple<int, int, int, int> tup;

ll divc(ll a, ll b){ //割り算(切り上げ)
    return (a + b - 1) / b;
}

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    ll sum = min(a + b + 1, c) + b;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256