akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    ll n, p;
    cin >> n >> p;
    ll k = p;
    vector<ll> prime(sqrt(p),0);
    if(n==1){
        cout << p << endl;
        return 0;
    }
    for (ll i = 2; i <= sqrt(p);i++){
        if(p%i==0){
            while(1){
                prime[i]++;
                p /= i;
                if(p%i!=0){
                    break;
                }
            }
        }
    }
    ll sum = 1;
 //   cout << sqrt(p) << endl;
    for (int i = 2; i <= sqrt(k);i++){
       // cout <<i<<" "<< prime[i] << " ";
        if(prime[i]/n>=1){
            sum*=pow(i,(prime[i]/n));
        }
    }
  //  cout << endl;
    cout << sum << endl;
}


Measured memory_bytes: 8064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

A, B, C, D = map(int, input().split())

while True:
    C -= B
    if C <= 0:
        print('Yes')
        sys.exit(0)
    A -= D
    if A <= 0:
        print('No')
        sys.exit(0)



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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);

   string s;
   cin >> s;
   int ans = 0;
   for(int i=0;i<s.size();i++){
      if(s[i] == '1')ans++;
   }
   cout<<ans<<endl;

   return 0;
}


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int left=n-1;
  int right=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A') left=min(left,i);
    if(s[i]=='Z') right=max(right,i);
  }
  cout<<right-left+1<<endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int time = (int) Math.ceil((double) d / s);
        boolean judge = time <= t;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35624
#include <stdio.h>
#include <stdlib.h>


#define NO_DATA 100000


int main() {
    int n, m, i, j, denom;
    int coin[20];
    int **count, *count_data;
    int c1, c2;

    scanf("%d %d", &n, &m);
    for (i=0; i<m; i++) {
        scanf("%d", &(coin[i]));
    }

    count_data = (int *)malloc(sizeof(int) * (n+1) * (m+1));
    count = (int **)malloc(sizeof(int*) * (m+1));
    for (i = 0; i <= m; i++) {
        count[i] = &(count_data[i*(n+1)]);
    }

    for (i = 0; i <= m; i++) {
        for (j = 0; j <= n; j++) {
            if (i == 0) {
                count[i][j] = NO_DATA;
                continue;
            }
            if (j == 0) {
                count[i][j] = 0;
                continue;
            }
            denom = coin[i-1];
            if (j < denom) {
                count[i][j] = count[i-1][j];
            }
            else {
                c1 = count[i][j-denom] + 1;
                c2 = count[i-1][j];
                count[i][j] = c1 < c2 ? c1 : c2;
            }
        }
    }

    printf("%d\n", count[m][n]);
    
    free(count);
    free(count_data);

    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int gcd(int x,int y){
  if(x<=y) swap(x,y);
  if(y==0)return x;
  if(x%y==0) return y;
  else return(gcd(y,x%y));//最大公約数
}

int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n)cin >> a[i];
    vector<int> right(n+1,0);
    vector<int> left(n+1,0);
    REP(i,n){
        left[i+1]=gcd(left[i],a[i]);
    }
    REPR(i,n-1){
        right[i]=gcd(right[i+1],a[i]);
    }
    int max1 = -INF;
    REP(i,n){
        max1 = max(max1,gcd(right[i+1],left[i]));//right[n]=0;left[0]=0;
    }
    COUT(max1);
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		double X = N*1.00000000;
		System.out.println((N-(N/2))/X);

		sc.close();
	}
};


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

int main(){
    int N;
    cin >> N;
    int H[N];
    int mx=0,ans=0;

    for(int i=0;i<N;i++){
        cin >> H[i];
        if(mx<=H[i]){
            mx=H[i];
            ans++;
        }
    }
    
    cout <<  ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside.
//AVX is better slightly
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

int n, m, qq;
int ans, a[100];
struct lol{
    int a, b, c, d;
} qr[100];

void bktr(int q){
    if (q == n){
        int temp = 0;
        for (int i=1; i<=qq; i++){
            if (a[qr[i].b] - a[qr[i].a] == qr[i].c) temp += qr[i].d;
        }
        //cout << temp << '\n';
        //for (int i=1; i<=n; i++) cout << a[i] << ' ';
        //cout << '\n';
        ans = smax(ans, temp);
        return;
    }
    for (int i=a[q]; i<=m; i++){
        a[q + 1] = i;
        bktr(q + 1);
    }
}

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    cin >> n >> m >> qq;
    a[0] = 1;
    for (int i=1; i<=qq; i++)
        cin >> qr[i].a >> qr[i].b >> qr[i].c >> qr[i].d;
    bktr(0);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
	int h,a;
	cin>>h>>a;
	if(h<a)
	cout<<"1"<<endl;
	else
	{
		if(h%a==0)
		cout<<h/a<<endl;
		else
		cout<<h/a+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = raw_input().split()[0]
t = ['dreameraser','dreamerase','dreamer','dream','eraser','erase']
while len(S) > 0:
    for i in t:
        if S[-len(i):]==i:
            S = S[:-len(i)]
            break
        elif i == t[-1]:
            print "NO"
            exit()
print "YES"


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


def main():
    a, b = map(int, input().split())
    ans = 0
    empty = 1

    for i in range(20 + 1):
        if empty >= b:
            print(max(0, ans - 1))
            exit()
        else:
            ans += 1
            empty = i * a - ((i - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// Harry Singh**************************************************************************************************************

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 using namespace std;
#define endl '\n'
#define ll long long 
#define maxn 100010
const int MOD = 1000000007;
bool prime[20000000+3]; 

void harry_singh(){

   
   ll n,m;
   cin>>n>>m;
   ll v,u;
   vector<ll> vc[200005];
   ll vis[100005]={0};
   ll dis[100005]={0};
   ll vals[100005]={0};
   for(ll i=0;i<=100005;i++)
   dis[i]=1000000009;
   
   for(int i=1;i<=m;i++)
   {
   	cin>>u>>v;
   	if(u==1)
   	vc[u].push_back(v);
   	else if(v==1)
   	vc[v].push_back(u);
   	else
   	{
   		vc[u].push_back(v);
   	vc[v].push_back(u);
   	}
   	
   }
   
   if(vc[1].size()==0)
   cout<<"No\n";
   else
   {
   	queue<ll> q;
   	q.push(1);
   	dis[1]=0;
   	while(q.empty()==false)
   	{
   		int current=q.front();
   		q.pop();
   		if(vis[current])
   		continue;
   	    vis[current]++;
   	    
   		for(ll i=0;i<vc[current].size();i++)
   		{
   			ll th=vc[current][i];
   			if(vis[th]==0)
   			{
   					if(dis[th]>dis[current]+1){
   					dis[th]=dis[current]+1;
   					vals[th]=current;}
   			}

   			q.push(th);// 6   355    4 5 3
   			
   		}

   	}
   	
   	int f=0;
   	for(int i=1;i<=n;i++){
   	if(vis[i]==0){f=1;break;}}
   	if(f==0)
   	{
   		cout<<"Yes\n";
   	for(int i=2;i<=n;i++)
   	cout<<vals[i]<<endl;
   	}
   	else cout<<"No\n";
   	
   	
   }
   
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int t=1;
    while (t--)
   harry_singh();
    return 0;
}

Measured memory_bytes: 18596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long x){
	if (1 < x && x < 2*N-1) {
		cout << "Yes" << endl;
		queue<ll> que;
		repn(i,2*N-1) {
			if (i != 1 && i != 2*N-1 && i != x) {
				que.push(i);
			}
		}
		rep(i,N-2) {
			if (!que.empty()) {
				cout << que.front() << endl;
				que.pop();
			}
		}
		cout << 1 << endl;
		cout << x << endl;
		cout << 2*N-1 << endl;
		rep(i,N-2) {
			if (!que.empty()) {
				cout << que.front() << endl;
				que.pop();
			}
		}
	} else {
		cout << "No" << endl;
	}
}

int main(){	
	long long x;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&x);
	solve(N, x);
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const ll MOD = 1e9 + 7;

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

    string S;
    cin >> S;
    ll A = 0, B = 0, C = 0, N = 1;
    for (char c : S) {
        if (c == 'A') A = (A + N) % MOD;
        if (c == 'B') B = (B + A) % MOD;
        if (c == 'C') C = (C + B) % MOD;
        if (c == '?') {
            C = (3 * C + B) % MOD;
            B = (3 * B + A) % MOD;
            A = (3 * A + N) % MOD;
            N = 3 * N % MOD;
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 512
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {   
            string[] str = new string[1000000];
            int[] ans = new int[4] {0, 0, 0 ,0};
            for (int i = 0; (str[i] = Console.ReadLine()) != null; i++);

            foreach (var item in str)
            {
                if (item == "AC")
                 {
                    ans[0]++;
                 }
                else if (item == "WA")
                {
                    ans[1]++;
                }else if (item == "TLE")
                {
                    ans[2]++;
                }else if (item == "RE")
                {
                    ans[3]++;
                }
            }
            Console.WriteLine($"AC x {ans[0]}");
            Console.WriteLine($"WA x {ans[1]}");
            Console.WriteLine($"TLE x {ans[2]}");
            Console.WriteLine($"RE x {ans[3]}");
        }
    }
}


Measured memory_bytes: 29864
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

bool dfs(int i, int j, int N) {
    int calc = 4 * i + 7 * j;
    if (calc == N) {
        return true;
    } else if (calc > 100) {
        return false;
    }
    return dfs(i+1, j, N) || dfs(i, j+1, N);
}

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

    if (dfs(0, 0, N)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int fac = 1;
    for (int i = 1; i <= n; i++) fac *= i;
    map<vector<int>, int> mp;
    vector<int> v; for (int i = 1; i <= n; i++) v.push_back(i);
    int ix = 1;
    do {
        mp[v] = ix++;
    } while (next_permutation(v.begin(), v.end()));
    vector<int> p, q;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        p.push_back(x);
    }
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        q.push_back(x);
    }
    cout << abs(mp[p] - mp[q]);
    return 0;
}


Measured memory_bytes: 5248
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



struct Fact_combination {
private:
	vector<ll>FACT;
	vector<ll>IFACT;
	ll N;
public:
	ll extgcd(ll a, ll b, ll &x, ll &y) {
		ll g = a;
		x = 1;
		y = 0;
		if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
		return g;
	}
	ll invMod(ll a, ll m) {
		ll x, y;
		if (extgcd(a, m, x, y) == 1) return (x + m) % m;
		else return 0;
	}
	ll mod_pow(ll x, ll n) {
		ll res = 1;
		while (n > 0) {
			if (n & 1) res = res * x%MOD;
			x = x * x%MOD;
			n >>= 1;
		}
		return res;
	}
	void inverse(ll n) {
		N = n;
		FACT.resize(N + 1);
		IFACT.resize(N + 1);
		FACT[0] = 1;
		IFACT[0] = 1;
		for (int i = 1;i <= N;i++) {
			FACT[i] = FACT[i - 1] * i % MOD;
			IFACT[i] = invMod(FACT[i], MOD);
		}
	}
	ll combi(ll n, ll r) {
		if (n < 0 || r < 0 || r > n)return 0;
		if (r > n / 2)r = n - r;
		return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
	}
};



int n, a, b, c, d;
ll dp[2][1010];
vector<int>v[1010];


int main() {
	cin >> n >> a >> b >> c >> d;
	dp[0][0] = 1;
	Fact_combination fc;
	fc.inverse(n);
	for (int i = a;i <= b;i++) {
		for (int j = 1;j <= d;j++) {
			if (i*j > n)continue;
			v[i].eb(i);
		}
	}
	for (int i = a;i <= b;i++) {
		queue<P>q;
		for (int j = 0;j < n;j++) {
			if (dp[0][j])q.push(P(j, dp[0][j]));
		}
		for (int u = 0;u < v[i].size();u++) {
			int sz = q.size();
			while (sz) {
				P p = q.front();
				q.pop();
				sz--;
				if (p.fr + v[i][u] > n)continue;
				q.push(P(p.fr + v[i][u], ((p.sc*fc.combi(n - p.fr, v[i][u])%MOD * fc.invMod(u + 1,MOD))) % MOD));
				if (u + 1 < c)continue;
				dp[1][p.fr + v[i][u]] += p.sc * fc.combi(n - p.fr, v[i][u])%MOD * fc.invMod(u + 1, MOD) % MOD;
				dp[1][p.fr + v[i][u]] %= MOD;
			}
			for (int j = 0;j <= n;j++) {
				dp[1][j] += dp[0][j];
				dp[1][j] %= MOD;
				dp[0][j] = dp[1][j];
				dp[1][j] = 0;
			}
		}
	}
	cout << dp[0][n]%MOD << endl;
	return 0;
}

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

#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n";
#define print(a) for(auto &x : a) cout << x << " "; cout << "\n";

const int inf = 1e18 + 5;
const int N = 2e5 + 50;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
    int n, d;
    cin >> n >> d;
    // d = d * d;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        x = abs(x);
        y = abs(y);
        if(x * x + y * y <= d * d)
            ans++;
    }
    cout << ans << endl;
}

int32_t main()
{
    DESYNC
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
string s;
int q;
int k[75];

signed main() {
	int i;
	
	cin >> n >> s >> q;
	rep(i, q) cin >> k[i];
	
	rep(i, q) {
		int l = 0, r = 0;	//[l, r)
		int m = 0, c = 0, mc = 0;
		
		//初期化
		for (; r - l < k[i]; r++) {
			if (s[r] == 'M') {
				m++;
			}
			if (s[r] == 'C') {
				mc += m;
				c++;
			}
		}
		//cout << "[" << l << ", " << r << "), " << m << ", " << c << ", " << mc << endl;
		
		//尺取り
		int ans = 0;
		while (l < n) {
			//答える
			if (s[l] == 'D') { ans += mc; }
			//削除 (l++)
			if (s[l] == 'M') {
				mc -= c;
				m--;
			}
			if (s[l] == 'C') {
				c--;
			}
			l++;
			//追加 (r++)
			if (r >= n) continue;
			if (s[r] == 'M') {
				m++;
			}
			if (s[r] == 'C') {
				mc += m;
				c++;
			}
			r++;
			//cout << "[" << l << ", " << r << "), " << m << ", " << c << ", " << mc << endl;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;
ll c[51];
int main(){
    ll k,a,b;
    int j=0;
    scanf("%lld",&k);
    a=k/50;
    b=k%50;
    cout<<"50"<<endl;
    if(k%50==0){
        for(ll i=50+a-1;i>=a;i--)
            cout<<i<<" ";
    }
    else{
        for(ll i=50+a;i>=a;i--){
            c[j]=i;
            j++;
        }
        for(ll i=0;i<51;i++){
            if(i==b)
                continue;
            else
                cout<<c[i]<<" ";
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    if( n == 1 ) {
        dump("Hello World");
    }
    else if( n == 2 ) {
        int a, b;
        cin >> a >> b;
        dump(a+b);
    }
    return 0;  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
int main(void){
    // Your code here!
    int num;
    int count[26]={0};
    char ch;
    int i;
    //for(i=0;i<=25;i++) count[i]=0;
    while(scanf("%c",&ch)!=EOF){
        if((islower(ch))){
            num = ch - 'a';
            count[num]++;
        }
        else if(isupper(ch)){
            num = ch - 'A';
            count[num]++;
        }else{
            continue;
        }
    }
    for(i=0;i<26;i++){
       printf("%c : %d\n",'a'+i,count[i]);
    }
    return 0;
}



Measured memory_bytes: 2096
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[False]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                card[i][j] = True

    ans = "No"
    for i in range(3): #横に見てる
        if card[i][0] and card[i][1] and card[i][2]:
            ans = "Yes"
    for i in range(3): # 縦に見てる
        if card[0][i] and card[1][i] and card[2][i]:
            ans = "Yes"
    if card[0][0] and card[1][1] and card[2][2]:
        ans = "Yes"
    if card[0][2] and card[1][1] and card[2][0]:
        ans = "Yes"
    print(ans)

    
if __name__ == "__main__":
    main()

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

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int L; cin >> L;
	int n = 32 - __builtin_clz(L);
	vector< tuple<int, int, int> > V;
	for(int i = 1; i + 1 <= n; i++) {
		V.emplace_back(i, i + 1, 1 << (n - 1 - i));
		V.emplace_back(i, i + 1, 0);
	}
	while(L & (L - 1)) {
		int t = L & -L;
		L = L & (L - 1);
		int ctz = __builtin_ctz(t);
		V.emplace_back(1, n - ctz, L);
	}
	cout << n << ' ' << V.size() << '\n';
	for(auto &e : V) {
		int u, v, w;
		tie(u, v, w) = e;
		cout << u << ' ' << v << ' ' << w << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
	int A,X;
	scin(X)
	scin(A)
	if(A > X) printf("0\n"); else printf("10\n");
	return 0;
}

Measured memory_bytes: 128
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
#pragma endregion
const int maxn = 3005;
ll a[maxn], dp[maxn][maxn];
int main() {
    IO;
    int n;
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    per(l, 1, n) rep(r, l, n)
        dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
    cout << dp[1][n] << endl;
}

Measured memory_bytes: 49316
//in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   string s;
   cin>>s;
   sort(s.begin(),s.end());
   set<char>s1;
   set<char>:: iterator it;
   for(int i=0;i<s.size();i++)
    s1.insert(s[i]);
    bool f=0;
    for(it=s1.begin();it!=s1.end();it++)
    {
        int u=upper_bound(s.begin(),s.end(),*it)-s.begin();
         int l=lower_bound(s.begin(),s.end(),*it)-s.begin();
         int c=u-l;
         if(c%2!=0)
         {
             f=1;break;
         }


    }
    if(f==1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}



Measured memory_bytes: 3608
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int A, B, X; cin >> A >> B >> X;
	cout << (((X - A) >= 0 && (X - A <= B)) ? "YES" : "NO") << endl;;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappop,heappush
import sys
input = sys.stdin.readline
from math import sqrt
xs,ys,xt,yt=map(int,input().split())
N=int(input())
table=[[10**16]*(N+2) for i in range(N+2)]
L=[(xs,ys,0)]
for i in range(N):
    x,y,r=map(int,input().split())
    L.append((x,y,r))
L.append((xt,yt,0))
for i in range(N+2):
    for j in range(i+1,N+2):
        x,y,r=L[i]
        z,w,l=L[j]
        k=max(0,sqrt( abs(x-z)**2 + abs(y-w)**2   )-r-l )
        table[i][j]=k
        table[j][i]=k
H=[]
H.append((0,0))
visit=[0]*(N+2)
visit[0]=1
val=[10**16]*(N+2)
val[0]=0
#print(table)
while H:
    #print(H)
    cost,pt=heappop(H)
    if val[pt]<cost:
        continue
    if pt==N+1:
        print(val[pt])
        sys.exit()
    visit[pt]=1
    for j in range(N+2):
        if visit[j]==0 and j!=pt and val[j]>table[j][pt]+val[pt]:
            val[j] = table[j][pt] + val[pt]
            heappush(H,(val[j],j))



Measured memory_bytes: 122972
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            long area1 = go(h, w);
            long area2 = go(w, h);
//        System.out.println(area1+" "+area2);
            out.println(Math.min(area1, area2));

        }

        private long go(int tofix, int v) {
            long ans1 = Long.MAX_VALUE;
            long ans2 = Long.MAX_VALUE;
            for (long i = 0; i <= tofix; i++) {
                long A = i * v;
                long temp = (tofix - i) / 2;
                long B = temp * v;
                long C = (tofix - i - temp) * v;
                ans1 = Math.min(ans1, Math.max(A, C) - Math.min(A, B));
            }
//        System.out.println("ans1="+ans1);
            for (long i = 0; i <= tofix; i++) {
                long A = i * v;
                long B = (v / 2) * (tofix - i);
                long C = (v - v / 2) * (tofix - i);
                ans2 = Math.min(ans2, Math.max(A, C) - Math.min(A, B));
            }
//        System.out.println("ans2="+ans2);
            return Math.min(ans1, ans2);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21588
import java.util.*;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();

	if(Math.max(a,Math.max(b,c)) == 7 &&
	   Math.min(a,Math.min(b,c)) == 5 &&
	   a + b + c == 17){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}

    }
}


Measured memory_bytes: 8788
while True:
    a,op,b = input().split()
    
    if op == "?":
        break
    elif op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) // int(b))


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll n;
int a[50][50];
ll s[50];

ll f(){
	rep(d,1,31){
		ll temp=0;
		rep(i,0,n)if(a[i][d])temp|=s[i];
		rep(i,0,n)if(a[i][d])s[i]=temp;
		if(temp==(1LL<<n)-1)return d;
	}
	return -1;
}

int main(){
	while(scanf("%lld",&n),n){
		rep(i,0,50)rep(j,0,50)a[i][j]=0;
		rep(i,0,50)s[i]=1LL<<i;
		rep(i,0,n){
			ll m;
			scanf("%lld",&m);
			rep(j,0,m){
				ll t;
				scanf("%lld",&t);
				a[i][t]=1;
			}
		}
		printf("%lld\n",f());
	}
}


Measured memory_bytes: 2036
import itertools

N,M = map(int,input().split())
cakes = []
ans = 0

for i in range(0,N):
    pieces = [int(x) for x in input().split()]
    cakes.append(pieces)

pm = itertools.product([1,-1], repeat= 3)

for s1,s2,s3 in pm:
    ss = [x  * s1 + y * s2 + z * s3 for x,y,z in cakes]
    ss.sort()
    ss.reverse()
    ans = max(ans,sum(ss[0:M]))

print(ans)

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

int main() {
  int n;
  cin >> n;
  ll cnt[5];
  for (int i = 0; i < 5; i++) {
    cnt[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    char c = s[0];
    if (c == 'M') cnt[0]++;
    if (c == 'A') cnt[1]++;
    if (c == 'R') cnt[2]++;
    if (c == 'C') cnt[3]++;
    if (c == 'H') cnt[4]++;
  }

  ll ans = 0;
  int a[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  int b[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  int c[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
  for (int i = 0; i < (int)(sizeof(a) / sizeof(int)); i++) {
    ans += cnt[a[i]] * cnt[b[i]] * cnt[c[i]];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    
    //int a[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    if(d2 == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


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

using namespace std;

int r[51][11];
int w[51][11];
int p[51];

void init()
{

  for(int i = 0; i < 51; i++)
    {
      p[i] = 0;
      for(int j = 0; j < 11; j++)
	{
	  r[i][j] = w[i][j] = 0;
	}
    }


}


int main(void)
{

  int T,P,R;

  while(cin >> T >> P >> R)
    {

      init();

      for(int i = 0; i < R; i++)
	{

	  int tID , pID , time;
	  string judge;

	  cin >> tID >> pID >> time >> judge;
	  
	  if(judge == "WRONG")
	    {
	      if(r[tID][pID] != 1)
		{
		  w[tID][pID]++;
		}
	    }
	  
	  else if( r[tID][pID] == 0 )
	    {
	      r[tID][pID] = 1;
	      p[tID] += 1200 * w[tID][pID] + time;
	    }

	}
      
      pair< pair<int , int> , int > rank[50];

      for(int i = 0; i < T; i++)
	{
	  rank[i].first.first = -count(r[i + 1] , r[i + 1] + P + 1 , 1);
	  rank[i].first.second = p[i + 1];
	  rank[i].second = i + 1;
	}

      sort(rank , rank + T);

      for(int i = 0; i < T; i++)
	{
	  cout << rank[i].second << " " << -rank[i].first.first << " " << rank[i].first.second << endl;
	  
	}

    }
  return 0;

}

Measured memory_bytes: 1220
#include<stdio.h>
int F(int x,int y){return y?F(y,x%y):x;}
int main()
{
	int n,p,x,y,u,v,i,l,m,r,t;
	while(scanf("%d%d",&p,&n),p)
	{
		u=0;
		x=n+1;
		y=v=1;
		for(i=1;i<=n;++i)
		{
			for(l=1,r=n+1;l<r;)
			{
				m=(l+r)/2;
				if(double(m)*m/i/i>p)
				{
					if( (double)x/y > (double)m/i )
					{
						t=F(m,i);
						x=m/t,y=i/t;
					}
					r=m;
				}
				else
				{
					if( (double)u/v < (double)m/i)
					{
						t=F(m,i);
						u=m/t,v=i/t;
					}
					l=m+1;
				}
			}
		}
		printf("%d/%d %d/%d\n",x,y,u,v);
	}
	return 0;
}

Measured memory_bytes: 0
s=int(input())
t=list(map(int,input().split()))
a=0
for i in range(s):
  if t[i]%2==0:
    if t[i]%6!=0:
      if t[i]%10!=0:
        a=1
        break
if a==1:
  print('DENIED')
else:
  print('APPROVED')

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

int main()
{
	double Min = 99999999;
	double Max = -99999999;
	double Input;

	while (cin >> Input)
	{
		Min = min(Min, Input);
		Max = max(Max, Input);
	}
	cout << Max - Min << endl;

	return 0;
}

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

using namespace std;

class Plan
{
public:
	int t;
	int x;
	int y;

	Plan() {}
	Plan(int _t, int _x, int _y)
	{
		t = _t;
		x = _x;
		y = _y;
	}

	Plan operator -(const Plan& plan_) const
	{ 
		Plan plan;
		plan.t = this->t - plan_.t;
		plan.x = this->x - plan_.x;
		plan.y = this->y - plan_.y;

		return plan;
	}
};

bool calcIsRechable(Plan plan_diff)
{
	int sum = abs(plan_diff.x) + abs(plan_diff.y);
	if (plan_diff.t == sum) return true;
	
	int diff = plan_diff.t - sum;
	if (diff > 0 && (diff % 2 == 0)) return true;
	else return false;
}

int main()
{
	int N;
	vector<Plan> plans; //travel plan

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int t, x, y;
		cin >> t >> x >> y;
		plans.push_back(Plan(t, x, y));
	}

	Plan plan_prev(0, 0, 0);
	bool IsRechable = false;
	for(auto itr = plans.begin(); itr != plans.end(); ++itr)
	{
		Plan plan_diff = *itr - plan_prev;
		IsRechable = calcIsRechable(plan_diff);
		if (!IsRechable) break;
		plan_prev = *itr;
	}

	if (IsRechable) cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1912
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int m,d,i,j,x,y,ans=0;
	cin >> m >> d;
	for(i=1; i<=m; ++i){
		for(j=1; j<=d; ++j){
			x = j/10;
			y = j%10;
			if(x>1 && y>1 && i==x*y){
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#define llint long long
#define mod 1000000007

using namespace std;

llint sx, sy, tx, ty;
const int FACT_MAX = 3000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

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

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> sx >> sy >> tx >> ty;
	
	llint ans = 0;
	for(int i = sx; i <= tx; i++){
		ans += comb(i+ty+1, ty), ans %= mod;
		ans += mod - comb(i+(sy-1)+1, sy-1), ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 47104
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Sol();
        }

        public void Sol()
        {

            long x = long.Parse(Console.ReadLine());

            long a = x / 11;
            long ans = a * 2;
            long b = x % 11;
            if (b == 0)
            {
                
            }
            else if (b > 6)
            {
                ans += 2;
            }
            else
            {
                ans += 1;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int ct=0;
    vector<int> v(2010); //lの値 -> l以下の値で一番大きいindex
    int tmp = 0;
    for(int i=0; i<=2000; i++){
        v[i] = tmp;
        int ct = 0;
        for(auto li : l){
            if(i==li) {
                v[i] = ct;
                tmp = ct;
            }
            ct++;
        }
    }
    //rep(i,n) cout << l[i] << " ";
    ll ans = 0;
    rep(i,n){
        for(int j=i+1; j<n; j++){
            int mx = l[i]+l[j];
            //cout << mx << " " << v[mx-1] <<" " << j << endl;
            ans += (ll)max(0,v[mx-1] - j);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

int64 MinimumCost(vector< int > &A, vector< int > &B)
{
  vector< int > near(B.size());
  int tail = 0;
  for(int i = 0; i < B.size(); i++) {
    while(tail < A.size() && A[tail] < B[i]) ++tail;
    near[i] = tail;
  }
  int sz = (int) B.size() * 2 + 1;
  vector< int64 > dp(sz, 0);
  for(int i = 0; i < B.size(); i++) {
    const int diff = near[i] - (i == 0 ? 0 : near[i - 1]);
    for(int j = 0; j < sz; j++) dp[j] = dp[min(j + diff, sz - 1)];
    vector< int64 > nxt(sz, INF);
    for(int j = 0; j < sz - 1; j++) {
      const int k = near[i] - (int) B.size() + j;
      nxt[j + 1] = min(nxt[j + 1], nxt[j]);
      if(k < 0 || k >= A.size()) continue;
      nxt[j + 1] = min(nxt[j + 1], dp[j] + abs(B[i] - A[k]));
    }
    dp.swap(nxt);
  }
  if(dp.back() == INF) return (-1);
  return (dp.back());
}

int main()
{
  int N, P[4000], D[4000];

  while(scanf("%d", &N), N) {
    if(N == 2) {
      int a, b, c, d;
      scanf("%d %d %d %d", &a, &b, &c, &d);
      printf("%d\n", abs(a - c));
      continue;
    }
    vector< int > latte, malta;
    for(int i = 0; i < N; i++) {
      scanf("%d %d", &P[i], &D[i]);
      if(D[i] == 1) latte.push_back(i);
      else malta.push_back(i);
    }

    sort(begin(latte), end(latte), [&](int a, int b) -> bool
    {
      return (P[a] < P[b]);
    });
    sort(begin(malta), end(malta), [&](int a, int b) -> bool
    {
      return (P[a] < P[b]);
    });

    for(int i = 1; i < malta.size(); i++) --D[malta[i]];
    for(int i = 0; i + 1 < malta.size(); i++) --D[malta[i]];

    vector< int > beet, vs;
    for(int i : malta) while(D[i]--) beet.push_back(P[i]);
    for(int i : latte) vs.push_back(P[i]);
    if(vs.size() > beet.size()) puts("-1");
    else printf("%lld\n", MinimumCost(beet, vs) + P[malta.back()] - P[malta.front()]);
  }
}

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

int main(void) {
	int num, temp, prenum = -1, total = 0;
	cin >> num;
	vector<bool> preorder(num - 1, false);
	//vector<int> prevalue(num - 1);

	cin >> prenum;
	for (int i = 1; i < num; i++) {
		cin >> temp;
			if (prenum + 1 == temp) preorder.at(prenum-1) = true;
		prenum = temp;
	}
	for (int i = 0; i < num; i++) {
		cin >> temp;
		total += temp;
	}
	for (int i = 0; i < num - 1; i++) {
		cin >> temp;
		if (preorder.at(i)) total += temp;
	}

	cout << total << endl;
}


Measured memory_bytes: 256
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

void ans()
{
	int n;
	cin>> n;
	ll arr[n+10];
	ll x=0;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
		x^=arr[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cout<<(arr[i]^x)<<' ';
	}
	cout<<endl;
}

int main()
{
    // ll n;
    // cin >>n;
   ans();
    
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, cnt =0;cin>>n;
    string s;cin>>s;
    for(int i=0; i<n-2; i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')cnt++;
    }
    cout<<cnt<<endl;

}


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

#define mp make_pair
#define pb push_back

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

const int N = 2e5 + 10;

int n, a[N], ma[N], ma2[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) {
		scanf("%d", a + i);
		ma[i] = max(ma[i - 1], a[i]);
	}
	for(int i = n; i >= 1; i --) {
		ma2[i] = max(ma2[i + 1], a[i]);
	}
	for(int i = 1; i <= n; i ++) printf("%d\n", max(ma[i - 1], ma2[i + 1]));
	return 0;
}


Measured memory_bytes: 3968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[M];
    int[] d = new int[M];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    for(int i = 0; i < M; i++) {
      c[i] = sc.nextInt();
      d[i] = sc.nextInt();
    }
    for(int i = 0; i < N; i++) {
      int dist = Integer.MAX_VALUE;
      int check = 0;
      for(int j = 0; j < M; j++) {
        if(dist > Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])) {
          dist = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
          check = j + 1;
        }
      }
      System.out.println(check);
    }
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
ll n;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n;
  vector<vector<ll>>cnt(10,vector<ll>(10));
  repi(i,1,n+1){
    ll lo=i%10,hi=i;
    while(hi/10!=0)hi/=10;
    cnt[lo][hi]++;
  }
  ll res=0;
  rep(i,10)rep(j,10){
    res+=cnt[i][j]*cnt[j][i];
  }

  cout<<res<<endl;



  return 0;

}


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

#define N 100

int x[N];
int y[N];

int main() {
	int n, m, X, Y;

	cin >> n >> m >> X >> Y;
	for( int i = 0; i < n; i++ ) {
		cin >> x[i];
	}
	for( int i = 0; i < m; i++ ) {
		cin >> y[i];
	}

	int xmax = -101;
	for( int i = 0; i < n; i++ ) {
		if( x[i] > xmax ) {
			xmax = x[i];
		}
	}
	int ymin = 101;
	for( int i = 0; i < m; i++ ) {
		if( y[i] < ymin ) {
			ymin = y[i];
		}
	}
	int ans = 0;
	if( ymin <= xmax ) {
		ans = 1;
	}
	if( ymin <= X || ymin > Y ) {
		ans = 1;
	}

	if( ans == 0 ) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main()
{
 for(int i=0; ;i++)
 {
    string str;
    cin>>str;
    if(str=="-")break;
    int m;
    cin>>m;
    int h[m];
    for(int s=0;s<m;s++){
      cin>>h[s];
      string g;
      for(int f=0;f<h[s];f++){g+=str[f];}
      str.erase(str.begin(),str.begin()+h[s]);
      str+=g;
    }
   cout<<str<<endl;
 }
   return 0;
}


Measured memory_bytes: 3212
using System;
using System.Linq;

namespace ABC100_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(AB[0] <= 8 && AB[1] <= 8 ? "Yay!" : ":(");
        }
    }
}


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


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

	for (int i = 0; i <= n / 4; i++)
	{
		if ((n - 4 * i) % 7 == 0)
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
	return 0;
}

Measured memory_bytes: 256
// WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define _dbg(x) cout << #x << " is " << (x) << endl;
#define dbg(v, x) cout << #v << ": "; for(int i = 0; i < (x); i++)  cout << (v)[i] << " "; cout << endl;

using namespace std;

void solve()
{
    ll val = 100;
    ll x;
    cin >> x;
    ld mult = 1.01;
    ll ans = 0;
    while(val < x)
    {
        val *= mult;
        ans++;
    }
    cout << ans << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1;
    //cin >> q;
    for(int i = 0; i < q; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652