akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    pair<ll,ll> P[N];
    rep(i,N) cin >> P[i].first >> P[i].second;
    sort(P,P+N);
    ll cnt = 0;
    ll out = 0;
    rep(i,N){
        rep(j,P[i].second){
            out += P[i].first;
            cnt++;
            if(cnt==M) break;
        }
        if(cnt==M) break;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
n = gets.to_i
edge = (n-1).times.map{gets.split.map(&:to_i)}
vert = (0..n).map{[]}
colors = []

edge.each.with_index{|(a,b),i|
  vert[a] << [b,i]
  vert[b] << [a,i]
}
q = [1,0,0]
while q[0]
  a,parent,parent_color = q.pop
  color = 0
  vert[a].each{|b,i|
    next if b == parent
    color += 1
    color += 1 if color == parent_color
    colors[i] = color
    q << [b,a,color]
  }
end
p colors.max
puts colors

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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        string a,b;
        cin>>a>>b;
        ll n=a.size(),m=b.size();
        ll ans=0;
        ll i,j;
        for(i=0; i<=n-m; i++)
        {
            ll c=0;
            for(j=0; j<m; j++)
            {
                if(a[i+j]==b[j])
                    c++;
            }
            ans=max(ans,c);
        }
        cout<<m-ans<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M,D; cin >> M >> D;
    LL ans = 0;
    FOR(i,1,M+1){
        FOR(j,10,D+1){
            int d = j;
            int d1 = d % 10;
            int d2 = (d / 10) % 10;
            if(i == d1 * d2 && d1 >= 2 && d2 >= 2) {
                ans++;
                dump(i)
                dump(j)
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  double weight;

  while(scanf("%lf",&weight)!=EOF) {

  if(weight>91.00) printf("heavy\n");

  else if(weight>81.00) printf("light heavy\n");
  
  else if(weight>75.00) printf("middle\n");

  else if(weight>69.00) printf("light middle\n");

  else if(weight>64.00) printf("welter\n");

  else if(weight>60.00) printf("light welter\n");

  else if(weight>57.00) printf("light\n");

  else if(weight>54.00) printf("feather\n");

  else if(weight>51.00) printf("bantam\n");

  else if(weight>48.00) printf("fly\n");

  else printf("light fly\n");

  }
  return 0;

}

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

int main(){ 
    Int X; cin >> X;
    vector<bool> isnt_prime(100100, false);

    isnt_prime[0] = true;
    isnt_prime[1] = true;
    for (int i = 2; i < X; i++) {
        if (!isnt_prime[i]) {
            for (int j = 2; j * i < X + 100; j++) {
                isnt_prime[j * i] = true;
            }
        }
    }
    for (Int k = X; k < X + 100; k++) {
        if (!isnt_prime[k]) {
            cout << k << endl;
            return 0;
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll A = pow(10, 5);

const ll N = A + 200;

vector<bool> primes(N + 50000, true);

void prime_solve()
{
    primes[0] = false;
    primes[1] = false;
    for(ll i = 2; pow(i,2) <= N; i++){
        if(primes[i])for(ll j = 2; i*j<=N; j++){
            primes[i*j] = false;
        }
    }
}

/*
 * r =グー        index 0
 * s = ちょき          1
 * p = パー           2
 */

int main()
{
    uint32_t N, M;
    cin >> N >> M;
    vector<vector<uint32_t>> P(N+1, vector<uint32_t>(2, 0));
    uint32_t pc=0, wc=0;
    for(uint32_t i = 0; i < M; i++){
        int a;string s;
        cin >> a >> s;
        if(P[a][1] == 0)
            P[a][0]++;
        if(s == "AC" && P[a][1] == 0){
            P[a][1] = 1;
            pc++;
        }
    }
    for(uint32_t i = 1; i <= N; i++){
        if(P[i][1] == 1)wc += P[i][0]-1;
    }

    cout << pc << " " << wc << endl;

    return 0;
}


Measured memory_bytes: 5760
/**
 * Tree - Rooted Trees
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	static final int NIL = -1;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line;

		int n = parseInt(br.readLine());
		int[] p = new int[n];
		int[] l = new int[n];
		int[] r = new int[n];
		int[] d = new int[n];

		Arrays.fill(p, NIL);
		Arrays.fill(l, NIL);
		Arrays.fill(r, NIL);

		StringTokenizer st;
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			int u = parseInt(st.nextToken());
			int k = parseInt(st.nextToken());
			int c, _c = -1;
			for (int j = 0; j < k; j++) {
				c = parseInt(st.nextToken());
				if (j == 0) l[u] = c;
				p[c] = u;
				if (j > 0) r[_c] = c;
				_c = c;
			}
		}

		int root = 0;
		while (p[root] != NIL) root++;

		Deque<int[]> q = new ArrayDeque<int[]>();
		q.push(new int[]{root, 0});
		while (!q.isEmpty()) {
			int[] u = q.pop();
			d[u[0]] = u[1];
			if (r[u[0]] != NIL) q.push(new int[]{r[u[0]], u[1]});
			if (l[u[0]] != NIL) q.push(new int[]{l[u[0]], u[1] + 1});
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append("node " + i + ": ");
			sb.append("parent = " + p[i] + ", ");
			sb.append("depth = " + d[i] + ", ");
			if (p[i] == NIL) {
				sb.append("root, ");
			} else if (l[i] != NIL) {
				sb.append("internal node, ");
			} else {
				sb.append("leaf, ");
			}
			sb.append("[");
			if (l[i] != NIL) {
				int c = l[i];
				sb.append(c);
				while (r[c] != NIL) {
					sb.append(", " + r[c]);
					c = r[c];
				}
			}
			sb.append("]\n");
		}
		System.out.print(sb.toString());
	} //end main
}

Measured memory_bytes: 132384
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

ll f[NMAX*2];
    
ll pow(ll a, ll b, ll MOD)
{
    ll x=1,y=a; 
    while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
    return x;
}
    
/* Modular Multiplicative Inverse
    Using Euler's Theorem
    a^(phi(m)) = 1 (mod m)
    a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
    return pow(n,MOD-2,MOD);
}
    
ll C(ll n, ll r, ll MOD)
{
    
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
    

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

	int n,k;
	cin >> n >> k;

	f[0]  = 1;
	for(int i= 1; i< NMAX*2; ++i)
	{
		f[i] = (f[i-1] * i) % MOD;
	}


	ll ans = C(2*n -1, n- 1,MOD);

	for(++k; k <= n -1; ++k)
	{
		ans = (ans + MOD - C(n,k,MOD)* C(n-1,n-1-k,MOD)% MOD)%MOD;
	}

	cout << ans;


    return 0;
}

Measured memory_bytes: 15872
<?php

$input_number = trim(fgets(STDIN));
$ryuka_cache = [];

for ($i = 0; $i < (int)$input_number; $i++)
{
	$ryuka_cache[$i] = calc_ryuka($i);
}

echo calc_ryuka((int)$input_number);

function calc_ryuka($i)
{
	global $ryuka_cache;
	if (isset($ryuka_cache[$i]))
	{
		return $ryuka_cache[$i];
	}

	if ($i === 0)
	{
		return 2;
	}
	else if ($i === 1)
	{
		return 1;
	}

	return calc_ryuka($i - 1) + calc_ryuka($i - 2);
}


Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

using integer = unsigned long long;

int main(void) {
  integer N, K;
  std::cin >> N >> K;

  integer ptn = K * std::pow((integer)(K-1), (N-1));

  std::cout << ptn << std::endl;

  return 0;
}


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

int main(void){
	long long n, k;
	cin >> n >> k;
	vector<long long> a(n), b(n,0), c(n, 0);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			if(a[i] > a[j]){
				b[i]++;
			}
		}
		for(int j = 0; j < n; ++j){
			if(a[i] > a[j]){
				c[i]++;
			}
		}
	}
	long long ans = 0;
	for(int i = 0; i < n; ++i){
		ans += k * b[i];
		ans %= MOD;
		ans += ((k - 1) * k / 2) % MOD * c[i] % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int	 main(void)
{
  long int n,i,ai;
  long int sum=0;
  long int min=10000000;
  long int max=-10000000;
  
  scanf("%ld",&n);

  for(i=0; i<n; i++){
    scanf("%ld",&ai);
    sum = sum + ai;
    if(ai > max)
      max = ai;
    if(ai < min)
      min = ai;
  }

  printf("%ld %ld %ld\n",min,max,sum);
  
  return(0);
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    cout<<1.0-1.0*(n/2)/n;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n,a[3],i,j,k,temp;
    scanf("%d",&n);
    for (i=0; i<n; i++) scanf("%d",&a[i]);
    for (i=0; i<n-1; i++) {
        if (a[i]<a[i+1]) {
            temp=a[i];
            a[i]=a[i+1];
            a[i+1]=temp;
        }
    }
    for (i=1; i<=a[n-1]; i++) {
        for (j=0; j<n; j++) {
            if (a[j]%i!=0) break;
        }
        if (j==n) printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void) {
	int a, b;
	char op;

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

		switch(op) {
			case '+':
				printf("%d\n", a + b);
				break;
			case '-':
				printf("%d\n", a - b);
				break;
			case '*':
				printf("%d\n", a * b);
				break;
			case '/':
				printf("%d\n", a / b);
				break;
			default:
				break;
		}
	} while(op != '?');

        return 0;
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y;
int dp[10][10];
int SG(int x,int y){
    if(x<=1&&y<=1)return 0;
    if(dp[x][y]!=-1)return dp[x][y];
    set<int> s;
    for(int i=2;i<=x;i+=2)s.insert(SG(x-i,y+i/2));
    for(int i=2;i<=y;i+=2)s.insert(SG(x+i/2,y-i));
    for(int i=0;;i++)if(s.count(i)==0)return dp[x][y]=i;
}
void baoli(){
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++)dp[i][j]=-1;
    }
    for(int i=0;i<=5;i++){
        for(int j=i;j<=5;j++)cout<<i<<' '<<j<<' '<<SG(i,j)<<endl;
    }
}
int main(){
    //baoli();
    scanf("%lld%lld",&x,&y);
    if(x>y)swap(x,y);
    if(y-x<=1)printf("Brown\n");
    else printf("Alice\n");
    return 0;
}

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

int main(){
  int K, S;
  int total = 0;
  cin >> K >> S;
  for(int i = 0; i <= K; ++i){
    for(int j = 0; j <= K; ++j){
      if((S - i - j) >= 0 && (S - i - j) <= K) ++total;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

signed main(){
  int n;cin>>n;string s;cin>>s;
  int r = 0, b = 0;
  rep(i,n){
    if(s[i] == 'R')r++;
    else b++;
  }
  if(r > b)cout << "Yes" << endl;
  else cout <<"No" << endl;
}


Measured memory_bytes: 256
s = gets.chomp.split("")
count = 0
max = 0
for i in 0..s.length-1 do
    if s[i] == "A" ||s[i] == "T" ||s[i] == "G" ||s[i] == "C"
        count += 1
    else
        count = 0
    end
    if count > max
        max = count
    end
end

puts max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for(int i = A; i <= min(B, A + K - 1); i++) {
    cout << i << endl;
  }
  for(int i = max(B - K + 1, A + K); i <= B; i++) {
    cout << i << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 1e5+10;
int a[maxd],b[maxd],c[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    for(int i=1;i<n;i++) scanf("%d",&c[i]);
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans += b[a[i]];
        if(i>1&&a[i-1] == a[i]-1) ans+=c[a[i-1]];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

#上から貪欲法
N = ri()
A = np.array(rl())
A.sort()
answer = A[-2:-1-2*N:-2].sum()
print(answer)
#35


Measured memory_bytes: 46116
#include<bits/stdc++.h>
using namespace std;
int main()
{
     string s[200005];
     long long n,i,count=1;
     cin>>n;
     for(i=1;i<=n;i++)
     {
         cin>>s[i];
     }
     sort(s+1,s+1+n);
     for(i=1;i<n;i++)
     {
         if(s[i]!=s[i+1])count++;
     }
     cout<<count<<endl;
     return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = max(b * d, a * c);
  a = abs(a);
  b = abs(b);
  c = abs(c);
  d = abs(d);
  ans = max(ans, -min(a, b) * min(c, d));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

ll solve() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i] >> B[i];
    }
    vector<ll> dp(2e4+1, INF); 
    dp[0] = 0;
    for ( int i = 1; i <= 2e4; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            int k = i - A[j];
            if ( k < 0 ) continue;
            dp[i] = min(dp[i], dp[k] + B[j]);
        }
    }
    ll ans = INF;
    for ( int i = 2e4; i >= H ; i-- ) {
        ans = min(ans, dp[i]);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int round;
	while (scanf("%d", &round), round)
	{
		int n, m;
		scanf("%d%d", &n, &m);

		static int d[100100];
		d[0] = 0;
		for (int i = 1; i < n; ++i)
			scanf("%d", d + i);
		sort(d, d + n);

		int res = 0;
		while (m--)
		{
			int k;
			scanf("%d", &k);
			int i = lower_bound(d, d + n, k) - d;

			int dis = 1e9 + 10;
			if (i > 0)
				min_swap(dis, k - d[i - 1]);
			if (i < n)
				min_swap(dis, d[i] - k);
			min_swap(dis, round - k);

			res += dis;
		}
		printf("%d\n", res);
	}
}

Measured memory_bytes: 1264
// https://atcoder.jp/contests/abc108/tasks/abc108_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    P n[4], df;
    cin >> n[0].first >> n[0].second >> n[1].first >> n[1].second;
    df = {n[1].first - n[0].first, n[1].second - n[0].second};
    n[2] = {n[1].first - df.second, n[1].second + df.first};
    n[3] = {n[2].first - df.first, n[2].second - df.second};
    cout << n[2].first << " " << n[2].second << " " << n[3].first << " "
         << n[3].second << "\n";

    return 0;
}


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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  long long ans = 0;
  map<string, long long> mp;
  int n;
  cin >> n;
  rep(i, 1, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++mp[s];
  }
  for (const auto & p: mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << "\n";

  return 0;
}


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

/* ABC168 riple Dots */
int main()
{
    string S;
    string T;
    string ans = "No";
    cin >> S;
    cin >> T;

    if(S.size() == T.size()-1) {
        if(S == T.erase(S.size())) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string S1 = Console.ReadLine();
                if (S1 == "-")
                {
                    break;
                }
                int L1 = S1.Length;
                char[] S2 = S1.ToCharArray();
                int num1 = int.Parse(Console.ReadLine());
                for (int n1 = 0; n1 < num1; n1++)
                {
                    int num2 = int.Parse(Console.ReadLine());
                    char[] S3 = new char[num2];
                    for (int i2 = 0; i2 < num2; i2++)
                    {
                        S3[i2] = S2[i2];
                    }

                    char[] S4 = new char[L1 - num2];
                    for (int i3 = num2; i3 < L1; i3++)
                    {
                        S4[i3 - num2] = S2[i3];
                    }

                    for (int i4 = 0; i4 < L1 - num2; i4++)
                    {
                        S2[i4] = S4[i4];
                    }

                    for (int i5 = L1 - num2; i5 < L1; i5++)
                    {
                        S2[i5] = S3[i5 - L1 + num2];
                    }
                }
                Console.WriteLine(S2);
            }
        }
    }
}



Measured memory_bytes: 15916
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var S = ReadLine();
        var a = int.Parse(S.Substring(0, 2));
        var b = int.Parse(S.Substring(2));
        var x = false;
        var y = false;
        if (1 <= a && a <= 12) x = true;
        if (1 <= b && b <= 12) y = true;
        if (x && y) WriteLine("AMBIGUOUS");
        if (!x && y) WriteLine("YYMM");
        if (x && !y) WriteLine("MMYY");
        if (!x && !y) WriteLine("NA");

    }
}


Measured memory_bytes: 13140
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a=fsc.nextInt(), b=fsc.nextInt(), x=fsc.nextInt();
        fsc.close();
        double ans,s,t;
        if(x<=a*a*b/2.){
            s=2.*(double)x/((double)a*(double)b);
            t=(double) b;
            ans=90.-Math.atan2(s,t)*180./Math.PI;
        }
        else{
            s=(double) a;
            t=2.*((double) b-(double)x/((double)a*(double)a));
            ans=Math.atan2(t,s)*180./Math.PI;
        }
        System.out.println(ans);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Measured memory_bytes: 22996
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=10001;

int main()
{
	int a[5];
	while(cin>>a[0]>>a[1]>>a[2])
	{
		sort(a,a+3);
		if((a[0]==a[1] && a[2]!=a[0]) || (a[1]==a[2] && a[0]!=a[1]))
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	} 
	return 0;
} 

Measured memory_bytes: 256
# スイッチONとOFFで、電球と繋がっている繋がっていないも、0or1なので、ビット演算を使用するのが吉

# スイッチと電球の繋がりをビット列で表す
# スイッチ(行）と電球(列)のマトリクスを作って、繋がっているところに1、繋がっていないところに0
# 行方向に見るとスイッチがどの電球に繋がっているかのビット列ができる
# intで持ってもよいので、100 は　4　

# 電球が点いているか点いていないかをビット列で表す
# スイッチを押すたびに、1つ前のスイッチが繋がっている電球にそのスイッチも繋がっていれば、偶奇が変化してスイッチの点滅が変化する
# スイッチを押すたびにxorをとる
# 電球の点滅とpが一致していればok


n, m = map(int, input().split())

# kはスイッチ、sはスイッチが繋がっている電球を表す
k = []
s = []

for _ in range(m):
    tmp = tuple(map(int, input().split()))
    k.append(tmp[0])
    s.append(set(tmp[1:tmp[0] + 1]))
 
p = tuple(map(int, input().split()))
 
# print(k, s, p, sep="\n")

ans = 0

# スイッチの押し方を全部試す
for i in range(2 ** n):
    # 各iでonになっている電球の数
    light_on = 0
 
    # 電球jについて
    for j in range(m):
        switch_on = 0
 
        for k in range(n):
            # onになっているスイッチ（kビット目が立っているか）
            if (i >> k) & 1:
                # 電球jとつながっているものならカウント
                # sはスイッチkが繋がっている電球jのリスト
                # スイッチは1からなので、k+1
                if k + 1 in s[j]:
                    switch_on += 1
 
        # onになっているスイッチの個数がp[j]に等しいなら電球jは点灯している
        if switch_on % 2 == p[j]:
            light_on += 1
 
    # 全ての電球が点灯しているならカウント
    if light_on == m:
        # print(bin(i))
        ans += 1
 
print(ans)

Measured memory_bytes: 3064
#include<string>
#include<iostream>
using namespace std;
int main()
{
    string s;
    int f=0;
    getline(cin,s);
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='C'&&!f)f=1;
        if(s[i]=='F'&&f)f=2;
    }
    if(f==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5;
const int maxm = 5e5 + 5;
const ll inf = 2147483647;
int a[1001];
int main(){
    int x;
    cin>>x;
    if(x >= 400 && x < 600)cout<<8<<endl;
    if(x >= 600 && x < 800)cout<<7<<endl;
    if(x >= 800 && x < 1000)cout<<6<<endl;
    if(x >= 1000 && x < 1200)cout<<5<<endl;
    if(x >= 1200 && x < 1400)cout<<4<<endl;
    if(x >= 1400 && x < 1600)cout<<3<<endl;
    if(x >= 1600 && x < 1800)cout<<2<<endl;
    if(x >= 1800 && x < 2000)cout<<1<<endl;
    return 0;
}


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

int main()
{
	char b;
	cin >> b;
	
	if (b == 'A')
		cout << 'T' << endl;
	else if (b == 'C')
		cout << 'G' << endl;
	else if (b == 'T')
		cout << 'A' << endl;
	else if (b == 'G')
		cout << 'C' << endl;
	
	return 0;
}

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

int main() {
  int n, m, d;
  cin >> n >> m >> d;

  string str[n];
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      bool flag = false;
      for (int k = 0; k < d; k++) {
	if (j + k == m || str[i][j + k] == '#') {
	  flag = true;
	  break;
	}
      }
      if (flag == false) count++;
    }
  }

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      bool flag = false;
      for (int k = 0; k < d; k++) {
	if (j + k == n || str[j + k][i] == '#') {
	  flag = true;
	  break;
	}
      }
      if (flag == false) count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3212
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 1e6+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int w[20][2000];
int x[2000][20];
bool vis[1005];
int main(){
    int n = read(),m = read(),k = read();
    rep(i,1,n){
        rep(j,1,m){
            char c;
            cin >> c;
            w[i][j] = c -'0';
            x[j][i] = x[j][i-1] + w[i][j];
        }
    }
    int S = (1 << (n));
    //cout <<S<<endl;return 0;
    int ans = INF;
    for(int q = 1;q <= S-1;++ q){
        int p = q;
        p |= (1<<(n-1));
        vector<int> Q[20];
        int  tot = 0;
        int inx = 1;
        bool r = 1;
        for(int i = 0;i < n;++i){
            if((p>>i)&1){
                tot ++;
                rep(j,1,m){
                    int d = x[j][i+1] - x[j][inx-1];
                    if(d > k) {r = 0;break;}
                    Q[tot].push_back(d);
                }
                inx = i + 2;
            }
            if(r == 0) break;
        }
        if(r == 0) continue;
        /*
        rep(i,0,n-1){
            if((p>>i)&1) cout<<i+1<<' ';
        }
        puts("");
        rep(i,1,tot){
            rep(j,0,Q[i].size()-1) cout << Q[i][j]<<' ';
            puts("");
        }
        continue;
        */
        int h = 0;
        int Sum[12] = {0};
        for(int i = 0;i <= m-1;++i){
            bool op = 1;
            for(int j = 1;j <= tot;++j){
                Sum[j] += Q[j][i];
                if(Sum[j]>k){op = 0;break;} 
            }
            if(!op){
                h ++;
                rep(j,1,tot) Sum[j] = Q[j][i];
            }
        }
        ans = min(ans,tot-1+h);
    }
    if(ans == INF) ans = 0;
    cout << ans;
}


Measured memory_bytes: 384
# https://atcoder.jp/contests/agc009/tasks/agc009_a

n=int(input())
ab=[tuple(map(int,input().split())) for _ in range(n)]

ans=0
for a,b in reversed(ab):
    a+=ans
    res=a%b
    if res:
        ans+=b-res
print(ans)

Measured memory_bytes: 16720
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << "0\n";
        return;
    }
    if (a >= b) {
        cout << "1\n";
        return;
    }
    --a;
    --b;
    cout << (b + a - 1) / a << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)

l_max = 0
r_min = 10**9
m.times do |i|
  l,r = gets.split.map(&:to_i)
  l_max = [l,l_max].max
  r_min = [r,r_min].min
end

p [[n,r_min].min - l_max + 1, 0].max

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 2e3+2;

ll dp[T][T];
vii v;
int n;

ll solve(int l, int r) {
    if(l > r) return 0;
    if(~dp[l][r]) return dp[l][r];
    int x = l+n-r-1;
    return dp[l][r] = max(solve(l+1,r)+abs(v[x].se-l)*v[x].fi, solve(l,r-1)+abs(v[x].se-r)*v[x].fi);
}

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        v.eb(x,i);
    }
    sort(v.begin(),v.end(),greater<ii>());
    cout << solve(0,n-1) << endl;
    return 0;
}



Measured memory_bytes: 35124
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class G
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var h = Read();
		var n = h[0];
		// 多重辺および自己ループを除去。
		var es = new int[h[1]].Select(_ => Read()).Select(e => (v0: e[0], v1: e[1])).Where(e => e.v0 != e.v1).Distinct().ToArray();

		var map = Array.ConvertAll(new int[n], _ => new List<int>());
		var map_r = Array.ConvertAll(new int[n], _ => new List<int>());
		foreach (var (v0, v1) in es)
		{
			map[v0].Add(v1);
			map_r[v1].Add(v0);
		}

		var u = new bool[n];
		var order = new int[n];
		var c = n;
		var gs = new List<List<int>>();
		List<int> lg = null;

		void Dfs(int v)
		{
			u[v] = true;
			foreach (var nv in map[v]) if (!u[nv]) Dfs(nv);
			order[--c] = v;
		}
		for (int v = 0; v < n; v++) if (!u[v]) Dfs(v);

		void Dfs_r(int v)
		{
			u[v] = true;
			foreach (var nv in map_r[v]) if (!u[nv]) Dfs_r(nv);
			lg.Add(v);
		}
		Array.Clear(u, 0, n);
		foreach (var v in order) if (!u[v]) { gs.Add(lg = new List<int>()); Dfs_r(v); }

		Console.WriteLine(gs.Count);
		foreach (var g in gs)
			Console.WriteLine($"{g.Count} {string.Join(" ", g)}");
		Console.Out.Flush();
	}
}


Measured memory_bytes: 161636
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;

vector<int>G[MAX_N];
void rec(int now,vector<bool>&used,vector<int>&v){
    if(used[now])return;
    used[now]=true;
    for(auto g :G[now]){
        //cout<<g<<endl;
        if(used[g])continue;
        v[g]+=v[now];
        rec(g,used,v);
    }
}

int main(){
    int N,Q;
    cin>>N>>Q;
    vector<int>V(N,0);
    vector<bool>used(N,false);
    REP(i,N-1){
        int a,b;
        cin>>a>>b;a--;b--;
        G[a].PB(b);G[b].PB(a);
    }
    REP(i,Q){
        int p,x;
        cin>>p>>x;p--;
        V[p]+=x;
    }
    rec(0,used,V);
    REP(i,N)cout<<V[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;
    vector<vector<ll>> d(N, vector<ll>(N, -1));
    rep(i, N-1) d[i][i+1] = 1;
    d[X][Y] = 1;

    rep(i, N) rep(j, N) {
        if(i >= j) continue;
        if(j <= X || Y <= i) d[i][j] = j -i;
        else if (X <= i && j <= Y) d[i][j] = min(j - i, 1 + Y - j + i - X);
        else if (i <= X && Y <= j) d[i][j] = X - i + 1 + j - Y;
        else if (i <= X && X <= j && j <= Y) d[i][j] = X - i + min(j - X, 1 + Y - j);
        else if (X <= i && i <= Y && Y <= j) d[i][j] = min(Y - i, i - X + 1) + j - Y;
    }

    vector<ll> ans(N-1, 0);
    rep(i, N) rep(j, N) {
        if(i >= j) continue;
        ans[d[i][j] - 1]++;
    }

    rep(i, N-1) cout << ans[i] << endl;
}


Measured memory_bytes: 31616
#include <stdio.h>

int main()
{ 
  int a,b,d,r;
  double f;
  scanf("%ld%ld",&a,&b);
  d = a / b;
  r = a % b;
  f = (double)a/b;

  printf("%ld %ld %lf\n",d,r,f);

  return 0;
}
  

Measured memory_bytes: 1064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int H, W, N, a, out[100][100];
    cin >> H >> W >> N;

    int h = 0, w = 0;
    REP(i, N) {
        cin >> a;
        REP(_, a) {
            out[h][w] = i + 1;
            h = w == W - 1 ? h + 1 : h;
            w = (w + 1) % W;
        }
    }

    REP(i, H) {
        if (i % 2 == 0) REP(j, W) cout << out[i][j] << " ";
        else            RREP(j, W) cout << out[i][j] << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <array>
#include <map>
#include <cmath>
#include <random>
#include <numeric>
#include <vector>
#include <string>
#include <set>

typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()

using namespace std;
ll gcd(ll a, ll b){
  ll c;
  if(a<b){
    c=a;a=b;b=c;
  }
  while(b!=0){
    c=a%b;a=b;b=c;
  }
  return a;
}

ll lcm(ll a,ll b){
  ll c;
  c=a*b/gcd(a,b);
  return c;
}
int main() {
  int a,b;
  cin>>a>>b;
  if(a<9&&b<9)cout<<"Yay!";
  else cout<<":(";
}

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

int partition(int *A, char *C, int p, int r) {
    int x = A[r];
    int i = p;

    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            std::swap(A[i], A[j]);
            std::swap(C[i], C[j]);
            i++;
        }
    }
    std::swap(A[i], A[r]);
    std::swap(C[i], C[r]);
    return i;
}

void quickSort(int *A, char *C, int p, int r) {
    if (p < r) {
        int q = partition(A, C, p, r);
        quickSort(A, C, p, q - 1);
        quickSort(A, C, q + 1, r);
    }
}


bool checkStable(int *A, char *C, int * At, char *Ct, int n) {
    for (int i = 0; i < n - 1; i++) {
        if (A[i] == A[i + 1]) {
            for (int j = 0; j < n; j++) {
                if (C[i] == Ct[j] && A[i] == At[j]) {
                    break;
                } else if (C[i + 1] == Ct[j] && A[i + 1] == At[j]){
                    return false;
                }
            }
        }
    }
    return true;
}


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

    char C[n], Ct[n];
    int A[n], At[n];
    for (int i = 0; i < n; i++) {
        std::cin >> C[i] >> A[i];
    }

    std::memcpy(Ct, C, sizeof(char) * n);
    std::memcpy(At, A, sizeof(int) * n);

    quickSort(A, C, 0, n - 1);

    if (checkStable(A, C, At, Ct, n)) {
        std::cout << "Stable" <<std::endl;
    } else {
        std::cout << "Not stable" << std::endl;
    }
    
    for (int i = 0; i < n; i++) {
        std::cout << C[i] << " " << A[i] << std::endl;
    }
}



Measured memory_bytes: 3980
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int r,c,i=0,j=0,d=0;
		int sum=0;

		r = sc.nextInt();
		c = sc.nextInt();
		int table[][] = new int[r+1][c+1];

		for(i=0;i<r;i++){
			sum = 0;
			for(j=0;j<c;j++){
				table[i][j] = sc.nextInt();
				sum += table[i][j];
			}
			table[i][j] = sum;
			d += sum;
		}
		for(i=0;i<c;i++){
			sum = 0;
			for(j=0;j<r;j++){
				sum += table[j][i];
			}
			table[j][i] = sum;
		}
		table[j][i] = d;
		for(i=0;i<=r;i++){
			for(j=0;j<=c;j++){
				System.out.print(table[i][j]);
				if(c == j){
					break;
				}
				System.out.print(" ");
				
			}
			
			if(i<=r){
				System.out.println();
			}
			
			sc.close();
		}
	}

}


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

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull dint;

int main(void){
	init(string, s);

	bool ans = true;
	string bad = "LR";
	loop(i, 0, s.size()){
		if (s[i] == bad[i % 2]){
			ans = false;
			break;
		}
	}

	outl(ans ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
ll power(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res = (res*a)%MOD;

        a = (a*a)%MOD;

        b >>= 1;
    }
    return res;
}
int main()
{
    ll n;
    cin >> n;
    ll ans = power(10LL,n);
    ans  = (ans%MOD + power(8LL,n))%MOD;
    ans = (ans - (2LL * power(9LL,n)%MOD)%MOD + MOD)%MOD;
    if(ans < 0)ans += MOD;
    cout << ans << endl;

}


Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

#define MAX_DEPTH 20
#define MAX_NUM 1000000

using namespace std;

typedef struct {
  int node_number;
  int size;
  int *children;
} vertex;

int n;

int getDepth(int list[],int key,int def){

  int depth = def;

  if(list[key] != -1){
    depth = getDepth(list,list[key],depth+1);
  }
  return depth;
}

void printChildren(vertex v){

  int i;

  cout << "[";

    for(i = 0;i < v.size-1;i++){
      cout << v.children[i] << ", ";
    }
    cout << v.children[i] << "]";
}

int main(){

  int i;
  int j;
  int size;
  int num;
  int parent;
  int *parent_list;
  vertex *A;

  scanf("%d",&n);

  A = (vertex *)malloc(sizeof(vertex)*n);
  parent_list = (int *)malloc(sizeof(int)*MAX_NUM);

  for(i = 0;i < MAX_NUM;i++){
    parent_list[i] = -1;
  }

  for(i = 0;i < n;i++){
    scanf("%d",&num);
    scanf("%d",&size);
    A[num].node_number = num;
    A[num].size = size;
    A[num].children = (int *)malloc(sizeof(int)*size);
    for(j = 0;j < A[num].size;j++){
      scanf("%d",&A[num].children[j]);
      parent_list[A[num].children[j]] = A[num].node_number;
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: ",A[i].node_number);
    printf("parent = %d, ",parent_list[A[i].node_number]);
    printf("depth = %d, ",getDepth(parent_list,A[i].node_number,0));
    if(parent_list[A[i].node_number] == -1){
      printf("root, ");
    }
    else if(A[i].size == 0){
      printf("leaf, ");
    }
    else {
      printf("internal node, ");
    }
    printf("[");
    for(j = 0;j < A[i].size;j++){
      if(j == A[i].size-1){
	printf("%d",A[i].children[j]);
      }
      else{
	printf("%d, ",A[i].children[j]);
      }
    }
    printf("]\n");
  }

  return 0;

}

  //　　(　゜д゜)
  //＿(__つ/‾‾‾/＿
  //　　＼/　　　　/
  //
  //　　( ゜д゜ )
  //＿(__つ/‾‾‾/＿
  //　　＼/　　　　/

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

#define MAX 100000
#define ll long long

ll arr[MAX+5];
int n;
ll dp[MAX+5];

void initialize()
{
    for(int i=0;i<=MAX+5;i++) dp[i] = -1;
}

ll frog(int pos)
{
    if(pos<=1) return 0;
    if(pos==2) return abs(arr[2]- arr[1]);

    if(dp[pos]!=-1) return dp[pos];

    ll p1 = frog(pos-1)+abs(arr[pos] - arr[pos-1]);
    ll p2 = frog(pos-2)+abs(arr[pos] - arr[pos-2]);

    dp[pos] = min(p1, p2);

    return min(p1, p2);
}

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

    ll cost = frog(n);

    cout<<cost<<endl;
    return 0;
}


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

using namespace std;

int main(void) {
  string vowel = "aeiou";
  char c; cin >> c;

  for (auto it = vowel.begin(); it != vowel.end(); it++) {
    if (*it == c) {
      cout << "vowel" << endl;
      return 0;
    }
  }

  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15

int main() {
	int n, k;
	cin >> n >> k;
	int res = 1;
	for(int i = 0; i < n; i++){
		if(res * 2 < res + k)
			res *= 2;
		else
			res += k;
	}
	cout << res << endl;
	return 0;
}





Measured memory_bytes: 256