akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
vi fun(string & pat)
{
    ll M=pat.size();
    vi lps(M,0);
    ll len = 0;

    lps[0] = 0; 

    ll i = 1;
    while (i < M) {
        if (pat[i] == pat[len]) {
            len++;
            lps[i] = len;
            i++;
        }
        else 
        {
            if (len != 0) {
                len = lps[len - 1];

            }
            else 
            {
                lps[i] = 0;
                i++;
            }
        }
    }
    return lps;
}
ll maxe(string &s)
{
    ll n=s.size();
    ll in=0;
    ll ma=1;
    while(in<s.size())
    {
        ll low=in;
        while(low<n && s[in]==s[low])
            low++;
        ma=max(ma,low-in);
        in=low;
    }
    return ma;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    string s;
    cin>>n>>s;
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        ll k=0;
        for(ll j=0;j+i<n;j++)
        {
            if(s[j]==s[i+j])
            {
                k++;
                ans=max(ans,min(k,i));
            }
            else
                k=0;
        }
    }
    cout<<ans<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    ll N,X; cin>>N>>X;
    vector<ll> x(N);
    rep(i,N){
        cin>>x[i];
    }
    rep(i,N) {
        x[i]=abs(x[i]-X);
    }
    ll ans=x[0];
    rep(i,N){
        ans=__gcd(ans,x[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
vector<long long> divisor(long long n){//nの約数列挙
    vector<long long> res;
    for(long long i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}
int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> v = divisor(M);
    sort(v.begin(), v.end());
    long long ans = 0;
    for(int i = 0; i < v.size(); i++){
        if(M / v[i] >= N) ans = max(ans, v[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter


def solve(string):
    s, k = string.split()
    k = int(k)
    count = Counter(s)
    chars = sorted(set(s))
    for t in range(min(3, len(chars))):
        tmp = []
        i = s.index(chars[t])
        tmp.append(s[i:i + 5])
        if count[chars[t]] > 1:
            for _ in range(count[chars[t]] - 1):
                i = s.index(chars[t], i + 1)
                tmp.append(s[i:i + 5])
        g = []
        for p in tmp:
            for j in range(1, len(p) + 1):
                g.append(p[:j])
        g = sorted(set(g))
        if len(g) < k:
            k -= len(g)
            continue
        return g[k - 1]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vvl dp(n,vl(n+1,oo));
	FOR(i,0,n) dp[i][i+1] = 0;

	FOR(len,2,n+1) FOR(i,0,n) {
		ll j = i+len;
		ll sum = 0;
		FOR(k,i,j) sum += a[k];
		if (j > n) break;
		FOR(k,i+1,j) {
			dp[i][j] = min(dp[i][j], sum + dp[i][k] + dp[k][j]);
		}
	}
	cout << dp[0][n] << endl;
}



Measured memory_bytes: 1536
X,K,D=map(int,input().split())

X=abs(X)
idou=K*D
if(0<X):
    if(K*D<X):
        print(X-K*D)
        exit()

    a=abs(X//D)
    b=abs(X//D)+1
    kyori_a=X-a*D
    kyori_b=X-b*D

    if(K-a==0):
        print(abs(kyori_a))
        exit()
    if((K-a)%2==0):
        print(abs(kyori_a))
        exit()
    else:
        print(abs(kyori_b))
        exit()

elif(X==0):
    if(K%2==0):
        print(0)
        exit()
    else:
        print(D)
        exit()


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

typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll>> arr;
    for(int i=0;i<n;i++)
    {
        ll x;cin>> x;
        arr.push_back({x,i});
        
    }
    sort(arr.begin(),arr.end(),greater<pair<ll,ll>>());
    
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,INT_MIN));
    
    dp[0][0]=0;
    for( ll i=0;i<n;i++)
    {
        ll curr  = arr[i].first;
        ll idx  = arr[i].second;
        
        for(ll j=0;j<=i;j++)
        {
            if(dp[i][j]!=INT_MIN)
        {        dp[i+1][j+1] = max(dp[i+1][j+1],curr*abs(idx-j) + dp[i][j]);
                dp[i+1][j] =  max(dp[i+1][j], abs (n-1-(i-j)-idx)*curr+ dp[i][j]);
        
        }
        }
        
    }
ll ans =-1;
for(int i=0;i<=n;i++)
ans= max(ans,dp[n][i]);

cout<< ans<<endl;
}

Measured memory_bytes: 34644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  string N;
  cin >> N;
  int n = N[N.size()-1]-'0';
  string ans;
  if(2 == n || 4 == n || 5 == n || 7 == n || 9 == n){
    ans = "hon";
  }else if(0 == n || 1 == n || 6 == n || 8 == n){
    ans = "pon";
  }else{
    ans = "bon";
  }
  cout << ans << endl;
}


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

int main()
{
    string a;
    cin >>  a;
    if('A' <= a[0] && a[0] <= 'Z'){
        cout << 'A' << endl;
        return 0;
    }else{
        cout << 'a' << endl;
        return 0;
    }
}

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int a,b,s,s1,s2,mn;
	scanf("%d%d",&a,&b);
	s=a+b;
	s1=a-b;
	s2=a*b;
	if(s>=s1 && s>=s2)
	{
		printf("%d",s);
	}
	else if(s1>=s && s1>=s2)
	{
		printf("%d",s1);	
	}
	else
	{
	printf("%d",s2);
	}
	

	
}
	

Measured memory_bytes: 1712
import sys
input = sys.stdin.readline
n = int(input())
a = []
xy = []
ans = 0
def hantei(i):
    global bi
    for j in range(a[i]):
        if int(bi[xy[i][j][0]]) != int(xy[i][j][1]):
            return False
    return True
    
for i in range(n):
    s = int(input())
    a.append(s)
    slist = []
    for i in range(s):
        x,y = map(int,input().split())
        x -= 1
        slist.append([x,y])
    xy.append(slist)

for i in range(2**n):
    bi = bin(i)[2:].zfill(n)
    
    for j in range(n):
        if bi[j] == "1":
            if hantei(j) == False:
                break
    else:
        #print(i,sum([int(a)for a in bi]))
        ans = max(ans, sum([int(a)for a in bi]))
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int H[101];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> N) {
    if (N == 0) break;
    N++;
    rep(i, N) cin >> H[i];
    int w = -1;
    rep(i, N) {
      vector<int> xs;
      rep(j, i) xs.pb(H[j]);
      for (int j=i+1; j<N; j++) xs.pb(H[j]);
      int diff = xs[1] - xs[0];
      bool f = true;
      rep(i, (int)xs.size()-1) {
        if (diff != xs[i+1] - xs[i]) f = false;
      }
      if (f) {
        w = H[i];
        break;
      }
    }
    cout << w << "\n";
  }
  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i=0; i<h; i++) {
    cin >> grid.at(i);
  }
  
  vector<bool> usableRow(h, true);
  vector<bool> usableCol(w, true);
  
  for (int i=0; i<h; i++) {
    bool usable = false;
    for (int j=0; j<w; j++) {
      if (grid.at(i).at(j) == '#') {
        usable = true;
      }
    }
    if (!usable) {
      usableRow.at(i) = false;
    }
  }
  for (int i=0; i<w; i++) {
    bool usable = false;
    for (int j=0; j<h; j++) {
      if (grid.at(j).at(i) == '#') {
        usable = true;
      }
    }
    if (!usable) {
      usableCol.at(i) = false;
    }
  }
  
  for (int i=0; i<h; i++) {
    if (usableRow.at(i)) {
      for (int j=0; j<w; j++) {
        if (usableCol.at(j)) {
          cout << grid.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  
  
  return 0;
        
}


Measured memory_bytes: 256
/*  ex3_4
    hangan2020 */

#include <stdio.h>
int main(void){
    int number, divider;
    scanf("%d", &number);
 
    //Devide the input number by 1,2,3..,10
    for (divider = 1; divider <= 10; ++divider){
    /*printf("%d\n", divider);*/
        //If there exist a number in 1,2,3..,10 that is divisble and the quotient is smaller than 10, print Yes
        if ((number % divider == 0) && (number / divider < 10) && (divider < 10)){
            printf("Yes\n");
            break;
        }
        //If there exist no number that satisfy the upper condition, print No
        else if(divider >= 10) {
                printf("No\n");
        }
        else{}
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
 
int main(){
   int n;
   std::string s;
   std::cin >> n >> s;
   
   size_t wc = std::count(s.begin(),s.end(),'.');
   size_t bc = s.size() - wc;
   
   size_t lbc = 0;
   size_t rwc = wc;
   size_t ret = std::min(wc,bc);
   for(size_t i = 0;i<s.size();++i){
      if (s[i] == '.'){
         rwc--;
      }
      if(i > 0 && s[i -1] != s[i]){
         ret = std::min(ret,lbc + rwc);
      }
      if (s[i] == '#'){
         lbc++;
      }
   }
   std::cout << ret << std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (auto &&i : v) scanf("%d", &i);
    vector<int> u = {-1,2,5,5,4,5,6,3,7,6};
    vector<pair<int, int>> w;
    for (int i = 0; i < m; ++i) {
        w.emplace_back(u[v[i]], -v[i]);
    }
    sort(w.begin(), w.end());
    for (int i = 0; i < m; ++i) {
        w[i].second = -w[i].second;
    }
    vector<pair<int, int>> dp(10001);
    dp[0] = make_pair(1, 0);
    for (int i = 0; i <= 10000; ++i) {
        for (int j = 0; j < m; ++j) {
            if(i-w[j].first >= 0){
                dp[i] = max(dp[i],
                        make_pair(dp[i-w[j].first].first+1, w[j].second));
            }
        }
    }
    string ans;
    while(n > 0){
        ans += (dp[n].second + '0');
        n -= u[dp[n].second];
    }
    sort(ans.begin(), ans.end(), greater<>());
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;int f,Q,T,F;char S[1<<20],*x,*y;main(){for(x=S+(1<<18),cin>>x>>Q,y=strlen(x)+x;Q--&&cin>>T;)if(T&1)f^=1;else cin>>F,cin>>*(F-1^f?y++:--x);if(f)reverse(x,y);cout<<x;}

Measured memory_bytes: 896
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll a,p;
  cin>>a>>p;
  cout << (a*3+p)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)3e5 + 77;
int cnt[MAXN], n;

void solve() {
	cin >> n;

	for(int i = 0; i < n; ++i) {
		int v = fetch<int>();
		++cnt[v];
	}

	multiset<int> setik;
	int sum = 0;
	int m = 0;

	for(int i = 0; i < MAXN; ++i) {
		if(cnt[i]) {
			setik.insert(cnt[i]);
			sum += cnt[i];
			++m;
		}
	}

	for(int k = 1; k <= n; ++k) {
		while(!setik.empty()) {
			auto iter = prev(setik.end());
			int val = *iter; setik.erase(iter);
			int bound = (k == 1 ? INT_INF : (sum - val) / (k - 1));

			if(val <= bound) {
				setik.insert(val);
				break;
			} else {
				sum -= val;
				sum += bound;

				if(bound) {
					setik.insert(bound);
				}
			}
		}

		cout << sum / k << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 15488
num,yen = map(int,raw_input().split())

ans = [-1,-1,-1]
isanswered = False

if 10000*num >= yen: 
	for i in range(num+1):
		for j in range(num+1-i):
			if 10000*i + 5000*j + 1000*(num-i-j) == yen and num-i-j-(num-i-j) == 0:
				ans[0] = i
				ans[1] = j
				ans[2] = (num-i-j)
				isanswered = True
				break

		if isanswered == True :
			break

print '%d %d %d' %(ans[0],ans[1],ans[2])


Measured memory_bytes: 2692
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    N, W = getList()
    MI = 100
    MJ = 300
    sina = []
    w, v = getList()
    w1 = w
    v1 = v
    # sina.append((w ,v))
    for i in range(N-1):
        w, v = getList()
        sina.append((w - w1, v))

    dp = [-1 for i in range(MI*MJ+MI+MJ)]
    dp[0] = 0
    dp[MJ] = v1
    for w, v in sina:
        # print(w,v)
        nxt = [-1 for i in range(MI*MJ+MI+MJ)]
        for i in range(MI):
            for j in range(MJ):
                cur = dp[i*MJ + j]
                if cur != -1:
                    if nxt[i * MJ + j] < cur:
                        nxt[i * MJ + j] = cur
                    # print(cur)
                    # print(nxt[(i+1) * MJ + j + w])
                    if nxt[(i+1) * MJ + j + w] < cur + v:
                        nxt[(i + 1) * MJ + j + w] = cur + v
                        # print("update")

        dp = nxt
        # for i in range(MI):
        #     print(dp[i * MJ:i * MJ + MJ - 1])

    ans = 0
    for i in range(MI):
        for j in range(MJ):
            # print(i, j, dp[i * MJ + j])
            if w1 * i + j <= W:

                if dp[i*MJ + j] > ans:
                    # print(dp[i+MJ + j])
                    ans = dp[i * MJ + j]

    print(ans)






def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


Measured memory_bytes: 95788
#include<iostream>
using namespace std;
int main()
{
  int num;
  cin>>num;
  int rev=0;
  int sum=0,rem=0;
  while(num!=0){
 	 rem=num%10;
    num=num/10;
    if(rem==9){
    sum=sum*10+1;
    }
    else{
    sum=sum*10+9;
    }
  }
  while(sum!=0)
  {
    
    rev=(rev*10)+(sum%10);
  	sum=sum/10;
  }
  cout<<rev;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,m;
    cin >> n >> m;
    string a[n],b[m];
    rep(i, n)cin >> a[i];
    rep(i, m)cin >> b[i];
    rep(i, n - m + 1){
        rep(j, n - m + 1){
            rep(k, m){
                rep(t, m){
                    if (a[i + k][j + t] != b[k][t]) {
                        goto loopend;
                    }
                }
            }
            Yes;
            return 0;
        loopend:;
        }
    }
    No;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll N,M,cnt=0;
  cin>>N>>M;
  ll H[N];
  vector<vector<ll>> ans(N+5);
  for(int i=0;i<N;i++) cin>>H[i];
  for(int i=0;i<M;i++){
    ll a,b;
    cin>>a>>b;
    ans[a].push_back(H[b-1]);
    ans[b].push_back(H[a-1]);
  }
  for(ll i=1;i<=N;i++){
    bool f=true;
    if(ans[i].size()==0){
      cnt++;
      continue;
    }
    for(ll j=0;j<ans[i].size();j++){
      if(H[i-1]<=ans[i][j]) f=false;
    }
    if(f) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 9860
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	int n=s.size();
	rep(i,0,n){
		if(s[i]=='1')s[i]='9';
		else s[i]='1';
	}
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 3612
N = int(input())
A = list(map(int,input().split()))
s = [0]
for i in range(N):
    s.append(s[i] + A[i])
ans = 0
for i in range(N):
    ans += A[i] * (s[N] - s[i + 1])
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 31472
import math
atcoder = [int(input()) for i in range(6)]
loc = [atcoder[0],0,0,0,0,0]

ans = 0

num = 1000000000000000000000
for i in range(1,6):
    if atcoder[i] < num:
        num = atcoder[i]

ans2 = atcoder[0] / num
if atcoder[0] == num:
    print(5)
else:
    print(math.ceil(ans2)-1+5)

Measured memory_bytes: 3064
#include "stdio.h"
int main()
{
	int a, b, d, r;
	double f;

	while (1)
	{
		scanf("%d %d", &a, &b);
		if (a > 1000000000 || a < 1 || b > 1000000000 || b < 1)
			continue;
		break;
	}
		
	d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	printf("%d %d %f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 636
n=int(input())
x=list(map(int,input().split()))
x.sort()
x1=min(x)
x2=max(x)+1
ans=[]
for i in range(x1,x2):
    a=0
    for j in x:
        a+=(j-i)**2
    ans.append(a)
print(min(ans))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
    double a,b;
    cin >> a >>b ;
    cout << a/b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    bool use[26] = {};
    REP(i,n){
        use[s[i] - 'a'] = true;
    }
    REP(i,26){
        if(!use[i]){
            cout << s << char('a' + i) << endl;
            return 0;
        }
    }
    REP(i,26){
        use[i] = false;
    }
    char pre = s[n - 1];
    use[pre - 'a'] = true;
    for(int i = n - 2; i >= 0; i--){
        char c = s[i];
        if(c < pre){
            REP(j,26){
                char d = 'a' + j;
                if(d < c) continue;
                if(use[j]){
                    cout << s.substr(0, i) << d << endl;
                    return 0;
                }
            }
        }
        pre = c;
        use[c - 'a'] = true;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#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;
int now = 0;
int deco[1000];

void Sequence() {
	ll a, b, x;
	cin >> a >> b >> x;
	ll count = b / x;
	ll su = max(0ll, (a - 1)) / x;
	su -= (a == 0);
	cout << (count - su) << endl;
	
}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int d1,d2,d3,d4,d5,d6;
cin>>d1>>d2>>d3>>d4>>d5>>d6;
int m1=d1,m2=d2,m3=d3,m4=d4,m5=d5,m6=d6;
char x;
while(1)
{
m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
//
if(cin>>x) 1; else break;
if(x=='N')
	{m1=d2;m2=d6;m6=d5;m5=d1;
	}
if(x=='S')
	{m1=d5;m5=d6;m6=d2;m2=d1;
	}
if(x=='W')
	{m3=d6;m6=d4;m4=d1;m1=d3;
	}
if(x=='E')
	{m6=d3;m3=d1;m1=d4;m4=d6;
	}
d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
}
cout<<d1<<endl;
return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
struct ZFunc{
    vector<int> z;
    ZFunc(const vector<int> & v): z(v.size()){
        int n = v.size(), a = 0, b = 0;
        if(!z.empty()) z[0] = n;
        for(int i = 1; i < n; ++i) {
            int end = i; if(i < b) end = min(i + z[i-a], b);
            while(end < n && v[end] == v[end-i]) ++end;
            z[i] = end - i; if(end > b) a = i, b = end;
        }
    }
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	auto on = create<int>(30, n);
	for(int i = 29; i >= 0; i--){
		vector<int> ca(2 * n), b0(n), b1(n), m0;
		for(int j = 0; j < 2 * n; j++) ca[j] = (a[j % n]>>i)&1;
		for(int j = 0; j < n; j++) b0[j] = (b[j]>>i)&1;
		for(int j = 0; j < n; j++) b1[j] = b0[j] ^ 1;
		{
			m0 = b0; for(int v : ca) m0.push_back(v);
			ZFunc z(m0);
			for(int j = n; j < n + n; j++){
				if(z.z[j] >= n){
					on[i][j - n] = 1;
				}
			}
		}
		{
			m0 = b1; for(int v : ca) m0.push_back(v);
			ZFunc z(m0);
			for(int j = n; j < n + n; j++){
				if(z.z[j] >= n){
					on[i][j - n] = 2;
				}
			}
		}
	}
	for(int i = 0; i < n; i++){
		bool bad = false;
		for(int j = 29; j >= 0; j--){
			if(on[j][i] == 0) bad = true;
		}
		if(!bad){
			cout << i << ' ' << (a[i] ^ b[0]) << '\n';
		}
	}
	return 0;
}


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

int main() {
	int x,y;
	int ans;

 	cin >> x >> y;

	if (x>0) {
		if (y>0) {
        	if(x>y) ans=x-y+2;
             else ans=y-x;
	    }else if(y<0){
        	if(x>-y) ans=x+y+1;
             else ans=-y-x+1;
	    }else{
         	ans=x+1;
	    }
    }else if(x<0){
		if (y>0) {
        	if(-x>y) ans=-x-y+1;
             else ans=x+y+1;
	    }else if(y<0){
        	if(-x>-y) ans=-x+y;
             else ans=x-y+2;
	    }else{
         	ans=-x;
		}
    }else{
		if (y>0) {
         	ans=y;
	    }else if(y<0){
         	ans=-y+1;          
	    }else{
         	ans=y;
        }
    }
  
   
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, K; cin >> N >> K;
  vector<set<int>> s;
  for (int i = 0; i < N; ++i) {
    int A; cin >> A;
    if (i == 0) {
      s.push_back({A});
      continue;
    }

    bool found = false;
    int k = s.size();
    for (int x : s[k-1]) {
      if (abs(A-x) <= K) {
        found = true;
        break;
      }
    }
    if (found) {
      s.push_back({A});
      continue;
    }

    --k;
    for (; k > 0; --k) {
      for (int x : s[k-1]) {
        if (abs(A-x) <= K) {
          found = true;
          break;
        }
      }
      if (found)
        break;
    }
    s[k].insert(A);
  }

#if 0
  for (auto v : s) {
    for (int x : v) cout << x << " ";
    cout << endl;
  }
#endif

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


Measured memory_bytes: 41688
#include <stdio.h>
#include <string.h>
 
int main (){
	int n;
	char str[100005];

	scanf("%d", &n);
	scanf("%s", str);
	
	int len = strlen(str);
	
	for (int i=0; i<len; i++){
		if (str[i] + n > 'Z'){
			str[i] -= 26- n;
		}
		else{
			str[i] += n;
		}
	}
	
	printf("%s", str);
	return 0;
}

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

int main(){
	ll H, N;
	cin >> H >> N;
	ll sum = 0;
	for(int i=0;i<N;i++) {
		ll a;
		cin >> a;
		sum += a;
	}
	if(sum >= H) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define eb emplace_back
#define pb push_back
#define mk make_pair
#define mt make_tuple

#define Umap unordered_map
#define graph vector<vector<int>>

#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl

#define INF 1e9+5
#define N 40001
#define MAXN   100001
#define mod   2019


class Solution{
	public:
    bool sortbysec(const tuple<int, int, int>& a,const tuple<int, int, int>& b){
        return (get<1>(a) < get<1>(b)); 
    }
    int spf[0];
    void sieve(){
	    spf[1] = 1;
	    for(int i=2;i<MAXN;i++) spf[i] = i;

	    for(int i=4;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;
			    }
		    }
	    }
    }
    vector<int> getFactorization(int x){
        vector<int> primeFactors;
        while(x>1){
            primeFactors.pb(spf[x]);
            x /= spf[x];
        }
        return primeFactors;
    }
	void solve(){
       string s; cin>>s;
       int n = s.length();


       int suf = 0;
       int power_ten = 1;
       long long ans = 0;
       Umap<int,int>cnt_suf;
       cnt_suf[0]++;
       for(int j=n-1;j>=0;j--){
           int digit = s[j] - '0';

           suf = (suf+digit*power_ten)%mod;
           power_ten = (power_ten*10)%mod;

           ans+=cnt_suf[suf];
           cnt_suf[suf]++;
       }
       cout<<ans<<endl;
    }
    
};
int main(){
IOS;
	Solution ob;
	int t=1;
	// cin>>t;
   
	while(t--) ob.solve();
	return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,a=0;
	string an = "YES";
	cin >> N;
	vector<ll> A(N);
	
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		if (A.at(i) % 2 != 0) {
			a++;
		}
	}
	if (a % 2 != 0) {
		an = "NO";
	}
	cout << an << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long k;

	std::cin >> k;

	std::vector<long long> v(k);

	for (long long i = 0; i < k; i++)
	{
		std::cin >> v[i];
	}

	long long maxN = 2, minN = 2;

	for (long long i = k - 1; i >= 0; i--)
	{
			if (maxN < v[i]) {
				maxN = v[i];
			}
			else {
				maxN += v[i] - (maxN % v[i]) - 1;
			}

		if (minN < v[i] || minN % v[i] != 0) {
			if (minN < v[i]) {
				minN = v[i];
			}
			else {
				minN += v[i] - (minN % v[i]);
			}
		}

		//std::cout << (k) - i << "回目 " << minN << " " << maxN << std::endl;

	}

	long long temp1 = maxN, temp2 = minN;
	for (long long i = 0; i < k; i++)
	{
		temp1 -= temp1 % v[i];
		temp2 -= temp2 % v[i];
	}

	if (temp1 != 2 || temp2 != 2) {
		std::cout << -1 << std::endl;
		return 0;
	}

	std::cout << minN << " " << maxN << std::endl;

	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	static Map<Integer, List<Integer>> map1 = new HashMap<>();
	static Map<Integer, List<Integer>> map2 = new HashMap<>();

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]);
			int y = Integer.parseInt(sa[1]);
			List<Integer> list1 = map1.get(x);
			if (list1 == null) {
				list1 = new ArrayList<>();
				map1.put(x, list1);
			}
			list1.add(y);
			List<Integer> list2 = map2.get(y);
			if (list2 == null) {
				list2 = new ArrayList<>();
				map2.put(y, list2);
			}
			list2.add(x);
		}
		br.close();

		long ans = 0;
		while (!map1.isEmpty()) {
			ans += dfs(map1.keySet().iterator().next(), new HashSet<>(), 0, new HashSet<>());
		}
		System.out.println(ans - n);
	}

	static long dfs(int x, Set<Integer> set1, int y, Set<Integer> set2) {
		if (x > 0) {
			List<Integer> list = map1.get(x);
			if (list != null) {
				map1.remove(x);
				for (Integer next : list) {
					if (set2.add(next)) {
						dfs(0, set1, next, set2);
					}
				}
			}
		} else {
			List<Integer> list = map2.get(y);
			if (list != null) {
				map2.remove(y);
				for (Integer next : list) {
					if (set1.add(next)) {
						dfs(next, set1, 0, set2);
					}
				}
			}
		}
		return (long) set1.size() * set2.size();
	}
}


Measured memory_bytes: 96344
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
lint arr[100];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	vector<lint> ans;
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
	}
	REP(_, N) {
		lint idx = 0, max_idx = -1;
		REP(i, N) {
			if (arr[i] == -1) continue;
			if (arr[i] == idx + 1) max_idx = i;
			idx++;
		}
		if (max_idx == -1) {
			cout << -1 << endl;
			return 0;
		}
		else {
			ans.push_back(arr[max_idx]);
			arr[max_idx] = -1;
		}
	}
	reverse(ans.begin(), ans.end());
	REP(i, N) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 256
def sum_digits(n):
    total = 0
    while n > 0:
        total += n % 10
        n //= 10
    return total


def main():
    n, a, b = map(int, open(0).read().split())
    res = 0
    for i in range(1, n+1):
        total = sum_digits(i)
        if a <= total and total <= b:
            res += i
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import itertools
n=int(input())
f=[tuple(map(int,input().split())) for _ in range(n)]
p=[tuple(map(int,input().split())) for _ in range(n)]
ll=list(itertools.product(range(2),repeat=10))[1:]
ans=-10**10
for l in ll:
    t=0
    for i in range(n):
        c=0
        for j in range(10):
            if l[j]==1:
                if f[i][j]==l[j]:
                    c+=1
        t+=p[i][c]
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  int n;cin>>n;
  ivec a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sort(all(a));
  if(2*a[n-1]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3620
N, M = map(int, input().split())
A = list(map(int, input().split()))
vote = sum(A)
cnt = 0

for i in range(N):
  if A[i] >= vote / 4 / M:
    cnt += 1
  else:
    continue
 
if cnt >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <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);
}
int main()
{
    ll N;
    cin >> N;
    vint A(N + 1);
    for (size_t i = 0; i < N - 1; i++)
    {
        int j;
        cin >> j;
        A[j]++;
    }
    for (int i = 1; i <= N; i++)
    {
        cout << A[i] << endl;
    }

    return 0;
}

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

int main(){
  vector<int> N(3);
  for(int i = 0; i < 3; i++){
    cin >> N.at(i);
  }
  sort(N.begin(), N.end());
  if(N.at(0) == 5 && N.at(1) == 5 && N.at(2) == 7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let x1: i32 = iter.next().unwrap().parse().unwrap();
    let y1: i32 = iter.next().unwrap().parse().unwrap();
    let x2: i32 = iter.next().unwrap().parse().unwrap();
    let y2: i32 = iter.next().unwrap().parse().unwrap();
    let dx = x2 - x1;
    let dy = y2 - y1;
    let dx2 = -dy;
    let dy2 = dx;
    let x3 = x2 + dx2;
    let y3 = y2 + dy2;
    let x4 = x1 + dx2;
    let y4 = y1 + dy2;
    println!("{} {} {} {}", x3, y3, x4, y4);
}



Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
  int k;
  scanf("%d",&k);
  int a[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  printf("%d",a[k-1]);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;
int x, y, z, l, m, n, r, q, k;
//0 1 2 3 4 5 6 n = 7;
void solve() {
    cin>>n>>k;
    int a[100000];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int md = INT_MAX;
    sort(a, a+n);
    for(int i=0;i<=n-k;i++){
        md = min(md, a[i+k-1]-a[i]);
    }
    cout<<md<<'\n';
}

int main() 
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test;
    test = 1;
    while (test--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    auto a = vec<int>(3, 3); cin >> a;
    int n; cin >> n;
    VI b(n); cin >> b;
    FOR(i, 0, n)FOR(y, 0, 3)FOR(x, 0, 3) {
        if (a[y][x] == b[i])a[y][x] = -1;
    }

    bool ok = false;
    FOR(i, 0, 3)ok |= *max_element(all(a[i])) <= -1;
    FOR(i, 0, 3)ok |= max({ a[0][i],a[1][i],a[2][i] }) <= -1;
    ok |= max({ a[0][0],a[1][1],a[2][2] }) <= -1;
    ok |= max({ a[0][2],a[1][1],a[2][0] }) <= -1;
    cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
N, W = gets.split(' ').map(&:to_i)

vi = Array.new(101)
wi = Array.new(101)

dp = Array.new(101).map{Array.new(10010)}


N.times do |i|
	vi[i], wi[i] = gets.split(' ').map(&:to_i)
end

(W+1).times do |i|
	dp[0][i] = 0
end



for i in 0...N
	for w in 0..W
		if w >= wi[i]
			dp[i+1][w] = [dp[i][w-wi[i]]+vi[i], dp[i][w]].max
		else
			dp[i+1][w] = dp[i][w]
		end
	end
end


#for i in 0..N
#	for w in 0..W
#		print(dp[i][w].to_s+" ")
#	end
#	print("\n")
#end

print(dp[N][W].to_s+"\n")


Measured memory_bytes: 16768
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

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

    vector <double> a(N);
    REP(i,N)
    {
        double tmp;
        cin >> tmp;
        a[i] = 1/tmp;
    }

    double res = 0;

    REP(i,N)
    {
        res += a[i];
    }

    res = 1 / res; 

    printf("%.14f\n",res);

    return 0;
}

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

// repr(i,10,13) -> 10,11,12
#define repr(i,a,b) for(int i=a;i<b;i++)
// rep(i,3) -> 0,1,2
#define rep(i,n) for(int i=0;i<n;i++)
// reprrev(i,10,13) -> 12,11,10
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
// reprev(i,3) -> 2,1,0
#define reprev(i,n) reprrev(i,0,n)

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int inf = 1 << 29;
typedef tuple<int, int> T;

int main() {
    ios::sync_with_stdio(false);
    int y, x; cin >> y >> x;
    vector<vector<char>> c = vector<vector<char>>(y+1, vector<char>(x+1));

    int blank = x * y;
    repr(i, 1, y+1) {
        repr(j, 1, x+1) {
            cin >> c[i][j];
            if (c[i][j] == '#') {
                blank--;
            }
        }
    }
    queue<T> q;
    vector<vector<int>> s = vector<vector<int>>(y+1, vector<int>(x+1, inf));
    s[1][1] = 1;

    int min;
    q.push(T(1,1));
    while(!q.empty()) {
        T data = q.front();q.pop();
        int cy = get<0>(data);
        int cx = get<1>(data);
        if (cy == y && cx == x) {
            min = s[cy][cx];
            break;
        }
        rep(i, 4) {
            int cyd = cy + dy[i];
            int cxd = cx + dx[i];
            if (1<=cyd && cyd<=y && 1<=cxd && cxd<=x && c[cyd][cxd]!='#' && s[cy][cx] + 1 < s[cyd][cxd]) {
                q.push(T(cyd, cxd));
                s[cyd][cxd] = s[cy][cx] + 1;
            }
        }
    }
    if (s[y][x] != inf) {
        cout << blank - min << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

int main() {
    int n;
    double t, a;
    cin >> n >> t >> a;
    double h[n];

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

    double min=2000000.0;
    double temp, diff;
    int ans = 0;

    for(int i=0; i<n;i ++){
        temp = t-h[i]*0.006;
        diff = abs(a-temp);
        if(min>diff){
            ans = i+1;
            min = diff;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256