akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	Yes(a == b&&b == c);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    dp = [[0]*4 for _ in range(2)] # dp[lt][k] lt:less than, k:num of non-zero
    dp[0][0] = 1
    for a in input():
        a = int(a)
        ndp = [[0]*4 for _ in range(2)]
        for lt, k, d in product([0,1], range(4), range(10)):
            # less than
            if (not lt) and d > a: continue
            nlt = max(lt, d < a)
            # zero
            nk = k + (d>0)
            if nk > 3: continue
            # iterate
            ndp[nlt][nk] += dp[lt][k]
        dp = ndp

    k = int(input())
    print(dp[0][k] + dp[1][k])
resolve()

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

vector<int > sum_list;

void make_sumlist(int a){
  int x = 0;
  sum_list.push_back(0);
  for(int i=1; i<=a; i++){
    x+=i;
    sum_list.push_back(x);
  }
}
double calc_kitaiti(int x){
  int sum = sum_list[x];
  return (double)sum/x;
}
int main(){
  int N, K;
  cin >> N >> K;
  vector<int > p(N);
  int max_m=0;
  for(int i=0; i<N; i++){
    cin >> p[i];
    if(p[i]>max_m)max_m = p[i];
  }
  make_sumlist(max_m);
  vector<double> kitaiti(N);
  for(int i=0; i<N; i++){
    kitaiti[i] = calc_kitaiti(p[i]);
  }
  double ans =0;
  double max_ans=0;
  for(int i=0; i<N; i++){
    if(i<K){
      ans += kitaiti[i];
      max_ans = ans;
      continue;
    }
    ans = ans+kitaiti[i]-kitaiti[i-K];
    max_ans = max_ans < ans ? ans : max_ans;
  }
  cout << fixed << setprecision(10) << max_ans << endl;
  return 0;
}

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

int main()
{
	int ans;
	int a, b, c;

	cin >> a >> b >> c;

	if( a == b ) {
		ans = c;
	}
	else if( a == c ) {
		ans = b;
	}
	else {
		ans = a;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>
#include <cstdint>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>
#define M_PI 3.14159265358979323846

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
pair <int, int> vu[8] = { {0,1}, {1,0} , {1,-1},{0,-1},{-1,0},{-1,1},{0,1}, {1,0} }; // EWSN

const int max_v = 2e5 + 7;
const int INF = 1e7 + 7;

string s;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);	
	ci(s);
	fa(i, 0, s.size()) if (s[i] == '?') s[i] = 'D';
	co(s);
	return 0;
}

Measured memory_bytes: 3784
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.bigint;

void main()
{
	foreach (line; stdin.byLine) {
		auto eqn = line.chomp.split("=");
		BigInt nnum, xnum;
		int i;
		bool zero;
		foreach_reverse (e; eqn[1]) {
			if (e == 'X') {
				xnum += 10.to!BigInt ^^ i;
				if (i == eqn[1].length-1 && i >= 1) {
					zero = 1;
				}
			} else {
				nnum -= (e - '0') * 10.to!BigInt ^^ i;
			}
			i++;
		}
		foreach (e; eqn[0].split("+")) {
			i = 0;
			foreach_reverse (ee; e) {
				if (ee == 'X') {
					xnum -= 10.to!BigInt ^^ i;
					if (i == e.length-1 && i >= 1) {
						zero = 1;
					}
				} else {
					nnum += (ee - '0') * 10.to!BigInt ^^ i;
				}
				i++;
			}
		}
		
		bool f;
		foreach (j; zero.to!int..10) {
			if (nnum == xnum * j) {
				j.writeln;
				f = 1;
			}
		}
		if (!f) {
			writeln("NA");
		}
	}
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

//空文字列はなし！
//forever ei1333
class SuffixArray{
    vec<int> SA;
    const string S;
    int N;
public:
    SuffixArray(const string& S):S(S){
        N = S.size();
        SA.resize(N);
        iota(SA.begin(),SA.end(),0);
        sort(SA.begin(),SA.end(),[&](int i,int j){
            return S[i]==S[j]? i>j:S[i]<S[j];
        });
        vec<int> classes(N),C(S.begin(),S.end()),cnt(S.size());
        for(int len=1;len<N;len<<=1){
            for(int i=0;i<N;i++){
                if(i>0 && C[SA[i-1]]==C[SA[i]] && 
                SA[i-1]+len<N && C[SA[i-1]+len/2]==C[SA[i]+len/2]){
                    classes[SA[i]] = classes[SA[i-1]];
                }else{
                    classes[SA[i]] = i;
                }
            }
            iota(cnt.begin(),cnt.end(),0);
            copy(SA.begin(),SA.end(),C.begin());
            for(int i=0;i<N;i++){
                int sl = C[i]-len;
                if(sl>=0) SA[cnt[classes[sl]]++] = sl;
            }
            classes.swap(C);
        }
    }

    int operator[](int k)const{
        return SA[k];
    }

    int size()const{
        return N;
    }

    bool lt_substr(const string& T,int si=0,int ti=0){
        int sn = N,tn = T.size();
        while(si<sn && ti<tn){
            if(S[si]<T[ti]) return true;
            if(S[si]>T[ti]) return false;
            si++; ti++;
        }
        return si>=sn && ti<tn;
    }

    int lower_bound(const string& T,int si=0,int ti=0){
        int l = -1,r = N;
        while(l+1<r){
            int m = (l+r)>>1;
            (lt_substr(T,SA[m])? l:r) = m;
        }
        return r;
    }

    P<int,int> lower_upper_bound(string& T){
        int id = lower_bound(T);
        int l = id-1,r = N;
        T.back()++;
        while(l+1<r){
            int m = (l+r)>>1;
            (lt_substr(T,SA[m])? l:r) = m;
        }
        T.back()--;
        return {id,r};
    }

};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    SuffixArray SA(S);
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        string T;
        cin >> T;
        auto r = (SA.lower_upper_bound(T));
        cout << (r.first!=r.second) << endl;
    }
}


Measured memory_bytes: 19696
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  map<int,int> m;
  REP(i,4){
    int N;
    cin>>N;
    m[N]+=1;
  }
  if(m[1]*m[9]*m[4]*m[7]!=0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        long K = stdIn.nextLong();
        stdIn.close();   
        
        Queue<Long> queue = new ArrayDeque<Long>();
        for (long i = 1; i <= 9; i++) queue.add(i);

        long count = 0;
        long x = 0;
        while (count != K) {
            x = queue.remove();
            if (x % 10 != 0) {
                queue.add((10 * x) + (x % 10) - 1);
            }
            queue.add((10 * x) + (x % 10));
            if (x % 10 != 9) {
                queue.add((10 * x) + (x % 10) + 1);
            }
            count++;
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 30036
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=1000010;

int n,a[maxn],fac[maxn];

inline void pairwise()
{
	for(int i=1;i<=n;i++) if(a[i]!=1)
	{
		if(fac[a[i]]) return;
		fac[a[i]]=1;

		for(int j=2;j*j<=a[i];j++) if(a[i]%j==0)
		{
			if(fac[j]||fac[a[i]/j]) return;
			fac[j]=fac[a[i]/j]=1;
		}
	}

	PF("pairwise coprime");
	exit(0);
}

inline void setwise()
{
	int g=a[1];
	for(int i=2;i<=n;i++) g=__gcd(g,a[i]);

	if(g==1)
	{
		PF("setwise coprime");
		exit(0);
	}
}

int main()
{
	SF("%d",&n);
	for(int i=1;i<=n;i++) SF("%d",&a[i]);

	pairwise();
	setwise();

	PF("not coprime");

	return 0;
}

Measured memory_bytes: 8036
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 0;i < n;++i) {
		int tmp;
		cin >> tmp;
		cnt += tmp % 2;
	}
	cnt %= 2;
	if (cnt == 0)
	cout << "YES" << endl;
	else 
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a, b;
	cin >> a >> b;
	bool at = ( a == 'H');
	bool top = (b == 'H');
	if (at && top)
	{
		cout << 'H' << endl;
	}else if (at != top)
	{
		cout << 'D' << endl;
	}else{
		cout << 'H' << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
    if(i%2 == 0)
      cout << s[i];
  }
  cout << endl;
  return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  repLRE(i, 1, n) {
    ll b, q;
    for (ll j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        b = j;
        q = i / j;
        ll add = min(i + b - 1, n) - (i + k) + 1;

        if (add > 0 && b > k) {
          ans += add;
        }
        add = min(i + q - 1, n) - (i + k) + 1;
        if (add > 0 && b != q && q > k) {
          ans += add;
        }
      }
    }
  }
  repLRE(b, 1, n) {
    ll add = b - max(k, 1LL);
    if (add > 0) {
       ans += add;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

inline bool check(int w, int limit, const vector<int> &x, const vector<int> &sum) {
	const int n = x.size();

	int mn_next = n;
	int mx_next = n;
	int cnt = 0;
	vector<bool> dp(n, false);

	for(int i = n - 1; i >= 0; --i) {
		if(sum[n] - sum[i] + 1 * (mn_next - i - 1) <= w) {
			dp[i] = true;
			continue;
		}

		while(sum[mn_next - 1] - sum[i] + 1 * (mn_next - i - 2) > w) {
			if(dp[--mn_next]) --cnt;
		}

		while(sum[mx_next - 1] - sum[i] + limit * (mx_next - i - 2) >= w) {
			if(dp[--mx_next]) ++cnt;
		}

		if(cnt) dp[i] = true;
	}

	return dp[0];
}

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

	for(int w, n; cin >> w >> n && w;) {
		vector<int> x(n);
		for(auto &e : x) cin >> e;

		vector<int> sum(n + 1);
		partial_sum(begin(x), end(x), begin(sum) + 1);

		int L = 0, R = w;
		while(L + 1 < R) {
			const int M = (L + R) / 2;
			if(check(w, M, x, sum)) {
				R = M;
			}
			else {
				L = M;
			}
		}

		cout << R << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1588
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 1010;

int h, w;
char a[N][N];
int dp[N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (!i && !j) continue;
      if (a[i][j] == '#') continue;
      if (i) dp[i][j] += dp[i-1][j];
      if (j) dp[i][j] += dp[i][j-1];
      dp[i][j] %= MOD;
      //cerr << dp[i][j] << " ";
    }
    //cerr << nl;
  }
  cout << dp[h-1][w-1] << nl;
  return 0;
}


Measured memory_bytes: 5248
import java.util.*;
public class Main
{
 public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String S=sc.nextLine();
    if(S.charAt(2)==S.charAt(3)&&S.charAt(4)==S.charAt(5))
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 22868
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nl = readn::<usize>(" ");
    let n = nl[0];
    let l = nl[1];

    let a = readn::<usize>(" ");

    let mut last = 0;
    for i in 1..n {
        if a[i-1] + a[i] >= l {
            last = i;
            break;
        }
    }
    if last == 0 {
        println!("Impossible");
    } else {
        println!("Possible");
        let mut ans = "".to_string();
        for i in 1..last {
            ans = ans + &(i.to_string()) + "\n";
        }
        for i in (last+1..n).rev() {
            ans = ans + &(i.to_string()) + "\n"
        }
        ans = ans + &(last.to_string());
        println!("{}", ans);
    }
}

Measured memory_bytes: 9976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll a,b;cin >> a >>b;
    if(abs(a-b)<=1)cout << "Brown" <<endl;
    else cout << "Alice" <<endl;
}

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

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

ll q, t, a, b, c, d, m, n, k;
ll cnt, Mn, Mx, sum, sum1, sum2, ck;
ll arr1[1000], arr2[1000];

map <ll, ll> mp1, mp2;
set <ll> st1, st2;
vector <ll> vec1, vec2;
string str1, str2, str3;

int main()
{
    FIO;
    cin >> n >> a >> b;
    c = n / (a+b);
    n %= (a+b);
    m = c * a + min(a, n);
    cout << m << endl;

    return 0;
}


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

int h,w;
int maps[1401][1401];
int memo[1401][1401];
int ans=INT_MIN;

int dp(int y,int x){
  if(y > h || y <= 0 || x > w || x <= 0)return memo[y][x]=0;

  if(memo[y][x] != -1)return memo[y][x];

  int res = min(min(dp(y,x-1),dp(y-1,x)),dp(y-1,x-1))+1;

  // cout<<"("<<y<<","<<x<<")"<<res<<endl;

  if(maps[y][x] == 1)return memo[y][x]=0;

  ans = max(ans,res);

  return memo[y][x] = res;
}

int main(){
  cin>>h>>w;
  memset(memo,-1,sizeof(memo));
  //  for(int i=0;i<=h;i++)maps[i][0]=1;
  //  for(int i=0;i<=w;i++)maps[0][i]=1;
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	cin>>maps[i][j];
      }
    }
    dp(h,w);
    cout<<ans*ans<<endl;
}

Measured memory_bytes: 16584
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,k;
int mini;
int a[110];
bool dp[100010];
bool mark[100010];

bool resi(int br)
{
    if(br<mini)
        return false;
    if(mark[br])
        return dp[br];

    mark[br]=true;

    bool sol=true;
    for(int i=0;i<n;i++)
        if(a[i]<=br)
           sol=sol&resi(br-a[i]);

    dp[br]=!sol;
    return dp[br];
}


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

	cin>>n>>k;
	for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
	mini=a[0];
	cout<<(resi(k)?"First":"Second");
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h> 
using namespace std;
long long int lcm(long long int a, long long int b) 
{ 
	return (a*b)/__gcd(a, b); 
} 
// Driver program to test above function 
int main() 
{ 
	long long int a ,b;
    cin>>a>>b;
	cout<<lcm(a, b); 
	return 0; 
} 

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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var Q = sc.nextLong();
        var H = sc.nextLong();
        var S = sc.nextLong();
        var D = sc.nextLong();
        var N = sc.nextLong();

        long one = Math.Min(Math.Min(Q * 4, H * 2), S);
        long two = Math.Min(one * 2, D);

        if (N % 2 == 0) {
            WriteLine(N / 2 * two);
        } else {
            WriteLine((N / 2 * two) + one);
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef pair<int ,int> P;
int inf = 100000000;

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

    int a = n%10;//nの1の位
    n = n/10;
    int b = n%10;//nの10の位
    n = n/10;
    int c = n%10;//nの100の位
    n = n/10;
    int d = n%10;//nの1000の位

    if(a == b && b == c) cout << "Yes" << endl;
    else if(b == c && c == d) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,n;
  int height[20] = {};
  int result=0;
  int max=0;
  
  if(scanf("%d", &n) < 1){
    exit(1);
  }
  
  for(i = 0; i < n; i++){
    if(scanf("%d", &height[i]) < 1){
        exit(1);
    }
  }
  
  for(i = 0; i < n; i++){
      if(height[i] >= max){
          result++;
      }
      if(max < height[i]){
          max = height[i];
      }
  }
  

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


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	string s;
	cin >> s;
	//std::cin >> a >> b >> c;
	if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c') {
		cout << "Yes" << "\n";
	}
	else if (s[0] == 'a' && s[1] == 'c' && s[2] == 'b') {
		cout << "Yes" << "\n";
	}
	 else if (s[0] == 'b' && s[1] == 'a' && s[2] == 'c') {
		cout << "Yes" << "\n";
	}
	 else if (s[0] == 'b' && s[1] == 'c' && s[2] == 'a') {
		 cout << "Yes" << "\n";
	 }
	 else if (s[0] == 'c' && s[1] == 'a' && s[2] == 'b') {
		 cout << "Yes" << "\n";
	 }
	 else if (s[0] == 'c' && s[1] == 'b' && s[2] == 'a') {
		 cout << "Yes" << "\n";
	 }
	 else {
		 cout << "No" << "\n";
	 }
	std::cin >> e;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    final double EPS = 1.0e-10;
    final int INF = 1 << 28;

    void run() {
        Scanner sc = new Scanner(System.in);
        int MAX = 1120;
        boolean[] isPrime = new boolean[MAX];
        int[] primes = new int[187];
        Arrays.fill(isPrime, true);
        int idx = 0;
        for (int i = 2; i < MAX; i++) {
            if (isPrime[i]) {
                primes[idx++] = i;
                for (int j = i * 2; j < MAX; j += i)
                    isPrime[j] = false;
            }
        }
        int dp[][][] = new int[187][MAX + 1][15];
        for (int i = 0; i < 187; i++) {
            for (int j = 0; j < MAX + 1; j++) {
                Arrays.fill(dp[i][j], 0);
                if (j == primes[i])
                    dp[i][j][1] = 1;
            }
        }
        for (int i = 0; i < 186; i++) {
            for (int j = 0; j < MAX + 1; j++) {
                for (int k = 1; k <= 14; k++) {
                    dp[i + 1][j][k] += dp[i][j][k];
                    if (j - primes[i+1] >= 0) {
                        dp[i + 1][j][k] += dp[i][j - primes[i+1]][k - 1];
                    }
                }
            }
        }
        while (true) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            if ((n | k) == 0)
                break;
            System.out.println(dp[186][n][k]);
        }

    }

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

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

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = Int[]
	l = n
	f = 1
	for i in 1:n
		if f == 1
			push!(b,a[i])
		else
			unshift!(b,a[i])
		end
		f *= -1
	end
	if f == 1
		for i in 1:n-1
			print(b[i]," ")
		end
		println(b[n])
	else
		for i in n:-1:2
			print(b[i]," ")
		end
		println(b[1])
	end
end

main()

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

int main(){
    int A,B;
    string S,T,U;

    cin >> S >> T >> A >> B >> U;

    if(S==U){
        A--;
    }
    else if(T==U){
        B--;
    }

    cout << A << ' ' << B;







    return 0;
}


Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 11 - 04 - 20  |
// Atcoder BC 162|
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t;
  while(t--){
  	//cout << "Case :" << c - t << ": ";
  	int n;
  	cin >> n;
  	if(n%10 == 7 || (n/10)%10 == 7 || (n/100)%10 == 7) cout << "Yes\n";
  	else cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int n, a, b;
int main(){
    cin>>n>>a>>b;

    cout<<min(a, b)<<" "<<max(a+b-n, 0)<<endl;
    return 0;
}

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

bool isPrime(int n) {  
	for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 

int main(){
	int x;
	cin >> x;
	for (int i = x; i < 2 * x; i++){
		if (isPrime(i)){
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, max;
    int[] t = new int[24 * 3600];
    String s;
    char[] c;

    for(;;){
      n = sc.nextInt(); if(n == 0)break;
      for(i = 0;i < 24 * 3600;i++)t[i] = 0;
      for(;n-- > 0;){
        s = sc.next();
        c = new char[s.length()];
        for(i = 0;i < s.length();i++)c[i] = s.charAt(i);
        t[readint(c, 0, 2) * 3600 + readint(c, 3, 5) * 60 + readint(c, 6, 8)]++;
        s = sc.next();
        c = new char[s.length()];
        for(i = 0;i < s.length();i++)c[i] = s.charAt(i);
        t[readint(c, 0, 2) * 3600 + readint(c, 3, 5) * 60 + readint(c, 6, 8)]--;
      }
      max = -1;
      for(i = 1;i < 24 * 3600;i++){
        t[i] += t[i - 1];
        if(max < t[i])max = t[i];
      }
      out.println(max);
    }

    sc.close();
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res, s;
    d = 1; res = 0; s = 1;
    if(ch[l] == '-'){ s = -1; l++; }
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res * s;
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 72844
// https://atcoder.jp/contests/abc145/tasks/abc145_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    cout << N * N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N), b(N);
  REP(i, N) cin >> a[i] >> b[i];
  vector<int> c(M), d(M);
  REP(i, M) cin >> c[i] >> d[i];
  REP(i, N) {
    ll dis = 1e16;
    int coor = -1;
    REP(j, M) {
      ll disnow = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (disnow < dis) {
        coor = j;
        dis = disnow;
      }
    }
    cout << coor + 1 << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

edge = floyd_warshall(edge)
    
for i in range(n):
    for j in range(n):
        if edge[i][j]<=l:
            edge[i][j] = 1
        else:
            edge[i][j] = 0
                
edge = floyd_warshall(edge)

q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if edge[s-1][t-1] == float("inf"):
        print(-1)
    else:
        print(int(edge[s-1][t-1] - 1))

Measured memory_bytes: 17624
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1LL<<60)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main()
{
  int N;
  ll a[1024];
  while(1){
    cin >> N;
    if(N == 0) break;
    rep(i, N){
      string s;
      cin >> s;
      if(s == "x"){
	a[i] = -INF-1;
      }else{
	a[i] = stoi(s);
      }
    }

    ll b[2];
    b[0] = -INF;
    b[1] = INF;
    int flag = 0;
    rep(i, N){
      if(a[i] == -INF-1) continue;
      if(i&1) b[i&1] = min(b[i&1], a[i]);
      else b[i&1] = max(b[i&1], a[i]);
    }

    rep(i, N-1){
      if(a[i] == -INF-1) continue;
      if(a[i+1] == -INF-1) continue;
      if(i&1 && a[i] < a[i+1]) flag = 1;
      if((i&1) == 0 && a[i] > a[i+1]) flag = 1;
    }

    ll b1[2]; b1[0] = -INF; b1[1] = INF;
    if(a[0] == -INF-1) b1[1] = min(b1[1], a[1]);
    for(int i=1;i<N-1;i++){
      if(a[i] != -INF-1) continue;
      if(i&1) b1[0] = max(b1[0], max(a[i-1], a[i+1]));
      else b1[1] = min(b1[1], min(a[i-1], a[i+1]));
    }
    if(a[N-1] == -INF-1){
      if((N-1)&1) b1[0] = max(b1[0], a[N-2]);
      else b1[1] = min(b1[1], a[N-2]);
    }

    //    cout << b[0] << " " << b[1] << endl;
    //    cout << b1[0] << " " << b1[1] << endl;

    if((b[1] == INF && b[0] == -INF) || flag || b1[1] - b1[0] < 2){
      cout << "none\n";
    }else if(b1[1] - b1[0] == 2){
      cout << b1[0] + 1 << endl;      
    }else{
      cout << "ambiguous\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>

int h,heap[500000];

void maxHeapify(int *,int);
void buildMaxHeap(int *);

int main(){
  int i;
  scanf("%d",&h);
  for(i=1;i<h+1;i++) scanf("%d",heap+i);
  buildMaxHeap(heap);
  for(i=1;i<h+1;i++) printf(" %d",heap[i]);
  printf("\n");
}

void maxHeapify(int *a,int i){
  int l,r,largest,exchange;
  l=i*2;
  r=i*2+1;
  if(l<=h && a[i]<a[l]) largest=l;
  else largest=i;
  if(r<=h && a[largest]<a[r]) largest=r;
  if(largest!=i){
    exchange=a[largest];
    a[largest]=a[i];
    a[i]=exchange;
    maxHeapify(a, largest);
  }
}

void buildMaxHeap(int *a){
  int i;
  for(i=h/2;i>0;i--) maxHeapify(a,i);
}



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


def calc(n):
    if n % 2 == 0:
        kosuu = (n - 2) // 2
        kosuu += 1
        if kosuu % 2 == 0:
            res = n
        else:
            res = n ^ 1

    else:
        kosuu = (n - 1) // 2
        kosuu += 1
        if kosuu % 2 == 0:
            res = 0
        else:
            res = 1
    return res


print(calc(a - 1) ^ calc(b))


Measured memory_bytes: 3060
#include <iostream>			//cout,endl,cin
#include <string>			//string,to_string,stoi
#include <vector>			//vector
#include <algorithm>		//min,max,swap,sort,reverse,lower_bound,upper_bound
#include <utility>			//pair,make_pair
#include <tuple>			//tuple,make_tuple
#include <cstdint>			//int64_t,int*_t
#include <cstdio>			//printf
#include <map>				//map
#include <queue>			//queue,priority_queue
#include <set>				//set
#include <stack>			//stack
#include <deque>			//deque
#include <unordered_map>	//unordered_map
#include <unordered_set>	//unordered_set
#include <bitset>			//bitset
#include <cctype>			//isupper,islower,isdigit,toupper,tolower
#include <math.h>
#include <cstdio>
#include <cstring>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
    int k, n;
    ll c = 0;
    cin >> n >> k;
    vector<int> vc;
    while (n--) {
        int x;
        cin >> x;
        vc.push_back(x);
    }
    sort(vc.begin(), vc.end());
    for (int i = 0; i < k; i++) {
        c += vc[i];
    }
    cout << c << endl;
}

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

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(),v.end());
  if(v[0] == 5 && v[1] == 5 && v[2] == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n;
  while(cin>>n){
    double now=n,sum=n;
    for(int j=0;j<9;j++){
      if(j%2==0){
	now=now*2;
	sum+=now;
      }else if(j%2==1){
	now=now/3;
	sum+=now;
      }
    }
    printf("%.8f\n",sum);
  }
  return 0;
}

Measured memory_bytes: 3104
S = input()
S_r = S[::-1]
dire = ['dream','dreamer','erase','eraser']
dire_r = [0]*4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0

excep = 0

while ind  <len(S_r):
    if excep == 1:
        break
    flag2= 0
    for j in range(4):
        if flag2 ==0:
            case = 0
            for k in range(len(dire_r[j])):
                tmp = dire_r[j]

                if ind + k < len(S_r) and case == 0:
                #    print(j)
            #        print('S:'+S_r[ind+k])
            #        print('dire:'+tmp[k])
                    if S_r[ind+k] != tmp[k]:
                        flag = 0
                        case = 1
                        if j == 3:
                            excep = 1

                    elif k== len(dire_r[j])  -1:
                        ind = ind + len(dire_r[j])
                        flag = 1
                        case = 1
                        flag2 = 1


if flag == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
import sys

def solve():
    n = int(sys.stdin.readline().rstrip())
    a = list(map(int, sys.stdin.readline().split()))
    b = compress(a)

    ft = FenwickTree(max(b) + 1)
    ans = 0

    for bi in reversed(b):
        ans += ft.psum(bi + 1)
        ft.add(bi, 1)

    print(ans)

def compress(a):
    n = len(a)
    a = [(ai, i) for i, ai in enumerate(a)]
    a.sort()

    num = -1
    p = -1

    b = [None] * n

    for val, idx in a:
        if val > p:
            num += 1

        b[idx] = num
        p = val

    return b

class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.b = [0] * (n + 1)

    def add(self, i, x):
        i += 1

        while i <= self.n:
            self.b[i] += x
            i += i & (-i)

    def psum(self, r):
        res = 0

        while r > 0:
            res += self.b[r]
            r -= r & (-r)

        return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 44468
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long d,n;
  cin >> d >> n;
  if(n != 100){
	switch (d){
	case 0:
	  cout << n << endl;
	  break;
	case 1:
	  cout << 100 * n << endl;
	  break;
	case 2:
	  cout << 10000 * n << endl;
	  break;
	default:
	  break;
	}
  }
  else{
	switch (d){
	case 0:
	  cout << 101 << endl;
	  break;
	case 1:
	  cout << 10100 << endl;
	  break;
	case 2:
	  cout << 1010000 << endl;
	  break;
	default:
	  break;
	}	
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

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

	ll st = 0;
	ll nd = 1;
	ll rd = 2;
	
	ll ans = 0;

	while(st<n-2){
		while(nd<n-1)
		{
			for (ll c = rd; c < n;c++){
				if (l[st] + l[nd] > l[c])
				{
					if(l[st]!=l[nd] && l[st]!=l[c] && l[nd]!=l[c]){
						ans++;
					}
				}
			}
			nd++;
			rd++;
		}
		st++;
		nd = st + 1;
		rd = st + 2;
	}

	cout << ans << endl;
}

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



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

#define ll long long
#define ull unsinged long long
#define all(x) x.begin(), x.end()
#define endl "\n"

using namespace std;

int main (){
    //freopen("input.txt", "r", stdin);

    char ch[10];
    scanf("%s", ch);
    if(ch[2]==ch[3] && ch[4]==ch[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if (u==s)
        a=a-1;
    else if (u==t)
        b=b-1;
    cout<<a<<" "<<b;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 305;
const int MM = 1000000007;

ll pw2[MX*MX];
int N;

ll DP[MX][MX][MX];
int C[MX][MX];

int main()
{
	pw2[0] = 1;
	for(int i = 1; i < MX*MX; i++) pw2[i] = pw2[i-1] * 2 % MM;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++) scanf("%d", C[i]+j);
	}
	/*

	int tot = 0;

	for(int i = 0; i < 1<<N*N; i++){
		for(int j = 0; j < 1<<N*N; j++){
			int A[MX][MX] = {};
			for(int p = 0; p < N; p++){
				for(int q = 0; q < N; q++){
					for(int r = 0; r < N; r++){
						if( i&1<<p*N+q && j&1<<q*N+r ) A[p][r] ^= 1;
					}
				}
			}
			int ch = 1;
			for(int p = 0; p < N; p++){
				for(int q = 0; q < N; q++){
					if( A[p][q] != C[p+1][q+1] ) ch = 0;
				}
			}
			tot += ch;
		}
	}
	printf("%d\n", tot);
// */
	int K = 0, cur = 1;
	for(int i = 1; i <= N; i++){
		for(int j = cur; j <= N; j++){
			if( C[j][i] == 1 ){
				for(int k = 1; k <= N; k++) swap(C[j][k], C[cur][k]);
				break;
			}
		}
		if( C[cur][i] == 0 ) continue;
		for(int j = cur+1; j <= N; j++){
			if( !C[j][i] ) continue;
			for(int k = 1; k <= N; k++){
				C[j][k] ^= C[cur][k];
			}
		}
		K++; cur++;
	}

	DP[0][0][0] = 1;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= K; j++){
			for(int k = j; k <= N; k++){
				DP[i][j][k] = DP[i-1][j][k] * pw2[k] % MM;
				if( j && k ) DP[i][j][k] = (DP[i][j][k] + DP[i-1][j-1][k-1] * (pw2[K+(k-j)] - pw2[k-1] + MM)) % MM;
				if( k ) DP[i][j][k] = (DP[i][j][k] + DP[i-1][j][k-1] * (pw2[N] - pw2[K+k-1-j] + MM*2)) % MM;
//				printf("%d %d %d %lld\n", i, j, k, DP[i][j][k]);
			}
		}
	}
	ll ans = 0;
	for(int i = K; i <= N; i++){
//		printf("%d %d %d %lld\n", N, K, i, DP[N][K][i]);
		ans = (ans + DP[N][K][i] * pw2[(N-i)*N]) % MM;
	}
	printf("%lld\n", ans);
}


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

int main() {
    int n;
    cin >> n;
    int* x = new int[n];
    int* y = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    double d1 = 0.0;
    double d2 = 0.0;
    double d3 = 0.0;
    double di = 0.0;
    for (int i = 0; i < n; i++) {
        x[i] - y[i] > 0 ? d1 += (double)x[i] - (double)y[i] : d1 += (double)y[i] - (double)x[i];
        d2 += pow((x[i] - y[i]), 2.0);
        x[i] - y[i] > 0 ? d3 += pow(x[i] - y[i], 3.0) : d3 += pow(y[i] - x[i], 3.0);
        if (x[i] - y[i] > 0) {
            di < (double)x[i] - (double)y[i] ? di = (double)x[i] - (double)y[i] : di = di;
        }
        else {
            di < (double)y[i] - (double)x[i] ? di = (double)y[i] - (double)x[i] : di = di;
        }
    }
    printf("%lf\n%lf\n%lf\n%lf\n", d1, sqrt(d2), pow(d3, double((double)1.0 / (double)3.0)), di);
    return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int (i) = 0; (i) < (N); (i)++)

int main(){

    string S;
    cin >> S;

    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3552