akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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;
}

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

intpair odd[100001], even[100001];

int main() {
	int N; cin>>N;
	for(int i=0; i<N/2; i++) {
		int v; cin>>v;
		odd[v].first++;
		odd[v].second=v;

		cin>>v;
		even[v].first++;
		even[v].second=v;
	}
	sort(odd,odd+100001,greater<intpair>());
	sort(even,even+100001,greater<intpair>());

	if(odd[0].second==even[0].second) {
		if(odd[0].first-odd[1].first<even[0].first-even[1].first)
			odd[0].first=odd[1].first;
		else
			even[0].first=even[1].first;
	}
	
	cout<<N-odd[0].first-even[0].first<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#define N 100000
char s[N];
int main(void)
{
    int i, cnt0 = 0, cnt1 = 0;
    scanf("%s", s);
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] == '0')
            cnt0++;
    }
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] == '1')
            cnt1++;
    }
    printf("%d\n", cnt0 < cnt1 ? cnt0 * 2 : cnt1 * 2);
}

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

int main()
{
    string StrA, StrB;
    cin >> StrA >> StrB;

    int NA, NB;
    cin >> NA >> NB;


    string StrC;
    cin >> StrC;

    if (StrC == StrA) {
        NA = NA - 1;
    }
    else {
        NB = NB - 1;
    }

    cout << NA <<" "<< NB;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;

    unordered_map<string, ll> mp;

    ll ans = 0;
    rep(i,N){
        string s;
        cin >> s;
        sort(ALL(s));
        ans += mp[s];
        ++mp[s];
    }

    print(ans);

    return 0;
}

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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			String ans = "Three";
			String str;
			for(int i = 0; i < N; i++) {
				str = in.next();
				if(str.equals("Y")) {
					ans = "Four";
				}
			}
			out.println(ans);
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[4][N],to[N],num[2],n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<3;i++)for(int j=1;j<=n;j++)scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++){
        to[i]=a[1][i]/3+1;
        if(!((a[0][i]==a[1][i]-1&&a[1][i]==a[2][i]-1&&a[0][i]%3==1)||
            (a[0][i]==a[1][i]+1&&a[1][i]==a[2][i]+1&&a[0][i]%3==0))||abs(to[i]-i)%2)
                {printf("No\n");return 0;}
        num[i&1]^=a[0][i]>a[1][i];
    }
    for(int i=1;i<=n;i++){
        while(i^to[i])num[!(i&1)]^=1,swap(to[i],to[to[i]]);
    }
    printf("%s\n",num[0]||num[1]?"No":"Yes");
}


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

int main() {
  long n;
  cin >> n;
  vector<long> a(n);
  for(long i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  set<long> ya;
  bool pairwise=true;
  for(long i=0;i<n&&pairwise;i++) {
    for(long j=1;j*j<=a[i]&&pairwise;j++) {
      if(a[i]%j==0) {
        if(ya.count(j)&&j!=1) pairwise=false;
        ya.insert(j);
        if(j*j!=a[i]) {
          if(ya.count(a[i]/j)) pairwise=false;
          ya.insert(a[i]/j);
        }
      }
    }
  }
  if(pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  bool setwise=false;
  set<long> aaaa;
  for(long i=1;i*i<=a[0];i++) {
    if(a[0]%i==0) {
      if(i!=1) aaaa.insert(i);
      if(i*i!=a[0]) aaaa.insert(a[0]/i);
    }
  }
  for(long i=1;i<n;i++) {
    for(auto itr=aaaa.begin();itr!=aaaa.end();itr++) {
      if(a[i]%(*itr)!=0) aaaa.erase(itr);
    }
    if(aaaa.size()==0) {
      setwise=true;
      break;
    }
  }
  
  if(setwise) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

Measured memory_bytes: 11156
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i;
	int n, e, w, s, t;
	int tmp;
	char str[16];
	int total;
	
	while (scanf("%d", &n), n != 0){
		t = 1;
		s = 2;
		e = 3;
		
		total = 1;
		for (i = 0; i < n; i++){
			scanf("%s", str);
			if (strcmp(str, "North") == 0){
				tmp = s;
				s = 7 - t;
				t = tmp;
			}
			if (strcmp(str, "East") == 0){
				tmp = e;
				e = t;
				t = 7 - tmp;
			}
			if (strcmp(str, "West") == 0){
				tmp = e;
				e = 7 - t;
				t = tmp;
			}
			if (strcmp(str, "South") == 0){
				tmp = s;
				s = t;
				t = 7 - tmp;
			}
			if (strcmp(str, "Right") == 0){
				tmp = s;
				s = e;
				e = 7 - tmp;
			}
			if (strcmp(str, "Left") == 0){
				tmp = e;
				e = s;
				s = 7 - tmp;
			}
			total += t;
		}
		printf("%d\n", total);
	}
	return (0);
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;
    cin >> s;
    int res = 0;
    stack<int> st;
    int n = s.length();
    for (int i = 0; i < n; i++)
    {
        if (st.empty())
        {
            st.push(s[i]);
            continue;
        }
        if (st.top() == s[i])
        {
            st.push(s[i]);
            continue;
        }
        res += 2;
        st.pop();
    }
    cout << res << endl;
}


Measured memory_bytes: 720
N, K = input().split()
A = [i for i in map(int, input().split())]
k = 0
flag = 0
K = int(K)
for i in range(len(A)):
    for j in range(i+1,len(A)):
        if A[i] > A[j]:
            flag += 1
for i in range(len(A)):
    for j in range(len(A)):
        if A[i] < A[j]:
            k += 1
k = k*K*(K-1)//2
k = k+flag*K
print(k%(10**9+7))


Measured memory_bytes: 3188
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

pub fn gcd(a : i32, b : i32) -> i32 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}

// fn rec(pos : usize, isneg : bool, n : usize, a : &[i64], dp : ) -> i64 {
    
    
// }

fn main() {
    
    let mut dp : Vec<Vec<i64>> = vec![vec![0; 2] ; 100010];
    let n = read_t_in_line::<usize>()[0];
    let a = read_t_in_line::<i64>();

    for pos in (0..n).rev() {
        for isneg in 0..(2 as usize) {
            let mut ans = 0 as i64;
            let mut s = 1 as i64;
            if isneg == 1 {
                s = -1;
            }
            if pos == (n-1) {
                ans = s * a[pos];
            }
            else{
                // なにもしない場合
                {
                    ans = max(ans, dp[pos + 1][0] + s * a[pos]);
                }
                // -1をかける場合
                {
                    ans = max(ans, dp[pos + 1][1] + -1 * s * a[pos]);
                }
            }
            dp[pos][isneg] = ans;
        }
    }
    println!("{}", dp[0][0]);
}



Measured memory_bytes: 16576
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int t; cin>>t;while(t--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli x;
	
	cin>>x;
	
	if (x>=30)
		cout<<"Yes\n";
		
	else
		cout<<"No\n";

	return 0;
}


Measured memory_bytes: 3636
//https://blog.csdn.net/hesorchen
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(a) (a & (-a))
#define mod 1000000007
#define endl "\n"

int main()
{
    ll n, minn = 1000000009, a;
    cin >> n;
    ll ans = 0;
    while (n--)
    {
        cin >> a;
        if (a <= minn)
            ans++;
        minn = min(minn, a);
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll h, w, k;
    cin >> h >> w >> k;

    vvi s(h, vi(w, 0));
    rep(y, h) {
        string st;
        cin >> st;
        rep(x, w) s[y][x] = st[x] - '0';
    }

    vvi imos(h + 1, vi(w + 1));
    rep(i, h) rep(j, w) {
        imos[i + 1][j + 1] = imos[i][j + 1] + imos[i + 1][j] - imos[i][j] + s[i][j];
    }

    // cout << " -- imos -- " << endl;
    // rep(i, h) {
    //     rep(j, w) {
    //         cout << imos[i + 1][j + 1];
    //     }
    //     cout << endl;
    // }
    auto query = [&](int x1, int x2, int y1, int y2) {
        // cout << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
        return imos[y2][x2] - imos[y1][x2] - imos[y2][x1] + imos[y1][x1];
    };

    int ans = inf;
    rep(bits, 1 << (h - 1)) {
        vi cuts;
        cuts.push_back(0);
        rep(c, h - 1) {
            if (bits >> c & 1) cuts.push_back(c + 1);
        }
        cuts.push_back(h);

        // cout << " -- bits := ";
        // rep(i, cuts.size()) cout << cuts[i] << " ";
        // cout << endl;

        bool ok = true;
        vi ccuts;
        ccuts.push_back(0);
        rep(x, w) {
            int mx = 0;
            rep(cy, cuts.size() - 1) {
                chmax(mx, query(ccuts.back(), x + 1, cuts[cy], cuts[cy + 1]));
            }
            if (mx > k) {
                if (ccuts.back() == x) {
                    ok = false;
                    break;
                }
                ccuts.push_back(x);
                x--;
            }
        }
        if (ok) {
            // cout << " -- " << (cuts.size() - 2) << " + " << (ccuts.size() - 1) << " = " << (cuts.size() - 2) + (cuts.size() - 1) << " -- " << endl;
            // rep(i, cuts.size()) cout << cuts[i] << " ";
            // cout << endl;
            // rep(i, ccuts.size()) cout << ccuts[i] << " ";
            // cout << endl;
            chmin(ans, (cuts.size() - 2) + (ccuts.size() - 1));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.update = function(self, idx)
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = mma(self.stage[self.stagenum][idx], value)
  if not silent then
    self:update(idx)
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local z = 300000
local st = SegTree.new(z + 1, mma, 0)
for i = 1, n do
  local ai = a[i]
  local left = mma(0, ai - k)
  local right = mmi(z, ai + k)
  local cur = st:getRange(left + 1, right + 1)
  st:setValue(ai + 1, cur + 1)
end
print(st.stage[1][1])


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

using namespace std;

const int DIM = 1e5 + 7;

int v[DIM];

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

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++)
        cin >> v[i];


    sort(v + 1, v + 1 + n);

    cout << v[n / 2 + 1] - v[n / 2];
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    float ans = 0, preans = 0;
    REP(i, n){
        float a; cin >> a;
        preans += 1 / a;
    }
    ans = 1 / preans;
    cout << fixed << setprecision(6) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
  vector<ll> L(N);
  for(ll i=0;i<N;i++) {
cin>>L[i];
  }
  ll ans=0;
  for(ll i=0;i<N-2;i++) {
for(ll j=i+1;j<N-1;j++) {
for(ll h=j+1;h<N;h++) {
  if(L[i]==L[j]||L[j]==L[h]||L[h]==L[i]) {
continue;
  }
  if(abs(L[h]-L[j])<L[i]&&L[i]<L[h]+L[j]) {
ans++;
  }
}
}
  }
  
  cout<<ans<<endl;
}
  
  
  
  
  
  


Measured memory_bytes: 3628
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    int a, b;
    cin >> a >> b;
    cout << a / b << " " << a % b << " " << (double)a / (double)b << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



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

int kansu(int i){
  if(i==25964)
    return 0;
    else return i;
}

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;

  if ( y->parent == NIL ){
    root = x;
  } else {
    if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }

  if ( y != z ){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

const double PI = acos(-1);

int main() {
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
	string S;
	string T="0000000000";
	cin>>S;
	int check=0;
	REP(i,S.size()){
	   if(S[i]=='0'){
	      T[check]='0';
	      check++;
	   }else if(S[i]=='1'){
	      T[check]='1';
	      check++;
	   }else{
	      check=max(0,check-1);
	   }
	}
	REP(i,check){
            cout<<T[i];
        }
        cout<<endl;
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>pref(n + 3), suff(n + 3);
    pref[0] = 0, suff[n] = 0;
    for(int i = 0; i < n; i++){
        pref[i + 1] = pref[i];
        if(s[i] == 'W'){
            pref[i + 1]++;
        }
    }
    for(int i = n - 1; i >= 0; i--){
        suff[i] = suff[i + 1];
        if(s[i] == 'R'){
            suff[i]++;
        }
    }
    int ans = n + 5;
    for(int i = 0; i <= n; i++){
        int cur = max(pref[i], suff[i + 1]);
        ans = min(ans, cur);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 200005
const ll MOD = 1000000007;
vector<int> adj[MAX];
ll sz[MAX],powers[MAX];
ll ans,prod,n;

ll addmod(ll a, ll b){
	return (a+b)%MOD;
}

ll mulmod(ll a, ll b){
	return a*b%MOD;
}

ll modexp(ll a, ll n){
	if(n==0)
		return 1;
	ll p = modexp(a,n/2);
	p = p*p%MOD;
	if(n&1)
		p = p*a%MOD;	
	return p;
}

ll modinv(ll a){
	return modexp(a,MOD-2);
}

void dfs(int u, int p){
	sz[u] = 1;
	ll sum = 0;
	ll k = 0;
	for(int v: adj[u]){
		if(v == p){
			++k;
			continue;
		}
		dfs(v,u);
		sum = addmod(sum,powers[sz[v]]);
		sz[u] += sz[v];
		++k;
	}

	if(sz[u] != n)
		sum = addmod(sum,powers[n-sz[u]]);

	sum = mulmod(prod,addmod(sum,MOD+1-k));

	ans = addmod(ans,mulmod(modinv(2),MOD+1-sum));
}

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

	int u,v;
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	powers[0] = 1;
	for(int i=1;i<=n;i++)
		powers[i] = powers[i-1]*2%MOD;

	prod = modinv(powers[n-1]);
	ans = 0;
	dfs(1,0);
	cout<<ans<<endl;
}

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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<int> d;
  for (int i = 0; i < n; i++) {
    auto it = lower_bound(d.rbegin(), d.rend(), a[i]);
    if (it == d.rbegin()) {
      d.push_back(a[i]);
    } else {
      --it;
      *it = a[i];
    }
  }
  int ans = d.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimine("O3")
#define all(x) (x).begin(),(x).end()
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int x,a,b;
	cin >> x >> a >> b;
	if (a>=b)
	{
		printf("delicious");
		return 0;
	}
	printf("%s",b-a<=x?"safe":"dangerous");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=300005;
const int mod=998244353;
int n;
char s[max_n];
int cnt[7];
int mask=7;
int get(char c){
    if(c=='R')return 0;
    if(c=='G')return 1;
    if(c=='B')return 2;
}
int main(){
    scanf("%d",&n);
    scanf(" %s",s+1);
    cnt[0]=n;
    ll ans=1;
    for(int i=1;i<=n*3;i++){
        int x=get(s[i]);
        if(cnt[mask^(1<<x)]){
            ans=ans*cnt[mask^(1<<x)]%mod;
            cnt[mask^(1<<x)]--;
        }
        else{
            bool f=false;
            for(int i=0;i<3;i++){
                if(x==i)continue;
                if(cnt[1<<i]){
                    ans=ans*cnt[1<<i]%mod;
                    cnt[1<<i]--;
                    cnt[1<<i|(1<<x)]++;
                    f=true;
                    break;
                }
            }
            if(f==false){
                ans=ans*cnt[0]%mod;
                cnt[0]--;
                cnt[1<<x]++;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 
int main(){
	int t,a=0,b=0;
	rep(i,4) cin>>t, a+=t;
	rep(i,4) cin>>t, b+=t;
	cout<<max(a,b)<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>

typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for(ll i=init;i<(n);i++)

int main() {
    ll h, w;
    cin >> h >> w;
    if (w != 1 && h != 1)
        cout << ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << endl;
    else
        cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3612
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
A_a = [int(i) for i in A if i < x]
A_b = [int(i) for i in A if i > x]
L_a = len(A_a)
L_b = len(A_b)


if L_a >= L_b:
    print(L_b)
else:
    print(L_a)

Measured memory_bytes: 3064
def main():
    n = int(input())

    # for i in range(1, n + 1):
    #     if

    # i = 1
    # while i * i <= n:
    #     i += 1
    #
    # print((i - 1) ** 2)

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i ** j <= n:
            ans.append(i ** j)
            j += 1

    print(max(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

struct UnionFind{
    int data[100001]; 
    void init(int n){memset(data,-1,sizeof(data));}
    int find(int x){return data[x]<0?x:data[x]=find(data[x]);}
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x!=y){
            if(data[y]<data[x]) swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return;
    } 
    bool same(int x, int y){return (find(x) == find(y));}
    int size(int x){return -data[find(x)];}
};
int main(){
    int n,m;
    cin>>n>>m;
    int xi,yi,zi;
    UnionFind uf;
    uf.init(n);
    rep(i,m){
        cin>>xi>>yi>>zi;
        --xi,--yi;
        uf.unite(xi,yi);
    }
    int ans=0;
    rep(i,n)if(i==uf.find(i))++ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
gets
S_ARRAY = gets.chomp.split(" ").map(&:to_i).sort
gets
T_ARRAY = gets.chomp.split(" ").map(&:to_i).sort

def binary_search(val)
  left = 0
  right = S_ARRAY.count
  while left < right do
    mid = (left + right) / 2
    if S_ARRAY[mid] == val
      return true
    elsif val < S_ARRAY[mid]
      right = mid
    else # val < S_ARRAY[mid]
      left = mid + 1
    end
  end
end

ans = 0
T_ARRAY.each do |val|
  if binary_search(val)
    ans += 1
  end
end

p ans

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

int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(2));
  int count=0;
  bool flg=false;
  for(int i=0;i<n;i++){
    cin>>a[i][0]>>a[i][1];
    if(a[i][0]==a[i][1]){
      count++;
    }else{
      count=0;
    }
    if(count>=3){
      flg=true;
      break;
    }
  }
  cout<<(flg?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int N,M;
const int MAX=200010;
vector<int> g[MAX];
bool v[MAX];
void dfs(int x,int p){
    v[x]=true;
    for(int y:g[x])if(!v[y]){
        dfs(y,x);
    }
}
main()
{
    cin>>N>>M;
    for(int i=0;i<N;++i){
        int K;cin>>K;
        for(int j=0;j<K;++j){
            int L;cin>>L;
            g[i].push_back(L+N);
            g[L+N].push_back(i);
        }
    }
    dfs(0,-1);
    bool ok=true;
    for(int i=0;i<N;++i)ok&=v[i];
    cout<<(ok?"YES":"NO")<<endl;
}

Measured memory_bytes: 12220
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int n = in();
    int m = in();
    if (n == 0 && m == 0) break;
    vector<int> d(n), p(n);
    multimap<int, int> w;
    int s = 0;
    rep(i, n) {
      cin >> d[i] >> p[i];
      s += d[i] * p[i];
      w.emplace(-p[i], i);
    }
    for (auto &q : w) {
      auto &i = q.second;
      s -= min(m, d[i]) * p[i];
      m -= min(m, d[i]);
    }
    cout << s << endl;
  }
}



Measured memory_bytes: 3620
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);

#var_dump($v2);

# ソートしてハッシュを作成しておく

#var_dump($stdin);

for($i = 1; $i < count($stdin); $i++){
  $res = str_split($stdin[$i]);
  sort($res);
  #var_dump($res);
  $temp[] = implode($res);
  
}

$ans = 0;

$count= array_count_values($temp);

foreach($count as $k => $v){
  for($i = 0; $i < $v; $i++){
    $ans = $ans + $i;
  }
}

#var_dump($count);


echo $ans . PHP_EOL;



Measured memory_bytes: 61428
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    mod = 1000000007

    if N == 1:
        print(1)
        exit()

    p = defaultdict(int)
    for i in range(1, N+1):
        d = 2
        j = int(i**0.5)
        while d <= j:
            while i % d == 0:
                p[d] += 1
                i //= d
            d += 1
        if i != 1:
            p[i] += 1

    ans = 1
    for k in p.values():
        ans = (ans * (k+1))%mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40048
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<int,int> P;
#define fi first
#define se second
int main(){
    ios::sync_with_stdio(false);
   cin.tie(0);
int n,h;
cin>>n>>h;
vector<P> c(n),t(n);
for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    c.at(i)=P(a,b);
    t.at(i)=P(b,a);
}
sort(c.begin(),c.end(),greater<P>());
sort(t.begin(),t.end(),greater<P>());
int ans=0;
int j=0;
while(j+1<n&&c.at(j).fi==c.at(j+1).fi) j++;//きる中でも投げるダメが小さいもの
for(int i=0;i<n;i++){
    if(c.at(j).fi>t.at(i).fi)break;
    h-=t.at(i).fi;
    ans++;
    if(h<=0)break;
}
if(h>0){
    if(h%c.at(j).fi==0)ans+=h/c.at(j).fi;
    else ans+=h/c.at(j).fi+1;
}
cout<<ans<<endl;
}


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


int main(){
  ll n;
  cin >> n;
  for(ll a=1;a<3501;a++){
    for(ll b=1;b<3501;b++){
        if(4*a*b-n*(a+b)>0 && n*a*b%(4*a*b-n*(a+b))==0){
          cout << a << " " << b << " " << n*a*b/(4*a*b-n*(a+b)) <<endl;
          return 0;
        }
    }
  }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  vec a(3);
  for(ll i=0;i<3;i++) cin >> a[i];
  sort(a.begin(),a.end());
  if(a[0]+a[1]==a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define NIL -1
#define PARENT 0
#define LEFT 1
#define RIGHT 2

int Tree[25][3];

void Preorder(int pos) {
	if (pos == NIL) return;
	printf(" %d", pos);
	Preorder(Tree[pos][LEFT]);
	Preorder(Tree[pos][RIGHT]);
}

void Inorder(int pos) {
	if (pos == NIL) return;
	Inorder(Tree[pos][LEFT]);
	printf(" %d", pos);
	Inorder(Tree[pos][RIGHT]);
}

void Postorder(int pos) {
	if (pos == NIL) return;
	Postorder(Tree[pos][LEFT]);
	Postorder(Tree[pos][RIGHT]);
	printf(" %d", pos);
}

int main() {
	int i, n, pos, left, right;

	scanf("%d", &n);
	for (i = 0; i < n; i++) Tree[i][0] = NIL;

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &pos, &left, &right);
		Tree[pos][LEFT] = left;
		Tree[pos][RIGHT] = right;
		if (left != NIL) Tree[left][PARENT] = pos;
		if (right != NIL) Tree[right][PARENT] = pos;
	}

	i = 0;
	while (Tree[i][PARENT] != NIL) i++;

	printf("Preorder\n");
	Preorder(i);
	printf("\n");

	printf("Inorder\n");
	Inorder(i);
	printf("\n");

	printf("Postorder\n");
	Postorder(i);
	printf("\n");

	return 0;
}



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

#define N 100000

typedef struct pp{
  char name[100];
  int time;
}P;

int head=0,tail=0;
P Q[N];

void enqueue(P*,P);
P dequeue(P*);


int main(){
  int i,at=0,t,n,u[N];
  P q;
 
  scanf("%d%d",&n,&t);

  for(i=1;i<=n;i++){
    scanf("%s",&q.name);
    scanf("%d",&q.time);
    enqueue(Q,q);
  }

  while(1){
    q=dequeue(Q);
    if(q.time==-1) break;
    if(q.time<=t){
      at=q.time+at;
      printf("%s %d\n",q.name,at);
    }

    else{
      q.time=q.time-t;
      at+=t;
      enqueue(Q,q);
    }
  }
      
  return 0;
}

void enqueue(P *Q ,P q){
  if(head==(tail+1)%N) exit(1);

  Q[tail]=q;

  if(tail+1==N) tail=0;
  else tail++;
}

P dequeue(P *Q){
  P q;
  
  if(head==tail){
    q.time=-1;
    return q;
  }

  q=Q[head];

  if(head+1==N) head=0;
  else head++;

  return q;
}




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

int main() {
    int N;
    int M;
    cin >> N >> M;
    int vote[N];
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> vote[i];
        sum += vote[i];
    }
    int count = 0;
    for (int i = 0; i < N; ++i) {
        if (vote[i] >= (double) sum / 4 / M) {
            count ++;
        }
    }
    if (count >= M) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,ans=0;
  scanf("%d",&N);
  int p[100],a[100]={};
  for(int i=0;i<N;i++){
    scanf("%d",&p[i]);
    a[i]=i+1;
    
  }
  for(int i=0;i<N;i++){
    if(a[i]!=p[i]){
      ans+=1;
    }
  }
  if(ans<3){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <map>

using namespace std;


int mp[2100]={0};
int main() {
    string s;
    cin>>s;
    int num=0;
    int ans=0;
    mp[0]=1;

    int ten=10;
    for (int i=s.size()-1;i>=0;i--) {
        num+=(s[i]-'0')*ten;
        num%=2019;
        ten=ten*10%2019;
        mp[num]+=1;
    }

    //for (int i=0;i<2019;i++) if (mp[i]) cout<<i<<" "<<mp[i]<<endl;
    for (int i=0;i<2019;i++)
        ans+=mp[i]*(mp[i]-1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3376
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll a, b, ans = 0;
int main() {
	cin >> a >> b;
	if (b - a < 10) {
		FOR(i, a, b + 1)ans ^= i;
	}
	else {
		FOR(i, a,(a + 4) / 4 * 4) {
			ans ^= i;
		}
		FOR(i,4 * (b / 4),b + 1) {
			ans ^= i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
import math
a,b,h,m=map(int,input().split())
H=(12-h-m/60)/12
M=(60-m)/60


#ax=a*math.cos(2*math.pi/(12*(3-h)))
#ay=a*math.sin(2*math.pi/(12*(3-h)))
#bx=b*math.cos(2*math.pi/(60*(15-m)))
#by=b*math.sin(2*math.pi/(60*(15-m)))
ax=a*math.sin(2*math.pi*H)-b*math.sin(2*math.pi*M)
ay=a*math.cos(2*math.pi*H)-b*math.cos(2*math.pi*M)

bx=b*math.sin(2*math.pi*M)
by=b*math.cos(2*math.pi*M)

#
#print(ax,ay,bx,by)
#print(ax-bx,ay-by)
#d=abs(ax-bx)**2+abs(ay-by)**2
c=(ax**2+ay**2)**0.5

print(c)

Measured memory_bytes: 62676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    ll a[100005] = {}, g = 0, c[100005] = {};
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        a[i] /= 2;
        ll b = gcd(g, a[i]);
        if (!g) g = a[i];
        else g = g * a[i] / b;
        if (g > mod) g = mod;
    }
    for (int i = 0; i < n; i++) {
        while (a[i] % 2 == 0) a[i] /= 2, c[i]++;
    }
    for (int i = 1; i < n; i++) if (c[i] != c[i - 1]) {
        cout << 0;
        return 0;
    }
    ll z = m / g;
    if (z % 2) cout << z / 2 + 1;
    else cout << z / 2;
}


Measured memory_bytes: 5188
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>

#include <climits> // INT_MAX
#include <cmath> // ceil()
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define b2e(vec) vec.begin(), vec.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;


int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, n) {
		cin >> p[i];
	}

	sort(b2e(p));

	int sum = 0;
	rep(i, k) {
		sum += p[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 3632
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

using DataStructures

function main()
    N, M = parseMap(split(readline()))
    D = SortedDict{Int, Int}()
    for _ in 1:N
        A, B = parseMap(split(readline()))
        if haskey(D, A)
            D[A] += B
        else
            D[A] = B
        end
    end
    count = 0
    money = 0
    for d in D
        if M - count >= d[2]
            count += d[2]
            money += d[1] * d[2]
        elseif 0 < M - count < d[2]
            money += d[1] * (M - count)
            break
        else
            break
        end
    end
    println(money)
end


main()

Measured memory_bytes: 226128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<6-(a+b)<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
t = []
for i in range(n):
  t.append((a[i], 1))

for i in range(m):
  b, c = map(int, input().split())
  t.append((c, b))

t.sort(reverse=True)
ans = 0
for c, b in t:
  for _ in range(b):
    if n == 0:
      break
    ans += c
    n -= 1

print(ans)


Measured memory_bytes: 77740
#include <stdio.h>

int main(int argc , char *argv[]){
    int n,q;
    int i,j;
    int N[10000];
    int Q[500];
    int count=0;
    
    scanf("%d",&n);
    if(n>=10001)return 0;
    
    for(i=0;i<n;i++){
        scanf("%d",&N[i]);
        }
    
    
    
    scanf("%d",&q);
    if(q>=501)return 0;
    
    for(i=0;i<q;i++){
        scanf("%d",&Q[i]);
    }
    
        for(i=0;i<q;i++){
            for(j=0;j<n;j++){
                if(Q[i]==N[j]){
                    count++;
                    break;
                }
            }
        }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
using namespace std;

double abs_(double a)
{
	if (a > 0) return a;
	else return -a;
}

int main(){
	int n;
	cin >> n;
	while (n--){
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double a = (y2 - y1)*(x4 - x3);
		double b = (y4 - y3)*(x2 - x1);
		if (abs_(a - b) < 0.0000000001){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3180