akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static int[][][] oh = new int[4][3][10];

	public static void main(String[] args) {
		int[] edit = new int[4];
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 4; j++) {
				edit[j] = sc.nextInt();
			}
			editRoom(edit[0], edit[1], edit[2], edit[3]);
		}

		dispHouse();

		sc.close();
	}

	private static void dispHouse() {

		for(int i = 0; i < oh.length; i++) {
			for(int j = 0; j < oh[0].length; j++) {
				for(int k = 0; k < oh[0][0].length; k++) {

					System.out.print(" " + oh[i][j][k]);

				}

					System.out.println();
			}
				if (i < oh.length - 1) {
					System.out.println("####################");
				}

		}

	}

	public static void editRoom(int b, int f, int r, int v){
		oh[b - 1][f - 1][r - 1] += v;
	}
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;


main() {
    cin >> a >> b;
    ct((a+b+1)/2)
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n;cin>>n;
    vl dp(n+1);
    dp[0]=dp[1]=1;
    fore(i,2,n)dp[i]=dp[i-2]+dp[i-1];
    cout<<dp[n]<<endl;
}

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



Measured memory_bytes: 3220
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n, n_numbers, n_min, n_max, i;
  long long n_sum=0;
  cin >> n;
  n_min = 1000000;
  n_max = -1000000;
  n_sum = 0;
  for(i=0 ;i<n;i++){
    cin >> n_numbers;
    n_min=min(n_min,n_numbers);
    n_max=max(n_max,n_numbers);
    n_sum += n_numbers;
  }
  cout << n_min << " " << n_max << " " << n_sum << endl;
  return 0;
}


Measured memory_bytes: 3100
M, D = map(int, input().split())
ans = 0
for m in range(1, M + 1):
    for d in range(22, D + 1):
        d1 = d % 10
        if 2 > d1:
            continue
        d10 = d // 10
        if d1 * d10 == m:
            ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

struct edge {
  int to;
  ll cost;
  edge(int t, ll c): to(t), cost(c) {};
};

using P = pair<ll, int>;

vector<ll> d;
vector<int> par;
void dijkstra(int s, int N, vector<vector<edge>>& G) {
  priority_queue<P, vector<P>, greater<P>> que;
  d = vector<ll>(N, longinf);
  par = vector<int>(N, -1);
  d[s] = 0;
  que.push(P(0, s));

  while(!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;

    for(int i=0; i<(int)G[v].size(); i++) {
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
        par[e.to] = v;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<vector<edge>> G(n);
  rep(i, n-1) G[i+1].push_back({i, 0});
  vector<int> L(m), R(m);
  vector<ll> C(m);
  rep(i, m) {
    cin >> L[i] >> R[i] >> C[i];
    G[--L[i]].push_back({--R[i], C[i]});
  }
  dijkstra(0, n, G);
  cout << (d[n-1]==longinf ? -1 : d[n-1]) << "\n";
  return 0;
}


Measured memory_bytes: 14676
#include<cstdio>
#include<vector>

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

using namespace std;

typedef long long ll;

const int P_MAX=100000;
vector<int> P;
void sieve(){
	static bool er[P_MAX+1];
	rep(i,P_MAX+1) er[i]=(i>=2);
	for(int i=2;i*i<=P_MAX;i++) if(er[i]) for(int j=i*i;j<=P_MAX;j+=i) er[j]=false;
	rep(i,P_MAX+1) if(er[i]) P.push_back(i);
}

vector< pair<double,ll> > sa; // <テ渉?n)/n, n>
void dfs(int i,long double a,int e,ll sigma){
	sa.push_back(make_pair(sigma/a,a));
	ll sigma2=sigma;
	for(int j=1;j<=e;j++){
		if(a>1e15) return;
		a*=P[i];
		sigma2=P[i]*sigma2+sigma;
		dfs(i+1,a,j,sigma2);
	}
}

int main(){
	sieve();

	dfs(0,1,77,1);

	for(ll n;scanf("%lld",&n),n;){
		double ans=1;
		rep(i,sa.size()) if(sa[i].second<=n && sa[i].first>ans) ans=sa[i].first;
		printf("%.9f\n",ans);
	}

	return 0;
}

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

int main() {
    int N; cin >> N;
    int M; cin >> M;
    int ans = 0;
    int n = N - 1;
    int m = M - 1;
    ans += N * n / 2;
    ans += M * m / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << (A <= 8 && B <= 8 ? "Yay!" : ":(") << endl;
	return 0;
}

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

int d[10][10];

int main() {

    int H, W;
    cin >> H >> W;
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> d[i][j];
        }
    }

    for(int k = 0; k < 10; k++) {
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if(a == -1) continue;
            ans += d[a][1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

def count(n,s):
    if s == 0:
        return 3**n - 3*(2**n) + 3
    elif s == 1:
        return 3**n - 2**(n+1) + 1
    elif s == 2:
        return 3**n - 2**n
    else:
        return 3**n

def num753(Nlist, appeared):
    n = len(Nlist)
    if n == 0:
        if appeared == 7:
            return 1
        else:
            return 0
    
    top = Nlist[-1]
    
    ap3 = appeared|1
    s3 = ap3 % 2 + (ap3 % 4)//2 + ap3 // 4
    ap5 = appeared|2
    s5 = ap5 % 2 + (ap5 % 4)//2 + ap5 // 4
    ap7 = appeared|4
    s7 = ap7 % 2 + (ap7 % 4)//2 + ap7 // 4

    if appeared == 0:
        ans = sum([count(i,0) for i in range(3,n)])
    else:
        ans = 0

    if top < 3:
        pass
    elif top == 3:
        ans = ans + num753(Nlist[:-1],ap3)
    elif top == 4:
        ans = ans + count(n-1,s3)
    elif top == 5:
        ans = ans + count(n-1,s3) + num753(Nlist[:-1],ap5)
    elif top == 6:
        ans = ans + count(n-1,s3) + count(n-1,s5)
    elif top == 7:
        ans = ans + count(n-1,s3) + count(n-1,s5) + num753(Nlist[:-1],ap7)
    else: # top == 8,9
        ans = ans + count(n-1,s3) + count(n-1,s5) + count(n-1,s7)
    
    return ans

N = int(input())
Nlist=[]
while N > 0:
    Nlist.append(N % 10)
    N = N // 10
Nlist = np.array(Nlist,dtype=np.int)

print(num753(Nlist,0))

Measured memory_bytes: 20148
# input
N = int(input())
K = int(input())
X = list(map(int, input().split()))

ans = 0

for i in range(N):
    if X[i] >= K - X[i]:
        ans += 2 * (K - X[i])
    else:
        ans += 2 * X[i]

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


string chan(string s){
    string res;
    res+=s[0];
    for(int i=0;i<s.size()-1;i++)if( s[i] == 'a' || s[i] == 'i' || s[i] =='u' || s[i] == 'e'||s[i] =='o'){
	res+=s[i+1];
    }
    return res;
}

int main(){
    while(1){
    int n;
    cin>>n;
    if(n==0)break;
    vector<string> s(n);
    int k = 0;
    bool f = true;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++)s[i] = chan(s[i]);
    for(int i=0;i<n&&f;i++){
	for(int j=i+1;j<n&&f;j++){
	    int cnt = 0;
	    if( s[i] == s[j] ){
		f = false;
		cout<<-1<<endl;
		break;
	    }
	    for(int l = 0;l< min( s[i].size() , s[j].size() );l++){
		if(s[i][l] == s[j][l] )cnt++;
		else break;
	    }
	    k = max( k , cnt);
	}
    }
    if(f)
    cout<<k+1<<endl;
    }
    return 0;
}



Measured memory_bytes: 3080
import math
import sys
input = sys.stdin.readline


def main():
    N = int(input())

    answer = 0
    for a in range(1, math.ceil(N**(1 / 2))):
        for b in range(a, N):
            c = (N - a * b)
            if c <= 0:
                break
            if a != b:
                answer += 2
            else:
                answer += 1
    print(answer)


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  string S;
  vector<int> c(26, 0);
  for (int i = 0; i < n; i++) {
    cin >> S;
    vector<int> tmp(26, 0);
    for (char s : S) {
      tmp[s - 'a']++;
    }
    for (int j = 0; j < 26; j++) {
      if (i == 0) {
        c[j] = tmp[j];
      } else {
        c[j] = min(c[j], tmp[j]);
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < c[i]; j++) {
      cout << (char)('a' + i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, h;
  cin >> n >> h;
  vector<P> A(n);
  ll maxa = 0;
  rep(i,n) {
    cin >> A[i].second >> A[i].first;
    chmax(maxa, A[i].second);
  }
  sort(all(A), greater<P>());
  ll ans = 0;
  rep(i,n) {
    if (A[i].first < maxa || h <= 0) break;
    h -= A[i].first; //投げて攻撃
    ans++;
    debug(ans, h);
  }
  if (h > 0) {
    ans += (h+maxa-1)/maxa; //振って攻撃
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> x(n+1, 0);
    priority_queue<pair<int, int> > pq;

    for(int i=0; i<q; ++i){
        int a, v;
        cin >> a >> v;
        x[a] += v;
        pq.push(make_pair(x[a], -a));

        for(;;){
            int b = -pq.top().second;
            int w = pq.top().first;
            if(x[b] == w){
                cout << b << ' ' << w << endl;
                break;
            }
            pq.pop();
        }
    }

    return 0;
}

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

using namespace std;

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;

  int dx=tx-sx,dy=ty-sy;

  cout<<string(dy,'U')<<string(dx,'R');
  cout<<string(dy,'D')<<string(dx,'L');
  cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
  cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';

  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll a, b;
        cin >> a >> b;

        if (a * b <= 0) {
                cout << "Zero" << endl;
                return 0;
        }

        if (a > 0) {
                cout << "Positive" << endl;
        } else {
                ll n = b - a + 1;
                if (even(n)) {
                        cout << "Positive" << endl;
                } else {
                        cout << "Negative" << endl;
                }
        }
}


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

using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;

template<typename C>
i64 Size(const C& c) { return static_cast<i64>(c.size()); }

template<typename C>
void Sort(C &c) { std::sort(c.begin(), c.end()); }

template<typename C>
void SortR(C &c) { std::sort(c.rbegin(), c.rend()); }

template<typename T, typename U, typename Comp=std::less<>>
bool ChMax(T& x_max, const U& x, Comp comp={}) {
  if(comp(x_max, x)) {
    x_max = x;
    return true;
  }
  return false;
}

template<typename T, typename U, typename Comp=std::less<>>
bool ChMin(T& x_min, const U& x, Comp comp={}) {
  if(comp(x, x_min)) {
    x_min = x;
    return true;
  }
  return false;
}

struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;

  ProconInit() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(IOS_PREC);
    if (AUTOFLUSH) std::cout << std::unitbuf;
  }
} PROCON_INIT;

void solve() {
  i64 n; std::cin >> n;
  std::vector<i64> a(n - 1); for (auto &i : a) std::cin >> i;

  std::map<i64, i64> m;
  for (i64 i = 1; i <= n; i++) m[i] = 0;

  for (auto &i : a) {
    m[i]++;
  }

  for (auto &i : m) {
    std::cout << i.second << "\n";
  }
}

signed main() {
  solve();

  return 0;
}


Measured memory_bytes: 17192
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <string.h>
#include <array>
#include <bitset>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << '\n';
	return 0;
}

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

public class Main {

	public static void main(String[] args)throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a[]=new int[5],p=0;
		StringTokenizer st = new StringTokenizer(br.readLine());
		for(int i=0; i<5; i++) {
			a[i]=Integer.parseInt(st.nextToken());
			if(a[i]==0) p=i+1;
		}
		System.out.println(p);
	}

}


Measured memory_bytes: 32528
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int sz[110000];
vector<pair<int,int> >g[110000];
int L[110000];
int R[110000];
int N;
long long ret[110000];
long long c[110000];
void dfs(int a,int b){
	sz[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i].first)continue;
		dfs(g[a][i].first,a);
		sz[a]+=sz[g[a][i].first];
		L[g[a][i].second]=sz[g[a][i].first];
		R[g[a][i].second]=N-sz[g[a][i].first];
	}
}
int sz2[110000];
long long calc(int a,int b){
	sz2[a]=1;
	long long re=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i].first)continue;
		long long tmp=calc(g[a][i].first,a);
		sz2[a]+=sz2[g[a][i].first];
		re+=tmp+ret[g[a][i].second]*sz2[g[a][i].first];
	}
	return re;
}
int x[110000];
int y[110000];
int main(){
	int a;scanf("%d",&a);
	N=a;
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(make_pair(q,i));
		g[q].push_back(make_pair(p,i));
		x[i]=p;
		y[i]=q;
	}
	dfs(0,-1);
	for(int i=0;i<a;i++)scanf("%lld",c+i);
		int at=-1;
	for(int i=0;i<a-1;i++){
		if(L[i]!=R[i]){
			long long T=ABS(c[x[i]]-c[y[i]]);
			long long D=ABS(L[i]-R[i]);
			ret[i]=T/D;
			assert(T%D==0);
		}else{
			assert(at==-1);
			at=i;
		}
	}
	if(~at){
		long long dist=calc(x[at],y[at])+calc(y[at],x[at]);
		ret[at]=(c[x[at]]-dist)/(a/2);
	}
	for(int i=0;i<a-1;i++)printf("%lld\n",ret[i]);
}

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

int main(){
  string s, t, u;
  cin >> s >> t;
  int A,B;
  cin >> A >> B;
  cin >> u;
  if(s == u) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
}

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

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

  for (int i=a; i<=b; i++){
    if (c % i == 0) sum++;
  }

  cout<<sum<<endl;
  return 0;
}
		     



Measured memory_bytes: 3088
tailrec fun solve():Unit{
    val (n, m, a) = readLine()!!.split(' ').map(String::toInt)
    if (n == 0 && m == 0 && a == 0) return
    var pos = a
    Array(m){
        val (h, p, q) = readLine()!!.split(' ').map(String::toInt)
        Border(h, p, q)
    }.sortedByDescending(Border::height).forEach {
        if (it.a == pos){
            pos = it.b
        }else if (it.b == pos){
            pos = it.a
        }
    }
    println(pos)
    solve()
}
fun main(args:Array<String>):Unit {
    solve()
}
data class Border(val height:Int, val a:Int, val b:Int)


Measured memory_bytes: 75804
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	sort(a.begin(), a.end(), greater<int>());

	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i * 2 + 1];
	}

	cout << sum << endl;
	return 0;
}

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

JPY = 'JPY'
BTC = 'BTC'
RAITO_BTC_TO_JPY = 380000
# 1.0 BTC == 380000.0 円

def solve(N: int, x: "List[float]", u: "List[str]"):
    #x_ = list(map(standardize_to_JPY, zip(x,u)))
    x_ = []
    for i in range(N):
        x_.append(standardize_to_JPY(x[i], u[i]))
    print(sum(x_))
    return

def standardize_to_JPY(xi, ui):
    if ui == BTC:
        return xi * RAITO_BTC_TO_JPY
    else:
        return xi

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]" 
    u = [str()] * (N)  # type: "List[str]" 
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,i] <- getIntList
    print $ n+1-i

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    ll x;
    cin>>x;
    vi v;
    for(ll i=2; i*i<=x;i++)
    {
        if(x%i==0)
        {
            int pow=0;
            while(x%i==0)
            {
                x/=i;
                pow++;
            }
            v.pb(pow);
        }
    }
    if(x!=1)v.pb(1);

    ll ans=0;

    for(auto z:v)
    {
        rep(i,1,10)
        {
            j= i*(i+1)/2;
            if(j>z)break;
        }
        
        i--;
        ans+=i;
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 3656
a = int(input())
b = list(map(int, input().split()))
b.sort()
c = 1 if a % 2 == 0 else 0
for i in range(a):
    if (a % 2) ^ (i % 2) == 0 and i != 0:
        c += 2
    if b[i] != c:
        print(0)
        exit()
print((2 ** (a // 2)) % (10 ** 9 + 7))


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

const int N=3005,mod=1e9+7;
int n,m,f[N][N][2],ans;
void Inc(int &x,int y) {x+=y, x=x>=mod?x-mod:x;}
int main()
{
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for(int i=1;i<=n;++i) f[0][i][0]=1;
	for(int i=0;i<m;++i) {
		for(int j=0;j<=n;++j) {
			for(int o=0;o<2;++o) {
				if(j<n) {
					Inc(f[i+1][j+1][o],f[i][j][o]);
					Inc(f[i+1][j][o],f[i][j][o]);
				}
				if(j>0) {
					Inc(f[i+1][j-1][o],f[i][j][o]);
					if(j == 1 && !o) Inc(f[i+1][j][1],f[i][j][0]);
					else Inc(f[i+1][j][o],f[i][j][o]);
				}
			}
		}
		Inc(f[i+1][0][1], f[i+1][0][0]), f[i+1][0][0]=0;
	}
	for(int i=0;i<=n;++i) Inc(ans,f[m][i][1]);
	printf("%d",ans);
	return 0;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

ll binpow(ll a, ll b, const ll mod) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = (ans * a) % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, p; cin >> n >> p;
    string s; cin >> s;

    if (p == 2 or p == 5) {
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            if ((s[i] - '0') % p == 0)
                ans += i + 1;
        }
        cout << ans << '\n';
        return 0;
    }

    vector<int> rem(p, 0);
    rem[0] = 1;
    ll cur = 0;
    for (int i = 0; i < n; ++i) {
        cur *= 10;
        cur += (s[i] - '0');
        cur %= p;
        ll val = binpow(10, n - i - 1, p) * cur;
        val %= p;
        ++rem[val];
    }

    auto choose2 = [&](int n) -> long long {
        if (n <= 1) return 0;
        return 1ll * n * (n - 1) / 2;
    };

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

    cout << ans << '\n';

}

Measured memory_bytes: 720
#include<stdio.h>
int main(){

	int a,b,c;
	unsigned int i,count = 0;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	for(i = a;i <= b;i++){

		if(c % i == 0){
			count++;
		}

	}
	printf("%d\n",count );


return 0;
}

Measured memory_bytes: 1860
import math
import itertools
import sys

def main():
  n = int(input())
  X = list(map(int, input().split()))
  Y = list(map(int, input().split()))

  p1 = 0
  p2 = 0
  p3 = 0
  pf = 0

  for i in range(n):
    p1 += math.sqrt((X[i] - Y[i]) ** 2)
    p2 += (X[i] - Y[i]) ** 2
    p3 += (math.sqrt((X[i] - Y[i]) ** 2)) ** 3
    if pf < math.sqrt((X[i] - Y[i]) ** 2):
      pf = math.sqrt((X[i] - Y[i]) ** 2)

  p2 = math.sqrt(p2)
  p3 = p3 ** (1/3)

  print(p1,p2,p3,pf, sep='\n')

if __name__ == '__main__':
  main()


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int power(int n)
{
    int num=1;
    for(int i=0;i<n;i++)num*=10;
    return num;
}
int main()
{
    string str;
    while(getline(cin,str)){
        stack<double> st;
        for(int i=0,point=0;;i++){
            if(str[i]==' '||str[i]=='\0'){
                if(i-point==1){
                    if(str[point]-'0'>9||str[point]-'0'<0){
                        double righ=st.top();
                        st.pop();
                        double lef=st.top();
                        st.pop();
                        if(str[point]=='+')st.push(lef+righ);
                        else if(str[point]=='-')st.push(lef-righ);
                        else if(str[point]=='*')st.push(lef*righ);
                        else st.push(lef/righ);
                        }
                    else st.push(str[point]-'0');
                }
                else{
                    double now=0;
                    bool kawa=0;
                    if(str[point]=='-'){
                        point++;
                        kawa=1;
                    }
                    for(int j=point;j<i;j++)now+=(str[j]-'0')*power(i-j-1);
                    if(kawa)now*=-1;
                    st.push(now);
                }
                if(str[i]=='\0')break;
                point=i+1;
            }
        }
        printf("%lf\n",st.top());
    }
}

Measured memory_bytes: 1232
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	while (true) {
		scanf("%d %c %d", &a, &op, &b);
		switch (op) {
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a*b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		default:
			return 0;
		}
	}
	return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;

    int a[50], b[50], c[50], d[50];
    for (int i=0; i<Q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    int mx = 0;
    vector<int> A;
    function<void(int)> dfs = [&](int val) {
        if ((int)A.size() == N) {
            int pt = 0;
            for (int i=0; i<Q; ++i) {
                if (abs(A[a[i]] - A[b[i]]) == c[i]) pt += d[i];
            }
            mx = max(mx, pt);
            return;
        }
        for (int i=val; i<=M; ++i) {
            A.push_back(i);
            dfs(i);
            A.pop_back();
        }
    };
    dfs(1);

    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;
 
 int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if(s*t>=d) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];
    sort(all(a));
    reverse(all(a));

    ll sum = 0;
    int cnt = 0;
    rep (i, n) {
        if (cnt == n - 1) break;
        int nn;
        if (i == 0) nn = 1;
        else nn = 2;
        rep (_, nn) {
            sum += a[i];
            cnt++;
            if (cnt == n - 1) break;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const int MAXN=1000+20;
int dp[MAXN][MAXN];
int maze[MAXN][MAXN];
int h,w,n,sx[10],sy[10],temp;
void input(){
	memset(maze,-1,sizeof(maze));
	cin>>h>>w>>n;
	cin.get();
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			char x;
			x=cin.get();
			if(x=='.') maze[i][j]=0;
			if(x=='X') maze[i][j]=-1;
			if(x>='0' && x<='9'){
				maze[i][j]=x-'0';
				sx[x-'0']=i;
				sy[x-'0']=j;
			}
			if(x=='S'){
				maze[i][j]=0;
				sx[0]=i;
				sy[0]=j;
			}
		}
		cin.get();
	}
//	for(int i=0;i<10;++i) cout<<sx[i]<<' '<<sy[i]<<endl;
/*	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cout<<setw(4)<<maze[i][j];
		}
		cout<<endl;
	}*/
}
void bfs(int xx,int yy,int nn){
	queue <int> tx;
	queue <int> ty;
	tx.push(xx);
	ty.push(yy);
	while(tx.size() && ty.size()){
		int qx=tx.front(),qy=ty.front();
		tx.pop();
		ty.pop();
		for(int i=0;i<4;++i){
			int x=qx+dx[i],y=qy+dy[i];
			if(maze[x][y]==-1 || dp[x][y]>=0) continue;
			tx.push(x);
			ty.push(y);
			dp[x][y]=dp[qx][qy]+1;
			if(x==sx[nn] && y==sy[nn]){
				temp=dp[qx][qy];
//				cout<<temp<<endl;
				break;
			}
//			cout<<x<<' '<<y<<' '<<dp[x][y]<<endl;
		}
	}
//	cout<<endl;
}
void solve(){
	for(int i=0;i<n;++i){
//		cout<<temp<<endl;
		memset(dp,-1,sizeof(dp));
//		cout<<sx[i+1]<<' '<<sy[i+1]<<endl;
		dp[sx[i]][sy[i]]=temp;
		bfs(sx[i],sy[i],i+1);
	}
	cout<<dp[sx[n]][sy[n]]+n-1<<endl;
}
int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 11272
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
ll n, m, q,c;
ll bit[40];
ll keta[100010];
ll kubaru(ll a){
   int i = -1;
   while(a)
   {
	  i++;
	  if (a >0)bit[i]++;
	  a >>= 1;
   }
   return i;
}

int main() {
   cin >> n >> m;
   VLL a(n);
   rep(i, n)cin >> a[i];
   sort(a.begin(), a.end());
   for (int i = 0; i < n; i++)
   {
	  keta[i]=kubaru(a[i]);
   }
   ll sum = 0;
   int res = m;
   int i = 39;
   while( i>=1)
   {
	  sum += bit[i];
	  if (sum > m)
	  {
		 sum -= bit[i];
		 break;
	  }
	  i--;
   }
   if (i == 0) {
	  cout << max((ll)0, n - (m - sum)) << endl;
	  return 0;
   }
   for (int l = 0; l < n; l++)
   {
	  a[l] >>= max((ll)0,(keta[l] - i));
   }
   sort(a.begin(), a.end());
   ll ans = 0;
   rep(l, m - sum) {
	  a[n - 1 - l] /= 2;
   }
   rep(i, n)ans += a[i];
   cout << ans << endl;
}

Measured memory_bytes: 1792
n=int(input())
s=[]
ans=0
a=0
b=0
ba=0
for i in range(n):
    s.append(input())
    
for i in range(n):
    flg=0
    if s[i][0]=="B":
        b+=1
    if s[i][-1]=="A":
        a+=1
        if s[i][0]=="B":
            ba+=1
            
    for j in range(len(s[i])):
        if s[i][j]=="B" and flg==1:
            ans+=1
            
        if s[i][j]=="A":
            flg=1
        else:
            flg=0
if ba==a and ba==b and ba!=0:
    ans+=(ba-1)
else:
    ans+=min(a,b)
print(ans)

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(l.rbegin(), l.rend());
    cout << accumulate(l.begin(), l.begin() + k, 0) << endl;
}


Measured memory_bytes: 3572
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int MOD1, MOD2;
int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm_plus(int a, int b) {                                                        //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD1; b; a = a * a % MOD1, b >>= 1)
    if (b & 1) res = res * a % MOD1;
  return res;
}
int bpm_minus(int a, int b) { //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD2; b; a = a * a % MOD2, b >>= 1)
    if (b & 1) res = res * a % MOD2;
  return res;
}

class DAnythingGoesToZero {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    string X;
    cin >> N >> X;
    vector<int> process(200010, 0);
    REP(i, 1, 200001) {
      int temp = 0;
      rep(j, 20) if ((i >> j) & 1) temp++;
      process[i] = 1 + process[i % temp];
    }
    int zero, one;
    zero = 0;
    FOR(i, X)
    if (i == '0') zero++;
    one   = N - zero;
    int p = INF;
    if (one == 1) {
      rep(i, N) if (X[i] == '1') {
        p = i;
        break;
      }
    }
    int plus = 0, minus = 0;
    MOD1 = one + 1;
    MOD2 = max(one - 1, 1LL);
    rep(i, N) {
      if (X[i] == '1') {
        plus += bpm_plus(2, N - 1 - i);
        minus += bpm_minus(2, N - 1 - i);
        plus %= MOD1;
        minus %= MOD2;
      }
    }
    vector<int> ret(N);
    rep(i, N) {
      int ans = 0;
      if (X[i] == '1') {
        ans = minus;
        ans -= bpm_minus(2, N - 1 - i);
        ans = mod(ans, MOD2);
      } else {
        ans = plus;
        ans += bpm_plus(2, N - 1 - i);
        ans = mod(ans, MOD1);
      }
      if (i == p) {
        cout << 0 << endl;
      } else {
        cout << 1 + process[ans] << endl;
      }
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DAnythingGoesToZero solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];

  long long res = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool ok = true;
    for (int i = 0; i < M; i++) {
      int con = 0;
      for (auto v : s[i])
        if (bit & (1 << v)) con++;
      if (con % 2 != p[i]) ok = false;
    }
    if (ok) res++;
  }

  cout << res << endl;
}

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

int main() {
  
  int status[4][3][10];
  
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        status[i][j][k] = 0;
      }
    }
  }
  
  int n; cin >> n;
  
  for (int i = 0; i < n; i++) {
    int b, f, r, v; cin >> b >> f >> r >> v;
    status[b - 1][f - 1][r - 1] += v;
  }
  
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << status[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) cout << "####################" << endl;
  }
  
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 3e5 + 5, md = 1e9 + 7;

inline int add(int x, int y) {
    x += y;
    if(x >= md) x -= md;
    return x;
}

inline int sub(int x, int y) {
    x -= y;
    if(x < 0) x += md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

ll a[N];
int n, ans;

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

 
 for(register int j = 0; j < 60; j++) {
	 int cnt = 0;
        for(register int i = 1; i <= n; i++)
		cnt += ((a[i]>>j)&1);
	//ll temp = 1LL<<j;
	//ans= (ans + ((temp % mod) * (cnt*(n-cnt)) ) % mod);
	ans = add (ans , mul((1LL << j) %md , mul(cnt,n-cnt)));
}

cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

N = input()
N_list = list(reversed(N))

if int(N_list[0]) in hon:
  print("hon")
elif int(N_list[0]) in pon:
  print("pon")
else:
  print("bon")

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cur = 0;
  for (int i = 0; i < n; ++i) {
    cur += s[i] - '0';
    cur %= 9;
  }
  if (cur == 0) puts("Yes");
  else puts("No");
  return 0;
}



Measured memory_bytes: 3732
use std::io;
use std::str::FromStr;

fn get_parms<T: FromStr>() -> Vec<T>
where
    <T as FromStr>::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("stdin error");
    return buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
}

fn main() {
    let vec = get_parms::<f64>();
    let (a, b) = (vec[0], vec[1]);
    println!(
        "{} {} {:.5}",
        a as i64 / b as i64,
        a as i64 % b as i64,
        a / b
    );
}


Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	n--,m--;
	cout<<n*m<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

Graph G;
vector<ll> A;
vector<ll> ans;

void dfs(int u, int p, vector<ll>& vec, vector<ll>& dp) {

	int idx = lower_bound(dp.begin(), dp.end(), vec.back()) - dp.begin();
	ll old = dp[idx];
	dp[idx] = vec.back();
	ans[u] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

	for (auto e : G[u]) {
		if (e == p) continue;
		vec.push_back(A[e]);
		dfs(e, u, vec, dp);
		vec.pop_back();
	}
	dp[idx] = old;
}

int main() {
	ll n; cin >> n;
	A.resize(n);
	for (int i = 0; i < n; ++i) cin >> A[i];

	ans.resize(n);
	G.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		ll u, v; cin >> u >> v; --u; --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	vector<ll> dp(2*n, INF), buf;
	buf.push_back(A[0]);

	dfs(0, -1, buf, dp);
	for (int i = 0; i < n; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 39252
#include <cstdio>
#include <algorithm>
int n, a[100005], b[100005];
long long ans;
int main(){
	scanf("%d", &n);
	for (register int i = 1; i <= n + 1; ++i) scanf("%d", a + i);
	for (register int i = 1; i <= n; ++i) scanf("%d", b + i);
	for (register int i = 1; i <= n; ++i){
		int t = std :: min(a[i], b[i]);
		a[i] -= t, b[i] -= t, ans += t;
		t = std :: min(a[i + 1], b[i]);
		a[i + 1] -= t, b[i] -= t, ans += t;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 896
def main():
    N, A, B = map(int, input().split())

    length_A_plus_B = A + B # AとBの和
 
    quo = N // length_A_plus_B # 商
    rem = N % length_A_plus_B # 余り

    ans = 0
    if N < length_A_plus_B: # NがAとBの和より小さい時
        if N <= A:
            ans = N
        else:
            ans = A
        print('{}'.format(ans))
        exit() # 処理を抜ける

    ans = quo * A 
    if rem <= A:
        ans += rem
    elif rem > A:
        ans += A
    
    print('{}'.format(ans))



if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define clr clear()
#define ll long long int
#define inf (1<<30)
#define ins insert
#define endl '\n'
#define xx first
#define yy second
#define eps 1e-9
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000
#define mx 0
inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
inline ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

ll summer(ll n){
    ll sum=0;
    if(n==0)
        return 0;
    else
        return n%10+summer(n/10);
}
int main() {
    FAST_IO
    ll n,a,b,j=0,r,i,ans=0;
    cin>>n>>a>>b;
    for(i=1;i<=n;i++){
         if(a<=summer(i) && summer(i)<=b)
            ans+=i;
    }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256