akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

class dice {
public:
	dice(int m1, int m2, int m3, int m4, int m5, int m6);
	~dice();
	void roll(char c);
	int getmT() { return mT; };
	int getmS() { return mS; };
	int getmE() { return mE; };
	int getmW() { return mW; };
	int getmN() { return mN; };
	int getmB() { return mB; };
private:
	int mE, mW, mS, mN;
	int mT, mB;

};

dice::dice(int m1, int m2, int m3, int m4, int m5, int m6) : mT(m1), mS(m2), mE(m3), mW(m4), mN(m5), mB(m6) {

}

dice::~dice() {

}

void dice::roll(char c) {
	switch (c) {
	case 'E':
		int tE;
		tE = mE;
		mE = mT;
		mT = mW;
		mW = mB;
		mB = tE;
		break;
	case 'W':
		int tW;
		tW = mW;
		mW = mT;
		mT = mE;
		mE = mB;
		mB = tW;
		break;
	case 'N':
		int tN;
		tN = mN;
		mN = mT;
		mT = mS;
		mS = mB;
		mB = tN;
		break;
	case 'S':
		int tS;
		tS = mS;
		mS = mT;
		mT = mN;
		mN = mB;
		mB = tS;
		break;
	}
}



int main() {
	int me[6];
	for (int i = 0; i < 6; i++) {
		cin >> me[i];
	}
	dice* mDice;
	mDice = new dice(me[0], me[1], me[2], me[3], me[4], me[5]);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		string meirei = "SWSWWSWSENENNENE";
		int mae, ue;
		cin >> ue >> mae;
		for (int j = 0; j < meirei.length(); j++) {
			mDice->roll(meirei[j]);
			if ((ue == mDice->getmT()) && (mae == mDice->getmS())) {
				cout << mDice->getmE() << endl;
				break;
			} else if ((ue == mDice->getmT()) && (mae == mDice->getmE())) {
				cout << mDice->getmN() << endl;
				break;
			} else if ((ue == mDice->getmT()) && (mae == mDice->getmN())) {
				cout << mDice->getmW() << endl;
				break;
			} else if ((ue == mDice->getmT()) && (mae == mDice->getmW())) {
				cout << mDice->getmS() << endl;
				break;
			} else if ((ue == mDice->getmB()) && (mae == mDice->getmW())) {
				cout << mDice->getmN() << endl;
				break;
			} else if ((ue == mDice->getmB()) && (mae == mDice->getmN())) {
				cout << mDice->getmE() << endl;
				break;
			} else if ((ue == mDice->getmB()) && (mae == mDice->getmE())) {
				cout << mDice->getmS() << endl;
				break;
			} else if ((ue == mDice->getmB()) && (mae == mDice->getmS())) {
				cout << mDice->getmW() << endl;
				break;
			}
		}
	}
	delete mDice;
	mDice = 0;
	return 0;
}


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

const int N = 8e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

const long double PI = 3.141592653589793238462643383279;

int MAX[N];

void ustaw(int v, int p, int k, int a, int x) {
	if (k <= a) return;
	if (p > a) return;
	if (p + 1 == k) MAX[v] = max(MAX[v], x);
	else {
		int s = (p + k) / 2;
		ustaw(2*v, p, s, a, x);
		ustaw(2*v+1, s, k, a, x);
		MAX[v] = max(MAX[2 * v], MAX[2 * v + 1]);
	}
}

int czytaj(int v, int p, int k, int a, int b) {
	if (k <= a || p >= b) return 0;
	if (a <= p && k <= b) return MAX[v];
	int s = (p+k)/2;
	return max(czytaj(2*v, p, s, a, b), czytaj(2*v+1, s, k, a, b));
}

map<int, int> skalowanie;

int main() {
	vector<int> ska;
	int x1, y1, x2, y2;
	long long y1old, y2old;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	y1old = y1;
	y2old = y2;
	ska.push_back(y1);
	ska.push_back(y2);
	int n;
	scanf("%d", &n);
	vector<pair<int,int>> pun;
	for (int i = 0; i < n; i ++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ska.push_back(y);
		pun.push_back({x, y});
	}
	sort(ska.begin(), ska.end());
	int id = -1;
	int last = -1;
	for (int x: ska) {
		if (x > last) {
			id ++;
			skalowanie[x] = id;
		}
		last = x;
	}
	int n2 = 1;
	while(n2 <= id) n2 *= 2;
	y1 = skalowanie[y1];
	y2 = skalowanie[y2];
	for (int i = 0; i < pun.size(); i ++) {
		pun[i].second = skalowanie[pun[i].second];
	}
	if (x1 > x2) {
		swap(x1, x2);
		swap(y1, y2);
	}
	sort(pun.begin(), pun.end());
	for (auto p : pun) {
// 		printf("%d\n", p.first);
		if (p.first < x1) continue;
		if (p.first > x2) continue;
		if (p.second > max(y1, y2) || p.second < min(y1, y2)) continue;
		int wynik = 0;
		if (y1 < y2) {
// 			printf("male %d\n", p.second);
			wynik = czytaj(1, 0, n2, 0, p.second + 1);
		} else {
// 			printf("duze\n");
			wynik = czytaj(1, 0, n2, p.second, n2);
		}
		ustaw(1, 0, n2, p.second, wynik + 1);
	}
	long double cwiartka = PI / 2 * 10;
	cout.precision(30);
		int half = 0;
		int ile = czytaj(1, 0, n2, min(y1, y2), max(y1, y2) + 1);
// 		printf("ile %d\n", ile);
		if (ile == min(abs(x1 - x2), (int)abs(y1old - y2old)) + 1) {
			ile --;
			half ++;
		}
		printf("%.30Lf\n", 100 * (long long)(abs(y1old - y2old) + abs(x1 - x2))
							- 20 * ile + cwiartka * ile + half * (2 * cwiartka - 20));
}


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

int main(void)
{
    int user;

    cin >> user;
    int h, m, s;
    h = user / (60*60);
    m = (user / 60) % 60;
    s = user % 60;
    cout << h << ':' << m << ':' << s << endl;
    return 0;
}

Measured memory_bytes: 3088
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll count_div(ll n, ll m) {
    if (n%m != 0) return 0;
    else return 1 + count_div(n/m, m);
}
#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    
    ll ans = 0;
    REP(i, N) ans += A[i] - 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;int cnt= 0 ;
    const string CODEFESTIVAL2016 = "CODEFESTIVAL2016";
    for(int i = 0; i < s.size(); i ++) {
    	if(s[i] != CODEFESTIVAL2016[i]) {
    		cnt++;
		}
	}cout<<cnt<<endl;
    return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

ll bp(ll a, ll d, ll m) {
    if (d == 0) {
        return 1;
    }
    auto h = bp(a, d / 2, m);
    auto hh = (h * h) % m;
    if (d % 2) {
        hh = (hh * a) % m;
    }
    return hh;
}


void oneCase() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 1; i <n; ++i) {
        int a;
        cin >> a;
        --a;
        ++mp[a];
    }
    for (int i = 0; i < n; ++i) {
        cout << (mp.count(i) ? mp[i] : 0) << "\n";
    }

}

int main() {
//    std::ios::sync_with_stdio(false);
//    std::cin.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 13004
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    val aa = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    val ab  = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
     var ans = ab.sum()
    if(aa[0]<=ans)
        print("Yes")
    else
        print("No")
}


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

using namespace std;

int main(){
    int n, x;
    scanf("%d %d", &n, &x);
    int arr[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
    }
    int resp = 0, curr = 0;
    for(int i = 0; i < n; i++){
        if(curr > x)break;
        resp++;
        curr += arr[i];
    }
    if(curr <= x)resp++;
    printf("%d\n", resp);
    return 0;
}

Measured memory_bytes: 256
/*
	首先发现一些性质
	如果一个点接了 ≥ 2 个度数为 1 的点, 那么先手赢
	那么 dfs 的时候, 就会把连在一起的
	一个度数为 1, 一个度数不为 1 的结点 (叶子和上面的那个)
	的两个点去掉不看(先手填叶子上面的), 变成一个子问题
*/
#include <iostream>
#include <cstdio>
#define N 100005

using namespace std;

int n;
int head[N], nex[N << 1], to[N << 1], te;
int deg[N], fa[N], f[N];

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
inline void ade(int u, int v) { 
	nex[++te] = head[u], head[u] = te;
	to[te] = v, ++deg[v];
}

void dfs(int u) {
	for(int i = head[u]; i; i = nex[i]) {
		int v = to[i];
		if(v == fa[u]) continue;
		fa[v] = u, dfs(v);
	}
	if(f[u] >= 2) {
		puts("First");
		exit(0);
	}
	if(deg[u] == 1) ++f[fa[u]];
	if(f[u]) --deg[fa[u]];
}

int main() {
	read(n);
	for(int i = 1, u, v; i < n; ++i) {
		read(u), read(v);
		ade(u, v), ade(v, u);
	}
	if(n == 2) return puts("Second"), 0;
	for(int i = 1; i <= n; ++i) {
		if(deg[i] == 1) continue;
		dfs(i);
		return puts(deg[i] ? "Second" : "First"), 0;
	}
	return 0;
}

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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a == b){printf("%d\n",a+b);}
  else if(a > b){printf("%d\n",a*2-1);}
  else{printf("%d\n",b*2-1);}
  return 0;
}


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

class dice{
public:
    int face[6];

    dice(){}

    void rollN(){
        int c = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = c;
    }

    void rollS(){
        int c = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = c;
    }

    void rollW(){
        int c = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = c;
    }

    void rollE(){
        int c = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = c;
    }

    void rollZ(){
        int c = face[1];
        face[1] = face[2];
        face[2] = face[4];
        face[4] = face[3];
        face[3] = c;
    }

};

int main() {
    dice A;
    rep(i, 6){
        cin >> A.face[i];
    }

    int q; cin >> q;

    rep(i, q){
        int a, b; cin >> a >> b;

        int ans;
        rep(j, 4){
            if (A.face[0] == a) break;

            A.rollN();

            if (j == 3){
                A.rollE();
                if(A.face[0] == a)break;
                A.rollE();
                A.rollE();
            }
        }

        rep(j, 4){
            if(A.face[1] == b)break;
            A.rollZ();
        }

        cout << A.face[2] << endl;

    }
}


Measured memory_bytes: 3088
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(bN[i-1: :i]) % 2 != aN[i - 1]:
        bN[i-1] = 1

print(sum(bN))
if sum(bN) != 0:
    print(*[i+1 for i, b in enumerate(bN) if b == 1])


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

int main() {
  string s, t; cin >> s >> t;
  s = s + s;
  vector<vector<int>> v(26);
  for (int i = 0; i < s.size(); i++) {
    v.at(s.at(i) - 'a').push_back(i+1);
  }
  int idx = 1;
  long long ans = 0;
  for (int i = 0; i < t.size(); i++) {
    if (v.at(t.at(i)-'a').size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    int next = *lower_bound(v.at(t.at(i)-'a').begin(), v.at(t.at(i)-'a').end(), idx);
    ans += (next - idx) + 1;
    idx = next + 1;
    if (idx > s.size()/2) idx -= (s.size()/2);
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll r;
  cin >> r;

  cout << (3 * r * r) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
  int a,b,num;
  scanf("%d %d",&a,&b);
 
  if(a>b) num=a+a-1;
  if(b>a) num=b+b-1;
  if(a==b) num=a+b;
  
  printf("%d",num);
  
  return 0;
}

Measured memory_bytes: 128
import sys
from itertools import groupby
def input(): return sys.stdin.readline().rstrip()


def main():
    S=list(input())
    ans=[0]*(len(S))
    index=0
    for key, value in groupby(S):
        le=len(list(value))
        if key=='L':
            ans[index]+=(le+1)//2
            ans[index-1]+=le//2
        else:
            ans[index+le]+=le//2
            ans[index+le-1]+=(le+1)//2
        index+=le
    print(*ans, sep=" ")
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 12264
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;
#define Jaldi_jaldi_kar_subha_panvel_ke_liye_nikalna_hai ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    Jaldi_jaldi_kar_subha_panvel_ke_liye_nikalna_hai
    lli n,r;
    cin>>n>>r;
    if(n>=10)
    	cout<<r<<endl;
    else{
    	cout<<r+100*(10-n)<<endl;
    }
    
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, M;
ll A[100005];
ll S[100005];

bool check(ll x) {
    ll num = 0;
    REP(i, N) {
        ll ok = -1, ng = N;
        while (abs(ng - ok) > 1) {
            ll mid = (ng + ok) / 2;
            if (A[mid] + A[i] >= x)
                ok = mid;
            else
                ng = mid;
        }
        num += ok + 1;
    }
    return num <= M;
}

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

    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N, greater<ll>());

    ll mx = INF, ng = 0;
    while (abs(ng - mx) > 1) {
        ll mid = (ng + mx) / 2;
        if (check(mid))
            mx = mid;
        else
            ng = mid;
    }

    memset(S, 0, sizeof(S));
    REP(i, N) {
        S[i + 1] += S[i] + A[i];
    }
    ll ans = 0;
    ll num = 0;
    REP(i, N) {
        ll ok = -1, ng = N;
        while (abs(ng - ok) > 1) {
            ll mid = (ng + ok) / 2;
            if (A[mid] + A[i] >= mx)
                ok = mid;
            else
                ng = mid;
        }
        ll n = ok + 1;
        ans += n * A[i] + S[n];
        num += n;
    }

    ans += (M - num) * (mx - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑



void dijkstra(int n) {
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>que;
	fill(dij.begin(), dij.end(), INF);
	dij[n] = 0;
	que.push(pair<ll, ll>(0, n));

	while (!que.empty()) {
		pair<ll, ll>p = que.top();
		que.pop();
		ll mon = p.second;
		if (dij[mon] < p.first) continue;
		for (int i = 0; i < G[mon].size(); ++i) {
			edge e = G[mon][i];
			if (dij[e.to] > dij[mon] + e.cost) {
				dij[e.to] = dij[mon] + e.cost;
				que.push(pair<ll, ll>(dij[e.to], e.to));
			}
		}
	}
}


ll a, b, c, d, e, f, cost, k[100005], l[200005], m[200005];
bool dang[100005];
int main() {
	cin >> a >> b >> c >> d >> e >> f;
	G.resize(a + 1);
	dij.resize(a + 1);

	for (int i = 0; i < c; ++i) {
		cin >> k[i];
		G[0].push_back({ k[i],0 });
		dang[k[i]] = 1;
	}

	for (int i = 0; i < b; ++i) {
		cin >> l[i] >> m[i];
		addedge(l[i], m[i], 1);
	}

	dijkstra(0);

	G.clear();
	G.resize(a + 1);

	for (int i = 0; i < b; ++i) {
		if (m[i] == a) { G[l[i]].push_back({ m[i],0 }); }
		else {
			if (!dang[l[i]]) {
				if (dij[l[i]] <= d) { cost = f; }
				else { cost = e; }
				G[m[i]].push_back({ l[i],cost });
			}

			if (!dang[m[i]]) {
				if (dij[m[i]] <= d) { cost = f; }
				else { cost = e; }
				G[l[i]].push_back({ m[i],cost });
			}
		}
	}

	dij.clear();
	dij.resize(a + 1);
	dijkstra(1);

	cout << dij[a] << endl;
}



Measured memory_bytes: 20296
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <cstdio>

// 処理内容
int main() {

    int n; scanf("%d", &n);

    int ans[512] = {};
    for (int j = 1, j_end = n-1; j <= j_end; ++j) {
        for (int l = j & -j; l; ++ans[j-1]) l >>= 1;
    }
    for (int i = 0, i_end = n-2; i <= i_end; ++i) {
        for (int j = 0, j_end = n-2-i; j <= j_end; ++j) {
            printf("%d%c", ans[j], j == j_end ? '\n' : ' ');
        }
    }
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
#define all(i) (i).begin(), (i).end()
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

const int MN = 1e3 + 5;
const int MOD = 1e9 + 7;
int n, m;
char a[MN][MN];
int dp[MN][MN];

int f(int x, int y)
{
	if (!(0 <= x && x < n && 0 <= y && y < m)) return 0;
	if (a[x][y] == '#') return 0;
	if (x == n - 1 && y == m - 1) return 1;

	int &ret = dp[x][y];
	if (~ret) return ret;
	ret = f(x + 1, y) + f(x, y + 1);
	ret %= MOD;
	return ret;
}

int main()
{
	cin >> n >> m;
	rep(i, 0, n) rep(j, 0, m) cin >> a[i][j];
	mem(dp);

	cout << f(0, 0);
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <vector>
#include <queue>
#include <memory.h>
#include <functional>
#include <algorithm>
using namespace std;
#include <stack>

//FILE * in = freopen("input.txt", "r" , stdin);
char data[1000];

int main() {
	
	while(true) {
		bool flag = false;
		gets(data);
		if(data[0] == '.' && data[1] == 0)break;
		int i = 0;
		stack<int> a;
		while(data[i] != '.'){
			switch(data[i])
			{
			case '(':
				a.push('(');
				break;
			case '[':
				a.push('[');
				break;
			case ')':
				if(a.empty()) {
					flag = true;
					goto out;
				}
				if(a.top() == '(')
					a.pop();
				else {
					flag = true;
					goto out;
				}
				break;

			case ']':
				if(a.empty()) {
					flag = true;
					goto out;
				}
				if(a.top() == '[')
					a.pop();
				else {
					flag = true;
					goto out;
				}
				break;
			default:
				break;
			}
			i++;
		}
		out:
		if(!flag && a.empty())
			puts("yes");
		else
			puts("no");
	}

	return 0;
}

Measured memory_bytes: 948
k = int(input())
x = 7%k
cnt = 0

if k%2 ==0:
    print('-1')
else:
    while True:
        cnt += 1
        if x == 0:
            print(cnt)
            break
        elif cnt == k:
            print('-1')
            break
        else:
            x = (x*10+7)%k

Measured memory_bytes: 9176
/**
 *    author:  tourist
 *    created: 18.01.2020 23:53:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int k = 1;
  while (k + 1 <= n && a[k] >= k + 1) {
    k += 1;
  }
  int up = a[k - 1] - k;
  int right = 0;
  while (k + right < n && a[k + right] == k) {
    ++right;
  }
  cout << (up % 2 == 0 && right % 2 == 0 ? "Second" : "First") << '\n';
  return 0;
}


Measured memory_bytes: 640
readline()
c=zeros(Int,3)
ans=1
for a=map(x->parse(Int,x),split(readline()))
	id=1
	cnt=0
	for i=1:3
		if c[i]==a
			cnt+=1
			id=i
		end
	end
	ans=ans*cnt%(10^9+7)
	c[id]+=1
end
println(ans)


Measured memory_bytes: 165880
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 aa, bb;
	cin >> aa >> bb;
	if(aa == bb)
	{
		puts("Draw");
	}
	else if(aa == 1)
	{
		puts("Alice");
	}
	else if(bb == 1)
	{
		puts("Bob");
	}
	else if(aa > bb)
	{
		puts("Alice");
	}
	else
	{
		puts("Bob");
	}
	return 0;
}


Measured memory_bytes: 3508
use std::convert::From;
use std::fs;
use std::io::{stdin, Read};
use std::ops::{Add, AddAssign, Mul, Sub};
use std::str::FromStr;
const MOD: usize = 998244353;

#[derive(Debug, Clone, Copy)]
struct musize {
    value: usize,
}

impl std::fmt::Display for musize {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.value)
    }
}

impl From<usize> for musize {
    fn from(item: usize) -> Self {
        musize { value: item }
    }
}

impl AddAssign for musize {
    fn add_assign(&mut self, other: Self) {
        *self = *self + other
    }
}

impl Add for musize {
    type Output = Self;
    fn add(self, other: Self) -> Self {
        musize {
            value: (self.value + other.value) % MOD,
        }
    }
}

impl Sub for musize {
    type Output = Self;
    fn sub(self, other: Self) -> Self {
        let value = if self.value >= other.value {
            (self.value - other.value) % MOD
        } else {
            MOD - ((other.value - self.value) % MOD)
        };
        musize { value: value }
    }
}

impl FromStr for musize {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let v = s.parse::<usize>()?;
        Ok(musize { value: v })
    }
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, s): (usize, usize) = parse!(it, 2);
    let a: Vec<usize> = parse!(it, n);
    let mut dp: Vec<Vec<Vec<musize>>> = vec![vec![vec![0.into(); 3]; s + 1]; n + 1];
    dp[0][0][0] = 1.into();
    for i in 0..n {
        for j in 0..(s + 1) {
            dp[i + 1][j][0] = dp[i][j][0];
            dp[i + 1][j][1] += dp[i][j][1] + dp[i][j][0];
            dp[i + 1][j][2] += dp[i][j][2] + dp[i][j][1] + dp[i][j][0];
            if j + a[i] <= s {
                dp[i + 1][j + a[i]][1] += dp[i][j][1] + dp[i][j][0];
                dp[i + 1][j + a[i]][2] += dp[i][j][1] + dp[i][j][0];
            }
        }
    }
    println!("{}", dp[n][s][2]);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 549116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int Q;
int dp[128][128][128];

int dfs(int c, int a, int n){
  if(dp[c][a][n] >= 0) return dp[c][a][n];
  int res = 0;
  if(c > 0 && a > 0 && n > 0) res = max(res, dfs(c-1, a-1, n-1)+1);
  if(c > 1 && a > 0) res = max(res, dfs(c-2, a-1, n)+1);
  if(c > 2) res = max(res, dfs(c-3, a, n)+1);
  return dp[c][a][n] = res;
}

int main(){
  cin >> Q;
  rep(i, Q){
    memset(dp, -1, sizeof(dp));
    int c, a, n;
    cin >> c >> a >> n;
    int res = 0;
    while(c > 10 && a > 5 && n > 0){
      res++;
      c--;
      a--;
      n--;
    }

    while(c > 10 && a > 5){
      res++;
      c-=2;
      a--;
    }

    while(c > 10){
      res++;
      c-=3;
    }
    res += dfs(c, a, n);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 9348
n, x = map(int, input().split())

burgersize = [1]
beef_level = [2**i - 1 for i in range(1, n+2)]

a = 1
for i in range(n):
    a = 2*a + 3
    burgersize.append(a)


def eat(level, x):
    size = burgersize[level]
    half = (size + 1) // 2
    beef = beef_level[level]

    if size - 1 <= x:
        return beef

    elif x <= level:
        return 0

    elif level < x < half:
        return eat(level-1, x-1)

    elif x == half:
        return beef//2 + 1

    elif half < x < size - 1:
        return beef//2 + 1 + eat(level-1, x-half)

ans = eat(n, x)
print(ans)

Measured memory_bytes: 3188
# Kを受け取る
K = int(input())

# 文字列ACLを作るために、リストlを用意
l = ['A', 'C', 'L']

# 入力されたKの値に応じて、出力する文字列の分岐を作る
if 1<= K <= 5:
    K_letters = K*l
    out_letters = ''.join(K_letters)
    print(out_letters)

else:
    print('error')

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

string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	cout << 700 + ((s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o')) * 100;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1001001001;
ll cnt;
//merge sort
void out(int a[],int n){
    rep(j,n){
        cout << a[j];
        if(j!=n-1) cout << " ";
    }
    cout << endl;
}

void merge(int *A, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1+1),R(n2+1);
    rep(i,n1) L[i] = A[left + i];
    rep(i,n2) R[i] = A[mid + i];
    L[n1] = INF; R[n2] = INF;
    int i = 0, j = 0;
    for(int k=left;k<right;k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            cnt += n1 -i;
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int *A, int left, int right){

    if(left+1 < right){
        int mid = (left+right) / 2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

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

    int n;
    cin >> n;

    int s[n];
    rep(i,n) cin >> s[i];

    cnt = 0;
    mergeSort(s, 0, n);
    cout << cnt << endl;


    return 0;
}



Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;

//最大フロー
const int MAX_N = 510, MAX_K = 510;
const int MAX_V = 510 * 510;

struct edge{
    int to, cap, rev;
};

//vector<edge> G[MAX_N];
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        // cout << f << endl;
        if(f == 0) return flow;
        flow += f;
    }
}

char c[110][110];

signed main(){
    int h, w;
    cin >> h >> w;
    int s, t;
    int st = 201, ed = 202;    
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> c[i][j];
            if(c[i][j] == 'o'){
                add_edge(100 + i, j, 1);
                add_edge(j, 100 + i, 1);
            }else if(c[i][j] == 'S'){
                s = i * 100 + j;
                add_edge(st, 100 + i, INF);
                add_edge(st, j, INF);
            }else if(c[i][j] == 'T'){
                t = i * 100 + j;
                add_edge(100 + i, ed, INF);
                add_edge(j, ed, INF);
            }
        }
    }
    if(s % 100 == t % 100 || s / 100 == t / 100){
        cout << -1 << endl;
        return 0;
    }

    cout << max_flow(st, ed) << endl;
}

Measured memory_bytes: 7808
// Atcoder Regular Contest 061
// Problem E - Snuke's Subway Trip
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::priority_queue;
#include <deque>
using std::deque;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);

const int maxN = 100000 + 233;
const int maxM = 200000 + 233;
const int NODE = 1000000 + 2333;
const int INF = 0x3f3f3f3f;
int n, m;
struct Edge {
	int from, to, com;
	Edge() {}
	Edge(int f, int t, int c) : from(f), to(t), com(c) {}
};
vector<Edge> edges;
vector<int> G[maxN];
vector<pii> H[NODE];

int cnt = 0;
void addEdge(int x, int y, int z) {
//	printf("%d->%d : %d\n", x, y, z);
	H[x].push_back(pii(y, z));
}

int d[NODE]; bool vis[NODE];
priority_queue<pii, vector<pii>, std::greater<pii> > pq;
int BFS(int s, int t) {
	for(int i = 0; i <= cnt; ++i) d[i] = INF, vis[i] = false;
	d[s] = 0; pq.push(pii(0, s));
	while(!pq.empty()) {
		int u = pq.top().second; pq.pop();
		if(u == t) return d[u];
		if(vis[u]) continue; else vis[u] = true;
		for(pii p : H[u]) {
			int v = p.first, dist = p.second;
			if(d[v] > d[u] + dist) {
				d[v] = d[u] + dist;
				pq.push(pii(d[v], v));
			}
		}
	}
	return -1;
}

bool cmp(int x, int y) {
	return edges[x].com < edges[y].com;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		edges.push_back(Edge(x, y, z));
		G[x].push_back(edges.size() - 1);
		G[y].push_back(edges.size() - 1);
	}
	
	cnt = n + edges.size() + 233;
	for(int u = 1; u <= n; ++u) {
		sort(G[u].begin(), G[u].end(), cmp);
		for(int i = 0; i < G[u].size(); ++i) {
			++cnt;
//			printf("Node created in %d: #%d\n", u, cnt);
			addEdge(u, cnt, 1); addEdge(cnt, u, 0);
			for(int j = i; j < G[u].size() && edges[G[u][i]].com == edges[G[u][j]].com; ++j) {
				i = j;
				addEdge(cnt, n + 1 + G[u][j], 0); addEdge(n + 1 + G[u][j], cnt, 0);
			}
		}
	}
	printf("%d\n", BFS(1, n));
	return 0;
}

Measured memory_bytes: 64048
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

ll n, a[maxn], x[maxn];

int main() {
    n = read();
    reg ll sum = 0;
    for (reg int i = 1; i <= n; i++) a[i] = read(), sum += a[i];
    reg ll num = 0;
    for (reg int i = 1; i <= (n - 1); i += 2) {
        num += a[i];
    }
    x[n] = (sum / 2 - num) * 2;
    for (reg int i = n - 1; i >= 1; i--) {
        x[i] = 2 * (a[i] - x[i + 1] / 2);
    }
    for (int i = 1; i <= n; i++) cout << x[i] << " ";
    return 0;
}


Measured memory_bytes: 2816
s=input()
if s[0]!='A':
    print('WA')
else:
    count=0
    for i in range(2,len(s)-1):
        if s[i]=='C':
            count+=1
    if count!=1:
        print('WA')
    else:
        a=list(s)
        a.remove('A')
        a.remove('C')
        b=''.join(a)
        if b.islower():
            print('AC')
        else:
            print('WA')

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

void solve(std::vector<long long> H, std::vector<long long> M, long long K) {
    cout << (H[1] - H[0]) * 60 + M[1] - M[0] - K << endl;
}

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


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

int main(){
	int m, n;
	cin >> n >> m;
	int *a = new int[n*m];
	int *b = new int[m];

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

	int sum;
	for (int i = 0; i < n; i++){
		sum = 0;
		for (int j = 0; j < m; j++){
			sum += a[i*m+j] * b[j];
		}
		cout << sum << endl;
	}

	delete[] a;
	delete[] b;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9

int main() {
    int N;
    cin >> N;
    int div = 0;
    int count = 0;
    for(int i=1; i<=N; i+=2){
        for (int j=1; j<=i; j++){
            if (i%j == 0){
                div ++;
            }
        }
        if (div == 8){
            count ++;
        }
        div = 0;

    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

N,M = [int(x) for x in stdin.readline().rstrip().split()]
ab_dict = {}
amount = 0
money = 0

for _ in range(N):
  a,b = [int(x) for x in stdin.readline().rstrip().split()]
  if a in ab_dict: ab_dict[a] += b
  else: ab_dict[a] = b

ab_dict = sorted(ab_dict.items())

for a, b in ab_dict:
  if(b > M - amount):
    money += a * (M - amount)
    break
  else:
    money += a * b
    amount += b

print(money)

Measured memory_bytes: 23000
#include <iostream>

using namespace std;

int main() {
	int N,W;
	cin >> N >> W;
	int val[110],weight[10010];
	for (int i=0;i<N;i++) {
		cin >> val[i] >> weight[i];
	}
	int res[110][10010];
	//res[number][weight]
	for (int i=0;i<N+1;i++) {
		res[i][0] = 0;
	}
	for (int i=0;i<W+1;i++) {
		res[0][i] = 0;
	}

	for(int i=1;i<N+1;i++) {
		for(int j=1;j<W+1;j++) {

			if (weight[i-1] > j) {

				res[i][j] = res[i-1][j];

			} else {

				res[i][j] = max((val[i-1]+res[i-1][j-weight[i-1]]),res[i-1][j]);
			}
		}
	}
	//for(int j=1;j<W+1;j++) {
	//	cout << endl;
	//	for(int i=1;i<N+1;i++) {
	//		cout << res[i][j] << " ";
	//	}
	//}


	cout << res[N][W] << endl;
}

/*
????????£????????????1?????????????????????????????????????????????????????????????´???°????????????????????¨Runtime error????????????????????????????????????????????\??????????????¨??£??????
*/

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

template<uint32_t N = 10'000'000>
struct Sieve_of_Eratosthenes{
  using u32 = uint32_t;
  std::vector<u32> factor;
  Sieve_of_Eratosthenes(){
    factor.resize(N+1);
    for(u32 p=2;p<=N;++p){
      if(factor[p])continue;
      factor[p] = p;
      for(u32 x=p+p;x<=N;x+=p){
        if(factor[x])continue;
        factor[x] = p;
      }
    }
  }
  std::vector<u32> prime_factor(u32 x){
    std::vector<u32> pf;
    while(factor[x]){
      pf.push_back(factor[x]);
      x /= factor[x];
      while(factor[x]==pf.back())x/=factor[x];
    }
    return pf;
  }
};

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

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  constexpr int a_max = 1e6;
  Sieve_of_Eratosthenes ushi;

  map<int,int> mp;
  bool pairwise_coprime = true;
  for(auto const& ai:a){
    for(auto const& p:ushi.prime_factor(ai)){
      if(mp.count(p)){
        pairwise_coprime = false;
        break;
      }
      mp[p]++;
    }
  }
  
  if(pairwise_coprime){
    cout<<"pairwise coprime"<<endl;
    return 0;
  }

  bool setwise_coprime = accumulate(begin(a),end(a),0,[](auto a,auto b){return gcd(a,b);}) == 1;
  if(setwise_coprime){
    cout<<"setwise coprime"<<endl;
    return 0;
  }

  cout<<"not coprime"<<endl;


}

Measured memory_bytes: 49796
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n;
  while(cin >> n && n) {
    multimap<int,string> ans;
    for(int i=0; i<n; i++) {
      string name;
      cin >> name;
      int x,rank=500;
      for(int j=0; j<n-1; j++) {
	cin >> x;
	if(x==0) {
	  rank+=1000;
	} else if(x==1) {
	  rank--;
	}
      }
      string t=name;
      ans.insert(make_pair(rank,t));
    }
    vector<string> a;
    int d[n],k=-1,m=-1;
    fill(d,d+n,0);

    for(multimap<int,string>::reverse_iterator it=ans.rbegin(); it!=ans.rend(); it++) {
      if(m!=it->first) {
	k++;
	m=it->first;
      }
      d[k]++;
      a.push_back(it->second);
    }
    k=0;
    for(int i=0; i<n; i++) {
      for(int j=i+d[k]-1; j>=i; j--) cout << a[j] << endl;
      i+=d[k]-1;
      k++;
    }
  }
  return 0;
}


Measured memory_bytes: 1208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split();
            int k = int.Parse(data[0]);
            int s = int.Parse(data[1]);
            string k_cnt = "";
            string s_cnt = "";

            for(int i = 0; i < s; i++)
            {
                k_cnt += data[0];
            }

            for (int i = 0; i < k; i++)
            {
                s_cnt += data[1];
            }

            if (k <= s)
            {
                Console.WriteLine(k_cnt);
            }
            else
            {
                Console.WriteLine(s_cnt);
            }

            
            //Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
# -*- coding: utf-8 -*-

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB = sorted(AB, reverse=True)
if K < len(AB):
    AB = AB[:K]

ABC = []
for ab in AB:
    for c in C:
        ABC.append(ab + c)

ABC = sorted(ABC, reverse=True)
ABC = ABC[:K]

print("\n".join(map(str, ABC)))


Measured memory_bytes: 147840
#include<stdio.h>

int main()
{
    int i, j, k, num;
    char buffer[25];
    int b, f, r, v;
    int house[4][3][10]={{{0}}};
    
    fgets(buffer, 25, stdin);
    sscanf(buffer, "%d", &num);
    //scanf("%d", &num);
    //num =3;
    for(i=0;i<num;i++)
    {
        fgets(buffer, 25, stdin);
        sscanf(buffer, "%d %d %d %d", &b, &f, &r, &v);
        house[b-1][f-1][r-1] += v;
    }
    
    for(k=0;k<4;k++)
    {
        for(i=0;i<3;i++)
        {
            for(j=0;j<10;j++)
            {
                printf(" %d", house[k][i][j]);
            }
        putchar('\n');
        }
        if(k!=3)
        printf("####################\n");
    }

    return(0);
}


Measured memory_bytes: 2032
import sys
input = sys.stdin.readline

x, y = map(int, input().split())

if y < 2*x:
    print('No')
elif y % 2 != 0:
    print('No')
else:
    for i in range(x+1):
        if i*2 + (x-i)*4 == y:
            print('Yes')
            break
        elif i == x:
            print('No')

Measured memory_bytes: 9188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input!{
        source = src,
        n: usize,
        an: [usize; n],
    }
    return _solve(an).to_string();
}

fn _solve(an: Vec<usize>) -> usize {
    let mut count : usize = 0;
    for a in an.iter() {
        if a % 2 == 0 {
            let mut aa = *a;
            loop {
                aa = aa / 2;
                count += 1;
                if aa % 2 != 0 {
                    break;
                }
            }
        }
    }

    return count;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s;
    cin >> s;
    cout << (regex_match(s, regex(R"(A?KIHA?BA?RA?)")) ? "YES" : "NO") << endl;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;
	f(i,0,n-1){
	    cin>>ara[i];
        maxi=max(maxi,ara[i]);
        mini=min(mini,ara[i]);
	}
	cout<<maxi-mini<<endl;


}


Measured memory_bytes: 256
/*
[abc129] A - Airplane
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int d[3];

ll solve() { return accumulate(d, d + 3, 0) - *max_element(d, d + 3); }

int main() {
    for (int i = 0; i < 3; i++) {
        cin >> d[i];
    }

    cout << solve() << endl;

    return 0;
}


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

int main() {
  int D, N;
  cin >> D >> N;
  vector<int> T(D), A(N), B(N), C(N);
  for (int i = 0; i < D; ++i) {
    cin >> T[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i] >> C[i];
  }

  vector<vector<int>> dp(D + 1, vector<int>(N + 1, -1));
  for (int i = 0; i < N; ++i) {
    if (A[i] <= T[0] && T[0] <= B[i]) {
      dp[1][i + 1] = 0;
    }
  }

  for (int i = 1; i < D; ++i) {
    for (int j = 0; j < N; ++j) {
      if (dp[i][j + 1] == -1) {
        continue;
      }

      for (int k = 0; k < N; ++k) {
        if (A[k] <= T[i] && T[i] <= B[k]) {
          dp[i + 1][k + 1] =
              max(dp[i][j + 1] + abs(C[j] - C[k]), dp[i + 1][k + 1]);
        }
      }
    }
  }

  int ans = -1;
  for (int i = 1; i <= N; ++i) {
    ans = max(dp[D][i], ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3232