akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    bool A[105] = {};
    for(int i=0; i<m; i++) {
        int a; cin >> a;
        A[a] = true;
    }
    int ans=1000, temp=0;
    for(int i=x-1; i>=0; i--) {
        if(A[i]) temp++;
    }
    ans = min(ans, temp);
    temp=0;
    for(int i=x+1; i<=n; i++) {
        if(A[i]) temp++;
    }
    ans = min(ans, temp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <iomanip>
#define pi 3.14159265359

using namespace std;

int main() {
  
  double R=0;
  
  cin >> R;
  
  double cul = 2 * pi * R;
  
  cout << fixed << setprecision(7) << cul << endl;
  
}


Measured memory_bytes: 3756
w,h,n = map(int, input().split())
count = 0
list_prob = []
while count < n:
    list_prob.append(list((map(int, input().split()))))
    count += 1
w_max = w
h_max = h
w_min = 0
h_min = 0

for row in list_prob:
    if row[2] == 1:
        if w_min < row[0]:
            w_min = row[0]
    elif row[2] == 2:
        if w_max > row[0]:
            w_max = row[0]
    elif row[2] == 3:
        if h_min < row[1]:
            h_min = row[1]
    else:
        if h_max > row[1]:
            h_max = row[1]
if w_max < w_min or h_max < h_min:
    print(0)
else:
    print((w_max - w_min)*(h_max - h_min))

Measured memory_bytes: 3188
#include<stdio.h>
int N[45];
int main(){
  int n,i;
  N[0]=1;
  N[1]=1;
  scanf("%d",&n);
  for(i=2;i<=n;i++)N[i]=N[i-1]+N[i-2];
  
  printf("%d\n",N[n]);
  return 0;
}



Measured memory_bytes: 2132
N, M = list(map(int, input().split()))
a = []
for i in range(M):
    a.append(list(map(int, input().split())))
a.sort()
ans = 0

l, r = a[0][0], a[0][1]

for i in range(len(a)):
    if a[i][0] < r:
        if a[i][1] < r:
            l, r = a[i][0], a[i][1]
        else:
            l = a[i][0]
    else:
        ans += 1
        l, r = a[i][0], a[i][1]

ans += 1
print(ans)


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

int main() {
  int n;
  string s;
  cin>>n>>s;
  if (n % 2 != 0) cout<<"No"<<endl;
  else {
    int c = 0;
    for (int i=0;i<n/2;i++) {
      if (s[i] != s[i+n/2]) c++;
    }
    if (c == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main()
{
    int a,b,c;
    char s[101];
    
    int max;
    
    // スペース区切りの整数の入力
    scanf("%d %d %d",&a,&b,&c);

    max = b / a;
    
    if(max > c) {
    max = c;
    }


    // 出力
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
char s[10][10];
int book[10],t,n,m,a[20],d[20],c[10];
void dfs(int x)
{
	if(c[x]==1)
	dfs(x+1);
	if(x==8)
	{
		for(int i=0;i<8;i++)
		printf("%s\n",s[i]);
		return;
	}
	for(int i=0;i<8;i++)
	{
		if(book[i]==0&&a[x+i]==0&&d[x-i+8]==0)
		{
			book[i]=1;
			a[x+i]=1;
			d[x-i+8]=1;
			s[x][i]='Q';
			dfs(x+1);
			book[i]=0;
			a[x+i]=0;
			d[x-i+8]=0;
			s[x][i]='.';
		}
	}
}
int main()
{
	scanf("%d",&t);
	for(int i=0;i<8;i++)
	for(int j=0;j<8;j++)
    	s[i][j]='.';
	for(int i=0;i<t;i++)
	{
		scanf("%d%d",&n,&m);
		s[n][m]='Q';
		book[m]=1;
		a[n+m]=1;
		d[n-m+8]=1;
		c[n]=1;
	}
	dfs(0);
	return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,rev;
	};
	vector<vector<edge> > g;
	map<P,int> m;
	int DFS(int v,int t,int f,vi& used){
		if(v==t) return f;
		used[v]=1;
		for(int i=0;i<g[v].size();i++){
			edge &e=g[v][i];
			if(!used[e.to]&&e.cap>0){
				int d=DFS(e.to,t,min(f,e.cap),used);
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int Flow(int s,int t,int f){
		vi used(V);
		return DFS(s,t,f,used);
	}
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t){
		m[{s,t}]=g[s].size();
		g[s].push_back(edge{t,1,(int)g[t].size()});
		g[t].push_back(edge{s,1,(int)g[s].size()-1});
	}
	int Max_Flow(int s,int t){
		int ans=0;
		while(1){
			int f=Flow(s,t,1);
			if(f==0) return ans;
			ans+=f;
		}
	}
	void Clear(int u,int v){
		int I=m[{u,v}];
		g[u][I].cap=0;
		g[v][g[u][I].rev].cap=0;
	}
	int Add(int u,int v){
		add_edge(u,v);
		return Flow(0,V-1,1);
	}
	int Erase(int u,int v,int ind){
		int C=g[u][m[{u,v}]].cap;
		if(C==1){
			Clear(u,v);
			return 0;
		}
		int f=Flow((C?v:u),(C?u:v),1);
		if(f){
			Clear(u,v);
			return 0;
		}
		Flow(V-1,0,1);
		Clear(u,v);
		Flow((C?v:u),(C?u:v),1);
		return 1;
	}
};

int n,m,q;

int main(){
	cin>>n>>m>>q;
	Network nt(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		if(u>v) swap(u,v);
		nt.add_edge(u,v);
	}
	int res=nt.Max_Flow(0,n-1);
	for(int i=0;i<q;i++){
		int t,u,v;
		cin>>t>>u>>v;
		u--;v--;
		if(u>v) swap(u,v);
		if(t==1) res+=nt.Add(u,v);
		else res-=nt.Erase(u,v,i);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 4752
def a_addition(N, A):
    count_odd = 0  # 数列の要素のうち奇数のものの個数
    for a in A:
        if a % 2 == 1:
            count_odd += 1
    # 偶数のペアからは1個の偶数が生成される
    # 奇数が偶数個あれば、余ることなく奇数をペアにして偶数を生成できる
    # 奇数が奇数個あれば、ペアにできない奇数が余ってしまう
    if count_odd % 2 == 0:
        ans = 'YES'
    else:
        ans = 'NO'
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(a_addition(N, A))

Measured memory_bytes: 14108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int dp[2100][2100],a[2100],b[2100],c1[2100][2100],c2[2100][2100];
int main(){
	  int n,m,i,j,k,x;
	  char ch;
	  cin>>n;
	  for(i=1;i<=2*n;i++){
	  	 cin>>ch>>x;
	  	 if(ch=='B'){
	  	 	a[x]=i;
	  	 }else {
	  	 	b[x]=i;
	  	 }
	  }
	  for(i=1;i<=n;i++){
	  	 for(j=1;j<i;j++)
	  	    if(a[i]<a[j])c1[i][0]++;
	  	 for(j=1;j<=n;j++){
	  	 	c1[i][j]=c1[i][j-1];
	  	 	if(b[j]>a[i])c1[i][j]++;
	  	 }
	  }
	  for(i=1;i<=n;i++){
	  	 for(j=1;j<i;j++)
	  	    if(b[i]<b[j])c2[0][i]++;
	  	 for(j=1;j<=n;j++){
	  	 	c2[j][i]=c2[j-1][i];
	  	 	if(a[j]>b[i])c2[j][i]++;
	  	 }
	  }
	  int wh1=0,wh2=0;
	  for(i=1;i<=n;i++){
	  	 wh1+=c1[i][0];
	  	 wh2+=c2[0][i];
	  	 dp[i][0]=wh1;
	  	 dp[0][i]=wh2;
	  }
	  for(i=1;i<=n;i++)
	     for(j=1;j<=n;j++)
	        dp[i][j]=min(dp[i-1][j]+c1[i][j],dp[i][j-1]+c2[i][j]);
	  cout<<dp[n][n]<<endl;
	  return 0;
}


Measured memory_bytes: 51456
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	double ans = (n + 1) / 2;
	ans /= n;
	cout << setprecision(10) << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# code-festival-2017-qualcC - Inserting 'x'
def main():
    S = input().rstrip()
    ans, l, r = 0, 0, len(S) - 1
    while l < r:
        if S[l] == S[r]:
            l += 1
            r -= 1
        else:
            ans += 1
            if S[l] == "x":
                l += 1
            elif S[r] == "x":
                r -= 1
            else:
                print(-1)
                return
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second

using namespace std;

int main(){

    int a,b,c,k;
    cin >> a >> b >> c >> k;

    int mx1 = max(a,b);
    int mx2 = max(mx1,c);
    int mx3 = mx2;

    for(int i=0;i<k;i++){
        mx2 *= 2;
    }

    cout << a+b+c-mx3+mx2;



    return 0;
}

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



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

struct UnionFind{
    vector<int> par;
    
    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }
    
    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }
    
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    
    int size(int x){
        return -par[root(x)];
    }
};



int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n+m);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int l;
            cin>>l;
            uf.merge(l-1,m+i);
        }
    }

    for(int i=0;i<n-1;i++){
        if(!uf.issame(m+i,m+i+1)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
int main() {
	//code
	long long n,t,a;
	scanf("%lld",&n);
	scanf("%lld %lld",&t,&a);
	
	long long *H = (long long*)malloc(n*sizeof(long long));
	
	for(int i=0;i<n;i++) scanf("%lld",H+i);
	
	double min = INT_MAX;
	int idx=0;
	
	for(int i=0; i<n;i++)
	{
	    double tmp;
	    
	    tmp = (float)t - (float)H[i]*(0.006);
	    
	    
	    
	    if(min>fabs(tmp-a))
	    {
	        min = fabs(tmp-a);

	        idx = i;
	    }
	}
	printf("%d",idx+1);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

int main(){
	int n,m;
	cin >> n >> m;
	int t[100] ={};
	rep(i,0,m){
        int a,b;
        cin >> a >> b;
        t[a-1]++;
        t[b-1]++;
	}
	rep(i,0,n){
        cout << t[i] << endl;
	}
	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
using V = vector<ll>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll hcnt[300005],wcnt[300005];

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  ll ans = -INF;
  rep(i,N+1){
    rep(j,N-i+1){
      if(i+j>K)continue;
      priority_queue<ll,vector<ll>,greater<ll>> q;
      rep(k,i) q.push(v[k]);
      rep(k,j) q.push(v[N-k-1]);
      rep(k,K-i-j){
        if(q.empty()) break;
        if(q.top()<0) q.pop();
      }
      ll cnt = 0;
      while(!q.empty()) {
        cnt += q.top();
        q.pop();
      }
      chmax(ans,cnt);
    }
  }
  cout<<ans<<endl;
}

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

int main() {
    vector<string> ans;
    string s;
    while(cin >> s) {
        string now;
        for(auto c : s) {
            if(c == '.' || c == ',') {
                if(3 <= now.size() && now.size() <= 6) {
                    ans.push_back(now);
                }
                now.clear();
            } else {
                now += c;
            }
        }
        if(3 <= now.size() && now.size() <= 6) {
            ans.push_back(now);
        }
    }
    for(int i = 0; i < (int)ans.size(); ++i) {
        cout << ans[i] << " \n"[i + 1 == (int)ans.size()];
    }
}


Measured memory_bytes: 2928
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: int, B: int):
    tot = 0
    for i in range(N+1):
        s = sum([int(c) for c in str(i)])
        if A <= s <= B:
            tot += i
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
D, G =  map(int, input().split())
PCs = [list(map(int, input().split())) for i in range(D)]

arr = []
for i in range(D):
    steps = [0]
    count = PCs[i][0]
    point = 100 * (i + 1)
    bonus = PCs[i][1]
    
    for n in range(count):
        p = (n+1) * point
        if (n+1) == count:
            p += bonus
        steps.append(p)
    arr.append(steps)
# print(arr)

dp = arr[0]
for i in range(1, len(arr)):
    leng = len(dp) + len(arr[i])
    out = [0] * leng
    for x in range(len(dp)):
        for y in range(len(arr[i])):
            v = dp[x] + arr[i][y]
            out[x+y] = max(out[x+y], v)
    dp = out

for i in range(len(dp)):
    if dp[i] >= G:
        print(i)
        break

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

const long long INF = 1e9;

// 入力
int N;

// DP テーブル
long long dp[100010];

int main() {
    cin >> N;

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        dp[i+1] = min(dp[i]+1, dp[i+1]);
        int six = 6;
        while(i + six <= N){
        	dp[i+six] = min(dp[i]+1, dp[i+six]);
        	six *= 6;
        }
        int nine = 9;
        while(i + nine <= N){
        	dp[i+nine] = min(dp[i]+1, dp[i+nine]);
        	nine *= 9;
        }
    }

    // 答え
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

int	main() {
	int N;
	cin >>N;
	vector<int> M(N+1, 0);
	for (int i=0; i<N; i++) {
		int P;
		cin >>P;
		if (0==M.at(P))
			M.at(P)=1;
		P++;
		if (P<=N)
			if (0==M.at(P))
				M.at(P)=M.at(P-1)+1;
	}
	int S=0;
	for (int i=1; i<=N; i++)
		S=max(S, M.at(i));
	cout <<N-S <<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(void){
    int W,H,x,y,r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
     
    if(((x-r)>=0)&&(x<=(W-r))&&((y-r)>=0)&&(y<=(H-r)))
        cout << "Yes";
        else   cout << "No";
         
        cout << endl;
         
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(B / A, C) << "\n";
}

Measured memory_bytes: 384
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    X, Y, Z, K = NMI()
    A = NLI()
    B = NLI()
    C = NLI()
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    S = []
    for c_idx in range(min(len(C), 3000)):
        for ab_idx in range(min(len(AB), 3000)):
            S.append(C[c_idx] + AB[ab_idx])
    S.sort(reverse=True)
    for i in range(K):
        print(S[i])



if __name__ == "__main__":
    main()

Measured memory_bytes: 251968
class Dice:
    def __init__(self):
        self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front
    def set(self,l):
        self.dice=l
    def roll(self, s):
        import copy
        mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))
        l=copy.deepcopy(self.dice)
        if s == 'N': c = 0
        if s == 'S': c = 1
        if s == 'E': c = 2
        if s == 'W': c = 3
        for i in range(6):
            self.dice[i]=l[mat[i][c]]
    def get(self):
        return self.dice

d=Dice()
d.set(list(map(int,input().split())))
s=input()
for i in range(len(s)):
    d.roll(s[i])
print(d.get()[0])

Measured memory_bytes: 8260
using System;

class Atcoder81
{
    public static void Main()
    {
        string s = Console.ReadLine();

        if (s.IndexOf("a") >= 0 && s.IndexOf("b") >= 0 && s.IndexOf("c") >= 0)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 13280
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long int ll;


const ll N = 100005;
const int mod = 1000000007;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);
ll n;





int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   if(a+b+c>=22) cout<<"bust\n";
   else cout<<"win\n";
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   return ((a%mod)+(b%mod)+mod)%mod;
}
ll modpower(ll a, ll n){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a);
      a = modmulti(a,a);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 
 

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int n;
	int64_t ans = 0;

	cin >> n;
	vector<int> sum_a(n, 0);
	vector<int> a(n);
	vector<int64_t> c_a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum_a[a[i] - 1]++;
	}
	for (int i = 0; i < n; i++)
	{
		c_a[i] = (int64_t)sum_a[i] * (sum_a[i] - 1) / 2;
		ans += c_a[i];
	}
	for (int i = 0; i < n; i++)
		cout << ans + (int64_t)(sum_a[a[i] - 1] - 1) * (sum_a[a[i] - 1] - 2) / 2 - c_a[a[i] - 1] << endl;
}


Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll h,w;
  cin >> h >> w;
  if(h==1||w==1) {
    pr(1);
    return;
  }
  ll x=((h+1)/2)*((w+1)/2);
  ll y=(h/2)*(w/2);
  pr(x+y);
}

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


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

lint pow5(lint x) { return x*x*x*x*x; }

int main(){
    lint x; cin >> x;
    for(lint a = 0; a<=2000; a++){
        lint y = x-pow5(a);
        for(lint b = 0; b<=2000; b++){
            if(pow5(b) == y){
                outs(a); out(-b); return 0;
            }
            if(pow5(b) == -y){
                outs(a); out(b); return 0;
            }
        }
    }
    return -1;
}

Measured memory_bytes: 3620
from collections import defaultdict


def prime_factor(n):
    d = defaultdict(int)
    for i in range(2, n + 1):
        if i * i > n:
            break

        while n % i == 0:
            d[i] += 1
            n //= i

    if n != 1:
        d[n] += 1

    return d


N = int(input())
d = prime_factor(N)
ans = 0
for v in d.values():
    i = 1
    cur = 1
    cnt = 0
    while cur <= v:
        cnt += 1
        i += 1
        cur += i
    ans += cnt

print(ans)


Measured memory_bytes: 65908
#include<iostream>

using namespace std;

int main(void) {
	double t5, t10;
	int t5r, t10r;

	while(true) {
		cin >> t5 >> t10;
		if(cin.eof()) { break; }

		if(t5 < 35.5) { t5r = 1; }
		else if(t5 < 37.5) { t5r = 2; }
		else if(t5 < 40.0) { t5r = 3; }
		else if(t5 < 43.0) { t5r = 4; }
		else if(t5 < 50.0) { t5r = 5; }
		else if(t5 < 55.0) { t5r = 6; }
		else if(t5 < 70.0) { t5r = 7; }
		else { t5r = 8; }

		if(t10 < 71.0) { t10r = 1; }
		else if(t10 < 77.0) { t10r = 2; }
		else if(t10 < 83.0) { t10r = 3; }
		else if(t10 < 89.0) { t10r = 4; }
		else if(t10 < 105.0) { t10r = 5; }
		else if(t10 < 116.0) { t10r = 6; }
		else if(t10 < 148.0) { t10r = 7; }
		else { t10r = 8; }

		switch(max(t5r, t10r)) {
			case 1:
				cout << "AAA" << endl;
				break;
			case 2:
				cout << "AA" << endl;
				break;
			case 3:
				cout << "A" << endl;
				break;
			case 4:
				cout << "B" << endl;
				break;
			case 5:
				cout << "C" << endl;
				break;
			case 6:
				cout << "D" << endl;
				break;
			case 7:
				cout << "E" << endl;
				break;
			default:
				cout << "NA" << endl;
				break;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int h[100005];
int ans[100005];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= n; i++){
        scanf("%d",&h[i]);
        ans[i] = 1;
    }
    for (int i = 0; i < m; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        if (h[a] >= h[b]) ans[b] = 0;
        if (h[a] <= h[b]) ans[a] = 0;
    }
    int ct = 0;
    for (int i = 1; i <= n; i++){
        if (ans[i] == 1) ct++;
    }
    printf("%d",ct);

}


Measured memory_bytes: 4532
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)

	if x < 100 {
		fmt.Println(0)
		return
	}

	last := x % 100

	c5 := 0
	if last/5 > 0 {
		c5 = last / 5
		last %= 5
	}
	c4 := 0
	if last/4 > 0 {
		c4 = last / 4
		last %= 4
	}
	c3 := 0
	if last/3 > 0 {
		c3 = last / 3
		last %= 3
	}
	c2 := 0
	if last/2 > 0 {
		c5 = last / 2
		last %= 2
	}
	c1 := 0
	if last == 1 {
		c1 = 1
	}

	recalc := 0
	recalc += 105 * c5
	recalc += 104 * c4
	recalc += 103 * c3
	recalc += 102 * c2
	recalc += 101 * c1

	if recalc > x {
		fmt.Println(0)
		return
	}

	c0 := (x - recalc) / 100
	recalc += 100 * c0

	if recalc == x {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    while(cin >> S) {
        cout<< sz(S) / 2 - (int)count(all(S), 'p') << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long

using namespace std;

int N;
int X[101010], L[101010];
pair<int, int> itv[101010];

signed main()
{
    cin >> N;
    for (size_t i = 0; i < N; i++)
    {
        cin >> X[i] >> L[i];
        itv[i].first = X[i] + L[i];
        itv[i].second = X[i] - L[i];
    }

    sort(itv, itv + N);

    int ans = 0, t = -9090909090;
    for (size_t i = 0; i < N; i++)
    {
        if (t <= itv[i].second)
        {
            ans++;
            // cout << "A " << itv[i].second << " : " << itv[i].first << endl;
            t = itv[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
while True:
    try:
        N=int(input())
        for i in range(N):
            n=list(input())
            n_max=""
            n_min=""
            for j in sorted(n):
                n_min +=j
            n_max=int(n_min[::-1])
            n_min=int(n_min)
            print(n_max-n_min)
        break
    except:break


Measured memory_bytes: 5600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    string s;
    cin>>s;
    ll ans=0;
    rep(i,(ll)s.size()){
        if(s[i]=='+') ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int m,f,r;
    int i,j,k;
    scanf("%d %d %d",&m,&f,&r);
    while(m+1||f+1||r+1){
        if(m<0||f<0||m+f<30){
            printf("F\n");
        }else if(m+f<50){
            (r<50)? printf("D\n") : printf("C\n");
        }else if(m+f<65){
            printf("C\n");
        }else if(m+f<80){
            printf("B\n");
        }else{
            printf("A\n");
        }
        scanf("%d %d %d",&m,&f,&r);
    }
}

Measured memory_bytes: 1012
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int fie[5000][5000];
int main(){

    long long int A,B,C,D;
    cin>>A>>B>>C>>D;
    /*
    fie[A][B][0]={1};
    for(int i=A;i<=C;i++){
        for(int j=B;j<=D;j++){
            for(int k=0;k<2;k++){
                //if(i==A&&j==B&&k==0)continue;
                if(k==0){
                    fie[i+1][j][1]+=fie[i][j][k]*j;
                    fie[i][j+1][0]+=fie[i][j][k]*(i-1);
                    fie[i][j+1][1]+=fie[i][j][k];
                }
                if(k==1){
                    fie[i+1][j][1]+=fie[i][j][k]*j;
                    fie[i][j+1][1]+=fie[i][j][k]*(i-1);
                    fie[i][j+1][2]+=fie[i][j][k];
                }
                if(k==0){
                    fie[i+1][j][1]+=fie[i][j][k]*j;
                    fie[i][j+1][2]+=fie[i][j][k]*(j-1);
                    fie[i][j+1][2]+=fie[i][j][k];
                }
            }
        }
    }
    cout<<fie[C][D][0]+fie[C][D][1]+fie[C][D][2]<<endl;
    */

    fie[A][B]=1;
    for(long long int i=A;i<=C;i++){
        for(long long int j=B;j<=D;j++){
            if(i==A&&j==B)continue;
            fie[i][j]=(fie[i-1][j]*j+fie[i][j-1]*i-(i-1)*(j-1)*fie[i-1][j-1])%998244353;
            //printf("fie[%d][%d]=[%lld]+[%lld]-[%d]=[%d]\n",i,j,fie[i-1][j]*j,fie[i][j-1]*i,(i-A)*(j-B),fie[i][j]);
            //printf("hoge");
            fie[i][j]=(fie[i][j]+(long long int)998244353*(long long int)10)%(long long int)998244353;
        }
    }

    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            //printf("[%lld]",fie[i][j]);
        }
        //cout<<endl;
    }

    cout<<fie[C][D]<<endl;

    /*
    long long int ans=1;
    while(1){
        if(A<C&&B<D){
            ans*=A*B+A+B;
            A++;
            B++;
            ans%=998244353;
        }
        else if(A<C){
            A++;
            ans*=B;
            ans%=998244353;
        }
        else if(B<D){
            B++;
            ans*=A;
            ans%=998244353;
        }
        else{
            break;
        }
    }
    cout<<ans<<endl;
*/
    return 0;
}


Measured memory_bytes: 85792
<?php
$n = int();
$a = ints();
$sum = 0;
$mod = 10**9+7;
for($i = 0; $i <= 60; $i++){
  $c = 0;
  foreach($a as $b){
    $c += ($b >> $i) & 1; 
  }
  $sum += ((($c % $mod) * ($n-$c)) % $mod) * ((1<<$i)%$mod);
  $sum %= $mod;
}
echo $sum;
 
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}

Measured memory_bytes: 40936
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
(H,W)
(i,j)
1行ずつよまなきゃ
ああ、そういうことか
OXXXO
XXXXO
1
2になるのか
OXXXOXXOX
XXXOXXXXO
これはない

2e5)^2は無理
ええ・・・BITなら無理・・・
12345678
OOOXXXOO (1,1) (7,1) 4-6
OXXXXXXO (1,2) (8,2) 2-7
XXXXOOOO (5,7) (8,3) 1-4
OOOOOXXX (5,8) (9,3)みたいな

OOOXXXXX 4-8
XXOOOOOO 1-2
最高効率と手前保存しておくとか？

管理むずい

W通り保持・・・
12345678 //(スタート位置、今いるW）
OOOXXXOO {(1,1),(2,2),(3,3),(7,7),(8,8)} //0+1 {0,0,0,0,0}
OXXXXXXO {(1,1),(8,8)} //0+2 {0,0}
XXXXOOOO {(1,5),(8,8)} //0+3 {4,0}
OOOOOXXX {(1,5)} //(5-1)+4 {4}

mapとmultiset...
mapにlower_bound？
おしりから見ていくとか

(今いる位置、スタート位置）か。

・setにpair
set<pair<ll,ll>> S;
S.lower_bound({a,b});
a優先でb順に並んでる。

・eraseした後のitr
S.erase(itr);
itr++;
eraseした後ポインタの場所変わっちゃうので1つ先がとれるとは限らない。

S.erase(itr++);
erase処理前の移動でちゃんと1つ先がとれる。

おぎゃあああああああああああ

OOXX
XXOO
XXOO
OOOX
XXXO
XXXX
XXXO

最後消えてないじゃん
*/

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll H,W; cin>>H>>W;
  set<pair<ll, ll>> POS;
  multiset<ll> SC;
  rep(i, H){
    ll a, b, ans=0; cin>>a>>b;
    if (i == 0){
      for(ll j=1; j<a; j++){
        POS.insert({j, j});
        SC.insert(0);
      }
      for(ll j=b+1; j<=W; j++){
        POS.insert({j, j});
        SC.insert(0);
      }
    }
    else{
      auto itr1 = POS.lower_bound({a, -1});
      ll v1, v2;
      bool del = false;
      while(itr1 != POS.end() && itr1->first <= b){
        v1 = itr1->first;
        v2 = itr1->second;
        SC.erase(SC.find(v1 - v2));
        POS.erase(itr1++);
        del = true;
      }
      if (del && b < W && itr1->first != b+1){
        POS.insert({b+1, v2});
        SC.insert(b+1 - v2);
      }
    }
    if (SC.size() == 0){
      cout << -1 << endl;
      continue;
    }
    ans = *SC.begin();
    cout << ans + i + 1 << endl;

/*
cout<<"i:"<<i<<" SC.size():" << SC.size() << " POS.size():" << POS.size() << endl;
cout<<"SC:";
auto itr = SC.begin();
while (itr != SC.end()){
  cout<<*itr<<" ";
  itr++;
}
cout<<"POS:";
auto pitr = POS.begin();
while (pitr != POS.end()){
  cout<<"("<< pitr->first<<", "<<pitr->second<<") ";
  pitr++;
}
cout<<endl;
*/

  }
}

Measured memory_bytes: 25368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int N; cin >> N;
    string str = "357";
    map<string,int>mp;
    function<void(string)> solve  = [&](string s){
        for(auto c : str){
            auto temp = s;
            temp.push_back(c);
            if(stoll(temp) <= N){
                mp[temp]++;
                solve(temp);
            }
        }
    };
    solve("");
    int ans = 0;
    for(auto itr : mp)if(itr.second != 0)
        if(itr.first.find('3') != string:: npos)
            if(itr.first.find('5') != string:: npos)
                if(itr.first.find('7') != string:: npos)
                    ++ans;
    cout << ans << endl;
    
}


Measured memory_bytes: 3840
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int D;cin>>D;
    if(D==25){
        cout<<"Christmas";
    }else if(D==24){
        cout<<"Christmas Eve";
    }else if(D==23){
        cout<<"Christmas Eve Eve";
    }else{ 
        cout<<"Christmas Eve Eve Eve";
    }
}

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

int main() {
  long long N;
  cin >> N;
  map<string, int> S;
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    S[str] += 1;
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 18824
#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 INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


vector<int> solve(int n) {
    vector<int> ret;
    vector<int> table(n + 1);
    rep3(i, 2, n + 1) {
        if (table[i] == 1) continue;
        rep3(j, 2, n + 1) {
            if (i * j > n) break;
            table[i * j] = 1;
        }
    }
    rep3(i, 2, n + 1) if (table[i] == 0) ret.eb(i);
    return ret;
}

int main() {
    int n;
    cin >> n;
    
    auto v = solve(n);
    // for (int e : v) cout << e << " "; cout << endl;
    
    ll ans = 1;
    for (int e : v) {
        ll tmp = 0;
        rep3(j, 1, n + 1) {
            int div = pow(e, j);
            if (div > n) break;
            tmp += n / div;
        }
        // cout << e << " " << tmp << endl;
        (ans *= tmp + 1) %= inf;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 2000001
int parent(int i);
int left(int i);
int right(int i);
void maxHeapify(int);
void insert(int);
void extract(void);
int n=0;
int A[N];
int main(){
  int i;
  char s[10];
  while(1){
    scanf("%s", s);
    if(s[0]=='i'){
      n++;
      scanf(" %d", &A[n]);
      insert(A[n]);
    }
    else if(s[1]=='x') extract();
    else break;
  }   
    return 0;
}
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}  
void maxHeapify(int i){
  int l, r, largest, a;
  l=left(i);
  r=right(i);
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
 
  if(r <= n && A[r] > A[largest]) largest = r;
 
  if(largest != i){
    a = A[i];
    A[i] = A[largest];
    A[largest] = a;
    maxHeapify(largest);
  }
   
}
void insert(int key){
  int i,x; 
  i = n;
  while(i > 1 && A[parent(i)] < A[i]){
    x = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = x;
    i/=2;
  }   
}
 
void extract(void){
  int max; 
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1);
  printf("%d\n", max);
}

Measured memory_bytes: 4692
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, l = mi()
    strings = [input() for _ in range(n)]
    strings.sort()
    print(''.join(strings))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
object Main{
	def main(A:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n,m=s.nextInt
		val u=new UF(n)
		val a=Seq.fill(m)((s.nextInt-1,s.nextInt-1)).reverse.map(o=>{
			if(u.isConnected(o _1,o _2))
				0
			else{
				val t=u.groupSize(o _1).toLong*u.groupSize(o _2)
				u.connect(o _1,o _2)
				t
			}
		}).reverse.toArray
		(1 until m) foreach(i=>a(i)+=a(i-1))
		a foreach println
	}
}
class UF(n:Int){
	val a = Array.fill(n)(-1)
	def root(t:Int):Int =
		if(a(t) < 0) t
		else {
			val v = root(a(t))
			a(t) = v
			v
		}
	def connect(b:Int,c:Int) ={
		val d = root(b)
		val e = root(c)
		if(d == e)
			false
		else {
			def f(g:Int,h:Int) ={
				a(g) += a(h);
				a(h) = g;
			}
			if(a(d) > a(e)) f(e,d) else f(d,e)
			true
		}
	}
	def isConnected(a:Int,b:Int) = root(a) == root(b)
	def groupSize(t:Int) = -a(root(t))
}

Measured memory_bytes: 84208
#include <cstdio>
#include <string>
#include <algorithm>
using  namespace std;

int dr[]={-1, -1, -1, 0, 0, 1, 1, 1};
int dc[]={-1, 0, 1, -1, 1, -1, 0, 1};

bool cmp(const string& a, const string& b)
{
    if (a.size()<b.size()) return false;
    if (a.size()>b.size()) return true;
    return a<b;
}

int main()
{
    int n, m;
    while (scanf("%d%d", &n, &m), n) {
        char s[11][21];
        for(int i=0;i<n;++i) scanf("%s", s[i]);

        vector<string> spells;
        for(int i=0;i<n;++i) for(int j=0;j<m;++j) for(int k=0;k<8;++k) {
            int r=i, c=j, q=0;
            string t;
            do {
                t+=s[r][c];
                if (t.size()>1) spells.push_back(t);
                r=(r+dr[k]+2*n)%n;
                c=(c+dc[k]+2*m)%m;
            } while (r!=i || c!=j);
        }
        sort(begin(spells), end(spells), cmp);

        string res;
        for(int i=1;i<spells.size();++i) if (spells[i]==spells[i-1]) {
            res=spells[i];
            break;
        }
        puts(res.size()?res.c_str():"0");
    }
    return 0;
}

Measured memory_bytes: 29008
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                count += 1
print(count)

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    int d[N];
    for (int i=0; i<N; i++) cin >> d[i];
    long long int s = 0;
    for (int i=0; i<N-1; i++)
        for (int j=i+1; j<N; j++)
            s += d[i]*d[j];
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 256