akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(H,W,N);
  vi a(N); in(a);
  vvi ans(H,vi(W));
  int idx = 0;
  rep(i,H)
    for(int j=(i%2?W-1:0),cnt=0;cnt<W;cnt++,j+=(i%2?-1:1)){
      if(a[idx] == 0) idx++;
      ans[i][j] = idx + 1 , a[idx]--;
    }
  each(x,ans)out(x);
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 100;
int N;
int B[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> B[i];

	vector<int> ans;

	list<int> x(B, B+N);
	for(int i=0; i<N; i++){
		//for(auto j=x.begin(); j!=x.end();) cout << *j << (++j==x.end()?'\n': ' ');
		int k=N-i;
		auto t=x.rend();
		for(auto j=x.rbegin(); j!=x.rend(); j++){
			if(*j==k){
				t = j;
				break;
			}
			//cout << k << " " << *j << endl;
			k--;
		}
		if(t==x.rend()) break;
		//cout << k << " " << *t << endl;
		if(t==x.rbegin()){
			//cout << "last " << *t << endl;
			x.pop_back();
		} else {
			t++;
			x.erase(t.base());
		}
		ans.push_back(k);
	}
	reverse(ans.begin(), ans.end());

	if(ans.size()==N){
		for(int i=0; i<N; i++){
			cout << ans[i] << endl;
		}
	} else {
		cout << -1 << endl;
	}

	return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define debug(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> ii;
typedef pair <ii, int> iii;

void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
  string s;
  cin >> s;
  if(s.back() == 's')
    s += "es";
  else
    s += "s";
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n,c,sum=0;
    cin>>n>>c;

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

    sort(a,a+n);

    for(int i=0;i<c;i++)
    {
        sum+=a[i];
    }

    cout<<sum;
}


Measured memory_bytes: 3632
S = list(input())
K = int(input())
n = len(S)

#(方針)Sの「先頭(の連続)」と「末尾(の連続)」が同じ文字ならそこも連続に
#2連続→1回で置換できる,3連続→1回で置換できる,　「N連続→N//2回で置換できる」

A = [] #連続でちぎるようのリスト
count = 1
for i in range(n): 
 if(i != 0):
  if(S[i]== tmp): count += 1
  if((S[i] != tmp)or(i == n-1)):
    A.append([tmp,count])
    count = 1
 tmp = S[i]
if(n == 1): A.append([S[0],1])

ans = 0
for i in range(len(A)):
  if((i != 0)and(i != len(A)-1)):
   ans += (A[i][1]//2)*K
     
if(len(A) == 1):
   ans += (A[0][1]*K)//2  
elif(A[0][0] == A[-1][0]):
   ans += (A[0][1]//2) + (A[-1][1]//2) + ((A[0][1]+A[-1][1])//2)*(K-1) #最初の二項 : 結合後の先頭と末尾分 
elif(A[0][0] != A[-1][0]):
   ans += (A[0][1]//2)*K  
   ans += (A[-1][1]//2)*K
print(ans)     

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct activity{
    int a,b,c;
};
int maxHappiness(vector<activity> arr,int n){
    int  dp[n+1][3];

    dp[1][0] = arr[1].a;
    dp[1][1] = arr[1].b;
    dp[1][2] = arr[1].c;

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

        dp[i][0] = arr[i].a + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i].b + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i].c + max(dp[i-1][0],dp[i-1][1]);
    }

    return max(dp[n][0], max(dp[n][1],dp[n][2]));
}

int main() {
    
    int n;
    cin>>n;
    vector<activity> arr(n+1);

    for(int i=1;i<=n;i++){
        cin>>arr[i].a;
        cin>>arr[i].b;
        cin>>arr[i].c;
    }

    cout<<maxHappiness(arr,n);
}


Measured memory_bytes: 6676
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace c
{
    class Program
    {
        public static readonly long INF = 999999999999;
        public static readonly long MOD = 1000000007;

        static void Main(string[] args)
        {
            var a = Scanner.IntScan();
            var res = 0;
            foreach(var b in a)
            {
                res += b;
            }
            if (res >= 22) Console.WriteLine("bust");
            else if (res <= 21) Console.WriteLine("win");
        }
    }

    public class Scanner
    {
        public static string[] Scan() => Console.ReadLine().Split(' ');
        public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse);
        public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse);
        public static string[][] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()).ToArray();
        public static int[][] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()).ToArray();
        public static long[][] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()).ToArray();

    }

    public class Ex
    {
        public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; }
        public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; }
        public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if ((N/10)%111 == 0)
    cout << "Yes" << endl;
  else if ((N%1000)%111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			@SuppressWarnings("unchecked")
			List<Path>[] pathLists = new List[n];
			IntStream.range(0, n).forEach(i -> pathLists[i] = new ArrayList<>());
			IntStream.range(0, n - 1).forEach(i -> {
				int a = scanner.nextInt() - 1, b = scanner.nextInt() - 1;
				long c = scanner.nextLong();
				pathLists[a].add(new Path(a, b, c));
				pathLists[b].add(new Path(b, a, c));
			});
			int q = scanner.nextInt(), k = scanner.nextInt() - 1;
			long[] distances = dijkstra(pathLists, k, n);
			IntStream.range(0, q).forEach(
					i -> System.out.println(distances[scanner.nextInt() - 1] + distances[scanner.nextInt() - 1]));
		}
	}

	/**
	 * @param pathLists ノード間の連結パス一覧の配列
	 * @param src       開始ノード
	 * @param n         ノードの数
	 * @return 開始ノードからの距離の配列
	 */
	private static long[] dijkstra(List<Path>[] pathLists, int src, int n) {
		long[] distances = new long[n];
		Arrays.fill(distances, Long.MAX_VALUE);
		// 最短距離が確定したかどうか
		boolean[] fixed = new boolean[n];
		Arrays.fill(fixed, false);
		// 出発地点までの距離を0とする
		distances[src] = 0L;
		Queue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(src, src, 0));
		while (!queue.isEmpty()) {
			int now = queue.poll().to;
			if (!fixed[now]) {
				fixed[now] = true;
				for (Path path : pathLists[now]) {
					if (!fixed[path.to] && distances[path.to] > distances[now] + path.cost) {
						distances[path.to] = distances[now] + path.cost;
						queue.add(new Path(path.to, path.to, distances[path.to]));
					}
				}
			}
		}
		return distances;
	}

	/**
	 * ノード間の一つのパスを表すクラス
	 */
	private static class Path implements Comparable<Path> {
		/** 開始ノード */
		@SuppressWarnings("unused")
		int from;
		/** 終了ノード */
		int to;
		/** 移動コスト */
		long cost;

		Path(int from, int to, long cost) {
			super();
			this.from = from;
			this.to = to;
			this.cost = cost;
		}

		@Override
		public int compareTo(Path path) {
			if (this.cost > path.cost) {
				return 1;
			} else if (this.cost == path.cost) {
				return 0;
			} else {
				return -1;
			}
		}
	}
}


Measured memory_bytes: 81932
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int d[111][111],n,m,a,b;
int main(){
	r(i,111)r(j,111)d[i][j]=(i==j?0:1e5);
	cin>>n>>m;
	while(m--){
		cin>>a>>b;
		d[a][b] = -1;
	}
	r(k,n)r(i,n)r(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	r(i,n){
		if(d[i][i]<0){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}


Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//??????????????°

		int num1;
		int num2;
		int goukei;

		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()){
			num1 = scan.nextInt();
			num2 = scan.nextInt();

			goukei = num1 + num2;

			String keta = String.valueOf(goukei);

			System.out.println(keta.length());
		}
	}

}

Measured memory_bytes: 26404
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    vector<int> s;
    cin >> n;

    int a;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        s.push_back(a);
        sum += a;
    }
    sort(s.begin(), s.end());

    if(sum % 10 != 0){
        printf("%d\n", sum);
        return 0;
    }

    for(int i = 0; i < n; i++){
        if(s[i] % 10 != 0){
            printf("%d\n", sum - s[i]);

            return 0;
        }
    }

    printf("0\n");

    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=[abs(a) for a in A]
count=0
ans=0
for i in range(n):ans+=abs(A[i])
if 0 in A:print(ans)
else:
    for i in range(n):
        if A[i]<0:count+=1
    if count%2==0:
        print(ans)
    else:
        print(ans-2*min(B))

Measured memory_bytes: 14412
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define vpll vector<pll>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q;

map<string, int> mapa;
void solve(){
	cin >> n;
	FOR(i, n){
		string temp;
		cin >> temp;
		mapa[temp]++;
	}
	cout << "AC x " << mapa["AC"] << '\n';
	cout << "WA x " << mapa["WA"] << '\n';
	cout << "TLE x " << mapa["TLE"] << '\n';
	cout << "RE x " << mapa["RE"] << '\n';
}


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

	q = 1;
	// cin >> q;

	while(q--)
		solve();
}	

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

using namespace std;

typedef long long LL;

const int N = 305;
const int Mod = 1e9 + 7;

int n, m, f[N][N], g[N][N]; char ch[N][N];

string s[N], a, b;

int Calc(int flag) {
    for (int i = n - 1; i >= 0; i --) {
        int res = 0;
        for (int j = n - 1; j >= 0; j --) {
            int d = n - 1 - j;
            if (i < d) break;
            res += a[i - d] == b[j];
        }
        for (int j = n - 1; j >= 0; j --) {
            int d = n - 1 - j;
            if (i < d) break;
            int x = n - 1 - (i-d), y = n - 1 - j;
            if (!flag) g[x][y] = res;
            else g[y][x] = res;
//        cout << x << ' ' <<y << ' ' << res << endl;
            res -= a[i - d] == b[j];
        }
    }
}

int Dp(int x, int y) {
    if (f[x][y] != -1) return f[x][y];
    if (x == n || y == n) return f[x][y] = 0;
    f[x][y] = g[x][y] + min(Dp(x+1, y), Dp(x, y+1));
    return f[x][y];
}

int main() {
//    freopen("in.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++)
            scanf(" %c", &ch[i][j]);
    for (int i = 1; i <= m; i ++) {
        for (int j = 1; j <= n; j ++)
            s[i] += ch[j][i];
    }
    int res = 0;
    for (int i = 2; i <= m; i ++) {
        a = s[i-1], b = s[i];
        memset(g, 0, sizeof(g));
        Calc(0);
        swap(a, b);
        Calc(1);


//    for (int i = 0; i < n; i ++)
//        for (int j = 0; j < n; j ++)
//            cout << i << ' ' << j << ' ' << g[i][j] << endl;

        memset(f, -1, sizeof(f));
//        cout << Calc(0, 0) << ' ' << Calc(2, 0) << ' ' << Dp(0, 0) << endl;
        res += Dp(0, 0);
    }
    cout << res << endl;
}


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

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

    map<string, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto p : mp)
    {
        ll x = p.second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,C;
    cin >> n >> C;
    vector<vector<ll>> a(35,vector<ll>(100005,0));
    ll s,t,c;
    rep(i,n){
        cin >> s >> t >> c;
        a[c-1][s]++;
        a[c-1][t]--;
    }
    vector<ll> b(100005,0);
    rep(i,C){
        rep(j,100002){
            if (a[i][j+1] > 0) b[j] += a[i][j+1];
            if (a[i][j] < 0) b[j] += a[i][j];
        }
    }
    rep(i,100002) b[i+1] += b[i];
    PRINT(*max_element(all(b)));
}


Measured memory_bytes: 29808
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int& x : a) cin >> x;

    int cnt = 0;
    for(int i=0; i<n; i++) {
        for(int j=n-1; j>i; j--) {
            if(a[j-1] > a[j]) {
                swap(a[j-1], a[j]);
                cnt++;
            }
        }
    }

    for(int i=0; i<n; i++) {
        cout << a[i] << (i != n-1 ? " " : "\n");
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
int dp[3][100001];
vector<int>G[100001];
typedef pair<int,int>P;
void bfs(int x){
	dp[0][x]=0;
	queue<P>que;
	que.push(P(x,0));
	while(que.empty()==false){
		P p=que.front();
		que.pop();
		int x=p.first;
		int y=p.second;
		//cout<<x<<" "<<y<<endl;
		REP(i,G[x].size()){
			int ne=G[x][i];
			int bb=(y+1)%3;
			if(dp[bb][ne]==1e6){
				dp[bb][ne]=y+1;
				que.push(P(ne,y+1));
			}
		}
	}
}

int main(){
	cin>>N>>M;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		G[a].push_back(b);
	}
	REP(i,3){
		REP(j,N){
			dp[i][j]=1e6;
		}
	}
	int S,T;
	cin>>S>>T;
	S--;
	T--;
	bfs(S);
	/*REP(i,5){
		cout<<"a"<<dp[0][i]<<endl;
	}*/
	if(dp[0][T]==1e6){
		cout<<-1<<endl;
	}else{
		cout<<dp[0][T]/3<<endl;
	}
}

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

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

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

ll calc(ll n) {
  ll num = 1;
  for (ll i = 1; i <= 2; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}

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

  vector<ll> v(n);
  rep(i, n) {
    cin >> v[i];
  }

  map<ll, ll> mm;

  rep(i, n) {
    mm[v[i]]++;
  }
  ll as = 0;
  for (auto x : mm) {
    if (x.second >= 2) {
      as += calc(x.second);
    }
  }

  rep(i, n) {
    ll aiu = mm[v[i]];
    if (aiu == 2) {
      cout << as - calc(2) << endl;
    } else {
      cout << as - calc(aiu) + calc(aiu - 1) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int N;

void dfs(std::string s, char mx)
{
    if(s.length() == N)
    {
        std::cout << s << "\n";
    }else
    {
        for(char c='a'; c<=mx; c++)
        {
            dfs(s + c, ((c==mx) ? (char)(mx + 1) : mx));
        }
    }
}

int main()
{
    std::cin >> N;
    dfs("", 'a');
    return 0;
}

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

string Alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int l = 52;

int main(void) {
    int n, x, d;
    int k[1000];
    string s;
    map<char, int> mp;
    for (int i = 0; i < 52; i++) mp[Alpha[i]] = i;

    while (1) {
        cin >> n;
        if (n == 0) break;

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

        for (int i = 0; i < s.size(); i++) {
            d = k[i % n];
            x = (mp[s[i]] + 52 - d) % l;
            cout << Alpha[x];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include<string>
#include<stack>
#include<queue>
#include<stdio.h>
#include <algorithm>
#include<set>
#include<vector>

#define _CRT_SECURE_NO_WARNINGS

using namespace std;
struct Human
{
	int age;
	double weight;
	char name[256];
};

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { // n が 0 になるまで
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	//cin>>N;
	// for (int i = 0; i < N; ++i) cin >> A[i];
	//while(true){break; ++res;}
	//cout << res << endl;
	//sort(a, a+N, greater<int>()) 大きい順ソート sort(v.begin(), v.end()); // vector
	//set<int>values; values.insert() values.size()
	//map<string,int>salary; salary["John"] = 1400;
	// string num = to_string(counter);

	int l[10000];
	int n[10000];
	int v[3];
	int a, b, c, d;
	int sum = 0;
	int count=0;
	int kari = 0;
	int w, h;
	int x, y, r;
	vector<string> lang;
	vector<int> data;
	string s; // s.size() to_string char string %s

	cin >> a >> b >> c;

	for (int i = a; i < b+1; i++)
	{
		if(c%i==0)
		{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <complex>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
typedef complex<double> xy_t;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;


ll length(ll s){
  ll n = 1;
  ll sum = 0;
  int digits = 1;  
  // n以上について10n未満の数を見ていく
  while(n <= s){
    ll L = min(10 * n - 1, s);
    ll	c3  = L / 3 - (n - 1) / 3;
    ll	c5  = L / 5 - (n - 1) / 5;
    ll	c15 = L / 15- (n - 1) / 15;
    ll rest = L - n - c3 - c5 + c15 + 1;
    sum += rest * digits;
    sum += (c3 + c5) * 4;
    n *= 10;
    digits++;
  }
  return sum;
}

int main(){
  ll s;
  cin >> s;
  
  ll lb = 0, ub = s;

  while(ub - lb > 1){
    ll mb = (ub + lb) / 2;
    if(length(mb) < s){
      lb = mb;
    }else{
      ub = mb;
    }
  }
  
  ostringstream out;
  ll offset = s - 1 - length(lb);
  for(ll i = lb + 1; i < lb + 30; i++){
    if(i % 3 != 0 && i % 5 != 0) out << i;
    if(i % 3 == 0) out << "Fizz";
    if(i % 5 == 0) out << "Buzz";
  }
  cout << out.str().substr(offset, 20) << endl;
  
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    bool ok = true;

    rep(i,n){
        if(a[i]%2==0){
            if(a[i]%5!=0){
                if(a[i]%3!=0){
                    ok = false;
                }
            }
        }
    }
    if(ok){
        puts("APPROVED");
    }else{
        puts("DENIED");
    }
}

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

int main() {
  int M, T, P, R;
  while(cin >> M >> T >> P >> R){
    if(M==0) return 0;
    int solved[T][P] = {};
    vector<vector<int>> team(T, vector<int>(3)); // 0:solved, 1:time, 2:team number
    rep(i, T) team[i][2] = -i-1;
    rep(i, R){
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--;p--;
      if(j==0){
        if(solved[t][p]<0) team[t][1] += m + 20*abs(solved[t][p]);
        else{
          team[t][1] += m;
        }
        team[t][0] -= 1;
      }
      else solved[t][p] -= 1;
    }
    sort(team.begin(), team.end());
    rep(i, T){
      cout<<-team[i][2];
      if(i!=T-1){
        if(team[i][0]==team[i+1][0] && team[i][1]==team[i+1][1]) cout << "=";
        else cout<<",";
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
#define rep(i,n) for(int i = 0; i < n; i++)

int main(void) {
  char S[3][11];
  scanf("%s %s %s", S[0], S[1], S[2]);

  rep(i, 3) {
    S[i][0] = S[i][0] - 'a' + 'A';
  }
  printf("%c%c%c\n", S[0][0], S[1][0], S[2][0]);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
	int a,b,c,x,y,i,m,mini=2147483647;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	for(i=0; i<=100000; i++){
		if(i>=x && i>=y){
			m=i*2*c;
			if(mini>m){
				mini=m;
			}
			break;
		}
		if(i<x && i>=y){
			m=i*2*c+(x-i)*a;
			if(mini>m){
				mini=m;
			}
		}
		if(i>=x && i<y){
			m=i*2*c+(y-i)*b;
			if(mini>m){
				mini=m;
			}
		}
		if(i<x && i<y){
			m=i*2*c+(x-i)*a+(y-i)*b;
			if(mini>m){
				mini=m;
			}
		}
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var k = Int32.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var r = 0; var s = k;
        while (s<= l[1])
        {
            r++;
            s = k * r;
            if (s >= l[0] && s <= l[1])
            {
                Console.WriteLine("OK");
                return;
            }
        }
        Console.WriteLine("NG");
    }
}


Measured memory_bytes: 28224
#include <stdio.h>
#include <stdbool.h>

//答えの配列、さいころの目標の目、それの順列セット、p,1,サイコロの目の合計、順列の個数(まぁ720)、サイコロが完成したかどうか
char ans[30005];
int t[7]={0};
int sets[1000][6];
int p,q,tsum,countset,countnum;
bool completed;

//解く、枝刈り、完成したかの判別、順列セット作成
void solve(int nu,int nn,int ns,int ne,int nw,int nin,int now);
bool cut(int inv1,int inv2,int y1,int y2,int z1,int z2);
bool answercheck(int t1,int t2,int t3,int t4,int t5,int t6);
void set();

int main(void){
  int i;
  while(1){
    tsum=0;
    for(i=1;i<=6;i++){
      scanf("%d",&t[i]);
      tsum+=t[i];
    }
    if(tsum==0)break;
    scanf("%d %d",&p,&q);
    countset=0;
    countnum=0;
    set();
    completed=0;
    solve(0,0,0,0,0,0,0);
    //printf("%d\n",countnum);
    if(completed)for(i=p;i<=q;i++)printf("%c",ans[i]);
    else printf("impossible");
    printf("\n");
  }
  return 0;
}

//下、北、南、東、西、インバース（上）、現在の手数
void solve(int nu,int nn,int ns,int ne,int nw,int nin,int now){
 countnum++;
  //printf("%d\n",now);
  //完成したらおわり
  if(completed)return;
  //手数が目標に達したらチェック
  if(now==tsum){
    //printf("%d %d %d %d %d %d\n",nu,nn,ns,ne,nw,nin);
    if(answercheck(nu,nn,ns,ne,nw,nin))completed=1;
    return;
  }
  //これ以上探索しても無駄なら枝刈り
  if(cut(nu,nin,nn,ns,ne,nw)==0){
    // printf("%d %d %d %d %d %d return \n",nu,nn,ns,ne,nw,nin);
    return;
  }
  //ENSWの順番で探索、完成してたらおわり
  ans[now+1]='E';
  solve(ne+1,nn,ns,nin,nu,nw,now+1);
  if(completed)return;
  ans[now+1]='N';
  solve(nn+1,nin,nu,ne,nw,ns,now+1);
  if(completed)return;
  ans[now+1]='S';
  solve(ns+1,nu,nin,ne,nw,nn,now+1);
  if(completed)return;
  ans[now+1]='W';
  solve(nw+1,nn,ns,nu,nin,ne,now+1);
}

//上下ペア、側面２つ
bool cut(int inv1,int inv2,int y1,int y2,int z1,int z2){
  int i,needinv,needy,needz;
  int inv=inv1+inv2,y=y1+y2,z=z1+z2; 
  for(i=0;i<countset;i++){
    needinv = sets[i][0]+sets[i][1]-inv;
    needy = sets[i][2]+sets[i][3]-y;
    needz = sets[i][4]+sets[i][5]-z;
    if(inv1>sets[i][0]||inv2>sets[i][1]||y1>sets[i][2]||y2>sets[i][3]||z1>sets[i][4]||z2>sets[i][5])continue;
    //if(needinv<0||needy<0||needz<0)continue;
    if((needinv<=needy+needz)&&(needy-1<=needinv+needz)&&(needz-1<=needinv+needy))return 1;
  }
  return 0;
}
bool answercheck(int t1,int t2,int t3,int t4,int t5,int t6){
  int i;
  for(i=0;i<countset;i++){
    if(sets[i][0]==t1&&sets[i][1]==t2&&sets[i][2]==t3&&sets[i][3]==t4&&sets[i][4]==t5&&sets[i][5]==t6)return 1;  
  }
  return 0;
}

//6重ループをまわしてつくる。
void set(){
  int a,b,c,d,e,f;
  for(a=1;a<=6;a++){
    for(b=1;b<=6;b++){
      if(a==b)continue;
      for(c=1;c<=6;c++){
	if(a==c||b==c)continue;
	for(d=1;d<=6;d++){
	  if(a==d||b==d||c==d)continue;
	  for(e=1;e<=6;e++){
	    if(a==e||b==e||c==e||d==e)continue;
	    for(f=1;f<=6;f++){
	      if(a==f||b==f||c==f||d==f||e==f)continue;
	      sets[countset][0]=t[a];
	      sets[countset][1]=t[b];
	      sets[countset][2]=t[c];
	      sets[countset][3]=t[d];
	      sets[countset][4]=t[e];
	      sets[countset][5]=t[f];
	      countset++;
	    }
	  }
	}
      }
    }
  }
  //printf("%d\n",countset);
}



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

using namespace std;

int main() {
	int n, k;

	cin >> n >> k;

	vector <int> p(n);

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

	sort(p.begin(), p.end());

	int ans = 0;
	
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}

	cout << ans << "\n";

	return 0;
}

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

const int NIL = -1;

struct Node{
    int key;
    Node *left, *right;
    Node(int v = NIL) : key(v) {
        left = right = nullptr;
    }
};

void insert(Node* node, int key)
{
    if(node->key > key){
        if(node->left)
        {
            insert(node->left, key);
        }
        else{
            Node* newnode = new Node(key);
            node->left = newnode;
        }
    }
    else if(node->key < key){
        if(node->right){
            insert(node->right, key);
        }
        else{
            Node* newnode = new Node(key);
            node->right = newnode;
        }
    }
}

struct PrintTree
{
    void preorder(Node* node)
    {
        if(node){
            cout << " " << node->key;
            preorder(node->left);
            preorder(node->right);
        }
    }

    void inorder(Node* node)
    {
        if(node){
            inorder(node->left);
            cout << " " << node->key;
            inorder(node->right);
        }
    }

    void printTree(Node* root)
    {
        // inorder
        inorder(root);
        cout << endl;
        // preorder
        preorder(root);
        cout << endl;
    }
};

void find(Node* node, int key)
{
    if(!node){
        cout << "no" << endl;
        return;
    }
    if(node->key == key)
    {
        cout << "yes" << endl;
    }
    else if(node->key < key)
    {
        find(node->right, key);
    }
    else{
        find(node->left, key);
    }
}

int main()
{
    int n, key;
    char command[10];
    Node* root = nullptr;
    PrintTree print;
    cin >> n;
    for(int i=0;i<n;++i)
    {
        cin >> command;
        if(command[0] == 'i')
        {
            if(root){
                cin >> key;
                insert(root, key);
            }
            else{
                cin >> key;
                root = new Node(key);
            }
        }
        else if(command[0] == 'p'){
            print.printTree(root);
        }
        else{
            cin >> key;
            find(root, key);
        }
    }
}



Measured memory_bytes: 15492
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;


int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    char ch;
    cin>>ch;
    if(ch>='a'&&ch<='z')
    {
        cout<<"a"<<endl;
    }
    else
    {
        cout<<"A"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,a,b,x,cnt=0;
    vector<intf> su(1,0);
    cin >> n >>a >>b;
    rep(i,n+1){
        x = i%10 + (i%100)/10 + (i%1000)/100 + (i%10000)/1000 + i/10000;
        if(a<=x&&b>=x){
            su.emplace_back(i);
        }
    }
    cout << accumulate(su.begin(),su.end(),0) <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
int a[maxn],b[maxn];
int s[maxn]; 
signed main()
{
	ios::sync_with_stdio(0);
	int t=1;
	string s;
	cin >> s;
	if(s[1]=='B')
		cout << "ARC";
	else
		cout << "ABC";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

queue<ll> q;
int K;
ll bfs(){
  int count = 9;
  while(1){
    ll y = q.front(); q.pop();
    ll b = y%10;
    if(b!=0){
      ll t = y *10 + (b-1);
      ++count;
      if(count==K){ return t;}
      else{ q.push(t);}
    }
    ll t = y *10 + b;
    ++count;
    if(count==K){ return t;}   
    else{ q.push(t); }
    if(b!=9){
      ll t = y*10 + (b+1);
      ++count;
      if(count==K){ return t;}
      else{ q.push(t); }
    }
  }
}

int main(){
  cin>>K;
  if(K<=9){ cout << K<<"\n";}
  else{
    for(ll i=1;i<=9;++i){
      q.push(i);
    }
    cout << bfs() << "\n";
  }
}



Measured memory_bytes: 768
import java.util.Scanner;
 
 
public class Main{
     
	
    public static void main(String[] args){
    	
    	final Scanner sc = new Scanner(System.in);
    	
    	final int N = sc.nextInt();
    	
    	int[] sum = new int[100003];
    	
    	for(int i = 0; i < N; i++){
    		final int a = sc.nextInt();
    		final int b = sc.nextInt();
    		
    		sum[0]++;
    		sum[a]--;
    		sum[b+1]++;
    	}
    	
    	for(int i = 1; i <= 100002; i++){
    		sum[i] += sum[i-1];
    	}
    	/*
    	for(int i = 2; i <= N + 1; i++){
    		System.out.print(sum[i] + " ");
    	}
    	System.out.println();
    	*/
    	int max = 0;
    	for(int i = 2; i <= N + 1; i++){
    		//System.out.print(sum[i] + " ");
    		//System.out.print((N + 1 - i) + " ");
    		if(sum[i] <= (N + 1 - i)){
    			max = Math.max(max, i - 1);
    		}
    	}
    	
    	System.out.println(max);
    }
     
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int H, W, N;
  cin >> H >> W >> N;
  set<pair<int, int>> se;
  vector<pair<int, int>> vp;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    se.emplace(a, b);
    vp.emplace_back(a, b);
  }
  vi64 ans(10);
  set<pair<int, int>> already;
  each(s, vp) {
    int a, b;
    tie(a, b) = s;
    for (int i = -1; i <= 1; i++) {
      for (int j = -1; j <= 1; j++) {
        int ca = a + i;
        int cb = b + j;
        if (ca <= 0 || ca >= H - 1 || cb <= 0 || cb >= W - 1) continue;
        if (already.count(make_pair(ca, cb))) continue;
        int cnt = 0;
        for (int k = -1; k <= 1; k++) {
          for (int l = -1; l <= 1; l++) {
            int x = ca + k;
            int y = cb + l;
            if (se.count(make_pair(x, y))) cnt++;
          }
        }
        ans[cnt]++;
        already.emplace(ca, cb);
      }
    }
  }
  ans[0] = (i64) (H - 2) * (W - 2);
  reps(i, 9) ans[0] -= ans[i];
  rep(i, 10) cout << ans[i] << endl;
}


Measured memory_bytes: 47988
#include<bits/stdc++.h>
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.second < b.second);
}
int main()
{
    FAST();
    ll i,j,k,n,l,x,y,v,w,T;
   // vector<ll>v;
    map<ll,ll>m;
    string s;
    cin>>x>>v>>y>>w>>T;
    double f,g,h,t;
    ll a=abs(x-y);
    f=(w*a*1.0)/((v-w)*1.0);
    t=f/(w*1.0);
    h=T*1.0;
    if(t<=h&&t>0)
    {
        cout<<"YES"<<endl;
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3636
import math
N = int(input())
table = [list(map(int,input().split())) for i in range(N-1)]
for i in range(1,N+1):
    time = 0
    for j in range(i,N):
        if time < table[j-1][1]:
            time = table[j-1][1]+table[j-1][0]
        else:
            time = math.ceil((time-table[j-1][1])/table[j-1][2])*table[j-1][2]+table[j-1][1]+table[j-1][0]
    print(time)

Measured memory_bytes: 3188
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
vector<int> dx = { 0, 1, 1, 0, -1, -1, 0 };
vector<vector<int> > dy = {
	{ 1, 0, -1, -1, -1, 0, 0 },
	{ 1, 1, 0, -1, 0, 1, 0 }
};
int sx, sy, gx, gy, lx, ly, n;
int main() {
	cin >> sx >> sy >> gx >> gy >> n;
	vector<int> ex(n), ey(n);
	for (int i = 0; i < n; i++) cin >> ex[i] >> ey[i];
	cin >> lx >> ly;
	vector<vector<bool> > ok(ly * 2 + 1, vector<bool>(lx * 2 + 1, true));
	for (int i = 0; i < n; i++) ok[ey[i] + ly][ex[i] + lx] = false;
	vector<vector<vector<int> > > dist(ly * 2 + 1, vector<vector<int> >(lx * 2 + 1, vector<int>(6, 999999999))); dist[sy + ly][sx + lx][0] = 0;
	priority_queue<vector<int> > que; que.push({ 0, sx, sy, 0 });
	while (!que.empty()) {
		vector<int> u = que.top(); que.pop();
		int fx = u[1], fy = u[2], ft = u[3], cur = dist[fy + ly][fx + lx][ft];
		for (int i = 0; i < 7; i++) {
			int tx = fx + dx[i], ty = fy + dy[abs(fx) % 2][i], tt = (ft + 1) % 6;
			int cost = (abs(fx * fy * ft) % 6 == i ? 0 : 1);
			if (abs(tx) <= lx && abs(ty) <= ly && ok[ty + ly][tx + lx] && dist[ty + ly][tx + lx][tt] > cur + cost) {
				dist[ty + ly][tx + lx][tt] = cur + cost;
				que.push({ -dist[ty + ly][tx + lx][tt], tx, ty, tt });
			}
		}
	}
	int ret = 999999999;
	for (int i = 0; i < 6; i++) ret = min(ret, dist[gy + ly][gx + lx][i]);
	cout << (ret != 999999999 ? ret : -1) << endl;
	return 0;
}

Measured memory_bytes: 5460
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    ll N,M;
    cin >> N >> M;
    ll a[M];
    for(ll i=0;i<M;i++){
        cin >> a[i];
    }
    sort(a,a+M);
    ll sa[M];
    for(ll i=0;i<M-1;i++){
        sa[i] = abs(a[i]-a[i+1]);
    }
    ll sum = 0;
    sort(sa,sa+M);
    for(ll i=0;i<M-N;i++){
        sum = sum +sa[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nab = Input.ar;
        var abc = Input.ar2D(nab[0]);
        const int NUM = 401;
        var dp = new int[nab[0] + 1, NUM, NUM];
        for (var i = 0; i <= nab[0]; i++)
            for (var j = 0; j <NUM; j++)
                for (var k = 0; k < NUM; k++)
                    dp[i, j, k] = int.MaxValue / 2;
        dp[0, 0, 0] = 0;
        for (var i = 1; i <= nab[0]; i++)
            for (var j = 0; j < NUM; j++)
                for (var k = 0; k < NUM; k++)
                    if (j - abc[i - 1][0] >= 0 && k - abc[i - 1][1] >= 0)
                        dp[i, j, k] = Min(dp[i - 1, j, k], dp[i - 1, j - abc[i - 1][0], k - abc[i - 1][1]] + abc[i - 1][2]);
                    else dp[i, j, k] = dp[i - 1, j, k];
        var min = int.MaxValue;
        for (var i = 0; i < NUM; i++)
            for (var j = 0; j < NUM; j++)
                if (i!=0&&j!=0&&i * nab[2] == j * nab[1])
                    min = Min(min, dp[nab[0], i, j]);
        WriteLine(min > 4000 ? -1 : min);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

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

#define int long long

using namespace std;

pair <pair <int, int>, int> a[200041];
set <int> st, st1;	
int n;

bool check (int i, int j) {
	int x = a[i].second;
	if (x > n) x -= n;
	int y = a[j].second;
	if (y > n) y -= n;
	if (x == y) return 1;
	else return 0;
}

 main () {
	cin >> n;
	int asd = 1e9;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i].first.first >> a[i + n].first.first;
		a[i].first.second = i;
		a[i + n].first.second = i;
		a[i].second = i;                                                               	
		a[i + n].second = i + n;
	}
	sort (a + 1, a + n + n + 1);
	int ans = 0;
	for (int i = 1;i <= n;i ++) {
		int x = a[i].second;
		if (x <= n) st1.insert (1);
		else {	
			st1.insert (2);
			x -= n;
		}
		st.insert (x);
		ans += a[i].first.first;
	}
	int nxt = n + 1;
	if (check (n, n + 1)) nxt = n + 2;
	int nxt1 = n + 1;
	if (check (n - 1, n + 1)) nxt1 = n + 2;
	if (st.size () < n) {
		cout << ans;
	}
	else {
		if (st1.size () == 1) {
			cout << ans;
		}
		else cout << min (ans - a[n].first.first + a[nxt].first.first, ans - a[n - 1].first.first + a[nxt1].first.first);
	}
	return 0;
}

Measured memory_bytes: 9600
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	int f=0,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int cnt[MAXN+5];
int main(){
	int n=read(),k=read(),Q=read();
	for(int q=1;q<=Q;q++){
		int a=read();
		cnt[a]++;
	}
	for(int i=1;i<=n;i++){
		if(Q-cnt[i]>=k)
			puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 1024