akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0228();
	}
	
	class AOJ0228{
		boolean[] number;
		ArrayList<boolean[]> list;
		
		void doIt(){
			int input = in.nextInt();
			String result = "";
			for(int i=0;i<7;i++){
				if(list.get(input)[i]&&!number[i])result+="1";
				else if(!list.get(input)[i]&&number[i])result+="1";
				else result+="0";
			}
			number = list.get(input);
			System.out.println(result);
		}
		
		public AOJ0228() {
			list = new ArrayList<boolean[]>();
			boolean[] a_0 = {false,true,true,true,true,true,true};list.add(a_0);
			boolean[] a_1 = {false,false,false,false,true,true,false};list.add(a_1);
			boolean[] a_2 = {true,false,true,true,false,true,true};list.add(a_2);
			boolean[] a_3 = {true,false,false,true,true,true,true};list.add(a_3);
			boolean[] a_4 = {true,true,false,false,true,true,false};list.add(a_4);
			boolean[] a_5 = {true,true,false,true,true,false,true};list.add(a_5);
			boolean[] a_6 = {true,true,true,true,true,false,true};list.add(a_6);
			boolean[] a_7 = {false,true,false,false,true,true,true};list.add(a_7);
			boolean[] a_8 = {true,true,true,true,true,true,true};list.add(a_8);
			boolean[] a_9 = {true,true,false,true,true,true,true};list.add(a_9);
			while(true){
				int n = in.nextInt();
				if(n==-1)break;
				number = new boolean[7];//gfedcba
				for(int i=0;i<n;i++)doIt();
			}
		}
	}
	
}

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> V(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        V[a]++; V[b]++;
    }
    for(auto &v:V){
        if(v%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>string join(const v(T)&v){stringstream s;rep(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<class T>inline ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N;
  cin >> N;
  vi A(N);
  int sum = 0;
  rep(i, 0, N) {
    cin >> A[i];
    sum += A[i];
  }

  vi ans(N, 0);
  for (int i=1; i<N; i+=2) ans[0] += A[i];
  ans[0] = sum - 2*ans[0];

  rep(i, 0, N-1) {
    ans[i+1] = 2*A[i] - ans[i];
  }

  cout << ans[0];
  rep(i, 1, N) cout << " " << ans[i];
  cout << endl;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){

		int N = scan.nextInt();
		int[] arr = new int[N];
		for(int i = 0; i < N; i++){
			int num = scan.nextInt();
			arr[i] = num;
		}
		
		for(int i = 0; i < N; i++){
			if(i != N - 1){
				System.out.printf("%d ", arr[i]);
			} else{
				System.out.printf("%d\n", arr[i]);
			}
		}

		for(int i = 1; i < N; i++){
			int v = arr[i];
			int j = i - 1;
			while(j >= 0 && arr[j] > v){
				arr[j + 1] = arr[j];
				j--;
				arr[j + 1] = v;
			}
			for(int k = 0; k < N; k++){
				if(k != N - 1){
					System.out.printf("%d ", arr[k]);
				} else{
					System.out.printf("%d\n", arr[k]);
				}
			}
		}
	}
}

Measured memory_bytes: 44332
// 🐋💭  Buy an Integer
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}
// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

/*
 blue > green > red
 
 
 */
func main() {
    let abc = readInts()
    var (red, green, blue) = (abc[0], abc[1], abc[2])
    let k = readInt()
    var counter = k
    //__________________________________________ここまで入力
    while blue <= green || green <= red {
        while blue <= green {
            blue *= 2
            counter -= 1
        }
        while green <= red {
            green *= 2
            counter -= 1
        }
    }
    print(counter >= 0 ? "Yes": "No")
    
}
main()


Measured memory_bytes: 13592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;


int main()
{
	int N, M;
	vector<long long> Xs, Ys, Zs, Sums,Indexs;

	cin >> N >> M;

	long long x, y, z;
	for (int ni = 0; ni < N; ni++) {
		cin >> x >> y >> z;
		Xs.push_back(x);
		Ys.push_back(y);
		Zs.push_back(z);
		Indexs.push_back(ni);
	}

	int pn[][3] = { {1,1,1},
					{1,1,-1},
					{ 1,-1,1 },
					{ 1,-1,-1 },
					{ -1,1,1 },
					{ -1,1,-1 },
					{ -1,-1,1 },
					{ -1,-1,-1 },
	};


	long long max_ans = 0;
	for (int pi = 0; pi < 8; pi++) {
		Sums.clear();
		long long sum;
		for (int ni = 0; ni < N; ni++) {
			sum =pn[pi][0] *  Xs[ni] + pn[pi][1] * Ys[ni] + pn[pi][2]*Zs[ni];
			Sums.push_back(sum);
		}

		sort(Indexs.begin(), Indexs.end(), [&](int x, int y) { return(Sums[x] > Sums[y]); });

		long long ans = 0;
		long long sumx = 0;
		long long sumy = 0;
		long long sumz = 0;
		for (int mi = 0; mi < M; mi++) {
			int ni = Indexs[mi];
			sumx += Xs[ni];
			sumy += Ys[ni];
			sumz += Zs[ni];
		}
		ans = abs(sumx) + abs(sumy) + abs(sumz);

		if (ans > max_ans) max_ans = ans;
	}

	printf("%lld", max_ans);

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int h, n;
  scanf("%d%d", &h, &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    h -= x;
  }
  puts(h <= 0 ? "Yes" : "No");
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>

using namespace std;

void Solution()
{
    int n;
    
    cin>>n;
    
    for(int i = 0; i < n; i++)
    {
        string s, str;
        
        cin>>s;
        
        int p=0;
        
        for(int j = 0; j < (int)s.size(); j++)
        {
            if(s[j] == '>')
            {
                p++;
            }
            else if(s[j] == '<')
            {
                p--;
            }
            else if('a' <= s[j] && s[j] <= 'z')
            {
                if(p == -1)
                {
                    str = s[j] + str;
                    
                    p = 0;
                }
                else if(p == (int)str.size())
                {
                    str = str + s[j];
                }
            }
        }
        
        cout<<str<<"\n";
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong a[2][105];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[0][i];
    for (int i = 0; i < n; i++) cin >> a[1][i];

    for (int i = n; i > 0; i--) a[0][i - 1] += a[0][i];
    for (int i = n; i > 0; i--) a[1][i - 1] += a[1][i];

    llong ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans,
                  a[0][0] - a[0][i + 1] + a[1][i] - a[0][n]);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

long long a[1000000];
long long seg[4000000];
long long res[10000000];
long long brr=0;

long long stepen2(long long x)
{
    if(x%2==1)
    {
        x++;
        return stepen2(x);
    }
    return x;
}

long long query (long long idx, long long left, long long right, long long l, long long r)
{
    if(l<=left && r >= right)
    {
        return seg[idx];


    }
    if(r < left || l > right)
        return 2147483647;

    long long mid = (left+right)/2;
    long long k = query(2*idx,left,mid, l, r);
    long long nj = query(2*idx+1,mid+1,right, l, r);
    //if(idx == 7)
       // cout << k << " " << nj << endl;
    return min(k,nj);

}

void nmp (long long idx,long long left,long long right)
{
    if(left == right)
    {
        seg[idx] = a[left];
        return;
    }
    long long mid = (left + right)/2;
    nmp(2*idx, left, mid);
    nmp(2*idx+1, mid+1, right);
    seg[idx] = min(seg[2*idx], seg[2*idx+1]);
    //cout <<"idx " <<  idx << endl;
}

long long update (long long idx, long long left, long long right, long long pos, long long val)
{
    if (left == right)
    {
        seg[idx] = val;
        return 1;
    }
    long long mid = (left+right)/2;
    if(pos > mid)
        update(2*idx+1, mid+1, right, pos, val);
    else
        update(2*idx, left, mid, pos, val);
    seg[idx] = min(seg[2*idx], seg[2*idx+1]);
}


int main ()
{
    long long n,q;
    cin >> n >> q;
    n = stepen2(n);
    for (long long i=0;i<n;i++)
    {
        a[i] = pow(2,31)-1;
    }
    nmp(1, 0, n-1);
    for(long long i=0;i<q;i++)
    {
        long long qry;
        cin >> qry;
        if(qry == 0)
        {
            long long x, y;
            cin >> x >> y;
            update(1, 0, n-1, x, y);
            /*for(long long i = 1;i <=8; i++)
            {
                cout << seg[i] << " ";
            }
            cout << endl;*/
        }
        else
        {
            long long x,y;
            cin >> x >> y;
            res[brr] = query(1, 0 ,n-1, x, y);
            brr++;
        }
    }

    for(long long i=0;i<brr;i++)
        cout << res[i] <<endl;
}

Measured memory_bytes: 6324
n = int(input())
p = list(map(int,input().split()))
s = sorted(p)
cnt = 0
for i in range(n):
    if p[i] != i+1:
        cnt += 1

    
#print(p)
#print(s)
if cnt > 2:
        print("NO")
else:
    print("YES")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

//const ll dx[] = {1,0,0,-1};const ll dy[] = {0,1,-1,0};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    rep(i,N)cin >> A[i];
    rep(i,N)cin >> B[i];
    rep(i,N)cin >> C[i];
    sort(all(A));sort(all(B));sort(all(C));
    ll ans = 0;
    rep(i,N){
        auto itr1 = lower_bound(all(A),B[i]);
        auto itr2 = upper_bound(all(C),B[i]);
        ll n = itr1 - A.begin();
        ll m = N - (itr2 - C.begin());
        ans += n * m;
        //cout << n << "," << m << "\n";
    }
    cout << ans << endl;
}

Measured memory_bytes: 5548
from collections import Counter
N=int(input())
p=[]
dp=[[0]*100 for _ in range(100)]
dp[0][1]=1

for i in range(2,N+1):
    ti=i
    for j in range(2,i+1):
        while ti%j==0:
            p.append(j)
            ti//=j

cnt=Counter(p)
ans=0
for i,v in enumerate(cnt.values()):
    for j in range(100):
        for k in range(1,v+2):
            dp[i+1][min(76,j*k)]+=dp[i][j]
    ans=dp[i+1][75]

print(ans)

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	double R;
	cin >> R;
	cout << fixed<<setprecision(12)<<2 * M_PI*R << endl;

	return 0;
}

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

int main(){
	/* 一番上の数をtop
	 * 一番手前の数をfront
	 * 右側の数をright
	 */
	int n;//何回操作するか
	int ans[200];//答えの格納
	int anscount=0;//答えの数
	while(true){
		int top=1;
		int front=2;
		int right=3;
		int temp;//一時記憶
		cin>>n;
		if(n==0)break;
		string s;//文字列
		int sum=1;//合計
		for(int i=0; i<n; i++){
			cin>>s;
			if(s=="North"){
				temp=top;
				top=front;
				front=7-temp;
			}else if(s=="East"){
				temp=right;
				right=top;
				top=7-temp;
			}else if(s=="South"){
				temp=front;
				front=top;
				top=7-temp;
			}else if(s=="West"){
				temp=top;
				top=right;
				right=7-temp;
			}else if(s=="Right"){
				temp=front;
				front=right;
				right=7-temp;
			}else if(s=="Left"){
				temp=right;
				right=front;
				front=7-temp;
			}
			sum+=top;
		}
		ans[anscount]=sum;
		anscount++;
	}

	for(int i=0; i<anscount; i++){
		cout<<ans[i]<<"\n";
	}
	return 0;
}

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

int main()
{
    string s;
    cin>>s;
    if(s=="MON") cout<<6<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="FRI") cout<<2<<endl;
    else if(s=="SAT") cout<<1<<endl;
    else if(s=="SUN") cout<<7<<endl;
    return 0;
}


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

using namespace std;

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

    int cnt = 0;
    for(int i=0; i<n; i++)
    {
        int tmp;
        cin >> tmp;
        if(tmp >= k) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

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

int main(){
  int n;
  int c1,c2,c3;
  int counter=0;
  c1=0;c2=0;c3=0;
  string s;
  cin>>n;
  rep(i,n){
    cin>>s;

    rep(j,s.length()-1){
      if(s.at(j)=='A'&&s.at(j+1)=='B') counter++;
    }
    
    if(s.at(0)=='B'&&s.at(s.length()-1)=='A') c1++;
    else if(s.at(0)=='B') c2++;
    else if(s.at(s.length()-1)=='A') c3++;
  }

  if(c2==0&&c3==0){
    if(c1==0)cout<<counter<<endl;
    else{
      cout<<counter+c1-1<<endl;
    }
    return 0;
  }

  int x;
  x=min(min(c1,c2),c3);
  c1-=x;c2-=x;c3-=x;
  x*=2;
  int y;
  if(c1==0){
    y=min(c2,c3);
    
  }
  else if(c2==0){
    y=min(c3,c1);
    if(c1-y>0){
      y+=(c1-y);
    }
  }
  else if(c3==0){
    y=min(c2,c1);
    if(c1-y>0){
      y+=(c1-y);
    }
  }
  cout<<counter+x+y<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    int64_t hen_1 = 0;
    int64_t hen_2 = 0;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<int64_t>());
    int64_t tmp_num = 0;
    for (int64_t i=0; i<N; i++) {
        if (tmp_num == vec[i]) {
            if (hen_1 > 0) {
                hen_2 = tmp_num;
                break;
            } else {
                hen_1 = tmp_num;
                tmp_num = 0;
            }
        } else {
            tmp_num = vec[i];
        }
    }

    if (hen_1 > 0 && hen_2 > 0) {
        cout << hen_1 * hen_2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}


int main()
{
    cout.precision(15);
    double a, b, x;
    cin >> a >> b >> x;
    if (x/a <= a*b/2 ){
        cout << 180 * atan(a*b*b/(2*x)) / M_PI << endl;
    }else
    {
        cout << 180 * atan((2 * b / a) - (2 * x / (a * a * a))) / M_PI << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
  ll n,k;
  ll ans;
  cin >> n >> k;
  ans = k;
  for (int i = 1; i < n; i++) {
    ans *= k-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    char ch; cin>>ch;
    if (ch < 97)
    {
        cout<<'A';
    }
    else
        cout<<'a';
    
    return 0;
}

Measured memory_bytes: 3564
#include <memory.h>

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

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n;
	cin >> n;
	int a[100010];
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	if (a[0] != 0) {
		if (n == 0 && a[0] == 1)
			cout << 1 << endl;
		else
			cout << -1 << endl;
		return 0;
	}
	long long int minNodeNum[100010];
	long long int maxNodeNum[100010];
	minNodeNum[n] = a[n];
	maxNodeNum[n] = a[n];
	for (int i = n - 1; i >= 0; i--) {
		minNodeNum[i] = minNodeNum[i + 1] / 2 + a[i];
		maxNodeNum[i] = maxNodeNum[i + 1] + a[i];
		// cout << i << " " << minNodeNum[i] << " " << maxNodeNum[i] << endl;
	}
	if (maxNodeNum[0] >= 1) {
		long long int ans = 1;
		long long int now = 1;
		for (int i = 1; i < n + 1; i++) {
			if (now * 2 < minNodeNum[i]) {
				cout << -1 << endl;
				return 0;
			}
			long long int tmp = min(now * 2, maxNodeNum[i]);
			ans += tmp;
			now = tmp - a[i];
			// cout << i << " " << ans << " " << now << endl;
		}
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 5564
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <numeric>

using namespace std;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 
    
int main() {
    fast
    lo n,k,a[N];
    cin >> n >> k;
    lo sum = 0;
    for(lo i = 0 ; i < k ; i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n){
        cout << -1 << endl;
    }
    else{
        cout << n - sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3696
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = int.Parse(Console.ReadLine());
            var H = RL<int>();
            var dp = new int[N];
            dp[0] = 0;
            for(var i = 1;i < N; i++) {
                dp[i] = Math.Abs(H[i] - H[i - 1]) + dp[i - 1];
                if(i > 1) {
                    dp[i] = Math.Min(dp[i],Math.Abs(H[i] - H[i - 2]) + dp[i - 2]);
                }
            }
            Console.Write(dp[N - 1]);
        }

        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}

Measured memory_bytes: 18144
#include <cstdio>

const int N=4e3+5,mod=1e9+7;
int A,B,n,c[N][N],f[N][N],ans;

int main(){
	scanf("%d%d",&A,&B); n=4000;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i;++j){
			if(j==0) c[i][j]=1;
			else c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
			f[i][j]=c[i][j];
		}
	}
	for(int i=0;i<=n;++i){
		for(int j=1;j<=n;++j){
			f[i][j]=(f[i][j]+f[i][j-1])%mod;
		}
	}
	for(int i=0;i<=n;++i){
		for(int j=1;j<=n;++j){
			f[i][j]=(f[i][j]+f[i][j-1])%mod;
		}
	}
	for(int i=1;i<=A+1;++i){
		for(int j=0;j<=i-1;++j){
			int tmp=(j==0?1:f[j-1][i-j-1]);
			ans=(ans+1ll*c[B-1][j]*tmp%mod)%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 125568
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import pi
def main():
    n, *a = map(int, read().split())
    cnt = [0] * n
    for ae in a:
        cnt[ae-1] += 1
    print(*cnt, sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 31612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	if(a>=k)cout<<k;
	else if(a+b>=k)cout<<a;
	else cout<<a-(k-a-b);
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
	int res=0;int n;scanf("%d",&n);
	for(int i=1,x,y;i<=n;++i){
		scanf("%d%d",&x,&y);
		while(x%y)x=x-(x/y+1)*((x-x/y*y-1)/(x/y+1)+1);res^=x/y;
		// cout<<res<<
	}cout<<(res?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 256
N,X = map(int, input().split())
l = sorted(map(int, input().split()+[X]))
r = [l[n+1] - l[n] for n in range(N)]
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)


Measured memory_bytes: 14864
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  string s,p;
  cin >> s >> p;
  string ss = s + s;
  string ans = "No";
  for(int i = 0; i < s.size(); i++){
    if(ss.substr(i,p.size()) == p) ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3172
import java.math.BigInteger
import java.util.*

/**
 * Created by zzt on 17-7-11.
 */

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val p = scanner.nextInt()
    var hasOdd = false

    for (i in 1..n) {
        if (scanner.nextInt() % 2 != 0) {
            hasOdd = true
            break
        }
    }


    println(if (hasOdd) BigInteger("2").pow(n-1).toString() else if (p==0) BigInteger("2").pow(n).toString() else 0)
}

Measured memory_bytes: 31384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    FOR(i, 0, n + 1)cin >> a[i];
    FOR(i, 0, n)cin >> b[i];

    ll ans = 0;
    FOR(i, 0, n) {
        ans += min(a[i], b[i]);
        if (a[i] <= b[i]) {
            b[i] -= a[i];
            a[i] = 0;
        }
        else {
            a[i] -= b[i];
            b[i] = 0;
        }

        ans += min(a[i +1], b[i]);
        if (a[i + 1] <= b[i]) {
            b[i] -= a[i];
            a[i + 1] = 0;
        }
        else {
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    string left = "";
    string right = "";
    int cur = 0;
    int q;
    cin >> q;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){
            cur = 1 - cur;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if((cur+f)%2==1){
                left = c + left;
            }
            else
            {
                right = right + c;
            }
        }
    }
    if(cur == 1){
        reverse(left.begin(), left.end());
        reverse(right.begin(), right.end());
        reverse(s.begin(), s.end());
        s = right + s + left;
    }else{
        s = left + s + right;
    }
    cout << s << endl;
}

Measured memory_bytes: 1512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head
int m,mi,a[23333];

int main(){
    int n;scanf("%d",&n);m=0;mi=999;memset(a,0,sizeof(a));rep(i,0,n){int x;scanf("%d",&x);a[x]++;if(x>m)m=x;if(x<mi)mi=x;}
    if(a[m]==1)cout<<"Impossible"<<endl;
    else{
        int now=m/2;if(m%2){
            now++;
            if(mi!=now)cout<<"Impossible"<<endl;
            else{
                if(a[now]!=2)cout<<"Impossible"<<endl;
                else {
                        bool flag=false;
                        rep(i,now+1,m)if(a[i]<1)flag=true;
                        if(flag)cout<<"Impossible"<<endl;else cout<<"Possible"<<endl;
                }
            }
        }else{
            if(mi!=now)cout<<"Impossible"<<endl;
            else{
                if(a[now]!=1)cout<<"Impossible"<<endl;
                else {
                        bool flag=false;
                        rep(i,now+1,m)if(a[i]<2)flag=true;
                        if(flag)cout<<"Impossible"<<endl;else cout<<"Possible"<<endl;
                }
            }
        }
    }
	return 0;
}


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




int main(void){
int a,b,c;
int ues=0;
scanf("%d %d %d",&a,&b,&c);

for(int i=a;i<=b;i++){
    if(c%i==0){ues++;}
}

printf("%d\n",ues);
return 0;
}



Measured memory_bytes: 2120
N, T = map(int, input().split())
c = [0] * N
t = [0] * N
c_min = 10000
for i in range(N):
    c[i], t[i] = map(int, input().split())
    if c[i] <= c_min and t[i] <= T:
        c_min = c[i]
print(c_min) if c_min != 10000 else print('TLE')


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  int N;
  cin >> N;
  long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  long X[N];

  X[0] = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      X[0] += A[i];
    } else {
      X[0] -= A[i];
    }
  }

  for (int i = 1; i < N; i++) {
    X[i] = 2 * A[i - 1] - X[i - 1];
  }

  for (int i = 0; i < N; i++) {
    cout << X[i] << " ";
  }
  cout << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int j;
	int ans = 0;
	string flag = "true";
	while (true) {
		for (j = 0; j < n; j++) {
			if (a[j] % 2 == 0) {
				a[j] = a[j] / 2;
			}
			else {
				flag = "false";
				break;
			}
		}
		if (flag == "false")break;
		else ans++;
	}
	cout << ans << endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3096
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll H[N];
	for (ll i = 0; i < N; ++i) cin >> H[i];
 
	// 解法
	ll val_max = H[0];
	ll ans = 0;
	REP(i,N){
		if (val_max<=H[i]){
			ans++;
			val_max = H[i];
		}
	}
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

constexpr ll MOD = 1e9 + 7;

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

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

    static ll dp[101][100010];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;

    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = 1;
        for (int j = 1; j <= k; j++)
        {
            if (j - a[i] - 1 >= 0)
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i] - 1];
            else
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] = (dp[i][j] + MOD) % MOD;
        }
    }

    cout << dp[n][k] << endl;

    return 0;
}

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

int main () {
  int N;
  int c = 0;
  cin >> N;
  int a[N];
  for (int i=0; i<N; i++) {
    cin >> a[i];
    if ((i%2==0)&&(a[i]%2==1)) {
      c++;
    }
  }
  cout << c <<endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define pll pair<long,long>
#define INF 10000000000000000
typedef long long ll;
#define PI 3.14159265

vector<ll> v;
ll n,k;

bool chk(ll s)
{
	vector<ll> v1;
	ll s1=0;
	for(ll i=0;i<n;i++)
	{
		v1.pb(v[i]%s);
		s1+=s-(v1[i]);
	}
	sort(v1.begin(),v1.end());
	ll s2=0;
	for(ll i=0;i<n;i++)
	{
		s1-=(s-v1[i]);
		s2+=v1[i];
		if(s2==s1 && s2<=k)
		{
			return true;
		}
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	//ll n;
	cin>>n;
	cin>>k;
	ll s=0;
	v.resize(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
		s+=v[i];
	}
	
	ll ans=0;
	for(ll i=1;i*i<=s;i++)
	{
		if(s%i==0)
		{
			if(chk(i))
				ans=max(ans,i);
			if(chk(s/i))
				ans=max(ans,s/i);
		}
	}
	cout<<ans;
	
}				
					
					


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  ll n, k;
  cin >> k >> n;
  int cnt = 0;
  for (int i = 0; i < n + 1; i++) {
    for (int m = i; m < n + 1; m++) {
      if (i <= k && m - i <= k && n - m <= k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    heights = list(map(int, input().split()))

    n_max = 0
    temp_max = 0
    prev_h = 0

    for h in heights:
        if h <= prev_h:
            temp_max += 1
        else:
            temp_max = 0
        n_max = max(n_max, temp_max)
        prev_h = h
    print(n_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
//46
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int s[5]={};
    int o[5]={};
    while(n--){
      int h,m,mm;
      (cin>>h).ignore()>>m>>mm;
      int t=(11<=h)+(18<=h)+(21<=h)+4*(h<2)+(15<=h);
      s[t]++;
      o[t]+=((mm-m<0)?mm+60-m:mm-m)<=8;
    }
    for(int i=0;i<5;i++){
      const char *ts[]={"","lunch","","dinner","midnight"};
      if(i==0||i==2)continue;
      cout<<ts[i]<<' ';
      if(s[i]){
	cout<<o[i]*100/s[i]<<endl;
      }else{
	cout<<"no guest"<<endl;
      }
    }
  }
  return 0;
}
      

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

int main(){
    int n;
    cin>>n;
    vector<int> vec(n+1,0);
    REP(i,n-1){
        int tmp;
        cin>>tmp;
        vec[tmp]++;
    }
    REP(i,n){
        cout<<vec[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 4056
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;

pair<int,int> ratioo(int a,int b){
	if(__gcd(a,b)==1){
		return mp(a,b);
	}
	int temp=__gcd(a,b);
	a=a/temp;
	b=b/temp;
	return mp(a,b);
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

    int t;cin>>t;
    int a,b;cin>>a>>b;
    t--;
    while(t--){
    	int x,y;cin>>x>>y;
    	int s=1;
    	s=max(a/x,b/y);
    	for(int i=s;;i++){
    		if(x*i>=a && y*i>=b){
    			a=x*i;
    			b=y*i;
    			break;
    		}
    	}
    }
    cout<<a+b<<endl;
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,K;
    Scd2(N,K);

    vi a(N);
    vl s(N+1);
    Rep(i,N) Scd(a[i]);
    Rep(i,N){
        s[i+1] = s[i] + a[i];
    }
    vl b;
    Rep(i,N+1) Repe(j,N+1,i+1){
        b.push_back(s[j]-s[i]);
    }

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

    int M = b.size();

    ll ans = 0;
    vl c;
    RRep(si,63){
        ll B = 1LL << si;
        c.clear();
        Rep(i,M){
            if( b[i] & B ) c.push_back(b[i]);
        }
        if( c.size() >= K ) {
            M = c.size();
            ans |= B;
            b.clear();
            Rep(i,M) b.push_back(c[i]);
        }
    }

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

    return 0;
}



Measured memory_bytes: 6388
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class Node{
	int id;
	long value;
	this(int id, long v){
		this.id = id;
		this.value = v;
		}
	}

void main(){
	int n = readln.chomp.to!int;
	Node[] as;
	foreach(i; 0 .. n){
		as ~= new Node(i, readln.chomp.to!long);
		}
	
	as.sort!("a.value < b.value")();
	
	int ans = 0;
	for(int i = 0; i < as.length; i += 2){
		if(i % 2 != as[i].id % 2) ans += 1;
		}
	
	ans.writeln;
	
	}

Measured memory_bytes: 5628
#include<iostream>
using namespace std;
int main() {
    int a;
    cin >> a;
    if (a % 10 == (a / 10) % 10 && (a / 10) % 10 == ((a / 10) / 10) % 10) {
        cout << a << endl;
        return 0;
    }
    while (1) {
        if (a % 10 == (a / 10) % 10 && (a / 10) % 10 == ((a / 10) / 10) % 10) {
            cout << a << endl;
            return 0;
        }
        a++;
        if (a >= 1000) {
            return 0;
        }
    }
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
q = int(input())

total = sum(A) # これを基に各queryに対応(加算、減算)する

l = [0 for i in range(10**5+1)] # 配列のインデックスを各valueとみなす
for _ in A: # 各インデックスに各keyを加算
    l[_] += 1

for i in range(q):
    b, c = map(int,input().split())
    total += c * l[b] # totalの調整のみ
    total -= b * l[b] # 同上
    print(total)
    l[c] += l[b] # ここでリストの更新
    l[b] = 0 # 同上


Measured memory_bytes: 21088
N,M=map(int,input().split())
s=[list(map(int,input().split()))for _ in[0]*N]
c=[list(map(int,input().split()))for _ in[0]*M]
for x,y in s:
    d={k+1:abs(x-t[0])+abs(y-t[1])for k,t in enumerate(c)}
    print(min(d,key=d.get))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"bufio"
	"os"
	"reflect"
	"strconv"
	"strings"
)

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func sum(n []int) (c int) {
	c = 0
	for _, x := range n {
		c += x
	}
	return
}

func main() {
	var r, c int

	scanner := bufio.NewScanner(os.Stdin)

	fmt.Scan(&r, &c)

	bottom := make([]int, c)
	for i := 0; i < r; i++ {
		scanner.Scan()
		s := scanner.Text()
		n := mapf(strconv.Atoi, strings.Split(s, " ")).([]int)
		fmt.Println(s, sum(n))
		for j, x := range n {
			bottom[j] += x
		}
	}

	fmt.Println(strings.Join(mapf(strconv.Itoa, bottom).([]string), " "), sum(bottom))
}



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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

using namespace std;

typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }



int n, m;

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }



    cin >>n;

    cout<<(800*n - 200*(n/15)) <<endl;

    return 0;
}


Measured memory_bytes: 256