akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(400<=x && x<600){
    cout<<8<<'\n';
  }
  if(600<=x && x<800){
    cout<<7<<'\n';
  }
 if(800<=x && x<1000){
    cout<<6<<'\n';
  }
 if(1000<=x && x<1200){
    cout<<5<<'\n';
  }
  if(1200<=x && x<1400){
    cout<<4<<'\n';
  }
  if(1400<=x && x<1600){
    cout<<3<<'\n';
  }
 if(1600<=x && x<1800){
    cout<<2<<'\n';
  }
  if(1800<=x && x<2000){
    cout<<1<<'\n';
    }
  return(0);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll

int h, w, n, k, ans;

int pot[50*50];

int query(int y1, int y2, int x1, int x2)
{
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	int ans;
	cin >> ans;
	return ans;
}

void solve(int y1, int y2, int x1, int x2, int cnt, int split)
{
	if(cnt==0)
		return;

	if(cnt==(y2-y1+1)*(x2-x1+1))
	{
		for(int i = y1; i <= y2; ++i)
		{
			for(int j = x1; j <= x2; ++j)
			{
				ans += pot[i*w+j];
				ans %= k;
			}
		}

		return;
	}

	if(1)//split)
	{
		int m = (y1+y2)/2;
		int h = query(y1, m, x1, x2);
		solve(y1, m, x1, x2, h, split^1);
		solve(m+1, y2, x1, x2, cnt-h, split^1);
	}
	else
	{
		int m = (x1+x2)/2;
		int h = query(y1, y2, x1, m);
		solve(y1, y2, x1, m, h, split^1);
		solve(y1, y2, m+1, x2, cnt-h, split^1);
	}
}

int32_t main()
{
	cin >> h >> w >> n >> k;

	pot[0] = 1;

	for(int i = 1; i < 50*50; ++i)
	{
		pot[i] = pot[i-1]*2%k;
	}

	for(int j = 0; j < w; ++j)
	{
		solve(0, w-1, j, j, query(0, w-1, j, j), 1);
	}

	/*for(int i = 0; i < h; i += 5)
	{
		for(int j = 0; j < w; j += 5)
		{
			solve(i, i+4, j, j+4, query(i, i+4, j, j+4), 1);
		}
	}*/

	//solve(0, h-1, 0, w-1, n, 1);

	cout << "! " << ans << endl;
}

Measured memory_bytes: 720
n,q = map(int, input().split())

root_list = [i for i in range(n)]

def root(x):
    path_to_root = []
    while root_list[x] != x:
        path_to_root.append(x)
        x = root_list[x]
    for node in path_to_root:
        root_list[node] = x
    return x

def is_same_set(x,y):
    return root(x) == root(y)

def unite(x,y):
    root_list[root(x)] = root(y)

for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        #unite
        unite(x,y)
    else:
        if is_same_set(x,y):
            print(1)
        else:
            print(0)


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

int main(){
    string Q,E;
    cin>>Q>>E;
    string password;
    for(int i=0;i<Q.size();i++){
        password+=Q[i];
        if(E.size()==i)
            break;
        password+=E[i];
    }
    cout<<password<<endl;
    return 0;
}

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

int main()
{
    int n, x;
    int total;
    while (cin >> n >> x)
    {
        total = 0;
        if (n == 0 && x == 0)
        {
            break;
        }
        for (int i = 1; i <= n; ++i)
        {
            for (int j = i + 1; j <= n; ++j)
            {
                for (int k = j + 1; k <= n; ++k)
                {
                    if (i + j + k == x)
                        total += 1;
                }
            }
        }
        cout << total << endl;
    }
}


Measured memory_bytes: 3108
/*
 
Sviatoslav Bidzilia 2020
CF: anakib1
 
*/
 
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <functional>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a), [](int x, int y){return x > y;})
#define pii pair<int, int>
#define tii triple<int, int, int>
#define sz(x) (int)(x.size())
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long
 
template<typename A, typename B, typename C>
struct triple
{
    A X;
    B Y;
    C Z;
    triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
    return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
    if (a.X != b.X)
        return a.X < b.X;
    if (a.Y != b.Y)
        return a.Y < b.Y;
    return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
    ofs << "( " << p.F << " , " << p.S << " )";
    return ofs;
}
template<typename T>
void print(T a)
{
    for (auto i : a)
        cout << i << ' ';
    cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
    return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
    return min(a, min(b, c));
}
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
signed main()
{
    //freopen(".in", "r", stdin);a
    //freopen(".out", "w", stdout);
    srand(time(NULL));
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int k; cin >> k;
    queue<int> a;
    rngi(i, 9) a.push(i + 1);
    rng(k -1){
        int v = a.front(); a.pop();
        if(v % 10) a.push(10 * v + v%10-1);
        a.push(10 * v + v % 10);
        if(v % 10 < 9) a.push(10 * v + v % 10 + 1);
    }
    cout << a.front() << '\n';
}
//check corner case (interactives!)
//check n=1 or n=2
//check size of arrays
//more asserts
//scanf printf
//read everything normaly



Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define SETBIT(x) __builtin_popcountll(x)
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;

ll A[N], B[N];


ll exp(ll x, ll n, ll mod){
    ll ans = 1LL, X = x, N = n;
    while(N > 0){
        if(N & 1) ans = (ans * X) % mod;
        X = (X * X) % mod;
        N >>= 1;
    }
    return ans;
}

int main() {
    fast;

    ll l, r, d;

    cin >> l >> r >> d;
    int cnt = 0;
    for(int i = l; i <= r; i++) if(i % d == 0) cnt++;

    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;


class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		System.out.println(d + " " + r + " " + String.format("%.5f",f));
	}
}


Measured memory_bytes: 26332
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    const int A = 86400, B = 10800;

    priority_queue<pii, vector<pii>, greater<pii> > pq;
    int cur = 0, ans = 0, cnt = 0;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        (cur += a) %= A;
        if (cur <= B) {
            pq.push(mp(B - cur, 1));
            cnt++;
        } else {
            pq.push(mp(A - cur, 0));
        }
        (cur += b) %= A;
    }
    ans = cnt;

    for (int t = 0; t < A; ++t) {
        pii p;
        while (sz(pq) && (p = pq.top()).first == t && p.second == 0) {
            pq.pop();
            cnt++;
            pq.push(mp(t + B, 1));
        }
        smax(ans, cnt);

        while (sz(pq) && (p = pq.top()).first == t && p.second == 1) {
            pq.pop();
            cnt--;
            pq.push(mp(t + A-B, 0));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1528
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include<iostream>
#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,P) scanf("%d %d %d %d",&n,&m,&o,&P)
#define SINT5(n,m,o,P,q) scanf("%d %d %d %d %d",&n,&m,&o,&P,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1010000000; // 0x3C33'6080
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	k %= 2;
	rep(i, k) {
		// printf("%3lld   %3lld %3lld %3lld\n",a-b,a,b,c);
		ll A = b + c;
		ll B = a + c;
		ll C = b + a;
		a = A; b = B; c = C;
	}
	cout << a - b << endl;


}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int count = 0;

    // "000" ~ "999" まで総当たり
    rep(i, 0, 10) rep(j, 0, 10) rep(k, 0, 10)
    {
        bool f = false;
        bool m = false;
        bool e = false;

        // numberで指定された文字列が、Sの入力値で作成可能か判定
        rep(l, 0, N)
        {
            if (!f && S[l] == i + '0')
            {
                f = true;
                continue;
            }
            if (f && !m && S[l] == j + '0')
            {
                m = true;
                continue;
            }
            if (f && m && !e && S[l] == k + '0')
            {
                ++count;
                break;
            }
        }
    }

    std::cout << count << endl;

    return 0;
}


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

int main()
{
	int N, K;
	char s[11];
	scanf("%d", &N);
	scanf("%s", s);
	scanf("%d", &K);
	int i;
	char check = s[K - 1];
	for (i = 0;i < N;i++)
	{
		if (s[i] != check)s[i] = '*';
	}
	printf("%s\n", s);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cassert>
#include <complex>
#include <iomanip>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF 1000000007LL
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pb push_back
#define sz size()

typedef complex<double> P;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(){}
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

bool insecLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS ||
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;
}

P proj(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

double distLP(const L &l, const P &p) {
  return abs(p - proj(l, p));
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0];
  if (abs(A) < EPS) assert(0);
  return m[0] + B / A * (m[1] - m[0]);
}

vector<L> bisector(const L &l, const L &m){
	vector<L> res;
	if(insecLL(l,m)){
		P p=crosspoint(l,m);
		P dl=l[1]-l[0],dm=m[1]-m[0];
		P q,r;
		if(abs(dl)>abs(dm)){
			q=dl+dm/abs(dm)*abs(dl);
			r=dl-dm/abs(dm)*abs(dl);
		}else{
			q=dl/abs(dl)*abs(dm)+dm;
			r=dl/abs(dl)*abs(dm)-dm;
		}
		res.pb(L(p,p+q));
		res.pb(L(p,p+r));
		return res;
	}
	else{
		P p=proj(l,m[0]);
		P q=(m[0]+p)/2.;
		res.pb(L(q,q+l[1]-l[0]));
		return res;
	}
}

int n;
L line[111];

int main(){
	cout<<setprecision(15);
	while(cin>>n && n){
		rep(i,n){
			int x,y,xx,yy;
			cin>>x>>y>>xx>>yy;
			line[i]=L(P(x,y),P(xx,yy));
		}
		if(n<=2){
			cout<<"Many\n";
			continue;
		}
		vector<L> bisec01=bisector(line[0],line[1]),
		bisec02=bisector(line[0],line[2]);
		P ans(INF,INF);
		rep(i,bisec01.sz)rep(j,bisec02.sz){
			if(insecLL(bisec01[i],bisec02[j])){
				P p=crosspoint(bisec01[i],bisec02[j]);
				double dist=distLP(line[0],p);
				rep2(k,3,n){
					if(abs(distLP(line[k],p)-dist)>EPS){
						goto fail;
					}
				}
				if(abs(ans-p)>EPS){
					if(abs(ans)>INF){
						ans=p;
					}else{
						cout<<"Many\n";
						goto end;
					}
				}
				fail:;
			}
		}
		if(abs(ans)>INF)cout<<"None\n";
		else cout<<ans.real()<<" "<<ans.imag()<<endl;
		end:;
	}
}

Measured memory_bytes: 0
loop do
    w, d = gets.split.map(&:to_i)
    break if w == 0 && d == 0
    c = gets.split.map(&:to_i)
    r = gets.split.map(&:to_i)
    max = [c.max, r.max].max
    sum = 0
    1.upto(max) do |i|
        count = [c.count(i), r.count(i)].max
        sum += count * i
    end
    puts sum
end

Measured memory_bytes: 6096
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

bool flag[11][1<<15];
int memo[11][1<<15];
int g[11][11];

int main(){
  int n;
  while(cin>>n, n){
    vector<pair<string,int> > v[n];
    map<string,int> m;
    
    REP(i,n){
      int l; cin>>l;
      v[i] = vector<pair<string,int> >(l);
      REP(j,l){
	string str;
	int mon;
	cin>>str>>mon;
	v[i][j].f = str;
	v[i][j].s = mon;

	if(m.count(str)) m[str] = min(m[str], mon);
	else m[str] = mon;
      }
    }
    int q; cin>>q;
    int costsum = 0;
    bool check = true;
    vector<string> name(q);
    vector<int> place(n+1);
    REP(i,q){
      cin>>name[i];
      if(m.count(name[i])) costsum += m[name[i]];
      else check = false;
    }

    REP(i,n+1) REP(j,(1<<q)){
      flag[i][j] = false;
      memo[i][j] = INT_MAX;
    }
    REP(i,n+1) REP(j,n+1) g[i][j] = 0;

    int mm; cin>>mm;
    REP(i,mm){
      int a,b,d; cin>>a>>b>>d;
      g[a][b] = g[b][a] = d;
    }

    REP(i,n){
      int f = 0;
      REP(j,v[i].size())
	if(m[v[i][j].f] == v[i][j].s)
	  REP(k,q)
	    if(name[k] == v[i][j].f)
	      f |= (1 << k);
      place[i+1] = f;
    }

    if(!check){
      puts("impossible");
      continue;
    }

    typedef pair<int,pair<int,int> > data;
    priority_queue<data,vector<data>,greater<data> > pq;

    pq.push(mp(0, mp(0, 0)));

    while(pq.size()){
      data d = pq.top(); pq.pop();
      int cost = d.f;
      int pos = d.s.f;
      int f = d.s.s;

      if(flag[pos][f]) continue;
      flag[pos][f] = true;
      memo[pos][f] = cost;

      if(pos == 0 && f == (1<<q)-1)
	break;

      REP(i,n+1) if(g[pos][i] != 0){
	int cc = cost + g[pos][i];
	int ff = f | place[i];

	if(!flag[i][ff] && memo[i][ff] > cc){
	  memo[i][ff] = cc;
	  pq.push(mp(cc, mp(i, ff)));
	}
      }
    }

    if(flag[0][(1<<q)-1])
      printf("%d %d\n",costsum,memo[0][(1<<q)-1]);
    else
      puts("impossible");
  }
  return 0;
}

Measured memory_bytes: 0
s = input()
if s[0] == s[1]:
    if s[2] == s[3] and s[0] != s[2]:
        print("Yes")
    else:
        print("No")
elif s[0] == s[2]:
    if s[1] == s[3] and s[0] != s[1]:
        print("Yes")
    else:
        print("No")
elif s[0] == s[3]:
    if s[1] == s[2] and s[0] != s[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

using namespace std;
int u,v,kq,x[100005],y[100005],deg[100005],n,m,slx;
vector<int> a[100005],ng[100005];
queue<int> q;
void sxtp()
{
    for (int i=1;i<=n;++i) if (deg[i]==0) q.push(i);

    while (!q.empty())
    {

        int u=q.front();q.pop();
        x[++slx]=u;y[u]=slx;
        for (int i=0;i<a[u].size();++i)
        {
            int v=a[u][i];
            deg[v]--;
            if (deg[v]==0) q.push(v);
        }
    }
}
int main()
{

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (int i=1;i<=n+m-1;++i)
    {
        cin>>u>>v;
        a[u].push_back(v);deg[v]++;
        ng[v].push_back(u);
    }
    sxtp();
    for (int u=1;u<=n;++u)
    {
        kq=0;
        for (int j=0;j<ng[u].size();++j)
        {
            v=ng[u][j];
           // if (u==1) cout<<v<<endl;
            if (y[v]>y[kq]) kq=v;
        }
        cout<<kq<<'\n';
    }
   // cout<<x[1]<<' '<<y[6]<<endl;


    return 0;
}


Measured memory_bytes: 12928
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp make_pair
#define pb push_back
#define mes(a,b) memset(a,b,sizeof(a))
#define mes0(a) memset(a,0,sizeof(a))
#define lson l,mid,pos<<1
#define rson mid+1,r,pos<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define sss(a) a::iterator
#define all(a) a.begin(),a.end()

using namespace std;

typedef double DB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<long long ,int> pli;
typedef pair<int,long long > pil;
typedef pair<string,int> psi;
typedef pair<long long ,long long > pll;

const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const int maxn = 100000+10;
const int mod = 1e9+7;
deque<int> pos[26];
char s[212345];
int G[212345][26];
int vis[212345];
int pre[212345];
int dp[212345];
int nt[212345];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%s",s+1);
    int len=strlen(s+1);
    for (int i=1;i<=len;i++){
        pos[s[i]-'a'].pb(i);
    }
    for (int i=0;i<=len;i++){
        if (s[i])
            pos[s[i]-'a'].pop_front();
        for (int j=0;j<26;j++){
            if (pos[j].size()){
                G[i][j]=pos[j][0];
            }else G[i][j]=len+1;
        }
    }
    for (int i=len;i>=0;i--){
        int t=0;
        for (int j=0;j<26;j++){
            if (dp[G[i][j]]<dp[G[i][t]])t=j;
        }
        dp[i]=dp[G[i][t]]+1;
        nt[i]=t;
    }
    int ss=0;
    while (ss<=len){
        printf("%c",nt[ss]+'a');
        ss=G[ss][nt[ss]];
    }
    return 0;
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 2e3+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n,m,L;
int a[maxN];

int main()
{
	scanf("%d%d",&n,&L);
	int sum = 0;
	for(int i=1;i<=n;i++)
	{
		sum += (L+i-1);
	}
	int ans = INF;
	int res = sum;
	for(int i=1;i<=n;i++)
	{
		if(abs(L+i-1) < ans)
		{
			ans = abs(L+i-1);
			res = sum - (L+i-1);
		}
	}
	cout<<res<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
ll k;
int main()
{
    gbtb;
    cin>>n>>k;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    repd(i,2,n)
    {
        dp[i]=inf;
    }
    repd(i,2,n)
    {
        for(int j=i-1;j>=max(1ll,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}


Measured memory_bytes: 5168
w, h, n = map(int, input().split())

matrix = []
for j in range(h):
	line = []
	for i in range(w):
		line.append(0)
	matrix.append(line)

for k in range(n):
	x, y, a = map(int, input().split())
	if a == 1:
		for i in range(len(matrix)):
			for j in range(x):
				matrix[i][j] = 1
	elif a == 2:
		for i in range(len(matrix)):
			for j in range(x, len(matrix[0])):
				matrix[i][j] = 1
	elif a == 3:
		for i in range(y):
			for j in range(len(matrix[0])):
				matrix[i][j] = 1
	else:
		for i in range(y, len(matrix)):
			for j in range(len(matrix[0])):
				#print("i: ", i)
				#print("j: ", j)
				matrix[i][j] = 1

cnt = 0
for i in range(len(matrix)):
	for j in range(len(matrix[0])):
		if matrix[i][j] == 0:
			cnt += 1

print(cnt)

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

int n, a[1000], ans;

int main() {
	while (true) {
		cin >> n;
		if (!n)break;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);

		ans = INT32_MAX;
		for (int i = 0; i < n-1; i++) {
			ans = min(ans, abs(a[i] - a[i + 1]));
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 3108
while line = gets do
  n,x = line.chomp.split(" ").map{|x| x.to_i}
  if n==0 && x==0
    break
  end
  count = 0
  for i in (1..n).to_a.reverse do
    if i > x-3
      next
    elsif x > 3*i-3
      break
    end
    for j in (1..i-1).to_a.reverse do
      if i+j > x-1
        next
      elsif x-i-j > j-1
        break
      end
      count += 1
    end
  end
  printf("%d\n",count)
end


Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


void solve() {
    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] << "\n"; 
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    ll n, ans = 1, a, z = 0;
    cin>>n;
    while (n--){
        cin>>a;
        if (ans > (ll)1e18/a){
            ans = -1;
            break;
        }
        ans*=a;
    }

    while (n>0){
        cin>>a;
        if (a==0){
            z++;
        }
        n--;
    }
    if (z) ans = 0;
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  x/=50;
  int cnt=0;
  rep(i,0,a+1){
    rep(j,0,b+1){
      rep(k,0,c+1){
        if((i*10+j*2+k)==x) cnt++; 
      }
    }
  }
  cout<<cnt<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ND = br.readLine().split(" ");

		int N = Integer.parseInt(ND[0]);
		int D = Integer.parseInt(ND[1]);

		int[][] TENi = new int[N][D];

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

			String[] TEN = br.readLine().split(" ");

			for (int j = 0; j < D; j++) {
				TENi[i][j] = Integer.parseInt(TEN[j]);
			}

		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				//System.out.print(TENi[i][j] + " ");
			}
			//System.out.println();
		}

		double[][] sum = new double[N][N];

		for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < D; j++) {
					sum[k][i] += Math.pow(Math.abs(TENi[k][j] - TENi[i][j]), 2);
				}
				sum[k][i] = Math.sqrt(sum[k][i]);
			}
		}

		int count = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {

				if (sum[i][j] % 1 == 0 && sum[i][j] != 0) {
					//System.out.println(sum[i][j] + "は整数です");
					count++;
				}
			}
		}

		System.out.println(count / 2);
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxm = 200005;
const int maxn = 4005;
const int N = 2001;
const int M = 8004;
const int mod = 1e9+7;

int fac[maxn<<1],inc[maxn<<1],ans;
int dp[maxn][maxn],n,x[maxm],y[maxm];
LL fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
LL calc(int n,int m) {
	return (LL)fac[n+m]*inc[n]%mod*(LL)inc[m]%mod;
}
int main()
{
	#ifdef Amberframe
		freopen("agc001e.in","r",stdin);
		freopen("agc001e.out","w",stdout);
	#endif
	scanf("%d",&n);fac[0]=inc[0]=1;
	for (int i=1;i<=M;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[M]=fpm(fac[M],mod-2);
	for (int i=M;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	
	for (int i=1;i<=n;i++) scanf("%d %d",&x[i],&y[i]);
	for (int i=1;i<=n;i++) dp[N-x[i]][N-y[i]]++;
	for (int i=1;i<=(N<<1);i++)
	for (int j=1;j<=(N<<1);j++)	
		dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
	for (int i=1;i<=n;i++)
		ans=(ans+dp[N+x[i]][N+y[i]])%mod;
	for (int i=1;i<=n;i++)
		ans=(ans-calc(x[i]<<1,y[i]<<1))%mod;
	ans=ans*fpm(2,mod-2)%mod;
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 64512
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int x = int.Parse(s);
            int h = x / 3600;
            int m = (x - h * 3600)/60;
            int s1 = (x % 3600) - (m * 60);
            Console.WriteLine(h + ":" + m + ":" + s1);
        }
    }
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <cassert>
#include <cstddef>
#include <limits>
#include <queue>
#include <unordered_map>
#include <utility>
#include <vector>

// lib/dijkstra.hpp
#ifndef DIJKSTRA_HPP
#define DIJKSTRA_HPP


/*
usage:

tools::dijkstra<int> calculator(node_count);
calculator.add_edge(from_node, to_node, cost);
std::vector<int> distances = calculator.calc(start_node);
*/

namespace tools {
  template <typename T>
  class dijkstra {
  private:
    std::vector<T> distances;
    std::vector<std::size_t> prev_nodes;
    std::priority_queue<std::pair<T, std::size_t>, std::vector<std::pair<T, std::size_t>>, std::greater<std::pair<T, std::size_t>>> tasks;
    std::vector<std::unordered_map<std::size_t, T>> edges;

  public:
    static constexpr std::size_t NONE = std::numeric_limits<std::size_t>::max();

    dijkstra(const std::size_t node_count) :
      distances(node_count),
      prev_nodes(node_count),
      tasks(),
      edges(node_count) {
    }

    void add_edge(const std::size_t from, const std::size_t to, const T distance) {
      this->edges[from].insert(std::make_pair(to, distance));
    }

    std::vector<T> calc(const std::size_t start_node) {
      assert(start_node < this->distances.size());
      this->distances.assign(this->distances.size(), std::numeric_limits<T>::max());
      this->prev_nodes.assign(this->prev_nodes.size(), std::size_t(NONE));
      this->tasks.push(std::make_pair(0, start_node));
      while (!this->tasks.empty()) {
        const std::pair<T, std::size_t> task = this->tasks.top();
        this->tasks.pop();
        const T& distance = std::get<0>(task);
        const std::size_t& target_node = std::get<1>(task);
        if (this->distances[target_node] != std::numeric_limits<T>::max()) {
          // old task for already visited node
          continue;
        }
        this->distances[target_node] = distance;
        for (const std::pair<std::size_t, T>& edge : this->edges[target_node]) {
          const std::size_t& next_node = std::get<0>(edge);
          const T new_distance = distance + std::get<1>(edge);
          if (new_distance < this->distances[next_node]) {
            this->prev_nodes[next_node] = target_node;
            this->tasks.push(std::make_pair(new_distance, next_node));
          }
        }
      }
      return this->distances;
    }
  };
}

#endif

// main.cpp

int main() {
  std::int_fast64_t N;
  std::cin >> N;
  tools::dijkstra<std::int_fast64_t> dijkstra(N);
  for (std::int_fast64_t i = 0; i < N - 1; ++i) {
    std::int_fast64_t a_i, b_i, c_i;
    std::cin >> a_i >> b_i >> c_i;
    dijkstra.add_edge(a_i - 1, b_i - 1, c_i);
    dijkstra.add_edge(b_i - 1, a_i - 1, c_i);
  }

  std::int_fast64_t Q, K;
  std::cin >> Q >> K;
  std::vector<std::int_fast64_t> cache = dijkstra.calc(K - 1);
  for (std::int_fast64_t i = 0; i < Q; ++i) {
    std::int_fast64_t x_i, y_i;
    std::cin >> x_i >> y_i;
    std::cout << cache[x_i - 1] + cache[y_i - 1] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 21020
#include<iostream>
using namespace std;
#define H 251
#define X 2000000001
int main(){
  int h,a[H],i;
  cin>>h;
  for(i=1;i<=H;i++)a[i]=X;
  for(i=1;i<=h;i++){
    cin>>a[i];
  }

  for(i=1;i<=h;i++){
    cout<<"node "<<i<<": key = "<<a[i];
    if(i==1){
      if(h>=2)cout<<", left key = "<<a[i+1];
      if(h>2)cout<<", right key = "<<a[i+2]<<", "<<endl;    
      continue;
    }
    cout<<", parent key = "<<a[i/2];
    if(a[2*i]!=X && 2*i<=H){
      cout<<", left key = "<<a[2*i];
    }
    if(a[2*i+1]!=X&& 2*i<=H){
      cout<<", right key = "<<a[2*i+1];
    }
    cout<<", "<<endl;
  }
  return 0;
}



Measured memory_bytes: 3088
n, m, d = map(int, input().split())
mp = [input() for _ in range(n)]
ans = 0
for line in mp:
  cnt = 0
  for c in line:
    if c == ".":
      cnt += 1
    else:
      if cnt >= d:
        ans += cnt - d + 1
      cnt = 0
  if cnt >= d:
    ans += cnt - d + 1

for x in range(m):
  cnt = 0
  for y in range(n):
    if mp[y][x] == ".":
      cnt += 1
    else:
      if cnt >= d:
        ans += cnt - d + 1
      cnt = 0
  if cnt >= d:
    ans += cnt - d + 1

print(ans)


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int c[26] = {}, f = 0;
  string S;
  cin >> S;
  int len = S.size();
  REP(i, len) {
    int k = S[i] - 'a';
    if(c[k]) {
      f = 1;
    } else {
      c[k] = 1;
    }
  }
  cout << (f ? "no" : "yes") << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

S_ans = S
count = 0
for i in range(N):
    if S[i]=="(": # > p
        if i>=1 and S[i-1]==")": #m > p
            if count<0:
                S_ans = ("("*abs(count))+S_ans
                count = 0
        count += 1
    else: # > m
        count -= 1
    #print(S[i],count)
        
if count > 0:
    S_ans = S_ans+(")"*abs(count))
else:
    S_ans = ("("*abs(count))+S_ans
    
print(S_ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int m;
    cin >> m;
    ll keta = 0;
    ll sum = 0;
    rep(i, m) {
        int d; ll c;
        cin >> d >> c;
        keta += c;
        sum += d * c;
    }
    int last = sum % 9;
    if (last == 0) last = 9;
    ll ans = (9 * keta + sum - last - 1) / 9;
    cout << ans << endl;
    
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  ll a;
  rep(i, N){
    cin >> a;

    ans += a - 1;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
vector<int>mmp[M];
int col[M],du[M],val[M],dp1[M],dp2[M],n,rt,tot,more;
bool allb[M];
char ch[M];
void in()
{
    int a,b;
    scanf("%d",&n);
    for(int i=1;i<n;++i)
    scanf("%d%d",&a,&b),mmp[a].push_back(b),mmp[b].push_back(a);
    scanf("%s",ch+1);
    for(int i=1;i<=n;++i)col[i]=ch[i]=='W'?0:1,rt=col[i]?rt:i;
}
void dfs(int v,int f)
{
    allb[v]=col[v];int to;
    for(int i=mmp[v].size()-1;i>=0;--i)
    {
        to=mmp[v][i];if(to==f)continue;
        dfs(to,v);
        if(!allb[to])++du[v],++du[to];
        allb[v]&=allb[to];
    }
}
void dp(int v,int f)
{
    tot+=du[v];
    if((du[v]+col[v])&1)val[v]=0;
    else val[v]=2,++tot;
    int mx1=0,mx2=0,to;bool flag=0;
    for(int i=mmp[v].size()-1;i>=0;--i)
    {
        to=mmp[v][i];
		if(to==f||allb[to])continue;
        flag=1; dp(to,v);
        more=max(more,max(dp1[to]+mx2+val[v],dp2[to]+mx1+val[v]));
        mx1=max(dp1[to],mx1);
		mx2=max(dp2[to],mx2);
    }
    dp1[v]=mx1+val[v];dp2[v]=flag?mx2+val[v]:-INT_MAX;
}
void ac()
{
    dfs(rt,0);dp(rt,0);
    if(rt)printf("%d",tot-more);
    else printf("0");
}
int main()
{
    in();ac();
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> v(n, 0);
  for (ll i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  double a = double(v[0]);
  for (ll i = 1; i < v.size(); ++i) {
    a = (a + double(v[i])) / double(2);
  }

  cout << fixed << setprecision(10);
  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k=0,N,M,D;
  scanf("%d %d",&M,&D);
  
  for(i=1;i<=M;i++){
    for(j=1;j<=D;j++){
      if((j/10 != 1) && (j%10 !=1))
      if(i == ((j/10)*(j%10)))
        k++;
    }
  }
  printf("%d\n",k);
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	auto a = vector<int>(n);
	for(auto&& aa : a) cin >> aa;
	bool first = true;
	for(auto i = n - 1; i >= 0; i -= 2){
		if(first) first = false;
		else cout << " ";
		cout << a[i];
	}
	for(auto i = n % 2; i < n; i += 2){
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	
	b := make([]int, n-1)
	a := make([]int, n)
	
	for i := 0; i < n-1; i++ {
		scanner.Scan()
		j, _ := strconv.Atoi(scanner.Text())
		b[i] = j
	}
	
	answer := 0
	
	for i, _ := range a {
		if i == 0 {
			a[i] = b[i]
		} else if i == n-1 {
			a[i] = b[i-1]
		} else {
			a[i] = min(b[i-1], b[i])
		}
	}
	
	for _, s := range a {
		answer += s
	}
	
	fmt.Println(answer)
}

func min(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


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

    ll n;
    cin>>n;
    ll ans=(n*(n-1))/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
    int m = 0, ctr = 0;
    string str;
    cin >> str;
    FOR(i, 0, str.size())
    {
        if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T')
            ctr++;
        else
        {
            m = max(m, ctr);
            ctr = 0;
        }
    }
    cout << max(m, ctr) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

struct SegTree{
	llint size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(llint size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	
	void update(llint i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	llint query(int a, int b)
	{
		if(a > b) return inf;
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint N, E, T;
llint x[100005];
SegTree seg(17), seg2(17);

int main(void)
{
	cin >> N >> E >> T;
	for(int i = 1; i <= N; i++) cin >> x[i];
	
	seg.init(), seg.update(0, 0);
	seg2.init(), seg2.update(0, -2*x[1]);
	
	for(int i = 1; i <= N; i++){
		llint lb = lower_bound(x, x+N, x[i] - T/2) - x;
		llint tmp = seg.query(lb-1, i-1) + T;
		tmp = min(tmp, seg2.query(0, lb-2) + 2*x[i]);
		seg.update(i, tmp), seg2.update(i, tmp - 2*x[i+1]);
	}
	cout << seg.query(N, N) + E << endl;
	return 0;
}

Measured memory_bytes: 5120