akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


int main(){
	int n;
	scanf("%d", &n);
	ll a[n];
	REP(i, 0, n) scanf("%ld", &a[i]);

	bool p = true;
	std::map<ll,int> mp;
	REP(i, 0, n){
		ll x = a[i];
		for(ll i=2; i*i<=x; i++){
			if(x%i==0){
				if(mp[i]) p = false;
				else mp[i]++;
			}
			while(x%i==0) x/=i;
		}
		if(x!=1){
			if(mp[x]) p = false;
			else mp[x]++;
		}
		if(!p) break;
	}

	if(p){
		puts("pairwise coprime");
		return 0;
	}
	
	ll g = 0;
	REP(i, 0, n) g = std::gcd(g, a[i]);
	if(g==1) puts("setwise coprime");
	else puts("not coprime");
	return 0;
}



Measured memory_bytes: 11508
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cassert>
#include <bitset>
using namespace std;
typedef long long LL;

int N;
vector<LL>d;

template <class T>
struct fenwick_tree {
	vector<T> x;
	fenwick_tree(int n) : x(n, 0) { }
	T sum(int i, int j) {
		if (i == 0) {
			T S = 0;
			for (j; j >= 0; j = (j & (j + 1)) - 1) S += x[j];
			return S;
		}
		else return sum(0, j) - sum(0, i - 1);
	}
	void add(int k, T a) {
		for (; k < x.size(); k |= k + 1) x[k] += a;
	}
};

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		LL dd; cin >> dd;
		d.push_back(dd);
	}
	for (int loopcnt = 0; loopcnt < 2; ++loopcnt)
	{
		LL M = 1;
		while (M < 1e6)M *= 2;
		fenwick_tree<LL>bit(M);
		bit.add(0, 1);
		bit.add(1, -1);
		int isGood;
		for (int i = 0; i < N; ++i)
		{
			isGood = bit.sum(0, i);
			assert(isGood >= 0);
			if (isGood)
			{
				int next = d[i] / 10;
				bit.add(i + 1, 1);
				bit.add(i + next + 1, -1);
			}
		}
		if (isGood)
		{
		}
		else
		{
			cout << "no\n";
			return 0;
		}
		reverse(d.begin(), d.end());
	}
	cout << "yes\n";
	return 0;
}

Measured memory_bytes: 13596
n = int(input())
h = [int(i) for i in input().split()]

c = 0
tmp = h[0]
ans = 0
for i in range(1,n,1):
	if tmp >= h[i]:
		c+=1
	else:
		if c > ans:
			ans = c
		c = 0
	tmp = h[i]
if c > ans:
	ans = c
print(ans)

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


struct Edge {
    int to;
    ll B;
    Edge(int t, ll b) : to(t), B(b) {}
};

vector<ll> Dijkstra(const vector<vector<Edge>>& g, int s) {
    ll INF = 1LL<<60;
    vector<ll> d(g.size(), INF);
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> q;
    d.at(s) = 0;
    q.emplace(d.at(s), s);
    while ( !q.empty() ) {
        auto p = q.top();
        q.pop();
        int v = p.second;
        if ( d.at(v) < p.first ) continue;
        for ( auto e : g[v]) {
            if ( d.at(e.to) > d.at(v) + e.B ) {
                d.at(e.to) = d.at(v) + e.B;
                q.emplace(d.at(e.to), e.to);
            }
        }
    }
    return d;
}


ll solve() {
    ll N, M, S;
    ll u, v, a, b, c, d;
    cin >> N >> M >> S;
    ll AA = 2510;
    vector<vector<Edge>> G(N*AA);
    for ( int i = 0; i < M; i++ ) {
        cin >> u >> v >> a >> b;
        u--, v--;
        for ( ll j = 0; j < AA; j++ ) {
            if ( j - a >= 0 ) {
                G[u*AA+j].push_back(Edge(v*AA+j-a, b));
                G[v*AA+j].push_back(Edge(u*AA+j-a, b));
            }
        }
    }
    for ( int i = 0; i < N; i++ ) {
        cin >> c >> d;
        for ( ll j = 0; j < AA; j++ ) {
            if ( j+c < AA ) {
                G[i*AA+j].push_back(Edge(i*AA+j+c, d));
            } else {
                G[i*AA+j].push_back(Edge(i*AA+AA-1, d));
            }
        }
    }
    ll INF = 1LL << 60;
    vector<ll> ans(N, INF);
    if ( S > AA ) S = AA-1;
    vector<ll> tm = Dijkstra(G, S);
    for ( ll i = 0; i < N*AA; i++ ) {
        ans[i/AA] = min(ans[i/AA], tm[i]);
    }
    for ( ll i = 1; i < N; i++ ) {
        cout << ans[i] << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 24028
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s,t;
  cin>>s>>t;
  Int cnt=0;
  for(Int i=0;i<3;i++)
    if(s[i]==t[i]) cnt++;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int x,t;
    cin >> x >> t;
    cout << max(x-t,0) << endl;
    return 0;
}


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

// a + b + 2rt(ab) < c
// 2rt(ab) < c - a - b
// first check if c - a - b >= 0
// then check if 4ab < (c - a - b) ^ 2
//

using ll = long long;

int main() {
	ll a, b, c; scanf("%lld %lld %lld", &a, &b, &c);
	if (a + b <= c && 4 * a * b < (c - a - b) * (c - a - b)) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int d;
	int flag[101];
	for (int i = 0; i < 101; ++i) {
		flag[i] = 0;
	}
    cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> d;
		flag[d] = 1;
	}
	int ans = 0;
	for (int i = 0; i < 101; ++i) {
		ans += flag[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

vector<int> cntString(string s){
	vector<int> cnt(26, 0);
	rep (i, (int)s.length()){
		++cnt[(int)(s[i] - 'a')];
	} // end rep
	return cnt;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	string S; cin >> S;

	int res = 0;
	for (int i = 1; i < N; ++i){
		string pre = S.substr(0, i);
		string pos = S.substr(i);
		vector<int> preCnt = cntString(pre);
		vector<int> posCnt = cntString(pos);
		int curr = 0;
		rep (j, 26){
			if (preCnt[j] != 0 && posCnt[j] != 0){
				++curr;
			} // end if
		} // end rep
		res = max(res, curr);
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back()){++it;v2.pop_back();}
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it)
			m=*it++,x+=*it-m;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	reverse(ALL(v));
	if (v[0] != 2) cout << -1 << endl;
	else {
		ll l = 2;
		ll r = 4;
		for (int i = 1; i < n; i++) {
			ll k = v[i];
			l = dup(l,k) * k;
			r = dup(r,k) * k;
			if (r - l <= 1) {	
				cout << -1 << endl;
				return 0;
			}
		}
		cout << l << " " << r-1 << endl;
	}
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        ll sm = 0;
        rep(i, 0, N) sm += A[i];

        ll cnt = 0;
        rep(i, 0, N) {
                if (A[i] * 4 * M >= sm) ++cnt;
        }

        if (cnt >= M) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, m, x;
ll mat[15][15], c[15];
ll ans = 1e18;

void call(int i, int mask){
  if(i == n){
    std::vector<int> v(m, 0);
    ll cost = 0;
    for(int k = 0; k < n; k++){
      if(mask & (1 << k)){
        cost += c[k];
        for(int j = 0; j < m; j++){
          v[j] += mat[k][j];
        }
      }
    }
    for(int k = 0; k < m; k++){
      if(v[k] < x) return;
    }
    ans = min(ans, cost);
    return;
  }
  call(i + 1, mask);
  call(i + 1, mask | (1 << i));
}

int main() {

  cin >> n >> m >> x;

  for(int i = 0; i < n; i++){
    cin >> c[i];
    for(int j = 0; j < m; j++){
      cin >> mat[i][j];
    }
  }
  call(0, 0);
  if(ans == 1e18)cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  int n;cin >>n;
  int ans=n;
  if(n%2==1){ans*=2;}
  cout << ans << endl;
}


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


#define BUFSIZE 100
int main(){
  char buf[BUFSIZE];
  int a;
  int b;
  int m;
  int d;

  while(scanf("%d %d", &a, &b) == 2){
    m = a+b;
    if(m){
      d = 0;
      while(m>0){
        m = m/10;
        d++;
      }
    }else{
      d = 1;
    }
    printf("%d\n", d);
  };
  return 0;
}

Measured memory_bytes: 0
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val ab = Array.fill(n)(readLine().split(" ").map(_.toInt))
    .map(list => (list(0), list(1)))
    .sortBy(_._2)

  def solve(): String = {
    ab.foldLeft(0L) { case(acc, (a,b)) =>
      if(acc+a > b) return "No"
      else acc+a
    }
    "Yes"
  }

  println(solve())

}



Measured memory_bytes: 72024
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

ll ans(ll a){
	ll ret=0;
	for(int i=57;i>=0;i--){
		ll pos=(1ll<<i);
		if(i==0){
			if(a%4<=2&&a%4>=1) ret++; 
		}
		else if(a/pos&&((a&1)==0)){
			ret^=pos;
		}
		if(i>1)a%=pos;
		//cout<<a<<endl;
	}
	return ret;
}

int main(){
	ll n,m,c;
	cin>>n>>m>>c;
	ll b[m];
	ll a[n][m];
	rep0(j,m) cin>>b[j];
	rep0(i,n)rep0(j,m) cin>>a[i][j];
	ll ans=0;
	rep0(i,n){
		ll pos=0;
		rep0(j,m) pos+=a[i][j]*b[j];
		if(pos+c>0)ans++;
	}
	cout<<ans<<endl;

      return 0;
}

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

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

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


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

int main(){
    long long n,d;
    cin >> n >> d;
    int count = 0;
    for(int i=0;i<n;i++){
        long long x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d){
            count++;
        }
    }
    cout << count << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string s;cin>>s;
	int x=s.size();
	if(x%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<x-1;i+=2){
		if(s[i]!='h'||s[i+1]!='i'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

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

int main() {
  int N, K; cin >> N >> K;
  int H[N]; for (int i = 0; i < N; i++) cin >> H[i];
  int dp[N]; dp[0] = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = 1e+9;
    for (int j = 1; j <= K; j++)
      if (i >= j) dp[i] = min(dp[i], dp[i-j] + abs(H[i-j] - H[i]));
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 4332
import java.io.BufferedReader
import java.io.BufferedWriter

fun main() = Case().exec(::solve)
//fun main() = TestExecutor.assert(testCase) { Case(it.r, it.w).exec(::solve) }

fun solve(c: Case) {
    val (n, m) = c.intList()
    val edges = (0 until m).map { c.intList() }
    val tree = UnionFind(n)
    edges.forEach { (x, y) -> tree.unite(x - 1, y - 1) }
    c.println((0 until n).map { tree.root(it) }.groupBy { it }.values.map { it.size }.max().toString())
}

class UnionFind(n: Int) {
    val par = (0 until n).toMutableList()

    fun root(x: Int): Int = if (par[x] == x) x else root(par[x]).also { par[x] = it }
    fun same(x: Int, y: Int): Boolean = root(x) == root(y)
    fun unite(x: Int, y: Int) {
        val rx = root(x)
        val ry = root(y)
        if (rx != ry) par[rx] = ry
    }
}

class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) =
        input.use { out.use { Thread(null, { fn(this) }, "solve", 64 * 1024 * 1024).also { it.start() }.join() } }

    fun println(c: CharSequence?) = out.appendln(c)
    fun string(): String = input.readLine().trimEnd()
    fun long(): Long = input.readLine().toLong()
    fun intList(): List<Int> = input.readLine().split(" ").map { it.toInt() }
    fun longList(): List<Long> = input.readLine().split(" ").map { it.toLong() }
}

Measured memory_bytes: 114932
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/

#include <bits/stdc++.h>
using namespace std;

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*********************************!Template Ends Here!**********************************//

const int nn = 2e5+5;

void robin(){
    string s;
    cin >> s;
    int ans = 0, n = szz(s);
    int cnt = 0;
    for(int i = n-1; i >= 0; i--){
        if(i-1 >= 0 and s[i] == 'C' and s[i-1] == 'B') {
            cnt++;
            i--;
        }
        else if(cnt and s[i] == 'A'){
            ans += cnt;
        }
        else cnt = 0;
    }
    cout << ans;
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        robin();
    }
    return 0;
}

Measured memory_bytes: 720
while True:
  n, p = map(int, input().split())
  if n == 0:
    break
  lst = [0] * n
  ind = 0
  rest = p
  while True:
    if rest == 0:
      rest = lst[ind]
      lst[ind] = 0
    else:
      lst[ind] += 1
      rest -= 1
      if lst[ind] == p:
        print(ind)
        break
    ind = (ind + 1) % n



Measured memory_bytes: 5592
def count_hotels(n, hs):
    res = 1 + sum(all(hs[j] <= hs[i] for j in range(i)) for i in range(1, n))
    return res


def main():
    n = int(input())
    hs = [int(h) for h in input().split()]
    print(count_hotels(n, hs))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n,m=gets.split.map(&:to_i)
as=m.times.map{gets.to_i}
stairs=[0]*(n+1)
m.times{|i| stairs[as[i]]=nil}
stairs[0]=1
stairs[1]= as[0]!=1 ? 1:0
2.upto(n) do |j|
  stairs[j]= stairs[j] ? stairs[j-1]+stairs[j-2]:0
end
puts stairs[n]%1000000007


Measured memory_bytes: 433020
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	int q;
	cin>>q;
	while(q--){	
		int left=0;
		int right=n;
		int k;
		cin>>k;
		while(left<right){
			int middle=(left+right)/2;
			if(a[middle]<k){
				left=middle+1;
			}
			else if(a[middle]>k){
				right=middle;
			}
			else{
				cout<<1<<endl;
				break;
			}
		}
		if(left==right)	cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void){
	string S;
	cin >> S;
	vector<bool> check = vector<bool>(S.size(), true);
	bool loop = true;
	int result = 0;
	while(loop){
		loop = false;
		for(int index = 0; index < S.size() - 1; ++index){
			if(!check[index]){
				continue;
			}
			for(int back = index, next = index + 1; back > -1 && next < S.size(); --back,  ++next){
				if(!check[back]){
					break;
				}
				if(!check[next]){
					++back;
					continue;
				}
				if(S[back] == S[next]){
					break;
				}
				result += 2;
				loop = true;
				check[back] = false;
				check[next] = false;
			}
		}
	}

	cout << result << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {

	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int ans = 0;
	if (K <= A) {
		ans = K;
	}
	else if (K <= A + B) {
		ans = A;
	}
	else {
		ans = A - (K - A - B);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  int sum=0;
  for (int i = 0; i < s.size(); ++i)
  {
    sum+=s[i]-'0';
    sum%=9;
  }
  if(sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3720
g = gets.chomp
a = g[0].to_i
b = [true, false]
c = 1
while b[(1 + a ** 2) ** -(a ** 2)]
        puts "Case " + c.to_s + ": " + g
        c += 1
        g = gets.chomp
        a = g[0].to_i
end

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
llint mod = 1000000007;

int main() {
  int n;
  cin >> n;
  llint sum = n + 1;
  sum *= n;
  sum /= 2;
  int n3 = n/3;
  int n5 = n/5;
  int n15 = n/15;
  llint s3 = 0,s5 = 0,s15 = 0;
  s3 = (1 + n3) * 3;
  s3 *= n3;
  s3 /= 2;
  sum -= s3;
  s5 = (1 + n5) * 5;
  s5 *= n5;
  s5 /= 2;
  sum -= s5;
  s15 = (1 + n15) * 15;
  s15 *= n15;
  s15 /= 2;
  sum += s15;
  printf("%lld\n", sum);
} 

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

int main() {
  int a, b;
  cin >> a >> b;
  int total = 0;

  for (int i=a;i<b+1;i++) {
    int man = i / 10000;
    int sen = i % 10000 / 1000;
    int hyaku = i % 1000 / 100;
    int zyuu = i % 100 / 10;
    int iti = i % 10 / 1;

    if (man == iti && sen == zyuu) {
      total += 1;
    };
  }

  cout << total << endl;

  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

int main()
{
	int n; cin>>n;
	vi id(n),dist(n),box(n);
	rep(i,n)
		cin>>id[i]>>dist[i]>>box[i];
	
	//vvd dp(1<<n,vd(n,1e10));
	//vvi prev(1<<n,vi(n));
	static double dp[1<<15][15];
	static int prev[1<<15][15]={};
	rep(i,1<<15)
		fill(dp[i],dp[i]+15,1e10);
	rep(i,n){
		dp[1<<i][i]=0;
		prev[1<<i][i]=-1;
	}
	rep(i,1<<n){
		int weight=0;
		rep(j,n)
			if(1<<j&i)
				weight+=box[j]*20;
		rep(j,n) rep(k,n){
			if(!((1<<j)&i) || ((1<<k)&i))
				continue;
			double time=dp[i][j]+abs(dist[k]-dist[j])/(2000.0/(70+weight));
			if(dp[i|(1<<k)][k]>time){
				dp[i|(1<<k)][k]=time;
				prev[i|(1<<k)][k]=j;
			}
		}
	}
	
	vi res;
	{
		int i=0;
		rep(j,n)
			if(dp[(1<<n)-1][j]<dp[(1<<n)-1][i])
				i=j;
		for(int j=(1<<n)-1;i!=-1;){
			res.push_back(i);
			int ii=prev[j][i];
			int jj=j^(1<<i);
			i=ii;
			j=jj;
		}
	}
	
	reverse(allof(res));
	rep(i,res.size())
		printf("%d%c",id[res[i]],i==res.size()-1?'\n':' ');
	
	return 0;
}

Measured memory_bytes: 6628
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,f[3010][3010][2],res;//0: haven't reached 0; 1:have reached 0
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;i++)f[0][i][i==0]=1;
	for(int i=0;i<m;i++)for(int j=0;j<=n;j++){
		if(j)(f[i+1][j][j==1]+=f[i][j][0])%=mod,(f[i+1][j][1]+=f[i][j][1])%=mod;//-+
		if(j)(f[i+1][j-1][j==1]+=f[i][j][0])%=mod,(f[i+1][j-1][1]+=f[i][j][1])%=mod;//--;
		if(j<n)(f[i+1][j][0]+=f[i][j][0])%=mod,(f[i+1][j][1]+=f[i][j][1])%=mod;//+-;
		if(j<n)(f[i+1][j+1][0]+=f[i][j][0])%=mod,(f[i+1][j+1][1]+=f[i][j][1])%=mod;//++;
	}
	for(int i=0;i<=n;i++)(res+=f[m][i][1])%=mod;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 74208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string a,b;
  cin >> a >> b;
  if(a.size()>b.size()){
    cout << "GREATER" << endl;
  }else if(a.size()<b.size()){
    cout << "LESS" << endl;
  }else{
    if(a>b){
      cout << "GREATER" << endl;
    }else if(a<b){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }
  }
}


Measured memory_bytes: 256
def main():
    alice, bob = map(int, input().split())
    answer = ""
    if alice == bob:
        answer = "Draw"
    elif alice == 1 or (alice > bob and not bob == 1):
        answer = "Alice"
    else:
        answer = "Bob"
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


def main():
    K = int(input())

    ans = 0
    # a < b < c
    x = 0
    for a in range(1, K - 1):
        for b in range(a + 1, K):
            for c in range(b + 1, K + 1):
                x += gcd(gcd(a, b), c)

    y = 0
    # a = b != c
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            if b == c:
                continue
            y += gcd(b, c)
    z = 0
    for a in range(1, K + 1):
        z += a

    ans += 6 * x
    ans += 3 * y
    ans += z

    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 72072
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    ll mod = 1e9+7;
    int n;  cin >> n;
    ll *a = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<int> b((int)1e6+1, 0);

    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0)
            ans *= 3-b[0];
        else 
            ans *= b[a[i]-1]-b[a[i]];
        b[a[i]]++;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8020
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N, M; cin >> N >> M;
	vi s(M, 0), p(M);
	rep(i, M) {
		int k; cin >> k;
		rep(j, k) {
			int si; cin >> si;
			s[i] += pow(2, si - 1);
		}
	}
	rep(i, M) cin >> p[i];
	int ans = 0;
	rep(i, pow(2, N)){
		int f = 1;
		rep(j, M) {
			int tmp = __builtin_parityll(s[j] & i);
			if (tmp != p[j]) f = 0;
		}
		if (f) ans++;
	}
	cout << ans << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

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

int n,m;

bool on[1010];

int main(void){
	while(cin >> n >> m,n){
		rep(i,n) on[i]=true;
		int ans=0;
		int cur=n-1;
		rep(i,n){
			rep(loop,m){
				cur=(cur+1)%n;
				while(!on[cur]) cur=(cur+1)%n;
			}
			on[cur]=false;
			ans=cur+1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair


int n, y;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n >> y;

rep(i, 0, n){
    rep(j, 0, n-i){
    if(i*10000 + j*5000 + (n-j-i)*1000 == y){
        cout << i << " " << j << " "<< n-i-j << endl;
        return 0;
    }
    }
}

cout << -1 << " "<< -1 << " "<< -1 << endl;

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll x, k, d;
    cin >> x >> k >> d;

    ll t = abs(x) / d;
    x = abs(x);

    if (k <= x / d)
    {
        cout << abs(x - d * k) << endl;
        exit(0);
    }
    else
    {
        x %= d;
        k -= t;

        if (k % 2 == 0)
        {
            cout << x << endl;
        }
        else
        {
            cout << abs(x - d) << endl;
        }
    }

}

Measured memory_bytes: 3632
from sys import stdin
S = stdin.readline().rstrip()
len_S = len(S)
if len_S % 2 == 0:
    atcodeer = "gp"*(len_S//2)
else:
    atcodeer = "gp"*(len_S//2)+"g"

ans = 0
for s1, s2 in zip(S, atcodeer):
    if s1 == 'g' and s2 == 'p':
        ans += 1
    elif s2 == 'g' and s1 == 'p':
        ans -= 1
print(ans)

Measured memory_bytes: 41580
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
typedef signed long long sll;
typedef unsigned long long ull;

int prefs[100001];
int xs[100001];
int ids[100001];

int main() {
    init();
    sll n, m;
    cin >> n >> m;
    vector<pair<sll, sll> > cities(m);
    REP(i, m) {
        sll p, y;
        cin >> p >> y;
        cities[i] = make_pair(y, i);
        prefs[i] = p;
    }

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

    for (auto &t: cities) {
        ids[t.second] = 1 + xs[prefs[t.second]]++;
    }

    REP(i, m) {
        cout << setfill('0') << setw(6) << prefs[i] << setfill('0') << setw(6) << ids[i] << endl;
    }

    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 4224
from collections import Counter

s = list(input())
ss = s

ans = float("inf")

for target in list(set(s)):
	s = ss
	num = 0
	while len(set(s)) > 1:
		t = []
		for i in range(len(s)-1):
			if s[i] == target or s[i+1] == target:
				t.append(target)
			else:
				t.append(s[i])
		s = t
		num += 1
	if num < ans:
		ans = num

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <set>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    set<uint> s;
    cin >> N;
    for (auto &&i: irange(0U, N)){
        uint a;
        cin >> a;
        auto it = s.find(a);
        if (it != s.end()){
            s.erase(a);
        } else {
            s.insert(a);
        }
    }
    cout << s.size();
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
map<int,int>m;
int a[200010];
int main()
{
    int n,x;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&x);
        a[i]=x;
        m[x]++;
    }
    sort(a,a+n);
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
        int v=a[i];
        if(m[v])
        {
            m[v]--;
            int t=0;
            while((1<<t)<=v)
                t++;
            int k=(1<<t)-v;
            if(m[k])
            {
                ans++,m[k]--;
            }
        }
    }
    printf("%d\n",ans);
    return 0 ;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli N=109;
lli n, b[N], kq=0;
int main()
{
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		cin>>b[i];
	}
	kq=b[2]*2;
	for(int i=3;i<=n;i++)
	{
		if(b[i]<=b[i-1])
		{
			kq+=(b[i]-b[i-1])+b[i];
		}
		else
		{
			kq+=b[i];
		}
	}
	cout<<kq;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int n=32;
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int m;
  cin>>m;
  cout<<a[m-1];
}

Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2019-07-17.
//

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

ll my_log2(ll x) {
    ll ret = 0;
    while (x % 2 == 0) {
        ret++;
        x /= 2;
    }
    return ret;
}

int main() {
    ll N, a, res = 0;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> a;
        res += my_log2(a);
    }

    cout << res << endl;

    return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0) cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


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


int main(){
    map<ll,int> m;
    int n;
    cin >> n;
    bool f=true;
    for (int i=0;i<n;i++){
        int t;
        cin >> t;
        if (m.count(t)){
            cout << "NO" << endl;
            f=false;
            return 0;
        }
        else m[t]++;
    }
    if (f) cout << "YES" << endl;
    return 0;  
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n;
    cin>>n;
    vector<int>vec(n+1);
    for(int i = 0; i < n ; i++ ) cin>>vec[i];
    ll money = 1000;

    for(int i = 1 ; i <=n ; i++ ) {
        if(vec[i] > vec[i-1]) {
            ll stk = money/vec[i-1];
            ll rem = money % vec[i-1];
            money = stk *vec[i] + rem;
        }
    }
    cout<<money<<'\n';
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    int ct=0;
    while(a>0 && b>0){
      if(ct%2==0) c-=b;
      else a-=d;
      
      if(a<=0){ 
        cout<<"No"<<endl;
        break;
      }
      else if(c<=0){
        cout<<"Yes"<<endl;
        break;
      }
      ct++;
    }
    
    
}


Measured memory_bytes: 3632
N,K = input().split()
N = int(N)
K = int(K)

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 99999999999
for i in range(N-K+1) :
	max_v = trees[i+K-1]
	min_v = trees[i]
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff == 0) :
		break



print(min_diff)

Measured memory_bytes: 7388
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005
/* The judge is never wrong! Your code is buggy ??
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */




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

       int n;
       cin >> n;
       int i,a[n+1];
       int f[n+1];
       mem(f,0);
       for(i=1; i<n; i++){
           cin >> a[i];
           //cout << a[i];
           f[a[i]]++;
       }
       for(i=1; i<=n; i++){
           cout << f[i] << '\n';
       }
}


Measured memory_bytes: 6768
#include <stdio.h>

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

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;

ll MOD = 1e9+7;


template <typename T>
class Rerooting{
public:
	vector<vector<int>> edge;
	vector<map<int,T>> memo;

	struct Solver {
		virtual T init() const = 0;
		virtual T merge(T, T) const = 0;
		virtual T add_me(T) const = 0;
	};
	const Solver *solver;

	const T init_value;

	Rerooting(int N, const Solver *solver) :
		edge(N),
		memo(N),
		solver(solver),
		init_value(solver->init())
	{ }

	void add_edge(int u, int v) {
		edge[u].push_back(v);
		edge[v].push_back(u);
	}

	T dfs(int n, int b = -1) {
		T ret = init_value;
		for(auto t: edge[n]) if(t != b) {
			ret = solver->merge(ret, dfs(t, n));
		}
		return memo[n][b] = solver->add_me(ret);
	}

	void dfs2(int n, int b = -1) {
		// 累積を計算しておく
		const int sz = edge[n].size();
		T sumL[sz], sumR[sz];
		sumL[0] = init_value;
		rep(i, sz) {
			int t = edge[n][i];
			sumL[i+1] = solver->merge(sumL[i], memo[t][n]);
		}
		sumR[sz] = init_value;
		rrep(i, edge[n].size()) {
			int t = edge[n][i];
			sumR[i] = solver->merge(sumR[i+1], memo[t][n]);
		}

		// nが根のときの解をメモ
		memo[n][-1] = solver->add_me(sumR[0]);

		rep(i, sz) {
			int t = edge[n][i];
			if(t != b) {
				// 累積から逆方向の辺を計算。 1つの辺につき O(1)
				auto ret = solver->merge(sumL[i], sumR[i+1]);
				memo[n][t] = solver->add_me(ret);

				// 出ていく辺がすべて計算済みになった頂点は処理可能
				dfs2(t, n);
			}
		}
	}

	T solve(int n, int b = -1) {
		if(memo[n].count(b)) return memo[n][b];

		dfs(n);
		dfs2(n);

		return memo[n][b];
	}
};

struct Solver: Rerooting<ll>::Solver {
	ll init() const override {
		return 1;
	}

	ll merge(ll a, ll b) const override {
		return a * b % MOD;
	}

	ll add_me(ll a) const override {
		return a + 1;
	}
};

int main(){
	ios_base::sync_with_stdio(false);

	int N;
	cin >> N >> MOD;
	Rerooting<ll> rr(N, new Solver());
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		rr.add_edge(a, b);
	}

	rep(i,N) cout << rr.solve(i) - 1 << "\n";

	return 0;
}

Measured memory_bytes: 45568
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

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


ll lcm(ll a,ll b){
    return ( a*b/__gcd(a,b));
}



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


Measured memory_bytes: 384
# ABC117D

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

ans = 0
for d in range(40, -2, -1):
    if d != -1 and not (K & 1 << d):
        continue
    
    tmp = 0
    for e in range(40, -1, -1):
        mask = 1 << e
        num_1 = 0
        for i in range(N):
            if A[i] & mask:
                num_1 += 1
        if e > d:
            if K & mask:
                tmp += mask * (N - num_1)
            else:
                tmp += mask * num_1
        elif e == d:
            tmp += mask * num_1
        else:
            tmp += mask * max(num_1, N - num_1)
    
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 69772
#include<stdio.h>
#include<string.h>

int main(){
	char s[20];
	char an1[20], an2[20], an3[20], an4[20], an5[20];
	strcpy(an1, "hi");
	strcpy(an2, "hihi");
	strcpy(an3, "hihihi");
	strcpy(an4, "hihihihi");
	strcpy(an5, "hihihihihi");

	gets(s);

	if(!(strcmp(s, an1)) || !(strcmp(s, an2)) || !(strcmp(s, an3)) || !(strcmp(s, an4)) || !(strcmp(s, an5)))puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		for(;;){
			
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int sum = 0;
			int max = 0;
			int min = 1000;
			for(int i = 0; i < n ; i++){
				int s = sc.nextInt();
				min = Math.min(min, s);
				max = Math.max(max, s);
				sum += s;
			}
			
			System.out.println((sum-min-max)/(n-2));
			
			
		}
	}
}



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

#define INF 1120000000

int main(){
  int n,k;
  cin>>n>>k;
  int ans = 0;
  rep(i,n){
    int x;
    cin>>x;
    ans += 2*min(x, k-x);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  bool ok = true;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      if (s[i] == s[j]) ok = false;
    }
  }
  
  if (ok)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

Measured memory_bytes: 256