akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

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

using namespace std;

// x^n in mod
ll modpow(ll x, ll n, ll mod){
  if(n==0) return 1;

  if(n%2==0){
    return modpow(x*x%mod, n/2, mod) % mod;
  }else{
    return x * modpow(x, (n-1), mod) % mod;
  }
}

int main(){
  string s;cin>>s;
  ll a_counter[100000];
  ll c_counter[100000];
  ll a_count=0;
  ll c_count=0;
  a_counter[0]=0;
  if(s[0]=='A')a_counter[0]=1;
  if(s[0]=='?'){a_counter[0]=1;a_count++;}
  c_counter[s.size()-1]=0;
  if(s[s.size()-1]=='C')c_counter[s.size()-1]=1;
  if(s[s.size()-1]=='?'){c_counter[s.size()-1]=1;c_count++;}

  for(int i=1; i<s.size()-1; i++){
    if(s[i]=='A'){
      a_counter[i] = ( a_counter[i-1] + modpow(3, a_count, MOD) )%MOD;
    }else if(s[i]=='?'){
      a_counter[i] = ( a_counter[i-1]*3 + modpow(3, a_count, MOD) )%MOD;
      a_count++;
    }else{
      a_counter[i]=a_counter[i-1];
    }


    if(s[s.size()-1-i]=='C'){
      c_counter[s.size()-1-i] = ( c_counter[s.size()-i] + modpow(3, c_count, MOD) )%MOD;
    }else if(s[s.size()-1-i]=='?'){
      c_counter[s.size()-1-i] = ( c_counter[s.size()-i]*3 + modpow(3, c_count, MOD) )%MOD;
      c_count++;
    }else{
      c_counter[s.size()-1-i] = c_counter[s.size()-i];
    }
  }

  ll result=0;
  for(int i=1; i<s.size()-1; i++){
    if(s[i]=='B' || s[i]=='?'){
//cout<<a_counter[i-1]<<'*'<<c_counter[i+1]<<'='<<a_counter[i-1]*c_counter[i+1]%MOD<<endl;
      result += a_counter[i-1]*c_counter[i+1]%MOD;
    }
  }

  cout<<result%MOD<<endl;

//rep(i,s.size())cout<<a_counter[i]<<' ';cout<<endl;
//rep(i,s.size())cout<<c_counter[i]<<' ';cout<<endl;

  return 0;
}

Measured memory_bytes: 2048
from sys import stdin


def btc_to_jpy(btc):
    return btc * 380000


def main():
    input_line_list = stdin.readlines()
    n = input_line_list[0]
    x_u_list = input_line_list[1:]
    otoshidama_sum = 0.0
    for x_u in x_u_list:
        x, u = x_u.split()
        x_float = float(x)
        #print(x_float, u)
        if u == 'BTC':
            jpy = btc_to_jpy(x_float)
        else:
            jpy = x_float
        otoshidama_sum += jpy
    print(otoshidama_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG


struct Matrix {
  int numOfRow;
  int numOfColumn;
};


struct MinMatrix {
  int minMultiply;
  int numOfRow;
  int numOfColumn;
};


const int kMaxSize = 100;
const int kInvalid = -1;
MinMatrix minArrays[kMaxSize][kMaxSize];


bool isValid(MinMatrix mtx)
{
  return mtx.minMultiply != kInvalid ? true : false;
}

MinMatrix getMinScalarMultiply(const Matrix matrices[], int start, int end)
{
  DPRINTF("start %d  end %d\n", start, end);

  assert(start <= end);

  if (isValid(minArrays[start][end]))
    return minArrays[start][end];

  if (start + 1 == end)
  {
    MinMatrix mtx;

    mtx.minMultiply = 0;
    mtx.numOfRow = matrices[start].numOfRow;
    mtx.numOfColumn = matrices[start].numOfColumn;

    minArrays[start][end] = mtx;

    return minArrays[start][end];
  }


  MinMatrix minMtx;
  minMtx.minMultiply = INT_MAX;

  for (int i = start + 1; i < end; i++)
  {
    MinMatrix mtx0 = getMinScalarMultiply(matrices, start, i);
    MinMatrix mtx1 = getMinScalarMultiply(matrices, i, end);

    MinMatrix mtx;

    mtx.minMultiply = mtx0.minMultiply + mtx1.minMultiply + mtx0.numOfRow * mtx0.numOfColumn * mtx1.numOfColumn;
    mtx.numOfRow = mtx0.numOfRow;
    mtx.numOfColumn = mtx1.numOfColumn;

#if DEBUG
    DPRINTF("start %d  end %d  i %d : mtx.minMultiply %d  min.minMultiply %d\n",
        start, end, i, mtx.minMultiply, minMtx.minMultiply);
    DPRINTF("  mtx0.minMultiply %d  mtx1.minMultiply %d\n",
        mtx0.minMultiply, mtx1.minMultiply);
#endif

    if (minMtx.minMultiply > mtx.minMultiply)
      minMtx = mtx;
  }

  DPRINTF("start %d  end %d  multiply %d\n", start, end, minMtx.minMultiply);

  minArrays[start][end] = minMtx;

  return minArrays[start][end];
}


int calcMinScalarMultiply(const Matrix matrices[], int num)
{
  if (num <= 1)
    return 0;

  MinMatrix mtx = getMinScalarMultiply(matrices, 0, num);

  return mtx.minMultiply;
}


int main() {

  // init
  for (int i = 0; i < kMaxSize; i++)
    for (int j = 0; j < kMaxSize; j++)
      minArrays[i][j].minMultiply = kInvalid;

  int numOfMatrix;
  cin >> numOfMatrix; cin.ignore();

  Matrix  matrices[numOfMatrix];
  for (int i = 0; i < numOfMatrix; i++)
  {
    cin >> matrices[i].numOfRow; cin >> matrices[i].numOfColumn; cin.ignore();
  }

#if DEBUG
  for (int i = 0; i < numOfMatrix; i++)
  {
    DPRINTF("Matrix %d: %d %d\n", i, matrices[i].numOfRow, matrices[i].numOfColumn);
  }
#endif

  cout << calcMinScalarMultiply(matrices, numOfMatrix) << endl;

  return 0;
}




Measured memory_bytes: 3220
N = int(input())
h = list(map(int,input().split()))
count = 0

def devide(h):
    global count
    while 0 not in h:
        for i in range(len(h)):
            h[i] -= 1
        count += 1
    h2 = []
    h3 = []
    for i in h:
        if i == 0:
            h2.append(h3)
            h3 = []
        if i != 0:
            h3.append(i)
    h2.append(h3)

    for i in h2:
        if i == []:
            continue
        else:
            devide(i)
            
devide(h)
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, q; cin >> a >> b >> q;
	vector<ll> s(a+2);
	vector<ll> t(b+2);
	s.front() = t.front() = -BOUND;
	s.back() = t.back() = BOUND;
	for( int i = 1; i < a+1; ++i ){
		cin >> s[i];
	}
	for( int i = 1; i < b+1; ++i ){
		cin >> t[i];
	}
	for( int i = 0; i < q; ++i ){
		ll v; cin >> v;
		ll sb = upper_bound( s.begin(), s.end(), v ) - s.begin();
		ll sa = sb-1;
		sb = s[sb]; sa = s[sa];
		ll td = upper_bound( t.begin(), t.end(), v ) - t.begin();
		ll tc = td-1;
		td = t[td]; tc = t[tc];
		ll ans = min({ abs(sa-v)+abs(tc-sa), abs(sa-v)+abs(td-sa), abs(sb-v)+abs(tc-sb), abs(sb-v)+abs(td-sb),  abs(tc-v)+abs(sa-tc), abs(tc-v)+abs(sb-tc), abs(td-v)+abs(sa-td), abs(td-v)+abs(sb-td) });
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
	int n,x,ctr;
	cin >> n >> x;
	while(n!=0||x!=0){
		ctr = 0;
		for(int i=1;i<=n-2;i++){
			for(int j=i+1;j<=n-1;j++){
				if(x-i-j>j && x-i-j<=n){
					ctr++;
				}
			}
		}
		cout << ctr << endl;
		cin >> n >> x;
	}
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(void)
{
  char S[4];
  char remain;
  int min;
  cin >> S;
  for(int i = 0; i < 3; i++)
  {
    min = i;
    for(int j = i+1; j < 4; j++)
      if(S[min] > S[j])
        min = j;
    remain = S[i];
    S[i] = S[min];
    S[min] = remain;
  }
  if((S[0] == S[1]) && (S[2] == S[3]) && (S[1] != S[2]))
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
//region Template
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
template<typename T> void debug_out(string name, T arg) { cerr<<name<<"="<<arg<<endl; }
template<typename T1, typename... T2> void debug_out(string name, T1 arg, T2... args) {
    cerr<<name.substr(0, name.find(','))<<"="<<arg<<", ";
    debug_out(name.substr(name.find(',') + 1), args...); }
#define debug(...) debug_out(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion



int main() {
    FASTIO

    int n; cin>>n;
    vi a = READ<int>(n-1);
    map<int,int> cnt;

    for(int x:a) {
        cnt[x]++;
    }

    FOR(i,n)
    cout<<cnt[i+1]<<endl;




}

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

int main() {
	long int N, A, B;
	cin >> N >> A >> B;
	if(A > B || N == 0){
		cout << 0 << endl;
		return 0;
	}
	if(A != B && N == 1){
		cout << 0 << endl;
		return 0;
	}
	if(A == B || N == 2){
		cout << 1 << endl;
		return 0;
	}
	cout << (B*(N-1)+A) - (A*(N-1)+B) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int INF = 1<<30;
constexpr ll LINF = 1LL<<58;
constexpr int mod = 1000000007;

int dp[100010];

int main(){
    int n;
    cin >> n;
    int H[100010];
    for (int i = 2; i <= n; i++) dp[i] = INF;
    for (int i = 0; i < n; i++) cin >> H[i + 1];
    for (int i = 1; i < n; i++) {
        chmin(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
            NegaPosi ans = NegaPosi.Zero;

            if(inpt[0]>0&&inpt[1]>0) {
                ans = NegaPosi.Positive;
            } else if(inpt[0]<0&&inpt[1]<0) {
                if((inpt[1]-inpt[0]+1)%2==0) {
                    ans = NegaPosi.Positive;
                } else {
                    ans = NegaPosi.Negative;
                }
            }

            // a，a+1，…，b すべての積が、正ならば Positive を、負ならば Negative を、0 ならば Zero を出力せよ。
            string tmp = (ans==NegaPosi.Positive)?"Positive":(ans==NegaPosi.Negative?"Negative":"Zero");
            Console.WriteLine(tmp);

        }

        private enum NegaPosi {
            Negative,
            Positive,
            Zero
        }

        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




-3 -1







";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int a[N];

int main () {
    to_pray();

    int n;
    cin >> n;

    int ans = 0;

    for (int i = 1; i <= n; ++ i)
        cin >> a[i];

    for (int i = 1; i <= n; ++ i) {
        if (i == 1)
            ans += a[i];
        else
            ans += max(0, a[i] - a[i - 1]);
    }

    cout << ans;

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math")
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define reset(x, y) memset(x, y, sizeof(x))
#define ii pair<int, int>
#define task ""
ll gcd(ll a, ll b)
{
    return b ? gcd(b, a % b) : a;
}
const long long oo = 1e9 + 7;
long long dp[10000][100][2];
string k,a;
int d;
vector<int> digit;
void get(string s, vector<int> &digit)
{
    for (int i = 0; i < s.size(); ++i)
        digit.push_back(s[i] - '0');
}
long long calc(int idx, int muda, int tight)
{
    if (idx == digit.size())
       { if (muda == 0)
            return 1;
            return 0;
       }
    if (dp[idx][muda][tight] != -1)
        return dp[idx][muda][tight];
    long long res = 0;
    int lmt = (tight) ? digit[idx] : 9;
    for (int i = 0; i <= lmt; ++i)
    {
        int newtight = (digit[idx] == i) ? tight : 0;
        res = (res + calc(idx + 1, (muda + i) % d, newtight)) % oo;
    }
    dp[idx][muda][tight] = res;
    return res;
}
long long solve(string s)
{
    digit.clear();
    reset(dp,-1);
    get(s, digit);
    return calc(0, 0, 1);
}
///----------------------------------------------------------------------------------///
int main()
{
    fast;
    cin >> k;
    cin >> d;
    a="0";
    cout << 1LL * ((solve(k)-1+oo)%oo) << "\n";
}

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


int N;
int main(){
    cin >> N;
    int num[N];
    int max=-1;
    for(int i = 0;i < N; i++){
        cin >> num[i];
    }

    for(int i = 0;i < N; i++){
        for(int j = i;j < N;j++){
            if(max < abs(num[i]-num[j]))
                max = abs(num[i]-num[j]);
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int ab(int a) { if (a > 0) { return a; } else { return -a; } }

int main() {
	int N, Z, W, a[2000];
	int c[2001], A[2001][2], A_max[2000], A_min[2000];
	scanf("%d %d %d", &N, &Z, &W);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	c[0] = W;
	for (int i = 0; i < N; i++) {
		c[i + 1] = a[i];
	}

	A[N - 1][0] = ab(c[N - 1] - c[N]);
	A[N - 1][1] = ab(c[N - 1] - c[N]);

	A_max[N - 1] = A[N - 1][1];
	A_min[N - 1] = A[N - 1][1];

	for (int i = N - 2; i >= 0; i--) {
		A[i][0] = max(A_max[i+1], ab(c[i] - c[N]));
		A[i][1] = min(A_min[i+1], ab(c[i] - c[N]));

		A_max[i] = max(A[i + 1][1], A_max[i + 1]);
		A_min[i] = min(A[i + 1][0], A_min[i + 1]);
	}

	printf("%d\n", A[0][0]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            cnt++;
        }
        if(i > 0) {
            if(d.at(i) != d.at(i-1)) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    // Your code here!
   int a, b;
   cin >> a >> b;
   if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0 ){
       cout << "Possible" << endl;
   } else {
       cout << "Impossible" << endl;
   }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a[]=new int[3];
    for (int i=0;i<3;i++) {
      a[i]=sc.nextInt();
    }

    Arrays.sort(a);

    int problem1=a[0]-a[1];
    int problem2=a[1]-a[2];

    int ans=Math.abs(problem1)+Math.abs(problem2);

    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
from itertools import combinations
from itertools import permutations
s = input()
n = len(s)
a = [i for i in range(n)]
delta = 100200300400500
for c in range(0, n - 2):
    b = int(s[c] + s[c + 1] + s[c + 2])
    # print(c, b)
    delta = min(delta, abs(b - 753))
print(delta)

Measured memory_bytes: 3060
N,K = map(int,input().split())
H = list(map(int,input().split()))

INF = 10**10
dp = [0] + [INF for _ in range(N-1)]
for i in range(1,N):
  j = 1
  while (j <= K and i-j >= 0):
    dp[i] = min(dp[i],dp[i-j]+abs(H[i]-H[i-j]))
    j += 1
  #print(dp)
print(dp[N-1])

Measured memory_bytes: 57440
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    string ans = "";
    REP(i, s.length()){
        if(s[i] == '0'){
            ans = ans + "0";
        }
        else if(s[i] == '1'){
            ans = ans + "1";
        }
        else if(s[i] == 'B'){
            if(ans != ""){
                string tmp = "";
                REP(j, ans.length()-1){
                    tmp += ans[j];
                }
                ans = tmp;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e3+10;
int mod=998244353;
int dp[maxn][maxn];
int C[maxn][maxn];
int n;
int Pow(int a,long long k,int M=mod)
{
    int ret=1;
    while(k)
    {
        if(k&1)ret=ret*1LL*a%M;
        a=a*1LL*a%M;
        k>>=1;
    }
    return ret;
}
int main()
{
    scanf("%d%d",&n,&mod);
    C[0][0]=1,dp[0][0]=1;
    for(int i=1;i<=n+1;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod,dp[i][j]=(dp[i-1][j-1]+dp[i-1][j]*1LL*j)%mod;
    }
    int ans=0;
    for(int i=0;i<=n;i++)
    {
         int tmp=(i&1?mod-1:1)*1LL*C[n][i]%mod*Pow(2,Pow(2,n-i,mod-1))%mod;
         int sum=0,p2=Pow(2,n-i);
         for(int j=0,t=1;j<=i;j++,t=t*1LL*p2%mod)sum=(sum+dp[i+1][j+1]*1LL*t)%mod;
         ans=(ans+sum*1LL*tmp)%mod;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 119424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long>A(N);
  vector<long long>B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  long long count = 0;
  for (int i = N-1; i >= 0; i--) {
    A.at(i) += count;
    if (A.at(i) % B.at(i) != 0){
      count += B.at(i) - A.at(i) % B.at(i);
    }
  }
  cout << count << endl;
}

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

using namespace std;

const int N = 1e5 + 5, MAX_H = 1e4 + 5, inf = (int)1e9 + 123;
int n, K, h[N], dp[N];
deque<int> deq[MAX_H];

struct It {
    int node[MAX_H << 2];
    It () {
        for (int i = 0; i < (MAX_H << 2); ++i) node[i] = inf;
    }
    void update (int nd, int Left, int Right, int pos, int val) {
        if (pos < Left || Right < pos) return ;
        if (Left == Right) {
            node[nd] = val; return ;
        }
        int mid = Left + Right >> 1;
        update(nd << 1, Left, mid, pos, val); update(nd << 1 | 1, mid + 1, Right, pos, val);
        node[nd] = min(node[nd << 1], node[nd << 1 | 1]);
    }
    int get (int nd, int Left, int Right, int l, int r) {
        if (Right < l || r < Left) return inf;
        if (l <= Left && Right <= r) return node[nd];
        int mid = Left + Right >> 1;
        return min(get(nd << 1, Left, mid, l, r), get(nd << 1 | 1, mid + 1, Right, l, r) );
    }
} it[2];

int main () {
    scanf("%d %d", &n, &K);
    for (int i = 1; i <= n; ++i) scanf("%d", h + i);

    for (int i = 2; i <= n; ++i) {
        if (i - K - 1 > 0) {
            int id = h[i - K - 1];
            while (!deq[id].empty() && deq[id].front() < i - K) deq[id].pop_front();
            it[0].update(1, 1, MAX_H - 5, id, (deq[id].empty() ? inf : dp[deq[id].front()] - id) );
            it[1].update(1, 1, MAX_H - 5, id, (deq[id].empty() ? inf : dp[deq[id].front()] + id) );
        }
        int id = h[i - 1];
        while (!deq[id].empty() && dp[ deq[id].back() ] >= dp[i - 1]) deq[id].pop_back();
        deq[id].push_back(i - 1);
        it[0].update(1, 1, MAX_H - 5, id, (deq[id].empty() ? inf : dp[deq[id].front()] - id) );
        it[1].update(1, 1, MAX_H - 5, id, (deq[id].empty() ? inf : dp[deq[id].front()] + id) );
        dp[i] = min(it[0].get(1, 1, MAX_H - 5, 1, h[i]) + h[i], it[1].get(1, 1, MAX_H - 5, h[i], MAX_H - 5) - h[i]);
    }

    cout << dp[n];

    return 0;
}


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

int main(void){
  int N,sum=0;
  cin >> N;
  vector<int> vec(2*N);
  for(int i=0;i<2*N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for(int i=0;i<2*N;i++){
    if(i%2 == 1){
      sum+=vec.at(i);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
// 簡潔なスタイル
int N; // 少しだけ多めに取る
int min111(vector<long long>A) {
    long long ans = A.at(0);
    for(int i=0;i<A.size();i++) {
        if (ans > A.at(i)){
            ans = A.at(i);
        }
    }
return ans;
}
long long max111(vector<long long> A) {
    long long ans = A.at(0);
    for(int i=0;i<A.size();i++) {
        if (ans < A.at(i)){
            ans = A.at(i);
        }
    }
return ans;
}
long long sum111(vector<long long> A) {
    long long sum=0;
    for(int i=0;i<A.size();i++) {
        sum += A.at(i);
    }
return sum;
}
int main() {
int N;    
cin >> N;
vector<long long> A(N);
for (int i=0; i<N; ++i){
cin >> A.at(i);
}
cout <<min111(A)<<' '<<max111(A)<<' '<<sum111(A)<<endl;

}


Measured memory_bytes: 3348
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, d: usize,
        x: [[i32; d]; n],
    }
    let mut tot = 0;
    for i in 0..n {
        for j in 0..i {
            let mut dist = 0;
            for k in 0..d {
                let tmp = x[i][k] - x[j][k];
                dist += tmp * tmp;
            }
            let mut sq = -1;
            for i in 0..200 {
                if i * i == dist {
                    sq = i;
                    break;
                }
            }
            if sq >= 0 {
                tot += 1;
            }
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
#include<bits/stdc++.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    long long n,m,x,y,z,xx,yy;
    cin>>n>>m;
    xx=max(n,m);
    yy=min(n,m);
    for(long long i=0;i<=xx;i++)
    {
        x=abs(n-i);
        y=abs(m-i);
        if(x==y)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int n; cin >> n;
  int v[n]; rep(i,n) cin >> v[i];
  map<int, int> odd, even;
  rep(i, n) {
    if (i%2==0) even[v[i]]++;
    else odd[v[i]]++;
  }

  int o_max[2]={}, e_max[2]={};
  for (auto x: odd) {
    if (odd[o_max[0]]<=x.second) {
      o_max[1] = o_max[0];
      o_max[0] = x.first;
    }
    else if (odd[o_max[1]]<=x.second) {
      o_max[1] = x.first;
    }
  }
  for (auto x: even) {
    if (even[e_max[0]]<=x.second) {
      e_max[1] = e_max[0];
      e_max[0] = x.first;
    }
    else if (even[e_max[1]]<=x.second) {
      e_max[1] = x.first;
    }
  }

  // cout << o_max[0] << " " << o_max[1] << " " << e_max[0] << " " << e_max[1] << endl;
  int result;
  if (o_max[0]!=e_max[0]) result = n - (odd[o_max[0]]+even[e_max[0]]);
  else result = n - max(odd[o_max[0]]+even[e_max[1]], odd[o_max[1]]+even[e_max[0]]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>

int matchchar(char*S,char*T,int len){
  int ANS=0;
  for(int i=0;i<len;i++){
    if(S[i]!=T[i]){ANS++;}
  }
  if(ANS==0){return 1;}
  return 0;
}

void rotatechar(char*S,int len){
  char t;
  t=S[len-1];
  for(int i=len;i>0;i--){
    S[i]=S[i-1];
  }
  S[0]=t;
}


int main(){
  char S[100];
  char T[100];
  scanf("%s",S);
  scanf("%s",T);
  int len=strlen(S);

  for(int i=0;i<len;i++){
    if(matchchar(S,T,len)==1){
      printf("Yes");
      return 0;
    }
    rotatechar(S,len);
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m,a;
long long s=0;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d",&a);
		s+=a;
	}
	if (s>n) printf("-1");
	else printf("%d",n-s);
}

Measured memory_bytes: 3828
import itertools

N, M, Q = map(int, input().split())
X = []
for i in range(Q):
    a, b, c, d = input().split(" ")
    X.append([int(a), int(b), int(c), int(d)])

l = (list(itertools.combinations_with_replacement(range(1, M + 1), N)))
r = 0
result = 0
for k in l:
    r = 0
    for x in X:
        if k[x[1] - 1] - k[x[0] - 1] == x[2]:
            r += x[3]
    if result < r:
        result = r
print(result)

Measured memory_bytes: 21512
#include<iostream>

using namespace std;

#define ll long long

int main()
{
	ll N,cap[5];

	cin >> N;

	ll minCap = 1000000000000000;

	for(int i=0;i<5;i++)
	{
		cin >> cap[i];
		minCap = min(minCap,cap[i]);
	}

	ll nGroup = N/minCap;

	if(N%minCap==0)nGroup--;

	cout << nGroup + 5 << endl;

	return 0;
}

Measured memory_bytes: 256
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program {
     static long waru = 1000000007;
     static void Main(string[] args) {
     //入力を受け取る
     var NK  = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
     var N   = NK[0];
     var K   = NK[1];

     var A = 0L;
     var B = 0L;
     var dic = new Dictionary<long,long>();
     for(long i = 0;i < N;i++){
         var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
         A   = AB[0];
         B   = AB[1];
         if(dic.ContainsKey(A)){
             dic[A] += B;
         }else{
             dic.Add(A,B);
         }
     }
     
     var Sorted = dic.OrderBy((x) => x.Key);
     
     var ans = 0L;
     foreach(KeyValuePair<long,long> item in Sorted) {
         if(K > item.Value){
             K -= item.Value;
         }else{
             ans = item.Key;
             break;
         }
     }
     
     Console.WriteLine(ans);
     }
     
     static long kaijo(long num){
         long res =1;
        // Console.WriteLine(res);
         while(num != 1){
             res *= (num%waru);
             num--;
             res = res%waru;
         }
         
         return res%waru;
    　}
}
     
     
     
     
     


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=55;
int test,n,ans;
bool e1[maxn][maxn],e2[maxn][maxn],ban[maxn][maxn],mv[maxn];
int par1[maxn],par2[maxn],deg[maxn],q[maxn];
vector<int>edge1[maxn],edge2[maxn],nedge[maxn];

void dfs1(int x,int p,bool f){
	par1[x]=p;
	mv[x]=f;
	rep(i,int(edge1[x].size())){
		int y=edge1[x][i];
		if(y==p||ban[x][y])continue;
		dfs1(y,x,f||(!e2[x][y]));
	}
}
void dfs2(int x,int p){
	par2[x]=p;
	rep(i,int(edge2[x].size())){
		int y=edge2[x][i];
		if(y==p)continue;
		dfs2(y,x);
	}
}
int work(int x){
	dfs1(x,0,false);
	dfs2(x,0);
	REP(i,n)nedge[i].clear(),deg[i]=0;
	REP(i,n){
		if(mv[i]&&mv[par1[i]])nedge[i].pb(par1[i]),deg[par1[i]]++;
		if(mv[i]&&mv[par2[i]])nedge[par2[i]].pb(i),deg[i]++;
	}
	int l=1,r=0;
	REP(i,n)if(!deg[i])q[++r]=i;
	while(l<=r){
		int x=q[l++];
		rep(i,int(nedge[x].size())){
			int y=nedge[x][i];
			deg[y]--;
			if(!deg[y])q[++r]=y;
		}
	}
	if(r!=n)return n+1;
	int res=0;
	REP(i,n)res+=mv[i];
	return res;
}

int main(){
	scanf("%d",&test);
	while(test--){
		scanf("%d",&n);
		ans=n+1;
		REP(i,n){
			edge1[i].clear();
			edge2[i].clear();
			REP(j,n)e1[i][j]=e2[i][j]=false;
		}
		REP(i,n-1){
			int u,v;
			scanf("%d%d",&u,&v);
			edge1[u].pb(v);
			edge1[v].pb(u);
			e1[u][v]=e1[v][u]=true;
		}
		REP(i,n-1){
			int u,v;
			scanf("%d%d",&u,&v);
			edge2[u].pb(v);
			edge2[v].pb(u);
			e2[u][v]=e2[v][u]=true;
		}
		bool ok=true;
		REP(i,n)rep(j,int(edge1[i].size()))ok&=e2[i][edge1[i][j]];
		if(ok){
			puts("0");
			continue;
		}
		REP(i,n)if(int(edge1[i].size())==1){
			int ii=edge1[i][0];
			ban[i][ii]=ban[ii][i]=true;
			e1[i][ii]=e1[ii][i]=false;
			REP(j,n)if(j!=i&&j!=ii){
				edge1[i].pb(j);
				edge1[j].pb(i);
				e1[i][j]=e1[j][i]=true;
				ans=min(ans,work(i)+1);
				edge1[i].pop_back();
				edge1[j].pop_back();
				e1[i][j]=e1[j][i]=false;
			}
			ban[i][ii]=ban[ii][i]=false;
			e1[i][ii]=e1[ii][i]=true;
		}
		printf("%d\n",ans==n+1?-1:ans);
	}
	return 0;
} 

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var arrays = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();

            double total = arrays.Sum(x => x);

            var m = nm[1];
            var lim = total / (4 * m);
            Console.WriteLine(arrays.Count(a => a >= lim) >= m ? "Yes" : "No");
        }
    }
}

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

int main(){
	int n,k;
  	cin >> n >> k;
  
  	int prices[n];
  	for(int i = 0; i < n; i++) cin >> prices[i];
  
  	sort(prices, prices+n);
  
  	int total = 0;
  	for(int i = 0; i < k; i++) total += prices[i];
  
  	cout << total;
  
  	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")

using ll = std::int64_t;
using vint = std::vector<std::int32_t>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<std::int32_t, std::int32_t>;
using usetint = std::unordered_set<std::int32_t>;
using usetstr = std::unordered_set<std::string>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n, k;
    cin >> n >> k;
    vint h(n);
    rep(i, n)cin >> h[i];
    int ans = 0;
    rep(i, n) {
        if (h[i] >= k)++ans;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 640
S = [int(i) for i in input().split()]
S.sort()
A = S[2]
B = S[1]
C = S[0]

if (B - C) % 2 == 0:
  print(A - (B + C) // 2)
else:
  print(A - (B + C - 1) // 2 + 1)

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    map<pair<int,int>, int> mp;
    for (int i=0; i<N; i++) {
        int a,b;
        cin >> a >> b;
        for (int x=max(1,b-2); x<=b && x+2<=W; x++) {
            for (int y=max(1,a-2); y<=a && y+2<=H; y++) {
                // (x,y) は左上の頂点
                mp[make_pair(x,y)]++;
            }
        }
    }

    long long a[10];
    for (int i=0; i<10; i++) a[i] = 0;

    long long sum = 0;
    for(const auto m: mp) {
        a[m.second]++;
        sum++;
    }

    // 0だけ
    a[0] = (long long)(H-3+1) * (long long)(W-3+1) - sum;

    for (int i=0; i<10; i++) {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 56448
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int c[10]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main()
{
	int n, m; cin>>n>>m;
	int a[10];
	for(int i=0; i<m; i++) cin>>a[i];
	sort(a, a+m);
	int dp[10001];
	fill(dp, dp+n+1, -1);
	dp[0]=0;
	for(int i=0; i<n; i++){
		if(dp[i]==-1) continue;
		for(int j=0; j<m; j++){
			if(i+c[a[j]]<=n) dp[i+c[a[j]]]=max(dp[i+c[a[j]]], dp[i]+1);
		}
	}
	string ans;
	int k=n;
	while(k){
		for(int i=m-1; i>=0; i--){
			if(k-c[a[i]]>=0 && dp[k-c[a[i]]]==dp[k]-1){
				ans+=('0'+a[i]);
				k-=c[a[i]];
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int h, w, i, j;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i % 2 == 1) {
					if (j % 2 == 1) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (j % 2 == 1) {
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3116
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N=int(input())
    AB=[tup()for i in range(N)]
    AB.sort(key=lambda x:sum(x),reverse=True)
    #print(AB)

    n=N
    turn=0
    his=0
    her=0
    for i in range(N):
        if i%2==0:
            his+=AB[i][0]
        else:her+=AB[i][1]
    print((his-her))
            
#%%submit!
resolve()

Measured memory_bytes: 21328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Remoting.Contexts;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public uint NextUint()
        {
            return uint.Parse(Next());
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
        }


        public void Solve()
        {
            Scan();
            Console.WriteLine(A.Sum(I));
        }

        private int I(int n)
        {
            if (n % 2 == 1)
            {
                return 0;
            }
            else
            {
                return I(n / 2) + 1;
            }
        }

        static void Main() => new Program().Solve();
    }

}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &e : A) cin >> e;
  sort(A.begin(), A.end(), greater<ll>());
  ll sum = A[0];
  int j = 1;
  bool b = false;
  for (int i = 2; i < N; i++) {
    sum += A[j];
    if (b) j++;
    b = !b;
  }
  cout << sum << endl;
}

Measured memory_bytes: 4788
n=input()
year=list(n)

if int(year[0])>=int(year[1]) and int(year[0])>=int(year[2]):
  year[1]=year[0]
  year[2]=year[0]
else:
  temp=int(year[0])+1
  year[0]=str(temp)
  year[1]=str(temp)
  year[2]=str(temp)
year=''.join(year)
print(year)

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

int main() {
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool ok = true;
  if (s.size() != a+b+1) ok = false;
  for (int i = 0;i < s.size();i++) {
    if (i==a) {
      if (s.at(i) != '-') ok = false;
    }
    else {
      if (s.at(i) == '-') ok = false;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    int m, n;
    cin>>m>>n;
    cout<<( ( (m>=1 &&  m<=9) && (n>=1 && n<=9) ) ? m*n : -1 );
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int32 h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	int64 p1 = h1*a+h2*b+(h1/10)*c+(h2/20)*d;
	int64 p2 = k1*a+k2*b+(k1/10)*c+(k2/20)*d;
	if(p1 < p2)
		cout << "kenjiro" << endl;
	else if(p1 == p2)
		cout << "even" << endl;
	else
		cout << "hiroshi" << endl;
}



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

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;

    int turn = 0;
    while (!(a <= 0 || c<= 0)) {
        if (turn %2 == 0) {
            c-= b;
        }
        else {
            a-= d;
        }
        turn++;
    }

    if (a<= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, h, la=0;
    cin>>N;
    ll count=0;
    rep(i, N){
        cin>>h;
        if(h>la) count+=h-la;
        la=h;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256