akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    int S[100],H[100],D[100],C[100],n,m;
    char x;
    for(int i=1;i<=13;i++){
        S[i]=-1;
        H[i]=-1;
        D[i]=-1;
        C[i]=-1;
    }
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x>>m;
        if(x=='S'){
            S[m]=m;
        }
        else if(x=='H'){
            H[m]=m;
        }
        else if(x=='D'){
            D[m]=m;
        }
        else{
            C[m]=m;
        }
    }
    for(int i=1;i<=13;i++){
        if(S[i]==-1){
            cout<<'S'<<" "<<i<<endl;
        }
    }
    for(int i=1;i<=13;i++){
        if(H[i]==-1){
            cout<<'H'<<" "<<i<<endl;
        }
    }
    for(int i=1;i<=13;i++){
        if(C[i]==-1){
            cout<<'C'<<" "<<i<<endl;
        }
    }
    for(int i=1;i<=13;i++){
        if(D[i]==-1){
            cout<<'D'<<" "<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int a, b, k;
		ArrayList<Integer> list = new ArrayList<>();
		
		Scanner scanner = new Scanner(System.in);
		a = scanner.nextInt();
		b = scanner.nextInt();
		k = scanner.nextInt();
		
		scanner.close();
		
		int max = Math.max(a,  b);
		
		for (int i = 1; i <= max; i++) {
			if (a % i == 0 && b % i == 0) {
				list.add(0, i);
			}
		}
		
		System.out.println(list.get(k-1));
	}

}

Measured memory_bytes: 22868
#include<stdio.h>
int main(void){
    int H,W;
    int i,j;
    while(1){
    scanf("%d%d",&H,&W);
    if(H==0&&W==0)break;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
         printf("#");   
        }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}


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

using namespace std;

const int maxn=1e6;
int ans[maxn];

int main()
{
	memset(ans,0,sizeof(ans));
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>ans[i];
	int q;
	cin>>q;
	int k;
	int cnt=0;
	for(int i=0;i<q;i++){
		cin>>k;
		if(*lower_bound(ans,ans+n,k)==k)cnt++;
	}
	cout<<cnt<<endl;
	return 0;	
} 


Measured memory_bytes: 6992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		int pura = A + B;
		int mai = A - B;
		int kake = A * B;

		int kotae;
		if (pura < mai) {
			kotae = mai;
		} else {
			kotae = pura;
		}
		if (kotae < kake) {
			kotae = kake;
		}
		System.out.println(kotae);

	}

}

Measured memory_bytes: 23636
using System;
using System.Linq;

namespace V0029{
    public class Program{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split(' ');
            var group = input.GroupBy(s => s).ToArray();
            var res0 = group.First(g => g.Count() == group.Max(h => h.Count())).Key;
            var res1 = group.First(g => g.Key.Length == group.Max(h => h.Key.Length)).Key;
            Console.WriteLine("{0} {1}", res0, res1);
        }
    }
}

Measured memory_bytes: 9596
import sys


class BinaryIndexedTree(object):
    __slots__ = ["tree"]

    def __init__(self, size: int):
        self.tree = [0]*(size+1)

    def add(self, index: int, value: int) -> None:
        tree = self.tree
        next_index = index + 1

        while next_index < len(tree):
            tree[next_index] += value
            next_index += next_index & -next_index

    def sum(self, index: int):
        tree, result = self.tree, 0
        next_index = index + 1

        while next_index:
            result += tree[next_index]
            next_index -= next_index & -next_index

        return result


if __name__ == "__main__":
    n, q = map(int, input().split())
    bit = BinaryIndexedTree(n)
    result = []
    for com, x, y in (map(int, l.split()) for l in sys.stdin):
        if not com:
            bit.add(x-1, y)
        else:
            result.append(bit.sum(y-1) - bit.sum(x-2))

    print(*result, sep="\n")


Measured memory_bytes: 10740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int read() {
    static char s[1 << 18];
    static int i, j;
    int r = 0, t = 1, b = 0;
    while (1) {
        if (i == j) {
            cin.read(s, sizeof(s));
            i = 0;
            j = cin.gcount();
            if (j == 0) break;
        }
        int c = s[i++];
        if ('0' <= c && c <= '9') {
            r = r * 10 + (c - '0');
            b = 1;
        } else if (c == '-') {
            t = -1;
        } else if (b) {
            break;
        }
    }
    return r * t;
}

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

    int n = read();

    int a0 = read(), a1 = read();

    ll r0 = 0, r1 = max(a0, a1), r2;
    ll s = a0;

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

        if (i & 1) {
            r2 = max(r0 + a, s);
        } else {
            r2 = max(r0 + a, r1);
            s += a;
        }
        r0 = r1;
        r1 = r2;
    }

    cout << r1 << endl;

    return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, int e, lint MOD) {
    lint result = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            result *= cur_num;
            result %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return result;
}

const lint MOD = 1e9 + 7;
const lint max_num_grids = 2 * 1e5;
int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N, M, K;
    cin >> N >> M >> K;
    vec<lint> factorial(max_num_grids + 1);
    factorial.at(0) = 1;
    range(i, 1, max_num_grids + 1) {
        factorial.at(i) = factorial.at(i - 1) * (lint)i % MOD;
    }
    vec<lint> inv_factorial(max_num_grids + 1);
    range(i, 0, max_num_grids + 1) {
        inv_factorial.at(i) = pow(factorial.at(i), MOD - 2, MOD);
    }

    lint res = 0;
    range(d, 0, N) {
        res += d * ((N - d) * M * M) % MOD;
        res %= MOD;
    }
    range(d, 0, M) {
        res += d * ((M - d) * N * N) % MOD;
        res %= MOD;
    }
    // cout << res << "\n";
    res = res * factorial.at(N * M - 2) % MOD * inv_factorial.at(N * M - K) % MOD * inv_factorial.at(K - 2);
    res %= MOD;
    cout << res << "\n";
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int hap = 0;
    hap += 1000 * (n / 500);
    n %= 500;
    hap += 5 * (n / 5);

    cout << hap << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
// ABC 6-C
// http://abc006.contest.atcoder.jp/tasks/abc006_3
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
	    Scanner in = new Scanner(System.in);

	    int a = in.nextInt();
	    int b = in.nextInt();
	    
	    System.out.println((a + b) % 24);
	}
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    ll N, K; cin>>N>>K;
    vector<ll> P(N+1),C(N+1);
    rep(i,N)cin>>P.at(i+1);
    rep(i,N)cin>>C.at(i+1);


    ll max_score = -2*pow(10,18);
    for(ll i=1;i<N+1;i++){
        //最初にiに駒を置く場合のスコアを計算する

        //次にiが出るまでの周回のスコアを
        //またはその中でのスコアの最大値を計算する
        ll pos = i;
        ll temp_score = 0;
        ll temp_max_score = -2*pow(10,18);
        ll cycle_score;
        ll index = 0;
        ll flag = 0;
        while(true){
            index++;
            ll next_pos = P.at(pos);
            temp_score += C.at(next_pos);

            if(temp_max_score<temp_score){
                temp_max_score = temp_score;
            }
            if(index==K){
                flag = 1;
                break;
            }
            if(next_pos==i){
                cycle_score = temp_score;
                break;
            }
            pos = next_pos;
        }
        if(temp_max_score<=0 || flag == 1){
            if(max_score<temp_max_score){
                max_score = temp_max_score;
            }
            continue;
        }else{
            ll score = 0;
            score += K/index * cycle_score;
            ll pos = i;
            ll teemp = 0;
            ll max_teemp = 0;
            for(ll j=0;j<K%index;j++){
                pos = P.at(pos);
                teemp += C.at(pos);
                if(max_teemp<teemp){
                    max_teemp=teemp;
                }
            }
            score += max_teemp;
            if(score< (cycle_score*(K/index-1)+temp_max_score)){
                score = cycle_score*(K/index-1)+temp_max_score;
            }
            if(score<temp_max_score){
                score = temp_max_score;
            }
            if(max_score<score){
                max_score = score;
            }
        }
    }

    cout<<max_score<<endl;


    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    ll A,B;
    string res;

    cin >> A >> B;

    res = "Yes";
    if(A == 2 || B == 2)
    {
        res = "No";
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int W, H;
    int x, y, r;
 
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H)
    printf("Yes\n");
    
    else
    printf("No\n");
    
    return 0;
}



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


int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++) cin >> d[i];
    sort(d.begin(),d.end());
    int i = N/2;
    cout << d[i]-d[i-1] << endl;
}

Measured memory_bytes: 640
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int n,l;
	cin >> n >> l;
	vector<string>data(n);
	for (int i = 0; i < n; i++) {
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	for (int i = 0; i < n; i++) {
		cout << data[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int N;
vector<vector<int>> to;
vector<int> ans;
priority_queue<int> c;
int res = 0;

void dfs(int u, int v = -1){
    
    for (int i : to[u]) {
        if(i == v) continue;
        int d = c.top();
        c.pop();
        ans[i] = d;
        res += d;
        dfs(i,u);
    }
    
}



int main()
{
    cin >> N;
    to.resize(N);
    ans.resize(N);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,N){
        int cc;
        cin >> cc;
        c.push(cc);
    }
    ans[0] = c.top();
    c.pop();
    dfs(0);
    
    cout << res << endl;
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL vis[805][805] = {0};
char ch[805][805];
LL n,m,k,ans = INF;
LL dx[4] = {0,0,1,-1};
LL dy[4] = {1,-1,0,0};

struct node{
	LL x,y,stp;
}h,t; queue <node> q;
void bfs(LL x,LL y){
	t.x = x; t.y = y; t.stp = 0; q.push(t);
	while(!q.empty()){
		h = q.front(); q.pop();
		if(h.stp > k) continue;
		vis[h.x][h.y] = 1;
		ans = min(ans,min(min(h.x - 1,h.y - 1),min(n - h.x,m - h.y)));
		for(LL i = 0;i < 4;i ++){
			LL tx = h.x + dx[i],ty = h.y + dy[i];
			if(!tx || !ty || tx > n || ty > m) continue;
			if(vis[tx][ty] || ch[tx][ty] == '#') continue;
			vis[tx][ty] = 1;
			t.x = tx; t.y = ty; t.stp = h.stp + 1;
			q.push(t);
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	LL sx = 0,sy = 0;
	cin >> n >> m >> k;
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= m;j ++){
			cin >> ch[i][j];
			if(ch[i][j] == 'S'){ sx = i; sy = j; }
		}
	}
	bfs(sx,sy);
//	cout << ans << endl;
	cout << (ans + k - 1) / k + 1 << endl;
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
#include<vector>

int main(void){
	std::int64_t N;
	std::cin >> N;
	std::int64_t a[N];

	for(auto i = decltype(N)(1); i <= N; i++){
		std::cin >> a[i];
	}

	std::int64_t min = a[1];
	for(auto i = decltype(N)(1); i <= N; i++){
		if(a[i] < min){
			min = a[i];
		}
	}
	std::int64_t max = a[1];
	for(auto i = decltype(N)(1); i <= N; i++){
		if(a[i] > max){
			max = a[i];
		}
	}

	std::cout << max - min << std::endl;
	return 0;
	
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1001

int main(void)
{
    int i;
    char s[N];
    scanf("%s", s);

    for(i=0; s[i]; i++)
        putchar((s[i] - 'A' + 23) % 26 + 'A');

    puts("");
    return (0);
}

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

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

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


void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
    ll a=0;
    rep(i,N){
        ll sum=0;
        rep(j,M){
           sum+=B[j]*A[i][j] ;
        }
        sum+=C;
        (sum>0)?a++:1;
    }
    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define NMAX 105
#define WMAX 10005

using namespace std;

struct Item {
	int value;
	int weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1];

void solve() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < items[i].weight) {
				C[i + 1][j] = C[i][j];
			}
			else {
				C[i + 1][j] = max(C[i][j], C[i + 1][j - items[i].weight] + items[i].value);
			}
		}
	}
}

void input() {
	cin >> N >> W;
	for (int i = 1; i <= N; i++) {
		cin >> items[i].value >> items[i].weight;
	}
}

int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++)
		cin >> items[i].value >> items[i].weight;

	for (int i = 0; i < W; i++) C[0][i] = 0;

	solve();

	cout << C[N][W] << endl;

	return 0;
}


Measured memory_bytes: 7052
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
typedef vector<ll> VL;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 9999999999

ll h[100010],dp[100100],N,K;

int main(){
  cin >>N >>K;
  REP(i,N){
    scanf("%lld",&h[i]);
  }
  fill(dp,dp+N,INF);
  dp[0]=0;
  for(int i=1;i<N;++i){
    for(int j=1;i-j>=0 &&  j<=K;++j){
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << dp[N-1]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, C;
  cin >> N >> C;
  vvll D(C, vll(C));
  vvll c(N, vll(N));
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      cin >> D.at(i).at(j);
    }
  }
  vll zero(C, 0), one(C, 0), two(C, 0);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cin >> c.at(i).at(j);
      c.at(i).at(j)--;
      if((i+j)%3 == 0) zero.at(c.at(i).at(j))++;
      else if((i+j)%3 == 1) one.at(c.at(i).at(j))++;
      else two.at(c.at(i).at(j))++;
    }
  }
  ll ans = INF;
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      for(int k = 0; k < C; k++){
        if(i == j || j == k || k == i) continue;
        ll sum = 0;
        for(int l = 0; l < C; l++){
          sum += zero.at(l) * D.at(l).at(i);
          sum += one.at(l) * D.at(l).at(j);
          sum += two.at(l) * D.at(l).at(k);
        }
        chmin(ans, sum);
      }
    }
  }
  cout << ans << endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>

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

    bool found = false;
    for (int i = 1; i <= 50000; i++) {
        if ((int)(i * 1.08) == n) {
            std::cout << i << std::endl;
            found = true;
            break;
        }
    }

    if (!found) {
        std::cout << ":(" << std::endl;
    }

    return 0;
}

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

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

	int x;
	cin >> x;
	if (x < 4)
	{
		cout << 1 << endl;
		return (0);
	}
	bitset<2000000>	bs;
	for (int i = 2; i < 33; i++)
	{
		int temp = i;
		while (temp <= 1000)
		{
			temp *= i;
			bs.set(temp);
		}
	}
	for (int i = x; i > 0; i--)
	{
		if (bs.test(i))
		{
			cout << i << endl;
			return (0);
		}
	}
}


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

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

    int b = 0, s = 0;
    long long curr = 1000;
    for (int i = 0; i < n; i++)
    {
        while (a[i + 1] <= a[i] && i < n)
            i++;
        b = i;

        while (a[i + 1] >= a[i] && i < n)
            i++;
        if (i == n)
            i--;
        s = i;

        if (b < s)
        {
            long long num = (curr / a[b]);
            curr += num * (a[s] - a[b]);
        }
    }
    cout << curr << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  int N = S.length();
  int count = 0;
  int max = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'A' ||S.at(i) == 'T' ||S.at(i) == 'G' ||S.at(i) == 'C' ){
      count++;
    }else{
      if(count > max){
        max = count;
      	count = 0;
      }
    }
  }
  
  if(count>max){
    max=count;
  }
  cout << max << endl;
  return 0;
  
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    let v=[0,2,0,1,0,1,0,0,1,0,1,0];
    println!("{}",if v[a-1]==v[b-1]{"Yes"}else{"No"})
}

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

int main(){
  unsigned long long int a,b,x,count=0;
  cin >> a >> b >> x;

  count += b/x;
  if(a!=0){count -= (a-1)/x;}
  else{count++;}
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
template<class T,enable_if_t<is_integral<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}
template<class T,enable_if_t<is_floating_point<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-fmod(-a,b);}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    string s;
    cin>>s;
    int a=0;
    int n=s.size();
    REP(i,n/2){
        if(s[i]!=s[n-1-i])a++;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

vector<ll> px;
vector<int> ok;
vector<vector<int>> m;

void dfs(ll total, int child, vector<ll> &reslut){
    reslut[child] = total + px[child];
    ok[child] = 1;
    for(auto&& i : m[child]){
        if(ok[i] == 1) continue;
        dfs(total + px[child], i, reslut);
    }
}

int main(void)
{
    int N,Q;
    cin >> N >> Q;
    m.assign(N, vector<int>());
    REP(i, N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        m[a].pb(b);
        m[b].pb(a);
    } 
    px.assign(N, 0);
    REP(i, Q){
        int p,x;
        cin >> p >> x;
        p--;
        px[p] += x;
    }

    vector<ll> reslut(N, 0);
    ok.assign(N, 0);
    dfs(0,0,reslut);
    REP(i, N){
        pr(reslut[i]);
    }
}

Measured memory_bytes: 26624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define ll long long

int d = 365;
int k = 0;

vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        last[out[i]] = i+1; // タイプ番号
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
        //cout << "score : " << score << endl;
    }
    
    //cout << p << endl;
    //if(out.size() >= d) return score;
    //cout << k << endl;
    //cout << out.size() << " " << d << endl;
    //int p = min(int(out.size()+k), d);
    //int k = 13;
    //int p = min(int(out.size()+k), d);
    /*
    ll q = LLONG_MIN;
    for(int k = 0; k < 26; k++) {
        int p = min(int(out.size()+k), int(d));
        ll tmp = 0;
        for(int i = out.size(); i < p; i++) {
            for(int j = 0; j < 26; j++) {
                //score -= c[j]*((i)-last[j]);
                tmp -= c[j]*((i)-last[j]);
            }
        }
        if(tmp > q) {
            q = tmp;
        }
    }
    */

    //int k = 10;
    ll score_tmp = score;
    ll score_max = LLONG_MIN;
    for(int k = 0; k < 26; k++) { 
        score_tmp = score;
        int p = min(int(out.size()+k), int(d));
        for(int i = out.size(); i < p; i++) {
            for(int j = 0; j < 26; j++) {
                //score -= c[j]*((i)-last[j]);
                score_tmp -= c[j]*((i)-last[j]);
                //tmp -= c[j]*((i)-last[j]);
            }
        }
        if(score_tmp > score_max) {
            score_max = score_tmp;
        }
    }
    return score_max;
}

int main() {
    init();
    
    vector<int> out;
    ll ans = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
        //cout << "k: " << k << endl;
        //vector<int> out;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            //for(int k = 0; k < 26; k++) {
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            //}
            out.pop_back();
        }
        out.push_back(best);
    }
    //}
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

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

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

    set<string> s;
    for(int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        s.insert(tmp);
    }
    cout << s.size() << endl;
}


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

int main(){
    string s;
    cin>>s;
    int n = s.size()-1;
    int ans =0;
    rep(i,n/2+1){
        if(s[i]!=s[n-i]) ans++;
    }
    cout << ans<<endl;
}


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

int main() {
    int N;
    cin >> N;
    int res = N; // max ans is N (all 1)
    for (int i = 0; i <= N; i++) {
      int t = i;
      int c = 0;
      while (t > 0) c += t % 6, t /= 6;
      t = N - i; // Calc left by power of 9
      while (t > 0) c += t % 9, t /= 9;
      if (res > c) res = c;
    }
    cout << res << endl;
}

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

struct StQuery
{
  StQuery() : m_nLeft(0), m_nRigt(0) { }

  int m_nLeft;
  int m_nRigt;
};

void fnInput(string& rsStr, vector<StQuery>& rvoQuery)
{
  int nStrSiz, nQuerySiz;
  cin >> nStrSiz >> nQuerySiz;
  rvoQuery.resize(nQuerySiz);

  cin >> rsStr;
  
  for (StQuery& roQuery : rvoQuery)
    cin >> roQuery.m_nLeft >> roQuery.m_nRigt;
}

void fnSubStrACCnt(string sStr, const vector<StQuery>& cnrvoQuery)
{
  const string cnsAC = "AC";
  int nACCnt = 0;
  vector<int> vnACCnt(sStr.size());

  for (int nBgn = 0; nBgn < vnACCnt.size() - 1; nBgn++)
  {
    if (sStr.substr(nBgn, 2) == cnsAC) nACCnt++;
    vnACCnt[ nBgn + 1 ] = nACCnt;
  }

  for (int i = 0; i < cnrvoQuery.size(); i++)
  {
    cout << vnACCnt[ cnrvoQuery[i].m_nRigt - 1 ] - vnACCnt[ cnrvoQuery[i].m_nLeft - 1];
    cout << endl; 
  }
}
 
int main()
{
  string sStr;
  vector<StQuery> voQuery;

  fnInput(sStr, voQuery);
  fnSubStrACCnt(sStr, voQuery);

  return 0;
}

Measured memory_bytes: 4536
#include<stdio.h>
int fib[45];
int main(){
    int i, n;
    fib[0]=1;
    fib[1]=1;
    scanf("%d", &n);
    for(i=2; i<=n; i++)fib[i]=fib[i-1]+fib[i-2];
    printf("%d\n", fib[n]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

long long *value, *weight, dp[5000][5000]={};

int main()
{
	fast;
	int x=0, y=0, temp1=-1, temp2=-1;
    string a, b;
    cin>>a>>b;
    int n,m;
    m = a.length();
    n = b.length();
    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
            if(a[i-1]==b[j-1]){
               dp[i][j] =dp[i-1][j-1]+1;
            }
            else{

                dp[i][j] =max(dp[i-1][j], dp[i][j-1]);
            }


        }
    }
    stack<char> s;
    int i=m,j=n;
    while(i>=1 && j>=1){
            //cout<<i<<j<<endl;
        if(a[i-1]==b[j-1]){
            s.push(a[i-1]);
            i--;j--;

        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    while(!s.empty()){
        cout<<s.top();
        s.pop();
    }
    return 0;
}



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

int main() {
  int h, n; cin >> h >> n;
  int sum = 0;
  rep(i,n) {
    int a; cin >> a;
    sum += a;
  }
  if (h <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main()
{
    int n, r;
    int p, c;
    r = 0;
    vector<int> card;
    vector<int> reserve;
    while (true) {
        if (r == 0) {
            cin >> n >> r;
            if (n == 0 && r == 0)
                break;
            for (int i = 0; i < n; i++) {
                card.push_back(i + 1);
            }
            continue;
        }
        cin >> p >> c;
        for (int i = n - p + 1; i < n; i++) {
            reserve.push_back(card.at(i));
        }
        for (int i = n - (p - 1) - c; i < n - (p - 1); i++) {
            reserve.push_back(card.at(i));
        }
        {
            int j = 0;
            for (int i = n - (p - 1) - c; i < n; i++) {
                card.at(i) = reserve.at(j);
                j++;
            }
        }
        reserve.clear();
        reserve.shrink_to_fit();
        r--;
        if (r == 0) {
            cout << card.at(n - 1) << endl;
            card.clear();
            card.shrink_to_fit();
        }
    }
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(void) {
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		if(x<y){
			printf("%d %d\n",x,y);
		}else {
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 1700
while True:
	l=list(map(int,input().split()))
	if l[0]==0 and l[1]==0:
		break
	else:
		print('#'*l[1])
		for i in range(l[0]-2):
			print('#'+('.'*(l[1]-2))+'#')
		print('#'*l[1])
		print('')
	


Measured memory_bytes: 5620
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int p[SIZE],c[SIZE];
int get_bit(int x,int v){return (x>>v)&1;}
int main(){
    int D,G;
    R(D,G);
    REP(i,D)R(p[i],c[i]);
    int an=1e5;
    REP(i,1<<D){
        int need=0;
        int ss=0;
        REP(j,D){
            if(get_bit(i,j)){
                need+=p[j];
                ss+=c[j]+100*(j+1)*p[j];
            }
        }
        for(int j=D-1;j>=0;j--){
            if(get_bit(i,j))continue;
            int score=(j+1)*100;
            if(ss>=G)break;
            int v=min((G-ss+score-1)/score,p[j]);
            ss+=score*v;
            need+=v;
        }
        if(ss>=G)an=min(an,need);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
int a[100010];
map<int, vector<int>> mp;
using P = tuple<int, int, int>;
vector<P> ps;
int ans[100010];

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N;
    REP(i, N) {
        cin >> a[i];
        mp[a[i]].push_back(i);
    }
    for (auto&& p : mp) {
        SORT(p.second);
        ps.emplace_back(p.first, p.second[0], p.second.size());
    }
    ps.emplace_back(0, -1, -N);
    SORT(ps); REV(ps);
    int cum = 0;
    int top = N;
    for (int i = 0; i < ps.size() - 1; i++) {
        int diff = get<0>(ps[i]) - get<0>(ps[i + 1]);
        int cnt = get<2>(ps[i]) + cum;
        CHMIN(top, get<1>(ps[i]));
        ans[top] += cnt * diff;
        cum += get<2>(ps[i]);
    }
    REP(i, N) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 16500
#!/usr/bin/env python3
import sys

YES = "Possible"  # type: str
NO = "Impossible"  # type: str

def solve(A: int, B: int):
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main(){
vector<int> A(5);
int count = 0;
int sub = 0;
for(int i = 0; i < 5 ; i++){
cin >> A[i];
while(A[i] % 10 != 0){
  A[i]++;
  count++;
}
//cout << A[i] << endl;
sub = max(count,sub);
count = 0;
}
int sum = 0;
for(int i = 0; i < 5; i++){
  sum +=A[i]; 
}
cout << sum - sub  << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int[] values = new int[a];
		for(int i=0 ; i<values.length ; i++) {
			values[i] = s.nextInt();
		}
		solve(values);
	}

	public static void solve(int[] values) {
		boolean flg = true;
		int cnt = 0;
		while(flg) {
			flg = false;
			for(int i = values.length - 1 ; i > 0 ; i--) {
				if(values[i] < values[i-1]) {
					int tmp = values[i];
					values[i] = values[i-1];
					values[i-1] = tmp;
					cnt++;
					flg = true;
				}
			}
		}
		String disp = "";
		for(int i=0 ; i<values.length ; i++) {
			disp += values[i];
			if(i+1<values.length)
				disp += " ";
		}
		System.out.print(disp+"\n");
		System.out.println(cnt);
	}
}

Measured memory_bytes: 18760
#include<iostream>
#include<algorithm>
#define LL long long 
int N,Z,W; 
int A[2010];
int main(){ 
  std::cin>>N>>Z>>W; 
  for(int i=0;i<N;i++){
    std::cin>>A[i];
  }
  LL a=std ::abs(A[N-1]-W);
  LL b=0;
  if(N!=1)b=std ::abs(A[N-2]-A[N-1]);
  std::cout<<(std::max(a,b))<<std::endl;
  return 0;
}

Measured memory_bytes: 256
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


# endregion


n = inp()
ans = pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)
ans%=mod
print(ans)


Measured memory_bytes: 68544
import numpy as np
from collections import Counter
from functools import reduce

# s = input()
N = int(input())

res = Counter()

res2 = 0
for _ in range(N):
    s = input()
    counter = Counter(s)
    code = ""
    for k in sorted(counter.keys()):
        code += str(k) + str(counter[k])
    res[code] += 1

for v in res.values():
    res2 += (v*(v-1)//2)

# print(res)

print(res2)


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

int main() {
  long long H;
  cin >> H;
  long long count2 = 0;
  long long ans = 1;
  while (H / 2 != 0) {
    count2++;
    H = H / 2;
  }
  for (long long i = 0; i < count2 + 1; i++) {
    ans = ans * 2;
  }
  ans = ans - 1;
  cout << ans << endl;
}

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

int main(){
	int a,b,n,cnt=0;
	cin >> a >> b >> n;
for(int i=a;i<=b;i++)
{
        if(i%n==0)
{
            cnt++;
        }    }	

    cout << cnt << endl;
	return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int k, x;
	cin >> k >> x;
	fori(k * 2 - 1) { cout << x - k + 1 + i << " "; }
	return 0;
}

Measured memory_bytes: 256