akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    char c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

void bfs(vi &cnt, vi &color, vvi adj, ll room){
    queue<ll> que;
    que.push(room);

    while(!que.empty()){
        ll top = que.front();
        que.pop();

        // 隣接リストの探索
        for(auto p: adj[top]){
            if(color[p] == 1) continue;
            else{
                // 未探索
                que.push(p);
                color[p] = 1;
                cnt[p] = top+1;
            }
        }
    }
}

int main(){
    Init();
    ll n, m; cin >> n >> m;
    // カウント
    vi cnt(n); cnt[0] = 0; 
    // 訪れたか
    vi color(n, 0); color[0] = 1; 
    vvi adj(n, vi(0, 0));
    // 隣接リストの作成
    rep(i, m){
        ll a, b; cin >> a >> b; a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    // 幅優先で探索
    bfs(cnt, color, adj, 0);

    for(auto p: color){
        if(p != 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(ll i=1; i<n; i++){
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 20160
#include<bits/stdc++.h>
using namespace std;
// #define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	//mahakal();fast;

	ll h,n;
	cin>>h>>n;
	ll a[n+1],b[n+1];
	for(ll i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	ll dp[h+1];
	ll inf=1e9;dp[0]=0;
	for(ll i=1;i<=h;i++){
		dp[i]=inf;ll temp;
		for(ll j=0;j<n ;j++){
			if(i-a[j]<0) temp=0;
			else temp=dp[i-a[j]];
			dp[i]=min(b[j]+temp , dp[i]);
		}
	}
	cout<<dp[h]<<endl;

	return 0;
}

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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

const int H = 11;
const int W = 1010;

const int MAXVAL = 1030;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int h, w, K, sum[H][W];
char s[W];

il int Get(int c, int l, int r) {
    return sum[r][c] - sum[l - 1][c];
}

int f[MAXVAL][W];
int tot, pos[H], now[H], tp[H];

int ans = 0x3f3f3f3f;

int main() {
    h = read(), w = read(), K = read();
    Rep(i, 1, h) {
        gets(s + 1);
        Rep(j, 1, w) sum[i][j] = sum[i - 1][j] + (s[j] == '1');
    }
    int MAX = (1 << (h - 1)) - 1;
    Rep(i, 0, MAX) {
    	memset(now, 0, sizeof(now));
        //cout << "i: " << i << endl;
        tot = 0; int tp_ans = 0;
        Rep(j, 0, h - 2) {
            if (i & (1 << j)) pos[++tot] = j + 1;
        }
        //Rep(i, 1, tot) cout << pos[i] << ' ';
        //cout << endl;
        tp_ans = tot, pos[++tot] = h;
        bool failed = false;
        Rep(j, 1, w) {
        	Rep(k, 1, tot) {
        		tp[k] = Get(j, pos[k - 1] + 1, pos[k]);
        		if (tp[k] > K) {failed = true; break;}
			}
			if (failed) break;
        	Rep(k, 1, tot) {
        		now[k] += tp[k];
        		if (now[k] > K) {
        			Rep(l, 1, tot) now[l] = tp[l];
        			++tp_ans;
        			break;
				}
			}
			//cout << "j: " << j << endl;
			//Rep(k, 1, tot) cout << now[k] << ' ';
			//cout << endl;
		}
	    if (failed) continue;
        //cout << tp_ans << endl;
        ans = min(ans, tp_ans);
    }
    printf("%d", ans);
    //system("pause"); //Remember to delete before submition!!!
    return 0;
}

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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int a,b,c;
    cin >> a >> b >> c;
    if(b/a >= c){
        cout << c << endl;
    }else{
        cout << b/a << endl;
    }
    



    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> time(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> time.at(i);
    sum = sum + time.at(i);
  }
  int M,num;
  cin >> M;
  vector<int> drink(M);
  for(int i = 0; i < M; i++){
    cin >> num;
    cin >> drink.at(i);
    cout << sum + drink.at(i) - time.at(num - 1) <<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int l=sc.nextInt();
    String a=sc.next();
    String b=sc.next();
    String ans="";
    for (int i=0;i<l;++i) {
      ans+=a.charAt(i);
      ans+=b.charAt(i);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int n;
int MAS[100020];
int CST[100020];
typedef pair<int,int>P;
priority_queue<P, vector<P>, greater<P> >Q;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>MAS[i];
		CST[i]=-1;
	}
	for(int i=1;i<10;i++){
		MAS[n+i-1]=-1*i;
		CST[n+i-1]=-1;
	}
	Q.push(P(0,0));
	while(CST[n-1]<0){
		P p=Q.top();
		Q.pop();
		if(CST[p.second]>=0)continue;
		CST[p.second]=p.first;
		if(MAS[p.second]==0){
			for(int i=1;i<=6;i++){
				if(CST[p.second+i]<0){
					Q.push(P(1+p.first,p.second+i));
				}
			}
		}
 		else if(CST[p.second+MAS[p.second]]<0){
			Q.push(P(p.first,p.second+MAS[p.second]));
		}
	}
	
	cout<<CST[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 2008
#include <iostream>
#include <string>

int main() {
  int n;
  std::cin >> n;
  std::string hana, taro;
  int score_hana = 0, score_taro = 0;
  for (int i = 0; i < n; i++)
  {
    std::cin >> hana >> taro;
    if (hana < taro) {
      score_hana += 3;
    }
    else if (hana > taro)
    {
      score_taro += 3;
    }
    else
    {
      score_hana++;
      score_taro++;
    }
  }
  std::cout << score_taro << " " << score_hana << "\n";
}


Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

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

  int ans = 1e9;
  for ( int i = -100; i <= 100; i++ ) {
    int sum = 0;
    for ( int j = 0; j < N; j++ ) {
      sum += abs(a[j]-i)*abs(a[j]-i);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  rep(i, 120){
    string s = to_string(N);
    if (s[0] == s[1] && s[1] == s[2]) {
      cout << s << endl;
      exit(0);
    }else{
      N += 1;
    }
  }
}


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

using pii = pair<int, int>;
#define fst first
#define snd second

const pii fail = pii(-1, -1);


inline pii exec(pii cur, pii add) {
	if (cur == fail or add == fail) return fail;
	if (cur.snd == 0) return add;
	if (cur.snd != add.fst) return fail;
	return pii(cur.fst, add.snd);
}

const int sz = 1 << 18;
pii data[2 * sz], lazy[2 * sz];

inline void lazy_eval(int k) {
	if (lazy[k].snd == 0) return;

	for (int nk = 2 * k + 1; nk <= 2 * k + 2; ++nk) {
		data[nk] = exec(data[nk], lazy[k]);
		lazy[nk] = exec(lazy[nk], lazy[k]);
	}

	lazy[k].snd = 0;
}

void query(int a, int b, int k, pii add, int l, int r) {
	if (b <= l or r <= a ) return;

	if (a <= l and r <= b) {
		data[k] = exec(data[k], add);
		lazy[k] = exec(lazy[k], add);
		return ;
	}

	lazy_eval(k);

	const int m = (l + r) / 2;
	query(a, b, 2 * k + 1, add, l, m);
	query(a, b, 2 * k + 2, add, m, r);
}


int main(void) {
	int n, k, t;
	cin >> n >> k >> t;

	rep(i, 2 * sz) {
		data[i] = pii(0, 1);
		lazy[i] = pii(0, 0);
	}

	rep(loop, t) {
		int l, r, x;
		cin >> l >> r >> x, l--;
		query(l, r, 0, pii(x, x + 1), 0, sz);
	}

	rep(i, sz - 1) lazy_eval(i);

	int ans = 0;
	rep(i, n){
		//cerr << data[sz - 1 + i].fst << " " << data[sz - 1 + i].snd << endl;
		if (data[sz - 1 + i].fst == 0 and data[sz - 1 + i].snd == k + 1) ans++;
	}
	cout << ans << endl;

}

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


def solve(S: str):
    count = 0
    S = [s for s in S]

    count = 0
    sub_count = 0

    for s in S:
        if s == 'W':
            count += sub_count
        else:
            sub_count += 1
                
        
    print(count)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5044
//#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
 
template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL maxn=1e3+10;
LL MOD=1e9+7,inf=0x1f1f1f1f,mod=998244353;
db eps=1e-5;
LL t,n,m,q,ans;
string s;

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0,u,v,a,b;
	cin>>s;
	l=s.size();
	rep(i,0,l)s[i]-='0';
	for(i=0;i<(1<<l);i++){
		k=0;
		for(j=0;j<l;j++){
			k=k*10+s[j];
			if(i&(1<<j)){
				ans+=k;
				k=0;
			}
		}
		ans+=k;
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include<bits/stdc++.h> 
#include<cstring>
using namespace std;
 
int main()
{
	string A;
	cin>>A;
	string B;
	cin>>B;
	int m = A.length();
    int n = B.length();
	int dp[m+1][n+1];
	memset(dp, 0, sizeof(dp));
	for(int i =1;i<=m;i++)
	{
		for(int j =1;j<=n;j++)
		{
			if(A[i-1]==B[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]= max(dp[i-1][j], dp[i][j-1]);
		}
	}
	string res;
	int i = m;
	int j =n;
	while(i>=0 && j>=0)
	{
		if(dp[i][j]==dp[i-1][j]) i--;
		else if(dp[i][j]==dp[i][j-1]) j--;
		else{
			res = A[i-1]+res;
			i--;
			j--;
		}
	}
	cout<<res;
	 return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   string s[3];
   rep(i,3)cin>>s[i];
   int pos=0;
   int x[3];
   rep(i,3)x[i]=0;
   while(1){
       if(x[pos]==(int)s[pos].size()){
           cout<<(char)('A'+pos)<<endl;
           return 0;
       }
       int next=s[pos][x[pos]]-'a';
       x[pos]++;
       pos=next;
   }
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define MP make_pair
#define PB push_back
#define I insert

const LL mod=1000000007, N=200005;
using namespace std;

LL n, m, i, j, k, l, r, t, ans, fix[N], a[N];

int main(){
	cin >> n;
	for ( i = 0; i < n; ++i ){
		cin >> a[i];
		ans += fix[a[i]];
		fix[a[i]]++;
	}
	for ( i = 0; i < n; ++i ){
		cout << ans - (fix[a[i]]*(fix[a[i]]-1)/2-(fix[a[i]]-2)*(fix[a[i]]-1)/2) << endl;
	}

	return 0;
}
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE




Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

int main() {
	vector<int>x, y;
	int n, m, xx, yy, i, j;

	cin >> n >> m >> xx >> yy;

	for (i = 0; i < n; i++) {
		cin >> j;
		x.push_back(j);
	}
	for (i = 0; i < m; i++) {
		cin >> j;
		y.push_back(j);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	i = x[n - 1];
	j = y[0];

	if (i < j && i<yy && j>xx)
		cout << "No War";
	else
		cout << "War";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int h[100010];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int dp[100010];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]),dp[i-2] + abs(h[i-2] - h[i]));
    }
    cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
from collections import deque, _heapq
N, K = map(int, input().split())
V = deque(map(int, input().split()))

class Money:
    def __init__(self):
        self.yen = 0
        self.red = []

    def value(self):
        return self.yen + sum(self.red)

    def add(self, yen):
        if yen >= 0:
            self.yen += yen
        else:
            self.red.append(yen)

    def remove(self, yen):
        if yen >= 0:
            self.yen -= yen
        else:
            self.red.remove(yen)

#mny = Money()
def get(cnt, mny, lstop, rstop):
    ans = mny.value()

    if cnt <= 0:
        return ans

    if len(V) > 0:

        if lstop == 0:
            w = V.popleft()
            mny.add(w)
            ans = max(ans, get(cnt-1, mny, lstop, rstop))
            mny.remove(w)
            V.appendleft(w)
        elif lstop > 0:
            lstop -= 1

        if rstop == 0:
            w = V.pop()
            mny.add(w)
            ans = max(ans, get(cnt-1, mny, -1, rstop))
            mny.remove(w)
            V.append(w)

    if len(mny.red) > 0:
        w = min(mny.red)
        mny.red.remove(w)

        V.appendleft(w)
        ans = max(ans, get(cnt-1, mny, -1, -1))
        V.popleft()

        mny.red.append(w)    

    return ans

print(get(K, Money(), 0, 0))


Measured memory_bytes: 3436
// AOJ ALDS1_7_D: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D

package main

import (
	"fmt"
	"strings"
	"strconv"
	"bufio"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)
var pos int
var post []int

func nextInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func index(a []int, key int) int {
	for i, v := range a {
		if v == key {
			return i
		}
	}
	return -1
}

func recursion(pre, in []int, l, r int) {
	if (l >= r) {
		return
	}

	// 今見てるNode
	root := pre[pos]
	pos++

	// 今見てるNodeのinOrder順での位置
	m := index(in, root)

	// inOrderをmで左部分木と右部分木に分ける
	recursion(pre, in, l, m)
	recursion(pre, in, m+1, r)
	post = append(post, root)
}

func reConstruct(pre, in []int) {
	pos = 0
	recursion(pre, in, 0, len(pre))
	postOrder := make([]string, len(pre))
	for i := 0; i < len(pre); i++ {
		postOrder[i] = strconv.Itoa(post[i])
	}
	fmt.Println(strings.Join(postOrder, " "))
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	preOrder := make([]int, n)
	for i := 0; i < n; i++ {
		preOrder[i] = nextInt()
	}

	inOrder := make([]int, n)
	for i := 0; i < n; i++ {
		inOrder[i] = nextInt()
	}

	reConstruct(preOrder, inOrder)
}


Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
void oblivious()
{
    int n;
    cin>>n;
    double p[n+1];
    double dp[n+1][n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    mem0(dp);
    dp[1][1]=p[1];
    dp[1][0]=1-p[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-p[i]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)
            {
                if(i==1&&j==1)
                {
                    continue;
                }
                else
                {
                    dp[i][i]=dp[i-1][i-1]*p[i];
                }
                
            }
            else if(i>j)
            {
                dp[i][j]=(dp[i-1][j-1]*p[i]+(1-p[i])*dp[i-1][j]);
            }
        }
    }
    double ans=0;
    for(int i=1;i<=n;i++)
    {
        //cout<<dp[n][i]<<endl;
        if(i>n-i)
        {
            //cout<<dp[n][i]<<endl;
            ans+=dp[n][i];
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}
//Md Zuhair

Measured memory_bytes: 74124
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

signed main()
{
    
    speed
    int n;cin>>n;
    map <string,int> mp;
    rep(i,1,n){
      string xd;cin>>xd;
      mp[xd]++;
    }
    int mx=0;
    for(auto it:mp){
      mx=max(mx,it.second);
    }
    for(auto it:mp){
      if(it.second==mx){
        cout<<it.first<<endl;
      }
    }
   
 
 
    return 0;
}

Measured memory_bytes: 23808
import java.util.Scanner;

public class Main {
    static final long MOD = 1000000007;
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int d = scanner.nextInt();
        int[][] a = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                a[i][j] = scanner.nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if (isAns(a[i], a[j])) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }

    static boolean isAns(int[] a, int[] b) {
        int n = a.length;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += (a[i]-b[i])*(a[i]-b[i]);
        }
        for (int i = 0; i < 1000; i++) {
            if (i*i==sum) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll x;
    cin >> x;
    ll k = 100;
    ll count = 0;
    for (; k < x; k *= 1.01) {
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;



signed main(){
  int n;
  cin>>n;
  int odd=1;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==0)odd*=2;
  }
  cout<<pow(3,n)-odd<<endl;
  return 0;
}


Measured memory_bytes: 256
// ABC 148-E
// 2019.12.22 bal4u

#include <stdio.h>

typedef long long ll;

int main()
{
	ll N, n5, ans = 0;
	
	scanf("%lld", &N);
	if ((N & 1) == 0) {
		N /= 2, n5 = 5;
		while (N >= n5) {
			ans += N/n5;
			n5 *= 5;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 5e3 + 100;
const ll mod = 1e9 + 7; //998244353;
const ll big = 1e9;
 
int main() 
{
	data();
	//freopen("mountains.in", "r", stdin);
   	//freopen("mountains.out", "w", stdout);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * c, max(b * d, max(d * a, b * c)));
}                    

Measured memory_bytes: 3640
import sys
from collections import Counter

M = 10 ** 9 + 7


# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()

    c = Counter(a)
    expected = Counter()
    if n % 2 == 0:
        for i in range(1, n, 2):
            expected[i] = 2
    else:
        expected[0] = 1
        for i in range(2, n, 2):
            expected[i] = 2

    if c == expected:
        return 2 ** (n // 2) % M
        # return pow(2, n // 2, M)
    return 0


def main():
    res = solve()
    print(res)


main()


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MOD = 998244353;

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    vector<ii> v;
    FOR(i,1,N){ int D; cin >> D; v.emplace_back(D,i); }

    sort(ALL(v));
    int atD[N] = {0};
    int ans = 1;
    if (v[0] != ii(0,1)) cout << 0;
    else {
        atD[0] = 1;
        FOR(i,1,SZ(v)-1){
            if (v[i].fi == 0) ans = 0;
            else ans = (ll)ans * atD[v[i].fi-1] % MOD;
            ++atD[v[i].fi];
        }
        cout << ans;
    }
}



Measured memory_bytes: 1524
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int d[200000] = {};
int t[200000] = {};

int main(void)
{
	int n, m;
	INPUT(n);

	for (int i = 0; i < n; i++) {
		INPUT(d[i]);
	}

	INPUT(m);

	for (int i = 0; i < m; i++) {
		INPUT(t[i]);
	}

	sort(d, d + n);
	sort(t, t + m);

	int p = 0;

	for (int i = 0; i < m; i++) {
		while (d[p] != t[i]) {
			p++;
			if (p >= n) {
				printf("NO");
				return 0;
			}
		}
		p++;
	}

	printf("YES");

	return 0;
}


Measured memory_bytes: 1792
N = int(input())
s = [0] * N
t = [0] * N
for i in range(N):
  s[i],t[i] = input().split()
X = input()
flg = 0
sum = 0
for i in range(N):
  if (s[i] == X) & (flg == 0):
    flg = 1
  elif flg == 1:
    sum += int(t[i])
print(sum)

Measured memory_bytes: 3064
#include<stdio.h>

char map[8][8];

void bomb(int x,int y){
  int i;

  if(x<0 || x>7 || y<0 || y>7)return;

  if(map[y][x] == '1'){
    map[y][x] = '0';
    for(i=1;i<=3;i++){
      bomb(x+i,y);
      bomb(x-i,y);
      bomb(x,y+i);
      bomb(x,y-i);
    }
  }

  return;
}

void print_map(int n){
  int i,j;

  printf("Data %d:\n",n);
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      printf("%c",map[i][j]);
    }
    putchar('\n');
  }
  return;
}
    

int main(void){
  int i,j,k;
  int n;
  int x,y;

  scanf("%d ",&n);

  for(i=0;i<n;i++){
    
    for(j=0;j<8;j++){
      for(k=0;k<8;k++){
	scanf(" %c ",&map[j][k]);
      }
    }
    scanf(" %d %d ",&x,&y);

    bomb(x-1,y-1);

    print_map(i+1);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	vector<ll>a;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll ans=0;
	for(ll i=0;i<k;i++){
		ans+=a[i];
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
    int ans=0,id;
    int N,M;
    int A,B,C;
    string O,E;
    ll sum=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>C;
    int temp=A%B;
    N=temp;
    FOR(i,A,A*B){
        if((A*i)%B==C){N=1;break;}

    }
    if(N==1)cout<<"YES";
    else cout<<"NO";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

bool answer(int &ans) {
    if(ans == 3) {
        cout << "Yes" << endl; 
        return true;
    } else {
        ans = 0;
        return false;
    }
}

int main(void)
{
    v2_int bingo(3, v_int(3, 0));
    map<int, pii> a;
    
    irep(i,3) {
        irep(j,3) {
            int tmp;
            cin >> tmp;
            a[tmp] = make_pair(i,j);
        }
    }

    int n;
    cin >> n;

    irep(i, n) {
        int b;
        cin >> b;
        auto it = a.find(b);
        if(it != a.end()) { 
        bingo[a[b].first][a[b].second] = 1;
        }
    }

    int ans = 0;
    irep(i,3) {
        if(bingo[i][i]) { ans++; }
    }
    if(answer(ans)) return 0;

    if(bingo[0][2]) ans++;
    if(bingo[1][1]) ans++;
    if(bingo[2][0]) ans++;
    if(answer(ans)) return 0;

    irep(i, 3) {
        irep(j, 3) {
            if(bingo[i][j]) { ans++; }
        }
        if(answer(ans)) return 0;
    }

    irep(i, 3) {
        irep(j, 3) {
            if(bingo[j][i]) { ans++; }
        }
        if(answer(ans)) return 0;
    }
    cout << "No" << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<30
void divide_list(int,int);
void marge(int,int,int);
int v[5000000];
int c;
int main(void){
	int num;
	cin >> num;
	for(int i = 0 ; i < num; i++){
		cin >> v[i];
	}
	divide_list(num,0);
	for(int i = 0; i < num; i++){
		if(i) cout << " " ;
		cout << v[i];
	}
	cout << endl;
	cout << c << endl;
	return 0;
}
void divide_list(int right,int left){
	if(left+1 < right){
		int mid = (right + left) / 2 ;
		divide_list(mid,left);
		divide_list(right,mid);
		marge(right,left,mid);
	}
}
void marge(int right,int left,int mid){
	int R[300000],L[300000];
	int n1,n2;

	n1 = mid - left;
	n2 = right - mid;
	for(int i = 0 ; i < n1; i++) L[i] = v[i + left];
	for(int i = 0 ; i < n2; i++) R[i] = v[i + mid];
	R[n2] = L[n1] = INF;
	int k=0;
	int l=0;
	for(int j = left; j < right; j++){
		c++;
		if(L[l] <= R[k]){
			v[j] = L[l++];
		}
		else{
			v[j] = R[k++];
		}
	}
}

Measured memory_bytes: 5076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  int BCcnt=0;
  ll ans=0;
  for(int i=n-1;i>=0;i--){
    if(i-1>=0&&s[i]=='C'&&s[i-1]=='B'){
      BCcnt++;
      i--;
    }
    else if(s[i]=='A'){
      ans+=BCcnt;
    }
    else{
      BCcnt=0;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    ret = 0
    for i in range(1, N + 1 , 2):
        c = 0
        for j in range(1, i + 1):
            c += int((i % j) == 0)

        if c == 8:
            ret += 1
    return ret


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
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


struct SegTree {
  int seg_tree_size = 1;
  int nums_size;
  vector<ll> data;

  SegTree(int origin_size, vector<ll> a) {
    // 簡単のため数列の要素数が2のべき乗と考える
    while(seg_tree_size < origin_size) seg_tree_size *= 2;
    nums_size = seg_tree_size;
    seg_tree_size = seg_tree_size * 2 - 1;

    // 2分木の要素数は2*要素数-1
    // n + n/2 + n/4 + n/8 + ... 1 = 2*n-1
    data = vector<ll> (seg_tree_size, pow(2, 31));
    for (int i = 0; i < origin_size; i++) {
      update(i, a[i]);
    }
  }

  // k番目の値をxに変更
  void update(int k, int a){
    // 葉のノードの番号
    k += (seg_tree_size - nums_size);
    data[k] = a;

    // 登りながら更新
    while(k > 0) {
      k = (k-1) / 2;
      data[k] = min(data[k * 2  + 1], data[k * 2 + 2]);
    }
  }


  // [a, b)の最小値を求める
  // kは節点の番号。l, rはその節点が[1, r)に対応づいている
  // (a, b, 0, 0, n)として呼び出す。
  int query(int a, int b, int k, int l, int r){
    // cout << l << " : " << r << endl;
    // cout << a << " : " << b << endl;
    // 交差しなければ
    if(r <= a || b <= l) return INT_MAX;
    // [a, b)が[1, r)を完全に含んでいれば、この節点の値
    if(a <= l && r <= b) return data[k];
    // そうでなければ、2つの子の最小値
    else{
      int vl = query(a, b, k*2+1, l, (l+r)/2);
      int vr = query(a, b, k*2+2, (l+r)/2, r);
      // cout << min(vl, vr) << endl;
      return min(vl, vr);
    }
  }

  int query(int a, int b){
    return query(a, b, 0, 0, nums_size);
  }

};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<ll> v(n, INT_MAX);
  SegTree st(n, v);
  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    // print(st.data);
    if(com == 0) {
      st.update(x, y);
    }
    else{
      cout << st.query(x, y+1) << endl;
    }
  }
}



Measured memory_bytes: 6544
N, K = map(int, input().split())
A = list(map(int, input().split()))

from collections import Counter

counter = Counter(A)
cnt = len(list(counter.keys())) - K 

if cnt <= 0:
  print(0)
  exit() 

ans = 0

C = counter.most_common()[::-1]
for i in range(cnt):
  ans += C[i][1]

print(ans)

Measured memory_bytes: 39348
#include<stdio.h>
int main(void)
{
    int a[5],b[5];
    int i;
    int hit=0,blow=0;

    while(scanf("%d",&a[0])!=EOF){
    scanf("%d",&a[1]);
    scanf("%d",&a[2]);
    scanf("%d",&a[3]);
    for(i=0;i<4;i++){
        scanf("%d",&b[i]);
        if(a[i]==b[i]) hit++;
        if(a[0]==b[i])blow++;
        else if(a[1]==b[i])blow++;
        else if(a[2]==b[i])blow++;
        else if(a[3]==b[i])blow++;
    }
    printf("%d %d\n",hit,blow-hit);
    hit=0;
    blow=0;
   }
    return 0;
}

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

int size[6] = {60, 80, 100, 120, 140, 160};
int weight[6] = {2, 5, 10, 15, 20, 25};
int fee[7] = {600, 800, 1000, 1200, 1400, 1600, 0};

int main() {
	int n;
	int x, y, h, w;
	int cost;
	
	while(cin >> n, n){
		cost = 0;
		
		for(int i = 0; i < n; ++i){
			cin >> x >> y >> h >> w;
			int k, l;
			
			for(k = 0; k < 6; ++k){
				if(x + y + h <= size[k]) break;
			}
			
			for(l = 0; l < 6; ++l){
				if(w <= weight[l]) break;
			}
			
			cost += fee[max(k, l)];
		}
		cout << cost << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import scala.io.Source

object Main extends App{
  Source.stdin.getLines.toList.map(_.split(" ").map(_.toInt).toList).takeWhile({case List(a, b) => (a + b != 0)})
  .map(x => {for(i <- 1 to x(0)) yield "#"*x(1)}.mkString("\n"))
  .map(_ + "\n")
  .map(println)
}

Measured memory_bytes: 45880
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/

/*
void fo(int id){
	freopen((toString(id)+".txt").c_str(),"w",stdout);
}
*/

int op;
int a[3];
void solve() {
	int maxn=0;
	for(int i=0; i<3; i++)maxn=max(a[i],maxn);
	for(int i=0; i<3; i++) {
		op+=(maxn-a[i])/2;
	}
	cout<<op<<endl;
	exit(0);
}


int main(int argc,char* argv[]) {
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);

	if(a[0]%2!=a[1]%2&&a[0]%2!=a[2]%2) {
		op++;
		a[1]++;
		a[2]++;
	}else{
	
		if(a[1]%2!=a[0]%2&&a[2]%2!=a[1]%2) {
			op++;
			a[0]++;
			a[2]++;
		}else{
		
			if(a[2]%2!=a[0]%2&&a[2]%2!=a[1]%2) {
				op++;
				a[1]++;
				a[0]++;
		
			}
		}
	
	}
	solve();

	return 0;
}


Measured memory_bytes: 256
program abc169b
  use iso_c_binding
  implicit none

  integer :: n, i
  integer(c_int128_t) :: x, a(100000)
  integer(c_int128_t),parameter :: mx = 10_16**18

  read *, n
  read *, a(1:n)

  if (any(a(1:n) == 0)) then
     print *, 0
     stop
  end if

  x = 1

  do i = 1,n
     x = x * a(i)
     if (x > mx) then
        x = -1
        exit
     end if
  end do

  print *, x
end program abc169b


Measured memory_bytes: 4672
from sys import stdin

H, W = [int(x) for x in stdin.readline().rstrip().split()]

# h個の行とw個の列を選択
h, w = [int(x) for x in stdin.readline().rstrip().split()]

white_cell = H * W

black_cell = h * W + w * H - h * w

print(white_cell - black_cell)


Measured memory_bytes: 38384
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, i;
	std::cin >> N >> i;
	std::cout << (N - i + 1) << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#define R register
#define next mlgvegetable
#define mul mlgvegetable
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
inline ll read();
inline void write(ll x);
inline void writeln(ll x);
inline void writesp(ll x);
ll n;
ll num[1000000];
inline bool check(ll x,ll y){
	ll ans=0;
	for(;x>1;x/=10) ans++;
	for(;y>1;y/=10) ans++;
	if(ans>=20) return false;
	return true;
}
ll mul;
int main(){
	n=read();
	mul=1;
	for(ll i=1;i<=n;i++){
		num[i]=read();
		if(!num[i]){
			writeln(0);
			return 0;
		}
	}
	for(ll i=1;i<=n;i++){
		if(!check(mul,num[i])){
			writeln(-1);
			return 0;
		}
		else{
			mul*=num[i];
			if(mul>1000000000000000000){
				writeln(-1);
				return 0;
			}
		}
	}
	writeln(mul);
}
inline ll read(){
	ll x=0,t=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*t;
}
inline void write(ll x){
	if(x<0){putchar('-');x=-x;}
	if(x<=9){putchar(x+'0');return;}
	write(x/10);putchar(x%10+'0');
}
inline void writesp(ll x){
	write(x);putchar(' ');
}
inline void writeln(ll x){
	write(x);putchar('\n');
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, in;
	cin>>n;
	multiset<long long,greater<long long>> s;
	vector<long long> b;
	for(long long i=0; i<(1<<n); i++){
		cin>>in;
		s.insert(in);
	}
	b.push_back(*s.begin());
	s.erase(s.begin());
	for(long long i=0; i<n; i++){
		for(long long j=0; j<(1<<i); j++){
			auto si=s.upper_bound(b[j]);
			if(si==s.end()){
				cout<<"No";
				return 0;
			}
			b.push_back(*si);
			s.erase(si);
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 14712
#include <cstdio>
#define INF 1<<30

int n, M[100][100];

int prim() {
    int e, minv, minx, s;
    int p[n], d[n], v[n];

    for (e = 0; e < n; e++) {
        p[e] = -1;
        d[e] = INF;
        v[e] = 0;
    }

    d[0] = 0;

    while (1) {
        minv = INF;
        minx = -1;
        for (e = 0; e < n; e++) {
            if (minv > d[e] && v[e] != 1) {
                minx = e;
                minv = d[e];
            }
        }

        if (minx == -1) break;
        v[minx] = 1;
        
        for (e = 0; e < n; e++) {
            if (v[e] != 1 && M[minx][e] != INF) {
                if (d[e] > M[minx][e]) {
                    d[e] = M[minx][e];
                    p[e] = minx;
                }
            }
        }
    }

    s = 0;
    for (e = 0; e < n; e++) {
        if (p[e] != -1) s += M[e][p[e]];
    }

    return s;
}

int main(void) {
    int i, j, v;
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            scanf("%d", &v);
            M[i][j] = (v == -1) ? INF : v;
        }
    }

    printf("%d\n", prim());

    return 0;
}

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

int main(){
    char c;
    cin>>c;
    
    if (c=='a') cout<<"b";
        else if (c=='b') cout<<"c";
        else if (c=='c') cout<<"d";
        else if (c=='d') cout<<"e";
        else if (c=='e') cout<<"f";
        else if (c=='f') cout<<"g";
        else if (c=='g') cout<<"h";
        else if (c=='h') cout<<"i";
        else if (c=='i') cout<<"j";
        else if (c=='j') cout<<"k";
        else if (c=='k') cout<<"l";
        else if (c=='l') cout<<"m";
        else if (c=='m') cout<<"n";
        else if (c=='n') cout<<"o";
        else if (c=='o') cout<<"p";
        else if (c=='p') cout<<"q";
        else if (c=='q') cout<<"r";
        else if (c=='r') cout<<"s";
        else if (c=='s') cout<<"t";
        else if (c=='t') cout<<"u";
        else if (c=='u') cout<<"v";
        else if (c=='v') cout<<"w";
        else if (c=='w') cout<<"x";
        else if (c=='x') cout<<"y";
        else if (c=='y') cout<<"z";
}

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

int main() {
  int n, m, p, x, sum = 0;
  cin >> n;
  int t[n];
  REP(i, n) {
    cin >> t[i];
    sum += t[i];
  }
  cin >> m;
  REP(i, m) {
    cin >> p >> x;
    cout << sum - t[p - 1] + x << endl;
  }
  return 0;
}

Measured memory_bytes: 256