akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 100248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)


typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
double X0;
double Y0;
const int MAXN = 5e3+3;

struct Point{
  double x;
  double y;
  Point(double a = 0, double b = 0){
    x = a,y = b;
  }
  bool operator==(const Point p)const {
    return p.x == x && p.y == y;
  }
  bool operator<(const Point &p) const{
    return y<p.y || (y == p.y && x<p.x);
  }
  bool operator<=(const Point &p) const{
    return y<p.y || (y == p.y && x<=p.x);
  }
  Point operator+( Point p){
    return Point(x+p.x,y+p.y);
  }
  Point operator-( Point p){
    return Point(x-p.x,y-p.y);
  }
  Point operator*( double a){
	  return Point(a*x,a*y);
  }
  double operator*( Point p){
    return x*p.x + y*p.y;
  }
  double operator^( Point p){
    return x*p.y - y*p.x;
  }
  double norma2(){
    return x*x + y*y;
  }
  double norma(){
    return sqrt(this->norma2());
  }
};
struct Recta{
	Point P;
	Point V;
	Recta(Point p=Point(0,0),Point q=Point(0,0)){
		P=p;
		V=q;
		}
	Point operator *(Recta M){
		if(((M.V)^V) == 0){
			return Point(inf,inf);
			}
		else{
			double alpha;
			alpha=((M.P-P)^M.V)/(V^M.V);
			return P+V*alpha;
			}
		}
	};
struct Segmento{
	Point P;
	Point V;
	Segmento(Point p=Point(0,0),Point q=Point(0,0)){
		P=p;
		V=q;
		}
	Point operator *(Recta M){
		if(((M.V)^V) == 0){
			return Point(inf,inf);
			}
		else{
			double alpha;
			alpha=((M.P-P)^M.V)/(V^M.V);
			if((alpha<=1)&&(alpha>=0))
			{return P+V*alpha;}
			else
			{return Point(inf,inf);}
			}
		}
	};


int main(){
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	int out=a[0]+a[1];
	printf("%d\n",out);
	return 0;
	}


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

int main() {
  int h, w;
  vector<string> v;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }

  for (int i = 0; i < h; i++) {
    cout << v[i] << endl;
    cout << v[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double w, h, x, y;
int main() {
    while (cin >> w >> h >> x >> y) {
        double s = w * h;
        if (fabs(x * 2 - w) < 1e-10 && fabs(y * 2 - h) < 1e-10) printf("%.6f 1\n", s / 2);
        else printf("%.6f 0\n", s / 2);
    }
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val A = Array.fill(N)(sc.nextInt)

    var n = 1
    var r = 0
    for (ai <- A) {
      if (ai != n) {
        r += 1
      } else {
        n += 1
      }
    }
    if (r == N) "-1" else r.toString
  }
}


Measured memory_bytes: 72116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N;
	cin>>N;
	int x=800*N;
	int y=200*(N/15);
	cout<<x-y;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;

	int w,h,a,ans;
	bool map[62][62];
	int lap[62][62];
	
struct Node{
	int x,y,d;
	Node(int a,int b,int c){
		x=a;
		y=b;
		d=c;
	}
};
//テ」ツ?禿」ツ?ョテ・ツ、ツ嘉」ツ?ェテ」ツ?ョテ」ツ?ッpushテ」ツつ津、ツクツ?ヲツ仰ャテ」ツ?ァテ」ツつ?」ツつ凝ァツつコ
typedef struct Node node;


int main(){
	//テ・ツ?・テ・ツ環崚」ツ?古ァツ可ケテヲツョツ甘」ツ?ェテ」ツ?ョテ」ツ?ァテ」ツδ榲」ツδε」ツδ療」ツつ津ヲツ仰。テ・ツシツオテ」ツ?凖」ツつ凝」ツ?ィテ」ツ??」ツ??」ツ?凖」ツ?氾」ツ??ヲツ?敕ィツ?ε」ツ?ョテ、ツコツコテ」ツ?ョティツヲツ凝」ツ??
	cin>>w;
	cin>>h;
	
	while(w!=0 || h!=0){
		ans=0;
		for(int lop=0;lop<62;lop++){
			for(int lop2=0;lop2<62;lop2++){
				if(lop==0 || lop==61 || lop2==0 || lop2==61|| lop2==w*2 || lop==h*2){
					map[lop][lop2]=1;
				}else{
					map[lop][lop2]=0;
				}
				lap[lop][lop2]=0;
			}
		}
		//テ」ツδ榲」ツδε」ツδ療」ツ?ョテ・ツ、ツ姪・ツ?エ
		map[0][1]=0;
		map[h*2][w*2-1]=0;
		//テ・ツ?・テ」ツつ甘・ツ渉」テ・ツ?コテ・ツ渉」
		
		for(int lop=0;lop<h*2-1;lop++){
			if(lop%2==0 || lop==0){
				for(int lop2=0;lop2<w-1;lop2++){
					cin>>a;
					if(a==1){
						if(map[lop][lop2*2+2]==0){
							map[lop][lop2*2+2]=1;
						}
						if(map[lop+1][lop2*2+2]==0){
							map[lop+1][lop2*2+2]=1;
						}
						if(map[lop+2][lop2*2+2]==0){
							map[lop+2][lop2*2+2]=1;
						}
					}
				}
			}else{
				for(int lop2=0;lop2<w;lop2++){
					cin>>a;
					if(a==1){
						if(map[lop+1][lop2*2]==0){
							map[lop+1][lop2*2]=1;
						}
						if(map[lop+1][lop2*2+1]==0){
							map[lop+1][lop2*2+1]=1;
						}
						if(map[lop+1][lop2*2+2]==0){
							map[lop+1][lop2*2+2]=1;
						}
					}
				}
			}
		}
		//テ・ツ」ツ?ァツ板淌ヲツ按静」ツ??ヲツ仰。テ・ツシツオテ」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツ?凝」ツつ嘉・ツ」ツ?」ツつづ、ツクツ?」ツ?、テ」ツ?ォテ」ツ?、テ」ツ?催ッツシツ禿」ツ?、
		//テァツクツヲテ」ツ?ィテヲツィツェテ」ツ?ァテゥツ?催ィツ、ツ?」ツ?凖」ツつ凝・ツ?エテ・ツ青暗」ツ?ッテ・ツ」ツ?・ツ?ェテ・ツ??
		
		bool done[62][62]={0};
		queue<node> q;
		q.push(node(1,1,0));
		//テ・ツ?ィテヲツ篠「テァツエツ「テァツ板ィテ」ツつュテ」ツδ・テ」ツδシテァツ板淌ヲツ按?
		
		while(q.size()!=0){
			node qq=q.front();
			q.pop();
			//テ、ツクツ?」ツ?、テ・ツ?コテ」ツ??テヲツ慊?・ツ按敕」ツ?ッテ・ツスツ禿ァツ?カ 1,1,0
			
			if(done[qq.y][qq.x]==0){
				//テ・ツ」ツ?」ツ?古」ツ?ェテ」ツ??ヲツ卍づ」ツ?ッテゥツ?イテ」ツつ?
				done[qq.y][qq.x]=1;
				//テヲツ按サテ」ツつ嘉」ツ?ェテ」ツ??」ツつ暗」ツ??」ツ?ォテ・ツ」ツ?」ツ?、テ」ツ?湘」ツつ?
				
				if(qq.x==w*2-1 && qq.y==h*2-1){
					ans=(qq.d+2)/2;
					break;
				}
				//テ」ツつエテ」ツδシテ」ツδォテ」ツ?ェテ」ツつ嘉」ツつッテ」ツδェテ」ツつ「
				
				//cout<<"aaaa"<<endl;
				if(map[qq.y][qq.x-1]==0){
					q.push(node(qq.x-1,qq.y,qq.d+1));
				}
				if(map[qq.y-1][qq.x]==0){
					q.push(node(qq.x,qq.y-1,qq.d+1));
				}
				if(map[qq.y][qq.x+1]==0){
					q.push(node(qq.x+1,qq.y,qq.d+1));
				}
				if(map[qq.y+1][qq.x]==0){
					q.push(node(qq.x,qq.y+1,qq.d+1));
				}
			}
			//テ」ツ?ゥテ」ツつ古」ツつづ」ツ?ェテ」ツ??・ツ?エテ・ツ青?テ」ツつ津・ツ?コテ」ツ?療」ツ?ヲテァツオツづ、ツコツ?
		}
		cout<<ans<<endl;
		
		cin>>w;
		cin>>h;
	}
	
	return 0;
}

Measured memory_bytes: 3072
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
        xs: [usize; n],
    }
    assert!(n % 2 == 0);
    let mut xs = xs;
    xs.sort();

    let begin = xs[n/2 - 1];
    let end = xs[n/2];

    let ans = end - begin;
    println!("{}", ans);
}


Measured memory_bytes: 6524
"use strict"

function Main(s) {
  s = s.split('\n');
  const h = Number(s[0]);
  const w = Number(s[1]);
  const n = Number(s[2]);
  
  if(h>w){
    console.log(Math.ceil(n/h));
  }else{
    console.log(Math.ceil(n/w));
  }
}

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

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i=0; i<3*n; i++)
    cin >> a.at(i);

    sort(a.rbegin(),a.rend());

    long long sum=0;
    for(int i=0; i<n; i++){
        sum += a.at(i*2+1);
    }
    cout << sum << endl;



}

Measured memory_bytes: 4508
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			char[] S = sc.next().toCharArray();
			
			boolean[] used = new boolean[26];
			for(final char s : S){
				used[s - 'a'] = true;
			}
			
			for(int i = 0; i < 26; i++){
				if(used[i]){ continue; }
				
				System.out.println(String.valueOf(S) + (char)('a' + i));
				return;
			}
			
			String orig = String.valueOf(S);
			String min = null;
			
			for(int lst = S.length - 1; lst >= 0; lst--){
				for(int fst = lst - 1; fst >= 0; fst--){
					if(S[lst] > S[fst]){
						S[fst] = S[lst];
						final String new_str = String.valueOf(S).substring(0, fst + 1);
						
						if(new_str.compareTo(orig) > 0){
							if(min == null || new_str.compareTo(min) < 0){
								min = new_str;
							}
						}
						
						S = orig.toCharArray();
					}
				}
				
			}
			
			System.out.println(min == null ? -1 : min);
			/*
			try(final PrintWriter pw = new PrintWriter(System.out)){
				pw.println();
			}
			*/
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22484
#include<stdio.h>

int main()
{
	int a,b,c,t;
	int ts;scanf("%d",&ts);
	while(ts--)
	{
		scanf("%d%d%d",&a,&b,&c);
		if(a<b)
		{
			t=a;
			a=b;
			b=t;
		}
		if(a<c)
		{
			t=a;
			a=c;
			c=t;
		}
		if(a*a == (b*b+c*c)) printf("YES\n");
		else printf("NO\n");
	}	
}

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

#define int long long

#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
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
signed main(){
    cin>>N;
    vint A(N);rep(i,N)cin>>A[i];

    rep(i,114514){
        bool f=true;
        rep(j,N)if(A[j]&1)f=false;
        if(!f){
            cout<<i<<endl;
            return 0;
        }
        rep(j,N)A[j]>>=1;
    }
    return 0;
}


Measured memory_bytes: 256
A=input()
B=input()
C=input()
X=input()
A=int(A)
B=int(B)
C=int(C)
X=int(X)
count=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k==X:
        count=count+1
print(count)

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool flag = false;
  if(C > A && C < B) flag = true;
  if(C > B && C < A) flag = true;
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define __LOCAL_DEBUG__
#include<bits/stdc++.h>
using namespace std;
#ifdef __LOCAL_DEBUG__
# define _debug(x) { cerr << "\033[94m" << __func__ << " " << #x << ": " << (x) << "\n\033[0m"; }
#else
# define _debug(...) {((void) 0);}
#endif
#define REP(i, n) for (int i = (0); i < (n); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define EACH(x, arr) for (auto& x : arr) 
#define ITR(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define CLR(x, v) memset(x, v, sizeof (x))
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10;
int n, m;
void MAIN() {
    int a, b;
    cin >> n >> m >> a >> b;
    cout << (n - a) * (m - b) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int TC = 1;
    // cin >> TC;
    REP(tc, TC) {
    // while (cin >> n, n) {
        // cout << "Case " << tc + 1 << ": ";
        MAIN();
    }
    return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
An = list(map(lambda x:[int(x),1],input().split()))
D = [[0]*2 for _ in range(M)]
for i in range(M):
  B, C = map(int,input().split())
  D[i] = [C,B]
An.extend(D)
An.sort(reverse=True)
num = 0
cnt = 0
for i in range(len(An)):
  if cnt+An[i][1] >= N:
    num += An[i][0]*(N-cnt)
    print(num)
    break
  else:
    cnt += An[i][1]
    num += An[i][0]*An[i][1]
    


Measured memory_bytes: 35064
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
    int n,falg=0;

    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    long long m,p;
    for(int i=n-2; i>=0; i--)
    {
        if(a[i]==a[i+1]&&falg==0)
        {
            m=a[i];
            //printf("%d\n",a[i]*a[i+2]);
            i--;
            falg++;
        }
        else if(a[i]==a[i+1]&&falg==1)
        {
            p=a[i];
            falg=2;
            break;
        }

    }

    if(falg!=2)
        printf("0\n");
    else
        printf("%lld",m*p);
    return 0;
}

Measured memory_bytes: 640
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    string s; cin >> s;
    int cnt[26] = {};
    rep(i,0,s.length()) {
        if(i < 3) cnt[ s[i] - 'a' ]++;
        else {
            cnt[ s[i-3] - 'a' ]--;
            cnt[ s[i] - 'a' ]++;
        }

        if(cnt[ s[i] - 'a' ] == 2) {
            printf("%lld %lld\n", max(1LL, i-1), i+1);
            return 0;
        }
    }
    printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = "";
        while(stdIn.hasNext()) {
        s += stdIn.nextLine();
        }
        s = s.toLowerCase();
        int[] ans = new int[k.length];
        for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < k.length; j++) {
                if(s.charAt(i) == k[j]) {
                    ans[j]++;
                }
            }
        }
         
        for(int i = 0; i < 26; i++) {
            System.out.println(k[i]+" : " + ans[i]);
        }
    }
}


Measured memory_bytes: 26076
#include<stdio.h>

int main(){
  int o=0,i;
  double x,N;

  scanf("%lf",&N);
  for(i=1;i<=N;i++){
    if(i%2==0);
    else o++;
  }
  x=o/N;
  printf("%f\n",x);

  return 0;
}



Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

res = sum(b)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        res += c[a[i]-1]
print(res)

Measured memory_bytes: 3064
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> l(n);
    rep(i, n) {
        cin >> l[i];
    }
    sort(all(l));
    int ans = 0;
    rep(i, n) {
        for(int j = i + 1; j < n; ++ j) {
            for(int k = j + 1; k < n; ++ k) {
                if(l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k]) {
                    ++ ans;
                }
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;

const int N=200005;
int a[N],b[N],n;

int check(){
	int m=n/2+1,p=0;
	while(p+1<m&&b[m-p-1]!=b[m-p]&&b[m+p+1]!=b[m+p])p++;
	if(m-p==1) return (m&1)^b[m]^1;
	if(b[m-p-1]==b[m-p]) return b[m-p];
	return b[m+p];
}

int main(){
	scanf("%d",&n),n=2*n-1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int l=2,r=n-1,mid=(l+r+1)>>1;
	while(l<r){
		for(int i=1;i<=n;i++)b[i]=a[i]>=mid;
		if(check())l=mid;else r=mid-1;
		mid=(l+r+1)>>1;
	}
	printf("%d\n",mid);
	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int k;
  cin >> k;
  rep(i, 1, 10) {
    if(k) {
      cout << i << endl;
      k--;
    }else {
      break;
    }
  }
  int mt = 20, kr = 10, f = 1;
  while(k) {
    f++;
    int kkrk = 0, kkkr = kr;
    while(kkkr != 1) {
      kkrk++;
      kkkr /= 10;
    }
    int kkr = kr / 100;
    int kkkkr = kr / 10;
    int kmt = mt - 1 - kkr * 9 - kkkkr * 9;
    if(kr > 100) {
      rep(i, 0, 1) {
        rep(j, 0, 9) {
          if(k && (double)(kmt + kkr * j) / (double)(9 * (kkrk - 2) + f - 1 + j) <= (double)(mt - 1 - kkkkr * 9) / (double)(9 * (kkrk - 1) + f - 1)) {
            k--;
            cout << kmt + kkr * j << endl;
          }
        }
      }
    }
    kkr = kr / 10;
    kmt = mt - 1 - kkr * 9;
    rep(i, 0, 10) {
      if(k && (double)(kmt + kkr * i) / (double)(9 * (kkrk - 1) + f - 1 + i) <= (double)(mt - 1) / (double)(9 * kkrk + f - 1)) {
        cout << kmt + kkr * i << endl;
        k--;
      }
    }
    mt += kr;
    if(mt > kr * 10) {
      f = 1;
      mt -= kr;
      kr *= 10;
      mt += kr;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include "math.h"
int main()
{
	int N=0;
	int a[100];
	double ave;
	double sa=100000;
	int minnumber;
	scanf("%d",&N);
	for (int i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=0;i<N;i++)
	{
		ave+=a[i];
	}
	ave/=N;
	for (int i=0;i<N;i++)
	{
		if(a[i]-ave>0)
		{
			if(sa>a[i]-ave)
			{
				sa=a[i]-ave;
				minnumber=i;
			}
		}
		else
		{
			if(sa>ave-a[i])
			{
				sa=ave-a[i];
				minnumber=i;
			}
		}
	}
	printf("%d",minnumber);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int n, m, Sn = 0;
    cin >> n;
    m = n;
    while(n >= 10){
        Sn += n % 10;
        n /= 10;
    }
    Sn += n;
    if(m % Sn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n;
string s;

int main() {
    fast_io; cout_precision;
    cin >> s;
    n = s.length();
    for (ll i = 0; i < n; i++) {
        if (i + 1 < n && s[i + 1] == s[i]) {
            cout << i + 1 << ' ' << i + 2 << endl;
            return 0;
        }
        if (i + 2 < n && s[i + 2] == s[i]) {
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i],as[i]--;

  map<Int, Int> cnt;
  cnt[0]=1;
  Int ans=0;

  vector<Int> sm(n+1,0);
  for(Int i=0;i<n;i++){
    if(k<=i+1) cnt[sm[i+1-k]]--;
    sm[i+1]=(sm[i]+as[i])%k;
    ans+=cnt[sm[i+1]];
    cnt[sm[i+1]]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
//https://atcoder.jp/contests/abc075/tasks/abc075_c?lang=ja
//C - Bridge
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-1.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll N,M; cin>>N>>M;
  vector<pair<int,int>> cnt(M);
  for(auto&& p:cnt){
    cin>>p.first>>p.second;
  }
  ll ans=0;
  REP(i,M){
    uf_tree uft(N+1);
    REP(j,M){
      if(i==j)continue;
      uft.unite(cnt[j].first, cnt[j].second);
    }
    if(uft.size()-1>1) ++ans;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	int ans=0;
	repi(a,1,k+1)repi(b,1,k+1)repi(c,1,k+1){
		int tmp = gcd(a,b);
		tmp = gcd(tmp,c);
		ans+=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
n = int(input())
C = list(input())


W = C.count("W")
R = C.count("R")

# 仕切りより左側にある白石の数
w = 0
# 仕切りより右側にある赤石の数
r = R

ans = r

for i in range(n):
    if C[i] == "W":
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))
print(ans)

Measured memory_bytes: 10768
n = int(input())
p = [num for num in map(int, input().split(' '))]

ans = 0

for i in range(1, n-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
    ans += 1
  if p[i+1] < p[i] and p[i] < p[i-1]:
    ans += 1

print(ans)

Measured memory_bytes: 38384
from itertools import*
s,k=open(0)
k=int(k)
g=[len(list(v))for _,v in groupby(s)]
print(sum(c//2for c in g)*k+((g[0]*g[-2]%2*s[0]==s[-2])*~-k>>(len(s)-2<g[0])))

Measured memory_bytes: 3060
N = int(input())
List = input().split()
counter = [0 for _ in range(8)]
prime = 0
for item in List:
  if int(item) >=3200:
    prime +=1
  else:
    num = int(item)//400
    counter[num] += 1

minimum = max(8 - counter.count(0),1)
if counter.count(0) != 8:
  maximum = minimum + prime
else:
  maximum = prime
  
print(minimum, maximum)


Measured memory_bytes: 3060
//while(true) RP++;
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<set>
using namespace std;

const int Maxn=1e4;

int n,k; 
char str[15];
int cnt[35];

inline bool judge(int T){
	if (T==0) return true;
	int rate=0,sum=0;
	for (int i=0;i<26;i++)
		if (cnt[i]>=T) rate++; else sum+=cnt[i];
	if (rate+sum/T>=k) return true; return false;
}

inline void solve(){
	scanf("%d%d",&n,&k);
	memset(cnt,0,sizeof(cnt));

	for (int i=1;i<=n;i++){
		scanf("%s",str);
		cnt[str[0]-'A']++;
	}
	
	int left=0,right=n/k+1,Ans=0;
	while(left<=right){
		int mid=(left+right)/2;
		if (judge(mid)){
			left=mid+1;
			Ans=max(Ans,mid);
		}else{
			right=mid-1;
		}
	}
	
	printf("%d\n",Ans);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define max_heap priority_queue<int>
#define min_heap priority_queue<int,vector<int>,greater<int>>
using ll = long long;
#define int long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define inp_arr(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define out_arr(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";
#define deb(n) cerr << #n << " = " << n << "\n";
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
ll mypower(ll x,ll n,ll c){
    if(n == 0)
        return 1;
    ll temp = mypower(x,n/2,c)%c;
    if(n%2)
        return (n<0)? (1/x)*temp*temp%c: ((x*temp)%c)*temp%c;
    else
        return temp*temp%c;
}
bool codejam = 0;

void solve(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll red = 0;
	ll white = 0;
	vector<int> reds;
	for(int i=0;i<n;i++){
		if(s[i] == 'R'){
			red++;
			reds.push_back(i);
		}
	}
	sort(all(reds));
	ll red_max = -1;
	if(reds.size())
		red_max = reds[reds.size()-1];
	if(red_max == -1 || red == n){
		cout<<0<<endl;
		return;
	}
	ll ans = 0;
	for(int i=0;i<red;i++)
		if(s[i] == 'W')
			ans++;
	cout<<ans<<endl;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	solve();
	
	return 0;
}


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

const ll INF = 1001001001;
const ll mod = 1000000007;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    vector<int> ans(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i] >> d[i];
    int idx = 0;
    for(int i = 0; i < n; i++){
        int tmp = INF;
        for(int j = 0; j < m; j++){
            if(tmp > abs(a[i] - c[j]) + abs(b[i] - d[j])){
                idx = j;
                tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            }
        }
        ans[i] = idx;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] + 1 << endl;
    }
}

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


int main()
{
    /*
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    */
    string s,t;
    cin>>s>>t;
    int count = 0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main(){
	float a, b;
	cin >> a >> b;
	float c = 0;
	a /= 2;
	c = (b - a) * 2;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c == 'a'){
   cout << "vowel" << endl;
  }
  else if(c == 'e'){
   cout << "vowel" << endl;
  }
   else if(c == 'i'){
   cout << "vowel" << endl;
  }
   else if(c == 'u'){
   cout << "vowel" << endl;
  }
   else if(c == 'o'){
   cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
    

}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 == 0 ? "Even" : "Odd") << endl;

    return 0;
}



Measured memory_bytes: 888
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_right
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, D, K = MAP()

XH = []
for i in range(N):
    x, h = MAP()
    XH.append((x, h))

XH.sort(key=itemgetter(0))
X, _ = zip(*XH)
D = D * 2

imos = [0] * (N+1)
ans = 0
for i, (x, h) in enumerate(XH):
    imos[i+1] += imos[i]
    h -= imos[i] * K
    if h <= 0:
        continue
    cnt = ceil(h, K)
    idx = bisect_right(X, x+D)
    imos[i+1] += cnt
    imos[idx] -= cnt
    ans += cnt
print(ans)


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

int main(){
    int n_max,sum;
    cin >> n_max >> sum ;

    int x,y,z,count = 0;

    for(x = 0;x <= n_max;x++){
        for(y = 0;y <= n_max; y++){
            if(0 <= sum - x - y  && sum - x - y <= n_max)count++;
        }
    }

    cout << count << endl;
}

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

int main(){
  int s, sn, ans = 0;
  
  cin >> s;
  
  sn = s % 10;
  ans = sn;
  
  s /= 10;
  sn = s % 10;
  ans += sn;
  
  s /= 10;
  sn = s % 10;
  ans += sn;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,ans = mod;
    string s;
    cin >> n >> s;
    vector<ll> e(n + 1,0),w(n + 1,0);
    rep1(i, n){
        if (s[i - 1] == 'E') {
            e[i] = e[i - 1] + 1;
            w[i] = w[i - 1];
        }else if (s[i - 1] == 'W') {
            e[i] = e[i - 1] ;
            w[i] = w[i - 1] + 1;
        }
    }
    rep1(i, n)ans = min(ans, w[i - 1] + e[n] - e[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5380
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include<tuple>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

typedef std::tuple<std::string, int,int> mytuple;
bool mycompare( const mytuple &lhs, const mytuple &rhs )
{
    if (std::get<0>(lhs) != std::get<0>(rhs)) return std::get<0>(lhs) < std::get<0>(rhs);
    if (std::get<1>(lhs) != std::get<1>(rhs)) return std::get<1>(lhs) > std::get<1>(rhs);
    return std::get<2>(lhs) < std::get<2>(rhs);
}

int main(){
    int n;
    char s[11];
    int p;
    std::vector<tuple<string,int,int>> vec;
    scanf("%d",&n);
    REP(i,n){
        REP(j,11)s[j]='\0';
        scanf("%s%d",s,&p);
        vec.push_back(make_tuple(s,p,i+1));
    }
    sort(vec.begin(),vec.end(),mycompare);
    /*
    REP(i,vec.size()){
        printf("%s %d %d\n",get<0>(vec[i]).c_str(),get<1>(vec[i]),get<2>(vec[i]));
    }
    */
    REP(i,vec.size())printf("%d\n",get<2>(vec[i]));
    return 0;
}

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

int main(){
    int c;
    cin>>c;
    if(c==0)cout<<1;
    else cout<<0;
    cout<<endl;
    return 0;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main(){

	int n;
	cin >> n;

	vi a(n);
	map<int, int> mp;

	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}

	ll ansn = 0;
	rep(i, n) {
		ansn += (ll)mp[i + 1] * (mp[i + 1] - 1) / 2;
	}

	rep(i, n) {
		cout << ansn - mp[a[i]] + 1 << endl;
	}
}

Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll s, t, n, m;std::cin >> n >> m;
  Dijkstra dj(3*n+1);
  re(i, m){
    std::cin >> s >> t;
    dj.insert(s, t+n, 1);
    dj.insert(s+n, t+2*n, 1);
    dj.insert(s+2*n, t, 1);
  }
  std::cin >> s >> t;
  dj.dijkstra(s);
  std::cout << (dj.d[t]==dj.INF?-1:dj.d[t]/3) << '\n';
  return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

ll N,K;
ll A[200010];

ll calc(){
  map<ll,ll> mp;
  ll cnt[N];
  ll num = 1;
  ll roop = 0;
  ll st = 0;
  for(ll i=0;i<=N;i++){
    if(mp[num]!=0){
      st = mp[num];
      roop = i-mp[num];
      break;
    }
    mp[num] = i;
    cnt[i] = num;
    num = A[num];
  }
  ll x = K-st;
  if(x<roop) return cnt[K];
  ll r = x%roop;
  return cnt[st+r];
}

int main(){
  cin >> N >> K;
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  ll ans = calc();
  cout << ans << endl;
}



Measured memory_bytes: 19084
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint A, B, C, K;
    cin >> A >> B >> C >> K;

    lint ans = 0;
    ans += 1 * min(A, K);
    K -= min(A, K);
    ans += 0 * min(B, K);
    K -= min(B, K);
    ans += -1 * min(C, K);
    K -= min(C, K);

    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vi p(n);
    rep(i,n) cin>>p[i];
    double ans=0.0;
    double sum=0.0;
    rep(i,k){
        int s = (1+p[i])*p[i]/2;
        sum+=(double)s/p[i];
    }
    ans = sum;
    rep(i,n-k){
        int s1 = (1+p[i])*p[i]/2;
        int s2 =(1+p[k+i])*p[k+i]/2;
        sum += (double)s2/p[k+i];
        sum -= (double)s1/p[i];
        chmax(ans, sum);
    }
    cout<<setp(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <list>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cctype>

using namespace std;

typedef long long Board;

const int N = 9;
const Board GOAL = 0x087654321;

struct state {
    Board board;
    int count;
};

list<state> q;
set<Board> history;

inline void swap(int numpos, int spacepos, Board& board) {
    long long num = (board >> (numpos*4)) & 15;
    board |= num << (spacepos*4);
    board &= ~(15LL << (numpos*4));
}

inline int swap_and_check(int numpos, int spacepos, state s) {
    swap(numpos, spacepos, s.board);
    if (s.board == GOAL) {
        return ++s.count;
    }
    if (history.insert(s.board).second) {
        ++s.count;
        q.push_back(s);
    }
    return -1;
}

void print(Board b) {
    for (int i = 0; i < N; ++i) {
        printf("%2lld", (b >> (i*4) & 15));
    }
    printf("\n");
}

// OK
int main(void) {

    Board board = 0;
    for (int i = 0; i < N; ) {
        char ch;
        scanf("%c", &ch);
        if (isdigit(ch)) {
            board |= static_cast<long long>((ch - '0')) << (i*4);
            ++i;
        }
    }
//    print(GOAL);
//    print(board);

    int count = 0;
    if (board == GOAL) {
        goto END;
    }

    q.push_back({ board, 0 });
    while (!q.empty()) {
        state s = q.front();
        q.pop_front();

        int pos = -1;
        while (++pos < N) {
            if (((s.board >> (pos*4)) & 15) == 0) {
                break;
            }
        }

        if (pos < 6) {
            if ((count = swap_and_check(pos + 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos > 2) {
            if ((count = swap_and_check(pos - 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 < 2) {
            if ((count = swap_and_check(pos + 1, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 > 0) {
            if ((count = swap_and_check(pos - 1, pos, s)) > 0) {
                break;
            }
        }
    }

END:
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 9868
#include<cstdio>
#include<algorithm>
#include<utility>
#include<vector>
#include<set>
#include<map>
#include<math.h>

using namespace std;

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

typedef long long int ll;

int main(){
  ll X;
  ll i;
  scanf("%lld",&X);
  i=2;
  while(1){
    if(i*(i-1)/2==X){
      printf("%lld",i-1);
      break;
    }
    else if(i*(i-1)/2>X){
      printf("%lld",i-1);
      break;
    }
    else i++;
  }

  return 0;
}


Measured memory_bytes: 128
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL X,Y;
LL A,B,C;
LL p[100000],q[100000],r[100000];
 
LL ans = 0;

void solve(){
    sort(p,p+A,greater<LL>());
    sort(q,q+B,greater<LL>());
    sort(r,r+C,greater<LL>());

    LL sum_apple = 0;

    //appleに選んだリンゴを全部格納する
    priority_queue<LL> apple;
    for(int i=0;i<X;i++){
        apple.push(-p[i]);
        sum_apple += p[i];
    }
    for(int i=0;i<Y;i++){
        apple.push(-q[i]);
        sum_apple += q[i];
    }

    //無色のリンゴを美味しい順に見ていく
    for(int i=0;i<C;i++){
        //選んだリンゴのうち最も美味しくないものをworstとおく
        LL worst = -apple.top();
        if(worst<r[i]){
            sum_apple -= worst;
            sum_apple += r[i];
            apple.pop();
            apple.push(-r[i]);
        }
    }

    ans = sum_apple;
}
 
int main(){
    cin >> X >> Y >> A >> B >> C;
    for(int i=0;i<A;i++) cin >> p[i];
    for(int i=0;i<B;i++) cin >> q[i];
    for(int i=0;i<C;i++) cin >> r[i];
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4724
N, Y = map(int, input().split())
# i + j + k = N
# k = N - (i+j)
for i in range(N+1):
  for j in range(N+1 - i):
    k = N - (i+j)
    if Y == (10000*i + 5000*j + 1000*k):
      print(i,j,k)
      exit()
print(-1,-1,-1,)      

Measured memory_bytes: 3060