akhauriyash/Code-Regression huggingface dataset:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
a = LI()
ans = 0
for i, A in enumerate(a):
    if (i+1) % 2 == 1:
        if A % 2 == 1:
            ans += 1
print(ans)

Measured memory_bytes: 9124
n=int(input())
D={}
for i in range(n):
    s=input()
    if s in D:
        D[s]+=1
    else:
        D[s]=1

DD = sorted(D.items(), key=lambda x:x[1])

sn=DD[-1][1]
ans=[]
for i in DD:
    if i[1]==sn:
        ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 112984
A,B,C = map(int,input().split())
K = int(input())
cnt = 0
for _ in range(K):
	if A>=B:
		B *= 2
		cnt += 1
	else:
		break

for _ in range(K-cnt):
	if B>=C:
		C *= 2
	else:
		break
#print(cnt)

if (A<B) and (B<C):
	print('Yes')
else:
	print('No')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll h;
	ll k;
	string s, t;
	char c;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> n;

	if (n % 1000 == 0) l_ans = 0;
	else l_ans = 1000 - (n % 1000);

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3648
//ITP1_2_B
#include<iostream>
using namespace std;

int main()
{
	int a,b,c;
	
	cin>>a>>b>>c;
	
	if(a<b&&b<c)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include<stdlib.h>
#include <cassert>
using namespace std;
int main() {

    int arr[5];
    for(int i=0;i<5;++i)
    	cin>>arr[i];

    for(int i=0;i<5;++i)
        {

            if(arr[i]==0)
            {
            	cout<<i+1<<endl;
            	break;
            }
        }
















	return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	vector<int> hito(n);
  	for(int i =0;i<n -1;i++){
    int zyoushi;
     
    cin >> zyoushi;
    hito.at(zyoushi -1) ++;
    }
  	for(int i=0;i<n;i++){
  	cout <<hito.at(i) <<endl;
    }
	}

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

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

  sort(a.begin(), a.end(), greater<int>());
  int ans = max(0, 2 * a[0] - k - 1);
  cout << ans << endl;
  return 0;
}

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

long long int N, a, A;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i, A += __builtin_ctzll(a))
        scanf("%lld", &a);
    cout << A << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}



int main(){
  int D,N;cin>>D>>N;
  int count=0;
  f(i,1,10000000){
      if(D==0&&i%100!=0)count++;
      else if(D==1&&i%10000!=0&&i%100==0)count++;
      else if(D==2&&i%10000==0&&i%1000000!=0)count++;
    if(count==N){cout<<i<<endl;break;}
  }
    

  
}

Measured memory_bytes: 256
n, m = map(int, input().split())
if n % 2 == 1:
    for i in range(m):
        print(i + 1, n - i)
else:
    for i in range(m):
        if 2 * (i + 1) <= m + 1:
            print(i + 1, n - i)
        else:
            print(i + 1, n - i - 1)

Measured memory_bytes: 9212
from collections import deque
import sys


def suffle(deck, c):
    l = len(deck)
    if l % 2 == 0: mid = l//2
    else: mid = (l-1)//2
    deckA = deck[mid:]
    deckB = deck[:mid]
    deckC = []
    
    while(len(deckA) != 0 or len(deckB) != 0):
        deckC.extend(deckA[:c])
        deckA = deckA[c:]
        deckC.extend(deckB[:c])
        deckB = deckB[c:]

    return deckC

while(True):
    inp = sys.stdin.readline()
    if not inp: break
    deck = []
    n, r = map(int, inp[:-1].split())
    deck = [i for i in range(n)]
    c_list = map(int, sys.stdin.readline()[:-1].split())
    for c in c_list:
        deck = suffle(deck, c)

    print(deck[-1])
    #print(" ".join(map(str, deck)))

Measured memory_bytes: 7972
/*#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*f;
}

#define MAXN 100000
#define MOD 1000000007
int N,K;
vector<int> G[MAXN+5];
int dp[MAXN+5];

int Pow(long long x,int y){
	long long ret=1;
	while(y){
		if(y&1)
			ret=(ret*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return ret;
}

long long fac[MAXN+5],inv[MAXN+5];
int A(int n,int m){
	if(m>n)
		return 0;
	return fac[n]*inv[n-m]%MOD;
}

int main(){
	N=read(),K=read();
	fac[0]=1;
	for(int i=1;i<=K;i++)
		fac[i]=fac[i-1]*i%MOD;
    inv[0]=1;
    inv[K]=Pow(fac[K],MOD-2);
    for(int i=K-1;i>=1;i--)
        inv[i]=inv[i+1]*(i+1)%MOD;
	//printf("%d",inv[2]);
	for(int i=1;i<=N-1;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	long long Ans=1;
	for(int i=1;i<=N;i++)
		Ans=Ans*A(K,G[i].size()+1)%MOD;
	printf("%lld",Ans);
}
*/
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*f;
}

#define MAXN 100000
#define MOD 1000000007
int N,K;
long long Ans;
vector<int> G[MAXN+5];

long long dfs(int u,int fa,int d){
	long long R=K-min(d,2);
	if(int(G[u].size())-1>R)
		return 0;
	for(int i=0;i<int(G[u].size());i++){
		int v=G[u][i];
		if(v!=fa){
			if(!dfs(v,u,d+1))
				return 0;
			Ans=(Ans*R)%MOD;
			R--;
		}
	}
	return Ans;
}

int main(){
	N=read(),K=read();
	for(int i=1;i<=N-1;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	Ans=K;
	printf("%lld",dfs(1,-1,1));
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  function<pair<int, long long>(int, long long)> rec = [&](int d, long long n) {
    if (n == 1) return make_pair(d, 0ll);
    long long ret = n / 2;
    int D = 2 * d;
    if (D >= 10) {
      ret += n / 2;
      D = D % 10 + 1;
    }
    int DD;
    long long add;
    tie(DD, add) = rec(D, n / 2);
    ret += add;
    if (n & 1) {
      ret++;
      DD += d;
      if (DD >= 10) {
        ret++;
        DD = DD % 10 + 1;
      }
    }
    return make_pair(DD, ret);
  };
  int M;
  cin >> M;
  long long ans = -1;
  int cur = 0;
  for (int i = 0; i < M; i++) {
    int d;
    long long c;
    cin >> d >> c;
    int D;
    long long cnt;
    tie(D, cnt) = rec(d, c);
    ans += cnt + 1;
    cur += D;
    if (cur >= 10) {
      ans++;
      cur = cur % 10 + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<cstring>
#include<vector>
#include<climits>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
typedef pair<int,int> pii;

int main()
{
	const int M = 200;
	const int INF=INT_MAX/10;
	int n,m;
	while(cin>>n>>m&&m)
	{
		int cost[M][M];
		int time[M][M];
		FOR(i,M)FOR(j,M)cost[i][j]=time[i][j]=INF;
		FOR(i,n)
		{
			int a,b;
			cin>>a>>b;
			int C,T;
			cin>>C>>T;
			cost[a][b]=cost[b][a]=C;
			time[a][b]=time[b][a]=T;
		}
		
		FORI(k,1,m+1)
		{
			FORI(i,1,m+1)
			{
				FORI(j,1,m+1)
				{
					if(cost[i][k]!=INF&&cost[k][j]!=INF)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
					if(time[i][k]!=INF&&time[k][j]!=INF)time[i][j]=min(time[i][j],time[i][k]+time[k][j]);
				}
			}
		}
		int k;cin>>k;
		FOR(i,k)
		{
			int p,q,r;
			cin>>p>>q>>r;
			if(r)cout<<time[p][q]<<endl;
			else cout<<cost[p][q]<<endl;
		}
		
	}
}

Measured memory_bytes: 3364
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

int main(){
    string a,b;
    cin>>a;
    int n=0;
    for(int i=0;i<a.size();i++){
            a[i]=tolower(a[i]);
        }
    while(1){
        cin>>b;
        if(b=="END_OF_TEXT")break;
        for(int i=0;i<b.size();i++){
            b[i]=tolower(b[i]);
        }
        if(a==b)n++;
    }
    cout<<n<<endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long int

void solve(ll caseNo)
{
    int n, d;
    cin >> n >> d;
    ll D = 1LL*d*d;
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        int a, b;
        cin >> a >> b;
        ll dist = 0;
        dist += 1LL*a*a;
        dist += 1LL*b*b;
        if(dist <= D)    ans++;
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll cases;
    cases = 1;
    for(ll i=1;i<=cases;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int n, r, ans;

int main() {

	cin >> n >> r;

	if (n < 10)ans = r + 100 * (10 - n);
	else ans = r;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int> > adj[MAX];

void dijkstra(void);

int main() {

  int k,u,v,c;

  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> u >> k;
    for(int j=0;j<k;j++) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }

  dijkstra();


  return 0;

}
      
void dijkstra() {

  priority_queue<pair<int,int> > PQ;
  int color[MAX];
  int d[MAX];
  for(int i=0;i<n;i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0,0));
  color[0] = GRAY;

  while( !PQ.empty() ) {
    pair<int,int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    if(d[u]<f.first*(-1)) continue;

    for(int j=0;j<adj[u].size();j++) {
      int v = adj[u][j].first;
      if(color[v] == BLACK) continue;
      if(d[v]>d[u]+adj[u][j].second) {
	d[v] = d[u]+adj[u][j].second;

	PQ.push(make_pair(d[v]*(-1),v));
	color[v] = GRAY;
      }
    }
  }

  for(int i=0;i<n;i++) {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}


	



Measured memory_bytes: 7996
#include<iostream>
#include<utility>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	priority_queue<pair<pair<int,int>,pair<int,int>>> q;
	int i;
	vector<int> p(3);
	for(i=0;i<N;i++) {
		cin >> p[0] >> p[1] >> p[2];
		sort(p.begin(),p.end());
		q.push(pair<pair<int,int>,pair<int,int>>(pair<int,int>(p[0],p[1]),pair<int,int>(p[2],i)));
	}
	p[0] = p[1] = p[2] = 0;
	int ans = 0;
	while(!q.empty()) {
		if(p[0] == q.top().first.first && p[1] == q.top().first.second && p[2] == q.top().second.first)ans++;
		p[0] = q.top().first.first;
		p[1] = q.top().first.second;
		p[2] = q.top().second.first;
		q.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 3200
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var answer = "";
            switch (n % 10)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    answer = "hon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    answer = "pon";
                    break;
                case 3:
                    answer = "bon";
                    break;
            }

            Console.WriteLine(answer);
        }
    }
}


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

struct Point{
	double x;
	double y;
};

int main(){
	Point p1,p2;
	cin>>p1.x>>p1.y>>p2.x>>p2.y;
	double xx=p1.x-p2.x,yy=p1.y-p2.y;
	cout<<fixed<<setprecision(10)<<sqrt(xx*xx+yy*yy)<<endl;
	return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

ll a[3010];

ll dp[3010][3010][2];
bool done[3010][3010][2];

ll func(int l,int r,int p) {
	if (done[l][r][p]) return dp[l][r][p];
	if (l==r) {
		done[l][r][p]=true;
		if (p) {
			return dp[l][r][1]=a[l];
		} else {
			return dp[l][r][0]=-a[l];
		}
	}
	if (p) {
		dp[l][r][p]=max(func(l+1,r,0)+a[l],func(l,r-1,0)+a[r]);
		// dp[l][r][p]=max(dp[l+1][r][0]+a[l],dp[l][r-1][0]+a[r]);
	} else {
		dp[l][r][p]=min(func(l+1,r,1)-a[l],func(l,r-1,1)-a[r]);
		// dp[l][r][p]=min(dp[l+1][r][1]-a[l],dp[l][r-1][1]-a[r]);
	}
	done[l][r][p]=true;
	return dp[l][r][p];
}

int main(int argc, char const *argv[])
{
	
	int n;cin>>n;

	rep(i,n) cin>>a[i];

	ll ans = func(0,n-1,1);

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 158336
D = [0]*4
for i in range(3):
    a, b = map(int, input().split())
    D[a-1] += 1
    D[b-1] += 1
C = [0]*4
for d in D:
    C[d] += 1
print("YES" if C == [0, 2, 2, 0] else "NO")

Measured memory_bytes: 3060
#include <iostream>

int main(int argc, char *argv[])
{
  int N, Y;

  std::cin >> N >> Y;

  int max_num_thousand_yen = Y/1000;
  int max_num_five_thousand_yen = Y/5000;
  int max_num_ten_thousand_yen = Y/10000;

  for (int i = 0; i <= max_num_five_thousand_yen; ++i) {
    int num_five_thousand_yen = i;

    for (int j = 0; j <= max_num_ten_thousand_yen; ++j) {
      int num_ten_thousand_yen = j;
      int num_thousand_yen = max_num_thousand_yen - num_five_thousand_yen*5 - num_ten_thousand_yen*10;

      if (num_thousand_yen < 0)
        continue;

      bool is_valid_num = num_thousand_yen + num_five_thousand_yen + num_ten_thousand_yen == N;
      bool is_valid_yen = num_thousand_yen*1000 + num_five_thousand_yen*5000 + num_ten_thousand_yen*10000 == Y;

      if (is_valid_num && is_valid_yen) {
        std::cout << num_ten_thousand_yen << " " << num_five_thousand_yen << " " << num_thousand_yen << std::endl;
        return 0;
      }
    }
  }

  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}


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

using namespace std;

int n, m;
struct Item {
    int id, price;
    string name;
    vector<int> edge;
    Item() {}
};
vector<Item> Graph;
int memo[101];

int Rec(int id)
{
    if (memo[id] != -1)
        return memo[id];

    int price = Graph[id].price, cmp = 0;

    for (int i = 0; i < Graph[id].edge.size(); ++i)
        cmp += Rec(Graph[id].edge[i]);

    return memo[id] = (cmp == 0) ? price : min(price, cmp);
}

int main()
{
    while (cin >> n, n) {
        string s, d;
        map<string, int> hash;

        Graph.resize(n);
        for (int i = 0; i < n; ++i) {
            memo[i] = -1;
            Graph[i].edge.clear();
        }

        for (int i = 0; i < n; ++i) {
            int p;

            cin >> s >> p;
            hash.insert(map<string, int>::value_type(s, i));
            Graph[i].id = i;
            Graph[i].price = p;
            Graph[i].name = s;
        }

        cin >> m;
        for (int i = 0; i < m; ++i) {
            int num;

            cin >> s >> num;
            for (int j = 0; j < num; ++j) {
                cin >> d;
                Graph[hash[s]].edge.push_back(hash[d]);
            }
        }

        cin >> s;
        cout << Rec(hash[s]) << endl;
    }

    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

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



int main() {
    int s; cin >> s;
        if (s%111 != 0){
            cout << 111*(s/111 + 1) << endl;
        }else{
            cout << s << endl;
        }
    return 0;
}

Measured memory_bytes: 764
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

vector<int> prev_l;
vector<int> next_r;
string s;
int n;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n = s.size();
    prev_l = vector<int>(n);
    next_r = vector<int>(n);

    int prev = -1;
    REP(i, n) {
        prev_l[i] = prev;
        if (s[i] == 'L') {
            prev = i;
        }
    }

    int nex = n;
    for (int i = n - 1; i >= 0; --i) {
        next_r[i] = nex;
        if (s[i] == 'R') nex = i;
    }

    vector<int> ans(n, 0);
    REP(i, n - 1) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            int lcnt = i + 1 - prev_l[i + 1] - 1;
            int rcnt = next_r[i] - i - 1;
            ans[i] = (lcnt + 1) / 2 + rcnt / 2;
            ans[i + 1] = lcnt / 2 + (rcnt + 1) / 2;
        }
    }

    cout << ans[0];
    REP(i, n - 1) cout << " " << ans[i + 1];
    cout << endl;
}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >> s;
    
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
    else cout << "Good" << endl;
   
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char m[101];
	int n,max,sum=0,j=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>m[i];
	}
	max=0;
	while(m[j]!='\0')
	{
		if(m[j]=='I')
		sum++;
		if(m[j]=='D')
		sum--;
		j++;
		if(sum>max)
		max=sum;
	}
	cout<<max;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i<b; i++)
typedef long long ll;
int main() {
    int n;
    cin >> n;
    
    string s = "";
    while(n != 0) {
      if (n % 2 != 0) {
        n--;
        s += "1";
      } else {
        s += "0";
      }
      n /= -2;
    }
    
    reverse(s.begin(), s.end());
    if (s == "") {
      s = '0';
    }
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
# include <bits/stdc++.h>
using namespace std;
long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  

int main()
{
  int flag=1,flag1=0;
  ll sum=0,tot=0,ans=0;
  map<int,int>mp;
  vi v,v1;
  set<int>st,st1;
  string s;
  scii(a,b);
  cout<<a*b;










return 0;
}

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

using namespace std;

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

    vector<string> names;
    int n;
    cin >> n;
    for(int i=0; i < n; i++)
    {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        names.push_back(s);
    }
    sort(names.begin(),names.end());
    int start = 0;
    long long ans = 0;
    for(int i = 1; i < n; i++)
    {
        if(names[start] != names[i])
        {
            long long diff = (i-start);
            ans +=   diff * (diff-1)/2 ;
            start = i;
        }
    }
    long long diff = (n-start);
    ans +=   diff * (diff-1)/2 ;
    cout << ans;
	return 0;
}


Measured memory_bytes: 5748
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] xS = new long[N];
		long[] yS = new long[N];
		long[] zS = new long[N];
		long[] xT = new long[N];
		long[] yT = new long[N];
		long[] zT = new long[N];
		ArrayList<Long> X = new ArrayList<Long>();
		ArrayList<Long> Y = new ArrayList<Long>();
		ArrayList<Long> Z = new ArrayList<Long>();
		for (int i = 0; i < N; i++) {
			xS[i] = sc.nextLong();
			yS[i] = sc.nextLong();
			zS[i] = sc.nextLong();
			xT[i] = sc.nextLong();
			yT[i] = sc.nextLong();
			zT[i] = sc.nextLong();
			X.add(xS[i]);
			X.add(xT[i]);
			Y.add(yS[i]);
			Y.add(yT[i]);
			Z.add(zS[i]);
			Z.add(zT[i]);
		}

		Collections.sort(X);
		Collections.sort(Y);
		Collections.sort(Z);

		long ans = 0;
		for (int i = 0; i < N * 2 - 1; i++) {
			for (int j = 0; j < N * 2 - 1; j++) {
				for (int k = 0; k < N * 2 - 1; k++) {
					int overlap = 0;
					// x,y,z???????????????????????¨????????????????????????
					// ????????????????¢?????????????????????¬??????????????????
					for (int l = 0; l < N; l++) {
						if (xS[l] <= X.get(i) && X.get(i + 1) <= xT[l]
								&& yS[l] <= Y.get(j) && Y.get(j + 1) <= yT[l]
								&& zS[l] <= Z.get(k) && Z.get(k + 1) <= zT[l]) {
							overlap++;
						}
					}
					if (overlap >= K) {
						ans += (X.get(i + 1) - X.get(i)) * (Y.get(j + 1) - Y.get(j)) * (Z.get(k + 1) - Z.get(k));
					}
				}
			}
		}
		System.out.println(ans);
	}

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

Measured memory_bytes: 30280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int ary[4];
    rep(i,4) ary[i] = 0;
    rep(i,3)
    {
        int a,b;
        cin >> a >> b;
        a--;b--;
        ary[a]++;
        ary[b]++;
    }
    int odd = 0;
    rep(i,4)
    {
        if (ary[i]%2==1) odd++;
    }
    if (odd == 0 || odd == 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    
    
}




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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    vector<vector<int>> graph(N);
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        a--;
        if(i) graph[a].emplace_back(i);
        else if(a) ans++;
    }
    vector<int> depth(N);
    auto dfs = [&](auto &&dfs, int cur, int pre) -> int {
        int d = depth[cur];
        for(auto &to : graph[cur]) {
            if(to == pre) continue;
            depth[to] = depth[cur] + 1;
            d = max(d, dfs(dfs, to, cur));
        }
        int ret = d;
        if(pre == 0) return ret;
        if(d - depth[cur] == K - 1) {
            ans++;
            ret = depth[pre];
        }
        return ret;
    };
    dfs(dfs, 0, 0);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 18548
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    
    string str(s);
    transform(str.begin(), str.end(), str.begin(), ::tolower);

    s[k-1] = str[k-1];
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
//#define cin fin
//#define cout fout
using namespace std;

//ifstream fin("file.in");
//ofstream fout("file.out");

const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;

int k,x;
vector<int>acc;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> k >> x;
	for(int i=x;i<=min(1000000LL,x+k-1);i++) acc.push_back(i);
	for(int i=x-1;i>=max(-1000000LL,x-k+1);i--) acc.push_back(i);
	sort(all(acc));
	for(int i=0;i<acc.size();i++) cout << acc[i] << ' ';
}


Measured memory_bytes: 256
#include <iostream>

using i64 = long long;

const i64 MOD = 1000000007;
const int N = 200000 + 7;

int n;
int a[N], c[N], e[N];
int cril, crir;
i64 f[N], g[N], h[N], q[N];
i64 ans, s = 1;

i64 pow(i64 a, i64 k) {
	i64 t = 1;
	for (; k; a = a * a % MOD, k >>= 1) if (k & 1) t = t * a % MOD;
	return t;
}

i64 bit[N];
void add(int i, i64 v) {
	for (; i <= n; i += i & -i) ( bit[i] += v ) %= MOD;
}
i64 sum(int i) {
	i64 t = 0;
	for (; i; i -= i & -i) t += bit[i];
	return t % MOD;
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i), ++c[a[i]];
	for (int i = n; i; --i) {
		c[i] += c[i + 1];
		if (c[i] - n + i - 1 <= 0) cril = i, crir = crir ? crir : i;
		f[i] = (c[i] - n + i - 1) * pow(c[i] - n + i, MOD - 2) % MOD;
		s = s * std::max(c[i] - n + i, 0) % MOD;
	}
	for (int i = g[0] = h[0] = 1; i <= n; ++i)
		g[i] = g[i - 1] * (f[i] ? f[i] : 1) % MOD,
		h[i] = h[i - 1] * pow(f[i] ? f[i] : 1, MOD - 2) % MOD,
		q[i] = f[i] ? q[i - 1] : i;

	for (int i = 1; i <= n; ++i) e[c[a[i]]--] = i;
	for (int i = 1, j; i <= n; i = j) {
		if (!f[a[e[i]]]) { j = i + 1; continue; }
		for (j = i; j <= n && a[e[j]] > q[a[e[i]]]; ++j)
			( ans += (sum(n) - sum(e[j]) - sum(e[j] - 1)) * h[a[e[j]]] ) %= MOD,
			add(e[j], g[a[e[j]]]);
		for (j = i; j <= n && a[e[j]] > q[a[e[i]]]; ++j)
			add(e[j], -g[a[e[j]]]);
	}
	for (int i = 1; i <= n; ++i)
		ans += sum(e[i] - 1), add(e[i], 2);
	ans = (ans % MOD * s % MOD * (-MOD / 2) % MOD + MOD) % MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 13944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  string s;
  ll k;
  cin >> s >> k;
  rep(i,k) {
    if (s[i] != '1') {
      cout << s[i] << '\n';
      return 0;
    }
  }
  cout << '1' << '\n';
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int const d1[] = {0,0,1,-1};
int const d2[] = {1,-1,0,0};

int H, W;
vector<vector<char>> fi(410, vector<char>(410, '1'));
vector<vector<bool>> seen(410, vector<bool>(410, false));


void input() {
    cin >> H >> W;
    repr(i, 1, H+1) repr(j, 1, W+1) cin >> fi[i][j];
}

pair<ll, ll> bfs(int i, int j) {
    queue<pair<int, int>> qu;
    qu.push(make_pair(i, j));
    seen[i][j] = true;

    ll b = 0, w = 0;
    (fi[i][j]=='.'? w:b) += 1;
    while(!qu.empty()) {
        auto p = qu.front(); qu.pop();
        int x = p.first; int y = p.second;
        rep(k, 4) {
            int nx = x+d1[k], ny = y+d2[k];
            if (fi[nx][ny] != '1' && fi[nx][ny] != fi[x][y] && !seen[nx][ny]) {
                (fi[nx][ny]=='.'? w:b) += 1;
                seen[nx][ny] = true;
                qu.push(make_pair(nx, ny));
            }
        }
    }

    return make_pair(b, w);
}

void solve() {
    ll ans = 0;
    repr(i, 1, H+1) repr(j, 1, W+1) if(!seen[i][j]) {
        auto pa = bfs(i, j);
        ans += pa.first * pa.second;
    }
    cout << ans << endl;
}

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

    input();
    solve();

    return 0;
}


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 7;
int n, m;
char s[N][N];
int dp[N][N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n >> m;
	FOR(i, 1, n + 1) FOR(j, 1, m + 1) cin >> s[i][j];
	
	FOR(i, 0, N) FOR(j, 0, N) dp[i][j] = INF;
	
	dp[1][1] = 0;
	FOR(i, 1, n + 1) FOR(j, 1, m + 1) 
	{
		setmin(dp[i][j], dp[i - 1][j] + (s[i][j] != s[i - 1][j]));
		setmin(dp[i][j], dp[i][j - 1] + (s[i][j] != s[i][j - 1]));
	}
	
	if (s[1][1] == '#' && s[n][m] == '#')
		cout << dp[n][m] / 2 + 1;
	else 
		cout << (1 + dp[n][m]) / 2;
	
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 896
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;


int main()
{   
    long long K, A, B;

    cin >> K >> A >> B;
    
    long tmp = B / K;
    if(A <= tmp*K){
        std::cout << "OK" << std::endl;
    }else{
        std::cout << "NG" << std::endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n;

	ll ans=0;
	for(i=2;i*i<=n;i++)
	{
		x=0;
		while(n%i==0)
		{
			x++;
			n/=i;
		}

		for(j=1;;j++)
		{
			y=(j*(j+1))/2;
			if(y<=x)
				ans++;
			else
				break;
		}
	}
	if(n>1)
		ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	string s,a;
	cin >> s;
	rep(i,0,s.size()) {
		if (s[i] == '0') a += '0';
		else if (s[i] == '1') a += '1';
		else if (s[i] == 'B' && a.size()) a.pop_back();
	}
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
      cin>>s;

        int c=0;

         if(s[2]==s[3])
          c++;

          if(s[4]==s[5])
            c++;

         if(c==2)
          cout<<"Yes";

          else
          cout<<"No";    
}


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

using namespace std;

int main( void )
{
	long long OK;
	bool T[50][30];
	vector<int> V[30];
	long long A[50];
	int n;
	while(cin >> n, n) {
		OK = 1;
		OK = (OK << n) - 1;
		fill(A, A+50, 1);
		for(int i=0; i < 30; ++i) V[i].clear();
		for(int i=0; i < n; ++i) {
			A[i] = A[i] << i;
			//cout << A[i] << endl;
			fill(T[i], T[i]+30, false);
			int f; cin >> f;
			for(int j=0; j < f; ++j) {
				int d; cin >> d;
				T[i][d-1] = true;
				V[d-1].push_back(i);
			}
		}
		//cout << OK << endl;
		int ans = -1;
		for(int i=0; i < 30; ++i) {
			long long check = 0;
			for(int j=0; j < n; ++j) {
				if(T[j][i]) {
					for(int k=0; k < V[i].size(); ++k) {
						//A[j] |= (1 << V[i][k]);
						A[j] |= A[V[i][k]];
					}
					check |= A[j];
				}
			}
			//cout << check << endl;
			if(check == OK) {
				ans = i + 1;
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 920
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	int array[15];
	int ans = 0;
	cin >> n;
	rep(i, n) cin >> array[i];
	sort(array, array+n);
	rep(i, n-1) ans += array[i];
	ans += array[n-1] / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
$cnt = 0
def dfs(a,b,n)
    a = a.to_s
    b = b.to_s
    a = a + b
    a = a.to_i
    if(a > n)
        return 
    else
        k = a
        seven = 0 
        five = 0
        three = 0
    while k > 0
        k % 10 == 3 ? three+= 1 : k % 10 == 5 ? five+= 1 : seven += 1
        k /= 10
    end
    if(five > 0 && seven > 0 && three > 0)
        $cnt += 1
    end
end
    dfs(a,3,n)
    dfs(a,5,n)
    dfs(a,7,n)
end

n = gets.to_i

dfs(0,3,n)
dfs(0,5,n)
dfs(0,7,n)

puts $cnt


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


int N;
string s[100002];
ll M,A,R,C,H;


int main(){
    cin>>N;
    Rep(i,N) cin>>s[i];
    M=A=R=C=H=0;
    Rep(i,N){
        if(s[i][0]=='M') M++;
        if(s[i][0]=='A') A++;
        if(s[i][0]=='R') R++;
        if(s[i][0]=='C') C++;
        if(s[i][0]=='H') H++;
    }
    ll ans=0;
    ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <memory.h>

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  ll A[N+2];
  A[0] = 0, A[N+1] = 0;
  ll total = 0;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    total += abs(A[i] - A[i-1]);
  }
  total += abs(A[N+1] - A[N]);
  for(int mid=1;mid<=N;mid++){
    int left = mid-1;
    int right = mid+1;
    if(A[left] >= A[right]){
      if(A[mid] >= A[right] && A[mid] <= A[left]){
        cout << total << endl;
      }else if(A[mid] > A[left]){
        cout << total - (A[mid] - A[left])*2 << endl;
      }else{
        cout << total - (A[right] - A[mid])*2 << endl;
      }
    }else{
      // A[left] < A[right]
      if(A[mid] >= A[left] && A[mid] <= A[right]){
        cout << total << endl;
      }else if(A[mid] > A[right]){
        cout << total - (A[mid] - A[right])*2 << endl;
      }else{
        cout << total - (A[left] -A[mid])*2 << endl;
      }
    }
  }
}

Measured memory_bytes: 2048
N = int(input())
L = list(map(int, input().split()))

count = 0

for k in range(N):
    for j in range(N):
        for i in range(N):
            if i>=j or j>=k:
                continue
            l = sorted([L[i], L[j], L[k]])
            if l[0] == l[1] or l[1] == l[2]:
                continue
            if l[2] < l[0] + l[1]:
                count += 1


print(count)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  dump(s.substr(0, 4) == "YAKI" ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
<?php
$max = trim(fgets(STDIN));

$dataList = array( "JPY"=>0, "BTC"=>0 );
for( $i=0; $i<$max; $i++ )
{
  list( $price, $unit ) = explode( " ",  trim(fgets(STDIN)) );
  $dataList[$unit] += $price;
}

$result = $dataList["JPY"]+$dataList["BTC"]*380000.0;
echo $result;

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

using namespace std;
const int N = 1e5 + 5;
typedef long long ll;

int g = 1, p = 0;
char str[N];
int score;

int main() {
    scanf("%s", str);
    for(int i = 1; i < N; i++) {
        if(p < g) {
            p++;
            if(str[i] == 'g') score++;
        }
        else {
            g++;
            if(str[i] == 'p') score--;
        }
    }
    printf("%d", score);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }else if(a==1){
        cout<<"Alice"<<endl;
    }else if(b==1){
        cout<<"Bob"<<endl;
    }else if(a>b){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Bob"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = []
for i in range(H):
    s = list(map(lambda x:x=='#', input()))
    S.append(s)


for i in range(H):
    for j in range(W):
        if S[i][j]:
            print('#',end='')
        else:
            t = 0
            for a in range(-1,2):
                for b in range(-1,2):
                    if 0<=i+a<H and 0<=j+b<W and S[i+a][j+b]:
                        t+=1
            print(t,end='')
    print()


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

string s;
int n, q, br[100005];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
cin >> s;
for(int i = 0 ; i < n - 1 ; ++i){
	if(s[i] == 'A' && s[i + 1] == 'C'){
		br[i + 1]++;
	}
}
for(int i = 1 ; i <= n ; ++i){
	br[i] += br[i - 1];
}
for(int i = 0 ; i < q ; ++i){
	int l, r;
	cin >> l >> r;
	cout << br[r - 1] - br[l - 1] << endl;
}

return 0;
}



Measured memory_bytes: 1488