akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int a[4];
int main() {
	int i, j, k;
	scanf("%d%d%d%d", &a[1], &a[2], &a[3], &a[0]);
	sort(a, a+4);
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	double r,a,b;
	cin>>r;
	a=r*2*3.141592653589;
	b=r*r*3.141592653589;
	printf("%f ",b);
	printf("%f\n",a);
	return 0;
}

Measured memory_bytes: 1232
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <cmath>
#include <math.h>
using namespace std;
static const double pi = 3.141592653589793;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double deg = (30 * h - 11 * m / 2) * pi / 180;
  double x = a*a + b*b - 2 * a * b * cos(deg);
  double c = sqrt(x);
  cout << fixed << setprecision(15);
  cout << c << endl;
}

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

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll>right(n+1);
    vector<ll>left(n+1);
    right[n]=0;
    left[0]=0;
    for(ll i = 1;i <= n;i++){
        if(s[i-1]=='<')left[i]=left[i-1]+1;
        else left[i]=0;
    }
    for(ll i = n-1;i>=0;i--){
        if(s[i]=='>')right[i]=right[i+1]+1;
        else right[i]=0;
    }
    ll ans = 0;
    for(ll i = 0;i<n+1;i++){
        ans += max(right[i],left[i]);
        //cout << right[i] << " " << left[i] << endl;
    }
    cout << ans << endl;
    return 0;
}

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

import sys
import copy

# input = sys.stdin.readline

# ---------------------------------------------------------

S = input().rstrip()

cnt1 = 0
cnt2 = 0

for i in range(len(S)):
    if i % 2 == 0:
        cnt1 += (S[i] != '0')
    else:
        cnt1 += (S[i] != '1')

for i in range(len(S)):
    if i % 2 == 1:
        cnt2 += (S[i] != '0')
    else:
        cnt2 += (S[i] != '1')

print(min(cnt1, cnt2))


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

using namespace std;

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

    cin >> a >> b >> c >> d;

    while (a > 0 || c > 0) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    ll k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (int i = 1; i < n; i++) a[i] += a[i - 1];
    for (int i = 1; i < m; i++) b[i] += b[i - 1];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > k) break;
        int cur = i + 1;
        ll val = k - a[i];
        int l = 0, r = m - 1, mid, best = -1;
        while (l <= r) {
            mid = (l + r) / 2;
            if (val >= b[mid]) {
                best = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        if (best != -1) cur += best + 1;
        ans = max(ans, cur);
    }
    for (int i = 0; i < m; i++) {
        if (b[i] > k) break;
        int cur = i + 1;
        ll val = k - b[i];
        int l = 0, r = n - 1, mid, best = -1;
        while (l <= r) {
            mid = (l + r) / 2;
            if (val >= a[mid]) {
                best = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        if (best != -1) cur += best + 1;
        ans = max(ans, cur);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6732
#include<stdio.h>

typedef struct{
  int m[6];
} DICE;

void diceroll(DICE *,char);

int main(){
  DICE dice;
  int cnt, i, a, b;
 
  //input dice
  for(i=0;i<6;i++) scanf("%d",&dice.m[i]);

  //input quiz num 
  scanf("%d",&cnt);


  //search
  for(i=0;i<cnt;i++){
    scanf("%d %d",&a,&b);

    //search b
    while(dice.m[0]!=b){
      diceroll(&dice,'S');
      if(dice.m[0]==b) break;
      diceroll(&dice,'E');
    }
    
    //roll S
    diceroll(&dice,'S');
    
    //search a
    while(dice.m[0]!=a) diceroll(&dice,'E');
    
    printf("%d\n",dice.m[2]);
  }

  return 0;
}



void diceroll(DICE *dice,char c){
  int tmp;
  tmp=dice->m[0];
  
  if(c=='N'){
    dice->m[0]=dice->m[1];
    dice->m[1]=dice->m[5];
    dice->m[5]=dice->m[4];
    dice->m[4]=tmp;
  }
  
  else if(c=='S'){
    dice->m[0]=dice->m[4];
    dice->m[4]=dice->m[5];
    dice->m[5]=dice->m[1];
    dice->m[1]=tmp;
  }
  
  else if(c=='E'){
    dice->m[0]=dice->m[3];
    dice->m[3]=dice->m[5];
    dice->m[5]=dice->m[2];
    dice->m[2]=tmp;
  }
  
  else if(c=='W'){
    dice->m[0]=dice->m[2];
    dice->m[2]=dice->m[5];
    dice->m[5]=dice->m[3];
    dice->m[3]=tmp;
  }

  else return;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using ll = long long;
using namespace std;

int main() {
  ll a, b, n, x;
  cin >> a >> b >> n;
  x = b - 1;
  if (x <= n) {
    cout << a * x / b << endl;
    return 0;
  } else {
    x = n;
    cout << a * x / b << endl;
    return 0;
  }
  return 0;
}

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

int main() {
  int N; 
  int judge = 0;
  string S;
  
  cin >> N;
  
  for(int i = 0; i < N; i++)
  {
    cin >> S;
    
    if(S == "Y")
      judge = 1;
  }

  if(judge == 1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


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

struct Edge {
    int from, to, cap, rev;
    Edge(int f, int t, int c, int r) : from(f), to(t), cap(c), rev(r) {} // 初期化
};
 
struct Graph {
    vector<vector<Edge>> G;
    Graph(int n = 0) : G(n) {} // 初期化
 
    vector<Edge>& operator[](int i) { return G[i]; }
    int size() { return G.size(); }
    void add_edge(int from, int to, int cap) {
        G[from].push_back(Edge(from, to, cap, (int)G[to].size()));
        G[to].push_back(Edge(to, from, 0, (int)G[from].size() - 1));
    } // 有向辺を加える
};
 
struct FordFulkerson {
    const int INF = 1e5;
    vector<int> used; 
    FordFulkerson(){}; // 初期化
 
    int dfs(Graph &G, int s, int g, int f) {  // 増加可能経路を見つけて増加分のフローを返す
        if (s == g) return f;
        used[s] = true;
        for (auto &e : G[s]) {
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(G, e.to, g, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    } // 増加可能経路を見つけて増加分のフローを返す
 
    int max_flow(Graph &G, int s, int g) {
        int flow = 0;
        while (true) {
            used.assign(G.size(), false);
            int f = dfs(G, s, g, INF);  // f が増加分のフロー
            if (f == 0) {
                return flow;
            } else {
                flow += f;
            }
        }
        return 0;
    }
};


int main(){
    int h, w; cin >> h >> w;
  
  int sx, sy, tx,ty;

    Graph data(202);
    rep(i,h) rep(j,w) {
        char c; cin >> c;
        if (c == 'S') {
            data.add_edge(200,i,100100);
            data.add_edge(200,j+100,100100);
          sx = i; sy = j;
        }
        else if (c == 'T') {
            data.add_edge(i,201,100100);
            data.add_edge(j+100,201,100100);
          tx = i; ty = j;
        }
        else if (c == 'o') {
            data.add_edge(i,j+100,1);
            data.add_edge(j+100,i,1);
        }
    }
  if (sx == tx || sy == ty) { cout << -1 << endl; return  0; }

    FordFulkerson ans;
    cout << ans.max_flow(data, 200, 201) << endl;
    return 0;
}

Measured memory_bytes: 4456
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<int> enum_div(int n) {
    vector<int> ret;
    ret.push_back(n);
    for(int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int ans = 1;
    vector<int> d = enum_div(M);
    for(auto num : d) {
        if (M / num >= N) ans = max(ans, num);
    }
    cout << ans << endl;
    


    return 0;
}


Measured memory_bytes: 896
from collections import defaultdict
from bisect import bisect_left

S = input()
T = input()
lenS = len(S)
if set(S) >= set(T):
    SS = S + S
    pos = defaultdict(list)
    for i, s in enumerate(SS): pos[s].append(i)
    ans = -1
    for t in T:
        lb = (ans + 1) % lenS
        nxt = bisect_left(pos[t], lb)
        ans += pos[t][nxt] - lb + 1
    ans += 1
    print(ans)
else:
    print(-1)

Measured memory_bytes: 12404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using namespace std;

class CombinationMod {
  int mod;
  std::vector<long long> fac, finv, inv;

  public:
  CombinationMod(int max_size, int prime_mod) : fac(std::vector<long long>(max_size)), finv(std::vector<long long>(max_size)), inv(std::vector<long long>(max_size)), mod(prime_mod) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_size; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  long long comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

int main(void) {
  lint n, m, k;
  cin >> n >> m >> k;
  CombinationMod cm(n * m, MOD);
  lint times = cm.comb(m * n - 2, k - 2);
  lint sumx = 0, sumy = 0;
  rep1(i, m - 1) {
    sumx += i * (m - i);
  }
  sumx = (sumx % MOD) * n * n % MOD;
  rep1(i, n - 1) {
    sumy += i * (n - i);
  }
  sumy = (sumy % MOD) * m * m % MOD;
  lint sum = (sumx + sumy) % MOD * times % MOD;
  cout << sum << endl;
  return 0;
}

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

typedef long long ll;

int main() {
    ll a,b,v,w,t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    string ans = "NO";
    if(abs(b-a)+(w-v)*t <= 0) ans = "YES";
    cout << ans;
}

Measured memory_bytes: 3604
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		String s = sc.next();
		s += sc.next();
		
		int num = Integer.parseInt(s);
		String ans = "Yes";
		double sqrt = Math.sqrt(num);
		double upper = Math.ceil(sqrt);
		double lower = Math.floor(sqrt);
		
		if (lower<sqrt && sqrt < upper) {
			ans = "No";
		}

		
		
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 21204
import java.util.Scanner;

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

  Scanner sc = new Scanner(System.in);
  while(true){
   int max=0,min=10000;
   int sum=0;
   int human = sc.nextInt();
   if(human==0) break;
   int[] point = new int[human];

   for(int i=0;i<point.length;i++){
    point[i]=sc.nextInt();
    if(point[i]>max) max=point[i];
    if(point[i]<min) min=point[i];
    sum += point[i];
   }
   sum = sum - max - min;
   int ave=sum/(human-2);
   System.out.println(ave);
  }
 }
}

Measured memory_bytes: 21112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
const int mod = 1e9 + 7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
using P = pair<mint,bool>;


int main() {
  int n, k; cin >> n >> k;
  vec a, b;
  rep(i,n) {
    int ab; cin >> ab;
    if (ab >= 0) {
      a.push_back(ab);
    } else if (ab < 0) {
      b.push_back(ab);
    }
  }

  if (k == n) {
    mint pro = 1;
    for (int aa : a) {
      pro *= aa;
    }
    for (int bb : b) {
      pro *= bb;
    }
    cout << pro << endl;
  } else if (a.empty() && k&1) {
    sort(all(b), greater<int>());
    mint pro = 1;
    rep(i,k) {
      pro *= b[i];
    }
    cout << pro << endl;
  } else {
    sort(all(b));
    sort(all(a), greater<int>());
    int ai = 0, bi = 0;
    mint pro = 1;
    if (k&1) {
      pro *= a[ai++];
    }
    while (ai + bi <= k-2) {
      if (ai >= a.size()) {
        pro *= b[bi++];
        pro *= b[bi++];
      } else if (bi >= b.size()) {
        pro *= a[ai++];
        pro *= a[ai++];
      } else {
        ll a2 = a[ai]; a2 *= a[ai+1];
        ll b2 = b[bi]; b2 *= b[bi+1];
        if (a2 > b2) {
          pro *= a[ai++];
          pro *= a[ai++];
        } else {
          pro *= b[bi++];
          pro *= b[bi++];
        }
      }
    }
    cout << pro << endl;
  }
}


Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int i,j,k,l,m,n,x,y,r,cnt,p;
    long long int idx=0,idc=0;
map<int,string>M,N;
    map<int,int>a,b;
cin>>n;
for(i=0;i<n;i++){cin>>N[i];}
    cin>>m;
    for(i=0;i<m;i++){cin>>M[i];}
  for(j=0;j<n;j++){
     cnt=1;
        if(N[j]!="ok"){
        for(k=j+1;k<n;k++){
            if(N[j]==N[k]){cnt++;}
        }
            a[idx]=cnt;idx++;N[k]="ok";
            
    }
  
}
    for(r=0;r<n;r++){
     if(N[r]!="ok"){
            cnt=0;
            for(p=0;p<m;p++){
          if(N[r]==M[p]){cnt++;}
         }
            b[idc]=cnt;idc++;
        }
 
  }
   x=0;
   for(l=0;l<idx;l++){
        y=a[l]-b[l];
        x=max(x,y);
    }
    cout<<x<<endl;


}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n%111==0)
	{
		printf("%d",n);
		return 0;
	}
	
	else if(n%111>0)
	{
		while(n%111){n++;}
		printf("%d",n);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 200+10
    ll N,A[100010];
    ll F[100010];
    ll l,r;
    ll ans;

ll LP(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return LP((x*x)%MOD,y/2)%MOD;
    else return LP(x,y-1)*x%MOD;
}
ll Fact[100010];
ll Com[100010];
void FC(ll x){
    Fact[0]=Com[0]=1;
    ll temp=1;
    EREP(i,x){
        temp=temp*i%MOD;
        Fact[i]=temp;
        Com[i]=LP(temp,MOD-2);
    }
}
ll MC(ll x,ll y){
    if(y==0)return 1;
    if(x<y)return 0;
    return (Fact[x]*(Com[y]*Com[x-y]%MOD))%MOD;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,100010)F[i]=-1;
    REP(i,N+1){
        cin>>A[i];
        if(F[A[i]]==-1)F[A[i]]=i;
        else{
            l=F[A[i]];
            r=i;
        }
    }
    FC(N+2);
    REP(i,N+1){
        DEB(MC(N+1,i+1))DEB(MC(l+N-r,i))END
    cout<<(MC(N+1,i+1)-MC(l+N-r,i)+MOD)%MOD<<endl;
    }
    return 0;
}


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

using namespace std;


vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

long long fastpow(long long a, long long n){
  long long ans = 1;
  while(n > 0){
    if(n & 1){
      ans *= a;
    }
    a *= a;
    n = n >> 1;
  }
  return ans;
}


int main(){
  long long n;
  cin >> n;
  cin.ignore();

  vector<pair<long long, long long>> prime_fact = prime_factorize(n);
  queue<pair<long long, long long>> prime_fact_extra;

  vector<long long> extra;

  vector <long long> already;

  long long cnt = 0;
  long long rem = 1;
  long double sqrt_n = sqrt(n);
  for(int i = 0; i < prime_fact.size(); i++){
    //printf("e = %lld p = %lld\n", prime_fact[i].first, prime_fact[i].second);
    long long p = prime_fact[i].second;
    long double sqrt_p = sqrt(p);
    // n(n+1)/2 <= Aとなるnを探る
    long long n_p = sqrt_p + 10;
    while(p < (n_p * (n_p + 1)) / 2){
      --n_p;
    }
    cnt += n_p;
  }

  cout << cnt << endl;
  
  return 0;
}
  


Measured memory_bytes: 3728
N = int(input())
H = list(map(int, input().split()))

prev = 10 ** 10
for i in range(N):
    ind = N-i-1
    cur = H[ind]
    if cur == prev + 1:
        continue
    else:
        if cur > prev + 1:
            print('No')
            exit()
        prev = cur

print('Yes')


Measured memory_bytes: 63984
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    string s,s1,s2;
    cin >> a >> b >> c >> d;   
    if (abs(a-c)<=d||(abs(a-c)<=2*d  && abs(a-b)<=d && abs(b-c)<=d) ) 
    cout << "Yes" << endl;

    else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 1e5 + 5;
int M;
int dp[N], dp1[N];
vector<int> g[N];
int par[N];
vector<int> pre[N], suf[N];
map<int,int> idx[N];
void dfs(int u,int p){
	par[u] = p;
	dp[u] = 1;
	for(int v : g[u]){
		if(v != p){
			dfs(v, u);
			dp[u] = (dp[u] * (dp[v] + 1)) % M;
			idx[u][v] = sz(pre[u]);
			pre[u].pb(dp[u]);
		}
	}
	int val = 1;
	for(int i = g[u].size() - 1; i >= 0; i--){
		if(g[u][i] != p){
			val = (val * (dp[g[u][i]] + 1)) % M;
			suf[u].pb(val);
		}
	}
	reverse(all(suf[u]));
}
void dfs1(int u,int p){
	if(p){
		dp1[u] = 1;
		dp1[u] = (dp1[u] * (dp1[p] + 1)) % M;
		int id = idx[p][u];
		if(id > 0){
			dp1[u] = (dp1[u] * pre[p][id - 1]) % M;
		}
		if(id < sz(suf[p]) - 1){
			dp1[u] = (dp1[u] * suf[p][id + 1]) % M;
		}
	}
	for(int v : g[u]){
		if(v != p)
		{
			dfs1(v, u);
		}
	}
}
void solve(){
	int n;
	cin >> n >> M;
	fr(i, 1, n - 1){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1, 0);
	dfs1(1, 0);
	// fr(i, 1, n){
	// 	cout << (dp[i] * (dp1[par[i]] + 1)) % M << endl;
	// }
	fr(i, 1, n){
		cout << ((dp1[i] + 1) * dp[i]) % M << endl;
	}
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

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

using namespace std;

long long a[100010];
long long b[100010];
int main()
{
    long long n,h;
    scanf("%lld %lld",&n,&h);
    for(int i=0; i<n; i++)
        scanf("%lld %lld",&a[i],&b[i]);
    sort(a,a+n);
    sort(b,b+n);
    int tp=lower_bound(b,b+n,a[n-1])-b;
    int cnt=0;
    for(int i=n-1; i>=tp; i--)
    {
        if(h>0)
        {
            h-=b[i];
            cnt++;
        }
        else
            break;
    }
    int kk=0;
    if(h>0)
    {
        kk=h/a[n-1];
        if(a[n-1]*kk!=h)
            cnt++;
    }
    cnt+=kk;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    vector<int> d (N,0);
    for (int i=0;i<N;i++){
        cin>>d[i];
        d[i]--;
    }
    int ret=0;
    for (int i=0;i<N;i++){
        int j=d[i];
        if (i==d[j]){
            ret++;
        }
    }
    cout<<ret/2<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	long long n, p;
	cin >> n >> p;

	map<long long, int> factors;
	while (p % 2 == 0) {
		++factors[2];
		p >>= 1;
	}

	for (long long i = 3; i * i <= p; i += 2) {
		while (p % i == 0) {
			++factors[i];
			p /= i;
		}
	}

	if (p > 2) {
		++factors[p];
	}

	long long g = 1;
	for (auto it = factors.begin(); it != factors.end(); ++it) {
		g *= pow(it->first, (it->second) / n);
	}

	cout << g << "\n";

	return 0;

}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    n-=1;
    for(ll i=0;i<=n;i++){
        ll p = i;
        ll m = n-i;
        ll ma = a + d*p - c*m;
        ll mi = a + c*p - d*m;
        if(b<=ma&&b>=mi){
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;
}

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

int main(){
    int x;
    cin >> x;
    vector<int>data(x+1);
    
    rep(i,x+1){
        if(i == 0){
            data[i] = 1;
            continue;
        }
        if(i < 100)continue;
        if(i==100||i==101||i==102||i==103||i==104||i==105)data[i]=1;
        if(data[i-100]== 1 || data[i-101] == 1||data[i-102] == 1||data[i-103] == 1||data[i-104] ==1||data[i-105]==1){
            data[i] = 1;
        }else data[i] = 0;
    }
    cout << data[x] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iostream>

using namespace std;

const int mov[24][6]= {
  {0,1,2,3,4,5},{0,2,4,1,3,5},{0,4,3,2,1,5},{0,3,1,4,2,5},
  {3,1,0,5,4,2},{3,0,4,1,5,2},{3,4,5,0,1,2},{3,5,1,4,0,2},
  {5,1,3,2,4,0},{5,3,4,1,2,0},{5,4,2,3,1,0},{5,2,1,4,3,0},
  {2,1,5,0,4,3},{2,5,4,1,0,3},{2,4,0,5,1,3},{2,0,1,4,5,3},
  {4,0,2,3,5,1},{4,2,5,0,3,1},{4,5,3,2,0,1},{4,3,0,5,2,1},
  {1,0,3,2,5,4},{1,3,5,0,2,4},{1,5,2,3,0,4},{1,2,0,5,3,4}
};

struct Cube {
	int num[7];
};

int n, cnt, ans;
char str[1000];
Cube c[5], now[5];
map<string,int> id;

int ID(char *st) {
	if (id[st] == 0) return id[st] = ++cnt;
	return id[st];
}

void dfs(int dep) {
	if (n == dep) {
		int ans1 = 0;
		for (int j = 0; j < 6; ++j) {
			int count[30] = {0};
			for (int i = 0; i < n; ++i) ++count[now[i].num[j]];
			int up = 0;
			for (int i = 1; i <= cnt; ++i) up = max(up, count[i]);
			ans1 += n - up;
		}
		ans = min(ans, ans1);
		return ;	
	}
	for (int i = 0; i < 24; ++i) {
		for (int j = 0; j < 6; ++j) {
			now[dep].num[j] = c[dep].num[mov[i][j]];
		}
		dfs(dep + 1);
	}
}

void Clear() {
	memset(c, 0, sizeof c);
	memset(now, 0, sizeof now);
	id.clear();
	cnt = 0;
}

int main() {
	while (1 == scanf("%d", &n)) {
		if (0 == n) break;
		Clear();
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 6; ++j) {
				scanf("%s", str);
				c[i].num[j] = ID(str);
			}
		}
		if (1 == n) {
			puts("0");
			continue;
		}
		ans = (int)1e9;
		now[0] = c[0];
		dfs(1);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1244
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static int[] dp;
	static String[] arr=new String[]{"dreamer","dream","eraser","erase"};
	static String a="";
	static int n;
	
	static boolean match(int idx1,int idx2)
	{
		if(idx2+arr[idx1].length()>n)
			return false;
		return (a.substring(idx2,idx2+arr[idx1].length())).equals(arr[idx1]);
	}
	
	static int solve(int idx)
	{
		if(idx>=n)
		{
			return 1;
		}
		if(dp[idx]!=-1)
		{
			return dp[idx];
		}
		else
		{
			int val=0;
			for(int i=0;i<arr.length;i++)
			{
				if(match(i,idx))
				{
					val=val|solve(idx+arr[i].length());
				}
			}
			dp[idx]=val;return dp[idx];
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		a=new String(sc.next());n=a.length();dp=new int[n];Arrays.fill(dp,-1);
		out.println(solve(0)==1?"YES":"NO");out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 18964
object Main extends App {
  val day = io.StdIn.readLine()
  println(Day(day) distanceOfSun())
}

trait Day {
  def distanceOfSun(): Int
}

class Mon extends Day {
  override def distanceOfSun(): Int = 6
}

class Tue extends Day {
  override def distanceOfSun(): Int = 5
}

class Wed extends Day {
  override def distanceOfSun(): Int = 4
}

class Thu extends Day {
  override def distanceOfSun(): Int = 3
}

class Fri extends Day {
  override def distanceOfSun(): Int = 2
}

class Sat extends Day {
  override def distanceOfSun(): Int = 1
}

class Sun extends Day {
  override def distanceOfSun(): Int = 7
}

object Day {
  def apply(day: String): Day = {
    day match {
      case "MON" => new Mon()
      case "TUE" => new Tue()
      case "WED" => new Wed()
      case "THU" => new Thu()
      case "FRI" => new Fri()
      case "SAT" => new Sat()
      case "SUN" => new Sun()
      case _ => ???
    }
  }
}


Measured memory_bytes: 27184
a =int(input())
b =int(input())
c =int(input())
x =int(input())

total=0
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total=500*i+100*j+50*k
            if total==x:
                count+=1
                
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int MAXN = 1010;
ULL T[MAXN],A[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> T[i] >> A[i];

    ULL a = T[0], b = A[0],ta,tb,tta,ttb,dera,derb;
    for(int i = 1; i < N; ++i)
    {
        ta = T[i];
        tb = A[i];
        if(ta >= a && tb >= b)
            a = ta,b = tb;
        else if(ta >= a)
        {
            if(b%tb == 0)
            {
                a = ta*(b/tb);
                b = tb*(b/tb);
            }
            else
            {
                a = ta*(b/tb + 1);
                b = tb*(b/tb + 1);
            }
        }
        else if(tb >= b)
        {
            if(a%ta == 0)
            {
                b = tb*(a/ta);
                a = ta*(a/ta);
            }
            else
            {
                b = tb*(a/ta + 1);
                a = ta*(a/ta + 1);
            }
        }
        else
        {
            if(a%ta == 0) dera = a/ta;
            else dera = a/ta + 1;
            if(b%tb == 0) derb = b/tb;
            else derb = b/tb + 1;
            ULL uta = ta*dera;
            ULL utb = tb*dera;
            ULL uuta = ta*derb;
            ULL uutb = tb*derb;
            if(uta >= a && utb >= b && uuta >= a && uutb >= b)
            {
                if(uta+utb < uuta+uutb) a = uta,b = utb;
                else a = uuta, b = uutb;
            }
            else if(uta >= a && utb >= b)
                a = uta,b = utb;
            else
                a = uuta, b = uutb;
        }
    }
    cout << a+b << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Double diff = Double.MAX_VALUE;
		Integer output = 1001;
		Integer N = new Integer(scanner.next());
		Double T = new Double(scanner.next());
		Double A = new Double(scanner.next());
		ArrayList<Double> input = new ArrayList<Double>();
		for(int i = 0; i < N ; i ++ ) {
			input.add(Double.parseDouble(scanner.next()));
			input.set(i, T-input.get(i)*0.006);
			if(diff > Math.abs(A-input.get(i))) {
				diff = Math.abs(A-input.get(i));
				output = i+1;
			}
		}
		System.out.println(output);
		scanner.close();
	}
}


Measured memory_bytes: 23508
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Maybe

main = do
    n  <- fst . fromJust . B.readInt <$> B.getLine
    as <- sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine

    let ls = scanl (+) 0 as

    -- print $ zip as ls    
    print . (\x -> n - x) .  maximum $ sim (zip as ls) 0

sim []     n = [0]
sim (_:[]) n = [0]
sim ((x,x'):(y,y'):l) n = if 2*(x+x') >= y
    then sim ((y,y'):l) (n+1)
    else n+1 : sim ((y,y'):l) (n+1)

Measured memory_bytes: 16764
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
ll N, sum;

int *s = (int*)malloc(sizeof(int));

void sort (){
	for(int i = 0; i < N; i++){
		for(int j = N - 1; j > i; j--){
			int t;
			t = s[j];
			if(s[j-1] > s[j]) {
				s[j] = s[j-1];
				s[j-1] = t;
			}
		}
	}
}

int main(){
	sum = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> s[i];
		sum += s[i];
	}

	if(sum % 10 != 0) cout << sum <<endl;
	else{
		int t = 0;
		sort();
		while(s[t] % 10 == 0 && t < N){
			t++;
		}
		if(t == N) cout << 0 << endl;
		else cout << sum - s[t] << endl;
	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[120];
int main(){
	int i;
	cin>>a;
	bool flag=false;
	int n=strlen(a);
	for(i=0;i<n;i++)
		if(a[i]=='C') break;
	if(i!=n-1)
		for(i;i<n;i++)
			if(a[i]=='F') flag=true;
	if(flag==true) cout<<"Yes";
	else cout<<"No";	
	return 0;
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;
const int mxn = 2e5 + 5;

int fac[mxn], facr[mxn];

int mpow(int a, int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	int t = mpow(a, b / 2);
	t = (t * t) % mod;
	if (b % 2) t = (t * a) % mod;
	return t;
}

int cal(int n, int m) {
	return ((fac[n + m - 2] * facr[n - 1]) % mod * facr[m - 1]) % mod;
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int h, w, a, b; cin >> h >> w >> a >> b;
	fac[0] = facr[0] = 1;
	for (int i = 1; i <= h + w - 2; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
		facr[i] = mpow(fac[i], mod - 2);
	}
	int res = 0;
	for (int i = b + 1; i <= w; i++) {
		res += cal(h - a, i) * cal(a, w - i + 1);
		res %= mod;
	}
	cout << res << '\n';
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>

int n;
int f, b;

int main() {
	std::cin >> n;
	f = n;
	b = n;
	std::string str, r;
	while (1) {
		str = std::to_string(b);
		r = str;
		std::reverse(str.begin(), str.end());
		if (r == str)
			break;
		str = std::to_string(f);
		r = str;
		std::reverse(str.begin(), str.end());
		if (r == str)
			break;
		++f;
		--b;
	}
	std::cout << r << std::endl;
	return 0;
}

Measured memory_bytes: 3268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static double Solve1(int A, long[] V)
        {
            return (double)V.Take(A).Sum() / A;
        }
        static long Solve2(int N, int A, int B, long[] V)
        {
            long[][] C = new long[N + 1][];
            C[0] = new long[N + 1];
            C[0][0] = 1;
            for (int i = 1; i <= N; ++i)
            {
                C[i] = new long[N + 1];
                C[i][0] = 1;
                for (int j = 1; j <= N; ++j)
                {
                    C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
                }
            }
            long sum = 0;
            for (int i = A; i <= B; ++i)
            {
                if (i > A && V[0] > V[i - 1]) { break; }
                int n = V.Count(v => v == V[i - 1]);
                int r = V.Take(i).Count(v => v == V[i - 1]);
                sum += C[n][r];
            }
            return sum;
        }
        static void Main(string[] args)
        {
            int[] U = ReadInts();
            long[] V = ReadLongs().OrderByDescending(v => v).ToArray();
            Console.WriteLine(Solve1(U[1], V).ToString("F"));
            Console.WriteLine(Solve2(U[0], U[1], U[2], V));
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

	int ans=0;
	rep(i,n) rep(j,i) ans+=d[i]*d[j];
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 



ll s1[1000000]; ll s2[1000000]; ll s3[1000000];


int main()
{

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

fastio();

    ll n;
    cin>>n;

    ll a[n];

    For(i,0,n)
    cin>>a[i];

    ll cnt=0;

    if (n<3)
    {
        cout<<0;
        return 0;
    }

    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                s1[cnt]=a[i];
                s2[cnt]=a[j];
                s3[cnt]=a[k];
                cnt+=1;
            }
        }
    }

    ll ans=0;



    for(int i=0;i<1000000;i++)
    {
        if (s1[i]==0||s2[i]==0||s3[i]==0)
            continue;
        else
        {
            if (s1[i]!=s2[i] and s2[i]!=s3[i] and s3[i]!=s1[i])
            {
                if (s1[i]+s2[i]>s3[i] and s2[i]+s3[i]>s1[i] and s3[i]+s1[i]>s2[i])
                    ans+=1;
            }
        }
    }

    cout<<ans;

return 0;
}

Measured memory_bytes: 7440
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int sum[200000];
int dp[1 << 26];
int main(){
	fill(dp, dp + (1 << 26), (int)MOD);
	string s; cin >> s; int n = s.length();
	int las = 0;
	rep(i, n) {
		int t = s[i] - 'a';
		las ^= (1 << t);
		sum[i] = las;
	}
	fill(dp, dp + n, (int)MOD);
	dp[0] = 1;
	rep(i, 26) {
		dp[1 << i] = 1;
	}
	rep(i, n) {
		int x = sum[i];
		rep(j, 26) {
			int y = x ^ (1 << j);
			dp[y] = min(dp[y], dp[x] + 1);
		}
	}
	cout << dp[las] << endl;
	return 0;
}

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

int main() {
	char X, Y;
	cin >> X;
	cin >> Y;
	if (X == Y) cout << "=" << endl;
	else if (X > Y)cout << ">" << endl;
	else cout << "<" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N,M,Q;
  cin >> N >> M >> Q;
  vector<int> A(10);
  vector<vector<int>> S(Q,vector<int>(4));
  for(int h=0;h<Q;h++){
    for(int j=0;j<4;j++){
      cin >> S.at(h).at(j);
    }
  }
                        int mx=0;
  for(A.at(0)=1;A.at(0)<M+1;A.at(0)++){
      for(A.at(1)=A.at(0);A.at(1)<M+1;A.at(1)++){
        for(A.at(2)=A.at(1);A.at(2)<M+1;A.at(2)++){
          for(A.at(3)=A.at(2);A.at(3)<M+1;A.at(3)++){
        	for(A.at(4)=A.at(3);A.at(4)<M+1;A.at(4)++){
              for(A.at(5)=A.at(4);A.at(5)<M+1;A.at(5)++){
        		for(A.at(6)=A.at(5);A.at(6)<M+1;A.at(6)++){
          		  for(A.at(7)=A.at(6);A.at(7)<M+1;A.at(7)++){
        			for(A.at(8)=A.at(7);A.at(8)<M+1;A.at(8)++){
        			  for(A.at(9)=A.at(8);A.at(9)<M+1;A.at(9)++){
                        int score=0;
                        for(int k=0;k<Q;k++){
                          if(A.at(S.at(k).at(1)-1)-A.at(S.at(k).at(0)-1)==S.at(k).at(2)){
                            score+=S.at(k).at(3);
                          }
                        }
                        mx=max(mx,score);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
  }
      
      cout << mx <<endl;
    }

Measured memory_bytes: 3640
#include<bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;
 
using namespace std;
 
int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    vector<bool> jud(n,false);
    int ans=0;
    REP(i,n){
        int max;
        bool flg=false;
        for(int j=0;j<n;j++){
            if(jud[j]) continue;
          	if(red[j].f1>=blue[i].f1) continue;
            else{
                //cout << blue[i].f1 << ":" << red[j].f1 << endl;
                if(red[j].s2 < blue[i].s2){
                    if(!flg){
                        max=j;
                        flg=true;
                    }
                    if(red[max].s2 < red[j].s2) max = j;
                }
            }
        }
        if(flg){
            jud[max] = true;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// https://cf17-final.contest.atcoder.jp/tasks/cf17_final_d
#include <bits/stdc++.h>

using namespace std;

int n, h, p;
long long dp[5050], tmp[5050];
vector<pair<int, int>> v;

bool cmp(pair<int, int> a, pair<int, int> b) {
    return (a.first + a.second < b.first + b.second);
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &h, &p);
        v.emplace_back(h, p);
    }
    sort(v.begin(), v.end(), cmp);

    for(int i = 1; i < 5050; i++)
        dp[i] = 10000000000000000LL;

    for(int i = 0; i < n; i++) {
        memcpy(tmp, dp, sizeof dp);
        for(int j = 0; j <= i; j++) {
            if(v[i].first >= tmp[j])
                dp[j+1] = min(dp[j+1], tmp[j] + v[i].second);
        }
    }

    for(int i = n; i >= 0; i--) {
        if(dp[i] < 10000000000000000LL) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n,m;
    cin >> n >> m;
    ll p1 = min(n,m/2);
    ll p2 = max(0ll,(m-2*p1)/4);
    cout << p1 + p2 << endl; 
    return 0;
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
a=[0 for i in range(n)]
b=[0 for i in range(n)]
c=[[0 for i in range(2)] for i in range (n)]
for i in range(n):
    a[i],b[i] = map(int, input().split())
for i in range(n):
    c[i][0]=a[i]
for i in range(n):
    c[i][1]=b[i]
c.sort()
price=0
i=0
while(m>0):
    if(m>c[i][1]):
        price+=c[i][0]*c[i][1]
        m-=c[i][1]
    else:
        price+=c[i][0]*m
        m=0
    i+=1
print(price)

Measured memory_bytes: 23144