akhauriyash/Code-Regression huggingface dataset:
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
	cpp();
	ll n, w;
	cin >> n >> w;
	vector<ll> wei(n);
	vector<ll> val(n);
	ll maxV = n * 1000;
	for (ll i = 0; i < n; i++) {
		cin >> wei[i] >> val[i];
	}
	vector<vector<ll> > dp(n + 1, vector<ll>(maxV + 1, 0));
	dp[0][0] = 0;
	for (ll i = 1; i <= maxV; i++) {
		dp[0][i] = INT_MAX;
	}
	for (ll i = 1; i <= n; i++) {
		for (ll v = 1; v <= maxV; v++) {
			dp[i][v] = dp[i - 1][v];
			if (val[i - 1] <= v) {
				if (dp[i - 1][v - val[i - 1]] != INT_MAX)
					dp[i][v] = min(dp[i][v], dp[i - 1][v - val[i - 1]] + wei[i - 1]);
			}
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= maxV; i++) {
		if (dp[n][i] <= w) {
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 80256
#include<iostream>
#include<set>
using namespace std;
int main(){
    int N, K; cin >> N >> K;
    unsigned long long int ans = 1;
    for(int i=0; i<N; i++){
        if(i == 0) ans *= K;
        else ans *= (K-1);
    }
    cout << ans;
}

Measured memory_bytes: 256
<?php

$n = fgets(STDIN);
$s = fgets(STDIN);

$nums = [0];
$num = 0;
for ($i=0; $i<strlen($s); $i++){
  if ($s[$i] == 'I'){
    $num ++;
    array_push($nums, $num);
  } else {
    $num --;
    array_push($nums, $num);    
  }
}

echo max($nums);

?>

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

int main() {
  int N, a, b;
  cin >> N >> a >> b;
  int ans = 0;
  
  for(int i = 1; i <= N; i++){
    int c = 0;
    int d = i;
    
    for(int j = 0; j < 5; j++){
      c += d%10;
      d /= 10;
    }
    if(c >= a && c <= b){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
q_list = [list(map(int, input().split()))for _ in range(q)]

cum_sum = [0] * n
for i in range(1, n):
    cum_sum[i] = cum_sum[i - 1]
    if s[i - 1: i + 1] == "AC":
        cum_sum[i] += 1

for i in range(q):
    print(cum_sum[q_list[i][1] - 1] - cum_sum[q_list[i][0] - 1])

Measured memory_bytes: 30704
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int total = 0;
    int o = 0;
    int e = 0;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            e++;
        } else {
            o++;
        }
        total += a[i];
    }

    ll ans = 1;

    if(p == 0){
        ll m = 0;
        for(int i = 0; i <= o; i += 2){
            m += nCr(o, i);
        }
        ans = pow(2, e) * m;
    } else {
        ll m = 0;
        for(int i = 1; i <= o; i += 2){
            m += nCr(o, i);
        }
        ans = pow(2, e) * m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    string key = "keyence"; //7文字
    cin >> S;

    if (S.find("keyence") != -1)
    { //先頭に取り除く部分がある場合
        //末尾に取り除く部分がある場合
        cout << "YES" << endl;
    }
    else
    {                //先頭以外に取り除く部分がある場合
        int cur = 0; //後ろから何文字目までkeyenceと一致するか
        for (; cur < 7;)
        {
            if (S[S.length() - cur - 1] == key[key.length() - cur - 1])
            {
                cur++;
                continue;
            }
            else
            {
                break;
            }
        }
        int tmp = 0; //前から何文字目までkeyenceと一致するか
        for (; tmp < 7;)
        {
            if (S[tmp] == key[tmp])
            {
                tmp++;
                continue;
            }
            else
            {
                break;
            }
        }
        if (tmp + cur >= 7)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr char sp = ' ';

int T;
ll N, A, B, C, D;

ll tourist() {
	set<ll>st;
	priority_queue < pair<ll, pair<ll, bool>>, vector<pair<ll, pair<ll, bool>>>, greater<pair<ll, pair<ll, bool>>>>pq;
	pq.push({ 0,{N,true} });
	while (true) {
		ll d = pq.top().first;
		ll v = pq.top().second.first;
		bool b = pq.top().second.second;
		pq.pop();
		if (st.insert(v).second) {
			if (v == 0)return d;
			if (b) {
				for (ll i = max(0ll, v - 4); i <= v + 4; i++) {
					pq.push({ d + abs(i - v)*D,{i,false} });
				}
				if (D <= (5e18) / v) {
					pq.push({ d + v*D,{0,false} });
				}
			}
			if (v % 2 == 0) {
				pq.push({ d + A,{v / 2,true} });
			}
			if (v % 3 == 0) {
				pq.push({ d + B,{v / 3,true} });
			}
			if (v % 5 == 0) {
				pq.push({ d + C,{v / 5,true} });
			}
		}
	}
}

int main() {
	cin >> T;
	while (T--) {
		cin >> N >> A >> B >> C >> D;
		cout << tourist() << endl;
	}
}

Measured memory_bytes: 6040
n = int(input())
shop = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
candidate = []
for i in range(1, 2 ** 10):
    is_open = [False] * 10
    cnt = [0] * n
    for j in range(10):
        if (i >> j) & 1:
            is_open[j] = True
    for k in range(n):
        for l in range(10):
            if is_open[l] and shop[k][l] == 1:
                cnt[k] += 1
    now_profit = 0
    for k in range(n):
        now_profit += p[k][cnt[k]]
    candidate.append(now_profit)
candidate.sort(reverse=True)
print(candidate[0])

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

using namespace std;

int W, H;
int dp[1400][1400];
bool map[1400][1400];//true??§????????????

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> map[i][j];
		}
	}
	int ans = 0;
	if (!map[0][0])dp[0][0] = 1, ans = 1;
	else dp[0][0] = 0;
	for (int j = 1; j < W; j++) {
		if (!map[0][j])dp[0][j] = 1,ans = 1;
		else dp[0][j] = 0;
	}
	for (int i = 1; i < H; i++) {
		if (!map[i][0])dp[i][0] = 1,ans = 1;
		else dp[i][0] = 0;
	}
	for (int i = 1; i < H; i++) {
		for (int j = 1; j < W; j++) {
			if (map[i][j])continue;
			int tmp = 1000000;
			tmp = min(tmp, dp[i - 1][j]);
			tmp = min(tmp, dp[i][j - 1]);
			tmp = min(tmp, dp[i - 1][j - 1]);
			dp[i][j] = tmp + 1;
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans * ans << endl;
	return 0;
}

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

int main() {
    double x1, y1, x2, y2, dx, dy, ans;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = x2-x1; dy = y2-y1;
    ans = sqrt(dx*dx + dy*dy);
    printf("%.8lf", ans);
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int N = s.size();
    string answer = "";
    for (int i = 0; i < N; ++i)
    {
        if (i % 2 == 0){
            answer += s[i];
        }
    }
    cout << answer << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int a, b;
    cin >> a >> b;
    int ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int N;
    cin >> N;
    int n = N%10;

    if(n==2 || n==4 || n==5 || n==7 || n==9)
    {
        cout << "hon" << endl;
    }
    else if(n==0 || n==1 || n==6 || n==8)
    {
        cout << "pon" << endl;
    }
    else if(n==3)
    {
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
//cout<<"Case #"<<v1+1<<": ";
 
ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {     
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}

int main()
{
    fastio
	ll t,i,j,x,n;
	
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k)
	cout<<k;
	else if(k<=(a+b))
	{
	    cout<<a;
	}
	else
	{
	    ll ans=a;
	    ll z=(a+b)-k;
	    cout<<ans+z;
	}
    return 0;
}

Measured memory_bytes: 3616
import * as fs from 'fs';

namespace AtCoder.abc137 {

    export class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * 3 7
         * out
         * 5 6 7 8 9
         */
        main(): void {
            const [k, x] = this.args[0].split(' ').map(Number);

            let min: number = 0;
            let max: number = 0;

            min = (x - k < -1000000) ? -1000000 : x - k;
            max = (x + k > 1000000) ? 1000000 : x + k;

            let ans: string = '';
            for (let i = min+1; i < max; i++) {
                ans += i.toString() + ' ';
            }
            console.log(ans.trim());


        }
    }

}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc137.Program(args);
prg.main();




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

using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (count(s.begin(), s.end(), '7') > 0) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  vector<int> ans;
  for (int i=1; i<=n; i++) {
    if (sum > n) break;
    sum += i;
    ans.push_back(i);
  }
  int out = 0;
  if (sum - n != 0) out = sum - n;
  for (int i=0; i<ans.size(); i++) {
    if (ans[i] != out) cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn],a[maxn],b[maxn];
int main() {
    string a,b;cin>>a>>b;
    if(b.length()<=a.length()) {puts("No");return 0;}
    if(b.substr(0,a.length())==a) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>  
using namespace std;  
  
int ans, s, n;  
  
void dfs(int i, int sum, int n){  
    if((sum == s) && (n == 0)){  
        ans++;  
        return;  
    }  
    if((i == 10) || (n == 0)) return;  
    dfs(i+1, sum, n);  
    dfs(i+1, sum+i, n-1);  
}  
  
int main(){  
    while(cin >> n >> s){  
        ans = 0;  
        if(n == 0 && s == 0) break;  
        dfs(0, 0, n);  
        cout << ans << endl;  
    }  
    return 0;  
}  

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class ABC
{
    //          long[] sp = Console.ReadLine().Split().Select(long .Parse).ToArray();
    //          int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
        double ans = 1.0 * sp[0] / (sp[1] * 2 + 1);
        double output = Math.Ceiling(ans);
            Console.WriteLine(output);

    }




}




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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

using namespace std;

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

	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
	} else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import heapq
N = int(input())
AB = []
for i in range(N):
    ab = list(map(int, input().split()))
    AB.append([-ab[0] - ab[1], -ab[0], -ab[1]])

AB.sort(reverse=True)

heapq.heapify(AB)
ans = 0
for i in range(N):
    q = heapq.heappop(AB)
    if i % 2 == 0:
        ans += - q[1]
    else: ans += q[2]
print(ans)

Measured memory_bytes: 25068
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main()
{
    while (1)
    {
        ll a;
        cin >> a;
        if (a != 0)
        {
            ll tmp = 1000 - a;
            ll cnt = 0;
            cnt += tmp / 500;
            tmp = tmp % 500;
            cnt += tmp / 100;
            tmp = tmp % 100;
            cnt += tmp / 50;
            tmp = tmp % 50;
            cnt += tmp / 10;
            tmp = tmp % 10;
            cnt += tmp / 5;
            tmp = tmp % 5;
            cnt += tmp / 1;
            cout << cnt << endl;
        }
        else
        {
            return 0;
        }
    }
}



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

int **matrix, *seq, *sea, eflag, counter;

void cycle_path(int, int);
int main(void) {
  int i, v, e, s, t;
  scanf("%d %d", &v, &e);
  matrix = (int**)malloc(sizeof(int*) * v);
  seq = (int*)calloc(v, sizeof(int));
  sea = (int*)calloc(v, sizeof(int));
  for (i = 0; i < v; i++) matrix[i] = (int*)calloc(v, sizeof(int));
  for (i = 0; i < e; i++) {
    scanf("%d %d", &s, &t);
    matrix[s][t] = 1;
  }
  for (i = 0; i < v; i++) {
    if (!seq[i]) cycle_path(i, v);
    if (eflag) break;
  }
  if (eflag) printf("1\n");
  else printf("0\n");
  for (i = 0; i < v; i++) free(matrix[i]);
  free(matrix);
  free(seq);
  free(sea);
}
void cycle_path(int point, int size)
{
  int i;
  if (!eflag) {
    seq[point] = ++counter;
    sea[point] = 1;
    for (i = 0; i < size; i++) {
      if (!matrix[point][i]) continue;
      if (!seq[i]) cycle_path(i, size);
      else {
        if (seq[i] < seq[point] && sea[i]) eflag = 1;
      }
    }
    sea[point] = 0;
  }
}


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

int main() {
  int height[10], i;
  for (i = 0; i < 10; i++) {
    cin >> height[i];
  }
  sort(height, height + 10, greater<int>());
  for (i = 0; i < 3; i++) {
    cout << height[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
const LL MOD = 1000000007LL;
map<P, LL> memo;
LL f(LL S, LL X) {
	if (S == 0) return 1;
	if (memo.find(P(S, X)) != memo.end()) return memo[P(S, X)];
	LL ret = f(S / 2, X / 2);
	if (S >= 1 && X >= 1) (ret += f((S - 1) / 2, (X - 1) / 2)) %= MOD;
	if (S >= 2) (ret += f((S - 2) / 2, X / 2)) %= MOD;
	return memo[P(S, X)] = ret;
}
int main() {
	LL N;
	cin >> N;
	cout << f(N, N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int ara[200001],cnt[200001];
int main()
{
    int n;
    cin>>n;

    for(int i=2;i<=n;i++){
        cin>>ara[i];
        cnt[ara[i]]++;
    }
    for(int i=1;i<=n;i++)
        cout<<cnt[i]<<endl;
}


Measured memory_bytes: 5192
import sys
s = [c for c in "AKIHABARA"]
L = []
for i in range(0, 2):
    for j in range(0, 2):
        for k in range(0, 2):
            for l in range(0, 2):
                if i == 0:
                    s[0] = "X"
                if j == 0:
                    s[4] = "X"
                if k == 0:
                    s[6] = "X"
                if l == 0:
                    s[8] = "X"
                while "X" in s:
                    s.remove("X")
                L.append(s)
                s = [c for c in "AKIHABARA"] #bitで書きたかった・・・。
S = [c for c in input()]
for el in L:
    if S == el:
        print("YES")
        sys.exit(0)
print("NO")

Measured memory_bytes: 8812
using System;

class Program
{
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();

        if (a.Length == b.Length)
        {
            int c = string.Compare(a, b);
            if (c < 0)
                Console.WriteLine("LESS");
            if (c == 0)
                Console.WriteLine("EQUAL");
            if (c > 0)
                Console.WriteLine("GREATER");
        }
        else
        {
            Console.WriteLine(a.Length < b.Length ? "LESS" : "GREATER");
        }
    }
}

Measured memory_bytes: 11232
import collections
import math

N = int(input())

al = "abcdefghijklmnopqrstuvwxyz"
al_dict = {}
for i, c in enumerate(al):
    al_dict[c] = i

ss = []
for i in range(N):
    counts = [0 for i in range(26)]
    for char in input():
        ind = al_dict[char]
        counts[ind] += 1
    counts = [str(count) for count in counts]
    key = ",".join(counts)
    #c = collections.Counter(s0)
    #print(tuple(c))
    ss.append(key)

#print(ss)
cc = collections.Counter(ss)

#print(cc)
out = 0
for count in cc.values():
    if count == 1:
        continue
    out += math.factorial(count) // (math.factorial(count-2) * 2)
print(out)

#for s in ss:
#    for  in s[i+1]:
#        if s[i] == s[j]:
#            count += 1

#print(count)

Measured memory_bytes: 23920
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int N = in.nextInt();
        
        int a[][] = new int[N][N];
        
        for (int i = 0; i < N; i++){
            int idx = in.nextInt();
            int j = in.nextInt();
                for (int k = 0; k < j; k++){
                    int temp1 = in.nextInt();  
                    a[idx-1][temp1-1] = 1; 
                }
        }
        
        for (int i = 0; i < N; i++){
            for (int j = 0; j < N; j++){
                if (j != N-1){
                    System.out.print(a[i][j] + " ");
                }else{
                    System.out.println(a[i][j]);
                }
            }
        }

    }
    
}

Measured memory_bytes: 32348
n=int(input())
if n<=6:
    print(0)
else:
    if n%2==0:
        i=1
        c_of_5=0 
        while 5**i <= n:
            c_of_5+=n//((5**i)*2)
            i+=1
        print(c_of_5)
    else:
        print(0)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3= sc.nextInt();

		if(A1+A2+A3 > 21) {
			System.out.println("bust");
		}else {
			System.out.println("win");
			}

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define PI 3.1415926535897932384626433832795
using namespace std;

int main(){
    int n;
    cin>>n;
    ll a[n];
    ll dis[n+1];
    ll ans[n+1]={0};
    ll fin[n]={0};
    vector<int> all[n+1];
    f(i,n){
        cin>>a[i];
        all[a[i]].pb(1);
    }
    f(i,n+1){
        dis[i]=all[i].size();
        //cout<<dis[i]<<endl;
    }
    // f(i,n){
    //     if(dis[i]>0){
    //         fin++;
    //     }
    // }
    // f(i,n){
    //     if(all[a[i]].size()>=2){
    //         ans[i]= (fin * (fin-1))/2;
    //     }
    //     else{
    //         ans[i]= ((fin-1) *(fin-2))/2;
    //     }
    // }
    f(i,n+1){
        ans[i]=((dis[i])*(dis[i]-1))/2;
        //cout<<ans[i]<<endl;
    }
    ll ans1[n+1]={0};
    f(i,n+1){
        if(dis[i]>0){
            ans1[i] = ((dis[i]-1) * (dis[i]-2))/2;
            //cout<<ans1[i]<<endl;
        }
    }
    ll finA=0;
    f(i,n+1){
        finA= finA+ ans[i];
    }
    f(i,n){
        cout<<finA-ans[a[i]]+ans1[a[i]]<<endl;
    }
    


    return 0;
}



Measured memory_bytes: 18048
#include <bits/stdc++.h>
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
//#define all(a) a.begin(),a.end()
//#define pb push_back
//#define pob pop_back
typedef long long ll;
//using vi=vector<ll>;
using vc=vector<char>;
//using vvi=vector<vector<ll>>;
//bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
//bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
//int sum(vector<int> v){int x=0;rep(i,v.size()) x+=v[i];return x;}
//void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
//void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
void slove(){
  int n,ans=0;cin>>n;vc S(n);rep(i,n) cin>>S[i];
  rep(i,n-2) if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') ans++;
  cout<<ans<<endl;
}
int main(){
  slove();return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int t;
    if(b>=100) t=a*1000+b;
    else if(b>=10) t=a*100+b;
    else t=a*10+b;
    int k=sqrt(t);
    if(k*k==t) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left
input = sys.stdin.readline


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ai = a[-1]
    j = bisect_left(a, ai//2)
    aj = a[j]
    tmp = a[j-1]
    if aj == ai:
        aj = tmp
    elif ai // 2 - tmp < aj - ai // 2:
        aj = tmp
    print(ai, aj)


if __name__ == '__main__': main()

Measured memory_bytes: 14044
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	ll a, b;
	cin >> a >> b;

	println((a + b) % 24);
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  ll aI, aO, aT, aJ, aL, aS, aZ;
  cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ;

  ll res = 0;
  REP(i,2) {
    ll tmp = aO + ((aI - i) / 2) * 2 + ((aJ - i) / 2) * 2 + ((aL - i) / 2) * 2;
    if(aI > 0 && aJ > 0 && aL > 0) tmp += 3 * i;
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


int d[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
char dc[5] = "NESW";
char Map[25][25];

main(){
	int x,y,n,m,i,j;
	while(cin >> n, n){
		int sx, sy;
		for(i=0;i<=20;i++)
			for(j=0;j<=20;j++)
				Map[i][j] = 0;
		for(i=0;i<n;i++){
			cin >> x >> y;
			Map[x][y] = 1;
		}
		cin >> m;
		int ans = 0;
		x=10;y=10;
		for(j=0;j<m;j++){
			char c;
			int t;
			cin >> c >> t;
			int dt;
			for(i=0;i<4;i++) if(c == dc[i]) dt=i;
			for(i=0;i<t;i++){
				x += d[dt][0];
				y += d[dt][1];
				if(Map[x][y]){
					ans ++;
					Map[x][y] = 0;
				}
			}
		}
		cout << (ans == n ? "Yes":"No") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

#define int ll
#define endl '\n'


signed main() {
	fast;

	int n;
	cin>>n;
	vector<int> c(n);
	for(int i=0;i<n;i++) cin>>c[i];
	sort(all(c));

	int ans = 0;
	for(int i=0;i<n;i++) {
		int temp = c[i]*(n-i+1)%MOD;
		ans += temp;
		ans %= MOD;
	}

	ans *= power(2,2*n-2);
	ans %= MOD;

	cout<<ans;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    string C[2];
    cin >> C[0] >> C[1];
    if(C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0])
    {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

template<unsigned mod=1000000007>struct fp {
   unsigned v;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;

typedef pair<int,int> P;
Fp dp[310][310][310];

int main(){
   int n,m; cin>>n>>m;
   vector<P> rng[310];
   rep(i,0,m){
      int lb,rb,cnt; cin>>lb>>rb>>cnt;
      rng[rb].push_back({lb,cnt});
   }
   dp[0][0][0]=1;
   rep(i,0,n)rep(j,i,n)rep(k,j,n)if(dp[i][j][k]!=0){
      int ni=i,nj=j,nk=k+1; bool f=1;
      for(auto p:rng[k+1]){
         int l=p.first,c=p.second;
         int cnt=1;
         if(l<=nj)cnt++;
         if(l<=ni)cnt++;
         if(cnt!=c){f=0; break;}
      }
      if(f)dp[ni][nj][nk]+=dp[i][j][k];
      ni=i,nj=k,nk=k+1; f=1;
      for(auto p:rng[k+1]){
         int l=p.first,c=p.second;
         int cnt=1;
         if(l<=nj)cnt++;
         if(l<=ni)cnt++;
         if(cnt!=c){f=0; break;}
      }
      if(f)dp[ni][nj][nk]+=dp[i][j][k];
      ni=j,nj=k,nk=k+1; f=1;
      for(auto p:rng[k+1]){
         int l=p.first,c=p.second;
         int cnt=1;
         if(l<=nj)cnt++;
         if(l<=ni)cnt++;
         if(cnt!=c){f=0; break;}
      }
      if(f)dp[ni][nj][nk]+=dp[i][j][k];
   }
   Fp res;
   rep(i,0,n)rep(j,0,n)res+=dp[i][j][n];
   cout<<res.v<<endl;
   return 0;
}

Measured memory_bytes: 116608
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define MOD 1000000007
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a;
    cin >> n >> a;
    cout << (n * n) - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a,s;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a,s^=a;
	if(s==0)cout<<"Yes";
	else cout<<"No";
    return 0;
}

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

int main(){
  int n, a, s, t;
  t = 100;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    s = 0;
    for(int j = 0; ; j++){
      if(a % 2 == 0) {
        s++;
        a = a / 2;
      }
      else break;
    }
    t = min(s, t);
  }
  cout << t << endl;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c,d;cin>>a>>b>>c>>d;
  a*b<c*d ? cout<<c*d<<endl : cout<<a*b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;
int n;
unsigned long long ans;
struct town {
  int i, x, y;//, price;
};

town towns_x[100000];
town towns_y[100000];
int p[100000];
int r[100000];

bool x_sort(const town &l, const town &r) {
  return l.x < r.x;
}

bool y_sort(const town &l, const town &r) {
  return l.y < r.y;
}

struct D {
  int d, i, j;

  bool operator() (const D& left, const D& right) const {
    return left.d >= right.d;
  }
};

int find(int x) {
    if (x != p[x]) {
        p[x] = find(p[x]);
    }

    return p[x];
}

void merge(int x, int y) {
    int p_x = find(x);
    int p_y = find(y);
    if (p_y != p_x) {
        if (r[p_y] > r[p_x]) {
            p[p_x] = p_y;
        } else {
            p[p_y] = p_x;
            if (r[p_y] == r[p_x]) {
                r[p_x]++;
            }
        }
    }
}

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

  for (int i = 0; i < n; i++) {
    cin >> towns_x[i].x >> towns_x[i].y;
    towns_x[i].i = i;
    towns_y[i] = towns_x[i];
    p[i] = i;
  }

  sort(towns_x, towns_x + n, x_sort);
  sort(towns_y, towns_y + n, y_sort);
/*  bool good = true;
  for (int i = 0; (i < n) && good;) {
    good = false;
    for (int j = i+1; j < n; j++) {
      if (towns_x[i].x == towns_x[j].x) {
        p[j] = i;
      } else {
        good = true;
        i = j;
        break;
      }
    }
  }

  good = true;
  for (int i = 0; (i < n) && good;) {
    good = false;
    for (int j = i+1; j < n; j++) {
      if (towns_y[i].y == towns_y[j].y) {
        p[j] = i;
      } else {
        good = true;
        i = j;
        break;
      }
    }
  } */

  priority_queue<D, std::vector<D>, D> pq;

  for (int i = 1; i < n; i++) {
    D d;
    d.d = towns_x[i].x - towns_x[i-1].x;
    d.i = towns_x[i].i;
    d.j = towns_x[i-1].i;
    pq.push(d);

    d.d = towns_y[i].y - towns_y[i-1].y;
    d.i = towns_y[i].i;
    d.j = towns_y[i-1].i;
    pq.push(d);
  }

  while (!pq.empty()) {
    D d = pq.top();
    pq.pop();
  //  cout << d.d << endl;
    if (find(d.i) != find(d.j)) {
      merge(d.i, d.j);
      ans += d.d;
    }
  }

  cout << ans << "\n";

  return 0;
}



Measured memory_bytes: 7668
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	string s;
	cin >> s;

	bool result = false;
	if (s == "AAA" || s == "BBB")
	{
		result = true;
	}

	cout << (result ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 3580
A,B, M = gets.chomp.split.map(&:to_i)

a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

ans = a.min + b.min

def min(x,y)
  x < y ? x : y
end

M.times do
  x,y,c = gets.chomp.split.map(&:to_i)
  ans = min(ans, a[x-1] + b[y-1] - c)
end

puts ans



Measured memory_bytes: 19996
#include<cstdio>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	int imos[100003]={};
	rep(i,n+1){
		int l,r;
		if(i<n) scanf("%d%d",&l,&r);
		else    l=0, r=100001;
		imos[l]++;
		imos[r+1]--;
	}

	int ans,sum=0;
	rep(i,n+2){
		sum+=imos[i];
		if(i<=sum) ans=i-1;
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1112
N, M = map(int, input().split())
As = list(map(int, input().split()))

As.sort(reverse=True)
S = sum(As)
thre = S / (4 * M)

for i in range(M):
    if As[i] < thre:
        break
else:
    print('Yes')
    exit()
print('No')

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

int N;

int main() {

	cin >> N;

	int cnt = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j < N; j++) {
			if (i * j < N) {
				cnt += 1;
			}
			else {
				break;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3580
using System;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            for (int i; (i = int.Parse(Console.ReadLine())) != -1;) {
                var result = new System.Text.StringBuilder(10);
                while (i != 0) {
                    result.Insert(0, i & 3);
                    i >>= 2;
                }
                Console.WriteLine(result.Length == 0 ? "0" : result.ToString());
            }
        }
    }
}

Measured memory_bytes: 9352
N=int(input())
H=list(map(int,input().split()))

answer="Yes"

for i in range(1,N,):
    if H[N-i]>=H[N-i-1]:
        pass
    else:
        H[N-i-1]-=1
        if H[N-i]<H[N-i-1]:
            answer="No"

print(answer)

Measured memory_bytes: 14252
from collections import Counter
n = int(input())
s = []
for i in range(n):
    temp = input()[0]
    if temp in 'MARCH':
        s.append(temp)
c = Counter(s)
if len(c) < 3:
    print(0)
else:
    num = []
    for i in c:
        num.append(c[i])
    l = len(num)
    ans = 0
    for i in range(0, l):
        for j in range(i+1, l):
            for k in range(j+1, l):
                ans += num[i]*num[j]*num[k]
    print(ans)

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

int main() {

    int n, m, r, q;
    while (cin >> n >> m, (n or m)) {

        cin >> r;

        vector< pair<int, int> > nt[m+1];

        vector<int> tt(r), nn(r), mm(r), ss(r);
        rep(i, r) {
            cin >> tt[i] >> nn[i] >> mm[i] >> ss[i];
            nn[i]--;
            mm[i]--;
        }

        rep(i, r) {
            if (ss[i] == 1) {
                for (int j=i+1; j<r; ++j) {
                    if (nn[i] == nn[j] and mm[i] == mm[j] and ss[j] == 0 and tt[j] != -1) {
                        nt[mm[i]].push_back({tt[i], tt[j]});
                        tt[j] = -1;
                        break;
                    }
                }
            }
        }

        cin >> q;

        rep(i, q) {
            int ts, te, qm;
            cin >> ts >> te >> qm;

            int ans=0, s=-1, e=-1;
            qm--;

            for (auto se : nt[qm]) {
                int ss = se.first;
                int ee = se.second;

                if (ts > ee) continue;
                if (ss > te) break;

                if (s != -1 and e != -1) {
                    if (e >= ss) {
                        e = max(e, min(ee, te));
                    }
                    else {
                        ans += (e - s);
                        s = ss;
                        e = min(ee, te);
                    }
                }

                if (s == -1) {
                    s = max(ts, ss);
                }

                if (e == -1) {
                    e = min(te, ee);
                }

            }

            cout << ans + (e - s) << endl;

        }

    }
}

Measured memory_bytes: 3344
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  a=abs(x-a);
  b=abs(x-b);
  if(a>b)cout<<"B"<<endl;
  else cout<<"A"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int a, b, c, d;
signed main(){
	cin >>a >> b >> c >> d;
	if(a*b>c*d){
		cout << a*b << endl;
	}else{
		cout << c*d << endl;
	}
 
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int Lj4PdHRW;
  int A = 0;
  for(Lj4PdHRW=(0);Lj4PdHRW<(3);Lj4PdHRW++){
    A += rd_int();
  }
  if(A>=22){
    wt_L("bust");
    wt_L('\n');
  }
  else{
    wt_L("win");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// {
//   int A = 0;
//   rep(3) A += rd_int();
//   wt(if[A>=22, "bust", "win"]);
// }


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {

		int INF = 1 << 28;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int fee[][] = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(fee[i], INF);
			fee[i][i] = 0;
		}
		sc.useDelimiter(",|\\s+");
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();
			int d = sc.nextInt();
			fee[a][b] = c;
			fee[b][a] = d;
		}
		// }
		// 最終行は、x1, x2, y1, y2（整数;半角カンマ区切り）
		// x1：大工の出発する町の番号
		// x2：柱のある山里の番号
		// y1：殿様から大工が受け取ったお金
		// y2：柱の代金
		int x1 = sc.nextInt() - 1;
		int x2 = sc.nextInt() - 1;
		int y1 = sc.nextInt();
		int y2 = sc.nextInt();
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					fee[i][j] = Math.min(fee[i][j], fee[i][k] + fee[k][j]);
				}
			}
		}
		int ans = y1 - (y2 + fee[x1][x2] + fee[x2][x1]);
		System.out.println(ans);
	}
}

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

int h[100005], dp[100005];

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	for (int i = 1; i < n; i++) {
        dp[i] = 1e9;
        for (int j = i - 1; j >= max(i-k, 0); j--){
            dp[i] = min(dp[j] + abs(h[j] - h[i]), dp[i]);
        }
	}
	printf("%d", dp[n - 1]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double x = abs(30 * h + m / 2.0 - 6 * m);
    x = min(x, 360-x);
    const double PI = acos(-1);
    x = x * PI / 180;
    cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2 * a * b * cos(x)) << endl;
}


Measured memory_bytes: 4156
def solve():
    for i in range(1, H):
        for j in range(1, W):
            if s[i][j] == "#":
                if s[i + 1][j] == "." and s[i][j + 1] == "." and s[i-1][j] == "." and s[i][j-1] == ".":
                    print("No")
                    return;
    else:
        print("Yes")


H, W = [int(i) for i in input().split()]
s = [["."] * (W + 2)]
for _ in range(H):
    sh = ["."] + list(input()) + ["."]
    s.append(sh)
s.append([["."] * (W + 2)])
solve()





Measured memory_bytes: 3188