akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{

	int X, ans = 1, p, n;

	cin >> X;
	repc(b, 2, X) {
		n = b;
		repc(p, 2, X) {
			n *= b;
			if (n > X) break;
			else ans = max(ans, n);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static int amt;

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0520-input.txt"));

		while (scan.hasNext()) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			System.out.println(change(n));
		}

		scan.close();
		System.exit(0);
	}

	private static int change(int n) {
		int c = 0;
		amt = 1000 - n;
		c += chg(500);
		c += chg(100);
		c += chg(50);
		c += chg(10);
		c += chg(5);
		c += chg(1);

		return c;
	}

	private static int chg(int c) {
		int p = amt / c;
		amt %= c;
		return p;
	}

}

Measured memory_bytes: 26316
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M;
	cin >> N >> M;
	VLL P(M);
	vector<string> S(M);
	for (LL m = 0; m < M; m++) {
		cin >> P[m] >> S[m];
	}
	vector<bool> check(N + 1, false);
	LL AC = 0;
	for (LL m = 0; m < M; m++) {
		if (S[m] == string("AC")) {
			if (check[P[m]])continue;
			check[P[m]] = true;
			AC++;
		}
	}
	LL WA = 0;
	vector<bool> accheck(N + 1, false);
	for (LL m = 0; m < M; m++) {
		if (check[P[m]]) {
			if (S[m] == string("AC")) {
				accheck[P[m]] = true;
			}
			else {
				if (!accheck[P[m]])WA++;
			}
		}
	}
	cout << AC << " " << WA << "\n";
}

Measured memory_bytes: 6528
# from sys import exit
while(True):
    M, Nmin, Nmax = [int(n) for n in input().split()]
    if M + Nmin + Nmax == 0:
        break
    # N = int(input())
    P = [int(input()) for _ in range(M)]
    # S = str(input())
    # L = len(S)
    # T = str(input())
    # exit()
    dif = [0]*(M)
    for i in range(len(P)-1):
        dif[i+1] = P[i] - P[i+1]
    # print(dif)
    ans = Nmin
    tmp = dif[Nmin]
    for i in range(Nmin+1, Nmax+1):
        if dif[i] >= tmp:
            ans = i
            tmp = dif[i]
    print(ans)



Measured memory_bytes: 5624
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    map<string, long long> m;
    string s;
    long long ans = 0;
    while(t--) {
        cin >> s;
        sort(s.begin(), s.end());
        ++m[s];
    }
    for (auto p : m) {
        ans += p.second*(p.second-1)/2;
    }
    cout << ans << '\n';
    return 0;
}



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

#define LINE_BUF_SIZE 1024

int main(){

    int i,j,k;
    long long int N,A,B;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%lld %lld %lld", &N,&A,&B);

    long long int *X = (long long int *)malloc((sizeof(long long int)*N));
    int v;
    long long int count = 0;

    scanf("%lld",&X[0]);

    for(i=1;i<N;i++){
        scanf("%lld",&X[i]);
        v = X[i]-X[i-1];
        if( v * A < B )count += v * A;
        else count += B;
    }

    printf("%lld",count);

    return 0;

}

Measured memory_bytes: 896
const main = input => {
  const [[S], [T]] = input

  if (S.length !== T.length - 1) return [['No']]

  if (T.slice(0, -1) !== S) return [['No']]

  return [['Yes']]
}

const wrapper = data => {
  const input = data.split('\n').map(line => line.split(' '))
  const output = main(input)
  console.log(output.map(line => line.join(' ')).join('\n'))
}

wrapper(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29636
n,k=map(int, input().split())
*a,=map(int, input().split())

from collections import deque
d=deque([])
zeros=0
for i in range(k):
    if a[i]==0:
        zeros+=1
    d.append(a[i])

for i in range(k, n):
    tmp=d.popleft()
    if tmp==0:
        zeros-=1
    if zeros==0 and a[i]>tmp:
        print('Yes')
    else:
        print('No')
    d.append(a[i])
    if a[i]==0:
        zeros+=1
        

Measured memory_bytes: 99880
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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; }

int main(){
  ll n,a,b; cin >> n >> a >> b;
  if((b-a)%2==0) cout << (b-a)/2;
  else{
    ll ans = min(max(a-1,b-1),max(n-a,n-b));
    if(a-1 < n-b){
      b -= a;
      chmin(ans,(b-1)/2+a);
    }else{
      a += n-b+1;
      chmin(ans,(n-a)/2+n-b+1);
    }
    cout << ans;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
N = int(input())

ans = False
M = 0
if N <= 81:
    if N % 9 == 0:
        M = N / 9
    elif N % 8 == 0:
        M = N / 8
    elif N % 7 == 0:
        M = N / 7 
    elif N % 6 == 0:
        M = N / 6
    elif N % 5 == 0:
        M = N / 5
    elif N % 4 == 0:
        M = N / 4
    elif N % 3 == 0:
        M = N / 3
    elif N % 2 == 0:
        M = N / 2
    else:
        M = N

    if M <= 9:
        ans = True

if ans == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;

vector<pair<ll,int>> func(ll x){
    vector<pair<ll,int>> v;
    for(ll i=2;i*i<=x;i++){
        if(x%i==0){
            v.push_back(make_pair(i,1));
            x/=i;
        }
        while(x%i==0){
            x/=i;
            v.back().second++;
        }
    }
    if(x!=1) v.push_back(make_pair(x,1));
    return v;
}

int main(){
    ll n,p;
    scanf("%lld %lld",&n,&p);
    auto v=func(p);
    ll ans=1;
    for(auto k:v){
        ans*=pow(k.first,k.second/n);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4132
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

N,K = na()
que = na()
revque = que[::-1]

ans = 0
for a in range(min(N,K)+1):
    for b in range(min(K-a,N-a)+1):
        sum_q = que[:a] + revque[:b] if b>0 else que[:a]
        r = sum(sum_q)
        sum_q.sort()
        l = 0
        #print(sum_q)
        if sum_q:
            for i in range(min(K-(a+b),len(sum_q))):
                #print(i)
                if sum_q[i]>0:
                    l = i
                    break
                else:
                    r-=sum_q[i]
        if ans < r:
            ans = r
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const int inf = 1 << 28;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

int N;

int solve(vector<vector<int> >& t){
    vector<int> dp(1<<N, inf); dp[0] = 0;
    rep(S, 1<<N){
        rep(i, N)if(!(S >> i & 1)){
            int mincost = t[i][0];
            rep(j, N)if(S >> j & 1)chmin(mincost, t[i][j+1]);
            chmin(dp[S|1<<i], dp[S] + mincost);
        }
    }
    return dp[(1<<N)-1];
}

int main(){
    while(cin >> N, N){
        vector<vector<int> > t(N, vector<int>(N+1));
        rep(i, N)rep(j, N+1)cin >> t[i][j];
        cout << solve(t) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1476
import sys
sys.setrecursionlimit(10**7)

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def cumsum(x):
    y = []
    current = 0
    for i in x:
        y.append(current + i)
        current += i
    return y

def solve():
    n = int(input())
    lw = list(map(int, input().split()))

    cumw = cumsum(lw)
    s = cumw[-1]
    dprint(lw, cumw)
    mn = -1
    for left in cumw[:-1]:
        diff = abs(left - (s-left))
        dprint(s, s - left, mn, diff)
        if mn == -1 or mn > diff:
            mn = diff

    print(mn)

solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
    int n,t;
    cin >> n >> t;
    vector<pair<int,int>> ct;
    rep(i,n){
        int c,t;
        cin >> c >> t;
        ct.emplace_back(c,t);
    }
    int ans=10000;
    rep(i,n){
        if(ct[i].second <= t){
            ans = min(ans,ct[i].first);
        }
    }
    if(ans==10000){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int H, N, A, sum = 0;
	scanf("%d%d",&H,&N);
	for (int i = 0; i < N; i++) {
   		scanf("%d",&A);
      	sum += A;
    }
  	if (H <= sum) {
      	printf("Yes\n");
    } else {
      	printf("No\n");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
ll a[200005],b[200005];
int main()
{
    OKawaiiKoto
    ll n,m,k,ans=0,cur=0,t;
    cin>>n>>m>>k;
    rep1(i,n) cin>>t,a[i]=a[i-1]+t;
    rep1(i,m) cin>>t,b[i]=b[i-1]+t;
    for(int i=n;i>=0;i--)
    {
        if(a[i]>k) continue;
        while(cur<m)
        {
            cur++;
            if(a[i]+b[cur]>k)
            {
                cur--;
                break;
            }
        }
        //cout<<i<<" "<<ans<<"\n";
        ans=max(ans,i+cur);
        if(cur==m) break;
    }
    cout<<ans;
}


Measured memory_bytes: 6728
//12:24
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp 
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;
  
int h[100100];

bool is_prime(int n){
	for(int i = 1;h[i]*h[i]<=n;i++){
		if(n%h[i]==0)return false;
	}
	return true;
}
//?´??????°????§£
vector<int> divisor(int n){
	vi res;
	for(int i = 1;h[i]*h[i]<=n;i++){
		if(n%h[i]==0){
			if(is_prime(h[i])) res.pb(h[i]);
			if(h[i]!=n/h[i] && is_prime(n/h[i]))res.pb(n/h[i]);
		}
	}
	if(is_prime(n))res.pb(n);
	return res;
}

int main(){
	rep(i,100100){
		h[i] = 7*(i/2)+1+(i%2)*5;
	}
	while(1){
		int n;
		cin >> n;
		if(n==1) break;
		vi d = divisor(n);
		sort(all(d));

		cout << n << ":";
		rep(i,d.size()) cout << " " << d[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3488
using System;

	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = 0;
			int k = 0;
			string[] c = Console.ReadLine().Split(' ');
			n = int.Parse(c[0]);
			k = int.Parse(c[1]);

			c = Console.ReadLine().Split(' ');
			int[] nums = new int[n];

			for (int i = 0; i < n; i++){
				nums[i] = int.Parse(c[i]);
			}

			int mini = 0;
			int miniCnt = 0;

			for (int i = 0; i < n; i++)
			{
				if (mini == 0)
				{
					mini = nums[i];
				}
				else if (nums[i] < mini)
				{
					mini = nums[i];
				}
			}

			for (int i = 0; i < n; i++)
			{
				if (mini == nums[i])
				{
					miniCnt++;
				}
			}
			int chgCnt = 0;

			chgCnt = (n - miniCnt) / (k - 1);
			if (((n - miniCnt) % (k - 1)) != 0) chgCnt++;

			Console.WriteLine(chgCnt);
		}
	
}


Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
long long const MAX=1e9+5;
int main()
{long long i,j,k,l,m,n,x,y,z,q,t,sum,d;sum=0;
cin>>n>>d;
d=d*d;
for(i=0;i<n;i++)
{cin>>x>>y;
x=x*x;y=y*y;
if(x+y<=d)sum=sum+1;}
cout<<sum;
return 0;}

Measured memory_bytes: 3628
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        while (true){
            int a = sc.nextInt();
            if (a == 0 ) break;
            i++;
            System.out.println("Case " + i + ": " + a);
        }
    }


}


Measured memory_bytes: 41112
#include <stdio.h>
int main(){
  int a[3];
  int k;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  scanf("%d",&k);
  for(int i=0;i<k;i++){
  if(a[0]>=a[1]){
    a[1]=a[1]*2;
  }else{
    a[2]=a[2]*2;
  }
  }
  if(a[0]<a[1]&&a[1]<a[2]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1644
{-#LANGUAGE BangPatterns#-}
module Main where

import Data.Functor
import Control.Monad

main::IO ()
main=do
  n<-read <$> getLine::IO Int
  when (n/=0) $
    do
      str <- getLine
      let out=times (toStr . split) str n
      putStrLn out
      main

toStr::[(Int,Char)]->String
toStr list=concatMap (\(n,c)->show n ++ [c])list

split::Eq a=>[a]->[(Int,a)]
split list=reverse $ split' 0 [] list

split'::Eq a=>Int->[(Int,a)]->[a]->[(Int,a)]
split' _ result []=result
split' !n result (x:y:ys)
  |x==y =split' (n+1) result (y:ys)
  |otherwise =split' 0 ((n+1,x):result) (y:ys)
split' !n result [x]=split' 0 ((n+1,x):result) []

times::(a->a)->a->Int->a
times _ x 0=x
times f x n=times f (f x) (n-1)

Measured memory_bytes: 7376
S = input()
list_Alpha = list("qwertyuiopasdfghjklzxcvbnm")
list_S = list(S)
for i in list_S:
  if i in list_Alpha:
    list_Alpha.remove(i)
  else:
    continue
if bool(list_Alpha) == True:
  list_Alpha.sort()
  print(list_Alpha[0])
else:
  print("None")

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
	ll n, k;
	cin >> n >> k;
	cout << fixed << setprecision(0) << k * pow(k - 1, n - 1) << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;

struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(10);
int sum,n,m,visited[11];
void dfs(int i){
    visited[i]=1;
    int flag=1;
    for(int j=1;j<=n;++j){
        if(!visited[j]){
            flag=0;
        }
    }
    if(flag){
        sum++;
        return;
    }
    for(auto x:adj[i]){
        if(!visited[x]){
            dfs(x);
            visited[x]=0;
        }
    }

}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:17
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1);
    cout<<sum;
}


Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main(){
	int A;
	int B;
	int C;
	int sum;
	int ans;
	cin >> A;
	cin >> B;
	cin >> C;
	
	sum = B+C;
	
	if(sum-A>0){
		ans = sum-A;
		cout << ans << endl;
	} else {
		ans = 0;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc165/tasks/abc165_c

from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
data = []
for _ in range(Q):
    data.append(list(map(int, input().split())))

res = []
for A in combinations_with_replacement(range(1,M+1), N):
    score = 0
    for i in range(Q):
        a,b,c,d = data[i]
        if A[b-1] - A[a-1] == c:
            score += d
    res.append(score)

print(max(res))

Measured memory_bytes: 80044
#include <iostream>

int main(int argc, char const *argv[]){
	
	int data[10] = {};
	for (int i = 0; i < 10; ++i){
		std::cin >> data[i];
	}

	for (int i = 0; i < 3; ++i){
		for (int j = 9; j > i; --j){
			if(data[j]>data[j-1]){
				int buff = data[j];
				data[j] = data[j-1];
				data[j-1] = buff;
			}
		}
	}

	for (int i = 0; i < 3; ++i){
		std::cout << data[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long long arr[2005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    for(int i = 0; i < n; ++i) cin >> arr[i];

    sort(arr, arr + n);

    long long tot = 0;

    for(int i = 0; i < n; ++i){
        int cur = i + 1;
        for(int j = i + 2; j < n; ++j){
            while(cur < j && arr[i] + arr[cur] <= arr[j])
                ++cur;
            tot += j - cur;
        }
    }

    cout << tot;

    return 0;

}


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

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

Measured memory_bytes: 4056
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <atcoder/fenwicktree>
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;
using namespace atcoder;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln '\n'
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zero ll(0)
#define set_bits(x) __builtin_popcountll(x)
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
 
ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	ll n,q;
	cin >> n >> q;
	fenwick_tree<ll> fw(n);
	v64 a(n);
	forn(i,n) {
		cin >> a[i];
		fw.add(i,a[i]);
	}
	forn(i,q){
		ll t1,t2,t3;
		cin >> t1 >> t2 >> t3;
		if(t1){
			cout << fw.sum(t2,t3) << ln;
		}
		else{
			fw.add(t2,t3);
		}
	}
	
}
 
int main()
{
	fast_cin();
	ll t=1;
    // cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 12148
n = int(input())
c = [1]
for i in range(6):
    c.append(6**(i+1))
for i in range(5):
    c.append(9**(i+1))
INF = float("inf")

dp = [INF]*(n+1)
dp[0] = 0

for i in range(len(c)):
    for j in range(n+1):
        if j + c[i] > n:
            break
        else:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1)

print(dp[n])

Measured memory_bytes: 49232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_R = 3009;
const int MAX_C = 3009;
const int MAX_K = 200009;
const int LIM_ITEM = 3;

int R, C, K;
int r[MAX_K], c[MAX_K], v[MAX_K];

int item[MAX_R][MAX_C];

// dp[i][j][k]: (i, j)までに, 同じ行内でアイテムk個以下のときの, 価値の合計の最大値
ll dp[MAX_R][MAX_C][LIM_ITEM + 1];

int main() {
    cin >> R >> C >> K;
    REP(i, K) cin >> r[i] >> c[i] >> v[i];

    REP(i, R+1) REP(j, C+1) item[i][j] = 0;
    REP(i, K) item[r[i]][c[i]] = v[i];

    REP(i, R+1) REP(j, C+1) REP(k, LIM_ITEM + 1) dp[i][j][k] = 0;

    // 配るDP
    REP(i, R+1) REP(j, C+1) REP(k, LIM_ITEM + 1) {
        // (i+1, j)への移動
        if (i < R) {
            // (i+1, j)でアイテムを拾わない
            dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][LIM_ITEM]);
            // (i+1, j)でアイテムを拾う
            if (k > 0) dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][LIM_ITEM] + item[i+1][j]);
        }
        // (i, j+1)への移動
        if (j < C) {
            // (i, j+1)でアイテムを拾わない
            dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
            // (i, j+1)でアイテムを拾う
            if (k < LIM_ITEM) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + item[i][j+1]);
        }
    }

    cout << dp[R][C][LIM_ITEM] << endl;
    return 0;
}

Measured memory_bytes: 323288
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	char a, b; scanf("%c %c", &a, &b);
	
	if(a == 'H') printf("%c\n", b);
	else if(b == 'D') printf("H\n");
	else printf("D\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

int main(){

    int n,k;
    string s;

    cin>>n>>k>>s;
    s[k-1] = (char)(s[k-1]-'A'+'a');
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
 
int main() {
  string s;
  cin >> s;
  int n = int(s.size());
  int co = 0;
  for (int i = 0; i < n-1; i++) {
    if (s[i] != s[i+1]) co++;
  }
  cout << co << endl;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
void solve(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();

    int hh = sc.nextInt();
    int ww = sc.nextInt();

    int a  = h*w - hh*w - ww*h + hh*ww;

    System.out.println(a);
  }
}


Measured memory_bytes: 21844
//
// Created by kinok on 2020/04/17.
//

#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include<string>
#include <iomanip>

using namespace std;


#define ll long long
#define rep(t) for(int i=0;i<t;i++)
#define deb(a) cout<<#a<<" : "<<a<<endl

	bool kaibun(string s){
        rep(s.length()){
            if(s[i]!=s[s.length()-i-1]){
                return false;
            }
        }
        return true;
    }


    int main(){
        double l;
        cin>>l;
        l/=3;
        l=pow(l,3);
        cout<<fixed<<setprecision(8)<<l<<endl;
        return 0;
    }






Measured memory_bytes: 256
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N;
  string s[100];
  cin>>N;
  for (int i(0);i<N;i++) cin>>s[i];
  for (int i(1);i<N;i++){
    if (s[i][0] != s[i-1][s[i-1].size()-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  sort(s,s+N);
  for (int i(1);i<N;i++){
    if (s[i] == s[i-1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 10;

#pragma GCC optimize("Ofast")

int dp[MAXN][MAXN];
string s, t;

int x, y;

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

	x = s.size(), y = t.size();

	for(int i = x; i >= 0; i--)
	{
		for(int j = y; j >= 0; j--)
		{
			if(i == x or j == y) dp[i][j] = 0;

			else if(s[i] == t[j]) dp[i][j] = 1 + dp[i + 1][j + 1];

			else
			{
				int caso1 = dp[i + 1][j];
				int caso2 = dp[i][j + 1];

				dp[i][j] = max(caso1, caso2);
			}
		}
	}

	//cout << dp[0][0];

	string resp = "";

	int i = 0, j = 0;

	while(i <= x and j <= y)
	{
		if(dp[i][j] == dp[i + 1][j]) i++;
        
        else if(dp[i][j] == dp[i][j + 1]) j++;
        
        else
        {
            resp += s[i];
            i++, j++;
        }
	}

	cout << resp << "\n";
}

Measured memory_bytes: 35584
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        if (A >= B && A >= C) {
            System.out.println((int)(A * Math.pow(2, K) + B + C));
        }
        else if (B >= A && B >= C) {
            System.out.println((int)(B * Math.pow(2, K) + A + C));
        }
        else {
            System.out.println((int)(C * Math.pow(2, K) + A + B));
        }
    }
}

Measured memory_bytes: 22612
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

bool isEightDivisors(int n){
  int cnt = 0;
  rep(i, n+1)
  {
    if(i==0)
      continue;
    if (n % i == 0)
    {
      cnt++;
    }
  }
  return cnt == 8;
}

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n;i+=2){
    if(isEightDivisors(i)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

long long s[51], p[51];

long long f(int n, long long x)
{
    if(n == 0)
    {
        return (x <= 0 ? 0 : 1);
    }
    if(x <= 1 + s[n - 1]) return f(n - 1, x - 1);

    return (1 + p[n - 1] + f(n - 1, x - s[n - 1] - 2));
}

int main(void)
{
    s[0] = 1;
    p[0] = 1;
    int n;
    long long x;
    cin >> n >> x;

    for(int i = 1; i <= n; i++)
    {
        s[i] = (2 * s[i - 1]) + 3;
        p[i] = (2 * p[i - 1]) + 1;
        // cout << i << " " << s[i] << " " << p[i] << endl;
    }

    cout << f(n , x) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e17
int va=10e8+7;
ll int dp[100004]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        ll ans{0},ma=arr[0];
        for(int i=1;i<n;i++){
            if(arr[i]>=ma) ma=arr[i];
            else{
                ans+=(ma-arr[i]);
                ma=max(ma,arr[i]);
            }
        }
        cout<<ans<<endl;
    }
 return 0;
}

Measured memory_bytes: 5192
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int a = int.Parse(line[0]);
		int b = int.Parse(line[1]);
		System.Console.WriteLine((a * b).ToString() + " " + (a * 2 + b * 2).ToString());
	}
}

Measured memory_bytes: 5604
//Harjot Singh Student NIT JALANDHAR	

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define inf 1e9+1
typedef long long int ll;
struct item
{
	int wt,val;
};
int main()
{
    
   int n,k;
 cin>>n>>k;
     item arr[n];
     for(int i=0;i<n;i++)
     	cin>>arr[i].wt>>arr[i].val;
   int maxval=1000*n;

   int dp[n+1][maxval+1];
   for(int i=0;i<=maxval;i++)
   {
   	dp[0][i]=inf;
   }
   for(int i=0;i<=n;i++)
   	dp[i][0]=0;

   for(int i=1;i<=n;i++)
   {
   	for(int j=1;j<=maxval;j++)
   	{
   		dp[i][j]=dp[i-1][j];

   		if(j>=arr[i-1].val)
   		{
   			dp[i][j]=min(dp[i][j],dp[i-1][j-arr[i-1].val]+arr[i-1].wt);
   		}
      
   }
     }
     int ma=0;
     for(int i=1;i<=maxval;i++)
     {
        if(dp[n][i]<=k)
        	ma=i;
     }

      cout<<ma<<endl;
	return 0;
   	}


Measured memory_bytes: 39680
#include <iostream>

using namespace std;
int table[500001];
int main() {
    char S[500001];
    cin >> S;

    int beforeIdx = 0;
    int minimum = 0;
    for (int i=0; S[i]!=0; i++) {
        if (S[i] == '<') {
            if (minimum>0) table[beforeIdx] = minimum;
            minimum = 0;
        }
        else {
            if (minimum == 0) {
                beforeIdx = i;
            }
            minimum++;
        }
    }
    if (minimum > 0)
        table[beforeIdx] = minimum;

    long long ans = 0;
    int score = 0;
    int need = 0;

    need = table[0];
    score = max(score, need);
    ans +=score;
    if (need > 0) need--;
    //cerr << score;
    for (int i=0; S[i]!=0; i++) {
        if (S[i] == '>') {
            score=0;
        }
        else {
            score++;
        }
        need += table[i+1];
        score = max(score, need);
        ans += score;
        if (need > 0) need--;

        //cerr << score;
    }
    //cerr << endl;

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2688
S = input()
S_list = [c for c in S]
#print(S_list)

Size = len(S_list)
S_param_untilL = [0]*Size
S_param_untilR = [0]*Size
S_final = [0]*Size


S_list_reverse = S_list[::-1] 
S_reverse = ''.join(S_list_reverse)
#print(S_reverse)

for i in range(Size):
  if S_list[i] == 'R':
    S_param_untilL[i] = S.find('L', i)  -i
    S_final[i+ S_param_untilL[i] - S_param_untilL[i] % 2 ] += 1
  if S_list[i] == 'L':
    S_param_untilR[Size - i-1] = S_reverse.find('R', Size - i-1)  -(Size - i-1)
    S_final[i- S_param_untilR[Size - i-1] + S_param_untilR[Size - i-1] % 2 ] += 1

    
#print(S_param_untilL)
#print(S_param_untilR)

for i in range(Size):
  print(S_final[i], end = ' ')



Measured memory_bytes: 11152
# -*- coding: utf-8 -*-
def main():
    import sys
    input = sys.stdin.readline
    N,M = map(int,input().split())
    SC = [list(map(int,input().split())) for i in range(M)]
    ans = ["x","x","x"]
    if N == 1:
        ans[0] = "0"
        ans[1] = "0"
        for sc in SC:
            if sc[0] == 1:
                if ans[2] == "x":
                    ans[2] = str(sc[1])
                elif ans[2] != "x" and ans[2] != str(sc[1]):
                    print(-1)
                    exit()
            elif sc[0] == 2 or sc[0] == 3:
                print(-1)
                exit()
    elif N == 2:
        ans[0] = "0"
        for sc in SC:
            if sc[0] == 1:
                if ans[1] == "x":
                    ans[1] = str(sc[1])
                elif ans[1] != "x" and ans[1] != str(sc[1]):
                    print(-1)
                    exit()
            elif sc[0] == 2:
                if ans[2] == "x":
                    ans[2] = str(sc[1])
                elif ans[2] != "x" and ans[2] != str(sc[1]):
                    print(-1)
                    exit()
            elif sc[0] == 3:
                print(-1)
                exit()
    elif N == 3:
        for sc in SC:
            if sc[0] == 1:
                if ans[0] == "x":
                    ans[0] = str(sc[1])
                elif ans[0] != "x" and ans[0] != str(sc[1]):
                    print(-1)
                    exit()
            elif sc[0] == 2:
                if ans[1] == "x":
                    ans[1] = str(sc[1])
                elif ans[1] != "x" and ans[1] != str(sc[1]):
                    print(-1)
                    exit()
            elif sc[0] == 3:
                if ans[2] == "x":
                    ans[2] = str(sc[1])
                elif ans[2] != "x" and ans[2] != str(sc[1]):
                    print(-1)
                    exit()
    if N == 1:
        if ans[0] == "x":
            ans[1] = "0"
        if ans[1] == "x":
            ans[1] = "0"
        if ans[2] == "x":
            ans[2] = "0"
        print(int("".join(ans)))
    elif N == 2:
        if ans[1] == "0":
            print(-1)
            exit()
        if ans[0] == "x":
            ans[1] = "0"
        if ans[1] == "x":
            ans[1] = "1"
        if ans[2] == "x":
            ans[2] = "0"
        print(int("".join(ans)))
    elif N == 3:
        if ans[0] == "0":
            print(-1)
            exit()
        if ans[0] == "x":
            ans[0] = "1"
        if ans[1] == "x":
            ans[1] = "0"
        if ans[2] == "x":
            ans[2] = "0"
        print(int("".join(ans)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3272
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    for(int n; 0<(n=readln().chomp().to!int()); )
    {
        auto a = iota(n).map!(_=>readln().split().array()).array();
        long[string] t;
        foreach(v;a)
        {
            immutable s = v[1..$].map!(to!long).reduce!"a*b"();
            if(v[0] in t) t[v[0]] += s;
            else t[v[0]] = s;
        }
        bool[string] u;
        string[] ids;
        foreach(v;a)
            if(t[v[0]]>=1000000 && v[0] !in u) ids~=v[0], u[v[0]]=true;
        if(ids.length==0) writeln("NA");
        else foreach(id;ids) writeln(id);
    }
}

Measured memory_bytes: 1356
n, m = map(int, input().split())
ans = [ False for _ in range(m) ]
a = []

for _ in range(n):
    a += [ list( map(int, input().split()) )[1:] ]

for i in range(m):
    all_true = True
    for j in a:
        if (i+1) not in j:
            all_true = False
            break
    if all_true:
        ans[i] = True

print (ans.count(True))


Measured memory_bytes: 3060
N=int(input())
S=[]
count=0
ans=0
for i in range(N):
    s=sorted(input())
    S.append(s)
S.sort()
x=S[0]
for i in range(1,N):
    if(S[i]==x):
        count += 1
    else:
        ans=ans+(count+1)*count//2
        count=0
        x=S[i]
ans=ans+(count+1)*count//2
print(ans)

Measured memory_bytes: 24652
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  var has = true
  var ans = ""
  for (i in 'a'..'z') {
    val c =  i.toChar()
    if (s.contains(c)) {
      continue
    } else {
      has = false
      ans = c.toString()
      break
    }
  }
  if (has) ans = "None"

  println(ans)
}


Measured memory_bytes: 30368
#include <bits/stdc++.h>
int main(void)
{
  int n, y;
  std::cin>> n >> y;
  for(int i = y / 10000; i >= 0; i--){
    int m = y - i * 10000;
    for(int j = m / 5000; j >= 0; j--){
      int k = (m - j * 5000) / 1000;
      if(i + j + k == n){
        std::cout << i << " " << j << " " << k << std::endl;
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x7f7f7f7f
using namespace std;
const int N = 2e5 + 5;
vector<int> G[N] = {};
int val[N] = {};
int n;
stack<int> ls[N];
int ans[N] = {};
bool ha[N] = {};
int t = 0;
int bs(int x) {
    int l = 1, r = t, mid;
    while (l <= r) {
        mid = (l + r) >> 1;
        if (ls[mid].top() < x)
            l = mid + 1;
        else r = mid - 1;
    }
    return l;
}
void dfs(int u, int f) {
    int idx = bs(val[u]);
    if (val[u] < ls[idx].top()) {
        ha[u] = true;
        ls[idx].emplace(val[u]);
        t = max(idx, t);
    }
    ans[u] = t;
    for (const int &v : G[u])
        if (v != f)
            dfs(v, u);
    if (ha[u]) {
        ls[idx].pop();
        if (ls[idx].top() == INF)
            t--;
    }
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> val[i];
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    ls[0].emplace(0);
    for (int i = 1; i <= n; i++)
        ls[i].emplace(INF);
    dfs(1, 0);
    for (int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 165244
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

constexpr int MOD = 1e9+7;

int dp[5001][5001];

int main(void) {
    int i, j, k, n;
    string s;
    cin >> n >> s;
    dp[0][s.size()] = 1;
    REP (i,1,n) REP (j,n) {
        dp[i][j] += dp[i-1][j+1];
        if (j > 0)
            dp[i][j] += dp[i-1][j-1] * 2 % MOD;
        else
            dp[i][j] += dp[i-1][j];
        dp[i][j] %= MOD;
    }
    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,M;cin >> N >> M;
    vector<LL> A(N);
    vector<LL> B(M);
    vector<LL> C(M);
    rep(i,N)cin >> A[i];
    rep(i,M)cin >> B[i] >> C[i];

    // ランレングス圧縮
    vector<pll> v;
    rep(i,N)v.push_back({A[i],1});
    rep(i,M)v.push_back({C[i],B[i]});
    sort(rall(v));

    LL ct = 0;
    LL ans = 0;
    for(auto a : v){
        if(ct + a.S > N){
            int tmp = N - ct;
            ans += a.F * tmp;
            break;
        }
        else{
            ct += a.S;
            ans += a.F * a.S;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
signed main(){
  string S;
  char a;
  getline(cin,S);
  rep(0,S.size()){
    if(S[i]!=' '){
      a=S[i];
      if(65<=S[i]&&S[i]<=90)a+=32;
      else if(97<=S[i]&&S[i]<=122)a-=32;
      cout<<a;
    }
    else cout<<' ';
  }
  cout<<endl;
}



Measured memory_bytes: 3156
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

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

int main() {
  ll n;

  cin >> n;

  ll c5 = 5;
  ll ans = 0;

  if(n % 2 == 1){
    puts("0");
    return 0;
  }

  while (c5 <= n) {
    ans += n / (2*c5);
    c5 *= 5;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll x;
    cin >> x;
    ll ans = (x + 10) / 11 * 2;
    if(x % 11 <= 6 && x % 11 > 0) ans--;
    cout << ans << endl;
}

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

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

const int INF = 1001001001;

using namespace std;

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

    int n; cin >> n;
    vector<int> h(n); rep(i,n) cin >> h[i];

    vector<int> dp(n,INF);

    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    for(int i=2; i<n; i++) {

        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));

    }

    cout << dp[n-1] << "\n";

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        long[] arr = new long[(int) n];

        long ans = 0;

        for (int i = 0; i<n; i++){
            arr[i] = sc.nextInt();
        }

        for (int i = 1; i<n; i++){
            if (arr[i] < arr[i-1]){
                ans += (arr[i-1]-arr[i]);
                arr[i] = arr[i-1];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 61316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

int gcd(int x,int y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int lcm(int x, int y)
{
	return (x * y / gcd(x, y));
}

signed main(){
	int A,B;
	cin>>A>>B;
	int l = lcm(A,B);
	OUT(l);
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n==3){
        cout << "2 3 25" << endl;
        return 0;
    }
    set<int> st2,st3,st6,ans;
    ans.insert(2);
    ans.insert(4);
    ans.insert(3);
    ans.insert(9);
    st6.insert(6);
    st2.insert(8);
    for(int i = 10;i<=30000;i++){
        if(i%6==0) st6.insert(i);
        else if(i%2==0) st2.insert(i);
        else if(i%3==0) st3.insert(i);
    }
    int k = min(2*((n-4)/4),4990);
    int t = n-2*k-4;
    int cnt = 0;
    if(n>=15000){
        for(auto itr = st2.begin();itr!=st2.end();itr++) ans.insert(*itr);
        for(auto itr = st3.begin();itr!=st3.end();itr++) ans.insert(*itr);
        for(auto itr = st6.begin();itr!=st6.end();itr++){
            if(cnt==n-15000) break;
            ans.insert(*itr);
            cnt++;
        }
    }
    else{
        auto itr1 = st2.begin();
        auto itr2 = st3.begin();
        for(int i = 0;i<k;i++){
            ans.insert(*itr1);
            ans.insert(*itr2);
            itr1++;
            itr2++;
        }
        for(int i = 0;i<t;i++){
            ans.insert(6*(i+1));
        }
    }
    for(auto itr = ans.begin();itr!=ans.end();itr++){
        cout << *itr << " ";
    }
}

Measured memory_bytes: 2176