akhauriyash/Code-Regression huggingface dataset:
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  building := make([][][]int, 4)
  for i := 0; i < 4; i++ {
    building[i] = make([][]int, 3)
  }

  for i := 0; i < 4; i++ {
    for j := 0; j < 3; j++ {
      building[i][j] = make([]int, 10)
    }
  }

  for i := 0; i < n; i++{
      b := nextInt() - 1
      s := nextInt() - 1
      r := nextInt() - 1
      n := nextInt()
      building[b][s][r] = building[b][s][r] + n
  }
  for b := 0; b < 4; b++ {
    for s := 0; s < 3; s++ {
      for r := 0; r < 10; r++ {
        fmt.Print(" ")
        fmt.Print(building[b][s][r])
      }
      fmt.Println()
    }
    if b != 3 {
      fmt.Println("####################")
    }
  }
}

func getStdin() (string) {
    sc.Scan()
    v := sc.Text()
    return v
}
func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 1176
n,q = gets.split.map &:to_i
s = gets.chomp
l = []
r = []

indexes = []

i = 0
while index = s.index("AC", i)
  indexes << index
  i = index + 1
end
reversed = indexes.reverse
size = indexes.size
q.times do |i|
  li,ri = gets.split.map{|s|s.to_i - 1}
  l = indexes.bsearch_index{|x|x >= li}
  if temp = reversed.bsearch_index{|x|x < ri}
    r = size - temp - 1
  else
    r = nil
  end
  if l && r
    puts [r-l+1, 0].max
  else
    puts 0
  end
end



Measured memory_bytes: 3452
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m
let ( /^ ) x y = power ( *^ ) x y (m - 2)

let () = Scanf.scanf "%d %s" @@ fun k s ->
  (* comb.(i) = (|S| - 1 + i)C(|S| - 1) *)
  let comb = Array.make (k + 1) 0 in
  comb.(0) <- 1;
  for i = 1 to k do
    comb.(i) <- (String.length s - 1 + i) *^ comb.(i - 1) /^ i
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) (power ( *^ ) 1 26 k) @@
  Array.init k @@ fun i ->
    power ( *^ ) (power ( *^ ) comb.(k - i) 25 (k - i)) 26 i


Measured memory_bytes: 22840
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }


const int MOD = 1000000007;


int dp[10005][100][2];  // [i-th digit where left-most is index 1][SUM % D up to i-th digit][1: num < K fullfilled, 0: otherwise] => count so far


int main()
{
    string K;
    int D;
    cin >> K >> D;

    dp[0][0][0] = 1;

    int len = K.length();
    for (int i = 1; i <= len; ++i) {
        int cd = (int) (K[i-1] - '0');
        rep(small, 2) rep(d, 10) {
            int nextSmall = small;
            if (!small && cd < d) continue;
            if (!small && d < cd) nextSmall = 1;
            // cout << "i = " << i << ", d = " << d << ", small = " << small << endl;
            rep(m, D) {
                if (dp[i-1][m][small] == 0) continue;
                int nextM = (m + d) % D;
                dp[i][nextM][nextSmall] = (dp[i][nextM][nextSmall] + dp[i-1][m][small]) % MOD;
                // cout << "dp[" << i << "][" << nextM << "][" << nextSmall << "] = " << dp[i][nextM][nextSmall] << endl;
            }
        }
    }

    // exclude 0
    int ans = (dp[len][0][0] + dp[len][0][1] - 1 + MOD) % MOD; 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int N = 1010;

char board[N][N];
int dist[N][N];

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

int h,w;

bool isSafe(int x, int y) {
  if(1 <= x && x <= h && 1 <= y && y <= w && board[x][y] == '.') {
    return true;
  } else {
    return false;
  }
}

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

  cin >> h >> w;
  int ch, cw, dh, dw;
  cin >> ch >> cw >> dh >> dw;

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> board[i][j];
    }
  }

  rep(i,N) rep(j,N) dist[i][j] = INF;

  using P = pair<int, pair<int,int>>;

  priority_queue<P, vector<P>, greater<P> > que;
  dist[ch][cw] = 0;
  que.push({0, {ch, cw}});

  while(!que.empty()) {
    P p = que.top();
    que.pop();

    int d = p.first;
    int curx = p.second.first;
    int cury = p.second.second;

    if(dist[curx][cury] < d) continue;

    for (int i = 0; i < 4; i++) {
      int nx = curx + dx[i];
      int ny = cury + dy[i];

      if(!isSafe(nx, ny)) continue;
      if(dist[nx][ny] <= d) continue;
      dist[nx][ny] = d;
      que.push({d, {nx,ny}});
    }

    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        int nx = curx + i;
        int ny = cury + j;

        if(!isSafe(nx, ny)) continue;
        if(dist[nx][ny] <= d + 1) continue;
        dist[nx][ny] = d + 1;
        que.push({d + 1, {nx,ny}});
      }
    }
  }

  int ans = dist[dh][dw];
  if(ans == INF) ans = -1;

  cout << ans << '\n';
}



Measured memory_bytes: 8576
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int d[5][1000];
int x,y;
int sx,sy,gx,gy;
char c;
int nx[5][1000],ny[5][1000],n[5];
int now,next;

int dis(int ay,int ax,int by,int bx){return abs(ay-by)+abs(ax-bx);}

int main(){
  while(scanf("%d %d",&x,&y) && (x||y)){
    for(int i=0;i<5;i++)n[i] = 0;
    
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	scanf(" %c ",&c);
	if(c!='.'){
	  if(c=='S'){
	    sx = j;
	    sy = i;
	  }else if(c=='G'){
	    gx = j;
	    gy = i;
	  }else{
	    int a = c-'1';
	    nx[a][n[a]] = j;
	    ny[a][n[a]] = i;
	    n[a]++;
	  }
	}
      }
    }
    
    int type = -1,res = 1<<30;
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++)
	for(int k=0;k<n[j];k++)d[j][k] = 1<<30;

      now = i;
      for(int j=0;j<5;j++){
	next = (now+1)%5;
	if(j==0){
	  for(int k=0;k<n[next];k++){
	    d[next][k] = min(d[next][k],dis(sy,sx,ny[next][k],nx[next][k]));
	  }
	}else if(j==4){
	  int m = 1<<30;
	  for(int k=0;k<n[now];k++){
	    m = min(m,d[now][k] + dis(gy,gx,ny[now][k],nx[now][k]) );
	  }
	  if(m<res){
	    type = i;
	    res = m;
	  }
	}else{
	  for(int k=0;k<n[now];k++){
	    for(int l=0;l<n[next];l++){
	      if(d[now][k]<d[next][l]){
		d[next][l] = min(d[next][l],d[now][k] + dis(ny[now][k],nx[now][k],ny[next][l],nx[next][l]));
	      }
	    }
	  }
	}
	now = next;
      }
    }
    if(type<0)printf("NA\n");
    else printf("%d %d\n",type+1,res);
  }
}

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

int main(){
	int n;
	cin>>n;
	long long x[n],tmp[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
		tmp[i] = x[i];
	}
	sort(tmp,tmp+n);
	long long cen = (tmp[(n/2)-1]+tmp[(n/2)])/2;
	long long ans = 0;
	for(int i=0;i<n;i++){
		if(x[i]<=cen){
			ans = tmp[(n/2)];
		}else{
			ans = tmp[(n/2)-1];
		}
		cout<<ans<<endl;
	}

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
vector<int> z_algorithm(const string &s) {
    vector<int> prefix(s.size());
    for(int i = 1, j = 0; i < s.size(); i++) {
        if(i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while(i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n - 1; i++) {
        string t = s.substr(i, n);
        auto v = z_algorithm(t);
        int tmp = 0;
        for(int j = 0; j < v.size(); j++) {
            tmp = max(tmp, min(j, v[j]));
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, m;
    cin >> n >> m;
    vector<string> s(n);
    REP(i, n){
        cin >> s.at(i);
    }

    vector<pair<ll, ll>> os;
    REP(i, n){
        REP(j, m){
            if(s.at(i).at(j) == 'o'){
                os.emplace_back(i, j);
            }
        }
    }

    vector<vector<pair<ll, ll>>> dst(os.size());

    REP(i, os.size()){
        const ll si = os.at(i).first, sj = os.at(i).second;
        dst.at(i).emplace_back(si, sj);
        vector<vector<bool>> vis(n, vector<bool>(m, false));
        vis.at(si).at(sj) = true;
        queue<pair<ll, ll>> que;
        que.emplace(si, sj);
        while(!que.empty()){
            const auto p = que.front(); que.pop();
            const ll pi = p.first, pj = p.second;
            // move down
            if(pi + 1 < n && s.at(pi + 1).at(pj) != '#' && !vis.at(pi + 1).at(pj)){
                vis.at(pi + 1).at(pj) = true;
                que.emplace(pi + 1, pj);
                dst.at(i).emplace_back(pi + 1, pj);
            }
            // move right
            if(pj + 1 < m && s.at(pi).at(pj + 1) != '#' && !vis.at(pi).at(pj + 1)){
                vis.at(pi).at(pj + 1) = true;
                que.emplace(pi, pj + 1);
                dst.at(i).emplace_back(pi, pj + 1);
            }
        }

        // cerr << "i=" << i << ", p=" << si << ", " << sj << ", size=" << dst.at(i).size() << endl;
    }

    const int src = 0;
    const int os_s = 1;
    const int dst_s = 1 + os.size();
    const int snk = dst_s + n * m;
    mcf_graph<int, ll> graph(snk + 1);

    // src to os
    REP(i, os.size()){ graph.add_edge(src, os_s + i, 1, 0); }

    // os to dst_s
    REP(i, os.size()){
        const ll pi = os.at(i).first, pj = os.at(i).second;
        for(const auto& d : dst.at(i)){
            const ll di = d.first, dj = d.second;
            const ll j = di * m + dj;
            const ll gain = (di - pi) + (dj - pj);
            graph.add_edge(os_s + i, dst_s + j, 1, n * m - gain);
        }
    }

    // dst_s to snk
    REP(i, n * m){ graph.add_edge(dst_s + i, snk, 1, 0); }

    const auto q = graph.flow(src, snk);
    assert(q.first == os.size());
    cout << - q.second + n * m * os.size() << endl;

    // check edge
    // const auto einfo = graph.edges();
    // for(auto e : einfo){
    //     if(e.from < os_s || e.from >= dst_s){ continue; }
    //     if(e.flow == 0){ continue; }
    //     const ll i = e.from - os_s;
    //     const ll j = e.to - dst_s;
    //     const ll dj = j % m;
    //     const ll di = j / m;
    //     cerr << "(" << os.at(i).first << ", " << os.at(i).second << ") => (" << di << ", " << dj << "), gain=" << - e.cost << endl;
    // }

    return 0;
}


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

int main(){
  
  int n;
  cin>>n;
  
  double ans=0;
  for(int i=0 ; i<n ; ++i){
    double a;
    cin>>a;
    
    ans += 1/a;
  }
  
  cout<<1/ans;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc070c()
}

fun abc070c() {
    val n = readLine()!!.toInt()
    val tList = (1..n).map { readLine()!!.toLong() }

    val answer = tList.fold(1L) { acc, l -> lcm(acc, l) }

    println(answer)
}

private fun lcm(a: Long, b: Long): Long {
    return a / gcd(a, b) * b
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}


Measured memory_bytes: 33652
import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	class R{
		int r=0;
	}

	void run(){
		sc=new Scanner(System.in);
		HashMap<Integer, R> map=new HashMap<Integer, R>();
		for(; sc.hasNext();){
			int n=sc.nextInt();
//			if(n==0)
//				break;
			if(!map.containsKey(n))
				map.put(n, new R());
			map.get(n).r++;
		}
		int m=0;
		for(Entry<Integer, R> entry : map.entrySet()){
			m=max(m, entry.getValue().r);
		}
		LinkedList<Integer> list=new LinkedList<Integer>();
		for(Entry<Integer, R> entry : map.entrySet()){
			if(entry.getValue().r==m)
				list.add(entry.getKey());
		}
		Integer[] arr=list.toArray(new Integer[0]);
		Arrays.sort(arr);
		for(int a : arr)
			println(a+"");

		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <vector>

int main() {
    size_t N;
    int M;
    scanf("%zu %d", &N, &M);

    std::vector<int> B(N+1, 1), R(N+1);
    R[1] = 1;

    for (int i=0; i<M; ++i) {
        size_t x, y;
        scanf("%zu %zu", &x, &y);

        ++B[y];
        if (R[x])
            R[y] = 1;

        if (!--B[x])
            R[x] = 0;
    }

    int res=0;
    for (size_t i=1; i<=N; ++i)
        if (R[i])
            ++res;

    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;


int main() {
	constexpr ull LONGEST = 10000000000; // 10^10(与えられた最長の距離)

	ull A, B, Q;
	cin >> A >> B >> Q;

	vector<ull> shrines(A);
	vector<ull> temples(B);
	vector<ull> questions(Q);

	for (auto&& s : shrines) {
		cin >> s;
	}
	for (auto&& t : temples) {
		cin >> t;
	}
	for (auto&& q : questions) {
		cin >> q;
	}
	
	// 解いていく。
	vector<ull> ans(Q);

	// 距離計算する関数
	auto GetLeftRightDistance = [LONGEST](const auto& buildings, ull start_point) -> pair<ull, ull> {
		const auto it = partition_point(cbegin(buildings), cend(buildings), [start_point](const auto& b) {
			return b < start_point;
		});
		// 出発地点から左右の建物への距離
		ull left = LONGEST * 2;
		ull right = LONGEST * 2;
		if (it == cend(buildings)) {
			// 出発した位置の左にしか建物がない
			left = start_point - *(it - 1);
		} else if (it == cbegin(buildings)) {
			// 出発した位置の右にしか建物がない
			right = *it - start_point;
		} else {
			// 出発した位置の両方に建物がある
			left = start_point - *(it - 1);
			right = *it - start_point;
		}
		return make_pair(left, right);
	};

	for (size_t i = 0; i < questions.size(); i++) {
		const auto shrine_lr = GetLeftRightDistance(shrines, questions[i]);
		const auto temple_lr = GetLeftRightDistance(temples, questions[i]);

		const auto sLeft  = shrine_lr.first;
		const auto sRight = shrine_lr.second;
		const auto tLeft  = temple_lr.first;
		const auto tRight = temple_lr.second;

		// 全通りで計算する。
		// 神社右 && 寺右
		// 距離が長いほうが移動距離となる
		const ull candidate1 = sRight > tRight ? sRight : tRight;

		// 神社左 && 寺左
		// 距離が長いほうが移動距離となる
		const ull candidate2 = sLeft > tLeft ? sLeft : tLeft;

		// 神社右 && 寺左
		// 先に神社に行く案
		// 神社は往復なので2倍。
		const ull candidate3 = sRight * 2 + tLeft;

		// 神社右 && 寺左
		// 先に寺に行く案
		// 寺は往復なので2倍。
		const ull candidate4 = sRight + tLeft * 2;

		// 神社左 && 寺右
		// 先に神社に行く案
		// 神社は往復なので2倍。
		const ull candidate5 = sLeft * 2 + tRight;

		// 神社左 && 寺右
		// 先に寺に行く案
		// 寺は往復なので2倍。
		const ull candidate6 = sLeft + tRight * 2;
		
		// 最も移動距離が短いのが答え
		ans[i] = min({candidate1,candidate2,candidate3,candidate4,candidate5,candidate6});
	}

	for (const auto & a: ans) {
		cout << a << endl;
	}
	return 0;

}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;
 


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string a;
	cin >>a;
	int n=sz(a);
	
	VI ct(27);
	for(auto x: a) ct[x-'a']++;
	ll sm=0;
	
	rep(i,26){
		sm += (ll)ct[i] * (n-ct[i]);
	}
	cout << sm/2 +1 <<endl;
	return 0;
}

Measured memory_bytes: 640
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
int get_first(function<bool(int)> f,int L, int R){
	while(L<R){
		int mid = (L+R)/2 ;
		f(mid)? R=mid:L=mid+1 ; 
	} 
	return L ;
}

void solve(){
	int n , k ;
	cin >> n >> k ;
	vector<int> a(n) ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
	}
	auto chk = [&](int m){
		int cnt = 0 ;
		for(int i = 0 ; i < n ; i++){
			cnt += (a[i]-1)/m ;
		}
		return cnt <= k ;
	} ;
	cout << get_first(chk,1,1e10) ;
}

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


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    for(int k=j+1;k<=n;k++){
                        if(i+j+k==x) count++;
                    }
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 24848
#include <stdio.h>

int main(){
    int x, b, f, r, v, y[4][3][10]={0};
    scanf("%d", &x);
    for (int i = 0; i < x; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        y[b-1][f-1][r-1]+=v;
    }
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                printf(" %d", y[i][j][k]);

            }
            puts("");
        }
      if(i!=3){
          printf("####################\n");
      }
        
    }
    
    
}


Measured memory_bytes: 2036
import java.util.*;

class Main {
	public static void main (String [] args){
		ansPrint();	
	}

	static int digits(int n){
		return Integer.toString(n).length();
	}

	static void ansPrint(){
		Scanner sc = new Scanner(System.in);
		int a, b, sum;
		while(sc.hasNextInt()){
			a = sc.nextInt();
			b = sc.nextInt();
			sum = a + b;
			System.out.println(digits(sum));
		}
	}
}	

Measured memory_bytes: 12000
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

struct Point {
    int x, y;
}

bool ismatch(Point a, Point b) {
    return a.x < b.x && a.y < b.y;
}

void main() {
    int n = readint();
    auto as = new Point[n];
    auto bs = new Point[n];
    foreach(ref p; as)
        readf("%d %d\n", &p.x, &p.y);
    foreach(ref p; bs)
        readf("%d %d\n", &p.x, &p.y);

    as.sort!("a.x < b.x");
    bs.sort!("a.x < b.x");

    bool[110] used;
    int ans;
    foreach(b; bs) { 
        int ymax = -1, id = -1;
        foreach_reverse(i, a; as) {
            if (ismatch(a, b) && !used[i] && ymax < a.y) {
                ymax = a.y;
                id = i.to!int;
            }
        }
        if (id != -1) {
            used[id] = true;
            ans++;
        }
    }
    ans.writeln;
    
    auto _ = readln(); // dbg
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p.at(i);
    
    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


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

int main(){
  int n;
  long long t;
  cin >> n >> t;
  vector<long long> time(n);
  for(int i = 0; i < n; i++) cin >> time.at(i);
  
  long long ans = 0, now = t;
  for(int i = 1; i < n; i++){
    if(now >= time.at(i)) ans += time.at(i) -time.at(i-1);
    else ans += t;
    now = time.at(i) + t;
  }
  
  cout << ans + t << endl;
}

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

int abs(int x) {
  if (x < 0) x = -x;
  return x;
}

using namespace std;
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  vector<int> ans(n-1, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int l, l1, l2;
      l1 = j - i;
      l2 = min(abs(i-x), abs(i-y)) + min(abs(j-x), abs(j-y)) + 1; 
      l = min(l1, l2);
      ++ans.at(l-1);
    }
  }
  for (int i = 0; i < n-1; ++i) {
    cout << ans.at(i) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int wher[1000 * 1000]; // 0-indexed!! n = wa+b
int caru[1000 * 1000]; // 0-indexed!!
int roofer[1000 * 1000];

int h, w;

void deb(){
	int i;
	for (i = 0; i < h * w; i++) {
		printf("%d: %d\n", i, roofer[i]);
	}
	return;
}

int findes(int i, int j, int dest) {
	if (i < j || dest == -1 || dest == roofer[j]) return dest;

	if (dest == i) {
		return roofer[j];
	} else {
		return -1;
	}
}

int solve(){
	int i;
	int result = 0;	
	for (i = 0; i < h * w; i++) {
		int ih, iw, dest = i;
		ih = wher[i] / w;
		iw = wher[i] % w;
			// printf("%2d: ", i);
		if (ih > 0) {
			int j = caru[wher[i] - w];
			dest = findes(i, j, dest);
		}
			// printf("%2d ", dest);
		if (ih < h-1) {
			int j = caru[wher[i] + w];
			dest = findes(i, j, dest);
		}
			// printf("%2d ", dest);
		if (iw > 0) {
			int j = caru[wher[i] - 1];
			dest = findes(i, j, dest);
		}
			// printf("%2d ", dest);
		if (iw < w-1) {
			int j = caru[wher[i] + 1];
			dest = findes(i, j, dest);
		}
			// printf("%2d\n", dest);
		roofer[i] = dest;
		if (dest == -1) result++;
	}

	// deb();

	return (int)printf("%d\n", result);
}

int main(void){
	int i;
	scanf("%d%d", &h, &w);
	for (i = 0; i < h * w; i++) {
		int x;
		scanf("%d", &x);
		wher[x - 1] = i;
		caru[i] = x - 1;
	}
	solve();
	return 0;
}

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

struct ModInt {
    using M = ModInt;
    long long v;
    ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
    M &norm() {
        v = (v < MOD) ? v : v - MOD;
        return *this;
    }
    M operator+(const M &x) const { return M(v + x.v); }
    M operator-(const M &x) const { return M(v + MOD - x.v); }
    M operator*(const M &x) const { return M(v * x.v % MOD); }
    M operator/(const M &x) const { return M(v * x.inv().v); }
    M &operator+=(const M &x) { return *this = *this + x; }
    M &operator-=(const M &x) { return *this = *this - x; }
    M &operator*=(const M &x) { return *this = *this * x; }
    M &operator/=(const M &x) { return *this = *this / x; }
    friend istream &operator>>(istream &input, M &x) {
        return input >> x.v, x.norm(), input;
    }
    friend ostream &operator<<(ostream &output, const M &x) {
        return output << x.v;
    }
    M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1)
                res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    M inv() const { return this->pow(MOD - 2); }

    static long long MOD;
    static vector<M> fact, finv;
    static void build(int n) {
        fact.assign(n + 1, 1);
        finv.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++)
            fact[i] = fact[i - 1] * M(i);
        for (int i = 0; i < n + 1; i++)
            finv[i] = fact[i].inv();
    }
    static M comb(int n, int k) {
        if (n < k || k < 0)
            return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int *x, int *y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            *y -= (a / b) * *x;
        } else {
            *x = 1, *y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

const int maxn = 22;
ModInt dp[maxn][1<<maxn];
bool done[maxn][1<<maxn];

int n;
int a[maxn][maxn];

/* 
状態：今注目している男性・その時点でどの女性がマッチ済みかを表すビット集合。
*/
ModInt dfs(int i, int s) {
    if (i == n) return (s == (1<<n) - 1) ? 1 : 0;
    if (done[i][s]) return dp[i][s];
    for(int j = 0; j < n; j++) {
        if (a[i][j] == 0 || s & (1 << j)) continue;
        dp[i][s] += dfs(i + 1, s | (1 << j));
    }
    done[i][s] = true;
    return dp[i][s];
}

int main() {
    cin >> n;
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }
    ModInt c = dfs(0, 0);
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 788736
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 10^^9 + 7;

void main() {
    int n;
    scan(n);
    auto a = new int[](n);
    auto b = new int[](n);
    auto c = new int[](n);
    iota(n).each!(i => scan(a[i], b[i], c[i]));
    
    auto dp = new int[][](n + 1, 4);
    fillAll(dp, -inf);
    dp[0][0] = 0;

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. 4) {
            if (j != 1) {
                dp[i+1][1] = max(dp[i+1][1], dp[i][j] + a[i]);
            }
            if (j != 2) {
                dp[i+1][2] = max(dp[i+1][2], dp[i][j] + b[i]);
            }
            if (j != 3) {
                dp[i+1][3] = max(dp[i+1][3], dp[i][j] + c[i]);
            }
        }
    }

    auto ans = max(dp[n][1], dp[n][2], dp[n][3]);

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

const int MAXn = 200005, MAX = 2147483647;
int n, q, t1, t2, t3, t4, h, d[MAXn], t[MAXn];
bool tag[MAXn];

int msb(int val) {
	int i = 0;
	while(val) val >>= 1, i++;
	return i;
}

void apply(int p, int val) {
	t[p] = val;
	if (p < n) d[p] = val, tag[p] = 1;
}

void build(int p) {
	while(p > 1) {
		p >>= 1;
		if (tag[p]) t[p] = d[p];
		else t[p] = min(t[p << 1], t[p << 1 | 1]);
	}
}

void push(int p) {
	for (int s = h - 1; s > 0; s--) {
		int i = p >> s;
		if (tag[i]) {
			apply(i << 1, d[i]);
			apply(i << 1 | 1, d[i]);
			tag[i] = 0;
		}
	}
}

void modify(int l, int r, int val) {
	l += n, r += n;
	int l0 = l, r0 = r;
	push(l);
	push(r - 1);
	for (; l < r; l >>= 1, r >>= 1) {
		if (l & 1) apply(l++, val);
		if (r & 1) apply(--r, val);
	}
	build(l0);
	build(r0 - 1);
}

int query(int l, int r) {
	l += n, r += n;
	push(l);
	push(r - 1);
	int ans = MAX;
	for (; l < r; l >>= 1, r >>= 1) {
		if (l & 1) ans = min(ans, t[l++]);
		if (r & 1) ans = min(ans, t[--r]);
	}
	return ans;
}

int main() {
	cin >> n >> q;
	h = msb(n);
	for (int i = 1; i < 2 * n; i++) t[i] = MAX;
	for (int i = 0; i < q; i++) {
		cin >> t1;
		if (t1 == 0) {
			cin >> t2 >> t3 >> t4;
			modify(t2, t3 + 1, t4);
		}
		else {
			cin >> t2 >> t3;
			cout << query(t2, t3 + 1) << endl;
		}
	}
}


Measured memory_bytes: 4380
#include <stdio.h>

#define MAX_N 1000
#define MAX_W 10000

int n;
int w[MAX_N];
int sorted_w[MAX_N];
int idx[MAX_W+1];
int used[MAX_N];

int min(int a, int b) {
  return a > b ? b : a;
}

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void bubbleSort() {
  int i, j;
  for(i = 0; i < n-1; i++) {
    for(j = n-1; j > i; j--) {
      if(sorted_w[j] < sorted_w[j-1]) {
	swap(&sorted_w[j], &sorted_w[j-1]);
      }
    }
  }
}

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", w+i);
    sorted_w[i] = w[i];
  }
  bubbleSort();
  for(i = 0; i < n; i++) idx[sorted_w[i]] = i;
  int minimam = sorted_w[0];
  int ans = 0;
  for(i = 0; i < n; i++) {
    if(used[i]) continue;
    int pos = i;
    int minimal = MAX_W;
    int sum = 0;
    int cnt = 0;
    while(!used[pos]) {
      used[pos] = 1;
      if(w[pos] < minimal) minimal = w[pos];
      sum += w[pos];
      cnt++;
      pos = idx[w[pos]];
    }
    //printf("%d %d %d\n", pos, minimal, sum);
    ans += min(sum-minimal+(cnt-1)*minimal,
	       sum-minimal+(cnt-1)*minimam+(minimam+minimal)*2);
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 620
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

S = int(input())
ans = 0
for i in range(1, (S//3)+1):
  rest = S - 3*i
  tmp = comb(rest+i-1, i-1)
  ans += tmp % (10**9+7)
ans = ans % (10**9+7)
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int n,a[20010],b[20010],p[20010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		a[i]=i*20000;
		b[i]=(n-i+1)*20000;
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		a[p[i]]-=n-i;
	}
	for (int i=1;i<=n;i++)
	{
		printf("%d ",a[i]);
	}
	puts("");
	for (int i=1;i<=n;i++)
	{
		printf("%d ",b[i]);
	}
	return 0;
}


Measured memory_bytes: 896
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        s: [String;n],
        m: usize,
        t: [String;m]
    }

    let mut a: HashMap<String,i32> = HashMap::new();
    let mut b: HashMap<String,i32> = HashMap::new();
    for k in s {
        let v = a.entry(k).or_insert(0);
        *v += 1;
    }
    for k in t {
        let v = b.entry(k).or_insert(0);
        *v += 1;
    }
    let mut res = 0;
    for (k,v1) in a {
        let v2 = if let Some(v) = b.get(&k) { *v } else { 0 };
        res = std::cmp::max(res, v1-v2);
    }
    println!("{}", res);
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  string S;
  cin >> S;
  rep(i, S.size()) {
    S[i] = 'x';
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int book[55] = {0};
    int n,m;
    scanf("%d %d",&n,&m);
    int a, b;
    for(int i=0; i<m; i++){
        scanf("%d %d",&a,&b);
        book[a]++;
        book[b]++;
    }
    for(int i=1; i<=n; i++){
        printf("%d",book[i]);
        if(i!=n) printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
X = list(int(i) for i in input().split())

if abs(X[0]-X[2]) <= X[3]:
    print("Yes")
else:
    if abs(X[0]-X[1]) <= X[3]:
        if abs(X[1]-X[2]) <= X[3]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < 6; i++){
    if(s.at(i) == '1')
      ans++;
  }
  cout << ans << endl;
  //cout << (  ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int num = 0;
  int n = N;
  while (n) {
    num += n % 10;
    n /= 10;
  }
  if (N % num == 0) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, ans = 0;
	int minn = 107;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		ans += x;
		if (x % 10 != 0) minn = min(minn, x);
	}
	if (ans % 10 == 0 && minn == 107) ans = 0;
	else if (ans % 10 == 0) ans -= minn;
	cout << ans << endl; 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
g = [[]for i in range(n)]
for i in range(n):
    v = list(map(int,input().split()))
    u = v[0]-1
    k = v[1]
    for j in range(k):
        g[u].append(v[j+2]-1)
time = 1
ans = []
d = [0]*n
f = [0] *n
visited = [0]*n

def dfs(now,last = -1):
    global time
    
    visited[now] = 1
    d[now] = time
    time += 1
    for next in g[now]:
        if visited[next]:continue
        dfs(next,now)
    f[now] = time
    time +=1
    
for i in range(n):
    if not visited[i]:dfs(i)
for i in range(n):
    print(i+1,d[i],f[i])
    
    
        
        


Measured memory_bytes: 5668
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int keta(int n) {
	int res = 0;
	while (n > 0) {
		res++;
		n /= 10;
	}
	return res;
}

int main() {
	string s; cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0;
}

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

int main() {
  string str;
  cin >> str;
  vector<char> v;
  for(int i=0; i < str.size(); i++){
    v.push_back(str.at(i));
  }

  bool frag = true;
  bool loopOne = true;
  char oldNum;
  char newNum;
  int ans = 0;
  for(int i=0; frag; i++){

    if(loopOne == true){
      if(v.size() < 2){
        frag = false;
        break;
      }
      loopOne = false;
      oldNum = v.at(i);
      continue;
    }

    newNum = v.at(i);

    if(oldNum != newNum){
      v.erase(v.begin() + i);
      v.erase(v.begin() + i - 1);
      ans += 2;
      i = -1;
      loopOne = true;
      continue;
    }

    if(v.size() == i + 1){
      frag = false;
      break;
    }

    oldNum = v.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<double, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 200005;

vector<pi> v;

int getLis(vector<pi> &v){
	sort(v.begin(), v.end());
	vector<int> fu;
	for(auto &i : v){
		auto l = lower_bound(fu.begin(), fu.end(), i.second);
		if(l == fu.end()) fu.push_back(i.second);
		else *l = i.second;
	}
	return fu.size();
}

bool mid(int s, int x, int e){
	if(s > e) swap(s, e);
	return s<= x && x <=e;
}
int main(){
	int x1, y1, x2, y2;
	int n;
	scanf("%d %d %d %d",&x1, &y1, &x2, &y2);
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		int x, y;
		scanf("%d %d",&x,&y);
		if(mid(x1, x, x2) && mid(y1, y, y2)){
			v.push_back(pi(x, y));
		}
	}
	if(pi(x1, y1) > pi(x2, y2)){
		swap(x1, x2);
		swap(y1, y2);
	}
	if(y1 > y2){
		swap(y1, y2);
		for(auto &i : v){
			i.second = y1 + y2 - i.second;
		}
	}
	int l = getLis(v);
	double dist = 100.0 * (y2 - y1 + x2 - x1) + (5 * acos(-1) - 20) * l;
	if(l == min(y2 - y1, x2 - x1) + 1){
		dist += 10 * acos(-1) - 20;
		dist -= 5 * acos(-1) - 20;
	}
	printf("%.20f\n", dist);
}


Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int w,h,n;
  cin>>w>>h>>n;
  int x[n], y[n], a[n];
  int bottom = 0, left = 0, right = w, up = h;
  for(int i = 0; i < n; i++)
  {
    cin>>x[i]>>y[i]>>a[i];
    if(a[i] == 1) {
      left = max(left, x[i]);
    } else if(a[i] == 2) {
      right = min(right, x[i]);
    } else if(a[i] == 3) {
      bottom = max(bottom, y[i]);
    } else {
      up = min(up, y[i]);
    }
  }
  if(right - left > 0 && up - bottom > 0) {
    // cout << left << " " << right << " " << up << " " << bottom << endl;
    cout << (right - left) * (up - bottom) << endl;
  } else {
    cout << 0 << endl;
  }
  

  return 0;
}


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

int main() {
	int a,b,c,d,e,f,g,h;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	int S=a+b+c+d;
	int T=e+f+g+h;
	if (S>T){
		cout << S << endl;
	}
	else cout << T << endl;
	
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
static lld r,j,a,m,b,l,x,y,n,s,q,i,z,p,k,c,d,t;string s1,s2,s3;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;lld c[n],f[n],s[n];
    rep(i,0,n-1)
    {
      cin>>c[i]>>s[i]>>f[i];
    }
    rep(i,0,n-1)
    {
      x=c[i]+s[i];q=0;
       rep(j,i+1,n-1)
       {
        q=0;
          if(x<s[j])
            x=s[j];
          p=0;
          while(x>p)
          {
            p=s[j]+(q)*(f[j]);
            q++;
          }
          x=p;
          x+=c[j];
       }
       cout<<x<<endl;
    }
    cout<<0;
}

Measured memory_bytes: 256
import collections
N = int(input())
N_List = list(map(int,input().split()))
hanN = N//2
ki = N_List[1::2]
gu = N_List[0::2]
kicnt = collections.Counter(ki)
gucnt = collections.Counter(gu)

kidict = kicnt.most_common()
gudict = gucnt.most_common()

kilen = len(kidict)
gulen = len(gudict)

if kilen == 1 & gulen == 1:
    if kidict == gudict:
        ans = hanN
    else:
        ans = 0
elif kidict[0][0] == gudict[0][0]:
    if kidict[0][1] > gudict[0][1]:
        ans = sum(map(lambda x:x[1],kidict[1:])) + sum(map(lambda x:x[1],gudict[2:])) + gudict[0][1]
    elif kidict[0][1] < gudict[0][1]:
        ans = sum(map(lambda x:x[1],gudict[1:])) + sum(map(lambda x:x[1],kidict[2:])) + kidict[0][1]
    else:
        if gudict[1][1] >= kidict[1][1]:
            ans = sum(map(lambda x:x[1],kidict[1:])) + sum(map(lambda x:x[1],gudict[2:])) + gudict[0][1]
        else:
            ans = sum(map(lambda x:x[1],gudict[1:])) + sum(map(lambda x:x[1],kidict[2:])) + kidict[0][1]
else:
    ans = sum(map(lambda x:x[1],gudict[1:])) + sum(map(lambda x:x[1],kidict[1:]))

print(ans)

Measured memory_bytes: 27776
'use strict';

function Main(input) {
    const C = input.split("\n")[0];
    const vowel = ["a", "e", "i", "o", "u"];
    let out = "consonant";

    vowel.forEach((e) => {
        if (C == e) {
            out = "vowel";
            return;
        }
    });

    console.log(out);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] imparray = new int[10][10];
		int retmpsum = 0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				imparray[i][j] = sc.nextInt();
			}
		}
		for(int x=0;x<10;x++){
			for(int y=0;y<10;y++){
				for(int z=0;z<10;z++){
					if(imparray[y][z] > imparray[y][x] + imparray[x][z]){
						imparray[y][z] = imparray[y][x] + imparray[x][z];
					}
				}
			}
		}
		for(int wh=0;wh<h;wh++){
			for(int ww=0;ww<w;ww++){
				int wint = sc.nextInt();
				if(wint!=-1){
					retmpsum += imparray[wint][1];					
				}
			}
		}
		System.out.println(retmpsum);
    }
}


Measured memory_bytes: 45832
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int k; cin >> k;
  vector<ll> a;
  rep(i,1,10) a.push_back(i);
  while(1){
    if(k<=a.size()){
      cout << a[k-1] << endl;
      return 0;
    }
    k-=a.size();
    vector<ll> old;
    swap(old,a);
    for(ll x: old){
      for(int i=-1; i<=1; ++i){
        int d = x%10+i;
        if(d<0 || 9<d) continue;
        ll nx = x*10+d;
        a.push_back(nx);  
      }
    }
  }
 }

Measured memory_bytes: 1712
while 1:
    n = input()
    if n == 0:
        break
    A = []
    for i in xrange(n):
        A.append(int(raw_input()))
    dp = [0] * len(A)
    dp[0] = A[0]
    for i in xrange(1, len(A)):
        dp[i] = max(dp[i - 1] + A[i], A[i])
    print max(dp)

Measured memory_bytes: 4388
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int prev = Integer.MAX_VALUE;
		long total = 0;
		for (int i = 0; i < n - 1; i++) {
		    int x = sc.nextInt();
		    total += Math.min(prev, x);
		    prev = x;
		}
		System.out.println(total + prev);
   }
}


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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int n;
int h[100100];
int dp[100100];

int main()
{
    cin >> n;
    rep(i, n)
    {
        cin >> h[i];
    }

    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
function Main(input) {
  const inputs = input.split("\n");
  const n = parseInt(inputs[0], 10);
  var nums = new Array(n)
  nums = inputs[1].split(" ");
  const result = nums.map(num => parseInt(num, 10))
    .sort((a, b) => a - b)
    .reduce((acc, value) => (acc + value) / 2);
  console.log(result);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n, C;
    scanf("%d%d", &n, &C);
    int a[C][200010];
    rep(i, C)rep(j, 200010) a[i][j] = 0;
    rep(i, n){
        int s, t, c;
        scanf("%d%d%d", &s, &t, &c);
        ++a[c-1][s*2-1];
        --a[c-1][t*2];
    }
    
    rep(i, C)rep(j, 200009) a[i][j+1] += a[i][j];
    int ans = 0;
    rep(i, 200010){
        int tmp = 0;
        rep(j, C)if(a[j][i]) ++tmp;
        ans = max(ans, tmp);
    }
    
    printf("%d\n", ans);
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int abs(int a){
  if(a>0)return a;
  else return -a;
}

int main(){
  int n;
  cin >>n;
  vector<int> a(n+1);
  rep1(i,n) cin >> a[i];
  const int INF = pow(10,9)+7;
  vector<int> dp(n+10,INF);
  dp[1] = 0;
  dp[2] = abs(a[2]-a[1]);
  for(int i=3;i<=n;i++){
    int cand1 = dp[i-2]+abs(a[i-2]-a[i]);
    int cand2 = dp[i-1]+abs(a[i-1]-a[i]);
    dp[i] = min(cand1,cand2);
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/abc162/tasks/abc162_d


import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = Integer.parseInt(in.nextLine());
        String S = in.nextLine();

        long rCount = 0, gCount = 0, bCount = 0;
        for (int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'R') rCount++;
            else if (S.charAt(i) == 'G') gCount++;
            else bCount++;
        }

        long anti =0;
        for (int i = 0; i < S.length()-2; i++) {
            for (int j = i+1; j < S.length()-1; j++) {
                int k = 2 * j - i;
                if(k >= S.length()) continue;

                if(S.charAt(i) != S.charAt(j) && S.charAt(j) != S.charAt(k) & S.charAt(i) != S.charAt(k)) anti++;


            }
        }


        out.println(rCount * gCount * bCount - anti);





        in.close();
        out.close();
    }
}


Measured memory_bytes: 37776