akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    bool t = true;
    set<string> s;
    string st; cin >> st;
    s.insert(st);
    rep(i,n-1){
        string a; cin >> a;
        if (st[st.size()-1] != a[0] || s.find(a) != s.end()){
            t = false;
        }
        st = a;
        s.insert(st);
    }
    if (t) yes();
    else no();
}

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

int border[9] = {
    400,
    600,
    800,
    1000,
    1200,
    1400,
    1600,
    1800,
    2000
};

int main() {
    int x = 0;
    cin >> x;
    for (int i = 0; i < 9; ++i) {
        if (x < border[i]) {
            cout << 9 - i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int N, K; std::cin >> N >> K;
	std::vector<int> X(N);
	int count = 0;
	for (auto& r : X) {
		std::cin >> r;
		if (r > std::abs(K - r))
			count += std::abs(K - r) * 2;
		else
			count += r * 2;
	}
	std::cout << count << std::endl;

	return 0;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 2018;

ll n, k, tmp, MX, ans;
vector <ll> adj[maxn];
vector <pll> ed;

void dfs(ll v, ll par, ll lvl) {
	if (lvl	> MX)
		return;
	tmp++;
	for (auto u : adj[v]) {
		if (u == par)
			continue;
		dfs(u, v, lvl + 1);
	}
}

int main() {
	cin >> n >> k;
	ll fr, to;
	for (int i = 1; i < n; i++) {
		cin >> fr >> to;
		adj[fr].pb(to);
		adj[to].pb(fr);
		ed.pb({fr, to});
	}
	MX = k / 2;
	if (k & 1) {
		for (int i = 0; i < ed.size(); i++) {
			ll v = ed[i].first, u = ed[i].second;
			tmp = 0;
			dfs(v, u, 0);
			dfs(u, v, 0);
			ans = max(ans, tmp);	
		}
	} else {
		for (int i = 1; i <= n; i++) {
			ll v = i;
			tmp = 0;
			dfs(v, v, 0);
			ans = max(ans, tmp);
		//	cout << v << " -> " << tmp << endl;
		}
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[200000],b[200000];
int main()
{
	int i,n,x1,x2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	x1=b[n/2-1];
	x2=b[n/2+1-1];
	for(i=0;i<n;i++)
	{
		if(a[i]<=x1)
		{
			printf("%d\n",x2);
		}
		else
		{
			printf("%d\n",x1);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
#define pb push_back
// to floor a/b you can do a/b and to ceiling a/b you can do (a+b-1)/b
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=(r%mod * x%mod)%mod;
        x=(x%mod * x%mod)%mod;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=(c[j]%mod + c[j-1]%mod)%mod;
    }
    return c[k];
}

bool prime[1001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100;j=j+i)
                prime[j]=false;
        }
    }
}
//Start of Matrix Exponentiation Code
void mat_mul(ll F[2][2],ll M[2][2]) {
   ll a = ((F[0][0]%mod * M[0][0]%mod)%mod + (F[0][1]%mod * M[1][0]%mod)%mod)%mod;
   ll b = ((F[0][0]%mod * M[0][1]%mod)%mod + (F[0][1]%mod * M[1][1]%mod)%mod)%mod;
   ll c = ((F[1][0]%mod * M[0][0]%mod)%mod + (F[1][1]%mod * M[1][0]%mod)%mod)%mod;
   ll d = ((F[1][0]%mod * M[0][1]%mod)%mod + (F[1][1]%mod * M[1][1]%mod)%mod)%mod;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void mpower(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   mpower(F, n / 2);
   mat_mul(F, F);
   if (n % 2 != 0)
      mat_mul(F, M);
}
ll fib_mat(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   mpower(F, n - 1);
   return F[0][0]%mod;
}
//End of Matrix Exponentiation
/*
Segment Tree
ll ar[200005];
ll st[800005];
void build(ll si,ll ss,ll se)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return ;
    }
    ll mid=(ss+se)/2;
    build(2*si,ss,mid);
    build(2*si+1,mid+1,se);
    st[si]=(st[2*si]+st[2*si+1]);
}
ll query(ll si,ll ss,ll se,ll l,ll r)
{

   if(l<=ss && se<=r)
     return st[si];
   if(l>se || r<ss)
    return 0;
   ll mid=(ss+se)/2;
   ll x=query(2*si,ss,mid,l,r);
   ll y=query(2*si+1,mid+1,se,l,r);
   return x+y;
}
void update(ll si,ll ss,ll se,ll qi)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return;
    }
    ll mid=(ss+se)/2;
    if(qi<=mid)
        update(2*si,ss,mid,qi);
    else
        update(2*si+1,mid+1,se,qi);
    st[si]=st[2*si]+st[2*si+1];
}
*/


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
	return 0;
}


Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string X; cin>>X;
  ll N=X.size();
  ll count=0,snum=0;
  rep(i,N){
    if(X[i]=='S') snum++;
    else if(snum>0) {snum--; count+=2;}
  }
  
  cout<<N-count<<'\n';
  
  return 0;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		if(n/100 > 0 && n/100 < 13) {
			if(n%100 > 0 && n%100 < 13) {
				System.out.println("AMBIGUOUS");
			}else {
				System.out.println("MMYY");
			}
		}else {
			if(n%100 > 0 && n%100 < 13) {
				System.out.println("YYMM");
			}else {
				System.out.println("NA");
			}
		}

	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define sc second
#define inf    1000000000LL
#define MP make_pair
#define N 
#define MOD 1000000007
#define orta ((a+b)/2)
using namespace std;
typedef long long int lint;
typedef pair<int,int> ii;



/*
   A!
---------
B! * (A-B)!

*/
int n,t;
int d[30004],k;
lint dp[305][305][305];
lint fon(int a,int k,int b)
{
	if(a==n+1) return 0;
	if(dp[a][k][b]!=-1) return dp[a][k][b];
	if(k==0)
		return dp[a][k][b]=fon(a+1,k,a)+max(0,d[a]-d[b]);
	return  dp[a][k][b]=min(fon(a+1,k,a)+max(0,d[a]-d[b]) , fon(a+1,k-1,b));
}
int main()
{
	memset(dp,-1,sizeof dp );
	scanf("%d %d",&n,&k);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d",&d[i]);
	}
	cout << fon(0,k,0);
}

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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> H(N);
    for(int i=0; i<N; i++) cin >> H[i];

    int ans = 0;
    for(int h : H){
        if(h >= K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
S = input()
a = len(S)
k1 = ''
k2 = ''
res = 0
if a % 2 == 0:
    for i in range(0,a//2):
        k1 += S[i]
    for i in range(a//2,a):
        k2 += S[i]
else:
    for i in range(0,(a-1)//2):
        k1 += S[i]
    for i in range((a-1)//2 + 1,a):
        k2 += S[i]
for i in range(len(k1)):
    if k1[i] != k2[(len(k1)-i-1)]:
        res += 1 
print(res)

Measured memory_bytes: 3064
unittest
{
	assert( [ "3 3 2", "1 2", "5 4", "9 2" ].solve == 2 );
	assert( [ "9 4 1", "1 5", "2 4", "3 3", "4 2", "5 1", "6 2", "7 3", "8 4", "9 5" ].solve == 5 );
	assert( [ "3 0 1", "300000000 1000000000", "100000000 1000000000", "200000000 1000000000" ].solve == 3000000000 );
	
	assert( [ "9 2 2", "1 3", "2 4", "3 3", "4 2", "5 5", "6 2", "7 3", "8 4", "9 5" ].solve == 5 );		// 追加ケース
}



import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto d = 0L;
	auto a = 0L;
	input.front.formattedRead!"%s %s %s"( n, d, a );
	auto xhs = new long[ 2 ][ n ];
	foreach( ref xh; xhs )
	{
		input.popFront;
		xh = input.front.split.to!( long[] );
	}
	xhs.sort;
	
	auto ans = 0L;
	auto t = 0L;
	auto queue = DList!( Tuple!( long, long ) )();
	foreach( xh; xhs )
	{
		while( !queue.empty && queue.front[ 0 ] < xh[ 0 ] )
		{
			t -= queue.front[ 1 ];
			queue.removeFront;
		}
		if( t < xh[ 1 ] )
		{
			auto c = ( xh[ 1 ] - t + a - 1 ) / a;
			ans += c;
			t += a * c;
			queue.insertBack( tuple( xh[ 0 ] + d * 2, a * c ) );
		}
	}
	return ans;
}


Measured memory_bytes: 9292
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    string S, T;
    cin >> S >> T;
    unordered_map<char,int> a;
    unordered_map<char,int> b;
    string t, s;
    for(int i = 0;i < S.length();i++){
        a[S[i]]++;
        b[T[i]]++;
    }
    for(int i = 0;i < S.length();i++){
        s += a[S[i]];
    }

    for(int i = 0;i < S.length();i++){
        t += b[T[i]];
    }

    if(s == t)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 1168
#include<stdio.h>

int main(void){
	int a,b,c;
	int mat[10] = {};

	scanf("%d %d %d",&a,&b,&c);

	mat[a]++;
	mat[b]++;
	mat[c]++;

	if(mat[5] == 2 && mat[7] == 1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#define rep(i,rept) for(long long i = 0; i <(long long)rept;i++)
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0, count = 0,x=0,y=0,z=0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami, mado[50];
	bool gg = true;
	int manji, nk[26] = { false };
	cin >> count >> a >> b >> x >> y;
	if (count%a == 0) {
		c = count / a;
	}
	else { c = count / a + 1; 
	}
	if (count%x == 0) {
		z = count / x;
	}
	else { z = count / x + 1; 
	}
	cout << min(z*y, c*b) << endl;
	return 0;
}



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

int calc(char *s, char *end)
{
	/*for (char *p = s; p != end; p++) printf("%c", *p);
	puts("");*/
	
	bool f = false;
	
	vector<int> st;
	vector<char> op;
	
	char *p = s;
	while (p != end){
		if (!f) if (*p == '('){
			char *e = p + 1;
			int cnt = 1;
			while (true){
				if (*e == '(') cnt++;
				if (*e == ')') cnt--;
				if (cnt == 0) break;
				e++;
			}
			st.push_back(calc(p + 1, e));
			p = e;
		}
		if (f) if (*p == '+' || *p == '-' || *p == '*' || *p == '/'){
			op.push_back(*p);
			p++;
			f ^= 1;
			continue;
		}
		if (!f) if (*p >= '0' && *p <= '9'){
			int n = atoi(p);
			st.push_back(n);
			stringstream ss;
			ss << n;
			p += ss.str().size() - 1;
		}
		if (!f) if (*p == '-'){
			int n = atoi(p);
			st.push_back(n);
			stringstream ss;
			ss << n;
			p += ss.str().size() - 1;
			//printf("%s\n", ss.str().c_str());
		}
		if (op.size() && (op.back() == '*' || op.back() == '/')){
			int b = st.back(); st.pop_back();
			int a = st.back(); st.pop_back();
			if (op.back() == '*') a *= b;
			if (op.back() == '/') a /= b;
			st.push_back(a);
			op.pop_back();
		}
		p++;
		f = !f;
		/*printf("__");
		for (auto a : st) printf("%d ", a);
		puts("");*/
	}
	
	while (op.size()){
		int t = st.front(); st.erase(st.begin());
		/*if (st.size() == 0){
			if (op.front() == '-') st.push_back(-t);
			else st.push_back(t);
			op.erase(op.begin());
			break;
		}*/
		if (op.front() == '+') st[0] = t + st[0];
		if (op.front() == '-') st[0] = t - st[0];
		op.erase(op.begin());
	}
	
	return st[0];
}

int main()
{
	int n;
	char str[1024];
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%s", str);
		str[strlen(str) - 1] = '\0';
		printf("%d\n", calc(str, str + strlen(str)));
	}
	
	return 0;
}

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

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

  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];
  for (int i = 0; i < 5; ++i) if (x[i] == 0) cout << i + 1 << endl;

  return 0;
}



Measured memory_bytes: 3644
A, B, K = map(int, input().split())
ans_a = 0
ans_b = 0
if A > K:
  ans_a = A - K
  ans_b = B
else:
  ans_a = 0
  if B > K - A:
    ans_b = (B-(K-A))
  else:
    ans_b = 0
print("{} {}".format(ans_a,ans_b))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld %lld",&n,&m,&k);
  if(n-k>=0) printf("%lld %lld",n-k,m);
  else if(n+m-k>=0) printf("0 %lld",m-(k-n));
  else printf("0 0");
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
cnt_a = cnt_b = cnt_ba = 0
ans = 0
for _ in range(n):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B':
        cnt_b += 1
        if s[-1] == 'A':
            cnt_ba += 1
    if s[-1] == 'A':
        cnt_a += 1

# print(ans, cnt_a, cnt_b)
if cnt_a == cnt_b == n:
    ans += n - 1
elif cnt_ba > 0 and cnt_a == cnt_b == cnt_ba:
    ans += cnt_ba - 1
else:
    ans += min(cnt_a, cnt_b)
print(ans)


Measured memory_bytes: 9180
x=int(input())
a=0
b=0
def f(n):
    n1 = n**(1/5)
    if n1==int(n1):
        return True

l=set()
l.add(0)
i=1
while i**5<100*x:
    i1=i**5
    l.add(i1)
    if i%2==1:
        l.add(-i1)
    i+=1

for i in l:
    b=i
    a=x+b
    if a in l:
        if a!=0 and b!=0:
            a1=(a/abs(a))*(abs(a)**(1/5))
            b1=(b/abs(b))*(abs(b)**(1/5))
            print(int(a1),int(b1))
        elif b==0:
            a1=(a/abs(a))*(abs(a)**(1/5))
            print(int(a1),0)
        else:
            b1=(b/abs(b))*(abs(b)**(1/5))
            print(0,int(b1))
        break

Measured memory_bytes: 9456
k, n = map(int, input().split())
a = [int(i) for i in input().split()]
ans = a[0]+(k-a[n-1])

for i in range(n):
    if i == 0 or i==n-1:
        continue
    else:
        ans = max(ans, abs(a[i]-a[i-1]), abs(a[i]-a[i+1]))
print(k-ans)

Measured memory_bytes: 24564
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rrep(i, n) {
        int a;
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3572
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/



void proc() {
	LOAD(int, R);
	LOAD(int, G);
	LOAD(int, B);
	LOAD(int, N);
	int res = 0;
	for (int r = 0; r <= N; ++r) {
		for (int g = 0; g <= N; ++g) {
			int n = N - r * R - g * G;
			if (n >= 0 && n % B == 0)++res;
		}
	}
	cout << res << endl;
}


#endif


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();
		int[] l = new int[q];
		int[] r = new int[q];
		for (int i = 0; i < q; i++) {
			l[i] = in.nextInt();
			r[i] = in.nextInt();
		}
		solve(s, l, r);
		in.close();
	}

	private static void solve(String s, int[] l, int[] r) {
		int[] c = new int[s.length() - 1];
		int ct = 0;
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C')
				ct++;
			c[i] = ct;
		}
		for (int i = 0; i < l.length; i++)
			if (l[i] == 1)
				System.out.println(c[r[i] - 2]);
			else
				System.out.println(c[r[i] - 2] - c[l[i] - 2]);
	}
}

Measured memory_bytes: 91556
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp0 = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0(u, p));
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				es[f.u].Remove(f.p);
				st.Push(new A0(f.u, -1));
				foreach (var v in es[f.u]) st.Push(new A0(v, f.u));
			}
			else
			{
				dp0[f.u] = 1L;
				foreach (var v in es[f.u]) dp0[f.u] = dp0[f.u] * (dp0[v] + 1) % Mod;
			}
		}
		return dp0;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp1 = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			var x = new long[W + 1];
			var y = new long[W + 1];
			x[0] = y[W] = 1;
			for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
			x = y = null;
			foreach (var v in es[u]) st.Push(v);
		}
		return dp1;
	}
}
struct A0 { public int u, p; public A0(int u, int p) { this.u = u; this.p = p; } }


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

ll n,m;
struct Edge {
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main(){
    cin >> n >> m;
    Graph G(n);
    ll a[m];
    ll b[m];
    ll c[m];
    ll dist[n][n];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(i==j) dist[i][j]=0;
            else dist[i][j]=1e9;
        }
    }
    for(ll i=0;i<m;i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(Edge(b[i],c[i]));
		G[b[i]].push_back(Edge(a[i],c[i]));
        dist[a[i]][b[i]]=c[i];
        dist[b[i]][a[i]]=c[i];
    }
    for(ll k=0;k<n;k++){
        for(ll i=0;i<n;i++){
            for(ll j=0;j<n;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    vector<ll> flag(m,0);
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            for(ll k=0;k<n;k++){
                if(j!=k){
                    if(dist[j][k]==dist[j][a[i]]+c[i]+dist[b[i]][k]) flag[i]=1;
                }
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<m;i++) if(flag[i]==0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3724
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
mA, nA = [], []
dd = []
for a in A:
    if a<0:
        mA.append(a)
    else:
        nA.append(a)
    dd.append(a*a)
#rA = A[::-1]
#print(mA, nA)
lnA = len(nA)
lmA = len(mA)

def F(idx):
    j = lnA-1
    r = 0
    for a in nA:
        while j >= 0:
            if nA[j]*a <= idx:
                break
            j -= 1
        r += j+1
    j = 0
    for a in mA[::-1]:
        while j < lmA:
            if mA[j]*a <= idx:
                break
            j += 1
        r += lmA-j
    j = 0
    for a in mA:
        while j < lnA:
            if nA[j]*a <= idx:
                break
            j += 1
        r += 2*(lnA-j)

    for a in dd:
        if a <= idx:
            r-=1
    return r//2
#print(F(448283280358331064))

mx, mn = 2*10**18, -2*10**18
idx = (mx + mn)//2
target = K
while mx - mn > 1:
    if F(idx) < target:
        idx, mn = (idx + mx)//2, idx
        continue
    idx, mx = (idx + mn)//2, idx
print(idx+1)


Measured memory_bytes: 119544
//35
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  static bool hm[1000001]={false,true};
  for(int i=0;i<=1000000;i++){
    for(int j=0;j<3;j++){
      int f[]={2,3,5};
      if(hm[i]&&i*f[j]<=1000000){
	hm[i*f[j]]=true;
      }
    }
  }
  for(int m,n;cin>>m>>n;){
    cout<<count(hm+m,hm+n+1,true)<<endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int p[n];
  rep(i, n) cin >> p[i];
  int ans = 0;
  for(int i = 1; i < n-1; i++){
    if((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) { cin >> a[i]; }
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())
         << endl;
    return 0;
}

Measured memory_bytes: 256
def traveling():
	N = int(input())
	t = [0] * (N + 1)
	x = [0] * (N + 1)
	y = [0] * (N + 1)
	for i in range(1, N + 1):
		t[i], x[i], y[i] = map(int, input().split())
	
	flag = True
	for i in range(1, N + 1):
		dt = t[i] - t[i - 1]
		dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
		if dist > dt:
			flag = False
		if dist % 2 != dt % 2:
			flag = False
		
	
	if flag:
		print('Yes')
	else:
		print('No')

traveling()

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

int main() {
    int n;
    while (cin >> n, n) {
        int cnt[26] = {};
        char ans_ch;
        int ans_tm = -1;
        for (int i = 1; i <= n; i++) {
            char c;
            cin >> c;
            cnt[c - 'A']++;

            int id = 0;
            for (int j = 0; j < 26; j++) {
                if (cnt[j] > cnt[id]) id = j;
            }
            bool no = false;
            for (int j = 0; j < 26; j++) {
                if (j != id && cnt[j] + n - i >= cnt[id]) {
                    no = true;
                    break;
                }
            }
            if (no) continue;
            if (ans_tm >= 0) continue;
            ans_ch = char(id + 'A');
            ans_tm = i;
        }
        if (ans_tm < 0) cout << "TIE" << endl;
        else cout << ans_ch << " " << ans_tm << endl;
    }
}


Measured memory_bytes: 3064
<?php
fscanf(STDIN,'%d%d',$A,$B);
if($A==1){
  $A=15;
}
if($B==1){
  $B=15;
}
if($A<$B){
  echo "Bob";
}elseif($A>$B){
  echo "Alice";
}else{
  echo "Draw";
}
 ?>


Measured memory_bytes: 3576
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;

int prime[1000000];
void eratosthenes(){
    for(int i = 0; i < 1000000; i++)    prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i = 0; i * i <= 1000000; i++)
        if(prime[i])
            for(int j = i * 2; j < 1000000; j += i)
                prime[j] = 0;
}

signed main(){
	int q;
	cin >> q;

	eratosthenes();

	int va[99999 / 2 + 1] = {};

	for(int i = 1; i < 100000; i += 2){
		va[i / 2 + 1] = prime[i] && prime[(i + 1) / 2];
	}

	rep(i, 99999 / 2 + 1)
		va[i + 1] += va[i];

	rep(i, q){
		int l, r;
		cin >> l >> r;
		cout << va[r / 2 + 1] - va[l / 2] << endl;
	}
}


Measured memory_bytes: 8832
/*
 * main.c
 *
 *  Created on: 2019/06/16
 *      Author: family
 */

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

int main()
{
	int X = 0, A = 0, ans = 0;
	scanf("%d %d", &X, &A);
	if(X < A) {
		ans = 0;
	} else {
		ans = 10;
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int people[8];
	while(cin >>people[0]>>people[1]>>people[2]>>people[3]>>people[4]>>people[5]>>people[6]>>people[7]){
		int jenny[9] = {4,1,4,1,2,1,2,1,0},ans[8],min = 100000;
		for(int k=0; k<8; k++){
			int p = 0;
			for(int i=0; i<8; i++){if(people[i]-jenny[i]>0){p+=people[i]-jenny[i];}}
			if(p<min){
				min = p;
				for(int i=0; i<8; i++){
					ans[i] = jenny[i];
				}
			}
			else if(p == min){
				for(int i=0; i<8; i++){
					if(jenny[i]>ans[i]){break;}
					if(jenny[i]<ans[i]){
						for(int j=0; j<8; j++){
							ans[j] = jenny[j];
						}
						break;
					}
				}
			}
			jenny[8] = jenny[0];
			for(int i=0; i<8; i++){
				jenny[i] = jenny[i+1];
			}
		}
		cout <<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<" "<<ans[4]<<" "<<ans[5]<<" "<<ans[6]<<" "<<ans[7]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int k;
  cin >> k;
  queue<ll> lunlun;
  REP(i,9) lunlun.push((ll)(i+1));
  int cnt = 0;
  while(!(lunlun.empty())){
    cnt++;
    if(k == cnt){
      cout << lunlun.front() << endl;
      return 0;
    }
    ll x = lunlun.front();
    if(0 != x%10) lunlun.push(x*10+(x%10)-1);
    lunlun.push(x*10+(x%10));
    if(9 != x%10) lunlun.push(x*10+(x%10)+1);
    lunlun.pop();
  }
}

Measured memory_bytes: 5100
a,b,c,d,e,f = map(int, input().split())
s_max = f*e//(e+100)
w_max = f//100

s=[]
w=[]

max = 0
ans = [100*a,0]
for i in range(s_max//c+1):
    for j in range(s_max//d+1):
        if c*i + d*j <= s_max:
            s.append(c*i + d*j)

for i in range(w_max//a+1):
    for j in range(w_max//b+1):
        if 0<a*i + b*j <= w_max:
            w.append(a*i + b*j)

for i in range(len(s)):
    for j in range(len(w)):
        if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>=max and w[j]*100+s[i]<=f:
            max = s[i]/(w[j]*100+s[i])
            ans = [w[j]*100+s[i],s[i]]

print(ans[0],ans[1])


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

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

    string a, b, c;
    cin >> a >> b >> c;

    LL f = 1;
    while(1){
        if(f == 1){
            if(a.size() == 0)
                return cout << "A\n", 0;

            if(a[0] == 'a')
                f = 1;
            if(a[0] == 'b')
                f = 2;
            if(a[0] == 'c')
                f = 3;

            a.erase(0, 1);
        }
        else if(f == 2){
            if(b.size() == 0)
                return cout << "B\n", 0;

            if(b[0] == 'a')
                f = 1;
            if(b[0] == 'b')
                f = 2;
            if(b[0] == 'c')
                f = 3;

            b.erase(0, 1);
        }
        else{
            if(c.size() == 0)
                return cout << "C\n", 0;

            if(c[0] == 'a')
                f = 1;
            if(c[0] == 'b')
                f = 2;
            if(c[0] == 'c')
                f = 3;

            c.erase(0, 1);
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
void yes() { cout << "Yes\n"; exit(0); }
void no() { cout << "No\n"; exit(0); }
int main() {
    int N; cin >> N;
    multiset<int> S;
    for (int i = 0; i < 1 << N; i++) {
        int s; cin >> s; S.insert(s);
    }
    multiset<int, greater<int>> curr;
    auto it = prev(S.end());
    curr.insert(*it);
    S.erase(it);
    for (int i = 0; i < N; i++) {
        vector<int> add;
        for (auto c : curr) {
            auto it = S.lower_bound(c);
            if (it == S.begin()) {
                no();
            }
            --it;
            if (*it >= c) no();
            add.push_back(*it);
            S.erase(it);
        }
        for (auto a : add) curr.insert(a);
    }
    yes();
    return 0;
}


Measured memory_bytes: 13304
#include<stdio.h>
int a[524288];
int main()
{
	int n;
	scanf("%d",&n);
	int s=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	if(!(n&1))
	{
		int ans1=0,ans2=0;
		for(int i=1;i<=n;i+=2)
		{
			ans1+=a[i];
		}
		for(int i=2;i<=n;i+=2)
		{
			ans2+=a[i];
		}
		if(ans1<ans2)
		{
			int t=ans1;
			ans1=ans2;
			ans2=t;
		}
		printf("%d %d\n",ans1,ans2);
		return 0;
	}
	int ans=0;
	for(int i=2;i<=n;i+=2)
	{
		ans+=a[i];
		a[i]=-a[i];
	}
	for(int i=1;i<=n;i++)
	{
		a[i]+=a[i-1];
	}
	int l=0,r=1000000000;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		int mn=0;
		for(int i=2;i<=n;i+=2)
		{
			if(a[i-1]-mn>=mid&&a[i]<mn)
			{
				mn=a[i];
			}
		}
		if(a[n]-mn>=mid)
		{
			l=mid;
		}
		else
		{
			r=mid-1;
		}
	}
	ans+=l;
	printf("%d %d\n",ans,s-ans);
	return 0;
}

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

int main() {
  int N;
  int cnt = 0;
  int min = 200001;
  cin >> N;
  for (int i = 0; N > i; i++) {
    int P;
    cin >> P;
    if (P < min) {
      min = P;
      cnt++;
    }
  }
  cout << cnt << '\n';
}


Measured memory_bytes: 256
<?php
$sc = new Scanner();
$a = $sc->next();

$count = 0;
str_replace("1", "", $a, $count);
out::println($count);

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function println($str = "")
    {
        echo $str . PHP_EOL;
    }
}

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int t; cin >> t;
	stringstream ss;
	f(_,0,t) {
		ll A,B,C,D;	
		cin>>A>>B>>C>>D;
		ll g = gcd(B,D);
		ll m = (B-A%B-1)/g;	
		if (A<B||D<B) ss << "No" << endl;
		else if (B<=C) ss << "Yes" << endl;
		else if ((A+m*g)%B <= C) ss << "Yes" << endl;
		else ss << "No" << endl;
	}
	cout << ss.str();

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n,m;
  cin >> n >> m;
  vector<int> v(m,0);

  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int temp; cin >> temp;
      v[temp-1]++;
    }
  }

  int ans = 0;
  for(int i = 0; i < m; i++){
    if(v[i] == n){
      ans++;
    }
  }

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

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

using namespace std;

int main(){
  int N, K;
  vector<pair<int, int>> edges;
  cin >> N >> K;
  if ((N*(N - 1) / 2 - (N - 1)) < K){
    cout << -1 << endl;
  }
  else{
    int c = 0;
    for (int i=0; i<N; i++){
      for (int j=i+1; j<N; j++){
        if (i == j) continue;
        if (c < K && j < N - 1) c++;
        else{
          edges.emplace_back(pair<int, int>(i + 1, j + 1));
        }
      }
    }
    cout << edges.size() << endl;
    for (auto e : edges){
      cout << e.first << " " << e.second << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
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); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int a,b;
  cin >> a >> b;
  if(a > b)rep(i,a)cout << b;
  else rep(i,b)cout << a;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, b, c, x, y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c >> x >> y;

  ll ans = 0;
  if(a + b > c * 2) {
    if(y > x) {
      swap(x, y); swap(a, b);
    }
    ans += y * 2 * c;
    if(a >= c * 2) ans += ((x - y) * 2) * c;
    else ans += (x - y) * a;

  } else {
    ans += x * a;
    ans += y * b;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	int N,K;
	cin>>N>>K;
    vector<bool>C(N+1);
	vector<int>d(K+1);
	vector<vector<int>>A(K+1,vector<int>(N+1,-1));
	vector<int>B(N+1);
	for(int i=1;i<=K;i++){
		cin>>d[i];
		rep(j,d[i]){
			cin>>A[i][j];
            C[A[i][j]]=true;
		}
	}
    int ans=0;
    for(int i=1;i<=N;i++){
        if(C[i]!=true)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

ll n;
char ch[] = {'3', '5', '7'};

int dfs(string s) {
    int res = 0;
    rep(i, 3) {
        string t = s;
        t += ch[i];
        // cout << t << endl;
        ll m = stoll(t);
        if (m > n) continue;
        
        res += dfs(t);
        
        map<char, int> mp;
        rep(j, sz(t)) mp[t[j]]++;
        if (sz(mp) < 3) continue;
        res++;
    }
    return res;
}

int main() {
    cin >> n;
    
    cout << dfs("") << endl;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, i, c;

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      c = 0;
      for(i = 5;i < 20000;i *= 5)c += n / i;
      out.println(c);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17148
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M,ans=0;
  cin>>N>>M;
  priority_queue<ll> Q;
  REP(i,N){
    ll a;
    cin>>a;
    Q.push(a);
  }
  
  REP(i,M){
    ll a=Q.top();
    Q.pop();
    Q.push(a/2);
  }
  
  REP(i,N){
    ll a=Q.top();
    Q.pop();
    ans+=a;
  }
  
  co(ans);
  return 0;
}

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

using ll = long long;
using R = __int128;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int d = (h2 - h1) * 60 + m2 - m1;
    cout << d - k << endl;
    return 0;
}

Measured memory_bytes: 3632