akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string S; cin >> S;
  if(S=="RRR")cout << 3 << endl;
  else if(S.substr(0,2)=="RR"||S.substr(1,2)=="RR") cout << 2 << endl;
  else if(S=="SSS") cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;
    const ld eps = 1e-9;



void solve(){
    int n , ans = 0 , x;
    cin >> n;
    for(int i = 1; i <= n; ++ i){
        cin >> x;
        if(x & 1 && i & 1){
            ++ ans;
        }
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3636
#include <stdio.h>

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

int main(void){
	int k, s;
	int count = 0;
	scanf("%d %d", &k, &s);
	for(int x = max(s - 2 * k, 0); x <= k; x++){
		count += max(min(s - x, k) - max(s - x - k, 0) + 1, 0);
		//printf("%d\n", max(min(s - x, k) - max(s - x - k, 0) +1, 0));
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = [int(v) for v in input().split()]


total = sum(A)

half = total / 2

v1 = 0
v2 = total
min_d = None

for i in range(N):
    v1 += A[i]
    v2 = total - v1

    d = abs(v2 - v1)

    if min_d is None:
        min_d = d
    elif min_d > d:
        min_d = d

print(min_d)


Measured memory_bytes: 26396
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n){
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(k > 0){
            k--;
        }
        else{
            ans += h[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(20000000)

def dfs(num):
    global visited, edge, has_edge
    for next_num in edge[num]:
        if visited[next_num]:
            continue
        if has_edge[num][next_num]:
            visited[next_num] = 1
            dfs(next_num)


n, m = map(int, input().split())
edge = [[] for _ in range(n+1)]
has_edge = [[0 for _ in range(n+1)] for _ in range(n+1)]
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append([a, b])
    edge[a].append(b)
    edge[b].append(a)
    has_edge[a][b] = 1
    has_edge[b][a] = 1

count = 0
for a, b in ab:
    visited = [0 for _ in range(n+1)]
    visited[1] = 1
    has_edge[a][b] = 0
    has_edge[b][a] = 0
    dfs(1)
    if sum(visited) != n:
        count += 1
    has_edge[a][b] = 1
    has_edge[b][a] = 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int n ;
 cin >> n;
 vector<VI> a(2,VI(n));
  rep(i,2){
    rep(j,n){
      cin >> a.at(i).at(j);
    }
  }
  VI sum(n);
  rep(i,n){
    rep(j,i+1){
      sum.at(i)+=a.at(0).at(j);
    }
    for(int k=i;k<n;k++){
      sum.at(i)+=a.at(1).at(k);
    }
  }
  int mx=0;
  rep(i,n){
    mx=max(mx,sum.at(i));
  }
  cout << mx << endl;
   
  
     
}

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

const int M = 1000000005;
const int Max = 100005;
struct Card
{
    char c;
    int n;
};
Card A[Max], S[Max];
Card a[Max/2], b[Max/2];

void Merge(Card S[], int left, int right, int mid)//归并（归并时比较排序）
{
    int n1 = mid-left, n2 = right-mid;//以mid为界限，分割为两个数组
    for(int i=0; i<n1; i++)
    {
        a[i] = S[i+left];
        //Count++;
    }
    for(int i=0; i<n2; i++)
    {
        b[i] = S[i+mid];
        //Count++;
    }
    a[n1].n = M, b[n2].n = M;//确保最后一个数较大，利于以下排序（M超出了S中元素的范围）
    int k=left, ka=0, kb=0;
    //Count++;
    while(k<right)
    {
        if(a[ka].n>b[kb].n)//升序排列
        {
            S[k++] = b[kb++];
        }
        else
        {
            S[k++] = a[ka++];
        }
        //Count++;//计数
    }
}

void MergeSort(Card S[], int left, int right)//用于分割数组，分别排序（分治）
{
    if(left+1<right)//判断是否可以分割
    {
        int mid = (left+right)/2;
        MergeSort(S, left, mid);
        MergeSort(S, mid, right);
        Merge(S, left, right, mid);//归并
    }
}

void swap(Card *x, Card *y)
{
    Card temp = *x;
    *x = *y;
    *y = temp;
}
int Partition(Card A[], int p, int r)
{
    Card x = A[r], t;
    //cout << x.n << endl;
    int i=p-1;
    for(int j=p; j<r; j++)
    {
        if(A[j].n<=x.n)
        {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
            //swap(A[i], A[j]);
        }
    }
    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
   // swap(A[i+1], A[r]);
    return i+1;
}

void quickSort(Card A[], int p, int r)
{
    if(p<r)
    {
        int q = Partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

int main()
{
    int n, flag = 1;
    char C[5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%s %d", C, &A[i].n);
        A[i].c = C[0];
        S[i].n = A[i].n;
        S[i].c = C[0];
    }
    quickSort(A, 0, n-1);
    MergeSort(S, 0, n);
    for(int i=0; i<n; i++)
    {
        if(S[i].c!=A[i].c)
        {
            flag = 0;
            break;
        }
    }
    if(flag) printf("Stable\n");
    else     printf("Not stable\n");
    for(int i=0; i<n; i++)
    {
        printf("%c %d\n", A[i].c, A[i].n);
    }
    return 0;
}



Measured memory_bytes: 5456
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才すぎないすか

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint();
	ll kazu[20] = {};
	const int mod = 1e9 + 7;
	const ll m = 1 + (1 << 20) + (1ll << 40);
	//なんではやいのかな？ブロック化的な奴なの？
	rep(i, N / 2) {
		ll a = getint();
		ll b = getint();
		rep(j, 20) {
			kazu[j] += a >> j & m;
			kazu[j] += b >> j & m;
		}
	}
	rep(i, N % 2) {
		ll a = getint();
		rep(j, 20) kazu[j] += a >> j & m;
	}

	ll kotae = 0;
	const ll m2 = (1 << 20) - 1;
	rep(j, 20) {
		ll tmp = (1ll << j) % mod;
		ll tmpk = (kazu[j] & m2);
		tmpk = tmpk * (N - tmpk) % mod;
		kotae += tmp * tmpk % mod;

		tmp = (1ll << (j + 20)) % mod;
		tmpk = (kazu[j] >> 20 & m2);
		tmpk = tmpk * (N - tmpk) % mod;
		kotae += tmp * tmpk % mod;

		tmp = (1ll << (j + 40)) % mod;
		tmpk = (kazu[j] >> 40 & m2);
		tmpk = tmpk * (N - tmpk) % mod;
		kotae += tmp * tmpk % mod;
	}

	printf("%lld", kotae% mod);

	Would you please return 0;
}

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

const int SIZE = 300 * 300 + 10;

int a2r[SIZE], a2c[SIZE];
int cumsum[SIZE];

int main() {
    int H, W, D;
    cin >> H >> W >> D;

    for (int r = 0; r < H; r++) {
        for (int c = 0; c < W; c++) {
            int A;
            cin >> A;

            a2r[A] = r;
            a2c[A] = c;
        }
    }

    for (int i = D + 1; i <= H * W; i++) {
        cumsum[i] += cumsum[i - D];
        cumsum[i] += abs(a2r[i] - a2r[i - D]) + abs(a2c[i] - a2c[i - D]);
    }

    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        cout << cumsum[R] - cumsum[L] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(void){
  long long int x, y;
  long long int t[1000000]={};
  int cnt=0;
  int j=0;

  cin >> x >> y;
  while(1){
    if(x<=y){
      cnt++;
      x*=2;
    }else{
      break;
    }
  }


  cout << cnt << endl;
return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
ll mpow(ll a, ll b) { ll r = 1; a %= mod; while (b) { r = r * ((b % 2) ? a : 1) % mod, a = a * a % mod, b >>= 1; }return r; }



int main() {
	ll x, y; cin >> x >> y;
	if (x % y)printf("%lld", x);
	else printf("-1");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  double n, k;
  cin >> n;
  cin >> k;

  /*
  double ans = 0;
  double iter;
  double tmp;

  for (int i = 1; i <= n; i++){
    iter = 0;
    if (i < k){
      tmp = i;
      while(true) {
        tmp = tmp * 2;
        if (tmp >= k){
          iter +=1;
          break;
        }
        else{
          iter +=1;
          continue;
        }
      };
      ans = ans + (1/n) * pow(0.5, iter);
    }
    else{
      ans = ans + (1/n) * (1/2);
    }

  }
  cout << ans << endl;
  */

  double p = 1 / n;
  double score, add, ans;
  ans = 0;

  for (int i = 1; i <= n; i++){
    score = i;
    add = p;
    while (score < k){
      score *= 2;
      add /= 2.0;
    };
    ans += add;
  }

  // cout << ans << endl;
  printf("%.12f\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  ll N, A, B, W, H, C, D;
  string s, t;
  cin >> A >> B >> C;
  vector<int> abc;
  abc.push_back(A);
  abc.push_back(B);
  abc.push_back(C);
  sort(ALL(abc));
  int ans = 0;
  ans += abc[2] -abc[1];
  int sabun = abc[1] -abc[0];
  if (sabun%2 == 0) ans += sabun/2;
  else ans += (sabun/2)+2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    int count = 0;
    while(A > 0 && C > 0) {
        if(count % 2 == 1) {
            A -= D;
        }else {
            C -= B;
        }
        ++count;
    }
    cout << ((count % 2 == 1) ? "Yes" : "No") << endl;
}


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

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  } else if(r < 2800){
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL a, b, c, d;
	cin >> a >> b >> c >> d;

	vector<LL> v;
	v.push_back(a*c);
	v.push_back(a*d);
	v.push_back(b*c);
	v.push_back(b*d);
	sort(v.begin(), v.end());
	printf("%lld\n", v[v.size()-1]);
	return 0;

}



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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll d = k - a;
  if(d < 0) {
    cout << a - k << " " << b << endl;
    return 0;
  } 
  else{
    if (d == 0) {
      cout << d << " " << b << endl;
    }else{
      ll e = b - d;
      if (e >= 0) cout << 0 << " " << e << endl;
      else cout << 0 << " " << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int add = a - b;
  if(add >= 0){
    cout << "delicious" << endl;
  }else{
    add *= -1;
    if(x < add){
      cout << "dangerous" << endl;
    }else{
      cout << "safe" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,a,b,c,l1,l2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if((a^i)&1){printf("No\n");return 0;}
		if(a>i||(l1&&!((l1^a)&1))){if(!l1)l1=a;else if(a<l2){printf("No\n");return 0;}else if(a<l1)l2=a;else l1=a;}
		if(i&1){if(b<a)b=a;}else if(c<a)c=a;
		if(b>i&&c>i){printf("No\n");return 0;}
		if(b<=i&&c<=i)l1=l2=0;
	}
	printf("Yes\n");
}//

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int keisan(int S,vector<long long int> &memo){
    if(memo[S] != -1){
        return memo[S];
    }
    if(S < 3){
        memo[S] = 0;
        return 0;
    }
    if (S < 6){
        memo[S] = 1;
        return 1;
    }
    memo[S] = (keisan(S - 1,memo) + keisan(S - 3,memo)) % 1000000007;
    return memo[S];
}
int main(){
    int S,i,ans = 0;
    cin >> S;
    vector<long long int> memo(S + 1,-1);
    cout << (keisan(S,memo)) % 1000000007 << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main() {
	int i = {};
	string S = "";

	cin >> S;
	if (S == "RRR") {
		cout << "3" << endl;
		return 0;

	}
	if (S == "RRS") {
		cout << "2" << endl;
		return 0;

	}
	if (S == "SRR") {
		cout << "2" << endl;
		return 0;
	}
	if (S == "RSS") {
		cout << "1" << endl;
		return 0;
	}
	if (S == "SRS") {
		cout << "1" << endl;
		return 0;
	}
	if (S == "SSR") {
		cout << "1" << endl;
		return 0;
	}

	if (S == "RSR") {
		cout << "1" << endl;
		return 0;
	}

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


Measured memory_bytes: 3600
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function heap(a::Array{Int,1})
	h = [a[1]]
	for i in 2:length(a)
		hpush(h,a[i])
	end
	h
end

function hpush(h::Array{Int,1},x)
	push!(h,x)
	l = length(h)
	if l>1
		k = l>>1
		while h[k]>x&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(k>>1,1)
			l = l>>1
		end
	end
end

function hpop(h::Array{Int,1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if h[2*k]>=z
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k]>=z&&h[2*k+1]>=z
					break
				else
					t = h[2*k]<h[2*k+1]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

function main()
	x,y,a,b,c = readline() |> split |> parseMap
	p = readline() |> split |> parseMap
	q = readline() |> split |> parseMap
	r = readline() |> split |> parseMap
	p = sort(p,rev=true)
	q = sort(q,rev=true)
	hp = Int[]
	hq = Int[]
	for i in 1:x
		hpush(hp,p[i])
	end
	for i in 1:y
		hpush(hq,q[i])
	end
	for i in 1:c
		if hq[1]<=hp[1]
			if hq[1]<r[i]
				hpop(hq)
				hpush(hq,r[i])
			elseif hp[1]<r[i]
				hpop(hp)
				hpush(hp,r[i])
			end
		else
			if hp[1]<r[i]
				hpop(hp)
				hpush(hp,r[i])
			elseif hq[1]<r[i]
				hpop(hq)
				hpush(hq,r[i])
			end
		end
	end
	println(sum(hp)+sum(hq))
end

main()

Measured memory_bytes: 173308
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll X;
    cin >> X;
    ll year = 0;
    ll mon = 100;
    for(int i = 0;; i++){
        mon += mon / 100;
        year++;
        if(mon >= X){
            cout << year <<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
// AOJ 0396: Treasure Map
// 2018.3.20 bal4u

#include <stdio.h>
#include <stdlib.h>

// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// 優先度付きキュー（最大値）
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)
#define QSIZE 1005
int que[2][QSIZE + 5];
int qsize[2];

void max_heapify(int id, int i)
{
	int l, r, max;
	int qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize[id] && que[id][l] > que[id][i]) max = l; else max = i;
	if (r < qsize[id] && que[id][r] > que[id][max]) max = r;
	if (max != i) {
		qt = que[id][i], que[id][i] = que[id][max], que[id][max] = qt;
		max_heapify(id, max);
	}
}

void deq(int id)
{
	que[id][0] = que[id][--qsize[id]];
	max_heapify(id, 0);
}

void enq(int id, int c)
{
	int i, max;
	int qt;

	i = qsize[id]++;
	que[id][i] = c;
	while (i > 0 && que[id][max = PARENT(i)] < que[id][i]) {
		qt = que[id][i]; que[id][i] = que[id][max], que[id][max] = qt;
		i = max;
	}
}


// 本問題関連
int W, H;
int a[1005], b[1005];

int cmp(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int main()
{
	int i, j, t, id, sa, sb;

	W = in(), H = in(), sa = sb = 0;
	for (i = 0; i < W; i++) a[i] = in(), sa += a[i];
	for (j = 0; j < H; j++) b[j] = in(), sb += b[j];
	if (sa != sb) goto No;
	qsort(a, W, sizeof(int), cmp);
	qsort(b, H, sizeof(int), cmp);
	if (W == H && a[0] == a[W - 1] && b[0] == b[H - 1]) goto Yes;
	qsize[0] = qsize[1] = 0;
	for (j = 0; b[j]; j++) enq(0, b[j]);
	for (id = i = 0; t = a[i]; i++, id = !id) {
		while (t > 0 && qsize[id] > 0) {
			j = que[id][0], deq(id), t--;
			if (j > 1) enq(!id, j - 1);
		}
		if (t > 0) goto No;
		while (qsize[id]) j = que[id][0], deq(id), enq(!id, j);
	}
Yes:puts("1");
	return 0;
No: puts("0");
	return 0;
}



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

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

Measured memory_bytes: 256
n = gets.to_i
xys = []
n.times do
  xys << gets.strip.split.map(&:to_i)
end

sum_distance = 0

xys.permutation(n) do |xy_root|
  0.upto(n-2) do |i|
    sum_distance += Math.sqrt((xy_root[i][0] - xy_root[i+1][0]) ** 2 + (xy_root[i][1] - xy_root[i+1][1]) ** 2)
  end
end
ans = sum_distance / xys.permutation(n).size
puts printf("%.10f", ans)

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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define     inf             2e18
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(int i = a ; i < b ; i++)
#define     repn(i, a, b)   for(int i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     pii              pair<int, int>
#define     pll             pair<long long int, long long int>
#define     vll             vector<long long int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


/*############################# DSU ##############################*/
vi parent(1e5), Size(1e5), Rank(1e5);

void make_set(int v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(int v){
	return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
		parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

unsigned int logn(unsigned int n, unsigned int r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

ll pw2[32];
void cal(){ pw2[0] = 1; rep(i, 1, 32)pw2[i] = 2*pw2[i-1]; }

/* ################################################################ */

void solve()
{
    ll a, b, c, k; cin>>a>>b>>c>>k;
    ll sum = 0;
    if(k>0){
        sum += min(a, k);
        k -= a;
    }
    if(k>0){
        sum += min(b, k)*0;
        k -= b;
    }
    if(k>0){
        sum += min(c, k)*(-1);
        k -= c;
    }
    cout<<sum<<nl;
}


int main()
{
    // boost;
    cal();
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
    return 0;
}

Measured memory_bytes: 4132
// 2014/06/03 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	while(true){
		char s[10001];
		cin >> s;

		if(cin.eof())
			break;

		int cnt = 0;
		char* p = s;
		while(true){
			p = strstr(p, "JOI");

			if(p==0)
				break;

			cnt++;
			p++;
		}
		cout << cnt << '\n';

		cnt = 0;
		p = s;
		while(true){
			p = strstr(p, "IOI");

			if(p==0)
				break;

			cnt++;
			p++;
		}
		cout << cnt << '\n';
	}

	return 0;
}

Measured memory_bytes: 1156
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M, X = map(int, readline().split())
    A = list(map(int, readline().split()))

    a = 0
    b = 0

    for x in A:
        if x <= X:
            a += 1
        if X <= x:
            b += 1

    print(min(a, b))


if __name__ == '__main__':
    main()


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

int main(){
  string s,t,u;
  cin >> s >> t;
  int a,b;
  cin >> a >> b >> u;
  if(u==s)cout << a-1 << " " << b;
  else cout << a << " " << b-1;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char S[200010], T[200010];
    scanf("%s %s", S, T);
    int i = 0, ans = 0;
    while(S[i] != '\0'){
        if(S[i] != T[i]) ans++;
        ++i;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1005,mod=1000000007;
int n,m;ll k;
char s[N][N],t[N][N]; 
struct mat
{
	ll a[3][3];
	mat(){memset(a,0,sizeof(a));}
	mat operator*(const mat&b)const
	{
		mat c;
		for(int i=1;i<=2;i++)for(int j=1;j<=2;j++)for(int k=1;k<=2;k++)c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j])%mod;
		return c;
	}
}A;
mat pw(mat a,ll b)
{
	mat r;r.a[1][1]=r.a[2][2]=1;
	for(;b;b>>=1,a=a*a)if(b&1)r=r*a;
	return r;
}
int pw(int a,ll b){int r=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)r=1ll*r*a%mod;return r;}
bool chk(){for(int i=1;i<=n;i++)if(s[i][1]=='#'&&s[i][m]=='#')return 1;return 0;}
void trn()
{
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)t[m-j+1][i]=s[i][j];
	swap(n,m);for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)s[i][j]=t[i][j];
}
int main()
{
	scanf("%d%d%lld",&n,&m,&k);
	int x=0,y=0,z=0;
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)x+=s[i][j]=='#';
	int a=chk();trn();
	int b=chk();trn();
	if(a&&b){puts("1");return 0;}
	else if(!a&&!b){printf("%d\n",pw(x,k-1));return 0;}
	else if(b)trn();
	for(int i=1;i<=n;i++)for(int j=1;j<m;j++)y+=s[i][j]=='#'&&s[i][j+1]=='#';
	for(int i=1;i<=n;i++)z+=s[i][1]=='#'&&s[i][m]=='#';
	A.a[1][1]=x;A.a[1][2]=y;
	A.a[2][1]=0;A.a[2][2]=z;
	A=pw(A,k-1);
	printf("%lld\n",(A.a[1][1]-A.a[1][2]+mod)%mod);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],dp[100005];
int solve(int idx){
    if(idx >= n - 1)
        return 0;
    int &ans = dp[idx];
    if(ans != -1)
        return ans;
    ans = 1e9;
    if(idx + 1 < n)
        ans = min(ans, abs(a[idx] - a[idx + 1]) + solve(idx + 1));
    if(idx + 2 < n)
        ans = min(ans, abs(a[idx] - a[idx + 2]) + solve(idx + 2));
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    memset(dp , -1, sizeof dp);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
void coutno(){
	puts("-1");exit(0);
}
int n;
typedef long long ll;
map <ll,int> mp;
vector<pair<ll,int> > v;
vector<pair<int,int> > res;
ll dp[100004];
int sz[100004]; 
int main(){
	for (int i=0;i<100004;i++) sz[i]=1;
	cin>>n;
	for (int i=1;i<=n;i++){
		ll x;cin>>x;
		mp[x]=i;v.push_back(make_pair(x,i));
	}
	sort (v.rbegin(),v.rend());
	ll x=v.back().first;
	for (int i=0;i<v.size();i++){
		if (v[i].first!=x){
			pair<ll,int> q=v[i];
			if (sz[q.second]*2>=n) coutno();
			ll need=q.first-(n-2*sz[q.second]);
			if (!mp.count(need)) coutno();
			int par=mp[need];
			dp[par]+=dp[q.second]+sz[q.second]; 
			sz[par]+=sz[q.second]; 
			res.push_back(make_pair(q.second,par)); 
		}
	}
	if (dp[v.back().second]!=x)coutno();
	for (int i=0;i<n-1;i++)
		cout<<res[i].first<<" "<<res[i].second<<"\n";
}

Measured memory_bytes: 12144
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, m;

int main()
{
	scanf("%d%d", &n, &m);
	
	if (n % 2 != 0) {
		int l = 1;
		int r = n;
		
		for (int i = 0 ; i < m ; i++) {
			printf("%d %d\n", l, r);
			l++;
			r--;
		}
	} else {
		int l = n / 2;
		int r = n / 2 + 1;
		std::set<int> numSet;
		
		for (int i = 0 ; i < m ; i++) {
			int diff = r - l;
			int rDiff = n - diff;
			if (diff == rDiff) {
				r++;
			} else {
				if ((numSet.find(diff) != numSet.end()) || (numSet.find(rDiff) != numSet.end())) {
					r++;
				}
			}
			diff = r - l;
			rDiff = n - diff;
			numSet.insert(diff);
			numSet.insert(rDiff);

			printf("%d %d\n", l, r);
			l--;
			r++;
		}
	}

	return 0;
}


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

int main(){
  int a,b,c,d;
    cin>>a;
  cin >>b;
  cin >>c;
  cin>>d;
  int e =0;
    for(int i=0;i<=a;i++){
      for(int j =0;j<=b;j++){
        for(int k =0; k <=c;k++){
      if(d == 500*i+100*j+50*k){
         e++;
      }
        }
      }
    }
  
    cout << e << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXD=105;
const int MAXA=1005;
const int MAXB=10005;
const int MAXC=1000005;
const int Maxx=0x7fffffff/2;
const int Minn=-0x7fffffff/2;
const int Maxn=0x3f3f3f3f;
const int Minm=-0x3f3f3f3f;
inline void read(int &oi){
	char ch;int f=1,res=0;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?f=-1:res=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')res=(res<<1)+(res<<3)+ch-'0';
	oi=res*f;
}
int maxxx(int x,int y){return x>y?x:y;}
int minnn(int x,int y){return x<y?x:y;}
int n;
int main(){
	read(n);
	while(n){
		if(n%10==7){
			puts("Yes");
			return 0;
		}
		n/=10;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <cassert>


using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string ans = "";
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; i++) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  long long n, k;
  cin >> n >> k;
  if((k&1)==1){
    cout << (n/k)*(n/k)*(n/k) << endl;
  }
  else{
    long long ans = 0;
    ans += (n/k)*(n/k)*(n/k);
    long long  tmp = (n/(k/2)) - (n/k);
    ans += tmp*tmp*tmp;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main () {

	int n;
  	std::cin >> n;
  
  	std::vector<std::pair<int, int>> ppl;
  
  	for(int i=0; i<n;++i) {
      int j;
      std::cin >> j;
      ppl.emplace_back(i, j);
    }
  
  	std::sort(ppl.begin(), ppl.end() ,[](auto lhs, auto rhs){
    return lhs.second < rhs.second; } );
  
  	for(auto&& p : ppl) {
      std::cout << p.first + 1 << " ";
    }
}

Measured memory_bytes: 1780
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

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

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> rev(n + 1);
    rep(i, n){
        int p;
        cin >> p;
        rev[p] = i;
    }

    multiset<int> st;
    st.insert(rev[n]);
    st.insert(-1);
    st.insert(-1);
    st.insert(n);
    st.insert(n);
    lint ans = 0;
    rreps(i, n - 1){
        auto it1 = st.lower_bound(rev[i]);
        auto it2 = it1;
        auto it3 = it1;
        auto it4 = it1;

        if(it1 != st.begin()){
            --it1;
            --it2;
            if(it1 != st.begin()){
                --it1;
            }
        }

        if(it4 != st.end()){
            ++it4;
        }

        if(it1 == it2 && it2 == it3){
            ans += (lint)i * (rev[i] + 1LL) * (*it4 - *it3);
        }else if(it1 == it2){
            ans += (lint)i * (*it1 + 1LL) * (*it3 - rev[i]);
            ans += (lint)i * (rev[i] - *it1) * (*it4 - *it3);
        }else if(it2 == it3 && it3 == it4){
            ans += (lint)i * (n - rev[i]) * (*it2 - *it1);
        }else if(it3 == it4){
            ans += (lint)i * (n - *it4) * (rev[i] - *it2);
            ans += (lint)i * (*it4 - rev[i]) * (*it2 - *it1);
        }else{
            ans += (lint)i * (rev[i] - *it2) * (*it4 - *it3);
            ans += (lint)i * (*it3 - rev[i]) * (*it2 - *it1);
        }

        st.insert(rev[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ull = unsigned long long;
using P = pair<int,int>;

const int N_MAX = 500;
int n;
vector<int> c[2];
int v [2][N_MAX];

int res[N_MAX][N_MAX];
void flip(){ rep(i,n)rep(j,i) swap(res[i][j],res[j][i]); }
bool func(){
  rep(i,n)rep(j,n) res[i][j] = -1;
  
  rep(x,2){
    rep(i,n){
      int d = v[x][i];
      if(c[x][i] == d) continue;

      rep(j,n){
        if(res[i][j] == !d) return false;
        res[i][j] = d;
      }
    }
    flip();
  }
  
  rep(xx,2)rep(x,2){
    rep(i,n){
      int d = v[x][i];
      if(c[x][i] != d)continue;

      vector<int> js; bool find = false;
      rep(j,n) {
        if(res[i][j]==-1) js.push_back(j);
        if(res[i][j]==d) find = true;
      }
      if(find) continue;
      if(js.size()==0) return false;
      if(js.size()==1) res[i][js[0]] = d;
    }
    flip();
  }
  vector<int> is, js;
  rep(i,n) {
    bool filled = true;
    rep(j,n) if (res[i][j] == -1) filled = false;
    if (!filled) is.push_back(i);
  }
  rep(j,n) {
    bool filled = true;
    rep(i,n) if (res[i][j] == -1) filled = false;
    if (!filled) js.push_back(j);
  }
  rep(i,is.size())rep(j,js.size()) {
    res[is[i]][js[j]] = (i+j)%2;
  }
  return true;
}

ull ans[N_MAX][N_MAX];
int main() {
  cin >> n;
  vector<ull> vs[2];
  rep(i,2) {
    c[i] = vector<int>(n);
    rep(j,n) cin >> c[i][j];
  }
  rep(i,2) {
    vs[i] = vector<ull>(n);
    rep(j,n) cin >> vs[i][j];
  }

  rep(b,64){
    rep(x,2)rep(i,n) v[x][i] = vs[x][i]>>b&1;
    if(!func()){
      cout << -1 << endl;
      return 0;
    }
    rep(i,n)rep(j,n) ans[i][j] |= ull(res[i][j])<<b;
  }
  rep(i,n){
    rep(j,n) cout << ans[i][j] << " ";
    cout << endl;
  }
}


Measured memory_bytes: 8396
#include <stdio.h>

int
main(void)
{
	int A, B;
	scanf("%d %d", &A, &B);

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
		puts("Possible");
	else
		puts("Impossible");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,l;
  cin>>n>>l;int s=50000;int a,d;
  int sum=(n*l)+(n*n-n)/2;
  for(int i=1;i<n+1;i++)
  {
    d=abs(sum-(sum-(l+i-1)));
    if(d<s)
    { s=d;a=i;}
  }cout<<sum-(l+a-1);
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
using namespace std;

int h,w,c;
int ans;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool canmove(int x,int y){
  return (0 <= x && x < w && 0 <= y && y < h);
}

void copy(int from[8][8],int to[8][8]){
  FOR(i,0,h) FOR(j,0,w) to[i][j]=from[i][j];
}

int count(int table[8][8]){
  int cnt=0;
  int color[8][8]={{0}};
  queue<pair<int,int> > q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    pair<int,int> pii=q.front();
    q.pop();
    if(color[pii.second][pii.first]) continue;
    color[pii.second][pii.first]=1;
    cnt++;
    FOR(i,0,4){
      if(canmove(pii.first+dx[i],pii.second+dy[i]) && table[0][0]==table[pii.second+dy[i]][pii.first+dx[i]]){
	q.push(make_pair(pii.first+dx[i],pii.second+dy[i]));
      }
    }
  }
  return cnt;
}

void dfs(int table[8][8],int cnt){
  if(cnt > 5) return;
  if(cnt == 5 && table[0][0]==c){
    ans=max(ans,count(table));
    return;
  }
  for(int i=1;i<=6;i++){
    int t[8][8];
    int color[8][8]={{0}};
    copy(table,t);
    queue<pair<int,int> > q;
    q.push(make_pair(0,0));
    while(!q.empty()){
      pair<int,int> pii=q.front();
      q.pop();
      if(color[pii.second][pii.first]) continue;
      color[pii.second][pii.first]=1;
      t[pii.second][pii.first]=i;
      FOR(k,0,4){
	if(canmove(pii.first+dx[k],pii.second+dy[k]) && table[0][0]==t[pii.second+dy[k]][pii.first+dx[k]]){
	  q.push(make_pair(pii.first+dx[k],pii.second+dy[k]));
	}
      }
    }
    dfs(t,cnt+1);
  }
}

int main(){
  while(cin>>h>>w>>c , h+w+c){
    int table[8][8];
    FOR(i,0,h) FOR(j,0,w) cin>>table[i][j];
    ans=0;
    dfs(table,0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int n;
    while (cin >> n, n) {
        vector<string> w(n);
        REP (i, n) cin >> w[i];
        vector<int> v = {5, 7, 5, 7, 7};
        REP (i, n) {
            int sum = 0, idx = 0;
            FOR (j, i, n) {
                if (sum + w[j].size() > v[idx]) {
                    idx = -1;
                    break;
                }
                sum += w[j].size();
                if (sum == v[idx]) {
                    sum = 0;
                    idx++;
                }
                if (idx == v.size()) break;
            }
            if (idx < 0) continue;
            cout << i + 1 << endl;
            break;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
int main(){
  char c[1000];
  int n,sum=0,i,size;

  while(1){
      scanf("%s",c);
      size = strlen(c);
      if(size == 1 && c[0] == '0') break;
      for(i=0;i<size;i++){
        n = c[i] - '0';
        sum += n;
      }
      printf("%d\n",sum);
      sum = 0;
  }
  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

ll gcd(ll a, ll b){
    if (a%b) return gcd(b,a%b);
    else return b;
}

int main() {
    ll k;
    cin >> k;
    ll sum = 0;
    rep(l,k){
        rep(m,k){
            rep(n,k){
                sum += gcd( gcd( l+1 , m+1 ) , n+1 );

            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  // ここにプログラムを追記
  int a, b, x;
  cin >> a >> b;
  x = a * b;
  if(x % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
bool isDistinct(vector<int> &A) {
    set<int> S;
    for (int a : A) {
        S.insert(a);
    }

    if (S.size() == A.size()) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A.at(i));
    }

    cout << (isDistinct(A) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    printf("%.7f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}

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



Measured memory_bytes: 3288
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
const ll MOD = 1000000007;
using namespace std;

int main(void)
{
    ll n;
    cin >> n;
    map<ll, ll> v;
    vector<ll> x;
    rep(i, 0, n)
    {
        ll tmp;
        cin >> tmp;
        x.push_back(tmp);
        v[tmp]++;
    }
    ll ans = 0;
    for (auto i : v)
    {
        if (i.second != 0)
            ans += (i.second) * (i.second - 1) / 2;
    }
    rep(i, 0, n)
    {
        if (v[x[i]] > 0)
            cout << ans - v[x[i]] + 1 << endl;
        else
            cout << ans << endl;
    }
}


Measured memory_bytes: 12840
#include<cstdio>

int main() {
    int a,b,c,d,e;
    d = 0, e = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = 1; i <= c; i++){
        if(c % i == 0 && i >= a){
            for(int d = a; d <= b; d++){
                if(d % i == 0){
                    e = e + 1;
                    break;
                }
            }
        }
    }
    printf("%d\n",e);
return 0;
}


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

int main(){
    int a,b,i,j,k;
    int s[] = {1,2,3};
    int f[] = {0,0,0};
    scanf("%d",&a);
    scanf("%d",&b);

    for(i=0;i<3;i++){
        if(a == s[i]){
            f[i] = 1;
        }
    }
    for(j=0;j<3;j++){
        if(b == s[j]){
            f[j] = 1;
        }
    }

    for(k=0;k<3;k++){
        if(f[k] == 0){
            cout << s[k] << endl;
        }
    }

    return 0;
}

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

int main(){
  long long int n,m,i,kotae=0,zero=0;
  cin>>n>>m;
  int a[m],b[m-1];
  for(i=0;i<m;i++){
    cin>>a[i];
  }
  sort(a,a+m);
  for(i=0;i<m-1;i++){
    b[i]=a[i+1]-a[i];
  }
  sort(b,b+m-1);
  for(i=0;i<m-n;i++){
    kotae+=b[i];
  }
  cout<<max(kotae,zero);
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int n,k,i,ans,point,temp1,temp2;
  point=0;
  scanf("%d %d",&n,&k);
  ans=n;
  int A[n];
  
  for(i=0;i<n;i++)
  {
  scanf("%d",&A[i]);
   if(A[i]==1) point=i+1;
  }
  
  if(point==1 && (n-1)%(k-1)==0) printf("%d",(n-1)/(k-1));
  else if(point==1 && (n-1)%(k-1)!=0) printf("%d",(n-1)/(k-1)+1);
  
  else{
  int min;
    min=point-1;
  if(min > k-1) min=k-1;
  
   for(i=0;i<=min;++i)
   {
   if((i-1)%(k-1)==0) temp1=(i-1)/(k-1);
   else temp1=(i-1)/(k-1)+1;
     
   if((n-i)%(k-1)==0) temp2=(n-i)/(k-1);
   else temp2=(n-i)/(k-1)+1;
   if(ans > temp1+temp2) ans=temp1+temp2;
   }
   printf("%d",ans);
  }
  
return 0;  
}

Measured memory_bytes: 2088
#include <iostream>
using namespace std;
int main () {
 
  	int n; cin >> n;
  
  	n = n % 10;
  	if (n == 3) {
    	cout << "bon";
    }
  	else if (n == 0 || n == 1 || n == 6 || n == 8) {
     	cout << "pon"; 
    }
  	else {
    	cout << "hon";
    }
  
 return 0; 
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
	int W, H, N;
	
	scanf("%d %d %d", &W, &H, &N);
	
	int x, y, a, i;
	int x_1 = 0, x_2 = W, y_1 = 0, y_2 = H;
	
	for(i = 0; i < N; i++) {
		scanf("%d %d %d", &x, &y, &a);
		if(a == 1 && x_1 < x) {
			x_1 = x;
		}
		else if(a == 2 && x_2 > x) {
			x_2 = x;
		}
		else if(a == 3 && y_1 < y) {
			y_1 = y;
		}
		else if(a == 4 && y_2 > y) {
			y_2 = y;
		}
	}
	
	int w = x_2 - x_1, h = y_2 - y_1;
	printf("%d", w > 0 && h > 0 ? w * h : 0);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

int main(){
    int a ,b;

    std::cin >> a >> b;

    if((a + b) % 2 == 0){
        int c = (a + b) / 2;
        std::cout << c << std::endl;
    }else{
        std::cout << "IMPOSSIBLE" << std::endl; 
    }

    return 0;
}


Measured memory_bytes: 256
s = input()

count = 0
for index in range(len(s)):
    if index % 2 == 0 and index - 2 <= len(s):
        if s[index:index + 2] == "hi":
            pass
        else:
            count += 1

if count == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<stdio.h>
main(){  
    int a, b, c;  
    scanf("%d %d %d", &a, &b, &c);     
    if ( a <= b && b <= c )   
    printf("%d %d %d\n", a, b, c);   
    else if ( a <= c && c <= b )   
    printf("%d %d %d\n", a, c, b);  
    else if ( b <= a && a <= c )   
    printf("%d %d %d\n", b, a, c); 
    else if ( b <= c && c <= a ) 
    printf("%d %d %d\n", b, c, a); 
    else if ( c <= a && a <= b )   
    printf("%d %d %d\n", c, a, b);  
    else   
    printf("%d %d %d\n", c, b, a); 
return 0;
    
}




Measured memory_bytes: 2708