akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
ary = gets.split.map(&:to_i).sort

nums = Hash.new(0)
ans = Array.new(ary.last+1, 0)
ary.each do |i|
  nums[i] += 1
  ans[i] = 1
end
res = 0
ary.each do |j|
  next if ans[j] == 0
  res += 1 if nums[j] == 1
  j.step(ary.last, j) do |k|
    ans[k] = 0
  end
end
p res

Measured memory_bytes: 46384
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

bool test(vector<ll>H, ll A, ll B,ll T,ll N)
{
  ll sum = 0;
  for(int i=0; i < N; i++)
    H[i] -= T*B;
  for(int i=0; i < N; i++){
    if(H[i] > 0){
      ll res = H[i]/(A-B);
      if(H[i]%(A-B) != 0)
	res++;
      sum += res;
    }
  }
  if(sum <= T)
    return true;
  else
    return false;
}

int main()
{
  ll N,A,B;
  cin >> N >> A >> B;
  vector<ll>H(N);
  ll sum = 0;
  for(int i=0; i < N; i++){
    cin >> H[i];
  }
  ll max = *max_element(H.begin(),H.end());
  ll min = 0;
  ll mid;
  for(;;){
    mid = min + (max-min)/2;
    if(test(H,A,B,mid,N)){
      max = mid-1;
    }else{
      min = mid+1;
    }
    if(max < min)
      break;
  }
  int t;
  for(t=max-1; t <= min+1; t++)
    if(test(H,A,B,t,N))
      break;
  cout << t  << endl;

  /*
  ll amari = 0;
  ll add = 0;
  for(int i=0; i < N; i++){
    sum += H[i] / B;
    amari = H[i] % A;
    if(amari % B == 0)
      add = amari / B;
    else
      add = amari / B + 1;
    if(i < N-1){
      H[i+1] -= sum*B;
      H[i+1] -= add*A;
    }
    sum += add;
    if(i < N-1 && H[i+1] <= 0)
      break;
  }
  cout << sum << endl;
*/
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll x[N], y[N], h[N];
  rep(i, N) cin >> x[i] >> y[i] >> h[i];

  ll idx = 0;
  while(h[idx] == 0) idx++;
  rep(cx, 101) rep(cy, 101){
    bool flg = true;
    ll H = h[idx] + abs(x[idx] - cx) + abs(y[idx] - cy);
    rep(i, N){
      if(max(H - abs(x[i]-cx) - abs(y[i]-cy), 0LL) != h[i]){
        flg = false;
        break;
      }
    }
    if(flg){
      printf("%lld %lld %lld\n", cx, cy, H);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define dd double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

int a[101];
int dp[100005];
int n;

bool stone(int k){
	bool ans = false;
	if(dp[k]!=-1)return dp[k];

	for(int i=0;i<n;i++){
		if(k>=a[i]){
			bool flag = stone(k-a[i]);
			if(flag==false) ans=true;
		}
	}
	return dp[k]=ans;
}

signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	int k;
	cin >> n >> k;
	for0(i,n)cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout << (stone(k)?"First":"Second");

	return 0;
}

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

int main() {
  int s,k=0;
  cin >> s ;
  
  for(int i=0;i<3;i++){
    if((s-s/10)%10==0){
      k++;
      cout << "Bad" << endl;
      break;
    }
    s=s/10;
  }
  if(k==0)
    cout << "Good" << endl;
  
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
AC=0
WA=0
TLE=0
RE=0
list1 = []
for _ in range(n):
    s = input()
    list1.append(s)

counter = Counter(list1)
for item,value in counter.items():
    if(item=='AC'):    AC+=value
    elif(item=='WA'):  WA+=value
    elif(item=="TLE"): TLE+=value
    else:
        RE+=value

print("AC x",AC )
print("WA x",WA )
print("TLE x",TLE )
print("RE x",RE )

Measured memory_bytes: 16556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int time;
  time = (h2*60+m2)-(h1*60+m1);
  cout << time - k;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
 int a,b;
 scanf("%d%d",&a,&b);
 if(a<b){
  printf("a < b\n");
 }else if(a>b){
  printf("a > b\n");
 }else{
  printf("a == b\n");
 }
 return 0;
}


Measured memory_bytes: 2128
#include <iostream>

using namespace std;

const int MAXN = 111;
int T[MAXN];

int main() {
    int N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
        int p, x;
        cin >> p >> x;
        cout << (sum - T[p - 1] + x) << endl;
    }
    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MAX = 10000007;

int solve(string s, int MOD){
	if(MOD<=0) return 0;
	int p = 1;
	reverse(all(s));
	int x = 0;
	FOR(i, s.size()){
		x = (x + p) % MOD;
		p = 2LL * p % MOD;
	}

	return x;
}

int computa(int n){
	int ans = 0;
	while(n){
		ans++;
		n%=__builtin_popcount(n);
	}
	return ans;
}

int p21[200007], p20[200007];

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


	int n; cin >> n;
	string s; cin >> s;

	int cnt = 0;
	FOR(i, n) cnt += (s[i]=='1');

	p21[0] = p20[0] = 1;
	for(int i = 1; i < 200007; i++){
		p21[i] = 2LL * p21[i-1] % (cnt+1);
		if(cnt > 1)
			p20[i] = 2LL * p20[i-1] % (cnt-1);
	}

	int x1 = 0, x0 = 0;
	FOR(i, n){
		if(s[n-i-1] == '1'){
			x1 = (x1 + p21[i]) % (cnt+1);
			if(cnt > 1)
			x0 = (x0 + p20[i]) % (cnt-1);
		}
	}

	FOR(i, n){
		if(s[i] == '1'){
			if(cnt == 1) cout << "0\n";
			else{
				int aux = (x0 - p20[n-i-1] + cnt-1)%(cnt-1);
				cout << computa(aux)+1 << '\n';
			}
		}else{
			int aux = (x1 + p21[n-i-1])%(cnt+1);
			cout << computa(aux)+1 << '\n';
		}
	}
	

	return 0;
}


Measured memory_bytes: 5336
#include <vector>
#include <cstdint>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
struct CumulativeSum2D{
  vector2d<T> cum;

  CumulativeSum2D(const vector2d<T>& data):cum(data.size(), vector<T>(data[0].size(),0)){
    cum[0][0]=data[0][0];
    for(int r=1;r<data.size();r++){
      cum[r][0]=cum[r-1][0]+data[r][0];
    }
    for(int c = 1; c < data[0].size(); ++c){
      cum[0][c]=cum[0][c-1]+data[0][c];
    }
    for(int r = 1; r < data.size(); ++r){
      for(int c = 1; c < data[0].size(); ++c){
        cum[r][c]=cum[r-1][c]+cum[r][c-1]-cum[r-1][c-1]+data[r][c];
      }
    }
  }


  /// \return 2頂点が(sr,sc)と(gr,gc)であるような矩形内の和(2頂点を含む)
  T Query(int sr, int sc, int gr, int gc){
    T result=cum[gr][gc];
    if(sr-1>=0){
      result-=cum[sr-1][gc];
    }
    if(sc-1>=0){
      result-=cum[gr][sc-1];
    }
    if(sr-1>=0&&sc-1>=0){
      result+=cum[sr-1][sc-1];
    }
    return result;
  }
};

template<class T>
struct CumulativeSum1D{
  vector<T> cum;

  CumulativeSum1D(const vector<T>& data):cum(data.size(),0){
    cum[0]=data[0];
    for(int i = 1; i < data.size(); ++i){
      cum[i]=cum[i-1]+data[i];
    }
  }


  /// \return 区間[l,r]の和
  T Query(int l, int r){
    return (l>0)?cum[r]-cum[l-1]:cum[r];
  }
};



//verify

#include <iostream>

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

// int main(){
//   int n;
//   cin>>n;
//   vector2d<lint> a(n, vector<lint>(n, 0));
//   for(int i = 0; i < n; ++i){
//     for(int j = 0; j < n; ++j){
//       cin>>a[i][j];
//     }
//   }
//
//   CumulativeSum2D<lint> cum(a);
//   lint result=INT64_MIN/2;
//
//   for(int sr = 0; sr < n; ++sr){
//     for(int sc = 0; sc < n; ++sc){
//       for(int gr = sr; gr < n; ++gr){
//         for(int gc = sc; gc < n; ++gc){
//           UpdateMax(result,cum.Query(sr,sc,gr,gc));
//         }
//       }
//     }
//   }
//
//   cout<<result<<endl;
//
// }

int main(){
  while(true){
    int n,k;
    cin>>n>>k;
    if(n==0) break;

    vector<lint> a(n);
    for(int i = 0; i < n; ++i){
      cin>>a[i];
    }
    CumulativeSum1D<lint> cum(a);
    lint result=INT64_MIN;
    for(lint l=0;l<n;l++){
      lint r=l+k-1;
      if(r>=n) break;
      UpdateMax(result,cum.Query(l,r));
    }
    cout<<result<<endl;
  }


}


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

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

mod = 1000000007
count = 0
for i in range(len(A)-1):
  for j in range(i, len(A)):
    if A[i] > A[j]:
      count += 1

A.sort(reverse=True)
count_ = 0
for i in range(len(A)-1):
  for j in range(i, len(A)):
    if A[i] > A[j]:
      count_ += 1

sum1 = count * K

K = K-1
sum = K*(K+1)//2

sum2 = count_ * sum
print((sum1 + sum2)%mod)


Measured memory_bytes: 3188
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, q;
    string s;
    cin >> n >> q;
    cin >> s;
    VE l(q), r(q);
    REP(i, q) cin >> l[i] >> r[i];
    ll sum[100003];
    REP(i, 100002)sum[i] = 0;
    rep(i, 1, s.size()) {
        ll now = sum[i];
        if(s[i - 1] == 'A' && s[i] == 'C')now++;
        sum[i + 1] = now;
    }
    REP(i, q) {
        print(sum[r[i]] - sum[l[i]]);
    }
}

Measured memory_bytes: 3456
import sys
import numpy as np
MOD = 10**9+7

n = int(sys.stdin.buffer.readline())
a = np.fromstring(sys.stdin.buffer.readline(), dtype = np.int64, sep = ' ')
ans = 0
for i in range(60):
    s = int((a&1).sum())
    ans += s*(n-s) * 2**i
    ans %= MOD
    a >>= 1
print(ans)


Measured memory_bytes: 38200
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#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 rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int ans = 8;
    int val = 600;
    while(x >= val){
        val += 200;
        ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ANovember30 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int m1, d1, m2, d2;
	    in >> m1 >> d1 >> m2 >> d2;
	    out << (d1 > d2 ? 1 : 0) << "\n";
	}
};


signed main() {
	ANovember30 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
ll n,x,y;
int main(){
    in(n);in(x);in(y);
    if((y-x)%2==0){
        printf("%lld\n",(y-x)/2);
        return 0;
    }
    ll ans=min(y-1,n-x);
    ll ny=y-x;
    ll nx=1;
    ans=min(ans,(ny-nx)/2+x);
    nx=x+n-y+1;
    ny=n;
    ans=min(ans,(ny-nx)/2+n-y+1);
    cout<<ans<<endl;
    return 0;
}
//电风扇电风扇


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    int min_N = 1000000000, max_N = 0;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        min_N = min(min_N, A);
        max_N = max(max_N, A);
    }
    
    int ans = max_N - min_N;
    cout << ans << endl;
    
}


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

static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    
    for(int i=0; i<n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(int v = 0; v<n; v++){
            if(M[u][v]==0) continue;
            if(d[v]!=INFTY) continue;
            d[v] = d[u]+1;
            q.push(v);
        }
    }
    
    for(int i=0; i<n; i++){
        cout << i+1 << " " << ( (d[i]==INFTY) ? (-1) : d[i] ) << endl;
    }
}

int main(){
    int u,k,v;
    
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = 0;
        }
    }
    
    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);
    
    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define inf 1000000000
#define ll long long
using namespace std;
int main()
{
    int len,locate,locate1,flag=1;
    ll k,ans=0,ans1=0,ans2=0,ans3=0;
    char a[205];
    scanf("%s%lld",a,&k);
    len=strlen(a);
    if(k==1)
    {
        for(int i=0; i<len; i++)
        {
            int tmp1=i;
            char tmp=a[i];
            while(a[i]==tmp&&i<len)
            {
                i++;
            }
            i--;
            ans+=(i-tmp1+1)/2;
        }
        printf("%lld",ans);
        return 0;
    }
    for(int i=len; i<=2*len-1; i++)
        a[i]=a[i-len];
    for(int i=0; i<2*len; i++)
    {
        int tmp1=i;
        char tmp=a[i];
        while(a[i]==tmp&&i<2*len)
        {
            i++;
        }
        i--;
        if(tmp1<=len-1&&i>=len)
        {
            locate=tmp1-1,locate1=i-len+1;
            ans1=(i-tmp1+1)/2;
            flag=0;
            break;
        }
    }
    if(!flag)
    {
        if(locate==-1&&locate1==len)
            printf("%lld",k*len/2);
        else
        {
            for(int i=0; i<=locate; i++)
            {
                int tmp1=i;
                char tmp=a[i];
                while(a[i]==tmp&&i<=locate)
                {
                    i++;
                }
                i--;
                ans+=(i-tmp1+1)/2;
            }
            for(int i=locate1; i<len; i++)
            {
                int tmp1=i;
                char tmp=a[i];
                while(a[i]==tmp&&i<len)
                {
                    i++;
                }
                i--;
                ans2+=(i-tmp1+1)/2;
            }
            for(int i=locate1; i<=locate; i++)
            {
                int tmp1=i;
                char tmp=a[i];
                while(a[i]==tmp&&i<=locate)
                {
                    i++;
                }
                i--;
                ans3+=(i-tmp1+1)/2;
            }
            printf("%lld",ans3*(k-2)+ans1*(k-1)+ans+ans2);
        }
    }
    else
    {
        for(int i=0; i<len; i++)
        {
            int tmp1=i;
            char tmp=a[i];
            while(a[i]==tmp&&i<len)
            {
                i++;
            }
            i--;
            ans+=(i-tmp1+1)/2;
        }
        printf("%lld",ans*k);
    }
    return 0;
}

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

//
ll n;
vector<ll>ar;
vector<vector<ll>>dp;
//

ll F(ll a, ll b)
{
	if (a == b + 1)
		return 0;
	if (a == b)
		return ar[a];
	if (dp[a][b] != -1)
		return dp[a][b];
	ll a1 = ar[a] - F(a + 1, b);
	ll a2 = ar[b] - F(a, b - 1);
	return (dp[a][b] = max(a1, a2));
}

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

	cin >> n; ar = vector<ll>(n);
	dp = vector<vector<ll>>(n, vector<ll>(n, -1));
	for (auto &it : ar)
		cin >> it;
	cout << F(0, n - 1);

	return 0;
}

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

int main(int argc, char const *argv[]) {
  unsigned long n;
  std::cin >> n;

  std::vector<unsigned long> data; // ABCDE
  for (size_t i = 0; i < 5; i++) {
    unsigned long tmp;
    std::cin >> tmp;
    data.push_back(tmp);
  }

  auto min_it = min_element(data.begin(), data.end());
  unsigned long min_index = distance(data.begin(), min_it);

  // std::cout << min_index << '\n';
  // std::cout << data.at(min_index) << '\n';

  if (n%data.at(min_index) != 0) {
  	std::cout << (min_index) + ((n/data.at(min_index))+1) + (5 - (min_index+1))<< '\n';
  } else {
    std::cout << (min_index) + (n/data.at(min_index)) + (5 - (min_index+1))<< '\n';
  }
}


Measured memory_bytes: 256
s = input()
t = input()

dic = {}
dic2 = {}

for i in range(len(s)):
    sc = s[i]
    tc = t[i]
    if sc not in dic:
        dic[sc] = tc
    elif dic[sc] != tc:
        print('No')
        exit()
for i in range(len(s)):
    sc = t[i]
    tc = s[i]
    if sc not in dic2:
        dic2[sc] = tc
    elif dic2[sc] != tc:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int M = 6010;
int dp[M];
struct node
{
    int a, b;
}p[M];
bool cmp(node x, node y)
{
    return x.a < y.a;
}
int main()
{
    int n, t;
    scanf("%d%d", &n, &t);
    int w = 6000;
    for(int i = 1; i <= n; i++) scanf("%d%d", &p[i].a, &p[i].b);
    sort(p + 1, p + n + 1, cmp);
    for(int i = 1; i <= w; i++) dp[i] = -1;
    for(int i = 1; i <= n; i++)
    {
        //printf("i = %d\n", i);
        for(int j = w; j >= p[i].a; j--)
        {
            if(j - p[i].a < t && dp[j - p[i].a] != -1)
            {

                dp[j] = max(dp[j], dp[j - p[i].a] + p[i].b);//printf("j = %d %d\n", j, dp[j]);
            }
        }
    }
    int maxn = 0;
    for(int i = 1; i <= w; i++)
    {
        maxn = max(maxn, dp[i]);//printf("i = %d %d\n", i, dp[i]);
    }
    printf("%d\n", maxn);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<=n/7;i++)
	{
		for(int j=0;j<=n/4;j++)
		{
			if(j*4+i*7==n)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//http://drken1215.hatenablog.com/entry/2019/06/15/135300
//↑参考にさせて頂いた解説。




#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e13+7;

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;}

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

int main(){
    int N,M,k[20],s[20][20],p[20];
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            int a;
            cin>>a;
            a--;
            s[i][j]=a;
        }
    }
    ll res=0;
    for(int i=0;i<M;i++) cin>>p[i];
    for(int bit=0;bit<(1<<N);bit++){//bitで、押されたスイッチを全列挙
        bool check=true;//全部のライトがついている状態把握用？
        for(int i=0;i<M;i++){
            int  con=0;//カウントの初期化。
            for(int j=0;j<k[i];j++){
                if(bit&(1<<s[i][j]))con++;//スイッチが押された状態をカウント。
            }
            if(con%2!=p[i])check=false;//i番のライトがついているか。
        }
        if(check)++res;
    }
    cout<<res<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main( void ){
    char str[20];
    scanf( "%s",str );
    for( int i = strlen( str ) - 1;i >= 0;i-- ){
        printf( "%c",str[i] );
    }
    printf( "\n" );
    return 0;
}

Measured memory_bytes: 932
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int ans = A[0];
  for(int i=1; i<N; i++){
    ans = gcd(ans,A[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
S = input()
Srev = S[::-1]
T = ['dream', 'dreamer', 'erase', 'eraser']

lenT = [len(i) for i in T]
Trev = [t[::-1] for t in T]

i = 0
while i < len(S):
    for j, t in enumerate(Trev):
        if Srev[i:i+lenT[j]] == t:
            i += lenT[j]     #; print(i, j, t) 
            break
    else:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 3188
n = int(input())
s = list(input())
w = [0] * (n+1)
e = [0] * (n+1)
ans = n
for i in range(n):
    if s[i] == "W":
        w[i+1] = w[i] + 1
    else:
        w[i+1] = w[i]

for i in range(n-1, -1, -1):
    if s[i] == "E":
        e[i] = e[i+1] + 1
    else:
        e[i] = e[i+1]

for i in range(1, n+1):
    ans = min(ans, w[i-1]+e[i])
print(ans)


Measured memory_bytes: 19848
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>

using namespace std;


int main(){
 int N;
 cin >> N;
 int a[N];
 int i;
 int j;
 for(i=0;i<N;++i){
     cin >> a[i];
   }
  int tmp = 0;
  int best;
  int hukusuu=0;
 for(i=0;i<1;++i){
   for(j=1;j<N;++j){
     if(tmp < a[j]){
       tmp = a[j];
       best = j;
       hukusuu = 0;}
     else if(tmp == a[j]){
       hukusuu++;}}
   cout << tmp << endl;
 }
 if(a[0]>=tmp){
   for(i=1;i<N;++i){
     cout << a[0] << endl;
   }}
  else if(hukusuu>0){
    for(i=1;i<N;++i){
    cout << tmp << endl;
    }}
   else{
    for(i=1;i<N;++i){
    if(i!=best){cout << tmp << endl;}
      else{
        int newtmp = 0;
        for(j=0;j<N;++j){
          if(j!=best)newtmp=max(newtmp,a[j]);}
        cout << newtmp << endl;
      }
    }
   } 
 return 0;
}


Measured memory_bytes: 2432
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
#include<limits>
#include <bitset>
#include <numeric>
#include <type_traits>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int INF = 1 << 30;
const ll LLINF = 2000000000;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
int main() {
	ll n, v[200020] = {};
	cin >> n;
	rep(i, n) {
		ll nn; cin >> nn;
		v[n/ 2 + (i % 2 == (n%2==0?0:1) ? (i + 1) / 2 : -(i + 1) / 2)] = nn;
	}
	rep(i, n)cout << v[i] <<" ";
	cout << "" << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<" "<<endl;
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//-------------------------------------------------------------------------------





int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	int k;
	cin>>k;
	int h[100005];
	for(int i=1;i<=n;++i){
		cin>>h[i];
	}
	int dp[100005]={};
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);

	for(int i=3;i<=n;++i){
		dp[i]=INT_MAX;
		for(int j=1;j<=k;++j){
          if(i-j>=1){
			dp[i]=min(dp[i],(dp[i-j]+abs(h[i-j]-h[i])));
          }
		}
	}
	cout<<dp[n]<<'\n';


}
 

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,a[100000],i,c=0,max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    i=0;
    while(i<n-1)
    {
        if(a[i]>=a[i+1])
            c++;
        else
        {
            if(c>max)
                max=c;
            c=0;
        }
        i++;
    }
    if(c>max)
        max=c;
    printf("%d\n",max);

}


Measured memory_bytes: 512
def inner_product(a1, a2, b1, b2)
  a1 * b1 + a2 * b2
end

while line = gets
  xA, yA, xB, yB, xC, yC, xD, yD = line.chomp.split().map(&:to_f)
  puts inner_product(xA - xB, yA - yB, xC - xD, yC - yD).abs < 1e-12 ? :YES : :NO
end

Measured memory_bytes: 8772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair< P , int > PP;
int n;
int A,B,C;
int x,y,z;
int nx,ny,nz;
int dx[]={1,0,0,-1,0,0};
int dy[]={0,1,0,0,-1,0};
int dz[]={0,0,1,0,0,-1};
map< PP , bool > mp;
 
bool check(int x,int y,int z){
  if(x==-1||y==-1||z==-1)return false;
  if(x==A||y==B||z==C)return false;
  PP key=PP( P(x,y) , z);
  if( mp.count(key) > 0)return false;
  return true;
}
 
int main(){
  while(scanf("%d %d %d %d",&A,&B,&C,&n)!=EOF){
    ll ans=(ll)A*(ll)B*2LL+(ll)B*(ll)C*2LL+(ll)C*(ll)A*2LL;    
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&x,&y,&z);
      for(int i=0;i<6;i++){
        nx=x+dx[i];
        ny=y+dy[i];
        nz=z+dz[i];
        if(check(nx,ny,nz))ans++;
        else ans--;
      }
      mp[ PP(P(x,y),z) ] = true;
    }
    cout<<ans<<endl;
    mp.clear();
  }
 
  return 0;
}

Measured memory_bytes: 1272
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
  while(1)
    {
  char buf[128][2];
  char str[128];
  buf['A']['0']='X';
  buf['A']['1']='Y';
  buf['X']['1']='Z';
  //buf['X']['0']='n';
  buf['Y']['0']='X';
  //buf['Y']['1']='n';
  buf['Z']['0']='W';
  buf['Z']['1']='B';
  buf['W']['0']='B';
  buf['W']['1']='Y';
  buf['B']['0']='Y';
  buf['B']['1']='X';
  scanf("%s",str);
  if(str[0]=='#')break;
  int ans=strlen(str);
  
  char now='A';
  for(int i=0;i<ans;i++)
    {
      
      now=buf[now][str[i]];
      

    }
  if(now=='B')printf("Yes\n");
  else printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 944
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n;
string s;

main(){
  cin>>s;
  n=s.size();
  rep(i,n){
    if(i==0&&(s[0]=='0'||s[n-2]=='0')){
      cout<<-1<<endl;
      return 0;
    }

    else if(i==n-1&&s[i]=='1'){
      cout<<-1<<endl;
      return 0;
    }
    if(i<n-1&&s[i]!=s[n-i-2]){
      cout<<-1<<endl;
      return 0;
    }
  }

  int a=1,t=3;
  queue<int> q;
  q.push(2);

  rep(i,n-1){
    if(s[i]=='1'){
      while(!q.empty()){
        cout<<a<<' '<<q.front()<<endl;
        if(q.size()==1) a=q.front();
        q.pop();
      }
      q.push(t++);
    }else{
      q.push(t++);
    }
  }

}


Measured memory_bytes: 2048
k = int(input())
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(s[k-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
using namespace std;
bool cmp(int v1,int v2){
	return v1>v2;
}
int main() {
	// your code goes here
	int n,k;cin>>n>>k;
	int a[n+2];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n,cmp);
	int tot = 0;
	for(int i=0;i<min(k,n);i++) tot+=a[i];
	printf("%d\n",tot);
	return 0;
}

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

int main() {
    int n;cin>>n;
    vector<int> ar(n);
    for(auto &i:ar) cin>>i;
    sort(ar.begin(), ar.end());
    int c=1;
    for(int i=0;i<n-1;i++) {
        if(ar[i]!=ar[i+1]) c++;
    }
    cout<<c<<"\n";
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int r;
  cin >> r;
  
  cout << 3*r*r << endl;

}


Measured memory_bytes: 256
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var Y = Number(lines[0].split(" ")[1]);

    for (var i = 0; i <= 2000; i++) {
        for (var j = 0; j <= 2000; j++) {
            if (N - i - j < 0) { break; }
            if (10000 * i + 5000 * j + 1000 * (N - i - j) === Y) { console.log(i, j, N - i - j); return (0) }
        }
    }
    console.log(-1, -1, -1);
});

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

ll f(ll x){
    if(x == 1) return 1LL;
    return 2 * f(floor(x / 2)) + 1LL;
}

int main(void){
    ll h;
    cin >> h;
    cout << f(h) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
s=[int(input())]
while True:
    if s[-1]%2==0:
        s.append(s[-1]//2)
    else:
        s.append(s[-1]*3+1)
    for i in range(len(s)-1):
        if s[i]==s[-1]:
            print(len(s))
            sys.exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  string s,t;
  cin >> s >> t;
  map<char, V> m;
  I i = 1;
  for(char c:s){
    m[c].push_back(i);
    i++;
  }
  I an = 0;
  I now = 0;
  for(auto c:t){
    if (m.find(c) != m.end()){
      auto iter = upper_bound(ALL(m[c]), now);
      if (m[c].end() - iter == 0){
        an += m[c].at(0) + (s.size() -  now);
        now = m[c].at(0);
      }else{
        an += *iter - now;
        now = *iter;
      }
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << an << endl;
  return 0;

  /*
  bool chk = true;
  I an = 0;
  I now = 0;
  while (chk){
    bool loop = true;
    for(auto c:s){
      an++;
      if(c == t.at(now)){
        loop = false;
        if(now == t.size()-1){
          chk = false;
          break;
        }else{
          now++;
        }
      }
    }
    if (loop){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << an << endl;
  return 0;
  */
}



Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,m;
vector<ll> v[10];
bool tf[10];
ll ans=0;
void DFS(ll x,ll k){
  if(k==n){
      ans++;
      return;
  }
  tf[x]=true;
  for(auto z:v[x]){
      if(!tf[z]){
          DFS(z,k+1);
      }
  }
  tf[x]=false;
}
int main(void) {
  cin>>n>>m;
  for(int i=0;i<m;i++){
      ll a,b;
      cin>>a>>b;
      v[a].push_back(b);
      v[b].push_back(a);
  }
  DFS(1,1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  string s;
  cin >> s;
  int tmp = 'R';
  int cnt0 = 0, cnt1 = 0;
  vector<int> ans(s.size());
  rep(i, s.size())
  {
    if(s[i] == 'R'){
      if(i%2)
        cnt1++;
      else
        cnt0++;
    }
    else
    {
      if(i%2){
        ans[i] += cnt1;
        ans[i - 1] += cnt0;
      }else{
        ans[i] += cnt0;
        ans[i - 1] += cnt1;
      }
      cnt1 = 0;
      cnt0 = 0;
    }
  }
  reverse(s.begin(), s.end());
  reverse(ans.begin(), ans.end());
  rep(i, s.size())
  {
    if (s[i] == 'L')
    {
      if (i % 2)
        cnt1++;
      else
        cnt0++;
    }
    else
    {
      if (i % 2)
      {
        ans[i] += cnt1;
        ans[i - 1] += cnt0;
      }
      else
      {
        ans[i] += cnt0;
        ans[i - 1] += cnt1;
      }
      cnt1 = 0;
      cnt0 = 0;
    }
  }
  reverse(ans.begin(), ans.end());
  rep(i,ans.size()){
    cout << ans[i] << " ";
  }
}

Measured memory_bytes: 1024
class Array
    def graphify(node)
        out = Array.new(node){Array.new(node,false)}
        self.each do |i,j|
            out[i-1][j-1]=true
            out[j-1][i-1]=true
        end
        return out
    end
end

def dfs(node)
    return if @visited[node]
    @visited[node]=true
    @graph[node].each_with_index do |e,i|
        dfs(i) if e
    end
    return
end

N,M = gets.split.map &:to_i
as = M.times.map{gets.split.map(&:to_i)}
ORIGEN=as.graphify(N)
cnt=0
as.each do |i,j|
    @graph=Marshal.load(Marshal.dump(ORIGEN))
    @graph[i-1][j-1]=false
    @graph[j-1][i-1]=false
    @visited=Array.new(N,false)
    dfs(0)
    cnt+=1 if !@visited.all?
end
puts cnt


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

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V>& x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T& x)
{
    int f = 0;
    cerr << '{';
    for (auto& i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif



int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    priority_queue<pair<int,int>> pq1  , pq2 ;

    vector<int> cnt1 (1e5 + 10) , cnt2(1e5 + 10); 

    int n ; 
    cin >> n ;

    vector<int> A (n);

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

    }

    for(int i = 0 ; i < n ; i += 2 ){
        cnt1[A[i]]++; 
    }

    for(int i = 1 ; i < n ; i += 2 ){
        cnt2[A[i]]++; 
    }

    // cout <<  cnt1[1] << "\n";
    for(int i = 0 ; i <=  1e5; ++i){
        
        // if (n/2 - cnt1[i]  == 0){
        //     cout << i << "\n";
        // }

        // debug(n/2 - cnt1[i],  i); 
        // debug(n/2 - cnt2[i] , i);
        pq1.push({n/2 - cnt1[i] , i}); 
        pq2.push({n/2 - cnt2[i], i}); 

        if (pq1.size() > 2){

            // debug(pq1.top()); 
            pq1.pop(); 
        }
        if (pq2.size() > 2){
            // debug(pq2.top());
            pq2.pop();
        }
    }
    pq1.push({n/2 , 1e6 + 1 }); 
    pq2.push({n/2 , 1e6 + 2}); 

    if ((int)pq1.size()  > 2){
        pq1.pop(); 
    }
    if ((int) pq2.size() > 2){
        pq2.pop(); 
    }

    vector<pair<int,int>> B;

    B.push_back(pq1.top()); 
    pq1.pop(); 
    B.push_back(pq1.top()); 
    pq1.pop();

    B.push_back(pq2.top());
    pq2.pop();
    B.push_back(pq2.top());
    pq2.pop();

    int ans = 1e9 ; 

    // debug(B);3
    for(int i = 0 ; i < 4 ; ++i){
        for(int j = 0 ; j < 4 ; ++j){
            if (B[i].second ==  B[j].second){
                continue; 
            }
            ans = min(ans , B[i].first + B[j].first); 
        }
    }

    cout << ans << "\n";



    return 0;
}



Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>

using namespace std;

int S;
int main() {
    cin >> S;
    int h, m, s;
    h = S / 3600;
    S %= 3600;
    m = S / 60;
    S %= 60;
    s = S;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 3184
n,x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

a.sort!
sum = 0
ans = 0
a.each do |v|
  if sum + v <= x
    sum += v
    ans += 1
  end
end
ans -= 1 if ans == n && sum != x 
p ans


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

void selectSort(int a[], int n) {
	int mini,temp;
	int l = 0;
	for (int i = 0; i < n; i++) {
		mini = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[mini])
				mini = j;
		}
		if (mini != i) {
			temp = a[mini];
			a[mini] = a[i];
			a[i] = temp;
			l++;
		}
	}

	for (int k = 0; k < n - 1; k++)
		cout << a[k] << " ";
	cout << a[n - 1] << endl;
	cout << l<<endl;
}
int main()
{
	int n;
	int a[200];
	while (cin >> n)
	{
		for (int i = 0; i < n; i++)
			cin >> a[i];
		selectSort(a, n);
	}
	
    return 0;
}



Measured memory_bytes: 3112
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	A := make([]int, N)
	for i, _ := range A {
		fmt.Scan(&A[i])
	}

	m := make(map[int]int)
	for _, a := range A {
		_, c := m[a]
		if c {
			fmt.Println("NO")
			return
		} else {
			m[a] = 1
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 13952
{-# LANGUAGE TupleSections #-}

import Control.Arrow
import Control.Applicative
import Data.List
import Prelude hiding (exp)

main :: IO ()
main = do
  { [n, k] <- readLineInputs :: IO [Int]
  ; as <- readLineInputs :: IO [Int]
  ; print $ solve k as
  }

solve :: Int -> [Int] -> Int
solve k as = (k × p) ＋ (k × (k - 1) × q × inv 2)
  where
    p = inversions as
    q = inversions' as

inversions' :: [Int] -> Int
inversions' as = count (runlen (sort as)) as

count :: [(Int, Int)] -> [Int] -> Int
count = iter 0
  where
    iter c _ [] = c
    iter c rs (x:xs) = iter (c + (foldr ((+) . snd) 0 $ takeWhile ((< x) . fst) rs)) rs xs

readLineInputs :: Read a => IO [a]
readLineInputs = map read . words <$> getLine

spanCount :: (a -> Bool) -> [a] -> (Int, [a])
spanCount p [] = (0, [])
spanCount p xxs@(x:xs)
  | p x       = first succ (spanCount p xs)
  | otherwise = (0,xxs)

runlen :: Eq a => [a] -> [(a, Int)]
runlen []     = []
runlen (x:xs) = case spanCount (x ==) xs of
  (m,ys) -> (x, succ m) : runlen ys

inversions :: Ord a => [a] -> Int
inversions = ($ 0) . fst . head . mergeAll . map ((id :: Int -> Int,) . (1 :: Int,) . (: []))

type List a = (Int, [a])

mergeAll :: Ord a => [(Int -> Int, List a)] -> [(Int -> Int, List a)]
mergeAll []   = []
mergeAll [xs] = [xs]
mergeAll (xs:ys:zss) = mergeAll (merge xs ys : mergeAll zss)

merge :: Ord a => (Int -> Int, List a) -> (Int -> Int, List a) -> (Int -> Int, List a)
merge (f, (_,[])) (g, ys) = (f . g, ys)
merge (f, xs) (g, (_,[])) = (f . g, xs)
merge p@(f,(m,xxs@(x:xs))) q@(g,(n,yys@(y:ys)))
  | x > y     = case merge p (g, (pred n, ys)) of
      (h,(_,zs)) -> ((m +) . h,  (m + n, y : zs))
  | otherwise = case merge (f, (pred m, xs)) q of
      (h,(_,zs)) -> (h, (m + n, x : zs))

-- modula arithmetic

base :: Int
base = 10^9 + 7

(＋) :: Int -> Int -> Int
m ＋ n = (m + n) `mod` base

(×) :: Int -> Int -> Int
m × n = (m * n) `mod` base

exp :: Int -> Int -> Int
exp m 0 = 1
exp m 1 = m
exp m n = if even n then p × p else m × exp m (pred n)
  where
    p = exp m (n `div` 2)

inv :: Int -> Int
inv n = exp n (base - 2)


Measured memory_bytes: 35196
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;

ll k, step = 10;

inline double getval( ll x ){
	ll y = 0;
	for( ll i = x; i; i /= 10 ) y += i % 10;
	return (double)x / (double)y;
}

int main(){
	scanf( "%lld", &k );
	for( int i = 1; i <= 9 && k; ++i, --k )
		printf( "%d\n", i );
	for( ll i = 19; k; i += step, --k ){
		while( getval(i+step) > getval(i+step+step) )
			step *= 10;
		printf( "%lld\n", i );
	}
	return 0;
}

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

int main()
{
	long long int n,k;
    cin>>n>>k;
  	long long int l1[n+1];
  	for(int i=1;i<=n;i++){
    	cin>>l1[i];  
    }
  	for(int i=k+1;i<=n;i++){
    	if(l1[i]>l1[i-k])cout<<"Yes\n";
      	else cout<<"No\n";
    }
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  int n;cin >> n;
  int a[200000],sorted[200000];
  rep(i,n)cin >> a[i];
  memcpy(sorted,a,sizeof a);
  sort(sorted,sorted+n);
  int left = sorted[n/2-1], right = sorted[n/2];
  rep(i,n){
    if(a[i]<=left){
      cout << right << endl;
    }else{
      cout << left << endl;
    }
  }
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
  char x, y;
  int a, b;
  scanf("%c %c", &x, &y);
  if ( x < y ) {
    puts("<");
  } else if ( x == y ) {
    puts("=");
  } else {
    puts(">");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
string n;
int main()
{
	cin>>n;
	for(int s=2;s<n.size();s++)
    {
        if(n[s]==n[s-1]&&n[s]==n[s-2])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    string x;
    cin>>x;
    int n=x.size(),s=0,ans=0;
    for(int i=0; i<n; i++){
        if(x[i]=='S') s++;
        else{
            if(s>0){
                s--;
                ans+=2;
            }
        }
    }
    cout<<n-ans<<endl;
}

Measured memory_bytes: 640