akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;


int main ( void ) {
    int N, ans = 0, _a = 0, b_ = 0, ba = 0;
    cin >> N;
    string s[N];
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        int length = s[i].length();
        if (s[i][0] == 'B' && s[i][length-1] == 'A') ba++;
        else{
            if (s[i][0] == 'B') b_++;
            if (s[i][length-1] == 'A') _a++;
        }
        for (int j = 0; j < length - 1; j++){
            if (s[i].substr(j, 2) == "AB") ans++;
        }
    }
    int d = b_ - _a;
    if (b_ == 0 && _a == 0 && ba == 0) ans += 0;
    else if (b_ == 0 && _a == 0) ans += ba - 1;
    else if (d == 0) ans += b_ + ba;
    else if (d > 0) ans += _a + ba;
    else if (d < 0) ans += b_ + ba;

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



Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main()
{
	double l,h,x,y;
	cin>>l>>h>>x>>y;
	cout<<(l*h)/2<<' ';
	if(x==l/2&&y==h/2)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	return 0;
}

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

int main()
{
    int n, num;
    cin >> n;
    int a[n + 1];
    int x[n + 1] = {0};

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

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

    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

int main(){
  int N, M;
  while(cin >> N >> M){
    vector<vector<int>> A(N, vector<int>(M)); cin >> A;
    REP(i,N) REP(j,M) A[i][j] -= 1;

    int ans = INT_MAX;

    vector<bool> s(M, true);

    REP(_,M){

      vector<int> count(M);

      REP(i,N){
        REP(j,M){
          if(s[A[i][j]]){
            count[A[i][j]] += 1;
            break;
          }
        }
      }
      
      int k = max_element(ALL(count)) - count.begin();

      s[k] = false;
      chmin(ans, count[k]);
    }
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 640
x, n = list(map(int, input().split()))
p_list = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()

i = 0
while True:
    x_i = x - i
    x_j = x + i

    if x_i not in p_list:
        print(x_i)
        exit()
    if x_j not in p_list:
        print(x_j)
        exit()

    i += 1


Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n;
signed main() {
	cin >> n;
	int p = 1, memo = 0;
	while (p < n) {
		p *= 2;
		if (p <= n)memo++;
	}
	int ans = 1;
	rep(i, memo + 1)ans *= 2;
	cout << ans - 1 << endl;
	ggr
}


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

void maxheap(int*,int);
void buildmaxheap(int*);


int n;

int main(){
    int *heap;

    scanf("%d",&n);
    heap=malloc(sizeof(int)*n+1);
    for(int i=1;i<=n;i++){
        scanf("%d",&heap[i]);
    }

    buildmaxheap(heap);

    for(int i=1;i<=n;i++){
        printf(" %d",heap[i]);
    }

    printf("\n");

    return 0;
}

void buildmaxheap(int* A){
    for(int i=n/2;i>=1;i--){
        maxheap(A,i);
    }
}

void maxheap(int* A,int i){
    int l=i*2;
    int r=i*2+1;
    int largest;
    int tmp;

    if(l<=n&&A[l]>A[i]){
        largest=l;
    }
    else{
        largest=i;
    }

    if(r<=n&&A[r]>A[largest]){
        largest=r;
    }

    if(largest!=i){
        tmp=A[i];
        A[i]=A[largest];
        A[largest]=tmp;
        maxheap(A,largest);
    }
}



Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

double getD(double x1, double y1, double x2, double y2) {
	return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double getDS(double x1, double y1, double x2, double y2) {
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}

vector<double> getI(double x1, double y1, double r1, double x2, double y2, double r2) {
	double d = getD(x1, y1, x2, y2);
	double ds = getDS(x1, y1, x2, y2);
	double a = (r1*r1-r2*r2+ds)/(2.0*d);
	double h = sqrt(r1*r1-a*a);
	double x0 = x1 + (x2-x1)*a/d;
	double y0 = y1 + (y2-y1)*a/d;
	double xc = x0 - (y2-y1)*h/d;
	double yc = y0 + (x2-x1)*h/d;
	double xd = x0 + (y2-y1)*h/d;
	double yd = y0 - (x2-x1)*h/d;
	return {xc, yc, xd, yd};
}

bool check(const vector<vector<double>> &p, const vector<vector<double>> &c, const int k) {
	for (auto &i : p) {
		int res = 0;
		for (auto &j : c) {
			double d = getD(i[0], i[1], j[0], j[1]);
			if (d - j[2] < 1e-6) {
				res++;
				if (res == k) {
					return true;
				}
			}
		}
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n, k;
	cin>>n>>k;
	if (k == 1) {
		cout<<0<<endl;
		return 0;
	}
	vector<vector<double>> v;
	for (int i = 0; i < n; i++) {
		double x, y, c;
		cin>>x>>y>>c;
		v.push_back({x, y, c});
	}
	double lo = 0, hi = 400000;
	while (abs(hi-lo) > 1e-6) {
		double t = (lo + hi) / 2.0;
		vector<vector<double>> c;
		vector<vector<double>> p;
		for (auto &i : v) {
			c.push_back({i[0], i[1], t/(double)i[2]});
			p.push_back({i[0], i[1]});
		}
		const int m = c.size();
		for (int i = 0; i < m-1; i++) {
			for (int j = i+1; j < m; j++) {
				double d = getD(c[i][0], c[i][1], c[j][0], c[j][1]);
				if (d >= abs(c[i][2] - c[j][2]) && d <= c[i][2] + c[j][2]) {
					auto s = getI(c[i][0], c[i][1], c[i][2], c[j][0], c[j][1], c[j][2]);
					p.push_back({s[0], s[1]});
					p.push_back({s[2], s[3]});
				}
			}
		}
		bool res = check(p, c, k);
		if (res) {
			hi = t;
		} else {
			lo = t;
		}
	}
	printf("%.6f\n", lo);
	return 0;
}

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


int N;
vector<int> a;

const int NMAX = 2000;

int dp[NMAX+1][NMAX+1];

int main()
{
    scanf("%d\n", &N);
    a.resize(N * 2);

    for (int i=0; i<2*N; i++)
    {
        char str;
        scanf("%s", &str);
        scanf("%d", &a[i]);
        if (str == 'W') a[i] *= -1;
    }

    vector<vector<int> > memo(2*N);
    //各石（黒1~N、」白1~N）の手前にある石を全部調べてソートしておく(N^2logN)
    for (int j=1; j<=N; j++) // 黒j
    {
        for (int i=0; i<2*N; i++)
        {
            if (a[i] == j) break;
            memo[j-1].push_back(a[i]);
        }
    }
    for (int j=1; j<=N; j++) // 白j
    {
        for (int i=0; i<2*N; i++)
        {
            if (a[i] == -j) break;
            memo[N + j - 1].push_back(a[i]);
        }
    }

    for (int i=0; i<2*N; i++) sort(memo[i].begin(), memo[i].end());

    // dp[i][j] : 先頭から黒i個白j個が正しい順に並ぶまでの最小操作回数

    dp[0][0] = 0;

    for (int i=1; i<=N; i++)
    {
        int aa = 0;
        for (int k=0; k<2*N; k++)
        {
            if (a[k] == i) break;
            if (a[k] > i || a[k] < 0) aa++;
        }
        int bb = 0;
        for (int k=0; k<2*N; k++)
        {
            if (a[k] == -i) break;
            if (a[k] < -i || a[k] > 0) bb++;
        }

        dp[i][0] = dp[i-1][0] + aa;
        dp[0][i] = dp[0][i-1] + bb;
    }

    for (int i=1; i<=N; i++)
    {
        for (int j=1; j<=N; j++)
        {
            /* iroiro */
            // 数字iが書かれた黒を手前に持ってくるまでの総回数
            int aa = 
            distance(lower_bound(memo[i-1].begin(), memo[i-1].end(), i), memo[i-1].end())
            + distance(memo[i-1].begin(), lower_bound(memo[i-1].begin(), memo[i-1].end(), -j));
            int bb =
            distance(upper_bound(memo[j-1+N].begin(), memo[j-1+N].end(), i), memo[j-1+N].end())
            + distance(memo[j-1+N].begin(), lower_bound(memo[j-1+N].begin(), memo[j-1+N].end(), -j));

            dp[i][j] = min(dp[i-1][j] + aa, dp[i][j-1] + bb);
        }
    }

    printf("%d\n", dp[N][N]);
    return 0;
}

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

vector<int> a(100);

int main(){
    int n; cin >> n;
    int cnt=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]%2==0) cnt++;
    }
    ll ans = pow(3, n);
    ll odd = pow(2, cnt);
    ans = ans - odd;

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 4104
/*
    Problem 14
    https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = 15;
const ll INF = 1e18;
/* global variables */
/* function */
/* main */
int main(){
    int N, K, upper;
    ll ans, tmp, pre;
    cin >> N >> K;

    vector<ll> building(N);
    for (int i = 0; i < N; i++) cin >> building[i];

    upper = pow(2, N);
    ans = INF;
    for (int b = 0; b < upper; b++) {
        bitset<MAX> bs(b);
        vector<int> v(MAX, 0);
        if (bs.count() != K or !bs[0]) continue;
        for (int i = 0; i < N; i++)
            if ((bs >> i)[0]) v[i] = 1;
        tmp = 0;
        pre = building[0];
        for (int i = 1; i < N; i++) {
            if (v[i]) {
                if (pre >= building[i]) {
                    tmp += pre - building[i] + 1;
                    pre = max(pre+1, building[i]);
                }
            }
            pre = max(pre, building[i]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


std::vector<int> prime_factors(int n) {
  std::vector<int> a;

  for (int i = 2; i * i <= n; i ++)
    for ( ; n % i == 0; n /= i)
      a.push_back(i);

  if (n != 1)
    a.push_back(n);

  return std::move(a);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  std::map<int, int> map;

  for (int i = 2; i <= N; i ++) {
    std::vector<int> a = prime_factors(i);

    for (const auto& k : a)
      map[k] ++;
  }

  int c[111] = {0};

  const std::vector<int> ths = {3, 5, 15, 25, 75};

  for (const auto& kv : map)
    for (const auto& th : ths)
      if (kv.second >= th - 1)
        c[th] ++;

  int C = 0;

  C += c[75];
  C += c[25] * (c[3] - 1);
  C += c[15] * (c[5] - 1);
  C += c[ 5] * (c[5] - 1) / 2 * (c[3] - 2);

  std::cout << C << std::endl;
    
  return 0;
}


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

int64_t GCD(int64_t X, int64_t Y){
  int64_t aX=max(X, Y);
  int64_t aY=min(X, Y);
  if(aX%aY==0){
    return aY;
  }
  else{
    return GCD(aY, aX%aY);
  }
}

int main(){
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  int64_t aC, aD, aCD;
  if(A%C==0){
    aC=(B-A+1)/C;
  }
  else{
    aC=(B-A+1+A%C-1)/C;
  }
  if(A%D==0){
    aD=(B-A+1)/D;
  }
  else{
    aD=(B-A+1+A%D-1)/D;
  }
  int64_t CD=C*D/GCD(C, D);
  if(A%CD==0){
    aCD=(B-A+1)/CD;
  }
  else{
    aCD=(B-A+1+A%CD-1)/CD;
  }
  cout << B-A+1-aC-aD+aCD << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n,k,S;
ll s[maxn];
map<ll,bool> M;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k); read(S);
	for (int i=1;i<=k;i++) printf("%d ",S);
	n-=k;
	for (int i=0;i<=k;i++) M[(ll)S*i+S]=1;
	s[0]=(ll)S*k;
	for (int i=1;i<=n;i++) {
		s[i]=s[i-1]+1;
		while (M[s[i]]) s[i]++;
		M[s[i]+S]=1;
	}
	for (int i=1;i<=n;i++) printf("%lld ",s[i]-s[i-1]); printf("\n");
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 13696
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<# x "="<<x<<endl

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

#define INF 1000000000
#define EPS 1e-10

double a[100], b[100], c[100], d[100];

#define EQ(x,y) fabs((x)-(y))<(EPS)

inline double dist(double x1,double y1,double x2,double y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}


int main(){
  int n;
  int cnt=1;
  while(cin>>n, n){
    rep(i,n){
      scanf("%lf %lf %lf %lf", &a[i], &b[i], &c[i], &d[i]);
    }

    int res=1;
    rep(i,n){
      // new line idx=i
      vector<pair<double, double> > cross;
      int adds=1;
      rep(j,i){
        // check if i and j have intersection point
        // => not paralell and inner square

        // is paralell ?
        if(EQ((a[i]-c[i])*(b[j]-d[j]), (a[j]-c[j])*(b[i]-d[i]))) continue;

        // calc intersection point
        double nx;
        double ny;
        if( EQ(a[i],c[i]) ){
          double dj = (b[j]-d[j])/(a[j]-c[j]);
          nx = a[i];
          ny = dj*(nx-a[j])+b[j];
        } else if( EQ(a[j],c[j]) ){
          double di = (b[i]-d[i])/(a[i]-c[i]);
          nx = a[j];
          ny = di*(nx-a[i])+b[i];
        } else {
          double di = (b[i]-d[i])/(a[i]-c[i]);
          double dj = (b[j]-d[j])/(a[j]-c[j]);
          nx = (b[j]-dj*a[j]-(b[i]-di*a[i]))/(di-dj);
          ny = di*(nx-a[i])+b[i];
          assert(EQ(ny, dj*(nx-a[j])+b[j]));
        }
        //      dbg(nx);dbg(ny);

        if(fabs(nx)-100.0<=-EPS && fabs(ny)-100.0<=-EPS){
	//if(-100<nx && nx<100 && -100<ny && ny<100){
          int reps=cross.size();
          bool flg=true;
          rep(k,reps){
            // new point is already added or not
	    //if(EQ(cross[k].first, nx) && EQ(cross[k].second, ny)){
	    if( dist(cross[k].first,cross[k].second,nx,ny)<EPS ){
              flg=false; break;
            }
          }
          if(flg){
            cross.pb(mp(nx,ny));
            adds++;
          }
        }

      }// rep  j
      //      dbg(adds);
      res += adds;
    }//rep i

    cout<<res<<endl;

  }
  return 0;
}

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

using namespace std;

int main(){
	double input;
	while(cin >> input){
		if(input <= 48.00) cout << "light fly" << endl;
		else if(input <= 51.00) cout << "fly" << endl;
		else if(input <= 54.00) cout << "bantam" << endl;
		else if(input <= 57.00) cout << "feather" << endl;	
		else if(input <= 60.00) cout << "light" << endl;	
		else if(input <= 64.00) cout << "light welter" << endl;	
		else if(input <= 69.00) cout << "welter" << endl;	
		else if(input <= 75.00) cout << "light middle" << endl;	
		else if(input <= 81.00) cout << "middle" << endl;	
		else if(input <= 91.00) cout << "light heavy" << endl;	
		else cout << "heavy" << endl;
	}
}

Measured memory_bytes: 1220
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    string s;
    cin>>s;

    ll B[n];
    ll R[n];
    ll G[n];

    for(int i=0;i<n;i++){
        if(i==0){
            if(s[i]=='B')B[i]=1,R[i]=0,G[i]=0;
            if(s[i]=='R')B[i]=0,R[i]=1,G[i]=0;
            if(s[i]=='G')B[i]=0,R[i]=0,G[i]=1;
            continue;
        }
        if(s[i]=='B')B[i]=B[i-1]+1,R[i]=R[i-1],G[i]=G[i-1];
        if(s[i]=='R')B[i]=B[i-1],R[i]=R[i-1]+1,G[i]=G[i-1];
        if(s[i]=='G')B[i]=B[i-1],R[i]=R[i-1],G[i]=G[i-1]+1;
    }

    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j] || i==j)continue;
            if(s[i]=='B' && s[j]=='R'){
                ans+=G[n-1]-G[j];
                if(j+(j-i)<n){
                    if(s[j+(j-i)]=='G')ans--;
                }
            }
            if(s[i]=='R' && s[j]=='B'){
                ans+=G[n-1]-G[j];
                if(j+(j-i)<n){
                    if(s[j+(j-i)]=='G')ans--;
                }
            }
            if(s[i]=='B' && s[j]=='G'){
                ans+=R[n-1]-R[j];
                if(j+(j-i)<n){
                    if(s[j+(j-i)]=='R')ans--;
                }
            }
            if(s[i]=='G' && s[j]=='B'){
                ans+=R[n-1]-R[j];
                if(j+(j-i)<n){
                    if(s[j+(j-i)]=='R')ans--;
                }
            }
            if(s[i]=='R' && s[j]=='G'){
                ans+=B[n-1]-B[j];
                if(j+(j-i)<n){
                    if(s[j+(j-i)]=='B')ans--;
                }
            }
            if(s[i]=='G' && s[j]=='R'){
                ans+=B[n-1]-B[j];
                if(j+(j-i)<n){
                    if(s[j+(j-i)]=='B')ans--;
                }
            }
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3708
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

count_dict = {}
for i in range(N):
    now_num = A_list[i]
    count_dict[now_num] = count_dict.get(now_num, 0) + 1

base_ans = 0
for _, v in count_dict.items():
    base_ans += (v * (v - 1)) // 2
    
for i in range(N):
    now_num = count_dict[A_list[i]]
    print(base_ans - (now_num * (now_num - 1) - ((now_num - 1) * (now_num - 2))) // 2)

Measured memory_bytes: 25716
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 1000000007

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, A ...int) int {
  S := SumInt(A...)
  C := (*F)[S]
  for _, a := range A {
    C *= (*Finv)[a]
    C %= p
  }
  return C
}

func Pow(n, k int) int {
  a := 1
  for ; 0 < k; k /= 2 {
    if k % 2 == 1 { a = (a * n) % p }
    n = (n * n) % p
  }
  return a
}

func Solve() {
  var K int
  NextInt(&K)
  S := NextLine()
  N := len(S)
  F, Finv, _ := Factorial(N + K)
  P := 0
  for k := 0; k <= K; k++ {
    P += (Pow(25, k) * Comb(&F, &Finv, N - 1, k) % p) * Pow(26, K - k) % p
    P %= p
  }
  Write(P)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  Write(B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for(ll i = 0; i < n; i++) {
        cin >> t[i];
    }

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

    ll cnt=0;
    ll pgr=0;
    while(pgr<n) {
        ll lim=t[pgr]+k;
        ll tmp=0;
        while(t[pgr+tmp]<=lim && tmp<c && pgr+tmp<n) tmp++;
        pgr+=tmp;
        cnt++;
    }
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
int N,A[3][3],b[10];
bool appear[3][3]; 
int main()
{
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
			cin>>A[i][j];
	}
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>b[i];
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			appear[i][j]=false;
			for(int k=0;k<N;k++)
			   if(A[i][j]==b[k]) appear[i][j]=true;
		}
	}
	string ANS="No";
	for(int i=0;i<3;i++)
	{
	   if(appear[i][0]&&appear[i][1]&&appear[i][2])
	     ANS="Yes";
    }
    for(int i=0;i<3;i++)
    {
    	if(appear[0][i]&&appear[1][i]&&appear[2][i])
    	  ANS="Yes";
	}
	if(appear[0][0]&&appear[1][1]&&appear[2][2])
	  ANS="Yes";
	if(appear[0][2]&&appear[1][1]&&appear[2][0])
	  ANS="Yes";
	cout<<ANS<<endl;
	return 0; 
} 

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

int n;
vector<int> v;
int main(){
    cin>>n;
    int k;
    cin>>k;
    for(int i=0;i<n;i++){
     int a;
        scanf("%d",&a);
        v.push_back(a);
    }
    int mint=*min_element(v.begin(),v.end());
    int ans=0;
    int i=0;
    while(i<n){
        ans++;
        i+=k-1;
        if(i==n-1)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M;
int x[MAXN],y[MAXN];
bool S[405][405],eat[405];
void Solve() {
    read(N);read(M);
    for(int i = 1 ; i <= M ; ++i) {
        read(x[i]);read(y[i]);
    }
    for(int i = 1 ; i <= N ; ++i) {
        S[i][i] = 1;
        for(int j = M ; j >= 1 ; --j) {
            if(S[i][x[j]] && S[i][y[j]]) {eat[i] = 1;break;}
            else if(S[i][x[j]] && !S[i][y[j]]) S[i][y[j]] = 1;
            else if(!S[i][x[j]] && S[i][y[j]]) S[i][x[j]] = 1;
        }
    }
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = i + 1 ; j <= N ; ++j) {
            if(!eat[i] && !eat[j]) {
                bool flag = 1;
                for(int h = 1 ; h <= N ; ++h) {
                    if(S[i][h] && S[j][h]) {flag = 0;break;}
                }
                ans += flag;
            }
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, string S){
	rep(i, S.length()) {
		S[i] = (S[i]-'A'+N)%26+'A';
	}
	cout << S << endl;
}

int main(){	
	long long N;
	string S;
	scanf("%lld",&N);
	cin >> S;
	solve(N, S);
	return 0;
}



Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;
vector<ll> adj[100005];
ll ans = 1;
ll A, B;

ll modMul(ll A, ll B){
	return (A * B) % MOD;
}


void dfs(ll par, ll curr, ll k) {
	ans = modMul(ans, k);
	// cout << ans << " ";
	k = K - 1;
	if(par != -1) {
		k--;
	}
	for(int i = 0; i < adj[curr].size(); i++) {
		if(adj[curr][i] != par) {
			dfs(curr, adj[curr][i], k);
			k--;
		}
	}
} 

int main() {
	scanf("%lld %lld", &N, &K);
	for(int i = 0; i < N - 1; i++) {
		scanf("%lld %lld", &A, &B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	ll par = -1;
	ll curr = 1;
	dfs(par, curr, K);
	cout << ans << " ";
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<char> a(w);
  for (int i = 0; i < w + 2; i++)
    cout << '#';
  cout << endl;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++)
      cin >> a.at(j);
    cout << '#';
    for (int j = 0; j < w; j++)
      cout << a.at(j);
    cout << '#' << endl;
  }
  
  for (int i = 0; i < w + 2; i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
let [| n; m|] = stdin.ReadLine().Split() |> Array.map int
let abArray = [| for _ in 1..n -> stdin.ReadLine().Split() |> Array.map int64 |]

let abArraySorted = Array.create<int64[][]> (m+1) [|[|0L;0L|]|]
abArray |> Array.groupBy (fun [| a; b; |] -> a) |> Array.iter (fun (a, array) -> if int a <= m then abArraySorted.[int a] <- array ) 

let appendSet i set =
    abArraySorted.[i] |> Seq.mapi (fun i [| a; b; |] -> b, a, i) |> Set.ofSeq |> Set.union set

// 一回のバイト
let job (set, i) = 
    match i with
    | -1 -> None
    | _ ->
        let set = appendSet (m-i) set
        let max = set |> Set.maxElement 
        let setNext = set |> Set.remove max
        Some( (max|> fun (b, a, i) -> b), (setNext, (i-1)))

Seq.unfold job (Set.empty,m-1)
|>Seq.sum
|>stdout.WriteLine


Measured memory_bytes: 52204
#include <stdio.h>

int main(void){
int H, W, i, j;
scanf("%d %d", &H, &W);

while( H !=0 || W != 0){
for( j=1 ; j<=H ; j++){
for( i=1 ; i<=W ; i++){
printf("#");
}
printf("\n");
}
scanf("%d %d", &H, &W);
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
typedef pair<double, double> dop;
//------------------変数-----------------------//
ll n, m, dp[1100001], order[100001], cnt[100101] = {}, imos[21][100200] = {};
ll bitmax = 1;
//-------------------関数----------------------//


int main() {
	string s; cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
	return 0;
}



Measured memory_bytes: 256
import collections

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


c = collections.Counter(A)

z = []
for k, v in c.items():
    if v >= 4:
        z.append(k)
    if v >= 2:
        z.append(k)

if len(z) < 2:
    print(0)
    exit()

x = max(z)
del z[z.index(x)]
y = max(z)

print(x*y)


Measured memory_bytes: 18600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b; cin >> a >> b;
  if(a>b) {
    for(int i=0; i<a; i++) cout << b;
  }
  else {
    for(int i=0; i<b; i++) cout << a;
  }
  return 0;
}

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

int main() {
  
  int N, a, count = 0, ans = 9999;
  cin >> N;

  for(int i = 0; i < N; i++) {
  
    cin >> a;
    count = 0;
    
    for(int j = 0; j <= count + 1; j++) {
      
      if(a % 2 == 0) {
        count += 1;
        a /= 2;
      }
      
      else {
        break;
      }
      
    }
    
    if(count < ans) {
      ans = count;
    }
      
  }
 
  cout << ans << endl;
  
}

Measured memory_bytes: 3616
while True:
    a, op, b = list(input().split())
    a, b = int(a), int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '?':
        break


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

using namespace std;
using ll=long long;
double mod = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)
char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                     's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}


int main() {
    ll N = 0, T = 0, answer = 0, sum1 = 0, sum2 = 0, tmp = 0;
    int cnt1 = 0, cnt2 = 0;
    cin >> N >> T;
    int *a = new int[N];
    REP(i, N)cin >> a[i];
    REP1(i, N) {
        if (abs(a[i - 1] - a[i]) < T) {
            sum1 += abs(a[i - 1] - a[i]);
        } else {
            sum1 += T;
        }
    }
    sum1 += T;

    cout << sum1 << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> mp1;
  map<int,int> mp2;
  i_i mx1={0,0};
  i_i mx2={0,0};
  rep(i,n){
    if(i%2==0){
      mp1[a[i]]++;
      if(mx1.second<mp1[a[i]]){
        mx1.first=a[i];
        mx1.second=mp1[a[i]];
      }
    }
    else{
      mp2[a[i]]++;
      if(mx2.second<mp2[a[i]]){
        mx2.first=a[i];
        mx2.second=mp2[a[i]];
      }
    }
  }
  if(mx1.first!=mx2.first){
    int ans=(n/2-mx1.second)+(n/2-mx2.second);
    cout << ans << endl;
    return 0;
  }
  int smx1=0;
  int smx2=0;
  for(auto c:mp1){
    if(c.first!=mx1.first) chmax(smx1,c.second);
  }
  for(auto c:mp2){
    if(c.first!=mx2.first) chmax(smx2,c.second);
  }
  int ans=min((n/2-mx1.second)+(n/2-smx2),(n/2-mx2.second)+(n/2-smx1));
  cout << ans << endl;

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/
 
ll hpow(ll a,ll b){
  ll res=1;
  while(b!=0){
    if(b&1)res=res*a%2019;
    a=a*a%2019;
    b=b>>1;
  }
  return res;
}
 
int main()
{
  string s;cin>>s;
  ll n=s.length();
  ll a[2019]={0};
  ll hoge=0;
  for(ll i=0;i<n;i++){
    hoge=(hoge+(s[n-1-i]-'0')*hpow(10,i))%2019;
    a[hoge]++;
  }
  ll ans=0;
  for(ll i=0;i<2019;i++){
    ans+=a[i]*(a[i]-1)/2;
  }
  cout<<ans+a[0]<<endl;
  return 0;
}

Measured memory_bytes: 3744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            for (int i = 1; i < n - 1; i++) {
                if (i * 3 + 2 > x) {
                    break;
                }
                for (int j = i + 1; j < n; j++) {
                    if (i + j + j + 1 > x) {
                        break;
                    }
                    for (int k = x - i - j; k >= j + 1; k--) {
                        if (k > n) {
                            continue;
                        }
                        if (i + j + k == x) {
                            count++;
                            break;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 25196
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
ll mod = 1000000007;
ll powy(ll a, ll b)
{
  if (b == 0) return 1;
  ll c = powy(a, b / 2);
  if (b & 1) return (((c * c) % mod) * a) % mod;
  else return (c * c) % mod;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n; cin >> n;
  ll c1 = powy((ll)10, n);
  ll c2 = powy((ll)9, n);
  ll c3 = powy((ll)8, n);
  c2 = (c2 * 2) % mod;
  c1 = (c1 - c2 + mod) % mod;
  c1 = (c1 + c3) % mod;
  cout << c1 << "\n";
  return 0;
}

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

int main(){
    ll N;
    cin >> N;
    ll H[N];
    for(ll i=0;i<N;i++){
        cin >> H[i];
    }

    for(ll i=N-1;i>0;i--){
        if(H[i-1] > H[i]){
            if(H[i-1]-1 > H[i]){
                cout << "No" << endl;
                return 0;
            }else{
                H[i-1] -= 1;
            }
        }
    }

    
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
int ctr=0;
for(int i=0;i<n;i++)
{
	cin>>arr[i];
	if((i+1)%2==1 && arr[i]%2==1)
	{
		ctr++;
	}
}
cout<<ctr<<endl;
}

Measured memory_bytes: 3648
b = input()
AT = ["A", "T"]
CG = ["C", "G"]
if b in AT:
    if b == AT[0]:
        print(AT[1])
    else:
        print(AT[0])
elif b in CG:
    if b == CG[0]:
        print(CG[1])
    else:
        print(CG[0])

Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 500000

int n, A[MAX];

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
} 

void maxHeapify(int A[], int i){

  int temp, largest, l, r;

   l  = left(i);
   r = right(i);

   if(l<=n && A[l]>A[i]){
     largest = l;
   }else{
     largest = i;
   }

   if(r<=n && A[r]>A[largest]){
     largest = r;
   }

   if(largest != i){
     temp = A[i];
     A[i] = A[largest];
     A[largest] = temp;
    
     maxHeapify(A, largest);
   }
}

void buildMaxHeap(int A[]){

  int i;
  for(i=n/2;i!=0;i--){
      maxHeapify(A,i);
  }
}


main(){

  int j,k;

  scanf("%d",&n);
  
  for(j=1;j<=n;j++){
    scanf("%d",&A[j]);
  }

   buildMaxHeap(A);

  for(k=1;k<=n;k++){
    printf(" %d",A[k]);
  }
  printf("\n");
  return 0;
}

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

int main()
{
	int X, A, B, N;
	scanf("%d%d%d%d", &X, &A, &B, &N);
	for (int i{}; i < N; i++)
	{
		std::string S;
		std::cin >> S;
		if (S == "nobiro") X += A;
		else if (S == "tidime") X += B;
		else X = 0;
		X = std::max(X, 0);
	}
	printf("%d\n", X);

	return 0;
}


Measured memory_bytes: 3336
def cin():  return list(map(int,input().split()))

N = cin()[0]
a = cin()

ans = [0] * N
cnt = a[0]
tmp = 1
for i in range(1, N):
    tmp *= -1
    cnt += a[i] * tmp
ans[0] = cnt
for i in range(1, N):  ans[i] = 2 * a[i - 1] - ans[i - 1]
print(*ans)

Measured memory_bytes: 90404
import sys

N = int(input())
sys.setrecursionlimit(N*10)

memo = dict()
INF = N

def withdraw(amount):
    if amount == 0:
        return 0
    if amount in memo:
        return memo[amount]

    answer = amount
    
    unit = 6
    while unit <= amount:
        answer = min(answer, withdraw(amount-unit)+1)
        unit *= 6

    unit = 9
    while unit <= amount:
        answer = min(answer, withdraw(amount-unit)+1)
        unit *= 9

    memo[amount] = answer
    return answer

print(withdraw(N))

Measured memory_bytes: 19696
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W, D] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    A ={}
    for i in range(H):
        input_raw = read_func().strip().split()
        for j in range(W):
            A[int(input_raw[j])] = (i, j)

    D_map = {}
    for x in range(1, H * W + 1):
        if x % D not in D_map:
            D_map[x % D] = [(A[x], 0)]
        else:
            (p, q) = D_map[x % D][(x / D) - (2 if x % D == 0 else 1)][0]
            pre_d = D_map[x % D][(x / D) - (2 if x % D == 0 else 1)][1]
            d = abs(p - A[x][0]) + abs(q - A[x][1])
            D_map[x % D].append((A[x], d + pre_d))

    input_raw = read_func().strip().split()
    [Q] = [long(input_raw[0])]
    for i in range(Q):
        input_raw = read_func().strip().split()
        [L, R] = [long(input_raw[0]), long(input_raw[1])]
        l = L % D
        print D_map[l][R/D - (1 if R % D == 0 else 0)][1] - D_map[l][L/D - (1 if L % D == 0 else 0)][1]



if __name__ == '__main__':
    main()


Measured memory_bytes: 48340
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	char a[10],b[10],c[10];
	scanf("%s %s %s",a,b,c);
	if(a[0]>=97&&a[0]<=122) printf("%c",a[0]-32);
	if(b[0]>=97&&b[0]<=122) printf("%c",b[0]-32);
	if(c[0]>=97&&c[0]<=122) printf("%c\n",c[0]-32);
	return 0;
}


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

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

fn calc_e(n: u64) -> f64 {
    return ((n as f64) + 1.0) / 2.0
}

fn main() {
    let n: u64 = read();
    let k: u64 = read();
    let pi: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut ek = vec![0.0; (k + 1) as usize];

    let mut max_e: f64 = 0.0;
    let mut tmp_max: f64 = 0.0;
    let mut index: usize = 0;
    for i in 0..n {
        let e = calc_e(pi[i as usize]);
        ek[index] = e;
        index = (index + 1) % ((k + 1) as usize);
        tmp_max = tmp_max + e;
        if i + 1 < k {
            continue
        }

        tmp_max = tmp_max - ek[index];

        if tmp_max > max_e {
            max_e = tmp_max;
        }
    }
    println!("{:.12}", max_e);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll N, M; cin >> N >> M;
    ll ans = min(N, M / 2);
    cout << ans + (M - ans * 2) / 4 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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 namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int d, t, s;
    cin >> d >> t >> s;
    
    if (s*t >= d) {
        cout << "Yes" << endl;
        
    } else {
        cout << "No" << endl;
        
    }



    return 0;
}

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

int main(){
    long long N;
    long long ans=0;
    cin >> N;
    for(long long i=1; i*i<=N; i++){
        if(N%i!=0) continue;
        if( ( N/i -i )>=2){
            ans +=N/i-1;
        }
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
import sys
from bisect import bisect

n = int(input())
aaa = list(map(int, sys.stdin.readlines()))

dp = [1]
for a in aaa:
    a *= -1
    i = bisect(dp, a)
    if i < len(dp):
        dp[i] = a
    else:
        dp.append(a)
print(len(dp))


Measured memory_bytes: 14244