akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//	std::cout<<std::fixed<<std::setprecision(10);


int main() {
  string S;
  int Q;
  cin >> S >> Q;
  vector<char> tail;
  vector<char> head;
  rep(i, S.size())
  {
    tail.push_back(S[i]);
  }

  int muki = 0; // 0 or 1;
  int T, F;
  char C;
  rep(i, Q)
  {
    cin >> T;
    if(T==1) {
      muki = (muki+1)%2;
    }
    else
    {
      cin >> F >> C;
      if((muki+F)%2==0) {
        tail.push_back(C);
      } else {
        head.push_back(C);
      }
    }
  }

  if(muki==0) {
    rep(i, head.size()) {
      cout << head[head.size() - 1 - i];
    }
    rep(i, tail.size()) {
      cout << tail[i];
    }
  } else {
    rep(i, tail.size()) {
      cout << tail[tail.size()-1-i];
    }
    rep(i, head.size()) {
      cout << head[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[7];
int main(){
    for(int i=0;i<7;i++) scanf("%lld",arr+i);
    ll ans = arr[1] + arr[0]/2*2 + arr[3]/2*2 + arr[4]/2*2 ;
    if(arr[0]&&arr[3]&&arr[4]){
        ll tmp = arr[1] + 3 + (arr[0]-1)/2*2 + (arr[3]-1)/2*2 + (arr[4]-1)/2*2;
        printf("%lld\n",max(tmp,ans));
    } else { printf("%lld\n",ans); }
}

Measured memory_bytes: 256
S = str(input())

a = b = c = d= 0

for i in S:
    if(i==S[0]):
        a=a+1
    if(i==S[1]):
        b=b+1
    if(i==S[2]):
        c=c+1
    if(i==S[3]):
        d=d+1
if(len(S)==4 and a==b==c==d==2):
    print("Yes")
else:
    print("No")

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

void solve() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);

	int res = 0;
	rep(i, N) {
		res += a[i] - 1;
	}
	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split(" "))
V = list(map(int, input().split(" ")))
V_rev = list(reversed(V))
val = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(N):
    for j in range(N):
        val[i + 1][j] = val[i][j] + V[i]
        val[i][j + 1] = val[i][j] + V_rev[j]

val[N][N] = val[N][N - 1] + V_rev[N - 1]

ans = 0
for l in range(N + 1):
    for r in range(N + 1):
        num = l + r
        if num > K or num > N:
            continue
        rm = []
        can = (K - num)
        for li in range(l):
            if V[li] < 0:
                rm.append(V[li])
        for ri in range(r):
            if V_rev[ri] < 0:
                rm.append(V_rev[ri])

        rm.sort()
        ans = max(ans, val[l][r] - sum(rm[:can]))

print(ans)

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

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

    int n;
    cin>>n;

    int b;
    cin>>b;
    int ans=b;
    int ib=b;

    for(int i=1;i<n-1;i++)
    {
        int b;
        cin>>b;

        ans+=min(ib,b);
        ib=b;
    }

    ans+=ib;

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&b!=c)||(a==c&&b!=c)||(b==c&&a!=c)) 
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  char c;
  cin >> c;
  switch(c) {
    case('A'):
      cout << 'T' << endl;
      break;
    case('T'):
      cout << 'A' << endl;
      break;
    case('C'):
      cout << 'G' << endl;
      break;
    case('G'):
      cout << 'C' << endl;
      break;
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<double,string>> vec(n);
  int i;
  for(i=0;i<n;i++){
    double a;
    string s;
    cin >> a >> s;
    vec.at(i)=make_pair(a,s);
  }
  double sum=0;
  for(i=0;i<n;i++){
    if(vec.at(i).second=="BTC"){
      vec.at(i).first*=380000;
    }
  }
  for(i=0;i<n;i++){
    sum+=vec.at(i).first;
  }
  cout << sum;
}
    
  
  
  

Measured memory_bytes: 256
n = gets.to_i

taro_score, hanako_score = 0, 0
n.times do
	taro, hanako = gets.split(' ')

	if taro > hanako then
		taro_score += 3	
	elsif taro == hanako
		taro_score += 1
		hanako_score += 1
	else
		hanako_score += 3
	end
end

puts "#{taro_score} #{hanako_score}"

Measured memory_bytes: 6100
#include <stdio.h>
#include <stdint.h>

#define STR_MAX    (100000)

#define FAST_TRIAL  (1)

uint64_t serialNum[STR_MAX+2];

int main(void)
{
    uint64_t n;
    uint64_t k;
    char s[STR_MAX+1];

    scanf("%ld %ld", &n, &k);
    scanf("%s", s);

    uint64_t ptr = 0;
    char curC;
    char nxtC;

    uint64_t indx   = 0;
    uint64_t head1  = 0;
    uint64_t max    = 0;
    uint64_t cntK   = 0;
    uint64_t curSum = 0;

    curC = s[ptr++];
    /* serialNumは 1 の数 -> 0の数としたいので0ならindxを送る */
    if ( curC == '0' ) {
        indx++;
    }

#ifdef FAST_TRIAL
    while ( (curC != '\0') && (cntK < k) ) {
        /* nxtCを得る */
        nxtC = s[ptr++];

        serialNum[indx]++;

        /* どうやら次は別の文字のようだ */
        if ( curC !=  nxtC ) {
            curSum += serialNum[indx++];

            if ( curC == '0' ) {
                /* 逆立ちできる人たちが増える */
                cntK++;
            }

            /* ここまでで今回のserialNumによるcurSumが決定するので最大値更新 */
            max = ( curSum >= max ) ? curSum : max;
        }

        curC = nxtC;
    }
#endif

    while ( curC != '\0' ) {
        /* nxtCを得る */
        nxtC = s[ptr++];

        serialNum[indx]++;

//        uint64_t dbgIndx = indx;

        /* どうやら次は別の文字のようだ */
        if ( curC !=  nxtC ) {
            curSum += serialNum[indx++];

            /* 0の連続が終わったときは昔の0を捨てる場合がある */
            if ( curC == '0' ) {
#ifdef FAST_TRIAL
                curSum -= (serialNum[head1] + serialNum[head1+1]);
                head1 += 2;
#else
                /* 逆立ちできる人たちが増える */
                cntK++;

                /* 逆立ちできる人たちがK人より多いとき */
                if ( cntK > k ) {
                    /* 
                     * 1Grp -> 0Grp -> 1Grp -> 0Grp ... 1Grp -> NEW 0Grp
                     * となるので先頭の0Grpと1Grp分を引いて, 0Grpのheadを移動させる
                     */
                    curSum -= (serialNum[head1] + serialNum[head1+1]);
                    head1 += 2;
                }
#endif
            }

            /* ここまでで今回のserialNumによるcurSumが決定するので最大値更新 */
            max = ( curSum >= max ) ? curSum : max;
        }

//        printf("%c : cntK=%ld, curSum=%ld, serialNum=%ld, head1=%ld, max=%ld\n", curC, cntK, curSum, serialNum[dbgIndx], head1, max);

        curC = nxtC;
    }

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

    return 0;
}



Measured memory_bytes: 1024
#include <map>
#include <cstdio>
using namespace std;
void solve(int T){
	map<pair<int,int>,int> m;
	char cmd[2];
	int n,k;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(auto it=m.begin();it!=m.end();){
				if(it->second==n){
					auto it2=it++;
					m.erase(it2);
				}else{
					++it;
				}
			}
		}else if(*cmd=='R'){
			auto it=m.lower_bound(make_pair(n,2000000000));
			if(it==m.begin()){
				puts("-1");
			}else{
				--it;
				printf("%d\n",it->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int cur=0;
			scanf("%d",&k);
			for(auto it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>k)d=k;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				k-=d;
				if(k==0)break;
				cur=it->first.second+1;
			}
			if(k)m[make_pair(cur,cur+k-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

Measured memory_bytes: 1240
s1 = list(input())

b1 = s1 == s1[::-1]

s2 = s1[:(len(s1) + 1) // 2-1]

b1 = b1 & (s2 == s2[::-1])

s3 = s1[(len(s1) + 1) // 2:]

b1 = b1 & (s3 == s3[::-1])

if b1:
    print('Yes')
else:
    print('No')

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

using namespace std;

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

typedef vector<int>::const_iterator iitr;


void solve(int n,iitr beg,iitr end){
  vector<int> tmp;
  for(iitr itr=beg;itr!=end;++itr){
    tmp.push_back(*itr);
  }
  sort(tmp.begin(),tmp.end());
  int cnt0=0,cnt1=0,cnt2=0,cnt3=0,ff=0;
  for(iitr itr=tmp.begin();itr!=tmp.end();++itr){
    if(*itr == 0){cnt0++;}
    else if(*itr == 1){cnt1++;}
    else if(*itr == 2){cnt2++;}
    else if(*itr == 3){cnt3++;}
  }
  bool flag=false,flag2=false;
  if(cnt0%2==1&&cnt1==0)flag=true;
  // 0,1以外の処理
  if(cnt0+cnt1+cnt2+cnt3==n && cnt2>0 && cnt3==1){
    if(flag){
      ff = 2;
      flag2=true;
      rep(i,cnt2-2)cout << 2 << endl;
      cout << 3 << endl;
      if(cnt2>=2)cout<<2<<endl;
    } else {
      rep(i,cnt2-1)cout << 2 << endl;
      cout << 3 << endl << 2 << endl;
    }
  } else {
    if(flag){
      if(cnt0+cnt1<n){
        flag2=true;
        ff = tmp[cnt0+cnt1];
        solve(n,tmp.begin()+cnt0+cnt1+1,tmp.end());
      }
    } else {//if (cnt2==0 && cnt3==0) {
      // cout << "flag43" << endl;
      for(iitr itr=beg+cnt0+cnt1;itr!=end;++itr){
        cout << *itr << endl;
      }
    }
    // else {
    // cout << "fda" << endl;
    //   solve(n,tmp.begin()+cnt0+cnt1,tmp.end());
    // }
  }
  // 0,1の処理
  if(!flag2&&(cnt0%2==0||cnt1==0)){
    rep(i,cnt0)cout << 0 << endl;
    rep(i,cnt1)cout << 1 << endl;
  } else if (!flag2) {
    rep(i,cnt0-1)cout << 0 << endl;
    cout << 1 << endl;
    cout << 0 << endl;
    rep(i,cnt1-1)cout << 1 << endl;
  } else {
    rep(i,cnt0-1)cout << 0 << endl;
    cout << ff << endl;
    cout << 0 << endl;
  }
}

int main(){
  int n,swflag=0;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  if(n==1){
    cout << a[0] << endl;
    return 0;
  }
  sort(a.begin(),a.end());
  solve(n,a.begin(),a.end());
  
  return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_set<string> set;
    for(int i=0; i<n; i++) {
        string cmd, str;
        cin >> cmd >> str;
        if(cmd=="insert") {
            set.insert(str);
        } else if(cmd=="find") {
            auto itr = set.find(str);
            cout << (itr!=set.end() ? "yes" : "no") << endl;
        }
    }
}


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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define ld long double
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define pii pair<int,int>
#define ff first
#define ss second
// #define N (int)()

const int k = 1000000000000000000;

using namespace std;

int32_t main() {
    fast
    int t_c = 1;
//	cin >> t_c;
    while (t_c--) {
        unordered_set<int> h;
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) {
            cin >> i;
            h.insert(i);
        }
        if (h.count(0)) {
            cout << 0 << endl;
        } else {
            int ans = 1;
            for (int i = 0; i < n; i++) {
                int prev = ans;
                ans *= a[i];
                if (ans < prev or ans > k) {
                    cout << -1 << endl;
                    return 0;
                }
            }

            cout << ans << endl;
        }

    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  int ans = d.at(n/2) - d.at(n/2-1);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <complex>

using namespace std;

typedef complex<double> Point;

double dot(const Point &v1, const Point &v2) {
    return v1.real()*v2.real() + v1.imag()*v2.imag();
}

int main() {
    while(true) {
        Point ps[4];
        for(int i = 0; i < 4; ++i) 
            cin >> ps[i].real() >> ps[i].imag();
        if(cin.eof()) break;

        if(dot(ps[0]-ps[1], ps[2]-ps[3]) == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

bool isPrime(ll n){
  if(n==1)return false;
  ll route = sqrt(n);
  for(ll i = 2; i <=route; i++)if(n%i==0)return false;
  return true;
}

int main(){
  ll Q; cin>>Q;
  vector<ll> L(Q),R(Q);
  rep(i,Q)cin>>L.at(i)>>R.at(i);
  //sort(L.begin(),L.end());
  //sort(R.begin(),R.end());
  vector<bool> P(100007);
  for(ll i = 1; i <= 100000; i++)P.at(i) = isPrime(i);
  vector<ll> RES(100007,0);//RES.at(i)は1からiまでの中に含まれる2017に似た数。
  for(ll i = 2; i <=100000; i++){
    ll a,b;
    a = i;
    if(a%2==0)RES.at(i)=RES.at(i-1);
    else{
      b = (a+1)/2;
      if(P.at(a)&&P.at(b))RES.at(i)=RES.at(i-1)+1;
      else RES.at(i)=RES.at(i-1);
    }
  }

  rep(i,Q){
    cout<<RES.at(R.at(i))-RES.at(L.at(i)-1)<<endl;;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define debug_say(a, b) cout << (a) << ": " << (b) << endl;
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll K, A, B;
  cin >> K >> A >> B;
  ll now = 1;
  if(B - A <= 2){
    say(K + now);
    return 0;
  }
  if(K - ((A - now) + 1 + 1) < 0){
    say(K + now);
    return 0;
  }


  K -= ((A - now) + 1 + 1);
  now = B;
  // debug_say("K", K);
  // debug_say("now", now);
  now += ((K/2)*(B - A) + (K%2));
  say(now);
}

Measured memory_bytes: 256
import math
import collections

# 試割法
def trial_division(target):
    dest = int(math.sqrt(target))
    
    # 素因数リスト
    factor = []
    for i in range(2,dest):
        while target % i == 0:
            target //= i
            factor.append(i)

    if target != 1:
        factor.append(target)

    if not factor:
        factor.append(target)
    return factor

n = int(input())

c = collections.Counter(trial_division(n))
count = 0

for v in c.values():
    for i in range(1,n):
        v -= i
        if v >= 0:
            count += 1
        else:break
print(count)


Measured memory_bytes: 9484
N = int(input())
As = list(map(int, input().split()))

isOKs = [False] * (N+1)
isOKs[0] = True
for A in As:
    if isOKs[A-1]:
        isOKs[A] = True

for A in reversed(range(1, N+1)):
    if isOKs[A]:
        print(N-A)
        break
else:
    print(-1)


Measured memory_bytes: 32276
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}


int main() {
    LL N, K;
    cin >> N >> K;
    LL m = LLONG_MIN, g;
    REP(i, N) {
        LL a;
        cin >> a;
        m = max(m, a);
        if (i == 0) {
            g = a;
        } else {
            g = __gcd(g, a);
        }
    }
    if (K % g == 0 && K <= m) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


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

int main()
{
  ll n; cin >> n;
  ll k; cin >> k;
  ll ans = 0;
  while(n > 0) {
    n /= k;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const int  mod = 1e9 +7;

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


    int n , k ;
    cin >> n >> k;
    vector<lli> dp (k + 1);
    dp[0] = 1;
    for(int child = 1 ; child <= n ; ++child){
      int a;
      cin >> a;

    vector<lli> pref(k+1);
      for(int j = k ; j >= 0;--j){
        int tmp = dp[j];
        int L = j + 1;
        int R = j + min(a,k-j);
        if(L <= R){
          pref[L] += tmp;
          pref[L] %= mod;
          if(R + 1 <= k){
            pref[R+1] -= tmp;
            if(pref[R+1]<0 ) pref[R+1] +=mod;
            pref[R+1] %= mod;
          }
        }
      }



    int pref_sum = 0;
    for(int i = 0 ; i <= k ; ++i){
      pref_sum += pref[i];
      pref_sum %=mod;
      dp[i] += pref_sum;
      dp[i] %=mod;

    }
    // for(auto it : dp) cout << it ;cout << endl;
    // for(auto it : pref) cout << it << " " ;cout << endl;

    }
  
    cout << dp[k] << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

long long key;
int H, A[MAX];
void maxHeapify(int i)
{
    int l = 2*i, largest;
    int r = 2*i+1;
    if(l<=H && A[l]>A[i])
        largest = l;
    else
        largest = i;
    if(r<=H && A[r]>A[largest])
        largest = r;
    if(largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}
int extract()
{
    int maxv;
    if(H < 1)    return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}
void increaseKey(int i, int key)
{
    if(key < A[i])   return;
    A[i] = key;
    while(i > 1 && A[i/2]<A[i])
    {
        swap(A[i/2],A[i]);
        i = i/2;
    }
}
void insert(int key)
{
    H++;
    A[H] = -INFTY;
    increaseKey(H,key);
}
int main()
{
    char com[10];
    while(1)
    {
        cin >> com;
        if(com[0] == 'i')
        {
            cin >> key;
            insert(key);
        }
        else
        {
            if(com[2]=='d')
                break;
            else
            {
                int c = extract();
                cout << c << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007



int main() {
  int N;
  cin >> N;
  if(N<3){
  cout << 0 << endl;
    return 0;
  }
  int ans=0;
  vector<lli> L(N);
  rep(i, N){
  cin >> L[i];
  }
  rep(i, N-2){
  rep2(j,i+1,N-1){
  rep2(k, j+1, N){
  if(L[i]+L[j]>L[k]&&L[i]!=L[j]){
  if(L[j]+L[k]>L[i]&&L[i]!=L[k]){
  if(L[k]+L[i]>L[j]&&L[k]!=L[j]){
  ans++;
  }
  }
  }
  }
  }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
n = int(input())
A = list(map(int,input().split()))

four = 0
two = 0
other = 0

for a in A:
    if a%4 == 0:
        four += 1
    elif a%2 == 0:
        two += 1
    else:
        other += 1
        
if two:
    if (other+1) <= four+1:
        print("Yes")
    else:
        print("No")
else:
    if other <= four+1:
        print("Yes")
    else:
        print('No')

Measured memory_bytes: 85204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[200];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int count = 0;
  int flag = 0;
  while(1){
    for(int i=0;i<n;i++){
      if(a[i] % 2 == 0){
        a[i] /= 2;
      }else{
        flag = 1;
        break;
      }
    }
    if(flag == 0){
      count++;
    }else{
      break;
    }
  }
  cout << count;
}

    


Measured memory_bytes: 256
S = input()
if len(S)%2==1:
  print("No")
else:
  flag = 1
  for i in range(0,len(S)-1,2):
    if not(S[i]=='h' and S[i+1]=='i'):
      flag = 0
  if flag:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.printf("%d",ans.solve());
	}

	private int solve() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int MOD = 1000000007;
		sc.nextLine();
		char[][] grid = new char[H+1][W+1];
		for(int i=1;i<=H;i++){
			String line = sc.nextLine();
			for(int j=0;j<line.length();j++){
				grid[i][j+1] = line.charAt(j);
			}
		}
 		
 		int [][] dp = new int[H+1][W+1];
 		dp[H][W] = 1;

 		for(int i=H;i>=1;i--){
 			for(int j=W;j>=1;j--){
 				if (i==H && j==W) continue;
 				if (grid[i][j]=='#') continue;
 				else {
 					dp[i][j] = (((i==H) ? 0 : dp[i+1][j]) + ((j==W) ? 0 : dp[i][j+1]))%MOD;
 				}
 			}
 		}

 		return dp[1][1];

	}
}

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

int main(){
    int alice = 0, bob = 0;
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a.at(i);

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

    rep(i,n){
        int tmp = a.at(i);
        if(i % 2 == 0){ alice += tmp; }
        else{ bob += tmp; }
    }
    cout << abs(alice - bob) << endl;
}

Measured memory_bytes: 764
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N,X,Y = map(int, input().split())

edges = [[] for _ in range(N)]

for i in range(N-1):
    edges[i].append(i+1)
    edges[i+1].append(i)


edges[X-1].append(Y-1)
edges[Y-1].append(X-1)

ans = [0] * (N-1)

queue = deque([])

def bfs(start):
    queue.extend(edges[start])
    visited = [False] *  N
    visited[start] = True
    i = 0
    while queue:
        length = len(queue)
        for l in range(length):
            current = queue.popleft()
            if not visited[current]:
                ans[i] += 1
                if edges[current]:
                    queue.extend(edges[current])
                visited[current] = True    
        i += 1

for i in range(N):
    bfs(i)

for i in ans:
    print(i // 2)


Measured memory_bytes: 118492
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  vector<int> a(3),mp(3);
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<int> l(n);
  rep(i,n){ cin >> l[i]; }
  sort(l.rbegin(),l.rend());
  
  int bit4 = pow(4,n);//0a 1b 2c 3no
  int ans=inf;
  rep(i,bit4){
    vector<int> type(n);
    vector<int> cura(3,0),curmp(3,0);
    int now=i;
    rep(j,n){ type[j]=now%4; now/=4; }
    rep(j,n){
      if(type[j]==3){continue;}
      cura[type[j]] += l[j];
      curmp[type[j]]++;
    }
    bool flag=true;
    rep(j,3){
      if(curmp[j]==0){flag=false;break;}
      curmp[j] = (curmp[j]-1)*10;
      curmp[j] += abs(cura[j]-a[j]); 
    }
    if(!flag){continue;}
    int cur = curmp[0]+curmp[1]+curmp[2];
    ans = min(ans,cur);
  }
  

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


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

int main(){
    int n,m,cnt=0;
    double sum=0;
    vector <int> v;
    scanf("%d %d",&n, &m);

    for(int i=0; i<n; i++){
        int a;
        scanf("%d",&a);
        sum+=a;
        v.push_back(a);
    }
    double ans=sum/(4*m);
    for(int i=0; i<n; i++){
        if(v[i]>=ans) cnt++;
    }

    if(cnt>=m) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable : 4996)
int t, n, p[1000001]; long long s[1000002];
int main() {
	for (int i = 0; i <= 1000000; i++) p[i] = i;
	for (int i = 2; i <= 1000000; i++) {
		if (p[i] == i) {
			for (int j = i; j <= 1000000; j += i) p[j] = p[j] / i * (i - 1);
		}
	}
	for (int i = 0; i <= 1000000; i++) {
		s[i + 1] = s[i] + p[i];
	}
	scanf("%d", &t);
	for (int i = 0; i < t; i++) {
		scanf("%d", &n);
		printf("%lld\n", s[n + 1] + 1);
	}
	return 0;
}

Measured memory_bytes: 14324
from collections import deque
n = int(input())
alist = deque(map(int, input().split()))

blist = deque([])
for i in range(n) :
    bi = alist.popleft()
    if (n^i)&1 == 1 :
        blist.appendleft(bi)
    else :
        blist.append(bi)

for b in blist :
    print(b, end=" ")

Measured memory_bytes: 25540
main = do
    a <- getLine
    b <- getLine
    c <- getLine
    putChar $ game a b c 'a'
    putStrLn ""

game [] _ _ 'a' = 'A'
game (a:as) bs cs 'a' = game as bs cs a
game _ [] _ 'b' = 'B'
game as (b:bs) cs 'b' = game as bs cs b
game _ _ [] 'c' = 'C'
game as bs (c:cs) 'c' = game as bs cs c

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 int N;
 cin>>N;
 vector<int>H(N);
 for(int i=0;i<N;i++){
     cin>>H[i];
 }
 int count=0;
 for(int i=0;i<N;i++){
    bool ok=true;
    for(int j=0;j<=i;j++){
        if(H[i]<H[j]){ok=false;}
    }
    if(ok){count++;}
 }
 cout<<count<<endl;
 return 0;}

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

using namespace std;

typedef long long ll;

char a[55][55], b[55][55];
int m, n;

bool good(int x, int y){
	for(int i=0; i<m; i++)
		for(int j=0; j<m; j++){
			if(a[i+x][j+y] != b[i][j])
				return false;
		}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> a[i][j];
	for(int i=0; i<m; i++)
		for(int j=0; j<m; j++)
			cin >> b[i][j];

 	for(int i=0; i<n-m+1; i++)
		for(int j=0; j<n-m+1; j++)
			if(good(i, j)){
				cout << "Yes" << endl;
				return 0;
			}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
// Problem : B - Increment Decrement
// Contest : AtCoder - AtCoder Beginner Contest 052
// URL : https://atcoder.jp/contests/abc052/tasks/abc052_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, x = 0;
	int ans = x;
	cin >> n;
	vector<char> v(n);
	for(auto &it:v){
	    cin >> it;
	    if(it=='I')x++;
	    else x--;
	    ans = max(ans,x);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
a, b, k = gets.chomp.split.map{|c| c.to_i}

for i in (1..k) do
    if i.odd? then
        if a.odd? then
            a -= 1
        end
        move = a/2
        b += move
        a -= move
    else
        if b.odd? then
            b -= 1
        end
        move = b/2
        a += move
        b -= move
    end
end

puts(a.to_s + " " + b.to_s)


Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = sc.nextInt();
        HashSet<String> set = new HashSet<>();
        for(int i=0; i<k; i++){
            for(int j=0; j<s.length()-i; j++){
                set.add(s.substring(j, j+i+1));
            }
        }
        List<String> list = new ArrayList<>(set);
        Collections.sort(list);
        System.out.println(list.get(k-1));
    }
}

Measured memory_bytes: 26192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
            cnt++;
    }
    dunk(cnt);
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;


int inv(int a)
{
	return a==1?1:(long long)(MOD-MOD/a)*inv(MOD%a)%MOD;
}
LL C(LL n,LL m)
{
	if(m<0)return 0;
	if(n<m)return 0;
	if(m>n-m)m=n-m;
	LL up=1,down=1;
	for(LL i=0;i<m;i++)
	{
		up=up*(n-i)%MOD;
		down=down*(i+1)%MOD;
	}
	return up*inv(down)%MOD;
}

int main(){
	LL x,y;
	scanf("%lld %lld",&x,&y);
	if(y < x) swap(x,y); 
	if((2*y-x) % 3 == 0){
		LL a = (2 * y - x) / 3;
		LL b = (x - a) / 2;
		printf("%lld",C(a+b,a));
	}
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef unsigned long ulong;

static ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}

#define N 17
long data[1<<N];

static void solve(const long n, const long a, const long b, const size_t sp, const size_t ep, const long mask){
    if(n==1){
        data[sp+0] = a;
        data[sp+1] = b;
        return;
    }
    const ulong d = diff(a, b);
    const ulong nmask = mask ^ (1<<d);
    const ulong aa = nmask & a;
    const ulong ab = nmask & (a ^ (nmask&(-nmask)));
    const ulong bb = nmask & b;
    const size_t mp = (sp+ep)/2;
    //printf("%ld %ld %ld\n", aa, ab, bb);
    solve(n-1, aa, ab, sp, mp, nmask);
    solve(n-1, ab, bb, mp, ep, nmask);
    const ulong ad = a&(1<<d);
    const ulong bd = b&(1<<d);
    for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
    for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        printf("NO\n");
        return 0;
    }
    solve(n, a, b, 0, 1<<n, 0xFFFFFFFFFFFFFFFF);
    const size_t m = 1<<n;
    printf("YES\n");
    for(size_t i=0; i<m-1; i++){
        printf("%ld ", data[i]);
    }
    printf("%ld\n", data[m-1]);
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool 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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int R0,W0,C,R;
    cin >> R0 >> W0 >> C >> R;
    while(R0 != 0){
        if(C*W0-R0<=0){
            cout << 0 << endl;
        }else{
            cout << (C*W0-R0+R-1)/R << endl;
        }
        cin >> R0 >> W0 >> C >> R;
    }
    return 0;
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

struct UnionFind {
    vector<int> par;

    UnionFind(int size) : par(size, -1){}
    void init(int n){ par.assign(n, -1); }

    int find(int x){
        if(par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return 0;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return 1;
    }
    int size(int x){
        return -par[find(x)];
    }
};

int main(){
    summon_tourist;

    int N; cin >> N;
    map<int, lnt> xcnt, ycnt;
    UnionFind uf(2e5);
    REP(i, N){
        int x, y; cin >> x >> y;
        x--; y += 99999;
        uf.unite(x, y);
    }
    REP(i, 1e5){
        xcnt[uf.find(i)]++;
    }
    RANGE(i, 1e5, 2e5){
        ycnt[uf.find(i)]++;
    }
    lnt ans = 0;
    REP(i, 2e5){
        if(uf.find(i) == i){
            ans += xcnt[i]*ycnt[i];
        }
    }
    ans -= N;
    cout << ans << endl;
}


Measured memory_bytes: 25984
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long K, T;
  cin >> K >> T;
  vector<long> a(T);
  rep (i, T) cin >> a[i];
  sort(a.begin(), a.end());

  long foo = 0;
  rep (i, T-1) foo += a[i];
  foo = a[T-1] - foo - 1;
  foo = max(0l, foo);

  cout << foo << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for(int i=s;i<(int)(n);i++)
#define forn(i,n) forsn(i,0,n)

typedef long long int tint;

const tint MOD = 998244353;

int balanced;
vector<int> pos;

int memo[310][610][310];
tint f(int idx, int balance, int missingOps) {
	if (idx + 1 == (int) pos.size()) return balance == balanced;
	if (memo[idx][balance][missingOps] != -1) return memo[idx][balance][missingOps];
	
	tint res = f(idx + 1, balance, missingOps);
	if (balance > balanced) {
		forsn(j, 1, min(balance - balanced + 1, pos[idx + 1] - pos[idx])) {
			res += f(idx + 1, balance - j, missingOps);
			res %= MOD;
		}
	}
	forsn(i, 1, missingOps + 1) {
		res += f(idx + 1, balance + i, missingOps - i);
		res %= MOD;
	}
	
	memo[idx][balance][missingOps] = res;
	return res;
}

int main() {
	memset(memo, -1, sizeof(memo));
	
	string s; cin >> s;
	int k; cin >> k; 
	k = min(k, (int)s.size());
	
	balanced = s.size();
	
	pos.push_back(-1);
	int starting = 0; while (starting < (int)s.size() && s[starting] != '0') starting++;
	if (starting < (int)s.size()) pos.push_back(0);
	forsn(i, 1, s.size() - starting) if (s[starting + i] == '0') pos.push_back(i);
	if (starting < (int)s.size()) pos.push_back(s.size() - starting);
	
	cout << f(0, balanced, k) << endl;
}


Measured memory_bytes: 232628
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

//1,2,3,4,5,6,7,8,9
//2,5,5,4,5,6,3,7,6



int main(){
    int n,m; cin >> n >> m;
    vector<int> a(m);
    rep(i,m){
        cin >> a[i];
    }
    sort(all(a));
    ll table[] = {0,2,5,5,4,5,6,3,7,6};

    auto cmp = [&](const string& a, const string& b){
        if(a.size()!=b.size()) return a.size() < b.size();
        for(size_t i=0;i<a.size();i++) if(a[i]!=b[i]) return a[i]<b[i];
        return false;
    };

    vector<string> dp(n+10);
    dp[0] = "0";
    for(int i=0;i<n;i++){
        if(dp[i].size()==0) continue;
        for(auto j : a){
            int nxt = i+table[j];
            if(nxt > n) continue;

            string ns = dp[i] + (char)(j+'0');
            if(cmp(dp[nxt],ns)) dp[nxt] = ns;
        }
    }

    cout << dp[n].substr(1) << endl;
}


Measured memory_bytes: 43776
//By Lin
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <queue>

#define X first
#define Y second
#define mp make_pair
#define sqr(x) ((x) * (x))
#define Rep(i, n) for(int i = 0; i<(n); i++)
#define foreach(it, n) for(__typeof(n.begin()) it = n.begin(); it != n.end(); it++)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

#define esp 1e-8
#define N 100010
#define MOD 1000000007

int n, K, lim, ans;

void dfs(int cur, int val, int lim) {
	if (lim < (K - cur) * val) return;
	if (lim > (K - cur) * n) return;
	if (cur == K) {
		if (lim == 0) ans++;
		return;
	}
	for (int i = val; i <= n; i++) 
		dfs(cur + 1, i + 1, lim - i);
}

int main() {
	while (~scanf("%d%d%d", &n, &K, &lim)) {
		if (n == 0) break;
		ans = 0;
		dfs(0, 1, lim);
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, cnt = 1;
  cin >> a >> b;
  int ans = b - a;
  a--;
  while (ans > 0) {
    ans -= a;
    cnt++;
  }
  if (b == 1) cnt = 0;
  cout << cnt << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (i % 2 == 0 && v[i] % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<typeinfo>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;

int main(){

  int A,B,K;

  cin >> A >> B >> K;

  vector<int> v;

  for(int i = A;i < A+K;i++){
	  if(i > B){
		  break;
	  }

	  v.push_back(i);
  }

  for(int j = B;j > B - K ;j--){
	  if(j < A){
		  break;
	  }
	  v.push_back(j);
  }


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

  v.erase(unique(v.begin(),v.end()),v.end());

  for(auto it = v.begin();it != v.end();++it){
	  cout << *it << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    REP(i, h) cin >> a[i];

    ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
    queue<PII> que;
    vector<vector<ll>> dist(h, vector<ll>(w, INF));
    REP(i, h) REP(j, w) {
        if(a[i][j] == 'S') {
            dist[i][j] = 0;
            que.push({i, j});
        }
    }
    while(que.size()) {
        ll x, y;
        tie(y, x) = que.front(); que.pop();
        REP(i, 4) {
            ll ny = y + dy[i], nx = x + dx[i];
            if(nx<0 || nx>=w || ny<0 || ny>=h || a[ny][nx]=='#') continue;
            if(dist[ny][nx] == INF) {
                dist[ny][nx] = dist[y][x] + 1;
                que.push({ny, nx});
            }
        }   
    }
    dump(dist);

    auto f = [&](ll len) {
        if(len==0) return 1LL;
        return (len-1)/k + 2;
    };
    ll ans = INF;
    REP(i, h) REP(j, w) {
        if(dist[i][j] <= k) {
            chmin(ans, f(i));
            chmin(ans, f(j));
            chmin(ans, f(h-i-1));
            chmin(ans, f(w-j-1));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}


int main() {
    string s; cin >> s; int ans = 0;
    for(int i = 1;i < s.length();i++){
        if(s[i] != s[i-1]) continue;
        if(s[i] == '1'){
            s[i] = '0';
        }else{
            s[i] = '1';
        }
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3592
var
	N,M,i,u,v,cnt:Longint;
	H:Array[1..100000]of Longint;
	ok:Array[1..100000]of Boolean;
begin
	read(N,M);
	for i:=1 to N do read(H[i]);
	for i:=1 to M do begin
		read(u,v);
		if H[u]>=H[v]then ok[v]:=True;
		if H[v]>=H[u]then ok[u]:=True;
	end;
	for i:=1 to N do if not ok[i]then inc(cnt);
	writeln(cnt);
end.


Measured memory_bytes: 1372
#include <iostream>
#include <string>

using namespace std;

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

    int C[N-1], S[N-1], F[N-1];
    for (int i = 0; i < N - 1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    int ans[N];
    for (int i = 0; i < N; i++){
        ans[i] = 0;
    }


    for (int i = 0; i < N - 1; i++){
        int time = S[i];
        for (int j = i; j < N - 1; j++){
            if (time <= S[j]){
                time = S[j] + C[j];
            }else{
                if (time % F[j] == 0){
                    time += C[j];
                }else{
                    time += C[j] + F[j] - (time % F[j]) ;
                }
            }
        }
        ans[i] = time;
    }
    
    
    for (int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }
    
    
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


int main()
{
  int N,v[100001],M1=0,M1i=0,M2=0,M2i=0;
  vector<int> num1(100001,0),num2(100001,0);
  cin >> N;
  REP(i,N)cin >> v[i];
  priority_queue<int> n1,n2;
  REP(i,N){
    if(i%2==0){
      num1[v[i]]++;
    }else{
      num2[v[i]]++;
    }
  }
  REP(i,100001){
    if(M1 < num1[i]){
      M1 = num1[i];
      M1i = i;
    }
    n1.push(num1[i]);
  }
  REP(i,100001){
    if(M2 < num2[i]){
      M2 = num2[i];
      M2i = i;
    }
    n2.push(num2[i]);
  }
  if(M2i == M1i){
    n1.pop();n2.pop();
    cout << (N-(M1+M2+max(n2.top()-M2,n1.top()-M1))) << endl;
  }else{
    cout << (((N/2) - *max_element(num1.begin(),num1.end())) + (N/2) - *max_element(num2.begin(),num2.end())) << endl;
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 2552
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    
    int a[200000];
    for(int i=0; i<n; ++i){
        scanf("%d", &a[i]);
    }
    
    int b[n];
    int c = n/2;
    int d = n/2;
    if(n%2 == 0){
        for(int i=0; i<n; ++i){
            if(i%2 == 0){
                b[c] = a[i];
                c++;
            }else{
                d--;
                b[d] = a[i];
            }
        }
    }else{
        for(int i=0; i<n; ++i){
            if(i%2 == 0){
                b[c] = a[i];
                c--;
            }else{
                d++;
                b[d] = a[i];
            }
        }
    }
    
    for(int i=0; i<n; ++i){
        printf("%d ",b[i]);
        }
    
    return 0;
}


Measured memory_bytes: 3712