akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char word[128][17],pre[17],now[17];
int POW[17];
int length[128],dp[2][1<<17];
int num_bit[1<<17];

int main(){

	for(int i = 0; i < 17; i++)POW[i] = pow(2,i);

	int H,W;
	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){
		scanf("%s",word[row]);
		for(length[row] = 0; word[row][length[row]] != '\0'; length[row]++);
	}

	int CURRENT = 0,NEXT = 1;

	for(int state = 0; state < POW[W]; state++){
		num_bit[state] = __builtin_popcount(state);
		dp[CURRENT][state] = -1;
		dp[NEXT][state] = -1;
	}

	dp[CURRENT][0] = 0;
	int loc,next;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			for(int state = 0; state < POW[W]; state++)dp[NEXT][state] = -1;

			for(int state = 0; state < POW[W]; state++){

				if(dp[CURRENT][state] == -1)continue;

				loc = num_bit[state & (1 << col)-1];

				if(loc < length[row]){
					next = dp[CURRENT][state];

					if(col > 0 && (state & (1 << (col-1))) != 0 && word[row][loc-1] == word[row][loc])next++;

					if(row > 0 && (state & 1 << col) != 0 && word[row][loc] == word[row-1][length[row-1]-num_bit[state >> col]])next++;
					dp[NEXT][state|1 << col] = max(dp[NEXT][state|1 << col],next);
				}

				if(loc+W-col > length[row]){
					dp[NEXT][state & ~(1 << col)] = max(dp[NEXT][state & ~(1 << col)], dp[CURRENT][state]);
				}
			}
			swap(CURRENT,NEXT);
		}
	}

	int ans = 0;
	for(int state = 0; state < POW[W]; state++){
		ans = max(ans,dp[CURRENT][state]);
	}

	printf("%d\n",2*ans);

	return 0;
}



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


int main() {
    long long int n, k;
    cin>>n>>k;
    priority_queue <long long int, vector<long long int>, greater<long long int> > pq;
    long long int temp;
    for(long long int i = 0;i<n;i++){
        cin>>temp;
        pq.push(temp);
    }
    long long int tmp1, tmp2;
    long long int tmp3;
    long long int cnt = 0;
    vector<pair<long long int, long long int> > done;
    for (long long int i = 0; i < k; i++) {
        cnt = 0;
        cin >> tmp1 >> tmp2;
        done.push_back({tmp2, tmp1});
    }
    sort(done.rbegin(), done.rend());
    for (long long int i = 0; i < k; i++){
        cnt = 0;
       while (cnt < done[i].second) {
        if (pq.top() < done[i].first) {
          pq.pop();
          pq.push(done[i].first);
          cnt++;
        } else {
          break;
        }
      }
    }
    long long int ans = 0;
    while (!pq.empty()) {
      ans += pq.top();
      pq.pop();

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
    int n, q, i, j;
    int cnt = 0;
    int S[10000];
    int T[500];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", S + i);
    scanf("%d", &q);
    for (i = 0; i < q; i++) scanf("%d", T + i);
    for (i = 0; i < q; i++) {
        for (j = 0; j < n; j++) {
            if (T[i] == S[j]) {
                cnt++;
                break;
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;

int main() {
  Int N, A, B;
  cin >> N >> A >> B;
  Int nn = N / (A+B);
  Int m = N - nn*(A+B);
  Int ans = nn * A;
  ans += min(m, A);
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
pts = dict()
for _ in range(N):
    s = input().strip()
    if not pts.get(s):
        pts[s] = 0
    pts[s] += 1

M=int(input())
for _ in range(M):
    t = input().strip()
    if not pts.get(t):
        pts[t] = 0
    pts[t] -= 1

print(max(0, max(pts.values())))

Measured memory_bytes: 61948
import java.util.*;

public class Main {
    public static void main (String args[])
    {
       
        Scanner sc = new Scanner(System.in);
        int x  = sc.nextInt();
        sc.close();
        if(x == 1){
            System.out.println("0");
        }else if (x == 0){
            System.out.println("1");
        }
    }   
}

Measured memory_bytes: 35640
a = int(input())
b = int(input())
c = int(input())
x = int(input())
s = 0
for i in range(a+1):
    for j in range(b+1):
        for l in range(c+1):
            if 500*i+100*j+50*l == x:
                s += 1
print(s)



Measured memory_bytes: 3060
import math
n = int(input())
s = list(input())
mod = 10**9 + 7

now = 0
result = 1
for i in range(2 * n):
    if s[i] == 'B':
        if now % 2 == 0:
            now += 1
        else:
            result = (result * now) % mod
            now -= 1
    else:
        if now % 2 == 0:
            result = (result * now) % mod
            now -= 1
        else:
            now += 1
if now != 0:
    result = 0
print((result * math.factorial(n)) % mod)

Measured memory_bytes: 61680
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

int  gcd(int a,int b) {
	return  (b==0)? a: gcd(b,a%b);
}
int dp[100005][3];
void solve(){ 
	int  n;  cin >> n ;
	int  a[1+n][3];
	for (int i=0;i<n;i++){
		for (int j=0;j<3;j++)
			cin >> a[i][j];
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<3;j++){
			if (i==0)  dp[i][j] = a[i][j]; 
			else {
				for (int k=0;k<3;k++){
					if (j==k) continue;
						dp[i][j] = max(dp[i][j],dp[i-1][k] + a[i][j]);
				}
				
			}
		}
	}
	int res=0;
	res = max(res,dp[n-1][0]);
	res = max(res,dp[n-1][1]);
	res = max(res,dp[n-1][2]);
	cout << res << endl ; 
}

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


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

using namespace std;

using ll = long long;

int main(){
   ll n, m;
   cin >> n >> m;
   priority_queue<ll> q;
   for(ll i = 0; i < n; ++i){
    ll tmp; cin >> tmp;
    q.push(tmp);
   }
   while(m--){
    ll kanta = q.top();
    kanta /= 2;
    q.pop();
    q.push(kanta);
   }
   ll ans = 0;
   while(!q.empty()){
    ans += q.top();
    q.pop();
   }
   cout << ans;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


ll solve(vector<ll>& a){
    ll n = a.size();

    ll i = 0;
    ll j = n-1;

    ll left = a[i];
    ll right = a[i];
    i++;
    
    ll sum = 0;
    ll cnt = 1;
    while(i <= j){
        if(0 <= j){
            sum += abs(left-a[j]);
            left = a[j];
            cnt++;
        }
        j--;
        if(cnt == n) break;

        if(0 <= j){
            sum += abs(right-a[j]);
            right = a[j];
            cnt++;
        }
        j--;
        if(cnt == n) break;

        if(i < n){
            sum += abs(left-a[i]);
            left = a[i];
            cnt++;
        }
        i++;
        if(cnt == n) break;

        if(i < n){
            sum += abs(right-a[i]);
            right = a[i];
            cnt++;
        }
        i++;
        if(cnt == n) break;
    }

    return sum;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

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

    ll x = solve(a);
    reverse(a.begin(), a.end());
    ll y = solve(a);

    cout << max(x, y) << endl;


    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
#include<stdio.h>

using namespace std;

int main() {
	int num;//人数
	int counter = 0;
	int height;//制限身長
	int i;
	int h[200000];
	cin >> num >> height;

	for (i = 0; i < num; ++i) {
		cin >> h[i];
		if (h[i] >= height) {
			++counter;
		}
	}

	cout << counter << endl;

}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int n;
int tab[100005];
int DP[100005];

int absol(int a){
    if(a < 0) return a * (-1);
    else return a;
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &tab[i]);
    DP[1] = 0;
    DP[2] = absol(tab[1] - tab[2]);
    for(int i = 3; i <= n; i++){
        DP[i] = min(DP[i-1] + absol(tab[i] - tab[i-1]), DP[i-2] + absol(tab[i] - tab[i-2]));
    }
    printf("%d", DP[n]);
    return 0;
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
L = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A % C == 0:
    X = A // C
if A % C != 0:
    X = A // C + 1
if B % D == 0:
    Y = B // D
if B % D != 0:
    Y = B // D + 1
ans = L - max(X,Y)
print(ans)



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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

vector<vector<int> > g(100005);
ll ans = 0;
ll k;

void dfs(int n, int lvl, int p = -1) {
    ll clrd = 0;
    if (lvl == 0) {
        ans += k;
        clrd = 1;
    } else {
        clrd = 2;
    }
    for (int i = 0; i < (int)g[n].size(); i++) {
        if (p == g[n][i]) continue;
        ans = (ans * (k - clrd)) % MOD;
        clrd++;
        dfs(g[n][i], lvl + 1, n);
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 0);
    cout << ans;
    return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;


int main(){
  int n,d;
  cin >> n >> d;
  d = 2*d+1;
  n%d == 0 ? cout << n/d : cout << n/d+1;
}




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ')
        .map { n -> if (n == "1") 14 else n.toInt() }
    val msg = when {
        a < b -> "Bob"
        b < a -> "Alice"
        else -> "Draw"
    }
    println(msg)
}


Measured memory_bytes: 38252
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int A;
    cin>>A;

    cout<<A*A*A<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

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

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	//cout << s.substr(0, n / 2) << endl;
	//cout << s.substr(n / 2, n-1) << endl;
	if (s.substr(0, n / 2) == s.substr(n / 2, n))yes();
	else no();

	system("pause");
	return 0;
}


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

using namespace std;

const int MX = 200005;
const int ME = 800005;
const int oo = 123123123;

template<typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template<typename T> void read(T &x)
{
	x = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct EDGE
{
	int v, c;

	EDGE (const int &v0 = 0, const int &c0 = 0) : v(v0), c(c0) {}
};

struct GRAPH	//板子
{
	EDGE e[ME];
	int fst[MX], nxt[ME], lnum;
	int dep[MX],q[MX];          //分层网络的深度，bfs 的队列

	void addeg(int nu, int nv, int nc)
	{
		nxt[++lnum] = fst[nu];
		fst[nu] = lnum;
		e[lnum] = EDGE(nv, nc);
	}

	void init()
	{
		memset(fst, 0xff, sizeof(fst));
		lnum = -1;
	}

	int bfs(int frm,int to)     //生成分层网络
	{
		int h=0,t=1,x,y;
		memset(dep,0xff,sizeof(dep));
		q[++h]=frm;
		dep[frm]=0;
		while(h>=t)
		{
			x=q[t++];
			for(int i=fst[x];i!=-1;i=nxt[i])
			{
				y=e[i].v;
				if(dep[y]==-1&&e[i].c)
				{
					dep[y]=dep[x]+1;
					q[++h]=y;
				}
			}
		}
		return (dep[to]>=0);    //返回分层网络是否成功生成
	}

	int cur[MX];                //当前弧优化的记录数组
	int dinic(int x,int mn,int tar)
	{
		if(x==tar)return mn;
		int y,a,now=0;
		for(int &i=cur[x];i!=-1;i=nxt[i])   //"int &i="这一句是当前弧优化的核心
		{
			y=e[i].v;
			if(e[i].c&&dep[y]==dep[x]+1)
			{
				a=dinic(y,min(mn-now,e[i].c),tar);
				now+=a;                     //整体流量优化，记录当前节点往下流的最大流量后再返回
				e[i].c-=a,e[i^1].c+=a;      //帮助 dinic 反悔
				if(mn==now)return now;
			}
		}
		return now;
	}

	int mxflow(int s, int t)
	{
		int tot=0;
		while(bfs(s,t))
		{
			memmove(cur,fst,sizeof(fst));
			tot+=dinic(s,+oo,t);
		}
		return tot;
	}
} G;

int n;
int global_s, global_t;

void input()
{
	G.init();
	read(n);
	global_s = n*2, global_t = n*2+1;
	for(int i=1; i<n; i++)
	{
		int c, x;
		read(c);
		for(int j=1; j<=c; j++)
		{
			read(x);
			G.addeg(x, n+i, 1);
			G.addeg(n+i, x, 0);
		}
	}
	for(int i=1; i<=n; i++)
	{
		G.addeg(global_s, i, 1);
		G.addeg(i, global_s, 0);
	}
	for(int i=1; i<n; i++)
	{
		G.addeg(n+i, global_t, 1);
		G.addeg(global_t, n+i, 0);
	}
}

int frm[MX];
pair<int, int> ans[MX];

void dfs(int x, int f)
{
	frm[x] = f;
	for(int i=G.fst[x]; ~i; i=G.nxt[i])
		if(G.e[i].c && !frm[G.e[i].v])
			dfs(G.e[i].v, x);
}

void work()
{
	if(G.mxflow(global_s, global_t) != n-1) puts("-1");
	else
	{
		int root = 0;
		for(int i=G.fst[global_s]; ~i; i=G.nxt[i])
			if(G.e[i].c)
				root = G.e[i].v;
		dfs(root, -1);
		bool fucked = 0;
		for(int i=1; i<=n; i++)
			if(!frm[i])
				fucked = 1;
		if(fucked) puts("-1");
		else
		{
			for(int i=1; i<=n; i++)
				if(i != root)
					ans[frm[i]-n] = make_pair(i, frm[frm[i]]);
			for(int i=1; i<n; i++)
				printf("%d %d\n", ans[i].first, ans[i].second);
		}
	}
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 21760
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();

    }

    private void solve() {
        int N = sc.nextInt();
        Map<Integer, Integer> dic = new HashMap<Integer, Integer>();
        int ans = N;
        for (int i = 0; i < N; i++) {
            int tmp = Integer.parseInt(sc.next());
            if (dic.containsKey(tmp)) {
                int next = dic.get(tmp) + 1;
                dic.put(tmp, next);
                if (next % 2 == 0) {
                    ans -= 2;
                }
            } else {
                dic.put(tmp, 1);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 49056
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<ll,ll>
typedef long long ll;
const int maxn=1e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
ll n,m,v,p,a[maxn]; 
bool check(ll num)
{
	ll b=a[n-p+1];
	if(a[num]>=b)return 1;
	if(a[num]+m<b)return 0;
	if(num+p-1>=v)
	{
		if(a[num]+m>=b)return 1;
		else return 0;
	}
	ll sum=(v-num-p+1)*m;
	for(ll i=num+1;i<=n-p+1;i++)
	{
		sum-=(a[num]+m-a[i]);
	}
	if(sum>0)return 0;
	return 1;
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(ll i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	ll l=1,r=n,ans;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid))r=mid-1,ans=n-mid+1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int m, f, r;
	char point[1];
	while (true){
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1){
			break;
		}
		if (m==-1||f==-1){
			point[0] = 'F';
		}
		else if (m + f >= 80){
			point[0] = 'A';
		}
		else if (m + f >= 65){
			point[0] = 'B';
		}
		else if (m + f >= 50){
			point[0] = 'C';
		}
		else if (m + f >= 30){
			point[0] = 'D';
			if (r >= 50){
				point[0] = 'C';
			}
		}
		else{
			point[0] = 'F';
		}
		cout << point[0]<<endl;
	}
}


Measured memory_bytes: 3124
n=int(input())
A=list(map(int,input().split()))
ans = [0]*8
r = 0
for i in range(n):
  if A[i] < 3200:
    ans[A[i]//400] = 1
  else:
    r += 1
print(*[max(sum(ans),1),sum(ans)+r])

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

int main(){
  int N;
  long long x;
  cin >> N >> x;

  long long a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a, a+N);

  int result = 0;
  for(int i=0;i<N-1;i++){
    if(x >= a[i]){
      x -= a[i];
      result++;
    }
    //cout << a[i] << endl;
  }
  if(x == a[N-1]){
    result++;
  }
  //cout << a[N-1] << endl;

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


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

int main() {
long long int N;cin >> N;
long long int count = 0;
vector<long long int> A(N);
vector<long long int> B(N);
vector<long long int> C(N);

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

    cin >> A.at(i);

    }

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

    cin >> B.at(i);

    }

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

    cin >> C.at(i);

    }

sort(A.begin(), A.end());
sort(B.begin(), B.end());
sort(C.begin(), C.end());

    for(int j = 0; j < N; j++){

    count += (lower_bound(A.begin(), A.end(), B.at(j)) - A.begin())*
              (C.end() - upper_bound(C.begin(), C.end(), B.at(j)));

}
cout << count << endl;
}

Measured memory_bytes: 2560
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n, d);
    ll c = 0;
    rep(i, n) {
        IN(x, y);
        if (x*x+y*y <= d*d) ++c;
    }
    cout << c << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;

ll exponentiation(ll base, ll exp) 
{ 
    ll t = 1; 
    while (exp > 0)  
    { 
        //cout << exp << endl;
        
        if (exp % 2 != 0) 
            t = (t * base) % mod; 
  
        base = (base * base) % mod; 
        exp /= 2; 
        //cout << exp << endl;
        //cout << base << endl;
    } 
    //cout << t << endl;
    //cout << base << endl;
    return t % mod; 
} 


ll comb(ll x, ll y){
    ll ans = 1;
    for(int i=0;i<y;i++) ans = (ans*(x-i))%mod;
    ll bol = 1;
    for(int i=2;i<=y;i++) bol = (bol*i)%mod;
    bol = exponentiation(bol,mod-2);
    ans = (ans*bol) % mod;
    
    return ans;
}


int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = exponentiation(2,n)-1 -(comb(n,a) + comb(n,b));
    ans+=2*mod;
    cout << ans%mod;

    return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n){
        cin >> h[i];
    }
    int ans = 0;
    REP(i, n){
        if(h[i] >= k){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair


using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

int n,m;
int a,b;

map<int,int> u;

int main () {
        cin >> n;

        for (int i = 1; i <= n; i ++)
                cin >> a,u[a] ++;

        cin >> m;

        for (int i = 1; i <= m; i ++) {
                cin >> b;
                if (u[b] == 0) {
                        cout << "NO" << endl;
                        return 0;
                }
                u[b] --;
        }
        cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main(void){
  int a;
  cin>>a;
  if(a>=65&&a<=90){
      cout<<"1"<<endl;
      return 0;
  }
   if(a>=97&&a<=122){
      cout<<"2"<<endl;
      return 0;
  }
  else{
      cout<<"0"<<endl; 
      return 0;
  }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;

const int MAX = 1e6;
const ll mod = 1e9+7;
//二項計算に必要なテーブルを作る

ll fac[MAX] = {0};
ll finv[MAX] = {0};
ll inv[MAX] = {0};

void tableinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2;i<MAX;i++){
    fac[i] = fac[i-1]*i%mod;
    inv[i] = mod - inv[mod%i] * (mod/i)%mod;
    finv[i] = finv[i-1]*inv[i] % mod;
  }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}



int main(){
  int x,y;
  cin >> x >> y;
  tableinit();
  if((x+y)%3 != 0 ) {cout << 0 <<endl;return 0;}
  int n = ((-1)*x+2*y) / 3;
  int m = (2*x+(-1)*y) / 3;
  if(n < 0 || m <0) {cout << 0 <<endl;return 0;}
  ll ans = COM(n+m,n);
  cout << ans <<  endl;
}

Measured memory_bytes: 23680
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int cnt[256] = {};
  for (char c : s) cnt[c]++;
  if ((cnt['E'] == 0) ^ (cnt['W'] == 0)) {
    cout << "No" << endl;
    return 0;
  }
  if ((cnt['N'] == 0) ^ (cnt['S'] == 0)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
main = do
  s <- getContents
  let [a, b, c, x] = map read . lines $ s
  print $ select a b c x

select :: Int -> Int -> Int -> Int -> Int
select a b c x
  = length [(s, t, u) | s <- [0..a]
                      , t <- [0..b]
                      , u <- [0..c]
                      , 500 * s + 100 * t + 50 * u == x]


Measured memory_bytes: 508
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val M = ni()
    val K = ni()
    val A = na(N)
    val B = na(M)
    val cumA = LongArray(N + 1)
    for (i in 0 until N) {
      cumA[i + 1] = cumA[i] + A[i]
    }
    val cumB = LongArray(M + 1)
    for (i in 0 until M) {
      cumB[i + 1] = cumB[i] + B[i]
    }

    var ans = 0
    var j = M
    for (i in 0 .. N) {
      while(j > 0 && cumA[i] + cumB[j] > K) {
        j--
      }
      debug{"$i $j"}
      if (cumA[i] + cumB[j] <= K) {
        ans = max(ans, i + j)
      }
    }

    out.println(ans)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

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

int main()
{   char w[101];
    scanf("%s",w);
    int a[26]={0},l=strlen(w);
    for(int i=0;i<l;i++){
        a[w[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(a[i]%2==1){
            printf("No");
            return 0;
        }
    }
    printf("Yes");

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int k = scanner.nextInt();
		Set<Integer> set = new TreeSet<>();
		int cnt = 0;
		for (int i = a; i <= b; i++) {
			if (cnt >= k) {
				break;
			}
			cnt++;
			set.add(i);
		}
		cnt = 0;
		for (int i = b; i >= a; i--) {
			if (cnt >= k) {
				break;
			}
			cnt++;
			set.add(i);
		}
		
		for (Integer ans : set) {
			System.out.println(ans);
		}
		scanner.close();

	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N,C,K; cin>>N>>C>>K;
    vint t(N);
    REP(i,N) cin>>t[i];
    sort(ALL(t));
    
    int ans=0;
    for(int i=0;i<N;)
    {
        int nxt=upper_bound(ALL(t),t[i]+K)-t.begin();
        nxt=min(nxt,i+C);
        i=nxt; ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
N,K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7

plus,minus,zero = 0,0,0
for i in range(N):
    if A[i] > 0:
        plus += 1
    elif A[i] < 0:
        minus += 1
    else:
        zero += 1

if N == K:
    ans = 1
    for i in range(N):
        ans *= A[i]
        ans %= MOD
    print(ans)

else:
    if K%2 == 1 and minus == N: # 負の場合
        A.sort(reverse=True)

        ans = 1
        for i in range(K):
            ans *= A[i]
            ans %= MOD
        print(ans)

    else: # そうじゃない場合
        l = []
        for i in range(N):
            if A[i] < 0:
                fugou = -1
            else:
                fugou = 1
            l.append((abs(A[i]),fugou))
        l.sort(reverse=True)
        #print(l)

        ans = 1
        fu = 0
        for i in range(K):
            if l[i][1] < 0:
                fu += 1
            ans *= l[i][0]
            ans %= MOD

        if fu%2 == 0:
            print(ans)
        elif ans == 0:
            print(0)
        else:
            sei_suteru = -1
            fu_suteru = -1
            for i in range(K)[::-1]:
                if sei_suteru == -1:
                    if l[i][1] > 0:
                        sei_suteru = l[i][0]
                if fu_suteru == -1:
                    if l[i][1] < 0:
                        fu_suteru = l[i][0]
                
            sei_ireru = -1
            fu_ireru = -1
            for i in range(K,N):
                if sei_ireru == -1:
                    if l[i][1] > 0:
                        sei_ireru = l[i][0]
                if fu_ireru == -1:
                    if l[i][1] < 0:
                        fu_ireru = l[i][0]

            #print(ans)
            #print(sei_suteru,fu_suteru,sei_ireru,fu_ireru)
            if sei_suteru >= 0 and fu_suteru >= 0 and sei_ireru >= 0 and fu_ireru >= 0:
                if sei_ireru*sei_suteru <= fu_ireru*fu_suteru: # 正を捨てて負を入れる方がいいとき
                    ans = -ans * -fu_ireru * pow(sei_suteru,MOD-2,MOD)
                    ans %= MOD
                else: # 負を捨てて正を入れる方がいいとき
                    ans = -ans * sei_ireru * pow(-fu_suteru,MOD-2,MOD)
                    ans %= MOD
            elif sei_ireru == -1 or fu_suteru == -1:
                ans = -ans * -fu_ireru * pow(sei_suteru,MOD-2,MOD)
                ans %= MOD
            else:
                ans = -ans * sei_ireru * pow(-fu_suteru,MOD-2,MOD)
                ans %= MOD

            print(ans)

Measured memory_bytes: 111908
#include<bits/stdc++.h>
using namespace std;
int a,k,s;
bool work(int n)
{
	s=(n-n%10)/10;
	k=n%10;
	if(s==0&&k!=9)
		return 0;
	if(k==9)
		return 1;
	else
		work(s);
}
int main()
{
	cin>>a;
	if(work(a)==1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
a.sort()

l = []

for i in range(n):
    li = abs(i - (n-1-i))
    l.append(li)
    
l.sort()


for ai, li in zip(l,a):
    if ai != li:
        print(0)
        sys.exit()

d = Counter(l)
mod = 10 ** 9 + 7
ans = 1

for li in d:
    for j in range(1,d[li]+1):
        ans *= j
        ans %= mod

print(ans)


Measured memory_bytes: 22244
#include<iostream>
#include<utility>
#include<queue>

#define P pair<int,int>
using namespace std;

int main(void){

	std::ios_base::sync_with_stdio();

	P st;
	int dx[]={ 2, 2, 2, 1, 1, 0, 0,-1,-1,-2,-2,-2};
	int dy[]={ 0, 1,-1, 2,-2, 2,-2, 2,-2, 0, 1,-1};
	int kx[]={ 1, 1, 1, 0, 0, 0,-1,-1,-1};
	int ky[]={-1, 0, 1,-1, 0, 1,-1, 0, 1};
	int nx,ny;
	int be,af;
	int n;
	int cnt;
	int map[10][10][10];
	bool flag;
	int sql[2][10];/*0...x 1...y*/
	queue<P > now;

	while(1){
		cin>>st.first>>st.second;
		if(st.first==0&&st.second==0) break;
		cin>>n;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					map[i][j][k]=-1;
				}
			}
		}
		for(int i=0;i<n;i++) cin>>sql[0][i]>>sql[1][i];
		now.push(P(st.first,st.second));
		flag=false;
		cnt=0;
		be=1;
		af=0;
		while(!now.empty()&&!flag){
			nx=now.front().first;
			ny=now.front().second;
			map[cnt][nx][ny]=1;
			for(int i=0;i<12;i++){
				if(nx+dx[i]>=0&&nx+dx[i]<10&&ny+dy[i]>=0&&ny+dy[i]<10){
					for(int j=0;j<9;j++){
						if(sql[0][cnt]+kx[j]>=0&&sql[0][cnt]+kx[j]<10&&sql[1][cnt]+ky[j]>=0&&sql[1][cnt]+ky[j]<10){
							if(nx+dx[i]==sql[0][cnt]+kx[j]&&ny+dy[i]==sql[1][cnt]+ky[j]){
								if(map[(cnt+1)%n][nx+dx[i]][ny+dy[i]]==1) flag=true;
								else if(map[(cnt+1)%n][nx+dx[i]][ny+dy[i]]==-1){
									af++;
									map[(cnt+1)%n][nx+dx[i]][ny+dy[i]]=0;
									now.push(P(nx+dx[i],ny+dy[i]));
								}
							}
						}
					}
				}
			}
			be--;
			if(be==0){
				be=af;
				af=0;
				cnt++;
				if(cnt==n) cnt=0;
			}
			now.pop();
		}
		if(flag) cout<<"OK"<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

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

    ll ans = LINF;

    rep(bit, (1<<n)){
        ll cnt     = 0;
        ll score   = 0;
        ll highest = a[0]-1;

        rep(i, n){
            if(bit & (1<<i)){
                score += max((ll)0, highest-a[i]+1);
                highest = max(highest+1, a[i]);
                cnt++;
            }
            highest = max(highest, a[i]);
        }

        if(cnt >= k){
            ans = min(ans, score);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;typedef long long ll;
#define inf 0x3f3f3f3f
#define read(x) scanf("%d",&x)
#define lowbit(x) (x&-x)
const int N=2e5+7;
int T;
int n,m;
int f[N];
int fid(int x)
{
    if(x==f[x]) return x;
    return f[x]=fid(f[x]);
}
void combine(int x,int y)
{
    int fx=fid(x),fy=fid(y);
    if(fx!=fy){
        f[fx]=fy;
    }
}
int main()
{
    read(n),read(m);
    for(int i=1;i<=n;i++) f[i]=i;
    for(int i=0,x,y;i<m;i++){
        scanf("%d%d",&x,&y);
        combine(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(fid(i)==i) ans++;
    printf("%d\n",ans-1);

    return 0;
}
/**


**/


Measured memory_bytes: 4220
N = int(input())
A = list(map(int,input().split()))

DP = [[[0,0] for i in range(2)] for i in range(N+1)]
DP[0][0][1] = 1000
DP[0][1][1] = 1000
ans = 1000
for i in range(1,N+1):
    if DP[i-1][0][0] < DP[i-1][1][1]//A[i-1]:
        DP[i][0] = [DP[i-1][1][1]//A[i-1],DP[i-1][1][1]%A[i-1]]
    elif DP[i-1][0][0] == DP[i-1][1][1]//A[i-1]:
        DP[i][0] = [DP[i-1][1][1]//A[i-1],max(DP[i-1][0][1],DP[i-1][1][1]%A[i-1])]
    else:
        DP[i][0] = DP[i-1][0]

    if DP[i-1][1][1] < DP[i-1][0][0]*A[i-1]+DP[i-1][0][1]:
        DP[i][1] = [0,DP[i-1][0][0]*A[i-1]+DP[i-1][0][1]]
    else:
        DP[i][1] = DP[i-1][1]

    ans = max(ans,DP[i][1][1])

print(ans)

Measured memory_bytes: 62388
#include<stdio.h>
#include<ctype.h>

int main()
{
	char s;
	int i = 0, count[26] = {};
	char alpha[] = "abcdefghijklmnopqrstuvwxyz";

	while ((s = getchar()) != EOF){
		s = tolower(s);
		for (i = 0; i < 26; i++){
			if (s == 'a' + i)
				count[i]++;
		}
	}

	for (i = 0; i < 26; i++)
	{
		printf("%c : %d\n", alpha[i], count[i]);
	}


	return(0);
}

Measured memory_bytes: 524
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const ll FINAL = 0x0ba9876543210ll;

struct Data
{
	ll s;
	int d;
	bool f;
	Data(ll s, int d, bool f) : s(s), d(d), f(f) {}
};

int bfs(ll init)
{
	if(init == FINAL)
		return 0;
	
	const int move[13][5] = {
		{2, -1},
		{2, 5, -1},
		{0, 1, 3, 6, -1},
		{2, 7, -1},
		{5, -1},
		{1, 4, 6, 9, -1},
		{2, 5, 7, 10, -1},
		{3, 6, 8, 11, -1},
		{7, -1},
		{5, 10, -1},
		{6, 9, 11, 12, -1},
		{7, 10, -1},
		{10, -1}
	};
	
	set<ll> visited[2];
	queue<Data> Q;
	Q.push(Data(init, 0, false));
	Q.push(Data(FINAL, 0, true));
	visited[0].insert(init);
	visited[1].insert(FINAL);
	int now[2] = {0};
	
	while(!Q.empty()){
		Data data = Q.front();
		Q.pop();
		now[data.f] = data.d + 1;

		for(int i=0, cnt=2; cnt; ++i){
			if(((data.s>>(i*4)) & 0xfll) == 0){
				for(int j=0; move[i][j]!=-1; ++j){
					ll next = data.s;
					next &= ~((0xfll << (i*4)) | (0xfll << (move[i][j]*4)));
					next |= ((data.s >> (move[i][j]*4)) & 0xfll) << (i*4);
					
					if(visited[!data.f].find(next) != visited[!data.f].end())
						return now[0] + now[1];

					if(visited[data.f].find(next) == visited[data.f].end()){
						visited[data.f].insert(next);
						if(now[0]+now[1] < 20)
							Q.push(Data(next, data.d+1, data.f));
					}
				}
				--cnt;
			}
		}
	}
	return -1;
}

int main()
{
	for(;;){
		int input[13];
		rep(i, 13){
			scanf("%d", &input[i]);
			if(input[i] == -1)
				return 0;
		}

		ll init = 0;
		rep(i, 13)
			init = (init << 4) | input[12-i];

		int ans = bfs(init);
		if(ans == -1 || ans > 20)
			puts("NA");
		else
			printf("%d\n", ans);
	}
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int n;

struct Edge{
  int from, to, cost;
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost){}
};

vector<vector<int>> to;
vector<vector<int>> rev_to;
vector<bool> reach1; 
vector<bool> reach2; 

void dfs(int v){
  if(reach1[v])return;
  reach1[v] = true;
  for(auto nv : to[v])dfs(nv);
}

void dfs2(int v){
  if(reach2[v])return;
  reach2[v] = true;
  for(auto nv : rev_to[v])dfs2(nv);
}


int ng = 0;

vector<Edge> es;
vector<int> dist;
void bellman_ford(int s){ 
  dist.assign(n, INF);
  dist[s] = 0;
  for(int i = 0; i < n; ++i){
    for(auto e : es){
      if(e.from == INF)continue;
      if(!reach1[e.from] || !reach2[e.from])continue;
      if(!reach1[e.to] || !reach2[e.to])continue;
      if(dist[e.from] + e.cost < dist[e.to]){
        dist[e.to] = dist[e.from] + e.cost;
        if(i == n - 1)ng = 1;
      }
    }
  }
}

int main(){
  int m, p;
  cin >> n >> m >> p;
  to.resize(n);
  rev_to.resize(n);
  for(int i = 0; i < m; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    c -= p;
    c *= -1;
    es.push_back(Edge(a, b, c));
    to[a].push_back(b);
    rev_to[b].push_back(a);
  }

  reach1.assign(n, false);
  reach2.assign(n, false);
  dfs(0);
  dfs2(n - 1);
  bellman_ford(0);
  if(ng)cout << -1 << endl;
  else cout << max(0, -dist[n - 1]) << endl;
  return 0;
}


Measured memory_bytes: 640
h,  w =  map(int, input().split())
a = []
a.append("."*(w+2))
for _ in  range(h):
    a.append("."+input()+".")
a.append("."*(w+2))

for i in range(1, h+1):
    ans = ""
    for j in range(1, w+1):
        if a[i][j] == ".":
            ans += str([a[i-1][j-1], a[i-1][j], a[i-1][j+1], a[i][j-1], a[i][j+1], a[i+1][j-1], a[i+1][j], a[i+1][j+1]].count("#"))
        else:
            ans += "#"
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll S;

int main(){
	cin>>S;
	ll l=1,r=1000000001;
	while(r-l>1){
		ll m=(l+r)/2;
		if(m*m<=S) l=m;
		else r=m;
	}
	ll t=l,a,tmp=0;
	if(t*t==S){
		cout<<0<<' '<<0<<' '<<t<<' '<<0<<' '<<0<<' '<<t<<endl;
		return 0;
	}
	if(t*(t+1)>=S) a=t*(t+1)-S;
	else a=(t+1)*(t+1)-S,tmp++;
	cout<<0<<' '<<0<<' '<<t+tmp<<' '<<a<<' '<<1<<' '<<t+1<<endl;
}

Measured memory_bytes: 256
while n = STDIN.gets
  if n == "0\n" then break end
  n = n.chomp.to_i
  airport_codes=[]
  max_length=0
  n.times do 
    airport_name = STDIN.gets.chomp
    airport_code=""
    airport_name.chars.each_with_index do |c, i|
      if i == 0 or airport_name[i-1] == 'a' or airport_name[i-1] == 'i' or airport_name[i-1] == 'u' or airport_name[i-1] == 'e' or airport_name[i-1] == 'o' then
        airport_code += c 
      end 
    end
    airport_codes.push(airport_code)
    if max_length < airport_code.length then
      max_length = airport_code.length
    end
  end
  airport_codes_substring=[]
  k=-1
  (0...max_length).each do |i|
    airport_codes_substring =  airport_codes.map { |code| code[0..i] }
    has_duplicate = airport_codes_substring.find { |code| airport_codes_substring.count(code) > 1 }
    if has_duplicate == nil then 
      k = i+1
      break 
    end 
  end
  puts k
end

Measured memory_bytes: 8876
H, W = map(int, input().split())
M = [list(input()) for _  in range(H)]
visited = [[0]*W for _ in range(H)]

from collections import deque
q = deque([[0, 0]])
while q:
    i, j = q.popleft()
    if i == H-1 and j == W-1:
        break
    
    for movei, movej in ((0, 1), (0, -1), (1, 0), (-1, 0)):
        ni = i + movei; nj = j + movej
        if ni < 0 or H <= ni or nj < 0 or W <= nj:
            continue
        if M[ni][nj] == '#':
            continue
        if visited[ni][nj] != 0:
            continue
        visited[ni][nj] = (i, j)
        q.append([ni, nj])
else:
    print(-1)
    exit()

si, sj = H-1, W-1
M[si][sj] = '*'
while si != 0 or sj != 0:
    si, sj = visited[si][sj]
    M[si][sj] = '*'
c = 0 
for i in range(H):
    c += M[i].count('.')
print(c)

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

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

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  if(a >= k){
    cout << a-k << " " << b << endl;
  }else if(a+b>=k){
    cout << 0 << " " << b-(k-a) << endl;
  }else{
    cout << 0 << " " << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
a, b = (int(_) for _ in input().split())
res = 0
for i in range(4,a+1):
    for ii in range(10,b+1):
        if (ii % 10) >= 2 and (ii //10) >= 2:
            if i == ((ii % 10) * (ii //10)):
                res += 1

print(res)




Measured memory_bytes: 3060