akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

bool check(ll index, string s, string t){
	rep(i, t.size()){
		if (!(s[i+index] == t[i] || s[i+index] == '?')) return false;
	}return true;
}

int main(){
	string s, t; cin >> s >> t;
	if (s.size() < t.size()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	ll start = -1;
	rep(i, s.size() - t.size() + 1){
		if (check(s.size() - t.size() - i, s, t)){
			start = s.size() - t.size() - i;
			break;
		}
	}
	if (start == -1){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}rep(i, s.size()){
		if (i == start){
			i += t.size() - 1;
			cout << t;
		}
		else{
			if (s[i] == '?') cout << "a";
			else cout << s[i];
		}
	}cout << endl;

	return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}



void solve(std::istream &in, std::ostream &out) {
  int k, a, b;
  in >> k >> a >> b;
  int rem = b / k - (a - 1) / k;
  if (rem > 0) {
    cout << "OK\n";
  } else {
    cout << "NG";
  }
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	string s;cin>>s;
	if(n%2){
		cout<<"No"<<endl;
		return 0;
	}
	bool ok = true;
	rep(i,n/2){
		if(s.at(i)!=s.at(i+n/2))
			ok=false;
	}
	if(ok)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
      cin>>a[i];
      sum+=a[i];
    }
    sort(begin(a),end(a),greater<ll>());
    vector<ll> cnt(n);
    cnt[0]=sum;
    FOR(i,1,n){
      cnt[i]=cnt[i-1]-a[i-1];
    }
    //cout_vec(cnt);
    ll ans=1;
    FOR(i,1,n){
      if(a[i-1]<=2*cnt[i]) ans++;
      else break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5 + 5)];
map <int, ll> MAP;

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%d", A + i);
    MAP[i - A[i]]++;
  }

  ll ans = 0;
  for (int i = 0; i < N; i++){
    ans += MAP[A[i] + i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 27168
#include <bits/stdc++.h>
using namespace std;
int Log(int a){
	int cnt=0;
	while(a%2==0){
		a/=2;cnt++;
	}
	return cnt;
}
int main(){
    int n,a[200];
    cin>>n;
    for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]=Log(a[i]);
	}
	sort(a,a+n);
	cout<<a[0]<<endl;
	return 0;
}


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

typedef long long ll;

 
int main(){
  int mi=2000, ma=-1;
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    if(mi>a) mi = a;
    if(ma<a) ma = a;
  }
  cout << ma-mi << endl;
  return 0;
}


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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;

namespace shniter {
	using Value=int;
	using Edge=pair<int,Value>;
	using Graph=vector<vector<Edge>>;
	const Value inf = 1<<20;

	vector<vector<Value>>w_h(const Graph&g) {
		vector<vector<Value>>asps(g.size(),vector<Value>(g.size(),1e9));
		for (int i = 0; i < g.size(); ++i) {
			for (auto e : g[i]) {
				asps[i][e.first]=e.second;
			}
			asps[i][i]=0;
		}

		for (int k = 0; k < g.size(); ++k) {
			for (int i = 0; i < g.size(); ++i) {
				for (int j = 0; j < g.size(); ++j) {
					asps[i][j]=min(asps[i][k]+asps[k][j],asps[i][j]);
				}
			}
		}
		return asps;
	}

	//最小シュナイター木
	Value solve(const Graph&g, const vector<int>shs) {
		//全点対最短経路(APSP : all pair shortest paths)
		auto asps = w_h(g);
		vector<vector<Value>>OPT(1 << shs.size(), vector<Value>(g.size(), inf));


		for (int p = 0; p < shs.size(); ++p) // trivial case
			for (int q = 0; q < g.size(); ++q){
				OPT[1 << p][q] = asps[shs[p]][q];
				OPT[0][q] = 0;
			}


		for (int k = 1; k < (1 << shs.size()); ++k) {
			for (int root = 0; root < g.size(); ++root) {
				if(!(k&(k-1)))continue;

				for (int e = 0; e < k; ++e) {
					if ((e | k) == k) {
						OPT[k][root] = min(OPT[k][root], OPT[e][root] + OPT[e^k][root]);
					}
				}
				
			}

			for (int p = 0; p < g.size(); ++p) {
				for (int q = 0; q < g.size(); ++q) {
					OPT[k][p] = min(OPT[k][p],
						OPT[k][q] + asps[p][q]);
				}
			}
		}
		Value ans = inf;
		for (int S = 0; S < (1 << shs.size()); ++S)
			for (int q = 0; q < g.size(); ++q)
				ans = min(ans, OPT[S][q] + OPT[((1 <<shs.size())-1 - S)][q]);

		return ans;
	}
}
int H,W;
int get_id(int x, int y) {
	if(x<0||W<=x||y<0||y>=H)return -1;
	else return y*W+x;
}

int main() {
	while (true) {
		cin>>H>>W;
		if(!H)break;
		vector<vector<int>>field(H,vector<int>(W));
		vector<int>storoberry_ids;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin>>field[i][j];
				if (field[i][j]) {
					storoberry_ids.push_back(get_id(j,i));
				}
			}
		}
		using namespace shniter;
		Graph g(H*W);
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				for (int way = 0; way < 4; ++way) {
					int dx[] = { -1,0,1,0 };
					int dy[] = { 0,1,0,-1 };
					int nx=x+dx[way];
					int ny=y+dy[way];
					int nid=get_id(nx,ny);
					int id=get_id(x,y);
					if (nid != -1) {
						g[id].push_back(Edge(nid,1));
					}
				}
			}
		}
		Value answer=solve(g,storoberry_ids);
		cout<<H*W-(answer+1)<<endl;
	}
	return 0;
}




Measured memory_bytes: 3212
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define s 3003
using namespace std;

ll dp[s][s];

ll solve(vector<ll>& a, ll i, ll j)
{
    //Base case
    if(i > j)
    return 0;
    
    //Lookup
    if(dp[i][j] != -1)
    return dp[i][j];
    
    //Rec Case
    ll op1 = a[i] + min( solve(a,i+1,j-1), solve(a,i+2,j));
    ll op2 = a[j] + min( solve(a,i+1,j-1), solve(a,i,j-2));
    
    return dp[i][j] = max(op1,op2);
}

int main()
{
    fast_io;
    
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    
    for(int i=0;i<n;i++)
    cin>>a[i];
    
    memset(dp,-1,sizeof(dp));
    ll X = solve(a,0,n-1);
    
    ll sum = 0;
    for(ll j=0;j<a.size();j++)
    sum += a[j];
    
    ll Y = sum - X;
    cout<<X-Y<<endl;
    
    return 0;
}


Measured memory_bytes: 70912
// InsertionSort.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <sstream>
#include <vector>

bool insertionSort(std::vector<int> &array, int n);

int main()
{
    int n = 0;
    std::string input;
    std::getline(std::cin, input);
    n = std::stoi(input);

    std::vector<int> array;
    std::getline(std::cin, input);
    std::stringstream ss(input);

    std::string buf;
    while (ss >> buf) {
        array.push_back(std::stoi(buf));
    }

    insertionSort(array, array.size());
    
    return 0;
}

bool insertionSort(std::vector<int> &array, int n)
{
    for (int i = 0, j = 0; i < n; i++) {
        auto v = array[i];
        j = i - 1;
        while (j >= 0 && array[j] > v) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = v;

        for (int k = 0; k < n; k++) {
            std::cout << array[k];
            if (k != n - 1) {
                std::cout << " ";
            }

        }
        std::cout << std::endl;
    }

    return true;
}


Measured memory_bytes: 3156
#include <iostream>
#include <set>

using namespace std;

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

  std::set<int> trees[26];
  for (int i = 0; i < N; i++) {
    char ch;
    cin >> ch;
    trees[ch - 'a'].insert(i);
  }

  int Q;
  cin >> Q;
  for (int _ = 0; _ < Q; _++) {
    int type;
    cin >> type;
    if (type == 1) {
      int i;
      char ch;
      cin >> i >> ch;
      i--;
      for (int c = 0; c < 26; c++) trees[c].erase(i);
      trees[ch - 'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      r--;

      int cnt = 0;
      for (int c = 0; c < 26; c++) {
        if (trees[c].size() != 0) {
          auto res = trees[c].lower_bound(l);
          if (res != trees[c].end() && *res <= r) cnt++;
        }
      }
      cout << cnt << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 23808
#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>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

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 unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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())

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

int x[111111];
bool visit[111111];
int main() {
	int n, m, inf = 2000000000;
	scanf("%d%d", &n, &m);
	auto g = vector<vector<PII> >(n);
	REP(i, m) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		l--, r--;
		g[l].PB(MP(r, d));
		g[r].PB(MP(l, -d));
	}
	queue<int> q;
	REP(i, n) {//BFS
		if (g[i].size() == 0 || visit[i]) continue;
		x[i] = 0;
		visit[i] = true;
		q.push(i);
		while (!q.empty()) {
			int idx = q.front();
			q.pop();
			REP(j, g[idx].size()){
				int ti = g[idx][j].first;
				int td = g[idx][j].second;
				if (visit[ti]) {
					if (x[ti] - x[idx] != td) {
						printf("No\n");
						return 0;
					}
				}
				else {
					visit[ti] = true;
					x[ti] = x[idx] + td;
					q.push(ti);
				}
			}
		}
	}
	printf("Yes\n");
	return 0;
}

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

using namespace std;


#define REP(i, n) for(int i = 0; i < n; i++)
#define VSORT(v) sort(v.begin(), v.end())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    while (n--) {
        vector<int> a(3);
        REP(i, 3)cin >> a[i];
        VSORT(a);
        if (a[2] * a[2] == a[0] * a[0] + a[1] * a[1]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  long long sum = 0;
  for (int i = 0; i < 3; i++) {
	if (S[i] == T[i]) sum++;
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int h, w;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	while(std::cin >> h >> w){
		if(h == 0 && w == 0){ break; }
		std::vector<std::string> image;
		std::vector<std::vector<bool> >  is_visited(h, std::vector<bool>(w, false));
		int x = 0;
		int y = 0;

		for(int y = 0; y < h; y++){
			std::cin >> buf;
			image.push_back(buf);
		}

		while(true){
			if(image[y][x] == '.'){
				std::cout << x << " " << y << std::endl;
				break;
			}
			if(is_visited[y][x]){
				std::cout << "LOOP" << std::endl;
				break;
			}
			is_visited[y][x] = true;
			switch(image[y][x]){
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case '^':
				y--;
				break;
			case 'v':
				y++;
				break;
			default:
				break;
			}
		}
	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>

int main() 
{
    int x,y;
    
    while(1)
    {
        scanf("%i",&x);
        scanf("%i",&y);

        if(x==0 && y==0)
        break;

        if(x<y)
        {
            printf("%i %i\n",x,y);
        }
        else if(x==y)
        {
            printf("%i %i\n",x,y);
        }
        else 
        {
            printf("%i %i\n",y,x);
        }

    }

}


Measured memory_bytes: 2036
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll INF=1<<29;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
int main(){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    ans=ngcd(a);
    cout << ans << endl;

}

Measured memory_bytes: 1920
from math import ceil

inf = float('inf')

D, G = map(int, input().split())
PCs = [tuple(map(int, input().split())) for _ in range(D)]

ans = inf
for bits in range(1 << D):
    score = 0
    count = 0
    for j, (p, c) in enumerate(PCs):
        if (bits >> j) & 1:
            score += p * (j + 1) * 100 + c
            count += p
    if score < G:
        for j, (p, c) in zip(reversed(range(D)), reversed(PCs)):
            if not ((bits >> j) & 1):
                need = ceil((G - score) / ((j + 1) * 100))
                if need < p:
                    score += need * (j + 1) * 100
                    count += need
                    break

    if score >= G:
        ans = min(ans, count)
print(ans)


Measured memory_bytes: 3188
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}
struct Edge{
  int to;
  int weight;

  Edge(int t,int w){
    to = t;
    weight = w;
  }
};

using Graph = vector<vector<Edge>>;
vector<bool> seen;

void dfs(const Graph &g,int v){
  seen[v] = true;
  
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  vector<int> todo;
  vector<int> dists;
  int v,e,r;
  
  cin >> v >> e >> r;

  Graph g;
  int s,t,d;
  g.resize(v);
  dists.resize(v);
  seen.assign(v,false);
  dists.assign(v,INF);
  for(ii=0;ii<e;ii++){
    cin >> s >> t >> d;
    g[s].push_back(Edge(t,d));
  }

  seen[r] = true;
  todo.push_back(r);
  dists[r] = 0;
  int dist = 0;
  int hoge;

  while( todo.empty() != true){

    v = todo[0];
    dist = dists[v];
    todo.erase(todo.begin());
    //cout << v << endl;
    //cin >> hoge;

    for(Edge e : g[v]){



      if(dist + e.weight < dists[e.to]){
        dists[e.to] = dist + e.weight;
        seen[e.to] = false;
      }
      
      if(seen[e.to] == false){
              todo.push_back(e.to);
      }

      seen[e.to] = true;
      
    }    
  }

  for(int d : dists){
    if(d != INF){
      cout << d << endl;
    }
    else{
      cout << "INF" << endl;
    }
  }

  
  return 0;

}



Measured memory_bytes: 12636
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



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

    int aa[200]= {};
    int bb[200]= {};
    
    rep(i,a,b+1)aa[i] = 1;
    rep(i,c,d+1)bb[i] = 1;

    int ans = 0;
    rep(i,0,101){
        if(aa[i] == 1 && bb[i] == 1)ans ++;
    }
    if(ans > 0)P(ans-1);
    else P(0);
	return  0;
}

Measured memory_bytes: 256
while 1:
 n=int(input())
 if n==0:break;
 a=[]
 for _ in[0]*n:
  b=list(map(int,input().split()))
  b+=[sum(b)]
  a+=[b]
  for s in b:print("%5d"%s,end='')
  print()
 for c in zip(*a):print("%5d"%sum(c),end='')
 print()


Measured memory_bytes: 5600
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,m,tmp=0;
    cin>>n>>m;
    int a[m];
    for (int i = 0; i < m; i++)
    {
        cin>>a[i];
        tmp+=a[i];
    }
    if(n<tmp)cout<<-1<<endl;
    else cout<<n-tmp<<endl;
    return 0;
}

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

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    vector<pair<unsigned long long, unsigned long long>> students;
    for (unsigned long long i = 0; i < n; ++i) {
        unsigned long long a;
        cin >> a;
        students.emplace_back(i + 1, a);
    }
    sort(students.begin(), students.end(), 
    [](const auto& lhs, const auto& rhs) {
        return lhs.second < rhs.second;
    }
    );
    for (const auto& item : students) cout << item.first << " ";
    cout << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 2544
//phoenix




#include <bits/stdc++.h>
using namespace std;


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=0; i--)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a) sort(a,a+n);


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;



/*
ll solveDp(ll i,ll w[],ll v[],ll n,ll wt,map <ll,map <ll,ll> > &dp) {
    if(i>=n || wt<0)
        return 0;
    if(dp[wt][i])
        return dp[wt][i];
    else if(wt<w[i])
        return dp.insert(mp([wt][i]=solveDp(i+1,w,v,n,wt,dp);
    else
        return dp[wt][i]=max(solveDp(i+1,w,v,n,wt,dp),v[i]+solveDp(i+1,w,v,n,wt-w[i],dp));
}
*/


/*
void bfs(ll k,bool vis[],ll n,vector <ll> v[]) {
    queue <ll> q;
    q.push(k);
    while(!q.empty()) {
        ll node=q.front();
        q.pop();
        cout<<node<<" ";
        vis[node-1]=true;
        fr(j,0,v[node-1].size()) {
            if(vis[v[node-1][j]-1]!=true)
                q.push(v[node-1][j]),vis[v[node-1][j]-1]=true;
        }
    }
}




void dfs(ll k,bool vis[],ll n,vector <ll> v[]) {
    cout<<k<<" ";
    vis[k-1]=true;
    fr(i,0,v[k-1].size()) {
        if(!vis[v[k-1][i]-1])
            dfs(v[k-1][i],vis,n,v);
    }
}




ll solveDp(ll i,ll a[],ll n,vector <ll> &dp) {
    if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    else {
        ll mx=-inf;
        fr(j,0,n) {
            mx=max(mx,a[i]+solveDp(i+j+2,a,n,dp));
        }
        return dp[i]=mx;
    }
}
*/



void cazz() {
    ll n,i,j,k,ans=0,f=0,wt,m=0;
    cin>>n;
    ll a[n-1],b[n]={};
    fr(i,0,n-1) {
        cin>>a[i];
        b[a[i]-1]++;
    }
    fr(i,0,n)
        cout<<b[i]<<"\n";
    /*cin>>n>>m;
    vector <ll> v[n];
    fr(i,0,m) {
        cin>>j>>k;
        v[j-1].pb(k);
        v[k-1].pb(j);
    }
    cout<<"\n";
    fr(i,0,n) {
        cout<<i+1<<"\t";
        fr(j,0,v[i].size()) {
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
    cout<<"\n";
    cin>>k;
    bool vis[n]={};
    bfs(k,vis,n,v);
    cout<<"\n";
    bool vi[n]={};
    dfs(k,vi,n,v);*/
}




int main() {
    spdio;
	cazz();
	return 0;
}




Measured memory_bytes: 6736
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below

void solve(){
	string str1,str2;
    cin>>str1>>str2;
    int n=str1.size()+1,m=str2.size()+1;
    int dp[n][m];
    for(int i=0;i<n;i++)
        dp[i][0]=0;
    for(int i=0;i<m;i++)
        dp[0][i]=0;
    
    string ans="";
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(str1[n-i-1]==str2[m-j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    if(dp[n-1][m-1]>0){
        // travel bottom up
        int i=n-1,j=m-1;
        while(i>0 and j>0 ){
            if(str1[n-i-1]==str2[m-j-1]){
                ans+=str2[m-j-1];
                i--;
                j--;
            }else{
                if(dp[i-1][j]>dp[i][j-1]){
                    i--;
                }else{
                    j--;
                }
            }
            // cout<<endl;
        }
    }

    cout<<ans<<endl;
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n;
ll m, v, p, a[125252];

bool is_ok(int mid){
  if(a[p-1]-a[mid]>m){
    return false;
  }
  ll cnt=m*v-m*(p+n-mid-1);
  FOR(i, p-1, mid){
    cnt-=min(a[mid]+m-a[i], (ll)m);
  }
  return cnt<=0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  cin>>n>>m>>v>>p;
  REP(i, n){
    cin>>a[i];
  }
  sort(a, a+n, greater<int>());
  int lb=p-1, ub=n;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(is_ok(mid)){
      lb=mid;
    }
    else{
      ub=mid;
    }
  }
  cout<<lb+1<<'\n';
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define MAX 50
using namespace std;

vector<vector<int> > d(MAX,vector<int>(MAX));
int w,h,data[MAX][MAX];

void dfs(int x, int y,int num){
    int vx[] = {1,-1,0,0,1,-1,1,-1};
    int vy[] = {0,0,1,-1,1,-1,-1,1};
    data[y][x] = num;

    for(int i=0; i<8; i++){
        int dx = vx[i] + x; int dy = vy[i] + y;
        if(dx >= w || dx < 0 || dy >= h || dy < 0 ||
            d[dy][dx] != 1 || data[dy][dx] == num) continue;
        dfs(dx,dy,num);
    }
}

int main(){
    while(1){
        cin>>w>>h;
        if(h == 0 && w == 0 ) break;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                 cin>>d[i][j];
            }
        }

        for(int i=0; i<MAX; i++){
            for(int j=0; j<MAX; j++){
                data[i][j] = -2;
            }
        }

        int ans = 0;

        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(d[i][j] == 1 && data[i][j] < 0){
                    dfs(j,i,ans);
                    ans++;
                }
            }
        }   
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;

    ll ret = 0;
    vector<ll> cnt(26);
    REP(i, n) {
        cnt[s[i]-'a']++;
        ll tmp = 1;
        REP(j, 26) {
            (tmp *= (cnt[j]+1)) %= MOD;
        }
        // cout << tmp << endl;
        ret = (tmp-1+MOD) % MOD;
    }
    cout << ret << endl;

    return 0;
}


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

int main() {
    int n;
    int x[20];
    cin >> n;
    rep(i, n){
      cin >> x[i];
    }
    int ans = 0;
    rep(i, n - 2){
      if((x[i] < x[i+1] && x[i+1] < x[i+2]) || (x[i] > x[i+1] && x[i+1] > x[i+2])) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let n = read_one::<usize>();
    for x in 0..=n {
        if (x as f64 * 1.08).floor() as usize == n {
            println!("{}", x);
            return;
        }
    }
    println!(":(");
}

#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 2628
#include <cstdio>

typedef long long LL;
const int N = 2e5 + 10;
const int Mod = 924844033;
const int M = (1 << 20) + 10;
struct E {int v, nt;} e[N<<1];
int n, L, tot, a[M], b[M], h[N], wn[30], fac[N], inv[N], rev[M];

inline int mls(int x) {return x < 0 ? x + Mod : x;}
inline int pls(int x) {return x >= Mod ? x - Mod : x;}
inline void add(int u, int v) {
	e[++tot] = (E){v, h[u]}, h[u] = tot;
	e[++tot] = (E){u, h[v]}, h[v] = tot;
}
template <class T> inline void swap(T &a, T &b) {T t = a; a = b, b = t;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline int qpow(int A, int B) {
	int S = 1;
	for (; B; B >>= 1, A = 1LL * A * A % Mod)
		if (B & 1) S = 1LL * S * A % Mod;
	return S;
}

inline int dfs(int x, int f) {
	int sz = 1;
	for (int v, i = h[x]; i; i = e[i].nt)
		if ((v = e[i].v) != f) sz += dfs(v, x);
	if (x != 1) ++a[sz], ++a[n - sz];
	return sz;
}

inline void FFT(int *a, int n) {
	for (int i = 0; i < n; ++i) if (i < rev[i]) swap(a[i], a[rev[i]]);
	for (int i = 1, l = L-1; i < n; i <<= 1, --l)
		for (int j = 0; j < n; j += i << 1)
			for (int u, v, k = 0, w = 1; k < i; ++k, w = 1LL * w * wn[l] % Mod)
				u = a[j + k], v = 1LL * w * a[i + j + k] % Mod,
				a[j + k] = pls(u + v), a[i + j + k] = mls(u - v);
}

inline void Mul(int m) {
	int invn, n = 1;
	for (L = 0; n <= m; n <<= 1, ++L);
	invn = qpow(n, Mod - 2);
	for (int i = 1; i < n; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << L-1);
	
	wn[0] = qpow(5, Mod-1 >> L);
	for (int i = 1; i < L; ++i) wn[i] = 1LL * wn[i-1] * wn[i-1] % Mod;
	FFT(a, n), FFT(b, n);
	for (int i = 0; i < n; ++i) a[i] = 1LL * a[i] * b[i] % Mod;
	
	wn[0] = qpow(wn[0], Mod - 2);
	for (int i = 1; i < L; ++i) wn[i] = 1LL * wn[i-1] * wn[i-1] % Mod;
	FFT(a, n);
	for (int i = 0; i < n; ++i) a[i] = 1LL * a[i] * invn % Mod;
}

int main() {
	int u, v, ret; in(n);
	for (int i = 1; i < n; ++i) in(u), in(v), add(u, v);
	dfs(1, 0), fac[0] = fac[1] = inv[0] = inv[1] = 1;
	
	for (int i = 2; i <= n; ++i) inv[i] = 1LL * (Mod - Mod / i) * inv[Mod % i] % Mod;
	for (int i = 1; i <= n; ++i) inv[i] = 1LL * inv[i - 1] * inv[i] % Mod;
	for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % Mod;
	
	for (int i = 0; i <= n; ++i)
		a[i] = 1LL * a[i] * fac[n - i] % Mod, b[i] = inv[i];
	Mul(n << 1);
	
	for (int i = 1; i <= n; ++i) {
		ret = mls(1LL*n*fac[n]%Mod*inv[n-i]%Mod*inv[i]%Mod - 1LL*a[n-i]*inv[i]%Mod);
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 23424
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<string> s(N);
  REP(i, N) cin >> s[i];

  vector<int> sum(N);
  REP(i, N) REP(j, N) if(s[i][j] == '1') sum[i]++;

  vector<vector<int>> S(N, vector<int>(N));
  REP(i, N) REP(j, N) S[i][j] = s[i][j] == '0' ? 0:1;

  vector<vector<int>> graph(N);
  REP(i, N){
    REP(j, N){
      if(S[i][j] == 1){
        graph[i].push_back(j);
        graph[j].push_back(i);
      }
    }
  }

  vector<vector<int>> maxvec(N);
  int length = -1, maxlength = -1;
  REP(k, N){

    queue<pair<int, int>> q;
    q.push(make_pair(k, 1));
    vector<int> visited(N, 0);
    vector<vector<int>> vec(N);
    visited[k] = 1;
    pair<int, int> p;
    vec[0].push_back(k);
    while(!q.empty()){
      p = q.front(); q.pop();

      for(int i : graph[p.first]){
        if(visited[i]) continue;
        visited[i] = 1;
        vec[p.second].push_back(i);
        length = p.second+1;
        q.push(make_pair(i, p.second+1));
      }
    }

    if(maxlength < length){
      maxlength = length;
      maxvec = vec;
    }
  }

  REP(i, N){
    REP(j, maxvec[i].size()){
      for(int k = 0; k < j; k++){
        if(S[maxvec[i][j]][maxvec[i][k]] == 1){
          cout << -1 << endl;
          return 0;
        }
      }
    }
    cout << endl;
  }

  cout << maxlength << endl;

  return 0;
}

Measured memory_bytes: 1536
L=[]
tmp=0
for i in range (3):
	L.append(list(map(int,input().split())))
N=int(input())
X=[]
for i in range (N):
	X.append(int(input()))
for i in range(N):
	for j in range(3):
		for k in range(3):
			if L[j][k]==X[i]:
				L[j][k]=0
if L[0][0]==0:
	if L[0][1]==0 and L[0][2]==0:
		tmp+=1
	if L[1][0]==0 and L[2][0]==0:
		tmp+=1
	if L[1][1]==0 and L[2][2]==0:
		tmp+=1
if L[1][1]==0:
	if L[1][0]==0 and L[1][2]==0:
		tmp+=1
	if L[0][1]==0 and L[2][1]==0:
		tmp+=1
	if L[0][2]==0 and L[2][0]==0:
		tmp+=1
if L[2][2]==0:
	if L[0][2]==0 and L[1][2]==0:
		tmp+=1
	if L[2][0]==0 and L[2][1]==0:
		tmp+=1
if tmp!=0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 3005;
const int MOD = 1000000007;

int n, S[N][N], s, res, i, j;
char t[N];


int main() {
scanf("%d", &n);
scanf("%s", t);
S[1][1] = 1;
for (i=2;i<=n;i++) {
	if (t[i - 2] == '<') {
		s = 0;
		for (j=1;j<=i;j++) {
			s = (s + S[i - 1][j - 1]) % MOD;
			S[i][j] = s;			
		}
	} else {
		s = 0;
		for (j=i;j>=1;j--) {
			s = (s + S[i - 1][j]) % MOD;
			S[i][j] = s;			
		}
	}
}
res = 0;
for (i=1;i<=n;i++) res = (res + S[n][i]) % MOD;
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 34176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep1(i, n) if(i % 3 != 0 && i % 5 != 0) ans += i;
    cout << ans << endl;
}

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

int main(int argc, void **arg)
{
    int n;
    int h[20];
    int count = 1;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &h[i]);
    }

    for (int i = 1; i < n; i++)
    {
        int j;
        for (j = i - 1; j >= 0; j--)
        {
            if( h[i] < h[j] ) break;
        }
        
        if( j < 0 ) count++;
    }
    

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 128
A, B, C, X, Y = map(int, input().rstrip("\n").split())
Z = min(X, Y)

ans = [
       A * X + B * Y,
       A * (X - Z) + B * (Y - Z) + 2 * C * Z,
       max(X, Y) * 2 * C
      ]

print(min(ans))


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

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int a, b;
    cin >> a >> b;
    int pl = a + b;
    int mn = a - b;
    int ml = a * b;
    cout << max(pl, max(mn, ml)) << endl;

    return 0;
}


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;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
void solve(){
   vector<ll>a,l(n+2),r(n+2);
    a.push_back(0);
    rep(i,n){
        ll ai;
        cin>>ai;
        a.push_back(ai);
    }
    a.push_back(0);
    l[0]=0,r[n+1]=0;
    for(int i=1;i<=n+1;i++){
        l[i]=l[i-1]+abs(a[i]-a[i-1]);
    }
    for(int i=n;i>=0;i--){
        r[i]=r[i+1]+abs(a[i]-a[i+1]);
    }
    for(int i=1;i<=n;i++)
    {
        ll ans=l[i]+r[i];
        ans=ans-abs(a[i]-a[i-1]);
        ans=ans-abs(a[i]-a[i+1]);
        ans=ans+abs(a[i-1]-a[i+1]);
        cout<<ans<<endl;
    }

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

    cin>>n;
    solve();
    return 0;
}


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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    long long x,y,ans=0;
    scanf ("%lld%lld",&x,&y);
    while (x<=y){
        ans++;
        x=2*x;
    }
    printf ("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x>=1200){
    cout<<"ARC"<<"\n";
  }
  else{
    cout<<"ABC"<<"\n";
  }
  
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  string S, T;
  cin >> S >> T;

  int count = 0;
  rep(i, S.size())
  {
    if (S[i] != T[i])
      count++;
  }
  cout << count << endl;

  return 0;
}


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

int main(){
 int A,B;
 cin >> A >> B;
 long long C=A;
 long long N=100000000;
 for (int i=0; i<N; i++){
    if (C%B==0){
       break; 
    }
    C+=A;
 }
 
 cout << C << endl;
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,l; cin>>n>>l;
	vector<string> s(n); rep(i,n) cin>>s[i]; sort(ALL(s));
	rep(i,n) cout<<s[i]; cout<<endl;
	return 0;
}


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

int main() {
  long mokuhyou,nowmoney = 100,count = 0;
  double rate = 1.01;
  cin >> mokuhyou;

  while(nowmoney < mokuhyou){
    
    nowmoney = nowmoney*rate;
    
    ++count;

  }
  
  
  
  
  	cout << count << endl;
  
}

Measured memory_bytes: 3636
N = int(input())
B = list(map(int, input().split()))
A = [0] * N
A[0] = B[0]
for i in range(N - 2):
    A[i + 1] = min(B[i], B[i + 1])
A[N - 1] = B[N - 2]
print(sum(A))


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

int main(){
    int n,cnt=0,cnt1=0;
    cin >> n;
    int a[n],c[n];
    char b[n],d[n],e[n];
    for(int i=0;i<n;i++) cin >> b[i] >> a[i];
    for(int i=0;i<n;i++){
        c[i]=a[i];
        d[i]=b[i];
        e[i]=b[i];
    } 
    bool flag = 1,flag1 = 0;
    while(flag){
        flag = 0;
        for(int j=n-1;0<j;j--){
            if(a[j]<a[j-1]){
                 swap(d[j],d[j-1]);
                 swap(a[j],a[j-1]);
                 cnt++;
                 flag = 1;
            }
        }
     }
     for(int i=0;i<n;i++){
         int minj = i;
         for(int j=i+1;j<n;j++){
             if(c[j]<c[minj]){
                 minj = j;
             }
         }
          swap(c[i],c[minj]);
          swap(e[i],e[minj]);
     }
    for(int i=0;i<n-1;i++) cout << d[i] << a[i] << " ";
    cout << d[n-1] << a[n-1] << endl;
    for(int i=0;i<n;i++){
        if(d[i]!=e[i]) flag1=1;
    }
    cout << "Stable" << endl;
    for(int i=0;i<n-1;i++) cout << e[i] << c[i]<<  " ";
    cout << e[n-1] << c[n-1]<< endl;
    if(flag1) cout << "Not stable" << endl;
    else cout << "Stable" << endl;
    
}


Measured memory_bytes: 3112
fun main(args: Array<String>) {
    val s = readString()
    val l = s.length
    var cnt = 0
    for (i in 0 until l / 2) {
        if (s[i] != s[l-1-i]) {
            cnt++
        }
    }
    println(cnt)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
b = [a[i] - (i+1) for i in range(n)]
b.sort()
if n % 2 == 0:
    c = (b[n//2-1] + b[n//2]) // 2
else:
    c = b[n//2]

ans = 0
for i in range(n):
    ans += abs(a[i]-(c+i+1))
print(ans)

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

using namespace std;

int N, M;
int f[100001];
int A[100001];
bool use[100001];

int find(int u)
{
    if(u!=f[u])
        f[u]=find(f[u]);
    return f[u];
}

int main()
{
    scanf("%d%d", &N, &M);
    for(int i=1; i<=M; i++)
        f[i]=i;
    int root=0;
    for(int i=0; i<N; i++)
    {
        int K;
        scanf("%d", &K);
        for(int j=0; j<K; j++)
        {
            scanf("%d", A+j);
            use[A[j]]=true;
            root=A[j];
            if(j>0)
                f[find(A[j-1])]=find(A[j]);
        }
    }
    bool ok=true;
    for(int i=1; i<=M; i++) if(use[i])
        ok&=find(i)==find(root);
    printf(ok?"YES\n":"NO\n");
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> a(M + 1);
    for (ll i = 0; i < M; i++) {
        cin >> a.at(i);
    }
    a.at(M) = N + 1;
    vector<ll> F(N + 2); //フィボナッチ数列
    for (ll i = 0; i < N + 2; i++) {
        if (i == 0) {
            F.at(i) = 0;
        }
        else if (i == 1 || i == 2) {
            F.at(i) = 1;
        }
        else {
            F.at(i) = F.at(i - 1) + F.at(i - 2);
            F.at(i) %= mod;
        }
    }
    ll ans = 1, left = 0, right = a.at(0), dist, cnt;
    dist = right - left;
    cnt = F.at(dist);
    cnt %= mod;
    ans *= cnt;
    ans %= mod;
    for (ll i = 0; i < M; i++) {
        left = right + 1;
        right = a.at(i + 1);
        dist = right - left;
        cnt = F.at(dist);
        cnt %= mod;
        ans *= cnt;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792