akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  int n = s.size();

  Vll c(n+1);
  rep(i, n) {
    int x = s[i] - 'a';
    c[i+1] = c[i]^(1ll<<x);
  }

  map<ll, int> dpmin;
  V dp(n+1, INF);
  dp[0] = 0;
  dpmin[0] = 0;
  rep2(i, 1, n+1) {
    if (dpmin.find(c[i]) != dpmin.end()) {
      chmin(dp[i], dpmin[c[i]]+1);
      chmin(dpmin[c[i]], dp[i]);
    }
    rep(x, 26) {
      int y = c[i]^(1ll<<x);
      if (dpmin.find(y) == dpmin.end()) continue;
      chmin(dp[i], dpmin[y]+1);
      if (dpmin.find(c[i]) == dpmin.end()) dpmin[c[i]] = dp[i];
      else chmin(dpmin[c[i]], dp[i]);
    }
  }

  int ans = dp[n];
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 15252
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, ans;
    cin >> N;
    vector<int> A(N+2);
    REP(int,i,1,N+1) cin >> A.at(i);
    A.at(0) = 0;
    A.at(N+1) = 0;
    vector<int> Fee1(N+1);
    vector<int> Fee2(N);
    int Sum = 0;
    REP(int,i,0,N+1){
        Fee1.at(i) = abs(A.at(i+1) - A.at(i));
        Sum += Fee1.at(i);
        //cout << Fee1.at(i) << " ";
    }
    //cout << endl;
    REP(int,i,0,N){
        Fee2.at(i) = abs(A.at(i+2) - A.at(i));
        //cout << Fee2.at(i) << " ";
    }
    //cout << endl;
    REP(int,i,0,N){
        ans = Sum - Fee1.at(i) - Fee1.at(i+1) + Fee2.at(i);
        cout << ans << endl;
    }
    return 0;
}


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

int func(int x, int y, int z){
    int val = ((x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x));
    if(val % 2 == 0){
        return val / 2;
    } else {
        return - 1;
    }
}

int main(void){
    int N;
    cin >> N;
    vector<int> fn(N, 0);

    int maxN = sqrt(N);
    for(int x = 1; x < maxN; x++){
        for(int y = 1; y < maxN; y++){
            for(int z = 1; z < maxN; z++){
                int val = func(x,y,z);
                if(val > 0 && val <= N){
                    fn[val - 1]++;
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        cout << fn[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <climits>

int main()
{
    int n;
    int x[100];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &x[i]);
    }

    int min_val = INT_MAX;
    for(int p=1; p<=100; p++){
        int val = 0;
        for(int i=0; i<n; i++){
            val += (x[i]-p) * (x[i]-p);
        }
        if(val < min_val){
            min_val = val;
        }
    }

   
    printf("%d\n", min_val);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
 
using namespace std;
 
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main(void){
    for(int w, n, cnt = 0; cin >> w >> n, w;){
        vi dp(w + 1); fill(ALL(dp), -1);
        dp[0] = 0;

        char c;
        while(n --){
            int tv, tw; cin >> tv >> c >> tw;
            for(int i = w; 0 <= i; i --) if(i + tw <= w && dp[i] >= 0) dp[i + tw] = max(dp[i + tw], dp[i] + tv);
        }
        
        vi::iterator it = max_element(ALL(dp));
        cout << "Case " << ++ cnt << ":" << endl << *it << endl << it - dp.begin() << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1200
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.valueOf(sc.nextLine());
		int[] list = new int[n];
		String[] ss = sc.nextLine().split(" ");
		for (int i = 0; i < n; i++) {
			list[i] = Integer.valueOf(ss[i]);
		}

		Arrays.sort(list);

		int size = n;
		int sizei = size - 2;
		int sizej = size - 1;
		long sum = 0;

		for (int i = 0; i < sizei; i++) {
			int li = list[i];
			for (int j = i + 1; j < sizej; j++) {
				int lj = list[j];
				int val = li + lj;
				boolean flag = true;
				for (int k = j + 1; k < size; k++) {
					int lk = list[k];
					if (val <= lk) {
						sum = sum + k - j - 1;
						flag = false;
						break;
					}
				}
				if (flag) {
					sum = sum + sizej - j;
				}
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 24148
#include <cstdio>
#include <algorithm>
using namespace std;
int vis[1000010],a[200010],in[1000010];
int main(){
	int n,i,j,cnt,mn=1000010,mx=0,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),vis[a[i]]++,in[a[i]]=1,mn=min(mn,a[i]),mx=max(mx,a[i]);
	for(i=1;i<=n;i++){
		cnt=1;
		while(1){
			cnt++;
			if(a[i]*cnt>mx)break;
			vis[a[i]*cnt]++;
		}
	}
	for(i=mn;i<=mx;i++)
		if(in[i]==1&&vis[i]==1)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10272
a=int(input())
li = list(map(int,input().split()))
if 0 in li:
  print(0)
  
else:
  result = 1
  for number in li:
    result = result * number
    if result > 10**18:
      print(-1)
      break

  if result <= 10**18:
    print(result)

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

int dp[133][133];
int main(){
	string s;
	int c=0;
	while(getline(cin,s)){
		c++;
		s.push_back(',');
		string sa;
		int y=0;
		
		for(int i=0;i<s.size();i++){
			if(s[i]!=','){
				sa.push_back(s[i]);
				}
			else{
				y++;
				dp[c][y]=(stoi(sa));
				sa.clear();
				}	
			}
		}
		
		for(int i=1;i<=105;i++){
			for(int j=1;j<=105;j++){
				if(i<=c/2)dp[i][j]=max(dp[i][j]+dp[i-1][j],dp[i][j]+dp[i-1][j-1]);
				else dp[i][j]=max(dp[i][j]+dp[i-1][j],dp[i][j]+dp[i-1][j+1]);
				}
			}
			int ans=0;
			for(int i=0;i<=c;i++)ans=max(dp[c][i],ans);
			cout<<ans<<endl;
			return 0;
	}

Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, x; cin >> N >> x;
  int a[N]; rep(i,N) cin >> a[i];

  ll result = 0;
  rep(i,N-1) {
    if (a[i]+a[i+1]>x) {
      result+=a[i]+a[i+1]-x;
      a[i+1]=max(x-a[i], 0);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 768
A, B, C = map(int, input().split())

ans = 0
if A == B == C and A % 2 == 0:
    ans = -1
else:
    count = 0
    while (A % 2 == B % 2 == C % 2 == 0):
        wA = (B/2 + C/2)
        wB = (A/2 + C/2)
        wC = (A/2 + B/2)
        A = wA
        B = wB
        C = wC
        count += 1
    ans = count

print(ans)


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

char Rs[256], Rt[256];
string S, T;

void failed() {
  puts("No");
  exit(0);
}

void print() {
  printf("\n");
  for (int i = 'a'; i <= 'z'; i++) {
    char c = Rs[i];
    if (c == 0) c = '_';
    printf("%c ", c);
  }
  printf("\n");
  for (int i = 'a'; i <= 'z'; i++) {
    char c = Rt[i];
    if (c == 0) c = '_';
    printf("%c ", c);
  }
  printf("\n");
}

main() {
  cin >> S >> T;
  bool b = true;
  for (int i = 0; i < S.size(); i++) {
    const char s = S[i];
    const char t = T[i];
    const char rs = Rs[s];
    const char rt = Rt[t];
    if (rs) {
      if (rs != t) failed();
    } else {
      Rs[s] = t;
    }
    if (rt) {
      if (rt != s) failed();
    } else {
      Rt[t] = s;
    }
    // print();
  }
  puts("Yes");
}

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

int main(){
  string s;
  cin >> s;
  if (s == "SAT"){
    cout << 1 << endl;
  }
  if (s == "FRI"){
    cout << 2 << endl;
  }
  if (s == "THU"){
    cout << 3 << endl;
  }
  if (s == "WED"){
    cout << 4 << endl;
  }
  if (s == "TUE"){
    cout << 5 << endl;
  }
  if (s == "MON"){
    cout << 6 << endl;
  }
  if (s == "SUN"){
    cout << 7 << endl;
  }
}

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

int main() {
  int n; cin >> n;
  vector<int> v(n,0);
  for (int i = 1; i < n; i++) {
    int tmp; cin >> tmp;
    v[tmp-1]++;
  }
  for (int a : v) cout << a << endl;
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N, Q;
  cin >> N >> Q;
  vector<vector<ll>> G(N);
  for (ll i = 0; i < N - 1; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  vector<ll> cnt(N);
  for (ll i = 0; i < Q; i++)
  {
    ll p, x;
    cin >> p >> x;
    p--;
    cnt.at(p) += x;
  }

  vector<bool> visited(N, false);
  vector<ll> st;
  visited.at(0) = true;
  st.push_back(0);
  while (!st.empty())
  {
    ll v = st.back();
    st.pop_back();

    for (auto nv : G.at(v))
    {
      if (visited.at(nv))
        continue;

      cnt.at(nv) += cnt.at(v);
      visited.at(nv) = true;
      st.push_back(nv);
    }
  }

  for (ll i = 0; i < N; i++)
  {
    cout << cnt.at(i) << ((i == N - 1) ? '\n' : ' ');
  }
}

Measured memory_bytes: 18032
INT_MAX = 2**31-1
MAX_N = 10**5

def init(n_):
    n = 1
    while n < n_:
        n *= 2
    dat = [INT_MAX] * (2*n-1)
    return n, dat

def update(k, a):
    k += n-1
    dat[k] = a
    while k > 0:
        k = (k-1) // 2
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2])

def query(a, b, k, l, r):
    if r <= a or b <= l:
        return INT_MAX
    if a <= l and r <= b:
        return dat[k]
    else:
        vl = query(a, b, k*2+1, l, (l+r)//2)
        vr = query(a, b, k*2+2, (l+r)//2, r)
        return min(vl, vr)

if __name__ == "__main__":
    n, q = map(int, input().split())
    n, dat = init(n)
    for i in range(q):
        com, x, y = map(int, input().split())
        if com == 0:
            update(x, y)
        elif com == 1:
            print(query(x, y+1, 0, 0, n))


Measured memory_bytes: 8696
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();

		if (S.equals(U)) {
			System.out.print(A - 1 + " " + B);
		} else {
			System.out.print(A + " " + (B - 1));
		}
	}
}

Measured memory_bytes: 21844
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(int(input()))
ans=0
punch=1
while 1:
  ans+=1
  punch=hoge[punch-1]
  if(punch-1==1):
    print(ans)
    break
  if(ans>=100001):
    print(-1)
    break



Measured memory_bytes: 7084
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n;
    int[] h;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    h = new int[6];
	    for(int i=0; i<n; i++){
		double x = sc.nextDouble();
		apart(h, x);
	    }
	    
	    for(int i=0; i<h.length; i++){
		System.out.print((i+1)+":");
		for(int k=0; k<h[i]; k++)
		    System.out.print("*");
		System.out.println();
	    }
	}
    }

    void apart(int[] h, double x){
	if(x<165.0) h[0]++;
	else if(x<170.0) h[1]++;
	else if(x<175.0) h[2]++;
	else if(x<180.0) h[3]++;
	else if(x<185.0) h[4]++;
	else h[5]++;
    }
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    string s;
    cin >> s;
    if(s == "SSS") cout << 0 << endl;
    else if(s=="RRR") cout << 3<< endl;
    else if(s=="RRS"||s=="SRR") cout << 2<< endl;
    else cout << 1 << endl;
}

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

int main() {
    string name1,name2,name3;

    cin >> name1 >> name2 >> name3;
    cout << name1.at(0) << name2.at(0) << name3.at(0) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;

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

const int MAXN = 1e5 + 1;

ll a, b, c, d;

int main(){

    cin >> a >> b >> c >> d;

    cout << max(max((ll)a*c, (ll)b*d), max((ll)a*d, (ll)b*c));

    return 0;

}


Measured memory_bytes: 3632
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  const ll mod = 1000000007;

  vll ps(n + 1, 0);
  ll ans = 1;
  for (ll i = 2; i <= n; i++) {
    if (ps[i] == 0) {
      ll tot = 0;
      for (ll k = i; k <= n; k *= i) tot += n / k;
      ans *= tot + 1;
      ans %= mod;
    }
    for (ll j = i + i; j <= n; j += i) ps[j] = 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(x);
    VI d(x); VIin(d);
    SORT(d);
    int ans = 1;
    rep(i,x-1) if(d[i] < d[i+1]) ans ++;
    ANS; 

    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

bool validMonth(string mm) {
    return (mm[0] == '0' && mm[1] != '0') || (mm[0] == '1' && mm[1] <= '2');
}

int32_t main() {

    string s; cin >> s;

    bool yymm = validMonth(s.substr(2, 2)), mmyy = validMonth(s.substr(0, 2));
    
    if(yymm && mmyy) {
        cout << "AMBIGUOUS\n";
    } else if(yymm) {
        cout << "YYMM\n";
    } else if(mmyy) {
        cout << "MMYY\n";
    } else {
        cout << "NA\n";
    }
    
    return 0;
}


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

int main()
{
	long int n, a, i,  b = 1000000 , c = -1000000,d = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		if (a > c) { c = a; }
		if (a < b) { b = a; }
		d += a;
	}
	cout << b << " " << c << " " << d << endl;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<climits>
#include<vector>

using namespace std;

int main(void) {
	
	int n, d, x;
	
	
	cin >> n;
	cin >> d >> x;

	std::vector<int> a(n);
	for (int i = 0;i < n;++i) {
		int a;
		cin >> a;
		x += 1 + ((d-1) / a);
	}

	cout << x;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main(){
	string str;
	cin >> str;
	rep(i,4){
		cout << str[i];
	}
	cout << " ";
	rep(i,8){
		cout << str[i+4];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll gcd = __gcd(n, m);
	ll lcm = (n * m) / gcd;
	n /= gcd;
	m /= gcd;
	for (int i = 0; i < gcd; i++) {
		if (s[i * n] != t[i * m]) {
			return cout << "-1", 0;
		}
	}
	cout << lcm << endl;
	return 0;

}


Measured memory_bytes: 3884
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        String combo = "";

        for (int i = 0; i < N; i++) {
            combo += String.valueOf(S.charAt(i));
            combo += String.valueOf(T.charAt(i));
        }
        System.out.println(combo);
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  for(int i=0;i<n;i++){
    cin >>  a.at(i);
  }
  vector<long> dp(n,10000000000);
  dp.at(0)=0;
  for(int i=0;i<n-1;i++){
    dp.at(i+1) = min(dp.at(i+1),dp.at(i)+abs(a.at(i)-a.at(i+1)));
    if(i<n-2)dp.at(i+2) = min(dp.at(i+2),dp.at(i)+abs(a.at(i)-a.at(i+2)));
  }
  cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define llint long long

using namespace std;

llint n, k;
vector<llint> pvec, nvec;
llint a[200005];

bool check(llint x)
{
	//cout << x << endl;
	llint ret = 0, p;
	if(x >= 0){
		ret += (llint)pvec.size() * (llint)nvec.size();
		for(int i = 0; i < pvec.size(); i++){
			if(pvec[i] == 0) p = (llint)pvec.size()-1;
			else p = upper_bound(pvec.begin(), pvec.end(), x/pvec[i]) - pvec.begin() - 1;
			ret += max(0LL, p-i);
		}
		for(int i = 0; i < nvec.size(); i++){
			p = upper_bound(nvec.begin(), nvec.end(), x/nvec[i]) - nvec.begin() - 1;
			ret += max(0LL, p-i);
		}
	}
	else{
		for(int i = 0; i < pvec.size(); i++){
			if(pvec[i] == 0) continue;
			llint p = nvec.end() - lower_bound(nvec.begin(), nvec.end(), (-x+pvec[i]-1)/pvec[i]);
			ret += max(0LL, p);
		}
	}
	//cout << x << " " << ret << endl;
	return ret >= k;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	for(int i = 1; i <= n; i++){
		if(a[i] >= 0) pvec.push_back(a[i]);
		else nvec.push_back(-a[i]);
	}
	sort(nvec.begin(), nvec.end());
	
	llint ub = 2e18, lb = -2e18, mid;
	while(ub-lb > 1){
		mid = (ub+lb)/2;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
	
	return 0;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
#define FAST    ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
#define modd 998244353 
 
 
int main(){
FAST;
ll k,a,b; cin>>k>>a>>b;
a--;
if(b/k>a/k)cout<<"OK";
else cout<<"NG";
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <list>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000007LL

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


int main()
{
	int n;
	ll a;
	list<ll> A;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(i%2==0)A.push_back(a);
		else A.push_front(a);
	}
	if(n%2==1)reverse(A.begin(),A.end());
	for(list<ll>::iterator it=A.begin();it!=A.end();it++){
		if(it!=A.begin())printf(" ");
		printf("%lld",*it);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int main(){
 
     
    int A,B,C,D,P;
    cin >>A>>B>>C>>D>>P;
        if (P <= C){
            if (P * A < B){
            cout<<P * A<<endl;
            }else{
                cout<<B<<endl;
            }
            }else{
            if (P*A<(P-C)*D+B){
                cout<<P*A<<endl;
            }else{
                cout<<(P-C)*D+B<<endl;}
            }
return(0);
        } 


Measured memory_bytes: 3088
package main

import "fmt"

const inf = 1 << 60

func f(a []int, n int) {
	for i := 0; i < len(a); i++ {
		a[i] = n
	}
	return
}

func cm(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	c := make([]int, n+1)
	f(c, inf)
	c[0] = 0
	for i := 0; i < n; i++ {
		cm(&c[i+1], c[i]+1)
		for j := 1; i+j <= n; j *= 6 {
			cm(&c[i+j], c[i]+1)
		}
		for j := 1; i+j <= n; j *= 9 {
			cm(&c[i+j], c[i]+1)
		}
	}
	fmt.Println(c[n])
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#ifdef _MSC_VER
#include <conio.h>
#else
#define getch()
#endif

using namespace std;

int main(){
	int unsolve=0;
	int nil=0;
	string str;
	cin >> nil >> str;
	for(int i=0;i<str.length();i++){
		if(str[i]=='('){
			unsolve++;
		}else if(str[i]==')'){
			if(unsolve==0){
				//cout << "i=" << i << ",unsolve" << endl;
				str.insert(str.begin(),'(');
				i++;
			}else{
				//cout << "i=" << i << ",solve" << endl;
				unsolve--;
			}
		}
	}
	for(int i=0;i<unsolve;i++){
		str+=')';
	}
	cout << str << endl;
	getch();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define ll long long
#define ld long double


int main(){

string s;
cin>>s;

sort(s.begin(), s.end());

s=="abc"?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 3068
#include<stdio.h>
#include<string.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
#define P 998244353
const int N=305;
int f[N][N][N],K,ans,n,cn[N];
char s[N];
il void mo(it&p,ct q){p+=q,p=(p>=P?p-P:p);}
int main(){
	scanf("%s%d",s+1,&K),n=strlen(s+1),K=(K<n?K:n);it i,j,k,l,c0;
	for(i=1;i<=n;++i) s[i]=='0'?++c0:++cn[c0];
	f[0][0][0]=1;
	for(i=0;i<=c0;++i)
		for(j=0;j<=K;++j)
			for(k=0;k<=j;++k)
				for(l=-(k<cn[i]?k:cn[i]);l<=K-j;++l)
					mo(f[i+1][j+(l>0?l:0)][k+l],f[i][j][k]);
	for(i=0,++c0;i<=K;++i) ans+=f[c0][i][0],ans=(ans>=P?ans-P:ans);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 56224
#include <bits/stdc++.h>
using namespace std;
 
int64_t gcd(int64_t a, int64_t b) {
  int64_t c = a, d = b;
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  a = c * d / a;
  return a;
} 

int main() {
  int64_t A,B,C,D;
  cin >> A >> B >> C >> D;
  A--;
  int64_t  E, AC, AD, AE, BC, BD, BE;
  E = gcd(C,D);
  AC = A/C;
  AD = A/D;
  AE = A/E;
  BC = B/C;
  BD = B/D;
  BE = B/E;
  int64_t sumA = A + AE - AC - AD;
  int64_t sumB = B + BE - BC - BD;
  cout << (sumB - sumA) << endl;
  return 0;
}

Measured memory_bytes: 256
///*******ZoHuyHieuZo*******///
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define Zo 
#define MOD 1000000007
#define maxn 1000111
#define pb push_back
#define mp make_pair
#define mem(i,m) memset(i,m,sizeof(i))

using namespace std;
struct II
{
    int x,y,z;
};
pii a[maxn];
pii b[maxn];
int par[maxn];
int res;
vector<II> canh;

bool cmp(II a,II b)
{
    return a.z<b.z;
}
int Find(int u)
{
    int v=par[u];
    while(u!=v)
        return par[u]=Find(v);
    return u;
}
void DSU(int x,int y)
{
    int u=Find(x);
    int v=Find(y);
    if(u==v) return ;
    if(u!=v);
    {
        par[v]=u;
        return ;
    }
}
void nhap()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].F>>b[i].F;
        a[i].S=b[i].S=par[i]=i;
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    for(int i=2;i<=n;i++)
    {
        canh.push_back({a[i].S,a[i-1].S,a[i].F-a[i-1].F});
        canh.push_back({b[i].S,b[i-1].S,b[i].F-b[i-1].F});
    }
    sort(canh.begin(),canh.end(),cmp);
    for(int i=0;i<canh.size();i++)
    {
        if(Find(canh[i].x)!=Find(canh[i].y))
            {
                DSU(canh[i].x,canh[i].y);
                res+=canh[i].z;
            }
    }
    cout<<res;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen(Zo".inp","r",stdin);
//    freopen(Zo".out","w",stdout);
    nhap();
}


Measured memory_bytes: 17520
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const KIND_NUM: usize = 2;
type TrieValue = usize;
#[derive(Clone)]
struct TrieNode {
    child: Vec<Option<usize>>,
}
impl TrieNode {
    fn new() -> TrieNode {
        TrieNode {
            child: vec![None; KIND_NUM],
        }
    }
}
struct Trie {
    pool: Vec<TrieNode>,
}
impl Trie {
    fn new() -> Trie {
        Trie {
            pool: vec![TrieNode::new(); 1],
        }
    }
    fn push(&mut self, vs: Vec<TrieValue>) {
        let mut index = 0;
        for v in vs {
            let v = v as usize;
            if self.pool[index].child[v] == None {
                self.pool[index].child[v] = Some(self.pool.len());
                self.pool.push(TrieNode::new());
            }
            index = self.pool[index].child[v].unwrap();
        }
    }
}

fn get_grundy_number(v: u64) -> u64 {
    if v == 0 {
        0
    } else {
        1 << v.trailing_zeros()
    }
}

fn dfs(trie: &Trie, depth: u64, index: usize, l: u64) -> u64 {
    let node = &trie.pool[index];
    let mut ret = 0;
    if node.child[0] != None || node.child[1] != None {
        for i in 0..2 {
            if let Some(nindex) = node.child[i] {
                ret ^= dfs(trie, depth + 1, nindex, l);
            } else {
                ret ^= get_grundy_number(l - depth);
            }
        }
    }
    return ret;
}

fn main() {
    let n: usize = read();
    let l: u64 = read();
    let mut trie = Trie::new();
    for _ in 0..n {
        let s: String = read();
        let s = s.chars().map(|c| (c as usize -'0' as usize) as usize).collect::<Vec<usize>>();
        trie.push(s);
    }
    let ans = dfs(&trie, 0, 0, l);
    println!("{}", if ans != 0 { "Alice" } else { "Bob" });
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x.at(i);

    int distance = 0;
    rep(i, N) {
        int a_distance = x.at(i);
        int b_distance = abs(K - x.at(i));
        distance += min(a_distance, b_distance);
    }

    cout << distance * 2 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int Maxn = 510;
int n, m;
char s[Maxn][Maxn];
int main() {
	int i, j, k;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; i++) scanf("%s", s[i]+1);
	for(i = 1; i <= n; i++){
		printf("#");
		if(i&1) for(j = 2; j < m; j++) printf("#");
		else for(j = 2; j < m; j++) printf("%c", s[i][j]);
		printf(".\n");
	}
	printf("\n");
	for(i = 1; i <= n; i++){
		printf(".");
		if(!(i&1)) for(j = 2; j < m; j++) printf("#");
		else for(j = 2; j < m; j++) printf("%c", s[i][j]);
		printf("#\n");
	}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "Yes"
#define no cout << "No"
#define NAME ""
bool isFile = 0;
 
typedef long long ll;
typedef long double ld;
 
const ll INF=1e9+1234;                                                   
const int N = 4e5 + 5; 
const ll MOD=998244353;
const ll mod=1e9+7;                                            
double EPS = 3e-18;
const double PI = acos(-1);  
 
 
void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);        
    cin.tie(NULL);                                         
    cout.tie(NULL);                                
}                                                     
 
int a[N];
 
 
void solve() 
{			  			 																	 									 	  	                      
	int k,n;
	cin >> k >> n;
	ll sum = 0;
	int mx = 0;
	forn(i,0,n)
	{
		cin >> a[i];
		if(i)
		{
			sum += a[i] - a[i-1];
			mx = max(mx,a[i] - a[i-1]);
		}
	}	
	int mn = a[0] + k - a[n-1];
	sum += mn;
	mx = max(mx,mn);
	cout << sum - mx;	
}                         
                           
int main()                                     
{                            
	faster();                 
	int t = 1;
	//cin >> t;	
	while(t--)
	{               	
		solve();
		ed;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

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


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

    cout << ll(n) * ll(n-1) / 2 << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll mod=1e9+7;
 ll n,k;
 cin>>n>>k;
 ll a[n];
 for(ll i=0;i<n;i++) cin>>a[i];
 ll dp[n][k+1];
 for(ll i=0;i<=a[n-1]&&i<=k;i++) dp[n-1][i]=1;
 for(ll i=a[n-1]+1;i<=k;i++) dp[n-1][i]=0;
 for(ll i=n-2;i>=0;i--){
  ll sum=0;
  ll start=0;
  for(ll j=0;j<=k;j++){
   dp[i][j]=(sum%mod+dp[i+1][j])%mod;
   if(j==start+a[i]){
    sum=(sum-dp[i+1][start])%mod;
    if(sum<0) sum+=mod;
    sum=(sum+dp[i+1][j])%mod;
    start++;
   }
   else sum=(sum+dp[i+1][j])%mod;
  }
 }
 cout<<dp[0][k]<<endl;
 return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll X; cin >> X;

  ll MAX = 200;
  for(ll A = -MAX; A <= MAX; A++){
    for(ll B = -MAX; B <= MAX; B++){
      if( pow(A,5) - pow(B,5) == X){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#include <string.h>

int main(void) {
    int N;
    int count = 0;
    char S[50];
    
    cin >> N;
    cin >> S;
    
    for (int i = 0; i < strlen(S) - 2; i ++) {
        if (S[i] == 'A') {
            if (strncmp((char*)(S + i), "ABC", 3) == 0) {
                count ++;
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    int a, b;
    vector<P> ab(M);
    REP(i, M) {
        cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab.begin(), ab.end());

    int now = 0;
    int ans = 0;
    for (P t : ab) {
        if (t.second >= now) {
            now = t.first;
            ans++;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
main(){
  int n,a[30][30],w,h,m,x1,x2,y1,y2;
  cin>>n;
  while(n--){
    memset(a,0,sizeof(a));
    set<pair<pair<int,int>,pair<int,int> > >s;
    cin>>h>>w>>m;
    r(i,m){
      cin>>x1>>y1>>x2>>y2;
      s.insert(mk(mk(x1,y1),mk(x2,y2)));
      s.insert(mk(mk(x2,y2),mk(x1,y1)));
    }
    a[0][0]=1;
    for(int i=1;i<=w;i++)if(!s.count(mk(mk(0,i),mk(0,i-1))))a[0][i]+=a[0][i-1];
    for(int i=1;i<=h;i++)if(!s.count(mk(mk(i,0),mk(i-1,0))))a[i][0]+=a[i-1][0];
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
      if(!s.count(mk(mk(i,j),mk(i,j-1))))a[i][j]+=a[i][j-1];
      if(!s.count(mk(mk(i,j),mk(i-1,j))))a[i][j]+=a[i-1][j];
    }
    if(a[h][w])cout<<a[h][w]<<endl;
    else cout<<"Miserable Hokusai!"<<endl;
  }
}

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

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



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int h,y,a=0,i;
    scanf("%d",&h);
    for(i=0;h>4;i++)
    {
        if(h>=500)
        {
            y=h/500;
            a=a+y*1000;
            h=h%500;
        }
        else
        {
            y=h/5;
            a=a+y*5;
            h=h%5;
        }
    }
    printf("%d\n",a);
    return 0;

}


Measured memory_bytes: 128
#include <iostream>

class Selection{
public:
	void trace(int *A, int N){
		for(int i = 0; i < N; i++){
			if(i > 0) std::cout << " ";
			std::cout << A[i];
		}
		std::cout << std::endl;
	}
	int selection_sort(int *A, int N){
		int count = 0;
		for(int i = 0; i < N; i++){
			int minj = i;
			for(int j = i; j < N; j++){
				if(A[j] < A[minj]){
					minj = j;
				}
			}
			if(i != minj){
				int tmp = A[i];
				A[i] = A[minj];
				A[minj] = tmp;
				++count;
			}
		}
		trace(A, N);
		return count;
	}

};

int main(){
	Selection s;
	int N;
	int A[100];

	std::cin >> N;
	for(int i = 0; i < N; i++){
		std::cin >> A[i];
	}
	std::cout << s.selection_sort(A, N) << std::endl;
}


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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)
#define PI 3.14159265358979323846264338327950L

// -----



int main()
{
    int n, ans=0;
    cin >> n;
    v<int> l(n);
    rep(i, n) cin >> l[i];
    rep(i, n)
    {
        REP(k, i+1, n)
        {
            REP(m, k+1, n)
            {
                if((l[i] != l[k] && l[i] != l[m] && l[k] != l[m]) && (l[i]+l[k] > l[m] && l[i]+l[m] > l[k] && l[k]+l[m] > l[i])) ++ans;
            }
        }
    }
    pl(ans);
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    double L;
    cin >> L;

    double ippen = L / (double)3;
    cout << fixed;
    cout << setprecision(12) << ippen * ippen * ippen << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()

for s1 in ["A",""]:
    for s2 in ["A",""]:
        for s3 in ["A",""]:
            for s4 in ["A",""]:
                if s==(s1+"KIH"+s2+"B"+s3+"R"+s4):
                    print("YES")
                    exit()
print("NO")


Measured memory_bytes: 2940
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) A[i] = sc.nextInt();

        Arrays.sort(A, Comparator.reverseOrder());
        int a = IntStream.range(0, N).filter(i -> i % 2 == 0).map(i -> A[i]).sum();
        int b = IntStream.range(0, N).filter(i -> i % 2 == 1).map(i -> A[i]).sum();
        int ans = a - b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 29508
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100];
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	x=0;
	for(i=1;i<n-1;i++)
	{
		if((a[i-1]>a[i]&&a[i]>a[i+1])||(a[i-1]<a[i]&&a[i]<a[i+1]))
		{
			x++;
		}
	}
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

long long modpow(long long a, long long n, long long p)
{
    long long out = 1;
    while (n)
    {
        if (n & 1)
        {
            out = out * a % p;
        }
        a = a * a % p;
        n >>= 1;
    }
    return out;
}

int main()
{
    lint n;
    std::vector<lint> step(100000, 0);

    scanf("%lld", &n);

    for (int i = 0; i < n; ++i)
    {
        lint d;
        scanf("%lld", &d);

        if (i == 0 && d != 0)
        {
            printf("%d", 0);
            return 0;
        }

        step[d]++;
    }

    if (step[0] > 1)
    {
        printf("%d", 0);
        return 0;
    }

    lint done = 0;
    lint prev = 1;
    lint i = 0;

    lint ans = 1;
    lint mod = 998244353;

    while (done < n)
    {
        lint cur = step[i];
        if (cur == 0)
        {
            printf("%d", 0);
            return 0;
        }
        done += cur;

        ans *= modpow(prev, cur, mod);
        ans %= mod;

        prev = cur;
        i++;
    }

    printf("%lld", ans);

    return 0;
}


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

using namespace std;
long long MOD = 1000000007LL;

int main() {
	int sx, sy;
	int tx, ty;
	int buf = scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

	string first = "";
	string second = "";
	second += "L";
	for (int i = sy; i < ty; ++i) {
		first += "U";
		second += "U";
	}
	second += "U";

	second += "R";
	for (int i = sx; i < tx; ++i) {
		first += "R";
		second += "R";
	}
	second += "D";

	second += "R";
	for (int i = ty; sy < i; --i) {
		first += "D";
		second += "D";
	}
	second += "D";

	second += "L";
	for (int i = tx; sx < i; --i) {
		first += "L";
		second += "L";
	}
	second += "U";

	cout << first << second << endl;
	return 0;
}

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

int main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,k) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N, A, B;
  cin >> N >> A >> B;
  ll M = A + (N - 1) * B, m = (N - 1) * A + B;
  if (A > B || A != B && N < 2)
    cout << 0 << endl;
  else if (N == 2)
    cout << 1 << endl;
  else
    cout << M - m + 1 << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

int main(void) {
	string s, t;
	cin >> s >> t;

	vector<vector<ll>> alph = vector<vector<ll>>(26, vector<ll>());

	rep(i, 0, s.size()) {
		alph[s[i] - 'a'].push_back(i);
	}
	ll count = 1;
	ll index = 0;
	rep(i, 0, t.size()) {
		if (alph[t[i] - 'a'].size() == 0) {
			count = -1;
			break;
		}
		auto itr = lower_bound(alph[t[i] - 'a'].begin(), alph[t[i] - 'a'].end(), index);
		if (itr != alph[t[i] - 'a'].end()) {
			index = *itr + 1;
		}
		else {
			count++;
			index = alph[t[i] - 'a'][0] + 1;
		}
	}
	ll ans = count > 0 ? (ll)s.size() * (count - 1) + index : -1;
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int n, a[100];
  cin >> n;
  rep(i, 0, n) cin >> a[i];

  dep(i, n, 0) {
    int b = 0;
    rep(j, 0, n) {
      if(a[j] >= i) b++;
    }
    if(b >= i) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3212