akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut c = 0;
    for mut e in a {
        while e % 2 == 0 {
            c += 1;
            e /= 2;
        }
    }
    println!("{}", c);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main()
{
int grid[3][3];
map<int,int>vis;
for(int i=0; i<3; ++i)
for(int j=0; j<3; ++j)
cin>>grid[i][j];
int n;
cin>>n;
for(int i=0; i<n; ++i)
{
int k;
cin>>k;
vis[k]=1;
}
int fn(0);
if(vis[grid[0][0]]&&vis[grid[0][1]]&&vis[grid[0][2]])
fn=1;
if(vis[grid[1][0]]&&vis[grid[1][1]]&&vis[grid[1][2]])
fn=1;
if(vis[grid[2][0]]&&vis[grid[2][1]]&&vis[grid[2][2]])
fn=1;
if(vis[grid[0][0]]&&vis[grid[1][0]]&&vis[grid[2][0]])
fn=1;
if(vis[grid[0][1]]&&vis[grid[1][1]]&&vis[grid[2][1]])
fn=1;
if(vis[grid[0][2]]&&vis[grid[1][2]]&&vis[grid[2][2]])
fn=1;
if(vis[grid[0][0]]&&vis[grid[1][1]]&&vis[grid[2][2]])
fn=1;
if(vis[grid[0][2]]&&vis[grid[1][1]]&&vis[grid[2][0]])
fn=1;
if(fn)
cout<<"Yes";
else
cout<<"No";
}


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

int main() {
    int d;
    int t;
    int s;
    cin >> d >> t >> s;
    float result = (float) d / s;
    if (result <= t) cout << "Yes";
    else cout << "No";
    
  
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
int N,Y,SEN,GOSEN,MAN,BOOL=0,i,j,k;
  scanf("%d %d",&N,&Y);
  for(i=0;i<=N;i++)
  {
    for(j=0;j<=N;j++)
    {
      k=N-(i+j);
      if(k>=0&&i+j+k==N&&10000*k+5000*j+1000*i==Y)
      {
	   MAN=k;
	   GOSEN=j;
        SEN=i;
        BOOL=1;
     	break;
      }
    }    
   }
  
  if(BOOL==1){printf("%d %d %d",MAN,GOSEN,SEN);}
  else printf("-1 -1 -1");
return 0;
}

Measured memory_bytes: 2128
N,Q = map(int,input().split())
s = str(input())
LEN = len(s)
SUM = [0 for _ in range(N+1)]
for i in range(2,N+1):
  if s[i-2:i] == "AC":
    SUM[i] += SUM[i-1]+1
  else:
    SUM[i] = SUM[i-1]
#print(SUM)

for i in range(Q):
  l,r = map(int,input().split())
  ans = SUM[r]-SUM[l-1]
  if l >=2 and s[l-2:l] == "AC":
    ans -= 1
  print(ans)

Measured memory_bytes: 6152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

int main(){
    int a,b;
    string s,A="",B="";
    cin>>s;
    A+=s[0]; A+=s[1];
    B+=s[2]; B+=s[3];
    a = atoi(A.c_str());
    b = atoi(B.c_str());
    if((a==0&&b>=13)||(a>=13&&b==0) ||(a>=13 && b>=13)||(a==0&&b==0)) cout<<"NA";
    else if(a<=12&&a>=1&&b>=1&&b<=12) cout<<"AMBIGUOUS";
    else if(a<=12 &&(b>=13||b==0)) cout<<"MMYY";
    else cout<<"YYMM";
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long int yen;
    long long int year=0,i=100;
    cin>>yen;
    for(;i<yen;)
    {
        i+=(0.01*i);
        year++;
    }
    cout<<year<<endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int n,x,m=0;

	while(true)	
	    {
	n=scan.nextInt();
	x=scan.nextInt();
	if(n==0 && x==0)break;
		for(int i=1;i<=n;i++)
		    {
			for(int j=1;j<=n;j++)
			    {
				for(int k=1;k<=n;k++)
				    {
					if(((i+j+k)==x) && (i<j) && (j<k))
					    {
						m++;
					
					    }
				    }
			    }
		    }
		System.out.println(m);
		m=0;
	    }
	
    }
}

Measured memory_bytes: 19620
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B");
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll l, n;
	cin >> l >> n;
	vl x(n + 1);
	REP(i, n)cin >> x[i + 1];
	x[0] = 0;
	x.push_back(l);
	ll ans = max(l - x[1], x[n]);
	{
		vl le(n + 1, 0), ri(n + 1, 0);
		REP(i, n) {
			le[i + 1] = le[i];
			le[i + 1] -= x[i + 1] - x[i];
			le[i + 1] += 2 * x[i + 1];
			if (i + 1 - 1 > n + 1 - (i + 1) - 1) {
				int k = min(n + 1 - (i + 1) - 1 + 1, i + 1);
				le[i + 1] -= 2 * x[i + 1 - k];
				le[i + 1] -= 2 * x[i + 1 - k - 1];
			}
		}
		RREP(i, n) {
			ri[i] = ri[i + 1];
			ri[i] += 2 * (l - x[i + 1]);
			if (n - i > i) {
				int k = min(i, n + 1 - (i + 1) - 1);
				ri[i] -= 2 * (l - x[i + 1 + k]);
				ri[i] -= 2 * (l - x[i + 1 + k + 1]);
			}
		}

		REP(i, n) {
			ans = max(ans, le[i + 1] + ri[i + 1]);
		}
	}
	{
		vl le(n + 1, 0), ri(n + 1, 0);
		REP(i, n) {
			le[i + 1] = le[i];
			le[i + 1] += 2 * x[i + 1];
			if (i + 1 > n + 1 - (i + 1) - 1) {
				int k = min(n + 1 - (i + 1) - 1, i + 1);
				le[i + 1] -= 2 * x[i + 1 - k];
				le[i + 1] -= 2 * x[i + 1 - k - 1];
			}
		}
		RREP(i, n) {
			ri[i] = ri[i + 1];
			ri[i] -= x[i + 2] - x[i + 1];
			ri[i] += 2 * (l - x[i + 1]);

			if (n - i - 1 > i) {
				int k = min(i + 1, n + 1 - (i + 1) - 1);
				ri[i] -= 2 * (l - x[i + 1 + k]);
				ri[i] -= 2 * (l - x[i + 1 + k + 1]);
			}
		}

		REP(i, n) {
			ans = max(ans, le[i] + ri[i]);
		}
	}
	cout << ans << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int N, M;
vector<pii> students;
vector<pii> checkpoints;

int dist(pii a, pii b)
{
    return abs(a.first - b.first) + abs(a.second - b.second);
}

void solve()
{
    cin >> N >> M;
    students = vector<pii>(N);
    checkpoints = vector<pii>(M);
    REP(i, N) cin >> students[i].first >> students[i].second;
    REP(i, M) cin >> checkpoints[i].first >> checkpoints[i].second;
    REP(i, N)
    {
        int visit = 0, min = INF;
        REP(j, M)
        {
           int d = dist(students[i], checkpoints[j]);
           if(d < min)
           {
               min = d;
               visit = j;
           }
        }
        cout << visit+1 << endl;
    }
}

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

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xmin[256];
int xmax[256];
int ymin[256];
int ymax[256];
char gchar[10];

int main(void){
	int h,w,n,tcase;
	cin >> tcase;
	REP(t,tcase){
		cin >> h >>w;
		n=0;
		VS b(h);
		REP(i,h)cin>>b[i];
		memset(xmin, -1,sizeof(xmin));
		memset(xmax, -1,sizeof(xmax));
		memset(ymin, -1,sizeof(ymin));
		memset(ymax, -1,sizeof(ymax));
		REP(i,h){
			REP(j,w){
				if(b[i][j] != '.'){
					if(xmin[b[i][j]]==-1)xmin[b[i][j]]=j;
					if(xmax[b[i][j]]==-1)xmax[b[i][j]]=j;
					if(ymin[b[i][j]]==-1)ymin[b[i][j]]=i;
					if(ymax[b[i][j]]==-1)ymax[b[i][j]]=i;
					xmin[b[i][j]] = min(xmin[b[i][j]], j);
					xmax[b[i][j]] = max(xmax[b[i][j]], j);
					ymin[b[i][j]] = min(ymin[b[i][j]], i);
					ymax[b[i][j]] = max(ymax[b[i][j]], i);
				}
			}
		}
		FOR(i,'A','Z'+1)if(xmin[i]!=-1)gchar[n++]=i;
		int cnt = 0;
		REP(i,n){
			REP(j,n){
				if(gchar[j]!=0){
					char c = gchar[j];
					int flag = 1;
					FOR(x, xmin[c], xmax[c]+1){
						FOR(y, ymin[c], ymax[c]+1){
							if(b[y][x]!='x' && b[y][x]!=c){
								flag = 0;
								break;
							}
						}
						if(!flag)break;
					}
					if(flag){
						FOR(x, xmin[c], xmax[c]+1)
							FOR(y, ymin[c], ymax[c]+1)
								b[y][x]='x';
						gchar[j]=0;
						cnt++;
						break;
					}
				}
			}
		}
		if(cnt == n)cout << "SAFE" << endl;
		else cout << "SUSPICIOUS" << endl;
	}
}

Measured memory_bytes: 1224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CUnification solver = new CUnification();
        solver.solve(1, in, out);
        out.close();
    }

    static class CUnification {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            char[] arr = s.toCharArray();
            int a = 0;
            int b = 0;
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == '0')
                    a++;
                else
                    b++;
            }
            out.println(Math.min(a, b) * 2);
        }

    }
}



Measured memory_bytes: 26784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=100010;
int ara[N];
int main()
{
    IOS;
    int n,k;cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>ara[i];
    int ans=inf;
    for(int i=k;i<=n;i++)
    {
        if(ara[i]>0&&ara[i-k+1]<0){
            int sum=ara[i]-ara[i-k+1];
            int f1=sum+ara[i];
            int f2=sum-ara[i-k+1];
//            cout<<i<<" "<<f1<<" "<<f2<<endl;
            ans=min(ans,min(f1,f2));
        }
        else
        {
            int sum;
            if(ara[i]<0)sum=abs(ara[i-k+1]);
            else sum=ara[i];
            ans=min(ans,sum);

        }
    }
    cout<<ans<<endl;
}


/*
8 7
-10 -4 -2 0 5 6 8 13

8 5
-15 -12 -8 -7 -4 -1 8 15
*/





Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;

string grid[2010];
     
int main(){
  ll H, W;

  cin >> H >> W;

  ll L[H][W];
  ll R[H][W];
  ll T[H][W];
  ll B[H][W];  

  for(int i = 0; i < H; ++i){
    cin >> grid[i];
    //cout << grid[i] << endl;
  }

  for(int i = 0; i < H; ++i){
    ll cnt = 1;
    for(int j = 0; j < W; ++j){
      if(grid[i][j] == '#'){
	cnt = 1;
	R[i][j] = 0;
      } else {
	R[i][j] = cnt;
	cnt++;

	//cout << R[i][j] << ",";
      }
    }

    //cout << endl;
  }

  //cout << endl;    

  for(int i = 0; i < H; ++i){
    ll cnt = 1;
    for(int j = 0; j < W; ++j){
      if(grid[i][W-1-j] == '#'){
	cnt = 1;
	L[i][W-1-j] = 0;
      } else {
	L[i][W-1-j] = cnt;
	cnt++;

	//cout << L[i][W-1-j] << ",";
      }
    }

    //cout << endl;
  }

  //cout << endl;  

  for(int j = 0; j < W; ++j){  
    ll cnt = 1;
    for(int i = 0; i < H; ++i){
      if(grid[i][j] == '#'){
	cnt = 1;
	B[i][j] = 0;
      } else {
	B[i][j] = cnt;
	cnt++;

	//cout << B[i][j] << ",";
      }
    }

    //cout << endl;
  }

  //cout << endl;

  for(int j = 0; j < W; ++j){  
    ll cnt = 1;
    for(int i = 0; i < H; ++i){
      if(grid[H-1-i][j] == '#'){
	cnt = 1;
	T[H-1-i][j] = 0;
      } else {
	T[H-1-i][j] = cnt;
	cnt++;

	//cout << T[H-1-i][j] << ",";
      }
    }

    //cout << endl;
  }

  ll tmp_max = 0;
  for(int j = 0; j < W; ++j){  
    for(int i = 0; i < H; ++i){
      ll cur = L[i][j] + R[i][j] + T[i][j] + B[i][j] - 3;
      if(cur > tmp_max) tmp_max = cur;
    }
  }
  

#ifdef DEBUG
  cout << "H=" << H << "W=" << W << endl;
#endif

  cout << tmp_max << endl;
  
  return 0;
}


Measured memory_bytes: 129408
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 絶対値を求める
UInt Abs(const Int a) {
    return a > 0 ? a : -a;
}

// ここの処理が問題によって変わる
// この関数の型とmain文内のPermutationLoopのテンプレート型が一致する
Int Func(vector<Int>& v, vector<Int>& p, vector<Int>& q) {
    // ループ前処理
    Int array_size = (Int)v.size();
    Int pPermuPosi = -1;
    Int qPermuPosi = -1;
    Int cnt = 0;
    do {
        bool isSameAsP = true;
        bool isSameAsQ = true;
        for (Int i = 0; i < array_size; ++i) {
            if (v[i] != p[i]) {
                isSameAsP = false;
            }
            if (v[i] != q[i]) {
                isSameAsQ = false;
            }
        }
        if (isSameAsP == true) {
            pPermuPosi = cnt;
        }
        if (isSameAsQ == true) {
            qPermuPosi = cnt;
        }
        ++cnt;
        // 階乗の各場合に行う処理
    } while (std::next_permutation(v.begin(), v.end()));
    // ループ後処理
    return Abs(pPermuPosi - qPermuPosi);
}

template <typename RetType, typename LoopFunc>
RetType PermutationLoop(Int n, LoopFunc loopFunc);

int main(void) {
    // 入出力処理
    Int n; // ループする回数 n! を決めるパラメータ
    cin >> n;
    vector<Int> p(n);
    vector<Int> q(n);
    for (Int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }
    for (Int i = 0; i < n; ++i) {
        cin >> q[i];
        --q[i];
    }

    // permutationループの処理(戻り値の型とキャプチャリストは問題によって変わる)
    // PermutationLoop<Func関数の戻り値型>[キャプチャリスト](引数)->戻り値の型
    // 引数 n : ループする回数 n! を決めるパラメータ 
    cout << PermutationLoop<Int>(n, [&p, &q]
            (vector<Int>& v) -> auto {
            return Func(v, p, q); 
            }
            ) << endl;
    return 0;
}

template <typename RetType, typename LoopFunc>
RetType PermutationLoop(Int n, LoopFunc loopFunc) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }
    return loopFunc(v);
}



Measured memory_bytes: 3628
s = int(input())
A = list()
B = list()
A.append(s)
B.append(s)
i = 0
while len(A)==len(B):
  if A[i] % 2 == 0:
    A.append(A[i] // 2)
  else:
    A.append(3*A[i] + 1)
  B = set(A)
  i += 1
print(i+1)

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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),().end()
#define SZ(x) ((int)(x).size())
typedef long long ll;



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

        int x;
        bool dev=false;
        cin>>x;

        if(x==1) {cout<<2<<endl; return 0;}
        while(1) {
                for(int j=2; j<sqrt(x); j++) {
                        if(x%j==0) {dev=true; break;}
                }
                if(dev==false) {break;}
                x++;
                dev=false;
        }
        cout<<x<<endl;
        return 0;
}


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

int main() {
  int N; cin >> N;
  int H[N]; for (int i = 0; i < N; i++) cin >> H[i];
  int dp[N]; dp[0] = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = dp[i-1] + abs(H[i-1] - H[i]);
    if (i > 1) dp[i] = min(dp[i], dp[i-2] + abs(H[i-2] - H[i]));
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 4292
def main():
    n = int(input())
    a = list(map(int, input().split())) + [0]

    money = 1000

    stock = 0
    i = 0
    while i < len(a):
        next_sell_value = a[i]
        next_sell = i
        buy_stock = False
        for j in range(i+1, len(a)):
            # print(j)
            # print(next_sell_value, a[j], a[i])
            if next_sell_value < a[j]:
                next_sell_value = a[j]
                next_sell = j
                buy_stock = True
                # print("buy", next_sell_value, a[i])
            if next_sell_value > a[j]:
                # print("break", i, j)
                break
        else:
            break
        
        # print(next_sell)

        if buy_stock:
            stock = money // a[i]
            money += stock * (a[next_sell] - a[i])

        i = j
    
    print(money)




    
    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 9176
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <climits>
#include <cmath>
#define lli long long int
using namespace std ;

int eval(vector<int> &height, vector<int> &dp, int i, int k)
{
	if(i == 0) return 0 ;
	if(dp[i] != -1) return dp[i] ;

	dp[i] = INT_MAX ;

	for(int j = 1 ; j <= k ; j++)
	{
		if(i-j < 0) break ;
		dp[i] = min(dp[i], eval(height,dp,i-j,k) + abs(height[i] - height[i-j])) ;
	}

	return dp[i] ;
}

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

	vector<int> height(n) ;
	vector<int> dp(n,-1) ;
	for(int i = 0 ; i < n ; i++) cin>>height[i] ;

	cout<<eval(height,dp,n-1,k)<<endl ;
	return 0;
}


Measured memory_bytes: 8832
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	// aのほうが小さくなる
	if (a < b) {
		swap(a, b);
	}
	while (a != 0) {
		b = b % a;
		swap(a, b);
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <functional>
using namespace std;

int A, B, cnt;

int main() {
	cin >> A >> B;
	for (int i = A; i <= B; i++) {
		string G = to_string(i);
		if (G[0] == G[4] && G[1] == G[3]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
  long long w, h, x, y;
  cin >> w >> h >> x >> y;
  
  cout << fixed << setprecision(10);
  cout << w * h / 2.0 << endl;
  if(x == w / 2.0 && y == h / 2.0) cout << 1 << endl;
  else cout << 0 << endl;
}

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

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

  map<char, int> mp;
  rep(i, w.size()) mp[w[i]]++;

  for (auto x : mp) {
    if (x.second % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

#define MAX 1000005
#define mod 1000000007

ll add(ll a,ll b)
{
	return (mod+(a+b)%mod)%mod;
}
ll mul(ll a,ll b)
{
	return (mod+(a*b)%mod)%mod;
}

ll n,m;
	
unordered_map <ll, vector <ll>> mp;

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

	ll n, m, k;
	cin>>n>>m>>k;
	
	vector <ll> A(n+1), B(m+1);
	
	ll sum0 = 0, sum1 = 0;
	
	for(ll i=0;i<n;i++)cin>>A[i], sum0 += A[i];
	for(ll i=0;i<m;i++)cin>>B[i];
	ll last = n-1;
	ll ans = 0;
	for(ll i=0;i<=m;i++)
	{
		while(sum0 + sum1 > k && last >= 0)
		{
			sum0 -= A[last];
			last--;
		} 
		if(sum0 + sum1 <= k)
		{
			ans = max(ans, i + last+1);
		}
		
		if(i!=m)
			sum1 += B[i];
	}
	
	cout<<ans<<endl;
	
	

}


Measured memory_bytes: 6348
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>
//#include <fstream>

using namespace std;
const int maxn = 2e5 + 5;

int tree1[maxn << 2], tree2[maxn << 2];
int n, q;

void init(int id, int l, int r) {
    if (l == r) {
        tree1[id] = tree2[id] = n;
        return;
    }
    int mid = (l + r) >> 1;
    init(id << 1, l, mid);
    init(id << 1 | 1, mid + 1, r);
    tree1[id] = tree2[id] = INT_MAX;
}


int query(int id, int l, int r, int v, int *tree) {
//    printf("%d %d %d\n", l, r, tree[id]);
    if (l == r) {
        return tree[id];
    }
    if (tree[id] != INT_MAX) {
        tree[id << 1] = min(tree[id], tree[id << 1]);
        tree[id << 1 | 1] = min(tree[id], tree[id << 1 | 1]);
        tree[id] = INT_MAX;
    }
    int mid = (l + r) >> 1;
    if (v <= mid) return query(id << 1, l, mid, v, tree);
    else return query(id << 1 | 1, mid + 1, r, v, tree);
}

void up(int id, int l, int r, int tl, int tr, int val, int *tree) {
    if (l == tl && r == tr) {
        tree[id] = min(tree[id], val);
        return;
    }
    if (tree[id] != INT_MAX) {
        tree[id << 1] = min(tree[id], tree[id << 1]);
        tree[id << 1 | 1] = min(tree[id], tree[id << 1 | 1]);
        tree[id] = INT_MAX;
    }
    int mid = (l + r) >> 1;
    if (tr <= mid) {
        up(id << 1, l, mid, tl, tr, val, tree);
    } else if (tl > mid) {
        up(id << 1 | 1, mid + 1, r, tl, tr, val, tree);
    } else {
        up(id << 1, l, mid, tl, mid, val, tree);
        up(id << 1 | 1, mid + 1, r, mid + 1, tr, val, tree);
    }
}

int main() {
    scanf("%d%d", &n, &q);
    init(1, 1, n);
    long long ans = 1LL * (n - 2) * (n - 2);
    for (int i = 0; i < q; i++) {
        int op, x;
        scanf("%d%d", &op, &x);
//        if(x==1) continue;
        if (op == 1) {
            int v = query(1, 1, n, x, tree1);
            ans -= (v - 2);
            up(1, 1, n, 1, v - 1, x, tree2);
        } else {
            int v = query(1, 1, n, x, tree2);
            ans -= (v - 2);
            up(1, 1, n, 1, v - 1, x, tree1);
        }
//        printf("%lld\n", ans);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7884
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int t1, t2;
  ll a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
    cout << "infinity";
  } else {
    if (a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2) {
      swap(a1, b1);
      swap(a2, b2);
    }
    if (a1 < b1) {
      cout << 0;
    } else {
      ll d1 = (a1 - b1) * t1, d2 = b1 * t1 + b2 * t2 - a1 * t1 - a2 * t2;
      if (d1 % d2 == 0)
        cout << (d1 / d2 * 2);
      else
        cout << (d1 / d2 * 2 + 1);
    }
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define ll long long

using namespace std;

const ll INF = LLONG_MAX / 2 - 1;


struct Edge {
	ll t;
	ll c;
	Edge(ll to, ll cost):t(to),c(cost){}
	Edge(){}
};

vector<ll> weigh;
ll R, C;

bool DFS(ll node, vector<vector<Edge> >& edge, ll& xmin, ll& ymin) {
	if (node < R) xmin = min(xmin, weigh[node]);
	else ymin = min(ymin, weigh[node]);
	for (auto &to : edge[node]) {
		if (weigh[to.t] == INF) {
			weigh[to.t] = to.c - weigh[node];
			if (not DFS(to.t, edge, xmin, ymin)) return false;
		}
		else {
			if (weigh[to.t] + weigh[node] != to.c) return false;
		}
	}
	return true;
}

int main() {
	cin >> R >> C;
	ll N;
	cin >> N;
	weigh.resize(R + C, INF);
	vector<vector<Edge> > edge(R+C);
	for(int i = 0; i < N; i++){
		ll r, c, a; cin >> r >> c >> a;
		--r; --c;
		edge[r].push_back(Edge(R+c,a));
		edge[R+c].push_back(Edge(r, a));
	}

	bool res = true;
	ll xmin, ymin;
	for(int i = 0; i < R + C; i++){
		if(weigh[i] == INF and edge[i].size() > 0) {
			xmin = ymin = numeric_limits<int>::max();
			weigh[i] = 0;
			if (not DFS(i,edge,xmin,ymin) or xmin+ymin < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 19584
#include<stdio.h>
int f(int a,int b,int d[110][2]){
  if(d[a][0]>d[b][0])return 1;
  if(d[a][0]<d[b][0])return 0;
  if(d[a][1]<d[b][1])return 1;
  if(d[b][1]>d[b][1])return 0;
  return a<b?1:0;
}
int main(){
  int a,b,t,n,m,i,j,r[110];
  char s[10];
  while(scanf("%d %*d %d",&n,&m),n||m){
    int w[110][110]={0};
    int d[110][2]={0};
    while(m--){
      scanf("%d %d %d %s",&a,&b,&t,s);
      if(s[0]=='C'){
	d[a][0]++;
	d[a][1]+=w[a][b]*1200+t;
      }
      else w[a][b]++;
    }
    for(i=1;i<=n;i++){
      r[i]=i;
      for(j=i;j-1&&f(i,r[j-1],d);j--)r[j]=r[j-1];
      r[j]=i;
    }
    for(i=0;i<n;i++)printf("%d %d %d\n",r[i+1],d[r[i+1]][0],d[r[i+1]][1]);
  }
  return 0;
}
 

Measured memory_bytes: 660
from collections import Counter

N=int(input())
A=[int(x) for x in input().split()]
Com=0

A_C=Counter(A)

for name,x in A_C.items():
    Com+=int(x*(x-1)/2)
    
for i in range(N):
    y=A_C[A[i]]
    print(Com-y+1)

Measured memory_bytes: 26780
//ll _(){
//    ll n,k;
//    cin >> n >> k;
//    vl arr(n);
//    cin >> arr;
//    map<ll,ll> cnt;
//    for(ll x : arr)
//        cnt[x] ++;
//    vl ans;
//    for(auto _ : cnt){
//        ll v,c;
//        tie(v,c) = _;
//        ans.pb(c);
//    }
//    sort(rall(ans));
//    ll ret = 0;
//    for(int i = k; i < sz(ans); ++i)
//        ret += ans[i];
//    return ret;
//}
//
//
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll _(){
    ll n,k;
    cin >> n >> k;
    vl arr(n);
    cin >> arr;
    map<ll,ll> cnt;
    for(ll x : arr)
        cnt[x] ++;
    vl ans;
    for(auto _ : cnt){
        ll v,c;
        tie(v,c) = _;
        ans.pb(c);
    }
    sort(rall(ans));
    ll ret = 0;
    for(int i = k; i < sz(ans); ++i)
        ret += ans[i];
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 16500
N, K = gets.chomp.split.map(&:to_i)
    h = gets.chomp.split.map(&:to_i)
    dp = Array.new(N, Float::INFINITY)
    dp[0] = 0
    for i in 0..N-2
      for j in 1..[N-i-1, K].min
        c = dp[i] + (h[i+j] - h[i]).abs
        dp[i+j] = c if c < dp[i+j]
      end
    end
    puts dp.last

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



int main()
{
    long long n;
    cin>>n;
    if(n%2!=0) { cout<<"0"<<endl; return 0; }
    n=n/2;
    long long ans=0;
    long long id=5;
    while(id<=n)
    {
        ans+=(n/id);
        id*=5;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
#define EPS 0.0001
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

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

    ll ans = max(a*c, max(a*d, max(b*c, b*d)));
    
    cout << ans << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

from collections import deque

N,X,Y = map(int, input().split())

count = [0 for i in range(N)]

for i in range(1,N):
  for j in range(i+1,N+1):
    distance = min(j-i, abs(X-i)+1+abs(Y-j))
    count[distance] += 1

for i in count[1:]:
  print(i)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

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

typedef long long ll;
typedef pair<int, int> p;

int main(){
  long double n, t, a;
  cin >> n >> t >> a;
  vector<long double> v;
  int res = -1;
  long double sa = INT_MAX;

  for (int i = 0; i < n; i++)
  {
    long double tmp;
    cin >> tmp;
    if(sa > abs(a - (t - tmp * 0.006)))
    {
      sa = abs(a - (t - tmp * 0.006));
      res = i;
    }
  }
  cout << res + 1 << endl;


}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n, m, k = readline() |> split |> parseArray
  a = readline() |> split |> parseArray
  b = readline() |> split |> parseArray

  aa = accumulate(+, a)
  ba = accumulate(+, b)
  nn = length(aa .<= k)
  mm = length(ba .<= k)
  ans = 0
  for i in 0:nn
    for j in mm:-1:0
      if (i == 0 ? 0 : aa[i]) + (j == 0 ? 0 : ba[j]) <= k
        mm = j
        ans = max(i + j, ans)
        break
      end
    end
  end

  println(ans)
end

main()


Measured memory_bytes: 236784
from collections import deque
n,m = map(int,input().split())
g = [[] for i in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    g[x-1].append(y-1)
    g[y-1].append(x-1)
ans = [-1]*n
deq = deque([0])
while deq:
    fr = deq.popleft()
    for go in g[fr]:
        if ans[go] == -1:
            ans[go] = fr
            deq.append(go)
print("Yes")
for i in ans[1:]:print(i+1)

Measured memory_bytes: 95160
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

li = [{1: N}]
for i in range(1, N-1):
    li.append({i: i, i+1: min(N-i+max(N-i-2, 0), N)})
li.append({N-1: N})

C = Counter(A)
for d in li:
    cnt = 0
    for k, v in d.items():
        if C[k] <= v:
            cnt += C[k]
        else:
            break
    else:
        if cnt == N:
            Yes()
            exit()
No()


Measured memory_bytes: 56536
N = int(input())
S = input()

dp1 = [set() for i in range(4)]
dp2 = [set() for i in range(4)]
dp1[0].add('')
for i, S_i in enumerate(S):
    for j, dp1_j in enumerate(dp1[:3]):
        for s in dp1_j:
            dp2[j].add(s)
            dp2[j + 1].add(s + S_i)
        dp2[3] = dp1[3]
    dp1 = dp2
    dp2 = [set() for i in range(4)]

print(len(dp1[-1]))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	}

}


Measured memory_bytes: 27184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,L,R;
  //入力 
  cin >> a >> b >> c >> d;
  //処理
	L = a + b;
 	R = c + d;
  
  if (L > R) {
   cout << "Left" << endl; 
  }else if (L < R){
   cout << "Right"<< endl;
  }else {
   cout << "Balanced" << endl;
  }
  
  //出力
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
const int N=1e9+7;
#define int long long
#define double long double
int dp[1000002]={0};
void sieve()
{
	for(int i=1;i<=1000002;i++)
	{
		for (int j = 1; j*i <= 1000002; ++j)
		{
			dp[i*j]+=1;
		}
	}
}
int32_t main()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 IOS;
int n;
cin>>n;
sieve();
int ans=0;
for (int i = 1; i <= n-1; ++i)
{
	int p=n-i;
	ans+=dp[p];
}
cout<<ans;

 	
 	 
 	 	
 	 
 

 	



  
 




  
return 0;
}


Measured memory_bytes: 11444
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
	int n ,w;
	cin >> n >> w;
	vector<int> weight(n);
	vector<int> value(n);
	int x;
	int y;
	for(int i=0; i<n; i++) {
		cin >> x >> y;
		weight[i] = x;
		value[i] = y;
	}
	long long sum[n+1][w+1];
	for(int i=0; i<w+1; i++) { sum[0][i] = 0; }
	for(int i=0; i<n+1; i++) { sum[i][0] = 0; }
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=w; j++) {
			if(j >= weight[i-1]) {
			sum[i][j] = max(sum[i-1][j] ,(sum[i-1][j-weight[i-1]] + value[i-1]));
			}
			else {
			sum[i][j] = sum[i-1][j];
			}
		}
	}
	cout << sum[n][w]; 
	return 0;
}


Measured memory_bytes: 79104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int n;
const int ar[7] = { 9, 19, 29, 39, 49, 59, 1<<30 };

void solve() {
  int ans[7], temp;
  rep (i,7) ans[i] = 0;
  rep (i,n) {
    cin >> temp;
    int v = lower_bound(ar, ar + 7, temp) - ar;
    ans[v]++;
  }
  rep (i,7) cout << ans[i] << endl;
}

int main() {
  while (cin >> n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 868
using System;
using System.Linq;
using static System.Math;
using static System.Console;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Stdin io = new Stdin();
            Solve(io);
        }
        static void Solve(Stdin io)
        {
            long x, y, v;
            long[] l = io.Inputs();
            x = l[0]; y = l[1]; v = 0;
            while (x <= y){
                v++;
                x *= 2;
            }
            WriteLine(v);
        }
    }
    class Stdin
    {
        public long Input()
        {
            return long.Parse(ReadLine());
        }
        public long[] Inputs()
        {
            string[] buf = ReadLine().Split(' ');
            return buf.Select(x => long.Parse(x)).ToArray();
        }
        public string Raw_Input()
        {
            return ReadLine();
        }
    }
}


Measured memory_bytes: 11348
class Dice():
    def __init__(self, numbers):
        self.top = numbers[0]
        self.s = numbers[1]
        self.e = numbers[2]
        self.w = numbers[3]
        self.n = numbers[4]
        self.bot = numbers[5]
    def rot(self, dir):
        top, s, e, w, n, bot = (self.top, self.s, self.e, self.w, self.n, self.bot)
        if dir == 'N':
            self.top = s
            self.s = bot
            self.e = e
            self.w = w
            self.n = top
            self.bot = n
        elif dir == 'S':
            self.top = n
            self.s = top
            self.e = e
            self.w = w
            self.n = bot
            self.bot = s
        elif dir == 'E':
            self.top = w
            self.s = s
            self.e = top
            self.w = bot
            self.n = n
            self.bot = e
        elif dir == 'W':
            self.top = e
            self.s = s
            self.e = bot
            self.w = top
            self.n = n
            self.bot = w
    def getTop(self):
        return self.top
    def rotMany(self, command):
        for dir in command:
            self.rot(dir)



li = list(map(int, input().split()))
D1 = Dice(li)
li = list(map(int, input().split()))
D2 = Dice(li)

cmd_list = [
    "SEN", "SEN", "SEN", "SENN",
    "SEN", "SEN", "SEN", "SENN",
    "SEN", "SEN", "SEN", "SENN",
    "SEN", "SEN", "SEN", "SENE",
    "SEN", "SEN", "SEN", "SENEE",
    "SEN", "SEN", "SEN", ""
]

for cmd in cmd_list:
    if D1.top == D2.top and D1.s == D2.s and D1.w == D2.w and D1.e == D2.e and D1.n == D2.n and D1.bot == D2.bot:
        print("Yes")
        exit(0)
    else:
        D1.rotMany(cmd)
print("No")



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21) {
		put("bust");
	} else {
		put("win");
	}
	return 0;
}


Measured memory_bytes: 256
ans=[]

while True:
    H,W=map(int,input().split())
    if W==H==0:
        break
    b=''
    for i in range(H):
        for j in range(W):
            if (i%2==0 and j%2==0) or (i%2==1 and j%2==1):
                b+='#'
            else:
                b+='.'
        b+='\n'
    ans.append(b)


print('\n'.join(ans))


Measured memory_bytes: 5740
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        pw.println((h-a) * (w-b));
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25368
#include <iostream>

using namespace std;

int main () {
  int N;
  cin >> N;
  int t, x, y;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    cin >> t >> x >> y;
    if (t % 2 == (x + y) % 2 && t >= (x + y)) continue;
    else flag = false;
  }
  
  if (flag) cout << "Yes" << endl;
  else if (!flag) cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
string T;
cin >> T;
for(int i = 0; i < T.size(); i++){
if(T.at(i) == '?')T.at(i) = 'D';
cout << T.at(i);}
}

Measured memory_bytes: 3724
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        double res = (double)a * b / 2;
        BigDecimal bd = new BigDecimal(res);
        System.out.print(bd.setScale(6, RoundingMode.HALF_UP) + " ");


        if(2*x == a && 2*y == b) {
            System.out.print("1");
        } else {
            System.out.print("0");
        }
    }
}


Measured memory_bytes: 39020
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int T;
	cin >> T;
	while(T--){
		int w, h, n;
		cin >> w >> h >> n;
		vector< vector<int> > dp(h + 1, vector<int>(w + 1));
		vector< vector<int> > mask(h + 1, vector<int>(w + 1));
		dp[0][0] = 1;
		for(int i = 0; i <= w; ++i){ mask[0][i] |= 1; }
		for(int i = 0; i <= h; ++i){ mask[i][0] |= 2; }
		while(n--){
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if(x1 == x2){
				mask[max(y1, y2)][x1] |= 1;
			}else{
				mask[y1][max(x1, x2)] |= 2;
			}
		}
		for(int i = 0; i <= h; ++i){
			for(int j = 0; j <= w; ++j){
				if(!(mask[i][j] & 1)){ dp[i][j] += dp[i - 1][j]; }
				if(!(mask[i][j] & 2)){ dp[i][j] += dp[i][j - 1]; }
			}
		}
		if(dp[h][w] == 0){
			cout << "Miserable Hokusai!" << endl;
		}else{
			cout << dp[h][w] << endl;
		}
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

ll n, m;

bool check(ll x) {
    return x * 2 <= m - 2 * max(0ll, x - n);
}

void solve() {
    scanf("%lld %lld", &n, &m);

    ll l = 0, r = 1e15, ans = -1;

    while (l <= r) {
        ll mid = (l + r) >> 1;

        if (check(mid)) {
            l = mid + 1;
            ans = mid;
        }
        else {
            r = mid - 1;
        }
    }

    printf("%lld\n", ans);
}

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

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256