akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
int n;
long double ans[305][305][305];
long double solve(int a,int b,int c){
    long double currans=0;
    if(a<0 || b<0 || c<0){
        return 0;
    }
    if(ans[a][b][c]!=-1){
        return ans[a][b][c];
    }
    long double A=a,B=b,C=c;
    currans=(A/n * solve(a-1,b,c)) + (B/n * solve(a+1,b-1,c)) +(C/n * solve(a,b+1,c-1)) + 1;
    currans*=n;
    currans/=a+b+c;
    ans[a][b][c]=currans;
    return ans[a][b][c];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n;
    int count[3];
	count[0]=0;
	count[1]=0;
	count[2]=0;
	for(int i=0;i<n;i++){
	    int a;
	    cin>>a;
	    count[--a]++;
	}
	for(int i=0;i<=n;i++){
	    for(int j=0;j<=n;j++){
	        for(int k=0;k<=n;k++){
	            ans[i][j][k]=-1;
	        }
	    }
	}
	ans[0][0][0]=0;
	cout<<fixed << setprecision(18)<<solve(count[0],count[1],count[2]);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll Q;
    cin >> Q;

    //　降順のキュー
    priority_queue<ll> max_que;

    // 昇順のキュー
    priority_queue<
      ll,                // 要素の型はint
      vector<ll>,   // 内部コンテナはstd::vector (デフォルトのまま)
      greater<ll>   // 昇順 (デフォルトはstd::less<T>)
    > min_que;


    ll ans = 0;

    ll left;
    ll right;

    REP(i, Q){
        ll query;
        cin >> query;
        if(query == 1){
            ll a, b;
            cin >> a >> b;

            ans += b;

            // 最初に何もないとき
            if(max_que.empty()){
                max_que.push(a);
                left = a;
                continue;
            }
            
            // 同じが左側のほうが数が少ないとき
            if(max_que.size() <= min_que.size()){
                max_que.push(a);
                
                // 左右のキューで大小が異なるとき
                if(max_que.top() > min_que.top()){
                    ll tempa = max_que.top();
                    max_que.pop();
                    ll tempb = min_que.top();
                    min_que.pop();

                    // キューの最小と最大を入れ替え
                    max_que.push(tempb);
                    min_que.push(tempa);
                }

                if(a < left) ans += left - a;
                if(a > right) ans += a - right;
                
                left = max_que.top();
                right = min_que.top();
                continue;
            }

            // 右側側のほうが数が少ないとき
            if(max_que.size() > min_que.size()){
                min_que.push(a);
                
                // 左右のキューで大小が異なるとき
                if(max_que.top() > min_que.top()){
                    ll tempa = max_que.top();
                    max_que.pop();
                    ll tempb = min_que.top();
                    min_que.pop();

                    // キューの最小と最大を入れ替え
                    max_que.push(tempb);
                    min_que.push(tempa);
                }

                ans += abs(left - a);
                
                left = max_que.top();
                right = min_que.top();
                continue;
            }

        }
        else{
            cout << left << " " << ans << endl;
        }
    }
    return 0;
}

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

int main(){
	int d;
	cin >> d;
	string res;
	if(d==25){
		res = "Christmas";
	}else if(d==24){
		res = "Christmas Eve";
	}else if(d==23){
		res = "Christmas Eve Eve";
	}else res = "Christmas Eve Eve Eve";
	cout << res << endl;
	return 0;
}



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

long long N, K;

vector<long long> A;


bool f(long long x) {

  // x未満を作ることができるペアの数を数える
  long long count = 0;
  for (int i = 0; i < N; i++) {

    if (0 <= A[i]) {

      // 全部 OK なら N - 1 個となる
      // 正の場合は、l が OK、r がダメ側
      int l = -1;
      int r = N;

      // border の範囲を二分探索で狭めていく
      while (l + 1 < r) {
        int border = (l + r) / 2;
        // 自分自身と自分自身のペアや、重複するペアも見る
        // x未満だったら、lをずらす
        // x未満じゃなかったら、rをずらす
        if (A[border] * A[i] < x) {
          l = border;
        } else {
          r = border;
        }
      }

      // 正の場合は境界より左側
      count += r;

    } else {

      // 負の場合は、l がダメ側、r が OK
      int l = -1;
      int r = N;

      // border の範囲を二分探索で狭めていく
      while (l + 1 < r) {
        int border = (l + r) / 2;
        // 自分自身と自分自身のペアや、重複するペアも見る
        // x未満だったら、rをずらす
        // x未満じゃなかったら、lをずらす
        if (A[border] * A[i] < x) {
          r = border;
        } else {
          l = border;
        }
      }

      // 負の場合は境界より右側
      count += N - r;

    }

    // 自分自身と自分自身のペアを引く
    if (A[i] * A[i] < x) {
      count--;
    }

  }

  // 半分は重複しているペアなので半分にする
  count /= 2;
  
  return count < K;
}

int main() {

  // 無限
  long long INF = (long long) (1e18)+1;

  cin >> N >> K;

  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());

  // 左端
  long long l = - INF;

  // 右端
  long long r = INF;

  // xの範囲を二分探索で狭めていく
  while (l + 1 < r) {

    // 左端と右端の中央
    long long x = (l + r) / 2;

    // x未満を作ることができるペアがk個未満か否か
    bool flg = f(x);

    // x未満を作ることができる場合は、lをずらす
    // x未満を作ることができない場合は、rをずらす
    if (flg) {
      l = x;
    } else {
      r = x;
    }

  }

  cout << l << endl;

  return 0;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long li;

const int inf = ~0U >> 1;
const int maxn = 100000;

int n, a[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  int ans = 0;
  for (int i = 0; i < n; ) {
    int j = i;
    while (j < n && a[i] == a[j]) ++j;
    ans += (j - i) / 2;
    i = j;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
fun main(arg: Array<String>) {
    while(true) {
        val (h, w) = readLine()!!.split(" ").map(String::toInt)
        if (h == 0 && w == 0) break
        for (i in 1..h) {
            for (j in 1..w) {
                if ((i + j) % 2 == 0) print("#")
                else print(".")
            }
            println("")
        }
        println("")
    }
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  cout << (n-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

diff_x = x2 - x1
diff_y = y2 - y1

x4 = x1 - diff_y
y4 = y1 + diff_x

x3 = x2 - diff_y
y3 = y2 + diff_x

print("{} {} {} {}".format(x3, y3, x4, y4))

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


int N;
int weight[100010];
int belong[100010];
list<int> has[100010];
int merge(int a,int b,int w){
	if( has[a].size() < has[b].size() ){
		swap(a,b);
		w *= -1;
	}
	int A = belong[a];
	int B = belong[b];
	int diff = w + weight[a] - weight[b];
	for( auto i : has[B] ){
		weight[i] += diff;
		belong[i] = A;
		has[A].push_back(i);
	}
	has[B].clear();
}
int main(){
	int N,Q;
	cin >> N >> Q;
	for(int i = 0 ; i < N ; i++) belong[i] = i, has[i].push_back(i);
	while(Q--){
		string in;
		cin >> in;
		int a,b,c;
		if( in == "COMPARE" ){
			cin >> a >> b;
			--a,--b;
			if( belong[a] == belong[b] ){
				cout << weight[b] - weight[a] << endl;
			}else{
				cout << "WARNING" << endl;
			}
		}else{
			cin >> a >> b >> c;
			--a,--b;
			if( belong[a] != belong[b] ){
				merge(a,b,c);
			}
			weight[a] += c;
			weight[b] += c;

		}
	}
}

Measured memory_bytes: 6712
//-----------------------
// author : xyqkoala
// time : 2020-07-12
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;
	cin>>n;
	vector<int> dp(n+1,0);

	int tn = sqrt(n);
	for(int i=1;i<=tn;i++){
		for(int j=1;j<=tn;j++){
			for(int k=1;k<=tn;k++){
				int temp = i*i+j*j+k*k+i*j+i*k+j*k;
				if( temp<=n){
					dp[temp]++;
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<dp[i]<<endl;
	}
}


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    string s;
    cin >> a >> b >> s;
    rep(i, s.size()) {
        if(i == a) {
            if(s[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        }
        else if(s[i] < '0' || s[i] > '9') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef long double ld;
typedef tuple<ld, ld, char> TPoint;
const int N = int(1e5) + 2;
const int nTest = 300;

TPoint p[N];
int _x, _y, n;
char d;
ld x, y;

ld f(ld step) {
    ld xmax = -1e18, xmin = 1e18, ymax = -1e18, ymin = 1e18;
    for(int i = 1; i <= n; ++i) {
        tie(x, y, d) = p[i];
        if(d == 'U') y += step;
        else if(d == 'D') y -= step;
        else if(d == 'L') x -= step;
        else x += step;
        xmax = max(xmax, x), xmin = min(xmin, x);
        ymax = max(ymax, y), ymin = min(ymin, y);
    }
    return (xmax - xmin) * (ymax - ymin);
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> _x >> _y >> d;
        p[i] = make_tuple(_x, _y, d);
    }
    ld lef = 0, rig = 2e12, res = 1e18;
    for(int i = 0; i < nTest; ++i) {
        ld x1 = lef + (rig - lef) / 3.0;
        ld x2 = rig - (rig - lef) / 3.0;
        if(f(x1) > f(x2)) lef = x1;
        else rig = x2;
    }
    cout << fixed << setprecision(10) << f(rig);
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int r, c;
int main() {
	while (true) {
		cin >> r >> c;
		if (r == 0 && c == 0) { break; }
		if (r % 2 == 1 && c % 2 == 1) { cout << "no" << endl; }
		else { cout << "yes" << endl; }
	}
	return 0;
}

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

int main(){
  int N, K, D=0, d;
  cin >> N >> K;
  for (int i=0; i<N; i++){
    cin >> d;
    if (d <= K-d){
      D += d;
    } else{
      D += K-d;
    }
  }
  cout << D*2 <<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N,D;
    cin >>N>>D;
    vector<vector<double>> X(N,vector<double>(D));
    for(int i = 0;i < N;i++){
        for(int j = 0;j < D;j++){
            cin >> X[i][j];
        }
    }
    int ans = 0;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(i != j){
                int sum = 0;
                for(int k = 0;k < D;k++){
                    sum += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
                }
                double A = pow(sum,0.5);
                int A1 = A;
                if(A1== A)ans++;
            }
        }
    }
    cout << ans/2 << endl;
}   

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var aList = nextIntArray();
  var bList = nextIntArray();
  var aSum = 0;
  var bSum = 0;
  var count = 0;//a > bの箇所を埋める
  for(var i = 0; i < N; i++){
    if(aList[i] < bList[i]){
       //偶奇が不一致なら、countに足す数値は1少ない
       count += Math.floor((bList[i] - aList[i]) / 2);
    }
  }
  for(var i = 0; i < N; i++){
    if(aList[i] > bList[i]){
       count -= aList[i] - bList[i];
    }
  }
  if(count >= 0){
     myout("Yes");
  }else{
     myout("No");
  }
}

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

int main() {
  int n,ans=0,k,x;
  cin >> n >>k;
  for (int i = 0; i < n; i++)
  {
      cin>>x;
      ans+=min(x,k-x);
  }
  cout<<2*ans<<endl; 
}


Measured memory_bytes: 256
var
  i,j,n,a:integer;
begin
  read(n);
  i:=0;
  for j:=1 to n do
  begin
    read(a);
    if a mod 2 = 1 then i:=i+1;
  end;
  if i mod 2 = 0 then writeln('YES') else  writeln('NO');
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


struct point{
  ll x;
  ll y;
};

int main(){
  int N,K; cin>>N>>K;
  point p[N];
  ll cand_x[N];
  ll cand_y[N];
  REP(i,N){
    cin>>cand_x[i]>>cand_y[i];
    p[i] = {cand_x[i],cand_y[i]};
  }
  sort(cand_x,cand_x+N);
  sort(cand_y,cand_y+N);
  
  ll ans = (cand_x[N-1]-cand_x[0])*(cand_y[N-1]-cand_y[0]);
  for(int xj=1; xj<N; ++xj){
    for(int xi=0; xi<xj; ++xi){
      for(int yj=1; yj<N; ++yj){
        for(int yi=0; yi<yj; ++yi){
          ll hidari = cand_x[xi];
          ll migi = cand_x[xj];
          ll sita = cand_y[yi];
          ll ue = cand_y[yj];
          
          int count = 0;
          REP(i,N){
            if( p[i].x>=hidari && p[i].x<=migi && p[i].y>=sita && p[i].y<=ue ){ ++count; }
          }
          if(count>=K){ ans = min(ans, (migi-hidari)*(ue-sita) ); }
        }
      }
    }
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: u64, b: u64) -> u64 {
    if a == 0 { b }
    else { gcd(b % a, a) }
}

fn main() {
    input!{
        N: usize,
        M: usize,
        A: [usize; M],
    }
    let e = 1_000_000_007;
    let mut oks = vec![true; N+1];
    for i in 0..M {
        oks[A[i]] = false;
    }
    let mut dp = vec![0; N+1];
    dp[0] = 1;
    for n in 0..N {
        let st = n+1;
        let ed = std::cmp::min(N, n+2)+1;
        for next in st..ed {
            if oks[next] {
                dp[next] += dp[n];
                dp[next] %= e;
            }
        }
    }

    println!("{}", dp[N]);
}



Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = (A+B)/2;
		if(Math.Abs(A-C)==Math.Abs(B-C)){
			Console.WriteLine(C);
		} else {
			Console.WriteLine("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
long long int  gcd(long long int  a, long long int b)
{
    if(a%b==0)
    {
        return b; 
    }
    return gcd(b,a%b);
}
int main()
{
   long long int n,sum=0,a,b,c,d;
    scanf("%lld",&n);
    for (a = 1; a <= n; a++)
    {
         for ( b = 1; b <=n; b++)
         {
             for ( c = 1; c <=n; c++)
             {
                   d=gcd(a,b);
                   d=gcd(d,c);
                   sum+=d;
             }
         }
    }
      printf("%lld\n",sum);  
    
}

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

int main(){
  ll n,r;
  cin >> n >> r;
  if(n>=10) cout << r << endl;
  else cout << r+100*(10-n) << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node_struct{int p,l,r;};
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);

  if(T[u].p == -1) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0,c = T[u].l;c != NIL;i++,c = T[c].r)
    {
      if(i)printf(", ");
      printf("%d",c);
    }
  printf("]\n");
}

void calcDepth(int u,int p){
  D[u] = p;
  if(T[u].l != NIL)calcDepth(T[u].l,p+1);
  if(T[u].r != NIL)calcDepth(T[u].r,p);
}

int main(){
  int i,j,k;
  int n;
  int id,sib,child;
  int root = NIL;
  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      T[i].p = T[i].l = T[i].r = NIL;
    }

  for(i = 0;i < n;i++)
    {
      scanf("%d %d",&id,&k);
      for(j = 0,sib = NIL;j < k;j++)
	{
	  scanf("%d",&child);
	  T[child].p = id;
	  if(j == 0) T[id].l = child;
	  else T[sib].r = child;
	  sib = child;
	}
    }

  for(i = 0;i < n;i++)
    {
      if(T[i].p == -1) root = i;
    }

  calcDepth(root,0);

  for(i = 0;i < n;i++) print(i);

  return 0;
}



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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] hp = new int[n][];
        for(int i=0;i<n;i++) hp[i]=new int[]{sc.nextInt(),sc.nextInt()};
        Arrays.sort(hp,new myC());
        long inf = Long.MAX_VALUE/10;
        long[] dp = new long[n+1];
        Arrays.fill(dp,inf);
        dp[0]=0;
        for(int i=1;i<=n;i++){
            for(int j=i;j>=1;j--){
                if(dp[j-1]<=hp[i-1][0]) dp[j]=Math.min(dp[j],dp[j-1]+hp[i-1][1]);
            }
        }
        int ans = 0;
        for(int i=1;i<=n;i++){
            if(dp[i]<inf) ans = Math.max(ans,i);
        }
        System.out.println(ans);
    }
    static class myC implements Comparator<int[]>{
        public int compare(int[] a, int[] b){
            if(a[0]+a[1]-b[0]-b[1]!=0) return a[0]+a[1]-b[0]-b[1];
            else return a[0]-b[0];
        }
    }
}


Measured memory_bytes: 35104
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int i=0,n,dp[45]={0};
	cin>>n;
	dp[0]=1;
	dp[1]=1;
	while(dp[n]<=0)
	{
		dp[i+2]=dp[i]+dp[i+1];
		i++;
	}
	cout<<dp[n]<<endl;	
	return 0;
}

Measured memory_bytes: 3088
#heapは1オリジンであり、index0にはダミーが入っているところに注意


def max_heapify(heap,i):#heapのi番目の要素とその子供について,heap条件を整える
    l=2*i
    r=2*i+1
    largest=i

    if(l < len(heap) and heap[i] < heap[l]):
        largest=l
    if(r < len(heap) and heap[largest] < heap[r]):
        largest=r
    if(i!=largest):
        heap[i],heap[largest]=heap[largest],heap[i]
        max_heapify(heap,largest)






n=int(input())
heap=list(map(int,input().split()))
heap.insert(0,-1)

for i in range(n//2 +1):
    max_heapify(heap,n//2 +1 -i)

for i in range(1,n+1):
    print(f" {heap[i]}",end="")
print()


Measured memory_bytes: 63712
#include<bits/stdc++.h>
#define mod 1000000007L
using namespace std;

int main()
{
  int h, w;
  scanf("%d%d", &h, &w);
  char c[h][w];
  for(int i = 0; i < h; i++)
  {
    scanf("%s", c[i]);
  }
  long long dp[h + 1][w + 1];
  memset(dp, 0, sizeof dp);
  dp[1][1] = 1;
  for(int row = 1; row <= h; row++)
  {
    for(int col = 1; col <= w; col++)
    {
      if(c[row - 1][col - 1] == '#')
        dp[row][col] = 0;
      else
        dp[row][col] += dp[row - 1][col] + dp[row][col - 1];
      dp[row][col] %= mod;  
    }
  }
  printf("%lld", dp[h][w]);
  
  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;++i) cin >> a[i];
  int ans=0;
  for(int i=0;i<n;++i) {
    ans+=a[i]-1;
  }
  cout << ans;
}


Measured memory_bytes: 256
S = input()
while len(S) > 0:
    if S[-5:] == "dream" or S[-5:] == "erase":
        S = S[:-5]
    elif S[-6:] == "eraser":
        S = S[:-6]
    elif S[-7:] == "dreamer":
        S = S[:-7]
    else:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

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

using namespace std;

static const int N=100;

int main(){
  int n,i,l,j,k,p[N+1],m[N+1][N+1];
  cin>>n;

  for(i=1;i<=n;i++){
    cin>>p[i-1]>>p[i];
  }

  for(i=1;i<=n;i++){
           m[i][i]=0;
  }
  for(l=2;l<=n;l++){
      for(i=1;i<=n-l+1;i++){
          j=i+l-1;
          m[i][j]=(1<<21);
          for(k=i;k<=j-1;k++){
             m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
          }
      }
   }

      cout<<m[1][n]<<endl;
      return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	sort(a.begin(), a.end());
	int ANS = 0;
	vector<int> c;
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			c.push_back(2);
		} else {
			c.push_back(-2);
		}
	}
	c.front() /= 2;
	c.back() /= 2;
	{
		vector<int> vc = c;
		sort(vc.begin(), vc.end());
		int s = 0;
		for (int i = 0; i < n; i++) {
			s += a[i] * vc[i]; 
		}
		ANS = max(ANS, s);
	}
	for (auto &x : c) {
		x *= -1;
	}
	{
		vector<int> vc = c;
		sort(vc.begin(), vc.end());
		int s = 0;
		for (int i = 0; i < n; i++) {
			s += a[i] * vc[i]; 
		}
		ANS = max(ANS, s);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> s(H,vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }
    
    for(int i = 1; i < H - 1; i++){
        for(int j = 1; j < W - 1; j++){
            if(s[i][j] == '#' && s[i][j] != s[i][j+1] && s[i][j] != s[i][j-1] &&  s[i][j] != s[i+1][j] && s[i][j] != s[i-1][j]){
                    cout << "No" << endl;
                    return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var N = input[0];
            var K = input[1];
            var ans = "";
            while (true)
            {
                ans = N % K + ans;
                N /= K;
                if (N == 0) break;
            }

            Console.WriteLine(ans.Count());
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n-1;i++){
        if((a[i]>a[i+1]&&a[i]<a[i-1])||(a[i]<a[i+1]&&a[i]>a[i-1])){
            ans++;
        }
    }
    cout << ans<<endl;
    return 0;
}




Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))
# n, k = map(int, input().split())
ans = []
for i in range(n+100):
    total = 0
    for j in range(n):
        diff = ((i+1)-X[j])**2
        total += diff
    ans.append(total)
print(min(ans))


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func dp(in string) string {
	dp := make([]int, len(in)+1)
	dp[0] = 1
	for i := 0; i < len(in); i++ {
		if dp[i] == 0 {
			continue
		}
		if i+5 <= len(in) && in[i:i+5] == "dream" {
			dp[i+5] = 1
		}
		if i+7 <= len(in) && in[i:i+7] == "dreamer" {
			dp[i+7] = 1
		}
		if i+5 <= len(in) && in[i:i+5] == "erase" {
			dp[i+5] = 1
		}
		if i+6 <= len(in) && in[i:i+6] == "eraser" {
			dp[i+6] = 1
		}
	}
	if dp[len(in)] == 1 {
		return "YES"
	} else {
		return "NO"
	}
}

func main() {
	var in string
	fmt.Scan(&in)
	fmt.Println(dp(in))
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
using P = pair <int,int>; //to, cost
using WeightedGraph = vector<vector <P>>; //to cost
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int x,a,b; cin>>x>>a>>b;
    bool safe, yammy;
    if(a >= b) yammy = true;
    else yammy = false;
    if((b-a)>x) safe = false; else safe = true;
    if(yammy && safe) cout<<"delicious"<<endl;
    else if(safe) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
# 上からx問目を選ぶことができるか二分探索
# x <= Pであれば必ず選べる
# A_x + M < A_Pであれば必ず選べない
# それ以外の場合
# A_xには必ず投票するのでA_x + Mが基準点
# A_xがP位である必要がある
# 上位P - 1位までにはM票投票して良い
# P + 1位以下に対しては、A_x + Mまでは投票して良い
# この投票して良い数がM * Vを上回ればOK

import sys
readline = sys.stdin.readline

N,M,V,P = map(int,readline().split())
A = sorted(list(map(int,readline().split())),reverse = True)

# 最初の時点で上位P位の点数を求めておく
border = A[P - 1]

# 大きい順に並べる

ok = -1
ng = N

def isOk(x):
  # 上からx番目を選ぶことが出来るか
#  print("x",x,"A[x]",A[x])
  if (x + 1) <= P:
    return True
  if A[x] + M < border:
    return False
  # 基準点
  base = A[x] + M
#  print("base",base,"点を取って合格したい")
  
  # 上位P - 1には必ず投票して良い
  vote = (P - 1) * M
#  print("まず",vote,"票を投票")
  # P位以下には、baseを超えないように投票して良い
  for i in range(P - 1,len(A)):
    limit = max(base - A[i], 0)
    can = min(limit, M)
#    print(A[i],"にはcan",can,"票投票できる")
    vote += can
#  print("vote",vote)
  if vote >= M * V:
    return True
  return False

while abs(ok - ng) > 1:
  mid = abs(ok + ng)//2
  if isOk(mid):
#    print(mid,"is ok")
    ok = mid
  else:
#    print(mid,"is ng")
    ng = mid
    
print(ok + 1)

Measured memory_bytes: 15028
function main(input) {
  const nums = input.split(" ").map(n => Number(n));
  const index = nums.indexOf(Math.max(...nums));
  let result = nums.splice(index, 1)[0] * 10;
  result += nums.pop();
  result += nums.pop();
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
#define int long long
#define mod 1000000007

#define mxn 25
int fact[mxn];
int inv[mxn];
int mul(int a, int b)
{
    return a*b%mod;
}
int mypower(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b%2)
            ans = mul(ans, a);
        b=b/2;
        a=mul(a,a);
    }
    return ans;
}
void pre()
{
    fact[0] = 1;
    int i;
    for(i=1;i<mxn;i++)
        fact[i] = mul(fact[i-1], i);
    inv[mxn-1] = mypower(fact[mxn-1], mod-2);    
    for(i=mxn-2;i>=0;i--)
        inv[i] = mul(inv[i+1], i+1);
}
int nCr(int n, int r)
{
    if(n < 0 || r < 0 || n < r)
        return 0;
    return mul(fact[n], mul(inv[r], inv[n-r]));    
}

signed main() {
    pre();
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        if(n <= 4)
            cout << 0 << '\n';
        else
        {
            n = n - 5;
            int j, r, i;
            int ans = 0;
            for(j=0;j<=11;j++)
            {
                int r = n - j;
                if(r < 0 || r%2 != 0)
                    continue;
                r=r/2;
                // Multiply C(11, j) and (15+r, 15)
                int val = 1;
                for(i=1;i<=15;i++)
                    val = mul(val, (r+i));
                val = mul(val, inv[15]);
                val = mul(val, nCr(11, j));
                ans = (ans+val)%mod;
            }
            cout << (ans+mod)%mod << '\n';
        }
    }
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  long long k;
  cin >> k;
  if (k & 1) {
    if (k % 7 == 0) {
      k /= 7;
    } 
    k *= 9;
    long long m = 1;
    for (int i = 1; i <= 1e6; i++) {
      m = (m * 10) % k;
      if (m == 1) {
        cout << i << '\n'; return;
      }
    }
    cout << -1 << '\n';
  } else {
    cout << -1 << '\n';
  }
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  if(a == b && b != c) ans = c;
  if(a != b && a == c) ans = b;
  if(a != b && b == c) ans = a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

void solve(ll n, ll x) {
    ll ans = 0;
    reps(i, 1, n + 1) {
        reps(j, i + 1, n + 1) {
            reps(k, j + 1, n + 1) {
                if ((i + j + k) == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    while(true) {
        ll n, x;
        cin >> n >> x;
        if ((n == 0) && (x == 0)) break;
        solve(n, x);
    }
    return 0;
}



Measured memory_bytes: 3132
k, a, b = map(int, input().split())

if a>=(b-1) :
    print (k + 1)
    exit()

if k < (a-1) :
    print (k+1) 
    exit()

c = a
k = k - (a-1)
money = 0

n = k // 2
cc = c + (b-a) * n
if (k % 2) == 1 :
    cc += 1

print (cc)

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

int main(){
  int n;
  cin>>n;
  ll a[100005];
  rep(i,n) cin>>a[i];
  ll sum=0;
  ll a1=0,a2=0;
  rep(i,n){
    sum+=a[i];
    if(i&1){
      if(sum>=0){
	a1+=sum+1;
	sum=-1;
      }
    }
    else{
      if(sum<=0){
	a1+=1-sum;
	sum=1;
      }
    }
  }
  sum=0;
  rep(i,n){
    sum+=a[i];
    if(!(i&1)){
      if(sum>=0){
	a2+=sum+1;
	sum=-1;
      }
    }
    else{
      if(sum<=0){
	a2+=1-sum;
	sum=1;
      }
    }
  }
  cout<<min(a1,a2)<<endl;
  return 0;
}

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

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	int a[100][100], b[100][100];
	long c[100][100] = {};

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++)
			cin >> b[i][j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
			cout << c[i][j] ;
			if(j != l-1)
			cout << " " ;
		}
		cout << endl;
	}
	return 0;

}

Measured memory_bytes: 1324
import java.io.PrintWriter

fun main(args: Array<String>) {
    val pw = PrintWriter(System.out)

    val (n, q) = readLine()!!.split(' ').map { it.toInt() }

    val u = IntArray(n - 1)
    val v = IntArray(n - 1)
    val cnt = IntArray(n)
    repeat(n - 1) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() - 1 }
        u[it] = a
        v[it] = b
        cnt[a]++
        cnt[b]++
    }

    val graph = Array(n) { IntArray(0) }
    repeat(n) {
        graph[it] = IntArray(cnt[it])
    }
    repeat(n - 1) {
        val a = u[it]
        val b = v[it]
        graph[a][--cnt[a]] = b
        graph[b][--cnt[b]] = a
    }

    val counters = IntArray (n) { 0 }
    repeat(q) {
        val (p, x) = readLine()!!.split(' ').map { it.toInt() }
        counters[p - 1] += x
    }

    val ans = IntArray (n) { 0 }
    val visited = BooleanArray (n) { false }
    visited[0] = true

    fun dfs(v: Int, counter: Int) {
        visited[v] = true
        ans[v] = counter + counters[v]
        graph[v].forEach {
            if (visited[it]) {
                return@forEach
            }
            dfs(it, ans[v])
        }
    }

    dfs(0, 0)

    pw.print(ans[0])
    for (i in (1 until ans.size)) {
        pw.print(" ${ans[i]}")
    }
    pw.println()
    pw.flush()
}


Measured memory_bytes: 130456
stdin = []
for x in range(6):
    stdin.append(int(input()))
a,b,c,d,e,k = (x for x in stdin)
ans = "Yay!"

for x in range(len(stdin)- 1):
    if x != len(stdin) - 2:
        for y in range(x+1,len(stdin)-1):
            if abs(stdin[x]-stdin[y]) > k:
                ans = ":("
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long A, B;
  cin >> A >> B;
  cout << max({A + B, A - B, A * B}) << '\n';
  return 0;
}


Measured memory_bytes: 3656
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	
    	String plain = sc.nextLine();
    	int q = sc.nextInt();
    	int argA, argB;
    	String argC;
    	String print;
    	String tmp = "";
    	ArrayList<String> prtList = new ArrayList<>();
    	int cnt = 0;
    	for(int i = 0; i < q; i++) {
    		String cmd = sc.next();
    		if(cmd.equals("print")) {
    			argA = sc.nextInt();
    			argB = sc.nextInt();
    			print = plain.substring(argA, argB + 1);
    			prtList.add(print);
    			cnt++;
    		} else if(cmd.equals("reverse")) {
    			argA = sc.nextInt();
    			argB = sc.nextInt();
    			tmp = plain.substring(argA, argB + 1);
    			StringBuffer sb = new StringBuffer(tmp);
    			tmp = sb.reverse().toString();
    			plain = plain.substring(0, argA) + tmp + plain.substring(argB + 1);
    		} else if(cmd.equals("replace")) {
    			argA = sc.nextInt();
    			argB = sc.nextInt();
    			argC = sc.next();
    			plain = plain.substring(0, argA) + argC + plain.substring(argB + 1);
    		}
    	}
    	for(int i = 0; i < cnt; i++) {
    		System.out.println(prtList.get(i));
    	}
    }
}

Measured memory_bytes: 29652
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<pi,lli>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e6 + 5;

int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		lli n;
		cin >> n;
		lli a[n];
		lli sum = 0;
		for(int i=0;i<n;i++)
		{
			cin >> a[i];
			sum = sum ^ a[i];
		}
		for(int i=0;i<n;i++)
		{
			cout << (sum^a[i]) << " ";
		}

	}	
	return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll h,a; cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

string a, b, c;
signed main(){
  int n, ans = 0;
  cin >> n >> a >> b >> c;
  rep(i,n){
    if(a[i] == b[i] and b[i] == c[i])continue;
    if(a[i] == b[i] or b[i] == c[i] or a[i] == c[i]){
      ans++;continue;
    }
    ans++;ans++;
  }
  printf("%lld\n", ans);
  return 0;
}






Measured memory_bytes: 256
n=int(input())
q=["?"]+[str(i) for i in range(1,n+1)]
print(*q)
color=input()
ans=[0]*(2*n+1)
left=1
right=n+1
while right-left>1:
    mid=(right+left)//2
    q=["?"]+[str(i) for i in range(mid,n+mid)]
    print(*q)
    b=input()
    if color==b:
        left=mid
    else:
        right=mid
ans[left]=color[0]
if color=="Red":
    zzz="Blue"
else:
    zzz="Red"
ans[left+n]=zzz[0]
k=left
q=["?"]+[str(i) for i in range(k+1,n+k)]+["0"]

for i in range(n+k+1,2*n+1):
    q[-1]=str(i)
    print(*q)
    b=input()
    ans[i]=b[0]
    
for i in range(1,k):
    q[-1]=str(i)
    print(*q)
    b=input()
    ans[i]=b[0]
    
q=["?"]+[str(i) for i in range(1,k)]+[str(i) for i in range(n+k+1,2*n+1)]+["0"]
for i in range(k+1,n+k):
    q[-1]=str(i)
    print(*q)
    b=input()
    ans[i]=b[0]
print("! "+"".join(ans[1:]))

Measured memory_bytes: 42432