akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,c;
ll a[300005],b[300005];
ll x,y,ans=0,look;

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		if(b[a[i]-1]!=0){
			b[a[i]] = b[a[i]-1]+1;
			ans = max(ans,b[a[i]]);
		}else{
			b[a[i]] = 1;
			ans = max(ans,b[a[i]]);
		}
	}
	p(n-ans);
	return 0;
}

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

int main() {
    int n, q, t;
    string name;
    queue<pair<string, int> > Q;
    
    cin >> n >> q;
    
    rep(i,n) {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }
    
    pair<string, int> u;
    int elaps = 0, a;
    
    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if (u.second > 0) Q.push(u);
        else cout << u.first << " " << elaps << endl;
    }
    
    return 0;
}


Measured memory_bytes: 6328
#include <bits/stdc++.h>
#define int long long int
using namespace std;
const int INF = 1e9 + 5;

int minCost(vector<int>& h, int k){
    int n = h.size();
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i=0; i<n-1; i++){
        for(int j=1; j<=k; j++){
            if(i+j < n)
                dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    return dp[n-1];
}


int32_t main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    cout << minCost(h, k) << "\n";
}

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

int main(){
    long long ans = 0;
    long long n, x, t;
    cin >> n >> x >> t;
    
    long long buf = 0;
    while (buf < n) {
        buf += x;
        ans += t;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3632
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


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

	ll N;
	cin >> N;
	vector<string> arr;
	rep(i, s.size()) {
		fori(j, i, min(i + 5, (ll)s.size())) {
			arr.push_back(s.substr(i, j - i + 1));
		}
	}
	sort(all(arr));
	unique(all(arr));
	cout << arr[N - 1] << endl;
}

Measured memory_bytes: 1660
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)


n,k = inm()
a = inl()
a.sort()
facary = [1]
for i in range(1,n):
    facary.append((facary[i-1]*i)%R)
ddprint(a)
ddprint(facary)
smp = smm = 0
for i in range(n):
    dp = dm = 0
    if i>=k-1:
        dp = ((facary[i]*modinv2(facary[k-1]*facary[i-k+1],R))*a[i])%R
    if i<=n-k:
        dm = \
         ((facary[n-i-1]*modinv2(facary[n-k-i]*facary[k-1],R))*a[i])%R
    ddprint("dp {} dm {}".format(dp,dm))
    smp += dp
    smm += dm
print((smp-smm)%R)


Measured memory_bytes: 64296
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

	std::vector<std::string> W(N);
	for(int i = 0; i < N; i++) {
		std::cin >> W[i];
	}

	bool answer = true;

	for(int i = 0; i < N; i++) {
		if(i != 0) {
			if(W[i - 1].back() != W[i].front()) {
				answer = false;
				break;
			}
		}
		if(std::count(W.begin(), W.end(), W[i]) != 1) {
			answer = false;
			break;
		}
	}

	std::cout << (answer ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int X = sc.nextInt();
   boolean br = true;
   
   while(br)
   {
     br=false;
     for(int i=2;i<=Math.sqrt(X);i++)
     {
       if(X%i==0)
       {
         br=true;
         break;
       }
     }     
     X++;
   }
   X--;
   System.out.println(X);
 }
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    set<int> s;
    REP(i, 3) {
        int a;
        cin >> a;
        s.emplace(a);
    }

    cout << s.size() << endl;
    return 0;
}

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

int main() {
    int N, C;
    cin >> N >> C;
    int record[C][MAX_T];
    for (int c = 0; c < C; c++) {
        fill(record[c], record[c] + MAX_T, 0);
    }
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        s--, t--, c--;
        fill(record[c] + s, record[c] + t + 1, 1);
    }
    int ans = 0;
    for (int t = 0; t < MAX_T; t++) {
        int nc = 0;
        for (int c = 0; c < C; c++) {
            nc += record[c][t];
        }
        ans = max(nc, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5,mod=1e9+7;
int n,ctt,tmp,a[maxn],d[maxn],cnt[maxn],cir_cnt[maxn];
long long ans=1,f[maxn];
bool vis[maxn];
vector <int> to[maxn];
queue <int> q;
void dfs(int now){
	if(cnt[now]!=1) tmp=now;
	vis[now]=true;ctt++;
	int siz=to[now].size();
	for(int i=0;i<siz;i++){
		int u=to[now][i];
		if(vis[u]==true) continue;
		dfs(u);
	}
}
int work(int now){
	int siz=to[now].size(),len;
	for(int i=0;i<siz;i++){
		int u=to[now][i];
		if(u==tmp){len=cnt[tmp]-2;continue;}
		len=work(u);
	}
	if(cnt[now]==1){return len-1;}
	else{
		if(len>=1){ans=0;}
		if(len<=-1){ans=ans*2%mod;}
		return cnt[now]-2;
	}
}
void Go(int now){
	ctt=0;tmp=0;
	dfs(now);
	if(!tmp){cir_cnt[ctt]++;}
	else{work(tmp);}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){cnt[i]=1;scanf("%d",&a[i]);to[i].push_back(a[i]);d[a[i]]++;}
	for(int i=1;i<=n;i++){if(d[i]==0) q.push(i);}
	while(!q.empty()){
		int now=q.front();q.pop();
		int siz=to[now].size();
		vis[now]=true;
		for(int i=0;i<siz;i++){
			int u=to[now][i];
			d[u]--;
			if(cnt[u]!=1) ans=0;
			else cnt[u]+=cnt[now];
			if(d[u]==0) q.push(u);
		}
	}
	for(int i=1;i<=n;i++){if(!vis[i]){Go(i);}}
	for(int i=1;i<=n;i++){
		f[0]=1;
		int opt=((i&1)&&(i!=1))?2:1,k=cir_cnt[i];
		for(int j=1;j<=k;j++){f[j]=0;}
		for(int j=0;j<k;j++){
			f[j+1]=(f[j+1]+f[j]*opt)%mod;
			f[j+2]=(f[j+2]+f[j]*(k-j-1)%mod*i%mod)%mod;
		}
		ans=ans*f[k]%mod;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 16896
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int a, b, k;
  readf("%s %s %s\n", &a, &b, &k);
  foreach (i; 0..k) {
    if (i % 2) {
      if (b % 2) {
        b--;
      }
      b /= 2;
      a += b;
    } else {
      if (a % 2) {
        a--;
      }
      a /= 2;
      b += a;
    }
  }
  writefln("%s %s", a, b);
}


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

bool is_prime_number(ll num)
{
    if (num == 2) {
        return true;
    }
    if (num % 2 == 0 || num == 1) {
        return false;
    }

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

void main_()
{
    vector<ll> like2017(1e5 + 1);
    for (ll i = 1; i <= 1e5; i++) {
        like2017[i] = is_prime_number(i) && is_prime_number((i + 1) / 2);
    }

    vector<ll> like2017_ps;
    partial_sum(begin(like2017), end(like2017), back_inserter(like2017_ps));

    ll Q;
    cin >> Q;

    for (ll i = 0; i < Q; i++) {
        ll l, r;
        cin >> l >> r;
        cout << like2017_ps[r] - like2017_ps[l - 1] << endl;
    }
}
int main()
{
    //cin.tie(nullptr);
    //cout.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2292
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

void bad()
{
    cout << "Impossible";
    exit(0);
}
void good()
{
    cout << "Possible";
    exit(0);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    sort(all(a));
    if (a[n - 1] != a[n - 2])
        bad();
    if (a[0] != (a[n - 1] + 1) / 2)
        bad();
    if (a[n - 1] % 2 == 0)
    {
        if (a[0] == a[1])
            bad();
    }
    else
    {
        if (n > 2 && a[0] == a[1] && a[1] == a[2])
            bad();
    }
    set <int> s;
    for (auto &i : a)
        s.emplace(i);
    for (int i = a[0]; i < a[n - 1]; ++i)
        if (!s.count(i))
            bad();
    good();
    return 0;
}



Measured memory_bytes: 256
def bipertite_matching(N, edges):
    def dfs(v):
        used[v] = True
        for u in edges[v]:
            w = match[u]
            if w < 0 or (used[w] == False and dfs(w)):
                match[v] = u
                match[u] = v
                return True
        return False
    match = [-1 for _ in range(N)]
    ret = 0
    for v in range(N):
        if match[v] < 0:
            used = [False for _ in range(N)]
            if dfs(v):
                ret += 1
    return ret

N = int(input())
a, b = [None] * N, [None] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c, d = [None] * N, [None] * N
for i in range(N):
    c[i], d[i] = map(int, input().split())
es = [[] for i in range(2 * N)]
for i in range(N):
    for j in range(N):
        if a[i] < c[j] and b[i] < d[j]:
            es[i].append(N+j)
            es[N+j].append(i)
print(bipertite_matching(2*N, es))


Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main()
{
	int k;
	cin>>k;
	int num=1;
	int x=7;
	while(x%k){
		if(num>1000010){
			num=-1;
			break;
		} 
 		num++;
		x=x*10+7;
		x%=k;
	}
	cout<<num<<endl; 
	return 0;
 } 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
 int n,ans=1;
  cin>>n;
  string s;
  cin>>s;
  rep(i,n-1){
    if(s.at(i)!=s.at(i+1))ans++;
  }
  cout<<ans<<endl;
}

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

int main() {
	string a, b, ans = "No";
	cin >> a >> b;
	int s = stoi(a + b);
	for (int i = 0;i < 1000;i++) {
		if (i*i == s) { ans = "Yes";break; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#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() {
    string n;
    cin >> n;
    int s = n.length();
    rep(i, s) {
        if (n.substr(i, 1) == "7") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll mod = 998244353;
	ll N;
	cin >> N;
	vector<ll> D(N);
	rep(i, N) cin >> D[i];
	if(D[0]!=0) {
		cout << 0 << endl;
		return 0;
	}


	sort(D.begin(), D.end());
	ll ans = 1;
	ll cnt = 0;
	ll pre_cnt = 1;
	ll num = 0;

	if(N>1) {
		if(D[1]==0){
			cout << 0 << endl;
			return 0;
		}
	}
	
	rep(i, N) {
		if(D[i]==num) {
			cnt++;
			ans *= pre_cnt;
			ans %= mod;
		}else if(D[i]==num+1){
			pre_cnt = cnt;
			ans *= pre_cnt;
			ans %= mod;
			cnt = 1;
			num++;
		} else {
			ans = 0;
			break;
		}
		//cout << D[i] << " ans " << ans << " pcnt " << pre_cnt << " num " << num << endl;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    if(s[i]=='1') cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const ll L = 2e17;

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <ll> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  auto chet = [&] (ll x, ll y, ll a, ll b) {
    if (x > a || y > b) {
      return false;
    }
    ll n = a - x + b - y;
    ll m = a - x;
    return ((n & m) == m);
  };
  auto f = [&] (ll t) {
    ll ret = 0;
    for (int i = 0; i < n; i++) {
      ret ^= chet(x[i], y[i], L - t, t);
    }
    return ret;
  };
  ll vl, vr;
  {
    ll y = 0;
    for (int k = 60; k >= 0; k--) {
      if (f(y - (1ll << k))) {
        y -= (1ll << k);
      }
    }
    vl = y;
    y = 0;
    for (int k = 60; k >= 0; k--) {
      if (f(y + (1ll << k))) {
        y += (1ll << k);
      }
    }
    vr = y;
  }
  ll ans = (vr - vl) - L;
  cout << -ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<int,int> c;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    c[a]++;
  }
  int r=0;
  for(auto x:c)
    r=abs(r-(x.second-1));
  cout<<c.size()-r%2<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 510000;
int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int p;
  cin >> p;
  MOD=p;
  COMinit();  
  ll a[p];
  rep(i,p)cin >> a[i];
  ll b[p]={};
  for(int i=0;i<p;i++){
    if(i==0){
      b[p-1]++;
      b[0]=p-1;
      b[p-1]*=(finv[p-1]*a[0]);
      b[p-1]%=p;
      b[0]*=finv[p-1]*a[0];
      b[0]%=p;
    }else{
      ll temp=1;
      ll add[p]={};
      for(int j=0;j<p-1;j++){
        add[p-1-j]=temp*a[i];
        add[p-1-j]*=finv[p-1];
        add[p-1-j]%=p;
        b[p-1-j]+=add[p-1-j];
        b[p-1-j]%=p;
        temp*=i;
        temp%=p;
      }
    }
  }
  for(int i=0;i<p;i++)cout << b[i]%p << ' ';
  cout << endl;
return 0;}


Measured memory_bytes: 12416
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
int main(){
    long long int N,i,j;
    scanf("%lli",&N);
    i=sqrt(N);
    for(;;i--){
        if(N%i==0){
            j=N/i;
            break;
        }
    }

    printf("%lli",(i-1)+(j-1));

 return 0;
}



Measured memory_bytes: 128
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	auto m = readInt();
	for(int i; i < m; ++i) {
		bool hash[string];
		auto s = readln.chomp;
		for(int j = 1; j < s.length; ++j) {
			auto s1 = s[0..j];
			auto s2 = s[j..$];
			auto s1r = s1.dup.reverse.idup;
			auto s2r = s2.dup.reverse.idup;
			hash[s1 ~ s2] = true;
			hash[s1 ~ s2r] = true;
			hash[s1r ~ s2] = true;
			hash[s1r ~ s2r] = true;
			hash[s2 ~ s1] = true;
			hash[s2 ~ s1r] = true;
			hash[s2r ~ s1] = true;
			hash[s2r ~ s1r] = true;
		}
		writeln(hash.length);
	}
}

Measured memory_bytes: 3372
def bubbleSort(A,N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for i in range(1,N):
            if A[N-i] < A[N-i-1]:
                A[N-i] , A[N-i-1] = A[N-i-1] , A[N-i]
                flag = 1
                count += 1
    return (count)

n = int(input())
data = [int(i) for i in input().split()]
a = bubbleSort(data,n)
print(" ".join(map(str,data)))
print(a)

Measured memory_bytes: 7740
from itertools import groupby

N=int(input())
A=list(map(int,input().split()))
A.sort()

A=groupby(A)
odd=0
even=0
for key,group in A:
    g=len(list(group))
    if g%2==1:
        odd+=1
    else:
        even+=1

if even%2==1:
    print(odd+even-1)
else:
    print(odd+even)

Measured memory_bytes: 56004
use std::cmp::max;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let k: i64 = itr.next().unwrap();
    let n: i64 = itr.next().unwrap();

    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let v: Vec<i64> = s.split_whitespace().map(|e| e.parse().unwrap()).collect();
    let mut a = 0;

    for i in 0..v.len() - 1 {
        a = max(a, v[i + 1] - v[i]);
    }

    a = max(a, v[0] + k - v[n as usize - 1]);

    println!("{}", k - a);
}


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

int N, M;

int main(){
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> T[i];
    sum += T[i];
  }
  cin >> M;
  for(int i = 0; i < M; i++){
    int P, X;
    cin >> P >> X;
    cout << sum - (T[P-1] - X) << endl;
  }
}

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


def runLength(s):
    a = []
    for i, c in enumerate(s):
        if len(a) == 0 or a[-1][0] != c:
            a.append([c, 1, i])  # 文字種, 長さ, 開始位置
        else:
            a[-1][1] += 1
    return a


def main():
    s = input().strip()
    ans = [-1]*(len(s)+1)
    a = runLength(s)
    a.sort(key=lambda x: x[1], reverse=True)
    for c, n, i in a:
        if c == "<":
            x = (ans[i] if ans[i] != -1 else 0)
            for j in range(i, i+n+1):
                if ans[j] == -1:
                    ans[j] = x
                x += 1
        else:
            x = (ans[i+n] if ans[i+n] != -1 else 0)
            for j in range(i+n, i-1, -1):
                if ans[j] == -1:
                    ans[j] = x
                x += 1
    print(sum(ans))


if __name__ == '__main__':
    main()


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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////
// Range Add Query //
/////////////////////////

class RAQ {
private:
	std::vector<int64_t> container_;

	void build(const unsigned int array_size)
	{
		unsigned int length{1};
		while (length < array_size)
			length <<= 1;
		container_.resize(2 * length);
	}

public:
	RAQ(const unsigned int array_size) { build(array_size); }
	RAQ(const std::vector<int64_t> &array)
	{
		build(array.size());
		std::copy(array.begin(), array.end(), container_.begin() + (container_.size() >> 1));
		for (int i{((int)container_.size() >> 1) - 1}; i > 0; i--)
			container_[i] = container_[2 * i] + container_[2 * i + 1];
	}
	// left,rightは0-indexed、[left, right)の半開区間
	void update(const int left, const int right, const int64_t added)
	{
		for (int left_i{std::max(0, left) + ((int)container_.size() >> 1)}, right_i{std::min((int)container_.size() >> 1, right) + ((int)container_.size() >> 1)};
			left_i < right_i; left_i >>= 1, right_i >>= 1
			)
		{
			if (left_i & 1)
			{
				container_[left_i] += added;
				left_i++;
			}
			if (right_i & 1)
			{
				right_i--;
				container_[right_i] += added;
			}
		}
	}
	// indexは0-indexed
	int64_t get(const int index) const
	{
		int64_t sum{};
		for (int add_place{index + ((int)container_.size() >> 1)}; add_place > 0; add_place >>= 1)
			sum += container_[add_place];
		return sum;
	}
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


int main()
{
	int n, q;
	scanf("%d%d", &n, &q);

	RAQ raq(n);
	for (int q_i{}; q_i < q; q_i++)
	{
		int com;
		scanf("%d", &com);
		if (com)
		{
			int i;
			scanf("%d", &i);
			i--;
			printf("%lld\n", raq.get(i));
		}
		else
		{
			int s, t, x;
			scanf("%d%d%d", &s, &t, &x);
			raq.update(s - 1, t, x);
		}
	}
	return 0;
}


Measured memory_bytes: 4948
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int N; cin >> N;
	vector<int>A;
	vector<Int>S;
	Int ps = 0;
	S.push_back(ps);
	for (int i = 0; i < N; i++) {
		int ipst; cin >> ipst;
		A.push_back(ipst);
		ps += ipst; S.push_back(ps);
	}
	sort(S.begin(), S.end());
	Int cnt = 0;
	ps = S[0];
	Int subcn = 1;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == ps) {
			cnt += subcn;
			subcn++;
		}
		else {
			ps = S[i];
			subcn = 1;
		}
	}
	print(cnt);





	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

bool mat[11][1002];

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            char ch;
            cin >> ch;
            mat[i][j] = ch - '0';
        }
    }
    int ans = INF;
    for(int mask = 0; mask < (1LL << (n-1)); mask++)
    {
        int cnt = __builtin_popcount(mask) + 1;
        vector<int> v(cnt+1, 0);
        int flag = 0;
        int dividers = cnt-1;
        for(int j = 1; j <= m; j++)
        {
            vector<int> tmp(cnt+1, 0);
            int idx = 0, sum = 0, a = mask;
            for(int i = 1; i <= n; i++)
            {
                sum += mat[i][j];
                int d = (a & 1);
                a >>= 1;
                if(d)
                {
                    tmp[++idx] = sum;
                    sum = 0;
                }
            }
            tmp[++idx] = sum;
            for(int i = 1; i <= cnt; i++)
            {
                if(tmp[i] > k)
                {
                    flag = 1;
                    break;
                }
            }
            if(flag)
                break;
            int tmpflag = 0;
            for(int i = 1; i <= cnt; i++)
            {
                if(v[i] + tmp[i] > k)
                {
                    tmpflag = 1;
                    break;
                }
            }
            if(tmpflag)
            {
                dividers++;
                for(int i = 1; i <= cnt; i++)
                    v[i] = tmp[i];
            }
            else
            {
                for(int i = 1; i <= cnt; i++)
                    v[i] += tmp[i];
            }
        }
        if(flag)
            continue;
        ans = min(ans, dividers);
    }
    cout << ans << endl;
    return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

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

    int s[n][n];
    int t[m][m];

    for(int i=0; i<n; i++){
        cin >> s[i][0];
        cin >> s[i][1];
    }
    for(int i=0; i<m; i++){
        cin >> t[i][0];
        cin >> t[i][1];
    }
    for(int i=0; i<n; i++){
        int dis = 1000000000;
        int chk = 0;
        for(int j=0; j<m; j++){
            int x = abs(s[i][0]-t[j][0])+abs(s[i][1]-t[j][1]);
            if(dis > x){
                dis = x;
                chk = j+1;
            }
        }
        cout << chk << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int main(){
    long long A, B;

    cin >> A >> B;

    if( (A + B) % 2 == 0){
        cout << (A + B) /2;
    }else{
        cout << "IMPOSSIBLE";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	float a, b;
	cin >> a >> b;
	float num = b * 10;
	bool flag = true;
	for (float i=num; i < num + 10;i++) {
		if (i*0.08-a<1.0&&i*0.08-a>=0.0) {
			flag = false;
			cout << i << endl;
			break;
		}
	}
	if (flag) {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

bool solve(const vector<vector<int> >& v)
{
    for(int i=0; i<2; ++i){
        set<int> s;
        for(int j=0; j<3; ++j)
            s.insert(v[i+1][j] - v[i][j]);
        if(s.size() != 1)
            return false;
    }

    for(int j=0; j<2; ++j){
        set<int> s;
        for(int i=0; i<3; ++i)
            s.insert(v[i][j+1] - v[i][j]);
        if(s.size() != 1)
            return false;
    }

    return true;
}

int main()
{
    vector<vector<int> > v(3, vector<int>(3));
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            cin >> v[i][j];
        }
    }

    if(solve(v))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

N, K = list(map(int, stdin.readline().rstrip().split()))
A = list(map(int, stdin.readline().rstrip().split()))


A.append(N + A[0])

max_diff = 0

for i in range(K):
    max_diff = max(max_diff, A[i+1] - A[i])

print(N - max_diff)



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

int gcd(int a,int b)
{
    if(b==0)   return a;
    return gcd(b,a%b);
}


int main() {
	int k;cin>>k;
	long long int ans=0;
	for(long long int i=1;i<=k;i++)
	{
	    for(long long int j=1;j<=k;j++)
	    {
	        for(long long int l=1;l<=k;l++)
	        {
	             ans+=gcd(i,gcd(j,l));
	        }
	    }
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (t, a) = readLine()!!.split(" ").map(String::toInt)
    val hs = readLine()!!.split(" ").map(String::toInt)
    var diff = Double.MAX_VALUE
    var minIndex = n
    hs.forEachIndexed { i, h ->
        val temp = t - h * 0.006
        val d = Math.abs(a - temp)
        if (d < diff) {
            diff = d
            minIndex = i
        }
    }
    println(minIndex + 1)
}


Measured memory_bytes: 37948
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;


int main() {

    int n; cin >> n;
    int tmp;
    string s;
    string ans = "";
    vector<vector<int>> v(n,vector<int>(26,0));

    rep(i,n){
        cin >> s;
        rep(j,s.size()){
            v[i][(int)(s[j]-'a')] ++;
        }
    }


    rep(i,26){
        tmp = 100000;
        rep(j,n){
            tmp = min(tmp,v[j][i]);
            if(tmp == 0) break;
            if(j == n-1){
                rep(k,tmp){
                    ans += char('a' + i);
                }
            }
        }
    }
    cout << ans;
    return 0;
}


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

import sys
from heapq import heappush, heappop

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

X,Y,Z,K=MAP()
A=sorted(LIST(), reverse=True)
B=sorted(LIST(), reverse=True)
C=sorted(LIST(), reverse=True)


que=[]
heappush(que, (-(A[0]+B[0]+C[0]), 0, 0, 0))
S={(0,0,0)}
for i in range(K):
    ans=heappop(que)
    print(-ans[0])
    a,b,c=ans[1:]
    if a+1<X and (a+1,b,c) not in S:
        heappush(que, (-(A[a+1]+B[b]+C[c]), a+1, b, c))
        S.add((a+1,b,c))
    if b+1<Y and (a,b+1,c) not in S:
        heappush(que, (-(A[a]+B[b+1]+C[c]), a, b+1, c))
        S.add((a,b+1,c))
    if c+1<Z and (a,b,c+1) not in S:
        heappush(que, (-(A[a]+B[b]+C[c+1]), a, b, c+1))
        S.add((a,b,c+1))


Measured memory_bytes: 4976
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,d,ans = 0;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n)rep(j,d) cin >> x[i][j];
  for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
      double r = 0;
      rep(k,d) {
        r += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      r = sqrt(r);
      if(floor(r) == r) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
x = input()
a = x.count('1')
b = int(x,2)
# print (b)

ary = [None for i in range(200010)]
ary[0] = 0

def f(n):
  if ary[n] is not None:
    return ary[n]
  b = bin(n).count('1')
  r = 1 + f(n%b)
  ary[n] = r
  return ary[n]


a1 = a + 1
a0 = a - 1
for i in range(200010):
  f(i)


one = [1] * 200010
zero = [1] * 200010
for i in range(1, 200010):
    if a0 != 0:
        one[i] = one[i-1] * 2 % a0
    zero[i] = zero[i-1] * 2 % a1


ans = [0 for i in range(n)]
c1 = b%a1
if a0 != 0:
  c0 = b%a0
for i in range(n-1, -1, -1):
  if x[n-1-i] == '0':
    y = c1 + zero[i]
    # y = x %a1
    y %= a1
    print (ary[y]+1)
  else:
    if a0 != 0:
      y = c0 - one[i]
      y %= a0
      print (ary[y]+1)
    else:
      print (0)
# ans.reverse()
# for i in ans:
#   print (i)

Measured memory_bytes: 28520
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;
typedef long long int ll;

ll n,t[100010],a[100010],b[100010],q,ts;
bool r=true;
int mht(int ax,int ay,int bx,int by){
    return abs(ax-bx)+abs(ay-by);
}


int main(){
    
    scanf("%lld",&n);
    a[0]=0;
    b[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%lld %lld %lld",&t[i],&a[i],&b[i]);
        q=mht(a[i],b[i],a[i-1],b[i-1]);
        ts=(t[i]-t[i-1]);
        r=r and (ts%2==q%2 and q<=ts);
        
        //printf("%d\n",q);
    }
    cout<<(r ? "Yes":"No")<<endl;
    // and q<=ts
}

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

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> vec(h);

    for (int i = 0; i < h; i++)
    {
        cin >> vec[i];
    }

    // 出力する行と列を判定する
    vector<bool> column(h); // 列
    vector<bool> row(w);    // 行

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (vec[i][j] == '#')
            {
                column[i] = true;
                row[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        if (!column[i])
            continue;
        for (int j = 0; j < w; j++)
        {
            if (!row[j])
                continue;
            cout << vec[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << endl;}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << endl;}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));

	rep(i, n-1){
		if(a[i] == a[i+1]){
			puts("NO");
			return 0;
		}
	}

	puts("YES");
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n ;cin >> n ;
	ll h[n+2] = {0} ;
	for(int i = 0; i < (n-1) ; i++){
		int x;cin >> x ;
		h[x]++;
	}
	for(int i = 1; i <= n ; i++){
		cout << h[i] << "\n" ;
	}
 	return 0;
}

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

int main(){
  int q,lim,query,x;

  while(1){
    deque<int> l;
    cin >> q >> lim;
    if(!q && !lim)break;
    for(int i=0;i<q;i++){
      cin >> query >> x;

      if(query==0){
	l.push_back(x);
	if((int)l.size()>lim)l.pop_front();
      }
      if(query==1)l.erase(l.begin()+x-1);
      if(query==2)cout << *(l.begin()+x-1) << endl;
      if(query==3)l.erase(find(l.begin(),l.end(),x));
    }
    cout << "end" << endl;
  }
}

Measured memory_bytes: 1172
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h =sc.nextInt(), n = sc.nextInt();
		int usm=0;
		for(int i=0;i<n;i++) usm += sc.nextInt();
		if(usm>=h) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 49124
from operator import itemgetter

n, m = map(int, input().split())
p, y = [], []
for i in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_), y.append(y_)

x = [0] * n
pn = [i for i in range(1, m+1)]
idn = [''] * m

yp = list(zip(y, p, pn))
yp.sort()

for i in range(m):
    p_ = yp[i][1] - 1
    x[p_] += 1
    idn[i] = format(yp[i][1], '0>6') + format(x[p_], '0>6')

y, p, pn = zip(*yp)
yp = list(zip(y, p, pn, idn))
yp.sort(key=itemgetter(2))
for i in range(m):
    print(yp[i][3])


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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}


int maxn = (int) 1000001;
 
int spf[1000005];

 
void gr() {
    
    for(int i = 1; i <= maxn; i++) {
           spf[i] = i;
    }
    
    for(int i = 2; i <= maxn; i += 2) {
           spf[i] = 2;
    }
    
    for(int i = 3; (i * i) <= maxn; i++) {
            if(spf[i] == i) {
                  for(int j = (i * i); j <= maxn; j += i) {
                          if(spf[j] == j) {
                              spf[j] = i;
                          }
                  }
            }
    }
    
    
}
 
 
ll tot[1000005] = {0};
vector<pair<ll, ll> > curr;

void cal1(int ele) {
        while(ele != 1) {
                    int a = spf[ele];
                    tot[a]++;
                    ele /= a;
        }
}
 
void cal(int ele) {
    
    while(ele != 1) {
        
        int a = spf[ele];
        ll c = 0;
        while(spf[ele] == a) {

                 c++;
                  ele /= a;
        }
        
            curr.pb({a, c}); 
            
        
    
    }
    
    
}



void solve() {
            
         ll n;
         cin >> n;
         ll A[n + 1];
         ll g = 0;
         
         for(ll i = 1; i <= n; i++) {
                cin >> A[i];
                cal1(A[i]);
                g = __gcd(g, A[i]);
         }
         
         bool flag = true;
         
        
         
         for(ll i = 1; i <= n; i++) {
              
                    curr.clear();
                    cal(A[i]);
               
                    for(ll j = 0; j < curr.size(); j++) {
                            ll a = curr[j].first;
                            ll b = curr[j].second;
                            
                            if(tot[a] > b) {
                                    flag = false;
                            }
                    }
         }
         
         if(flag) {
                cout << "pairwise coprime" << endl;
         } else if(g == 1) {
                cout << "setwise coprime" << endl;
         } else {
                cout << "not coprime" << endl;
         }
       
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    gr();

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 23028
#define _CRT_SECURE_NO_WARNINGS

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

using namespace std;

int n, w;

int flag[101][10001];
vector<pair<int, int>> v;

int dp(int cnt, int left){
	if (flag[cnt][left] >= 0) {
		return flag[cnt][left];
	}
	int ret;
	if (cnt == n) {
		ret = 0;
	} else if (left < v[cnt].second) {
		ret = dp(cnt + 1, left);
	} else {
		ret = max(
			dp(cnt + 1, left),
			dp(cnt + 1, left - v[cnt].second) + v[cnt].first
			);;
	}
	flag[cnt][left] = ret;
	return ret;
}

int main(){

	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		int v_, w_;
		cin >> v_ >> w_;
		v.push_back(make_pair(v_, w_));
	}

	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 10001; j++) {
			flag[i][j] = -1;
		}
	} 

	cout << dp(0, w) << endl;

	return 0;
}

Measured memory_bytes: 5144
#include<iostream>
#include<array>
#include<vector>
#include<cmath>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>
using namespace std;

struct points {
	int x;
	int y;
	int h;
};

int main(void) {
	int N;
	std::cin >> N;
	vector<points> pos(N);
	for (int i = 0; i < N; i++) {
		cin >> pos[i].x >> pos[i].y >> pos[i].h;
	}
	points base = pos[0];
	for (auto h_i : pos) {
		if (h_i.h != 0) {
			base = h_i;
			break;
		}
	}

	int h = 0;
	int h_ = 0;
	bool flag = false;

	for (int x = 0; x <= 100; x++) {
		for (int y = 0; y <= 100; y++) {
			h = abs(x - base.x) + abs(y - base.y) + base.h;
			flag = true;
			for (int i = 0; i < N; i++) {
				h_ = max(h - abs(pos[i].x - x) - abs(pos[i].y - y), 0);
				if (pos[i].h != h_) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cout << x << " " << y << " " << h << endl;
				return 0;
			}
		}
	}

}

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

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> fac;

    for (long long x = 1; x * x <= m; x++) {
        if (m % x == 0) {
            fac.push_back(x);
            if (x != m/x)
                fac.push_back(m/x);
        }
    }
    
    sort(fac.begin(), fac.end(), greater<long long>());

    for (auto x : fac) {
        if (m/x >= n) {
            cout << x << endl;
            return 0;
        }
    }

    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
int arr[256];
void Sequence() {
	int n;
	cin >> n;

	cout << (n * 800 - ((n / 15) * 200)) << endl;
}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256