akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, 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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;

	if (n % 1000 == 0) cout << 0 << endl;
	else cout << 1000 - n % 1000 << endl;
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;

    char al, bi, bl, ci;

    al = A[A.size() - 1];
    bi = B[0];
    bl = B[B.size() - 1];
    ci = C[0];

    //cout << al << bi << bl << ci << endl;

    if ((al == bi) && (bl == ci)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;

}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 2e5 + 10;
int64 a[N];
int64 dp[N][3];
bool visit[N][3];
int n;

int64 solve(int pos, int rem) {
  if (pos >= n) return 0;
  int64& ret = dp[pos][rem];
  if (visit[pos][rem]) return ret;
  visit[pos][rem] = true;
  ret = -(1LL << 60);
  for (int i = 0; i <= rem; ++i) {
    ret = max(ret, a[pos + i] + solve(pos + i + 2, rem - i));
  }
  // trace(pos, rem, ret);
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  memset(visit, 0, sizeof(visit));
  int64 ret = solve(0, n % 2 + 1);
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 18456
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n;
   cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++)
  {
  for(int j=1;j<=n;j++)
  rep(k,1,n+1)
  {
  	int ans=__gcd(i,__gcd(j,k));
  	sum+=ans;
	  }	
  }
  cout<<sum<<endl;
return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<stack>
#include<cstring>
using namespace std;
const int M=1e9+7;
int main(){
	int n;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	long long int maxi=a[0];
	long long int ans=0;
	for(int i=1;i<n;i++){
		if(a[i]>maxi)maxi=a[i];
		else ans+=(maxi-a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int x,y;
    cin>>x>>y;
    if(x==1 && y==1){
        cout<<1000000<<endl;
        return 0;
    }
    int cnt=0;
    if(x==1) cnt+=300000;
    if(x==2) cnt+=200000;
    if(x==3) cnt+=100000;
    if(y==1) cnt+=300000;
    if(y==2) cnt+=200000;
    if(y==3) cnt+=100000;
   cout<<cnt<<endl;
   
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	int n,i,j=0,k=0;
	char s[100001];
	scanf("%s",s);
	n = strlen(s);
	
	for(i = 0;i < n;i = i+ 2){
		if(s[i] != '1'){j++;}
		else{k++;}
	}
	for(i = 1;i < n;i = i + 2){
		if(s[i] != '0'){j++;}
		else{k++;}
	}
	
	if(j >= k){printf("%d",k);}
	else{printf("%d",j);}
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#define INF 100000000000000
using namespace std;

int n,u,v,cnt[5001];
long long a[5001],dp[5001][5001][2],dp2[5000][5001][2];
vector<int> g[5001];
vector<int> child[5001];
void dfs(int x,int y){
    cnt[x]++;
    for(int i=0;i<g[x].size();i++){
        if(g[x][i]!=y){
            dfs(g[x][i],x);
            child[x].push_back(g[x][i]);
        }
    }
    for(int i=0;i<=child[x].size();i++){
        for(int j=0;j<=5000;j++){
            dp2[i][j][0]=INF;
            dp2[i][j][1]=INF;
        }
    }
    if(a[x]>0){
        dp2[0][1][0]=a[x];
        dp2[0][1][1]=a[x];
    }
    else{
        dp2[0][1][0]=INF;
        dp2[0][1][1]=a[x];
    }
    for(int i=0;i<child[x].size();i++){
        for(int j=1;j<=cnt[x];j++){
            for(int k=1;k<=cnt[child[x][i]];k++){
                if(a[x]>0){
                    dp2[i+1][j+k-1][0]=min(dp2[i+1][j+k-1][0],dp2[i][j][0]+dp[child[x][i]][k][0]);
                }
                if((dp[child[x][i]][k][0]!=INF||dp[child[x][i]][k][1]<0)){
                    dp2[i+1][j+k][0]=min(dp2[i+1][j+k][0],dp2[i][j][0]);
                    dp2[i+1][j+k][1]=min(dp2[i+1][j+k][1],dp2[i][j][1]);
                }
                dp2[i+1][j+k-1][1]=min(dp2[i+1][j+k-1][1],dp2[i][j][1]+dp[child[x][i]][k][1]);
            }
        }
        cnt[x]+=cnt[child[x][i]];
    }
    for(int i=0;i<=cnt[x];i++){
        dp[x][i][0]=dp2[child[x].size()][i][0];
        dp[x][i][1]=dp2[child[x].size()][i][1];
    }
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i+1]);
    }
    for(int i=0;i<n-1;i++){
        scanf("%d %d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=0;i<n;i++){
        if(dp[1][i+1][0]!=INF||dp[1][i+1][1]<0){
            printf("%d\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 781048
N = int(input())
S = []
for i in range(N):
    a = str(input())
    S.append(a)

AC = S.count('AC')
WA = S.count('WA')
TLE = S.count('TLE')
RE = S.count('RE')

print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))

Measured memory_bytes: 16304
from heapq import heappop, heappush
N, M = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
C.sort(key=lambda x: (x[0], x[1]))
pq = []
j = 0
ans = 0
for i in range(1,M+1):
    while j<N and C[j][0]<=i:
        heappush(pq, -C[j][1])
        j += 1
    if len(pq)!=0:
        ans += -heappop(pq)
print(ans)

Measured memory_bytes: 35428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

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

    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int GaussJordanElim(vector<ll>& a, vector<int>& col) {
    int rank = 0, n = a.size();
    for (int i = 60; i >= 0; --i) {
        int j = rank;
        for (; j < n; ++j) {
            if (a[j]>>i&1) {
                swap(a[rank], a[j]);
                break;
            }
        }
        if (j == n) continue;
        col[rank] = i;
        rep(k,n) {
            if (rank == k) continue;
            if (a[k]>>i&1) a[k] ^= a[rank];
        }
        ++rank;
    }
    return rank;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll s = 0;
  rep(i,n) s ^= a[i];
  ll ans = s;
  rep(i,n) a[i] &= ~s;
  vector<int> col(n);
  int r = GaussJordanElim(a, col);
  ll x = 0;
  for (int i = 60; i >= 0; --i) {
    ll nx = x | (1ll<<i);
    {
      ll b = nx;
      rep(j,r) {
        if (b>>col[j]&1) b ^= a[j];
      }
      if ((b & nx) == 0) x = nx;
    }
  }
  ans += x*2;
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 4580
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

/* -------------------------------- Library -------------------------------- */

struct Data {
  int num;
  Data() : num(0) {;}
  Data(int n) : num(n) {;}
};

inline Data Merge(Data left, Data right) {
  return Data(left.num + right.num);
}

struct BIT {
  static const int len = 1 << 17;
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] = Merge(data[i], value);
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&(i+1))-1) s = Merge(s, data[i]);
    return s;
  }
};

/* ---------------------------------- Main ---------------------------------- */

int t[3][128000];

ll f(vector<int> v) {
  vector<pair<int,int>> vec;
  int n = v.size();
  REP(i,n) vec.emplace_back(v[i], i);
  sort(ALL(vec));
  BIT bit;
  ll res = 0;
  for (auto i: vec) {
    res += bit.query(n).num - bit.query(i.second).num;
    bit.update(i.second, 1);
  }
  return res;
}

bool solve() {
  int N;
  cin >> N;
  REP(i,3) REP(j,N) scanf("%d", &t[i][j]);
  vector<int> a, b, ra, rb;
  int rna = 0, rnb = 0;
  REP(i,N) {
    int n = max({t[0][i], t[1][i], t[2][i]}) / 3 - 1;
    bool rev = true;
    if (t[0][i] == n*3+1 && t[1][i] == n*3+2 && t[2][i] == n*3+3) rev = false;
    else if (t[0][i] == n*3+3 && t[1][i] == n*3+2 && t[2][i] == n*3+1) rev = true;
    else return false;
    if (i % 2 == 0) {
      if (n % 2 == 1) return false;
      a.push_back(n); ra.push_back(rev);
      if (rev) ++rna;
    }
    else {
      if (n % 2 == 0) return false;
      b.push_back(n); rb.push_back(rev);
      if (rev) ++rnb;
    }
  }
  return f(a) % 2 == rnb % 2 && f(b) % 2 == rna % 2;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3696
using System;

namespace ABC160A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Substring(2, 1) == s.Substring(3, 1) && s.Substring(4, 1) == s.Substring(5, 1))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int x;
  cin >> x;
  cout << x*x*x << endl;
}

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



Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100005;

int n,a[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int gcd(int x,int y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

bool solve()
{
	for (int i=1;i<=n;i++)
		if (a[i]&1)
		{
			if (a[i]==1) return 0;
			a[i]--;break;
		}
	int d=a[1],tot=0;
	for (int i=2;i<=n;i++) d=gcd(d,a[i]);
	for (int i=1;i<=n;i++) a[i]/=d,tot+=!(a[i]&1);
	if (tot&1) return 0;
	else if (n-tot>1) return 1;
	else return solve()^1;
}

int main()
{
	n=read();
	int tot=0;
	for (int i=1;i<=n;i++) a[i]=read(),tot+=!(a[i]&1);
	if (tot&1) puts("First");
	else if (n-tot>1) puts("Second");
	else puts(solve()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S.size() == 2){
    cout << S << endl;
  }else{
    for(int i = 2; i >= 0; i--){
      cout << S[i] ;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var A=arr.shift().split(" ").map(Number);
var B=arr.shift().split("+");
var sum=0;
B.forEach(function(v){
   var num=v.replace(/n\^/g,"")-0;
   sum+=Math.pow(A[0],num);
});
sum=sum*A[1];
if(sum>1000000000)sum="TLE";
console.log(sum);

Measured memory_bytes: 15684
#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  long long rem = n % k;
  printf("%lld", MIN(rem, ABS(rem - k)));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int INF = 100;
int main(){
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> t(N);
  for (int i = 0; i < N; i++){
    cin >> t[i];
  }
  vector<int> v(N);
  for (int j = 0; j < N; j++){
    cin >> v[j];
  }
  vector<int> S(N + 1, 0);
  for (int i = 0; i < N; i++){
    S[i + 1] = S[i] + t[i] * 2;
  }
  int T = S[N];
  vector<double> V(T + 1, INF);
  for (int i = 0; i < N; i++){
    for (int j = S[i]; j <= S[i + 1]; j++){
      V[j] = min(V[j], (double) v[i]);
    }
  }
  V[0] = 0;
  for (int i = 1; i <= T; i++){
    V[i] = min(V[i], V[i - 1] + 0.5);
  }
  V[T] = 0;
  for (int i = T - 1; i >= 0; i--){
    V[i] = min(V[i], V[i + 1] + 0.5);
  }
  double ans = 0;
  for (int i = 0; i < T; i++){
    ans += V[i] + V[i + 1];
  }
  ans /= 4;
  cout << ans << endl;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,K; cin >> N >> K;
    string S,T; cin >> S; S = "."+S;
    int ans = 0;
    for(int i = 1; i <= N; ++i) {
        if(S[i] != S[i-1]) {
            T.push_back(S[i]);
        }
        else ans++;
    }
    int M = T.size();
    int flg = 0;
    if(!(M%2)) {
        flg = 1;
        M--;
    }
    ans += 2*min(M/2,K);
    if(flg && M/2<K) ans++;
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 636
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,max):
        fac[i] = fac[i-1]*i%mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod

def COM(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod

mod = 998244353
N,M,K = map(int,input().split())

max = max(N,2) 
fac = [0] * max
finv = [0] * max
inv = [0] * max
COMinit()
ans = 0
for i in range(K+1):
    c = COM(N-1,i)
    m = pow(M-1,N-i-1,mod)
    ans = (ans + ((c*m%mod)*M%mod))%mod
print(ans)


Measured memory_bytes: 74328
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  string S; cin >> S;
  int N = (int)S.size();
  vector<int> ans(N, 0);
  int Rnum, Lnum, Rstart, i, R, L;
  Rnum = 0; Lnum = 0; Rstart = 0; i = 0;
  
  while(i < N){
    while(S[i] == 'R'){
      Rnum++;
      i++;
    }
    while(S[i] == 'L'){
      Lnum++;
      i++;
    } // S[i] は R
    R = (Rnum+1)/2 + Lnum/2;
    L = Rnum/2 + (Lnum+1)/2;
    ans[Rstart + Rnum - 1] = R;
    ans[Rstart + Rnum] = L;
    Rnum = 0; Lnum = 0; Rstart = i;
  }
  
  for (auto a: ans)
    cout << a << " ";
    cout << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

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

    ll d = c-a-b;

    ll dd = pow(c-a-b,2);

    if( c-a-b > 0 && 4*a*b < d*d ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define VL vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
int main()
{
    fastio
        ll l = 0;
        ll test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;
        cin>>n;
        if(n>=400 && n<600)
            cout<<8<<endl;
        if(n>=600 && n<800)
            cout<<7<<endl;
        if(n>=800 && n<1000)
            cout<<6<<endl;
        if(n>=1000 && n<1200)
            cout<<5<<endl;
        if(n>=1200 && n<1400)
            cout<<4<<endl;
        if(n>=1400 && n<1600)
            cout<<3<<endl;
        if(n>=1600 && n<1800)
            cout<<2<<endl;
        if(n>=1800 && n<2000)
            cout<<1<<endl;
    }
}

Measured memory_bytes: 3660
s = input()
t = input()
l_s = len(s)
l_t = len(t)

s2 = s + s
l_s2 = len(s2)

next_idx_1 = [[l_s2] * 26 for i in range(l_s2+1)]

for i in reversed(range(l_s2)):
    for j in range(26):
        next_idx_1[i][j] = next_idx_1[i+1][j]
    next_idx_1[i][ord(s2[i]) - ord("a")] = i

next_idx_2 = [[l_s2] * 26 for i in range(l_s2)]

for i in reversed(range(1, l_s2)):
    for j in range(26):
        next_idx_2[i-1][j] = next_idx_2[i][j]
    next_idx_2[i-1][ord(s2[i]) - ord("a")] = i

cur_idx = 0
for i in range(l_t):
    if i == 0:
        idx = next_idx_1[cur_idx%l_s][ord(t[i]) - ord("a")]

    else:
        idx = next_idx_2[cur_idx%l_s][ord(t[i]) - ord("a")]

    if idx == l_s2:
        print("-1")
        exit()

    cur_idx += idx - (cur_idx % l_s)
    
print(cur_idx+1)

Measured memory_bytes: 193684
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool a,b,c,d;

int p;
bool eval(const string &s){
  if(s[p]=='-'){
    p++;
    return !eval(s);
  }
  else if(s[p]=='('){
    p++;
    bool x = eval(s);
    if(s[p]=='^'){
      p++;
      bool y = eval(s);
      assert(s[p]==')');
      p++;
      return x^y;
    }
    else if(s[p]=='*'){
      p++;
      bool y = eval(s);
      assert(s[p]==')');
      p++;
      return x&y;
    }
    else assert(false);
  }
  switch(s[p++]){
    case '0': return false;
    case '1': return true;
    case 'a': return a;
    case 'b': return b;
    case 'c': return c;
    case 'd': return d;
    default: dbg(s,p);
  }
  assert(false);
}

int doall(const string &s){
  int x = 0;
  rep(i,2)rep(j,2)rep(k,2)rep(l,2){
    a=i; b=j; c=k; d=l;
    p = 0;
    x = x*2 + eval(s);
  }
  return x;
}

int main(){
  unordered_set<string> s;
  s.insert("a");
  s.insert("b");
  s.insert("c");
  s.insert("d");
  s.insert("-a");
  s.insert("-b");
  s.insert("-c");
  s.insert("-d");
  rep(i,3){
    unordered_set<string> ns(s);
    for(auto &ps : s) for(auto &pt : s) if(ps.size()+pt.size() <= 13 && ps < pt){
      string s1 = "(" + ps + "^" + pt + ")";
      string s2 = "(" + ps + "*" + pt + ")";
      ns.insert(s1);
      ns.insert(s2);
      if(s1.size()<16){
        ns.insert("-" + s1);
        ns.insert("-" + s2);
      }
    }
    swap(ns,s);
    // dbg(vector<string>(all(s)),i,s.size());
  }
  s.insert("0");
  s.insert("1");

  vector<int> vec(1<<16, INF);
  for(auto &str: s){
    int v = doall(str);
    vec[v] = min<int>(vec[v], str.size());
  }

  string str;
  while(cin>>str, str!="."){
    int v = doall(str);
    cout << vec[v] << endl;
  }

  return 0;
}

Measured memory_bytes: 11384
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

#define inf 10000000

using namespace std;

int h,w;
vector<vector <char>> map;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int bfs(int sy,int sx,int gy,int gx){
	vector<vector<int>> d;
	queue<pair<int,int>> que;
	d.resize(h);
	for(int i=0;i<h;++i){
		d[i].resize(w);
		for(int j=0;j<w;++j){
			d[i][j] = inf;
		}
	}
	d[sy][sx] = 0;
	que.push(make_pair(sy,sx));
	while(que.size() != 0){
		pair<int,int> p = que.front();
		que.pop();
		if(p.first == gy && p.second == gx)break;
		for(int i=0;i<4;++i){
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if(ny >= 0 && ny < h && nx >= 0 && nx < w){
				if(map[ny][nx] == '.' && d[ny][nx] == inf){
					que.push(make_pair(ny,nx));
					d[ny][nx] = d[p.first][p.second] + 1;
				}
			}
		}
	}
	return d[gy][gx];
}

int main(){
	int bc = 0;
	cin >> h >> w;
	map.resize(h);
	for(int i=0;i<h;++i){
		map[i].resize(w);
		for(int j=0;j<w;++j){
			cin >> map[i][j];
			if(map[i][j] == '#')bc++;
		}
	}
	int res = bfs(0,0,h-1,w-1);
	if(res == inf)cout << -1 << endl;
	else cout << h * w - (res + 1) - bc << endl;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
h=float("INF")
pos=0
for i in range(N):
    temp=T-H[i]*0.006
    if abs(temp-A)<h:
        h=abs(temp-A)
        pos=i+1
print(pos)

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N;
ll A[202020];
ll i, j, k;

int main(){
    scanf("%lld", &N);
    rep(i,1,111){
        rep(j,1,111){
            rep(k,1,111){
                ll a = i * i + j * j + k * k + i * j + j * k + k * i;
                if(a>101010)
                    continue;
                ++A[a];
            }
        }
    }
    rep(i,0,N){
        printf("%lld\n", A[i + 1]);
    }
    return 0;
}

Measured memory_bytes: 4344
def prime(p):
    memo = []
    for i in range(2,(int(p**0.5)+1)):
        while p%i==0:
            p //= i
            memo.append(i)
    if p != 1:
        memo.append(p)
    return memo

import collections
 
n=int(input())
 
memo = prime(n)

c = collections.Counter(memo)

memo = sorted(c.items(), key=lambda x:-x[0])

if len(memo) == 0:
  print(0)
else: 
  ans = 0
  for i ,j in memo:
    count_kazu = 1
    while 0 <= j-count_kazu:
      j -= count_kazu
      ans += 1
      count_kazu += 1
  print(ans)
  

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

int main(){
    int n; cin>>n;
    int t[100010]={0},x[100010]={0},y[100100]={0};
    for(int i=1;i<=n;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    for(int i=1;i<=n;i++){
        if((x[i]+y[i]+t[i])&1||!(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])<=t[i]-t[i-1])){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

int main()
{
	
	int n;
	cin>>n;
	int arr;
	int f=0;
	int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr;
		if(arr %2 == 0)
		{
			c++;
			if((arr %3 ==0))
			{
				f++;
			
			}
			else if(arr%5==0)
			f++;
		}
	}
	if(f==c)
	cout<<"APPROVED"<<endl;
	else
	cout<<"DENIED"<<endl;
	return 0;
	
}


Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
mp_min=a+b+c

for i in range(4**n):
    abc=[[],[],[],[]]
    for j in range(n):
            abc[i // (4**(n-1-j))].append(j)
            i = i % (4**(n-1-j))
    if len(abc[0]) == 0 or len(abc[1]) == 0 or len(abc[2]) == 0:
            continue
    a_mp = abs(sum(l[i] for i in abc[0])-a) + (len(abc[0])-1)*10
    b_mp = abs(sum(l[i] for i in abc[1])-b) + (len(abc[1])-1)*10
    c_mp = abs(sum(l[i] for i in abc[2])-c) + (len(abc[2])-1)*10
    mp_min = min(mp_min, a_mp+b_mp+c_mp)
print(mp_min)

Measured memory_bytes: 3064
import numpy as np
import math
N = int(input())
a = list()
for i in range(N):
    a.append(list(map(int, input().split())))
a = np.array(a)    
dis = 0
for i in range(N):
    for j in range(N):
        dis = dis + math.sqrt((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)
dis = dis/2
print(dis*2/N)

Measured memory_bytes: 12392
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N ,M;
	
	cin>>N>>M;
	
	cout<<yn(N == M)<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    double B = sc.nextDouble();
    long C = A * (long)(B * 100 + 0.1);
    System.out.println(C / 100);
  }
}


Measured memory_bytes: 37256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

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

void solve() {
    lli n;
    cin >> n;
    lli a[n + 1], ans[n + 1];

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ans[a[i]] = i;
    }

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
    }
}

int main()
{
    IOS;
    //comment it out
    //freopen("input.txt", "r", stdin);
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 2432
n, m = map(int,input().split())
lis = list(map(int, input().split()))
lis.sort()

if m <= n:
    print(0)
else:
    lis2 = [0]
    for i in range(m-1):
        lis2.append(int(abs(lis[i+1] - lis[i])))
    lis2.sort()
    lis2.reverse()
    del lis2[0:(n-1)]
    print(sum(lis2))



Measured memory_bytes: 13968
import java.util.Scanner;

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

    int size = sc.nextInt();
    
    int nums[] = new int[size];
    for (int i = 0; i < size; i++) {
      nums[i] = sc.nextInt();
    }

    int count = 0;

    while(true) {
      for (int i = 0; i < size; i++) {
        if (nums[i] == 0 || nums[i] % 2 == 1) {
          System.out.println(count);
          return;
        }
        nums[i] = nums[i] / 2;
      }
      count++;
    }
  }

}

Measured memory_bytes: 21844
#!/usr/bin/env python

def main():
    d = int(input())
    c_lst = list(map(int, input().split()))
    s_mat = [list(map(int, input().split())) for _ in range(d)]

    t_lst = []
    for _ in range(d):
        t_lst.append(int(input())-1)

    scr = 0
    last = [-1 for _ in range(26)]
    for day in range(d):
        t = t_lst[day]
        scr += s_mat[day][t]
        last[t] = day
        for typ in range(26):
            scr -= c_lst[typ] * (day - last[typ])
        print(scr)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9268
import sys
import itertools
from itertools import accumulate
def main():
    import itertools
    def eratosthenes_sieve(n):
        table = [0] * (n + 1)
        prime_list = []
        for i in range(2, n + 1):
            if table[i] == 0:
                prime_list.append(i)
                for j in range(i + i, n + 1, i):
                    table[j] = 1
        return prime_list
        def inputs():return (int(x) for x in input().split())
    input = sys.stdin.readline
    def inputs():
        return (int(x) for x in input().split())
    M = 10**5
    prime_list=eratosthenes_sieve(M)
    kaku = set(prime_list)
    N = [0]*(M+1)
    for i in range(1,M+1,2):
        if i in kaku and ((i+1)/2 in kaku):
            N[i] =1 
    ans = list(accumulate(N))
    Q = int(input())
    for i in range(Q):
        l,r = inputs()
        print(ans[r]-ans[l-1])
main()

Measured memory_bytes: 54612
X, Y = map(int,input().split())
if 2 * X < Y or 2 * Y < X or (X+Y) % 3:
  print(0)
  quit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb((X+Y)//3,(-X+2*Y)//3,mod))

Measured memory_bytes: 122048
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    map<char,int>m;
    map<char,int>::iterator it;
    cin>>s;
    for(int i=0;i<4;i++)
    {
        m[s[i]]++;
    }
    if(m.size()==2)
    {
        for(it=m.begin();it!=m.end();it++)
        {
            if(it->second<2)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	char s[105];
	scanf("%d",&n);
	cin>>s;
	if(strlen(s)<=n)cout<<s<<endl;
	else {
		s[n]='\0';
		printf("%s",s);
		printf("...\n",s);
	}
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>

using namespace std;


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

	int n;
	cin >> n;
	vector<int> numbers(n + 1);

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

	vector<int> dp(n + 1);

	for (int i = 2; i <= n; ++i) {
		if (i == 2) {
			if (numbers[1] == 1) {
				dp[1] = 1;
			}
		}

		if (numbers[i] == i)
			dp[i] = dp[i - 2] + 1;
		else
			dp[i] = dp[i - 1];
	}

	cout << dp[n] << endl;


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    
    ll odd[100010] = {};
    ll even[100010] = {};

    rep(i, n){
        ll a;
        cin >> a;
        if(i&1)odd[a]++;
        else even[a]++;
    }

    vector<ll> od(100010);
    vector<ll> ev(100010);
    iota(ALL(od), 0);
    ev = od;

    sort(ALL(od), [&](ll x, ll  y){
        return odd[x] > odd[y];
    });
    sort(ALL(ev), [&](ll x, ll  y){
        return even[x] > even[y];
    });

    ll ans;
    if(od.front()!= ev.front())ans = n - (odd[od.front()]+even[ev.front()]);
    else {
        ans = n - (odd[od.front()]+even[ev[1]]);
        ans = min(ans, n - (odd[od[1]]+even[ev.front()]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int v[102], n;

int compare_ints(const void* a, const void* b)
{
    int arg1 = *(const int*)a;
    int arg2 = *(const int*)b;

    if (arg1 < arg2) return -1;
    if (arg1 > arg2) return 1;
    return 0;

}

int main()
{
    int nr = 1, i;
    scanf("%d", &n);

    for(i = 0; i < n; i ++)
        scanf("%d", v + i);

    qsort(v, n, sizeof(int), compare_ints);

    for(i = 1; i < n; i ++)
        if(v[i] > v[i - 1])
            nr ++;

    printf("%d", nr);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] P = new int[N];
		int[] C = new int[N];
		
		for(int i=0; i<N; i++)
			P[i] = sc.nextInt()-1;
		for(int i=0; i<N; i++)
			C[i] = sc.nextInt();
		
		boolean[] visited = new boolean[N];
		
		long ans = Long.MIN_VALUE;
		for(int i=0; i<N; i++) {
			if(!visited[i]) {
				ArrayList<Integer> list = new ArrayList<>();
				int cur = i;
				while(!visited[cur]) {
					list.add(C[cur]);
					visited[cur] = true;
					cur = P[cur];
				}
				ans = max(ans, solve(list, K));
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
	
	static long solve(ArrayList<Integer> list, int K) {
		int L = list.size();
		long[] score = new long[L+L+1];
		for(int i=0; i<L+L; i++) {
			score[i+1] = score[i] + list.get(i%L);
		}
		
		long ans = Long.MIN_VALUE;
		for(int i=0; i<L; i++) {
			for(int j=1; j<=min(K, L); j++) {
				long sum = score[i+j] - score[i];
				if(score[L]>0) {
					sum += (K-j)/L*score[L];
				}
				ans = Math.max(ans, sum);
			}
		}
		
		return ans;
    }
}


Measured memory_bytes: 40008
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int) i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

const int N=1e5+10;
ll a[N<<4];
int sum[11];
main(){
    ios
    int h,w,n;scanf("%d%d%d",&h,&w,&n);
    h-=2,w-=2;
    int x;int y;
    int cnt=0;
    ll m=(ll)h*w;
    rep(iii,n){
        scanf("%d%d",&x,&y);
        rep(i,3)if( x-i>=1 && x-i<=h){
            rep(j,3)if(y-j>=1 && y-j<=w){
            a[cnt++]=((ll)(x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A+B)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cerr<<#a<<" : ";for(lli i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(lli i=0;i<row;i++) {for(lli j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {lli idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
	lli n;
	cin>>n;
	map<int,int> mp;
	fr(i,n){
		int x;cin>>x;mp[x]++;
	}
	lli ans=0;
	for(int i=30;i>=0;i--){
		for(auto v=mp.rbegin();v!=mp.rend();v++){
			//pr(*v,i);
			lli cur=(*v).F;
			lli matt=(1LL<<i)-cur;
			if(mp.find(matt)==mp.end())continue;
			if(cur==matt){
				ans+=(*v).S/2;
				(*v).S%=2;
			}else{
				lli tt=min((*v).S,mp[matt]);
				ans+=tt;
				mp[matt]-=tt;
				(*v).S-=tt;
			}
		}
	}
	cout<<ans<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 9600
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    h = ii()
    w = ii()
    n = ii()
    print(ceil(n/max(h,w)))




main()


Measured memory_bytes: 5716
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        long[] sum = new long[n + 1];
        for (int i = 1; i <= n; i++)
            sum[i] = sum[i - 1] + a[i - 1];
        long ans = long.MaxValue;
        for (int i = 1; i < n; i++)
        {
            long temp = Math.Abs(sum[n] - 2 * sum[i]);
            ans = Math.Min(ans, temp);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 31580