akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {

	public static long[] tree;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] height = new int[n];
		int[] beauty = new int[n];
		long[] dp = new long[n + 1];
		String[] s = br.readLine().split(" ");
		for (int i = 0; i < n; i++)
			height[i] = Integer.parseInt(s[i]);

		s = br.readLine().split(" ");
		for (int i = 0; i < n; i++)
			beauty[i] = Integer.parseInt(s[i]);

		int b = 1;
		while (b < n)
			b *= 2;
		tree = new long[b * 2]; // segment tree stores max beauty in given range
								// we treat the segment tree as storing beauties of flowers w/
								// heights going from 1 -> n
		for (int i = 0; i < n; i++) {
			int k = b + height[i]-1;
			long max = 0;
			while (k > 1) { // because queries will always be from 1-height[i], we never care about right
								// side only care about left side (we are on right side)
//				System.out.println(k);
				if (k % 2 == 1)
					max = Math.max(max, tree[k - 1]); //bottom up; if sibling, compare
				k /= 2;
			}
//			System.out.println(max + "*");
			dp[height[i]] = beauty[i] + max; // dp[x] now represents the max beauty of flower w/
												// height i where it currently stands. if shorter flower
												// comes later, then shorter will have 0, which is ignored.
			k =b + height[i]-1;
			while (k >= 1) {
				tree[k] = Math.max(tree[k], dp[height[i]]);
				k /= 2;
			}
			
//			for (int e = 1; e < b*2; e++)
//				System.out.print(tree[e] + " ");
//			System.out.println();
//			for (int j = i; j >= 0; j--) {
//				if (height[j] < height[i] && dp[j] > max)
//					max = dp[j];
//			}
			// old n^2 approach TLE where dp[i] represents
			// the max beauty if the i'th flower was chosen

		}
		System.out.println(tree[1]);
//		for (long t : dp) System.out.print(t + " ");
//		System.out.println(dp[n - 1]);
	}

}


Measured memory_bytes: 78332
def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    search_table = [False]*N
    itr = 0
    ret = 0
    while not search_table[itr]:
        search_table[itr] = True
        itr = A[itr]-1
        ret += 1
        if itr == 1: break
    
    print(ret if itr == 1 else -1)
    
solve()

Measured memory_bytes: 7852
#include <iostream>
//#include <conio.h>
using namespace std;

int main() {
	//scc何組か
	unsigned long s; unsigned long c; unsigned long ans;
	cin >> s >> c;
	if (s * 2 >= c) cout << c / 2 << endl;
	else {
		c = c / 2;
		cout << (s + c) / 2 << endl;
	}
	//_getch();
}



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

int main() {
    string o, e;
    cin >> o >> e;

    rep(i, o.size()) {
        cout << o.at(i);
        if (e.size() > i) 
            cout << e.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
      	int B = sc.nextInt();
     	int C = sc.nextInt();
      	int D = sc.nextInt();
      if(Math.abs(A - C) <= D){
        System.out.println("Yes");
      }else if(Math.abs(A - B) <= D && Math.abs(C - B) <= D){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
	}
}



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

int main(int argc, char const *argv[])
{
    int x = 1;

    std::vector<int> v;

    while (1)
    {
        std::cin >> x;
        if (x != 0)
        {
            v.push_back(x);
        }
        else
        {
            break;
        }
    }

    for (int i = 0; i != v.size(); i++)
    {
        std::cout << "Case " << i + 1 << ": " << v[i] << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3160
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b;
  while (cin >> a >> b) {
    int sum = a + b;
    int ans = 0;
    while (0 < sum) {
      ans++;
      sum /= 10;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3064
import sys
import math

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = 0
# iとjの距離は(2/N)回足される
XY = [lr() for _ in range(N)]
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = XY[i]
        x2, y2 = XY[j]
        length = ((x1-x2) ** 2 + (y1-y2) ** 2) ** .5
        answer += length

answer *= 2 / N
print(answer)


Measured memory_bytes: 3064
#include <stdio.h>
int main() {
    int n; 
    long tmp;
    long max = -1000000;
    long min = 1000000;
    long sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%ld", &tmp);
        max = max < tmp ? tmp : max; 
        min = min > tmp ? tmp : min;
        sum += tmp;
    }
    printf("%ld %ld %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2704
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <set>

using namespace std;

int field[10][10];
int n;

int bfs(int ss){
	set<int> passed;
	queue<int> q[2];
	int cur=0;
	int nxt=1;
	q[cur].push(ss);
	int cnt=0;
	passed.insert(ss);
	while(q[cur].size()){
		while(q[cur].size()){
			int cs=q[cur].front();
			if(cs==0)return cnt;
			q[cur].pop();
			// csÌóÔ©çÚ®Å«éóÔðñ
			int minx,miny;
			minx=miny=-1;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if((cs>>(i*n+j))&1){
						minx=j;
						miny=i;
						break;
					}
				}
				if(minx!=-1)break;
			}
			// EºÌÀWðè
			for(int i=miny;i<n;i++){
				for(int j=minx;j<n;j++){
					// ½]
					int ns=cs;
					for(int k=miny;k<=i;k++){
						for(int l=minx;l<=j;l++){
							if((ns>>(k*n+l))&1)ns&=~(1<<(k*n+l));
							else ns|=(1<<(k*n+l));
						}
					}
					if(passed.find(ns)==passed.end()){
						q[nxt].push(ns);
						passed.insert(ns);
					}
				}
			}
		}
		cnt++;
		swap(cur,nxt);
	}
	return -1;
}

int main(){
	while(cin>>n&&n){
		int ss=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>field[i][j];
				if(field[i][j])ss|=(1<<(i*n+j));
			}
		}
		int cnt=bfs(ss);
		for(int i=0;i<cnt;i++)cout<<"myon";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 6872
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  long long int n; cin >> n;
  long long int a=sqrt(n);
  long long int ans=n-1;
  if(n==2){
    cout << "0" << endl;
  }
  else{
  for(long long int i=2;i<=a+1;i++){
    if(n%i==0){
      if(n%(i-1)==n/(i-1)){
        ans=ans+i-1;
      }
      if(n%(n/i-1)==n/(n/i-1)){
        ans=ans+n/i-1;
      }
    }
  }
    
  cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n/2] - a[n/2-1];
}


Measured memory_bytes: 1024
h, w, k = map(int, input().split())
cl = []
for i in range(h):
  c = str(input())
  cl.append(c)

ttcl = [x for x in zip(*cl)]
tcl = []
for i in range(len(ttcl)):
  tt = "".join(ttcl[i])
  tcl.append(tt)

n = h
hb = ['0'] * n
hbl = []
for bit in range(1 << n):
  for i in range(n):
    if (bit >> i) & 1:
      hb[i] = '1'
    else:
      hb[i] = '0'
  hbl.append("".join(hb))

n = w
wb = ['0'] * n
wbl = []
for bit in range(1 << n):
  for i in range(n):
    if (bit >> i) & 1:
      wb[i] = '1'
    else:
      wb[i] = '0'
  wbl.append("".join(wb))

rc = 0
for i in range(len(hbl)):
  for j in range(len(wbl)):
    tbc = 0
    for m in range(h):
      for n in range(w):
        if (hbl[i][m] == '1') and (wbl[j][n] == '1'):
          if cl[m][n] == '#':
            tbc += 1
    if tbc == k:
      rc += 1
print(rc)

Measured memory_bytes: 9196
S=input()
N=len(S)
dp=[[0]*13 for i in range(N+1)]
mod=10**9+7
s=[1]
dp[0][0]=1
for i in range(N):
  s.append((s[-1]*10)%13)
for i in range(N):
  for k in range(13):
    if S[N-i-1]=="?":
      for j in range(10):
        dp[i+1][(k+j*s[i])%13]+=dp[i][k]
        dp[i+1][(k+j*s[i])%13]%=mod
    else:
      dp[i+1][(k+int(S[N-i-1])*s[i])%13]+=dp[i][k]
      dp[i+1][(k+int(S[N-i-1])*s[i])%13]%=mod
print(dp[N][5])   
#print(dp)

Measured memory_bytes: 67752
import itertools
def main(n,m):
    a = list(map(int, input().split()))
    select = list(itertools.combinations(range(n), 2))
    ans = 0
    for x,y in select:
        if ans < a[x] + a[y] <= m:
            ans = a[x] + a[y]
    if ans == 0:
        print("NONE")
    else:
        print(ans)
    return 1
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    main(n,m)


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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater());
  if(s < t){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	int n, a[20], b[20], c[19], ans = 0;
	cin >> n;
	for (int a1 = 0; a1 < n; a1++) {
		cin >> a[a1];
	}
	for (int b1 = 0; b1 < n; b1++) {
		cin >> b[b1];
		ans += b[b1];
	}
	for (int c1 = 0; c1 < n - 1; c1++) {
		cin >> c[c1];
	}
	for (int i = 1; i < n; i++) {
		if (a[i] - 1 == a[i - 1]) {
			ans += c[a[i - 1] - 1];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int YYQ=1e9+7;
int n,head[3030],tail[3030];
string s;
vector<int> z;
int inv[3030]={0,1},f[3030]={1,1},ff[3030]={1,1};
void pre(){
	for(int i=2;i<=n;i++){
		inv[i]=(YYQ-YYQ/i)*inv[YYQ%i]%YYQ;
		f[i]=f[i-1]*i%YYQ;
		ff[i]=ff[i-1]*inv[i]%YYQ;
	}
}
signed main(){
	cin>>n>>s;
	pre();
	int cnt=1;
	for(int i=0;i<n-1;i++){
		if(s[i]=='<') cnt++;
		else{
			z.push_back(cnt);
			cnt=1;
		}
	}
	z.push_back(cnt);
	head[z.back()] = 1;
	z.pop_back();
	reverse(z.begin(),z.end());
	for(int i=0;i<z.size();i++){
		for(int j=0;j<=n;j++)	tail[j]=0;
		for(int j=0;j<=n;j++) 
			if(head[j]){
				tail[j+z[i]]=(tail[j+z[i]]+YYQ-head[j]) % YYQ;
				tail[z[i]]=(tail[z[i]]+head[j]*ff[j]) % YYQ;
			}
		for(int j=0;j<=n;j++)	head[j]=tail[j];
	}
	int sum=0;
	for(int j=0;j<=n;j++)
		sum=(sum+head[j]*ff[j])%YYQ;
	cout<<sum*f[n]%YYQ<<endl;
	return 0;
}

Measured memory_bytes: 384
function Main(input) {
  input.trim();
  input = input.split(" ").map(Number);
  var arr = new Array(input[0]).fill(114514);
  for(var i=0;i<input[1];i++){
    arr[i] = input[2];
  }
  console.log(arr.join(" "));
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}

Measured memory_bytes: 15948
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+5;
string a;
int n;
int cnt = 0, COUNT = 0;
signed main(){
	cin >> a;
	n = a.size();
	a = ' ' + a;
	a = a + ":v";
	for(int i=1;i<=n;i++){
		if(a[i] == 'A')	cnt++;
		else if(a[i]=='B'&&a[i+1]=='C'){
			COUNT += cnt;
			i++;
			continue;
		}
		else cnt = 0;
	}
	cout << COUNT;
}
 

Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
int main(){

int a,b;
cin>>a>>b;
if(a>=b){
  for(int i=0; i<a; i++){
    cout<<b;
  }
  }else{
    for(int i=0; i<b; i++){
      cout<<a;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mod 1000000007
using namespace std;
int n,K,m;
int f[2002][2002];
int fac[4000010],inv[4000010];
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int C(int x,int y)
{
    if(x<y)  return 0;
    return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    fac[0]=1;
    for(int i=1;i<=4000000;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    inv[4000000]=quick_pow(fac[4000000],mod-2);
    for(int i=3999999;i>=0;i--)   inv[i]=1ll*inv[i+1]*(i+1)%mod;
    cin>>n>>K;
    if(K==1)
    {
        puts("1");
        return 0;
    }
    m=n*K;
    f[0][0]=1;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(i)  f[i][j]=f[i-1][j];
            if(j)  f[i][j]=(f[i][j]+1ll*C(m-(j-1)*(K-1)-i-1,K-2)*f[i][j-1]%mod)%mod;
        }
    }
    int ans=1ll*f[n][n]*fac[n]%mod;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    int arr[3][3];
    bool visited[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> arr[i][j];
            visited[i][j] = 0;
        }
    }
    int n; cin >> n;
    while(n--){
        int b; cin >> b;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(arr[i][j] == b){
                    visited[i][j] = 1;
                }
            }
        }
    }
    bool ans = 0;
    if(visited[0][0] && visited[1][1] && visited[2][2])ans = 1;
    if(visited[0][2] && visited[1][1] && visited[2][0]) ans = 1;
    if(visited[0][0] && visited[0][1] && visited[0][2]) ans = 1;
    if(visited[1][0] && visited[1][1] && visited[1][2]) ans = 1;
    if(visited[2][0] && visited[2][1] && visited[2][2]) ans = 1;
    if(visited[0][0] && visited[1][0] && visited[2][0]) ans = 1;
    if(visited[0][1] && visited[1][1] && visited[2][1]) ans = 1;
    if(visited[0][2] && visited[1][2] && visited[2][2]) ans = 1;
    if(ans){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long max(int,long *);
long min(int,long *);
long sum(int,long *);


int main (void)
{
	int n,i;
	long a[10000],mi,ma,su;

	scanf("%d", &n);

	for(i=0;i<n;i++){
		scanf("%ld", &a[i]);
	}

	mi=min(n,a);
	ma=max(n,a);
	su=sum(n,a);

	printf("%ld %ld %ld\n", mi,ma,su);

	return 0;
}

long max(int n,long a[])
{
	int i;
	long max=a[0];

	for(i=0;i<n-1;i++){
		if(a[i+1]>max){
			max=a[i+1];
		}
	}

	return max;
}

long min(int n,long a[])
{
	int i;
	long min=a[0];

	for(i=0;i<n-1;i++){
		if(a[i+1]<min){
			min=a[i+1];
		}
	}

	return min;
}

long sum(int n,long a[])
{
	int i;
	long sum=0;

	for(i=0;i<n;i++){
		sum=sum+a[i];
	}
	return sum;
}

Measured memory_bytes: 676
#include<atcoder/all>
#include<iostream>

using namespace std;

using mint = atcoder::modint998244353;
typedef pair<mint, mint> P;

//matrix22
struct matrix22{
    mint val[2][2];
    mint *operator[](int x){return val[x];}
    matrix22(mint a=0, mint b=0, mint c=0, mint d=0){
        val[0][0] = a;
        val[0][1] = b;
        val[1][0] = c;
        val[1][1] = d;
    }    
};

P apply(matrix22 m, P p){
    return {m[0][0] * p.first + m[0][1] * p.second, m[1][0] * p.first + m[1][1] * p.second};
}

matrix22 mult(matrix22 x, matrix22 y){
    matrix22 ans;
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < 2;j++){
            for(int k = 0;k < 2;k++){
                ans[i][k] += x[i][j] * y[j][k];
            }
        }
    }
    return ans;
}

matrix22 e(){return matrix22(1, 0, 0, 1);}


P zero(){return P(0, 0);}

P sum(P a, P b){return {a.first + b.first, a.second + b.second};}

int main(){
    int n, q;
    cin >> n >> q;
    vector<P> a(n);
    for(auto &elem:a){
        int tmp;
        cin >> tmp;
        elem = {tmp, 1};
    }
    atcoder::lazy_segtree<
        P,
        sum,
        zero,
        matrix22,
        apply,
        mult,
        e> seg(a);
        

    while(q--){
        int t, l, r, b, c;
        cin >> t;
        if(t == 0){
            cin >> l >> r >> b >> c;
            seg.apply(l, r, matrix22(b, c, 0, 1));
        }
        if(t == 1){
            cin >> l >> r;
            cout << seg.prod(l, r).first.val() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 23276
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };

    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let n = scan!(i64);
    for i in 1.. {
        if i * i <= n && n < (i + 1) * (i + 1) {
            println!("{}", i * i);
            break;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define loop(i,a,b) for (int i=a; i<b; ++i)
using ll = long long;
const int mod = 1e9+7;
typedef pair<int , int> pairs;
typedef complex<ll> G;

//const int N = 205;

int power(int a,int b){
    if(!b)
        return 1;
    int c=power(a,b/2);
    c=(1LL*c*c)%mod;
    if(b%2)
        c=(1LL*c*a)%mod;
    return c;
}


void done() {


}

/*string solve_palindrome(const string& s)
{
    string a = s;
    reverse(a.begin(), a.end());
    //a = s + "#" + a;
    int c = 0;
    for (int i = 1; i < (int)a.size(); i++)
    {
        while (c != 0 && a[c] != a[i])
            c = pref[c - 1];
        if (a[c] == a[i])
            c++;
        pref[i] = c;
    }
    return s.substr(0, c);
}
*/
int now(int a, int b, int c) {
	if (a > b) {
		swap(a, b);
	}
	if (a > c) {
		swap(a, c);
	}
	if (b > c) {
		swap(b, c);
	}
	return a != b && b != c && a + b > c;
}
void solve()
{
    ll n , k, w;
    cin >> n >> k >> w;

    ll al, bl, cl , dl;
    ll ah, bh, ch , dh;

    vector<ll>l(n);
    for(int i= 0;i < k;++i) {
        cin >> l[i];
    }
    cin >> al >> bl >> cl >> dl;
    vector<ll>h(n);
    for(int i = 0;i < k;++i) {
        cin >> h[i];
    }
    cin >> ah >> bh >> ch >> dh;
    for(int i = k;i < n;++i) {
        l[i] = (al * l[i-2] + bl * l[i-1] + cl)%dl + 1;
    }
    for(int i = k;i < n;++i) {
        h[i] = (ah * h[i-2] + bh * h[i-1] + ch) % dh + 1;
    }

    for(auto f : l)cout << f << " " ;
    cout << '\n';
    for(auto c : h)cout << c << " ";
    cout << '\n';



}
void another() {
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0;i < n;++i) {
        cin >> a[i];
    }

    int ans = 0;
    set<tuple<int , int, int>>res;

    for(int i = 0;i < n;++i) {
        for(int j = i+1;j < n;++j) {
            for(int k = j+1;k < n;++k) {
                if(now(a[i], a[j], a[k])) ++ans;

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

}
void test_case() {
    int t;
    cin >> t;
    while(t--)solve();
}
int main() {

   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    another();
}


Measured memory_bytes: 3628
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, _a = 1;
  scanf("%lld%lld", &a, &b);
  ll count = (b - a) - 2;
  for (int i = 2; count; i++)
  {
    _a += i;
    count--;
  }
  printf("%lld\n", _a - a);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  char s[4];
  scanf("%s",s);
  int i;
  for(i=0;i<3;i++){
    if(s[i]=='1') s[i]='9';
    else if(s[i]=='9') s[i]='1';
  }
  printf("%s",s);
  return 0;
}


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

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

    int count = 0;
    int answer = 0;

    for(const auto c: s) {
        if(c == 'A') {
            count = 1;
        } else if(count == 1) {
            if(c == 'B') {
                ++count;
            } else {
                count = 0;
            }
        } else if(count == 2) {
            if(c == 'C') {
                ++answer;
            }
            count = 0;
        }
    }
    std::cout << answer;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>

using namespace std;

int main(void)
{
	vector <int> a;
	int temp;
	int count = 0; //count number 4n
	int count2 = 0; //count number 4n+2
	int n;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		if ((temp%4!=0) && (temp%2==0))
		{
			count2++;
		}
		
		else if (temp % 4 == 0)
		{
			count++;
		}
	}

	if (count + ((count2 / 2)) >= (n/2))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2001
#define MOD 1000000007

int main(){
  int n,k,a[MAX],
      i,j;
  long long before=0,after=0,whole,sum;
  
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)
    scanf("%d", &a[i]);
  
  for(i=0;i<n;i++){
    for(j=0;j<i;j++)
      if(a[i] > a[j])
        before++;
    for(j=i+1;j<n;j++)
      if(a[i] > a[j])
        after++;
  }
  whole = before + after;
  
  sum = whole*(((long long)k*(k-1)/2) % MOD) + after*k;
  printf("%lld\n",sum%MOD);
  
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	//"math"
)

func main() {
	var s string
	fmt.Scanf("%s ", &s)
	for i := 0;i<4;i++{
		c := 0
		for j := 0;j<4;j++{
			if(s[i] == s[j]){
				c++
			}
		}
		if(c != 2){
			fmt.Print("No")
			return
		}
	}
	fmt.Print("Yes")
}

Measured memory_bytes: 512
lists = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(int(lists[k-1]))

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }.toMutableList()

    for (i in 0 until n) {
        val key = xs[i]
        var j = i - 1
        while (j >= 0 && xs[j] > key) {
            xs[j + 1] = xs[j]
            j--
        }
        xs[j + 1] = key

        println(xs.joinToString(" "))
    }
}


Measured memory_bytes: 36036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,ans=0;
  string s;
  cin >>  n >> s;

  rep(i,1000){
    string t=to_string(i);
    if(sz(t)==1) t="00"+t;
    if(sz(t)==2) t="0"+t;
    int cnt=0;
    for(int j=0; j<n; j++){
      if(s[j]==t[cnt]) cnt++;
      if(cnt>=3) break;
    }
    if(cnt>=3) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String s = scanner.next();
        int ans = 700;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'o') {
                ans += 100;
            }
        }
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () {
            s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

using namespace std;

int main()
{
    int N,M;
    vector<int> MAP;
    vector<int> DICE;
    int temp;
    int pos;
    int ans;

    cin >> N >> M;
    while(N!=0 && M!=0) {
        pos=0;
        ans=0;
        for(int i=0; i<N; ++i) {
            cin >> temp;
            MAP.push_back(temp);
        }
        for(int i=0; i<M; ++i) {
            cin >> temp;
            DICE.push_back(temp);
        }

        for(int i=0; i<M; ++i) {
            if(pos<N-1) {
                pos+=DICE[i];
                if(pos<N-1) {
                    pos+=MAP[pos];
                }
                ++ans;
            }
        }
        cout << ans << endl;

        MAP.clear();
        DICE.clear();
        cin >> N >> M;
    }


    return 0;
}

Measured memory_bytes: 3048
#include <stdio.h>
int main(void){
      int N,W,dp[101][10001],weight[101],value[101],i,a,b;
      weight[0]=0;
      value[0]=0;
      scanf(" %d %d",&N,&W);
      for(i=1;i<=N;i++){
          scanf(" %d %d",&a,&b);
          value[i]=a;
          weight[i]=b;
      };
      
    
    for(a=1;a<=N;a++){
        for(b=0;b<=W;b++){
            if(weight[a]<=b){
                if(dp[a-1][b]<=(value[a]+dp[a-1][b-weight[a]])){
                    dp[a][b]=(value[a]+dp[a-1][b-weight[a]]);}
                    else{
                    dp[a][b]=dp[a-1][b];};
                }else{
                    dp[a][b]=dp[a-1][b];
                };
        };
    };
    printf("%d\n",dp[N][W]);
    return 0;
}



Measured memory_bytes: 5652
import java.util.Scanner;

public class Main {
    public static int count = 0;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);              //Scannerを初期化

        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(socketCalc(a, b));




    }
    public static int socketCalc(int a, int b) {
        int count = 0;
        int socketAmount = 1;

        while(socketAmount < b) {
            socketAmount += (a - 1);
            count++;
        }
        return count;
    }
}


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

using namespace std;

ifstream fin("f.in");
ofstream fout("f.out");

int main()
{
    int a, x;
    cin >> x >> a;
    if(x < a) cout << 0 << '\n';
    else cout << 10 << '\n';
    return 0;
}


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

int main() {
    vector<int> X(5);

    for (auto &&x : X) {
        cin >> x;
    }

    for (int i = 0; i < X.size(); ++i) {
        if (X[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

int n, m, x[10];
int c[10]={0,2,5,5,4,5,6,3,7,6};
string d[10005];

string f(string p, string q) {
	if(p.size()>q.size() || p.size()==q.size() && p>q) return p;
	return q;
}

int main() {
	int i, j, t;
	cin >> n >> m;
	while(m--) {
		cin >> t;
		x[c[t]] = max(x[c[t]], t);
	}
	for(i=1; i<=n; i++) d[i] = ".";
	d[0] = "";
	for(i=2; i<=n; i++) {
		for(j=2; j<=8; j++) {
			t = x[j];
			if(!t || i<j || d[i-j]==".") continue;
			d[i] = f(d[i], d[i-j] + char(t+'0'));
		}
	}
	cout << d[n];
	return 0;
}

Measured memory_bytes: 41600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        int n = input.nextInt();
        for(int i = 1; i <= n; i++){
            if(i%3 == 0 || i%10 == 3){
                build.append(" "+i);
                continue;
            }
            int x = i;
            while(true){
                x /= 10;
                if(x%10 == 3){
                    build.append(" "+i);
                    break;
                }
                if(x <= 3){
                    break;
                }
            }
        }
        System.out.println(build);
    }
}

Measured memory_bytes: 28364
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

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

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


void harmony()
{
  int a, b;
  cin >> a >> b;

  if (a % 2 == b % 2) cout << (a + b) / 2 << "\n";
  else cout << "IMPOSSIBLE\n";
}


void transfer()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << "\n";
}


void A_137()
{
  int a, b;
  cin >> a >> b;

  cout << max(a + b, max(a - b, a * b)) << "\n";
}


void red_or_not()
{
  int a;
  cin >> a;
  string s;
  cin >> s;

  if (a >= 3200) cout << s << "\n";
  else cout << "red\n";
}


void tenki()
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  for (int i = 0; i < 3; ++i)
  {
    if (s[i] == t[i]) ++cnt;
  }
  cout << cnt << "\n";
}


void password()
{
  int n;
  cin >> n;

  cout << pow(n, 3) << "\n";
}






void golden_apple()
{
  int n, d;
  cin >> n >> d;

  int cnt = 0;
  while ((2 * d + 1) * cnt < n) ++cnt;

  cout << cnt << "\n";
}


void swap_0or1()
{
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 1; i <= n; ++i)
  {
    int p;
    cin >> p;
    if (p != i) ++cnt;
  }

  if (cnt <= 2) cout << "YES\n";
  else cout << "NO\n";
}


void uneven_numbers()
{
  int n;
  cin >> n;

  int ans = 0;
  for (int i = 1; i <= n; ++i)
  {
    string s = to_string(i);
    if (s.size() % 2 == 1) ++ans;
  }
  cout << ans << "\n";
}


void one_clue()
{
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i < x + k; ++i)
  {
    if (i == x + k - 1) cout << i << "\n";
    else cout << i << " ";
  }
}



void resistors_in_parallel()
{
  int n;
  cin >> n;
  vector<float> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  float ans = 0.0;
  for (int i = 0; i < n; ++i) ans += 1.0 / a[i];
  cout << 1.0 / ans << "\n";
}


void power_socket()
{
  int a, b;
  cin >> a >> b;

  if (b == 1) cout << 0 << "\n";

  int cnt = 1, tap = (a - 1) * cnt + 1;
  while (tap < b)
  {
    ++cnt;
    tap += a - 1;
  }
  
  cout << cnt << "\n";
}


void buffet()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n - 1; ++i) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    ans += b[a[i] - 1];
    if (i > 0 && a[i - 1] + 1 == a[i]) ans += c[a[i - 1] - 1];
  }
  cout << ans << "\n";
}




int main()
{
  //security();
  //fifty_fify();
  //dodecagon();
  //harmony();
  //transfer();
  //A_137();
  //red_or_not();
  //tenki();
  //password();


  golden_apple();
  //swap_0or1();
  //uneven_numbers();
  //one_clue();
  //resistors_in_parallel();
  //power_socket();
  //buffet();
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,D;
    R(N,D);
    D=2*D+1;
    W((N+D-1)/D);
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  while (1) {
    int N, M; cin >> N >> M;
    if (N == 0 and M == 0) break;
    vector<T> packets(M);
    REP(i, M) {
      int t, s, d; cin >> t >> s >> d; s--, d--;
      packets[i] = T(t, s, d);
    }
    sort(ALL(packets));
    vector<bool> infected(N, false);
    infected[0] = true;
    for (T packet : packets) {
      int t, s, d; tie(t, s, d) = packet;
      infected[d] =  infected[d] | infected[s];
    }
    cout << accumulate(ALL(infected), 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"


int main(int argc, char const *argv[])
{

#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    n = n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9){
        cout<<"hon";
    }
    else if(n==3){
        cout<<"bon";
    }
    else{
        cout<<"pon";
    }

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>    
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ans;
string s1, s2;
#define mod 1000000007

int main() {
	cin >> n >> s1 >> s2;
	
	bool flag;//1 color : 2color
	for(int i = 0; i < n; i++){
		if(i == 0){
			if(s1[0] == s2[0]){ans = 3; flag = true;}
			else{ans = 6; flag = false; i++;}
		}
		else{
			if(flag){
				if(s1[i] == s2[i]){ans *= 2;}
				else{ans *= 2; flag = false; i++;}
			}
			else{
				if(s1[i] == s2[i]){flag = true;}
				else{ans *= 3; flag = false; i++;}
			}
			ans %= mod;
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
					
using namespace std;
			
typedef long long ll;
#define mp make_pair
#define pub push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double
 
int n;
vector<int> g[100007];
 
int calcCnt(int v, int pred){
	int ans = 0;
	int cnt = 0;
	for (auto to : g[v]) if (to != pred){
		ans += calcCnt(to, v);
		cnt++;
	}
	if (v != 0) cnt--;
	ans += (cnt + 1) / 2;
	return ans;
}
 
bool f;
int ww;
 
int dfs(int v, int pred){
	if (g[v].size() == 1 && g[v][0] == pred) return 0;
	vector<int> t;
	for (auto to : g[v]) if (to != pred){
		t.pub(dfs(to, v) + 1);
	}
	sort(all(t));
	if (t.back() > ww){
		f = 0;
		return 0;
	}
	if (v == 0){
		if (t.size() % 2 == 1) t.pop_back();
		for (int i = 0; i < t.size() / 2; i++){
			if (t[i] + t[(int)t.size() - i - 1] > ww){
				f = 0;
			}
		}
		return 0;
	} else {
		if (t.size() % 2 == 0){
			bool ok = 1;
			for (int i = 0; i < t.size() / 2; i++) if (t[i] + t[(int)t.size() - 1 - i] > ww) ok = 0;
			if (ok) return 0;
			t.pop_back();
		}
		int vl = -1, vr = t.size();
		while(vl + 1 < vr){
			int vm = (vl + vr) >> 1;
			bool ok = 1;
			vector<int> tmp;
			for (int i = 0; i < t.size(); i++) if (i != vm) tmp.pub(t[i]);
			for (int i = 0; i < tmp.size() / 2; i++) if (tmp[i] + tmp[(int)tmp.size() - i - 1] > ww){
				ok = 0;
			}
			if (ok)
				vr = vm;
			else
				vl = vm;
		}
		if (vr == t.size()){
			f = 0;
			return 0;
		} 
		return t[vr];
	}
}
 
bool can(int val){ 
	f = 1; ww = val;
	dfs(0, -1);
	return f;
}
 
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pub(b);
		g[b].pub(a);
	}
 
	int vl = 0, vr = 1e9 + 7;
	while(vl + 1 < vr){
		int vm = (vl + vr) >> 1;
		if (can(vm))
			vr = vm;
		else
			vl = vm;
	}
	cout << calcCnt(0, -1) << ' ' << vr;
}	

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

using namespace std;

int main(){
  string S;
  cin >> S;
  string ans = "DEFAULT";
  if(S[0] != 'A') ans = "WA";
  int Ccount = 0;
  for(int i = 2; i < S.size()-1; i++){
    if(S[i] == 'C') Ccount++;
  }
  if(Ccount != 1) ans = "WA";
  if(isupper(S[1])) ans = "WA";
  for(int i = 2; i < S.size(); i++){
    if(isupper(S[i]) && S[i] != 'C') ans = "WA";
  }
  if(ans == "DEFAULT") ans = "AC";
  cout << ans;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a,b,mx,le;

void input(){
	cin>>n;
	return;
}

void solve(){
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>=mx)mx=a,le=b;
	}
	cout<<le+mx<<endl;
	return;
}

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

Measured memory_bytes: 764
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String s = sc.next();
    String t = "CODEFESTIVAL2016";
    
    int count = 0;
    for (int i = 0; i < t.length(); i ++) {
      if (s.charAt(i) != t.charAt(i)) count ++;
    }
    System.out.println(count);

  }
}


class FastScanner {
  public static String debug = null;

  private final InputStream in = System.in;
  private int ptr = 0;
  private int buflen = 0;
  private byte[] buffer = new byte[1024];
  private boolean eos = false;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        if (debug != null) {
          buflen = debug.length();
          buffer = debug.getBytes();
          debug = "";
          eos = true;
        } else {
          buflen = in.read(buffer);
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen < 0) {
        eos = true;
        return false;
      } else if (buflen == 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
      return buffer[ptr++];
    else
      return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
      ptr++;
  }

  public boolean isEOS() {
    return this.eos;
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
      throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
      throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    return (int) nextLong();
  }

  public long[] nextLongList(int n) {
    return nextLongTable(1, n)[0];
  }

  public int[] nextIntList(int n) {
    return nextIntTable(1, n)[0];
  }

  public long[][] nextLongTable(int n, int m) {
    long[][] ret = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        ret[i][j] = nextLong();
      }
    }
    return ret;
  }

  public int[][] nextIntTable(int n, int m) {
    int[][] ret = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        ret[i][j] = nextInt();
      }
    }
    return ret;
  }
}


Measured memory_bytes: 21204
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] A = new int[N];
	  int[] B = new int[N];
	  int[] C = new int[N];
	  long count = 0;
	  for(int i=0; i<N; i++) {
		  A[i] = sc.nextInt();
	  }
	  for(int i=0; i<N; i++) {
		  B[i] = sc.nextInt();
	  }  
	  for(int i=0; i<N; i++) {
		  C[i] = sc.nextInt();
	  }  
	  //昇順にソート
	  Arrays.sort(A);
	  Arrays.sort(B);
	  Arrays.sort(C);
	  
	  for(int j=0; j<N; j++) {
		  long x =(long)meguruSearch(B[j], A,true);
		  long y =(long)( N - meguruSearch(B[j], C,false));
		  count += x*y;
	  }
	  out.println(count);	  
  }
  	//ある条件を満たす最小の要素を返す二分探索
	public static int meguruSearch(int n, int[] list,boolean isA) {
		int left = -1;
		int right = list.length;
		
		while (right - left > 1) {
			int mid = left + (right - left) / 2;
			if(isA) {
				if(isOKofA(mid, n,list)) right = mid;
				else left = mid;
			}
			else  {
				if(isOKofC(mid,n,list))right = mid;
				else left = mid;
			}
		}		
		return right;		
	}
	//条件：list[index]>=nを満たす最小の座標。その座標未満の座標が条件を満たす
	public static boolean isOKofA(int index, int n, int[] list) {
		if( list[index] >= n) return true;
		else return false;
	}
	//条件：list[index]>nを満たす最小の座標。その座標以上の座標が条件を満たす
	public static boolean isOKofC(int index, int n, int[] list) {
		if( list[index]>  n) return true;
		else return false;
	}
	
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N, M; cin >> N >> M;
	vector<bool> broken(N+1, false);
	REP(i,M){
		int a; cin >> a;
		broken[a] = true;
	}

	vector<int> dp(N+2);
	const int mod = 1000000007;
	dp[N] = 1;
	for(int i=N-1;i >= 0; i--){
		if(broken[i]){
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i+1] + dp[i+2]) % mod;
	}
	
	cout << dp[0] << endl;


	return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
  
void f(int n) {
  string s;
  cin >> s;
  int count = 0;
  
  forn(i, n-2){
  	if(s[i] == 'A')
      if(s[i+1] == 'B')
        if(s[i+2] == 'C')
          count++;
  }
  cout << count << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  f(n);
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int findSumOfDigits(int x){
  int sum;
  if(x == 0) sum = 0;
  while(x > 0){
    sum += x % 10;
    x /= 10; 
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  int sumofdigits = findSumOfDigits(N);
  
  if (sumofdigits == 0){
    cout << "No";
    return 0;
  }    
  if(N % sumofdigits != 0) cout << "No";
  else cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    int max = 0;
    for (int i = 0; i < n - 1; ++i) {
        max += a[i];
    }
    if (a[n - 1] < max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    cout << d << " " << r << " ";
    cout << fixed << setprecision(5) << f << endl;
    return 0;
}


Measured memory_bytes: 3292