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

using namespace std;

#define int long long
#define endl "\n"

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

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

	rwf();

	int n, sum = 0;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 3640
#include <iostream>

int main(void){

  int a,b;
  std::cin >> a >> b;
  long c,d,e;
  c = a+b;
  d = a-b;
  e = a*b;

  long max_val = c;
  if(max_val<d) max_val = d;
  if(max_val<e) max_val = e;
  std::cout << max_val << std::endl;

  return 0;
}







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

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


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    long long ans = 0;
    sort(H.begin(), H.end());
    REP(i, N-K) ans += (long long) H[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int N, OddExistflag=0,endflag=0,cnt=0;
  int a[202];

  cin>>N;
  FOR(i,0,N){
    cin>>a[i];
  }

  while(1){
    FOR(j,0,N){
      if(a[j]%2==1){
        OddExistflag=1;
        endflag=1; break;
      }else{
        a[j]=a[j]/2;
      }
    }
    if(endflag==1){
      break;
    }else{
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	long long x, y;
	cin >> x >> y;
	long long a = x;
	int ans = 0;
	while (a <= y) {
		a *= 2;
		ans++;
	}
	cout << ans << endl;
	getchar();getchar();
	return 0;
}

Measured memory_bytes: 256
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

#define MAX_N (1000)
#define MAX_H (10000)
long long A[MAX_N + 1];
long long B[MAX_N + 1];

long long dp[MAX_N + 1][MAX_H + 1];

int main() {

	long long H, N;
	cin >> H >> N;
	for (long long i = 0; i < N; i++) {
		cin >> A[i+1] >> B[i+1];
	}
/*
i番目の魔法を使うと、敵の体力をA[i]減らせるが、自分の魔力もB[i]減る
Hだけ敵の体力を減らすとき、自分の魔力の減少値の最小値を求める

dp[i][j]:i番目までの魔法を使って、jだけ敵の体力を減らすときの魔力の減少値の最小値

dp[i][j] = dp[i-1][j] i番目の魔法を選択しない
dp[i][j] = dp[i-1][j-A[i]] + B[i] i番目の魔法を一回使う

まとめて書くと
dp[i][j] = min(dp[i-1][j], dp[i][j-A[i]]+B[i]);

*/


	// 1番目の魔法だけ使って倒す
	for (long long j = 1; j < H+1; j++) {
		dp[1][j] = (j / A[1] + (j % A[1] != (long long)(0))) * B[1];
	}

	for (long long i = 2; i < N+1; i++) {
		for (long long j = 1; j < H+1; j++) {
			dp[i][j] = min(dp[i - 1][j], dp[i][max((long long)(0), j - A[i])] + B[i]);
		}
	}

	cout << dp[N][H] << endl;

	return 0;
}



Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	ll k;
	cin >> n >> k;
	
	vector< vector<int> > a(60, vector<int>(2 * 1e5 + 5));
	for(int i = 0; i < n; ++i) {
		cin >> a[0][i];
		a[0][i]--;
	}
	
	for(int i = 0; i < 59; ++i) {
		for(int j = 0; j < n; ++j) {
			a[i + 1][j] = a[i][a[i][j]];
		}
	}
	
	int ans = 0;
	for(int bits = 59; bits >= 0; bits--) {
		if( k & (1LL << bits) ) {
			ans = a[bits][ans];
		}
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}


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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    string S;
    ll ans=0;
    int Wcnt=0,W[200010]={};
    cin>>S;

    for(int i=0;i<S.length();i++){
        if(S[i]=='W'){
            W[Wcnt] = i;
            Wcnt++;
        }
    }

    for(int i=0;i<Wcnt;i++){
        ans+=abs(W[i]-i);
    }

    cout<<ans<<endl;

    return 0;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

//	dsu.
struct dsu
{
	int *deg;
	int *pr;
	dsu(int n){
		deg = (int*)malloc(n*sizeof(int));
		pr = (int*)malloc(n*sizeof(int));
		for(int i=0;i<n;i++){
			deg[i]=1;
			pr[i] = i;
		}
	}
	int parent(int x){
		if(x!=pr[x]){
			return (pr[x] = parent(pr[x]));
		}
		return x;
	}
	void Union(int a,int b){
		int x = parent(a);
		int y = parent(b);
		if(x == y){
			return;
		}
		//assert(x!=y);
		if(deg[x]>deg[y]){
			pr[y] = x;
			deg[x] += deg[y];
		} else{
			pr[x] = y;
			deg[y] += deg[x];
		}
	}
};



int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n,m;
		scanf("%d %d",&n,&m);
		vector<pair<int,int> > e;
		for(int i=0;i<m;i++){
			int u,v;
			scanf("%d %d",&u,&v);
			e.push_back(make_pair(u,v));
		}
		int ans =0 ;
		for(int i=0;i<m;i++){
			dsu solver(100);
			for(int j=0;j<m;j++){
				if(j == i){
					continue;
				}
				solver.Union(e[j].first,e[j].second);
			}
			if(solver.parent(e[i].first) == solver.parent(e[i].second)){

			} else {
				ans++;
			}

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

Measured memory_bytes: 256
#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;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
using M = Mint<int>;
const int MAX = 505;
M dp[MAX][MAX]={};
M nx[MAX][MAX]={};
signed main(){
  int n,x;
  cin>>n>>x;
  vector<int> ls(n);
  for(int i=0;i<n;i++) cin>>ls[i];
  sort(ls.rbegin(),ls.rend());

  dp[0][0]=1;
  for(int l:ls){
    // i component
    for(int i=0;i<=n;i++){
      // length j
      for(int j=0;j<=x;j++){
        if(dp[i][j]==M(0)) continue;
        assert(j>=i*l);

        // solo
        if(j+l<=x)
          nx[i+1][j+l]+=dp[i][j]*M(i+1);

        if(!(i>=1)) continue;

        // whole
        nx[i+0][j+0]+=dp[i][j]*M(j-i*(l-1));

        // cover one
        for(int k=1;k<l and j+k<=x;k++)
          nx[i+0][j+k]+=dp[i][j]*M(i)*M(2);

        if(!(i>=2)) continue;

        // cover two
        for(int k=0;k+2<=l and j+k<=x;k++)
          nx[i-1][j+k]+=dp[i][j]*M(i-1)*M(l-k-1);
      }
    }

    for(int i=0;i<MAX;i++)
      for(int j=0;j<MAX;j++)
        dp[i][j]=nx[i][j],nx[i][j]=0;
  }


  M ans{0};
  for(int i=1;i<=n;i++)
    ans+=dp[i][x];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;
alias Pair = Tuple!(long, "s", long, "x");

void main() {
    long n;
    scan(n);

    long[Pair] mem;

    long func(long s, long x) {
        if (Pair(s, x) in mem) {
            return mem[Pair(s, x)];
        }
        if (s == 0) {
            return 1;
        }
        if (x == 0) {
            return s/2 + 1;
        }

        mem[Pair(s, x)] = (func(s/2, x/2) + func((s-1)/2, (x-1)/2)) % mod;
        if (s >= 2) {
            mem[Pair(s, x)] += func((s-2)/2, x/2);
        }
        mem[Pair(s, x)] %= mod;

        return mem[Pair(s, x)];
    }

    writeln(func(n, n));
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String aargs[]){
    Scanner sc = new Scanner(System.in);
    
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    sc.nextLine();
    char[][] map = new char[h][w];
    int ans = 0;
    
    for(int i = 0; i < h; i++){
      String str = sc.nextLine();
      for(int j = 0; j < w; j++){
      	map[i][j] = str.charAt(j);
      }
    }
    
    for(int i = 0; i < Math.pow(2, h); i++){
      for(int j = 0; j < (int)Math.pow(2, w); j++){
        int ii = i;
        
        int black = 0;
		for(int s = h - 1; s >= 0; s--){
          int ss = (int)Math.pow(2, s);
          int jj = j;
          for(int t = w - 1; t >= 0; t--){
            int tt = (int)Math.pow(2, t);
            if(ii / ss == 0 && jj / tt == 0 && map[s][t] == '#'){
              black++;
            }
            
            
            jj %= tt;
          }
          ii %= ss;
        }
        
        if(black == k){
          ans++;
        }
      }
    }
    
    System.out.println(ans);
    
  }
}

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

int main() {
  string S;
  cin >> S;
  int a=S.size();
  if(S[a-1]=='s') {
    cout << S << "es" << endl;
  }
  else {
    cout << S << "s" << endl;
  }
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include <string>
using namespace std;

#define N 4
#define N2 16

int MDT[N2][N2]; /* Mahattan Distance Table */

/* down, left, up, right */
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};

class Puzzle
{
    public:
    int pc[N2]; /* number in each piece */
    int MD;     /* Manhattan Distance */
    int space;  /* empty space */
    int dpth;   /* Depth */

    /* override operator for mapping */
    bool operator < (const Puzzle &p) const
    {
        for (int i = 0; i < N2; i++) {
            if (pc[i] == p.pc[i]) continue;
            return pc[i] < p.pc[i];
        }
        return false;
    }
};

class State
{
    public:
    Puzzle pz;
    int cost; /* MD + dpth */

    bool operator < (const State &st) const
    {
        return cost > st.cost;
    }
};

map<Puzzle, bool> mp;
priority_queue<State> pq;

int getAllMD(Puzzle &p)
{
    int sum = 0;
    for (int i = 0; i < N2; i++) {
        if (N2 == p.pc[i]) continue;
        sum += MDT[i][p.pc[i] - 1];
    }
    return sum;
}

int astar(Puzzle &in)
{
    State initial;
    initial.pz = in;
    initial.cost = in.MD + in.dpth;
    mp[in] = true;
    pq.push(initial);
    while (!pq.empty()) {
        State node = pq.top();
        pq.pop();
        if (0 == node.pz.MD) {
            return node.pz.dpth;
        }
        int x, y;
        x = node.pz.space % N;
        y = node.pz.space / N;
        for (int i = 0; i < 4; i++) {
            int tx = x + dx[i], ty = y + dy[i];
            if (tx < 0 || tx >= N || ty < 0 || ty >= N)
                continue;
            Puzzle tp = node.pz;
            tp.space = tx + ty * N;
            swap(tp.pc[tp.space], tp.pc[node.pz.space]);
            if (!mp[tp]) {
                State ts;
                tp.MD -= MDT[tp.space][node.pz.pc[tp.space] - 1];
                tp.MD += MDT[node.pz.space][tp.pc[node.pz.space] - 1];
                tp.dpth++;
                mp[tp] = true;
                ts.pz = tp;
                ts.cost = tp.MD + tp.dpth;
                pq.push(ts);
            }
        }
    }
    return -1;
}

int main()
{
    for (int i = 0; i < N2; i++) {
        for (int j = 0; j < N2; j++) {
            /* |x - x'| + |y - y'| */
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        }
    }

    Puzzle in;
    for (int i = 0; i < N2; i++) {
        cin >> in.pc[i];
        if (!in.pc[i]) {
            in.pc[i] = N2;
            in.space = i;
        }
    }
    in.MD = getAllMD(in);
    in.dpth = 0;

    cout << astar(in) << endl;
    return 0;
}

Measured memory_bytes: 256736
# AOJ 0155 Spider Jin
# Python3 2018.6.23 bal4u
# 最短経路問題

MAXLEN = 50
MAX = 100
INF = 0x7ffffffffffffff
x = [0]*(MAX+2)
y = [0]*(MAX+2)
d = [[INF for y in range(MAX+2)] for x in range(MAX+2)]
dist = [INF]*(MAX+2)
pre = [0]*(MAX+2)
	
import heapq
def dijkstra(V, to, start, goal):
	global dist
	dist = [INF]*V
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while len(Q):
		t, s = heapq.heappop(Q)
		if s == goal: break
		if dist[s] < t: continue
		for e in range(1, V):
			if to[s][e] < INF:
				nt = t + to[s][e]**0.5
				if dist[e] > nt:
					dist[e] = nt
					heapq.heappush(Q, (nt, e))
					pre[e] = s
while 1:
	n = int(input())
	if n == 0: break
	for i in range(n):
		j, x_, y_ = map(int, input().split())
		x[j], y[j] = x_, y_
	n += 1
	d = [[INF for y in range(n)] for x in range(n)]
	for i in range(1, n):
		for j in range(1, n):
			dx, dy = x[i]-x[j], y[i]-y[j]
			dd = dx**2 + dy**2		
			if dd <= MAXLEN**2:
				d[i][j] = d[j][i] = dd
	m = int(input())
	for i in range(m):
		s, g = map(int, input().split())
		if s == g: print(s)
		else:
			dijkstra(n, d, s, g)
			if dist[g] == INF: print("NA")
			else:
				ans = []
				ans.append(g)
				while g != s:
					g = pre[g]
					ans.append(g)
				print(*ans[::-1])
	


Measured memory_bytes: 5824
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

ll a, b, c;

void work() {
  a = read(), b = read(), c = read();
  if (c > a + b + 1) printf("%lld\n", b + (a + b + 1));
  else printf("%lld\n", b + c);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int ans = 0;
  for (int i=0; i<N; i++) {
    string left = S.substr(0, i+1);
    sort(left.begin(), left.end());
    left.erase(unique(left.begin(), left.end()), left.end());
    string right = S.substr(i+1);
    sort(right.begin(), right.end());
    right.erase(unique(right.begin(), right.end()), right.end());

    int cnt = 0;
    for (int j=0; j<left.size(); j++) {
      if (right.find(left[j]) != -1)
        cnt++;
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

constexpr cat mod = 1000000007;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = x * x % mod;
	if(e & 1) x = x * a % mod;
	return x;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<cat> inv(N+1, 0);
	for(int i = 1; i <= N; i++) inv[i] = pw(i, mod-2);
	vector<cat> sum_inv(N+1, 0);
	for(int i = 2; i <= N; i++) {
		sum_inv[i] = sum_inv[i-1] + inv[i];
		if(sum_inv[i] >= mod) sum_inv[i] -= mod;
	}
	cat ans = 0;
	for(int i = 0; i < N; i++) ans += A[i] * (1 + sum_inv[i+1] + sum_inv[N-i]) % mod;
	ans %= mod;
	for(int i = 1; i <= N; i++) ans = ans * i % mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 2560
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

n,d = inp
p r_up(n,d*2+1)

Measured memory_bytes: 1788
N,P=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]%=2

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)

Measured memory_bytes: 3064
def bubble_sort(A):
    flag = True
    swap = 0
    while flag:
        flag = False
        for j in range(len(A)-1,0,-1):
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1],A[j]
                swap += 1
                flag = True
    return swap

if __name__=='__main__':
   N=int(input()) 
   A=list(map(int,input().split()))
   swap = bubble_sort(A)
   print(*A)
   print(swap)

Measured memory_bytes: 7744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#define inf 1000000007
using namespace std;
 
int main(void){
    long long int n, k;
    cin >> n >> k;
    long long int ans = 0;
    vector<vector<long long int>> data(n, vector<long long int>(2));
    for(long long int i = 0; i < n; i++)
        for(long long int j = 0; j < 2; j++)  
            cin >> data.at(i).at(j);
    sort(data.begin(), data.end());
    for(long long int i = 0; i < n; i++){
        ans += data.at(i).at(1);
        if(ans >= k){
            cout << data.at(i).at(0) << endl;
            break;
        }
    }

    return 0;
}

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

bool compare( int* a , int *b , int n )
{
    for(int i=0;i<n;i++)
    {
        if( a[i] != b[i] )
            return false;
    }
    return true;
}
int main()
{
    int n ;
    cin>>n;
    int p[n];
    int q[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    for(int i=0;i<n;i++)
    {
        cin>>q[i];
    }
    int a[n];
    for(int i=0;i<n;i++)
        a[i] = i+1;
    int t1 =0,t2=0;
    int count =0;
    while( next_permutation(a,a+n) )
    {
        count++;
        if( compare(a,p,n))
            t1 =count;
        if( compare(a,q,n))
            t2 = count;
    }
    cout<<abs( t1-t2);

}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll h;
vector<ll> v[5];

int main(){
	while (cin >> h&&h){
		ll ans = 0;
		REP(i, 5){
			v[i].clear();
			v[i].resize(h);
		}
		REP(i, h){
			REP(j, 5){
				cin >> v[j][h - 1 - i];
			}
		}
		bool f = 1;
		while (f){
			//REP(i, 5){
			//	REP(j, v[i].size()){
			//		cout << v[i][j] << "  ";
			//	}
			//	cout << endl;
			//}
			f = 0;
			vector<pair<P, ll>> vpi;
			REP(i, h){
				ll cnt = 1, pos = 0;
				REP(j, 5 - 1){
					if (v[j][i] == v[j + 1][i]){
						if (v[j][i] != -1)cnt++;
						else cnt = 0;
					}
					else{
						if (cnt >= 3){
							vpi.push_back({ P(pos, cnt), i });
						}
						pos = j + 1;
						cnt = 1;
					}
				}
				if (cnt >= 3){
					vpi.push_back({ P(pos, cnt), i });
				}
			}
			REP(i, vpi.size()){
				f = 1;
				ll he = vpi[i].second, pos = vpi[i].first.first, cnt = vpi[i].first.second;
				//cout << he << " " << pos << " " << cnt << endl;
				ans += (v[pos][he] * cnt);
				REP(j, cnt)v[pos + j][he] = -1;
			}
			REP(i, 5){
				auto it = v[i].begin();
				while (it != v[i].end()){
					if (*it == -1){
						it = v[i].erase(it);
					}
					else it++;
				}
			}
			REP(i, 5){
				while (v[i].size() < h){
					v[i].push_back(-1);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t,l;cin >> n >> t >> l;
	vector<vector<int>> g1(n,vector<int>()), g2(n,vector<int>());
	rep(i,t){
		int p,q;cin >> p >> q;
		p--;q--;
		g1[p].pb(q);
		g1[q].pb(p);
	}
	rep(i,l){
		int r,s;cin >> r >> s;
		r--;s--;
		g2[r].pb(s);
		g2[s].pb(r);
	}
	vector<pii> a(n);
	map<pii,int> m;
	queue<int> q;
	int k = 1;
	rep(i,n){
		if(a.at(i).first == 0){
			a.at(i).first = k;
			q.push(i);
			while(!q.empty()){
				int cur = q.front();q.pop();
				rep(j,g1.at(cur).size()){
					int next = g1.at(cur).at(j);
					if(a.at(next).first != 0) continue;
					a.at(next).first = k;
					q.push(next);
				}
			}
			k++;
		}
	}
	k = 1;
	rep(i,n){
		if(a.at(i).second == 0){
			a.at(i).second = k;
			q.push(i);
			while(!q.empty()){
				int cur = q.front();q.pop();
				rep(j,g2.at(cur).size()){
					int next = g2.at(cur).at(j);
					if(a.at(next).second != 0) continue;
					a.at(next).second = k;
					q.push(next);
				}
			}
			k++;
		}
	}
	vector<int> ans(n);
	rep(i,n) m[a.at(i)]++;
	rep(i,n) ans.at(i) = m[a.at(i)];
	rep(i,n){
		if(i == n - 1) cout << ans.at(i) << endl;
		else cout << ans.at(i) << " ";
	}
}


Measured memory_bytes: 28544
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll long long
#define mod 1000000007

using namespace std;

bool check(string str)
{
	for (int i = 0; i < str.size() / 2; i++)
	{
		if (str[i] != str[i + str.size() / 2])
			return false;
	}

	return true;
}

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	string str;  cin >> str;

	while(str.size() != 0)
	{
		str.pop_back();
		str.pop_back();
		if (check(str))
		{
			cout << str.size();
			break;
		}
	}

	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() {
  ll x;
  cin >> x;
  ll ans = 100;
  ll year = 0;
  while(x > ans) {
    ll tmp = ans / 100;
    ans += tmp;
    year++;
  }
  
  cout << year << endl;
}


Measured memory_bytes: 3568
fun main(args: Array<String>) {
    val inf = 1200001
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val keys = (0 until m).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        val c = readLine()!!.split(' ')
                .map { 1 shl (it.toInt() - 1) }
                .reduce { acc, i -> acc or i }
        a to c
    }

    val dp = Array(m + 1) { IntArray(4096) { inf } }
    dp[0][0] = 0

    for (i in 0 until m) {
        for (j in 0 until 4096) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])
            val j2 = j or keys[i].second
            dp[i + 1][j2] = Math.min(dp[i + 1][j2], dp[i][j] + keys[i].first)
        }
    }

    dp[m][(1 shl n) - 1].let { println(if (it < inf) it else -1) }
}


Measured memory_bytes: 67660
#include <iostream>
#include <set>

#include <vector>
#include <algorithm>

using namespace std;

typedef long long int lli;

int main () {
  int n; cin >> n;
  vector<lli> as(n, 0);
  for (int i = 0; i < n; i++) { cin >> as[i]; }

  int ans = 0;
  multiset<lli> memo;
  for (int i = n - 1; i >= 0; i--) {
    auto it = memo.upper_bound(as[i]);
    if (memo.end() == it) {
      ans++;
    } else {
      memo.erase(it);
    }
    memo.insert(as[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5888
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <time.h>
using namespace std;

/* ?????????????????°???????´? */
void trace(int arr[], int n) {
    int i;
    for (i = 0; i < n; i++ ) {
        if(i > 0) {
            printf(" ");
        }
        printf("%d", arr[i]);
    }
    printf("\n");
}

int selectionSort(int arr[],int n){
    int count = 0;
    for(int i = 0;i<n-1;i++){
        int min = i;
        for(int j = i + 1;j<n;j++){
            if(arr[j] < arr[min]){
                min = j;
            }
        }
        if(min != i){
            swap(arr[min],arr[i]);
            count++;
        }

    }
    return count;
}





int main(){
    int n;
    int arr[110];
    cin>>n;
    for (int i = 0; i < n;i++) {
        cin>>arr[i];
    }

    int count = selectionSort(arr,n);
    trace(arr,n);
    cout<<count<<endl;
}

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

using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 200007;

int cnt[N];

int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int maks = 0;
    vector <int> A(n);
    for(auto &x: A) cin >> x;
    for(auto x: A){ cnt[x]++; maks = max(maks, x);}
    LL ans = 0;
    for(int i = 1; i <= maks; i++){
        ans += LL(cnt[i])*(cnt[i]-1)/2;
    }
    for(auto x: A){
        ans -= LL(cnt[x])*(cnt[x]-1)/2;
        cout << ans+LL(cnt[x]-1)*(cnt[x]-2)/2 << '\n';
        ans += LL(cnt[x])*(cnt[x]-1)/2;
    }

	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

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



int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int mmin=10000;
  rep(i,N){
    cin >> m[i];
    X -= m[i];
    if(mmin>m[i]) mmin = m[i];
  }

  cout << N + X/mmin << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,r;
  while(cin>>n>>r,n+r!=0){
    queue<int> yama;
    queue<int> x;
    queue<int> y;
    queue<int> z;
    for(int i=n;i>=1;i--)
      yama.push(i);
    for(int i=0;i<r;i++){
      int p,c;
      cin>>p>>c;
      for(int i=1;i<=p-1;i++){
	x.push(yama.front());
	yama.pop();
      }
      for(int i=1;i<=c;i++){
	y.push(yama.front());
	yama.pop();
      }
      while(!yama.empty()){
	z.push(yama.front());
	yama.pop();
      }
      while(!y.empty()){
	yama.push(y.front());
	y.pop();
      }
      while(!x.empty()){
	yama.push(x.front());
	x.pop();
      }
      while(!z.empty()){
	yama.push(z.front());
	z.pop();
      }
    }
    cout<<yama.front()<<endl;
  }
  return 0;
}

Measured memory_bytes: 2956
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int a, b, c;
	int max;
	scanf("%d %d %d\n", &a, &b, &c);
	if(a>b) max = a;
	else max = b;
	if(max<c) max = c;
	printf("%d\n", a + b +c + max * 9);
	return 0;
}

Measured memory_bytes: 128
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 29 August 2020 05:29:54 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
            long double d,t,s; 
            cin>>d>>t>>s;
            long double time = d/s;
            //cout<<time<<endl;
            if((long double)time <= (long double)t){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



Measured memory_bytes: 3740
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var) \
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

struct Solver {
  explicit Solver(int n) {
    parent_index_.reserve(n);
    for (int i = 0; i < n; ++i) {
      parent_index_.push_back(i);
    }
  }
  void register_friend(int s, int t) {
    auto r1 = get_root(s);
    auto r2 = get_root(t);
    if (r1 != r2) {
      parent_index_[r2] = r1;
    }
  }
  bool can_reach(int s, int t) { return get_root(s) == get_root(t); }

 private:
  int get_root(int i) {
    for (auto cur = i;;) {
      auto next = parent_index_[cur];
      if (next == cur) {
        return cur;
      }
      parent_index_[cur] = parent_index_[next];
      cur = next;
    }
  }

  vector<int> parent_index_;
};

int main() {
  int n, m;
  cin >> n >> m;
  Solver sol(n);
  for (int i = 0; i < m; ++i) {
    int s, t;
    cin >> s >> t;
    sol.register_friend(s, t);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int s, t;
    cin >> s >> t;
    auto ok = sol.can_reach(s, t);
    cout << (ok ? "yes" : "no") << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double n, m, d ;
    cin >> n >> m >> d ;
    if(d==0){
        cout << SP(10) << (m-1)/n <<endl ;
    }
    else if(2*d<=n){
        cout << SP(10) << (d+d+(n-2*d)*2)*(m-1)/(n*n) <<endl ;
    }
    else{
        cout << SP(10) << (2*d-2*n)*(m-1)/(n*n) <<endl ;
    }

    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{

	string O, E;
	cin >> O >> E;
	string Ans = "";

	if (O.size() == E.size()) {
		for (int i = 0; i < E.size(); i++) {
			cout << O[i] << E[i];
		}
	}
	else {
		for (int i = 0; i < E.size(); i++) {
			cout << O[i] << E[i];
		}
		cout << O[O.size() - 1];
	}


	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] l = new int[N];
        for(int i = 0 ; i < N; i++){
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for(int i = 0 ; i < K; i++){
            sum = sum + l[N-i-1];
        }
        System.out.println(sum);
     }
}

Measured memory_bytes: 21844
n = int(input())
s = input()
ans = []
first = []
for i in range(n - 2):
    if s[i] in first:continue
    first.append(s[i])
    second = []
    for j in range(i + 1, n - 1):
        if s[j] in second:continue 
        second.append(s[j])
        third = []
        for k in range(j + 1, n):
            if s[k] in third:continue  
            third.append(s[k])
            ans.append(s[i] + s[j] + s[k])
            
print(len(ans))

Measured memory_bytes: 73604
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;

const ld PI = acos(-1);

int main(){
    fast_io();
    ld R; cin >> R;
    cout << 2 * PI * R;
    
    return 0;
}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

    cout << bitset<32>(a&b) << endl;
    cout << bitset<32>(a|b) << endl;
    cout << bitset<32>(a^b) << endl;

    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define ll long long
#define MAXN 102
// #define M 1000000007
#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define pii pair< int,int >
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define vii vector<pii>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)

using namespace std;

int main()
{
    int n,d;
    cin>>n>>d;
    int cnt=0;
    f(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ll n;
    cin>>n;
    string s;
    while(n > 0){
        s += ((n+25)%26)+'a';
        n = (n-1)/26;
    }
    s = string(s.rbegin(),s.rend());
    cout<<s<<"\n";
    
	return 0;
}

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

int main()
{
    ll t;
    cin>>t;
    unordered_set<string> s;
    while(t--)
    {
        string str;
        cin>>str;
        s.insert(str);
    }

    cout<<s.size();
}

Measured memory_bytes: 17704
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

long long result, n,m,k,bufL,bufLL;

typedef pair<long long, long long> pl;

long long rx[1000],ry[1000];
long long bx[1000],by[1000];
long long bufS[10];



bool used[100000] = {};

vector<pl> re;
vector<pl> bl;
pl buf;



int main() {
	result = 0;

	cin >> n;
	

	
	for (int i = 0; i < n; i++) {
		cin >> rx[i]>>ry[i];
		buf.first = rx[i];
		buf.second = ry[i];
		re.push_back(buf);
	}

	for (int i = 0; i < n; i++) {
		cin >> bx[i] >> by[i];
		buf.first = bx[i];
		buf.second = by[i];
		bl.push_back(buf);
	}

	sort(bl.begin(), bl.end());
	sort(re.begin(), re.end());

	for (int i = 0; i < n; i++) {
		bufL = -1;
		for (int j = 0; j < n; j++) {

			if (used[j] == false) {
				if (re[j].first < bl[i].first) {
					if (re[j].second < bl[i].second) {
						if (bufL < 0) {
							bufL = j;
							result++;
						}
						else if (re[bufL].second < re[j].second) {
							bufL = j;
						}
					}

				}
				else {
					break;
				}
			}
		}

		if (bufL >= 0) {
			used[bufL] = true;
		}

	}

	cout << result << endl;

return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define PI 3.14159265
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a, b, x, v, result, tan;
    cin>>a>>b>>x;
    v = x;
    double temp = 2*v/(a*a);
    if(temp > b) {
    	double v1 = a*a*b;
    	double height = (2*(v1 - v))/(a*a);
    	tan = (height)/a;
    	result = (atan(tan) * 180)/ PI;
    	printf("%.10lf\n", result);
    }
    else if(temp == b) {
    	tan = temp/a;
    	result = (atan(tan) * 180)/ PI;
    	printf("%.10lf\n", result);
    }
    else {
    	double base = (2*v)/(a*b);
    	tan = b/base;
    	result = (atan(tan) * 180)/ PI;
    	printf("%.10lf\n", result);
    }
}

Measured memory_bytes: 384
import sys
from bisect import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n,m,x=map(int, input().split())
    a=list(map(int, input().split()))
    i=bisect_left(a,x)
    print(min(i,m-i))

main()

Measured memory_bytes: 2940
s = input()

def isPalindrome(a):
    i = 0
    j = len(a)-1
    while(i<j):
        if(a[i] != a[j]):
            return False
        i += 1
        j -= 1
    return True

n = len(s)
# print(s[:int((n-1)/2)])
# print(s[int((n+3)/2)-1:])
# print(isPalindrome(s[:int((n-1)/2)]))
print("Yes" if isPalindrome(s) and isPalindrome(s[:int((n-1)/2)]) and isPalindrome(s[int((n+3)/2)-1:]) else "No")

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

int main()
{
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << "\n";
}


Measured memory_bytes: 1024
n,m = map(int,input().split())

lmin = 1
rmax = n
for _ in range(m):
    l,r = map(int,input().split())
    if l > lmin:
        lmin = l
    if rmax > r:
        rmax = r
    
print(max(rmax - lmin + 1, 0))
    

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

int main() {
    int n;
    cin >> n;
    int v[n];
    int c;
    int sum=0;
    for(int i=0; i<n; i++) cin >> v[i];
    for(int i=0; i<n; i++) {
        cin >> c;
        v[i] -= c;
        if(v[i]>0) sum += v[i];
    }
    cout << sum << endl;

    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() {
    string S;
    cin >> S;

    bool ok = true;
    if (S[0] == S[1] && S[1] == S[2]) ok = false;

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

ll getSize(ll n) {
	ll size = 1;
	while(size < n) {
		size *= 2;
	}
	return size * 2;
}

class Flowers {
public:
	ll height;
	ll beauty;
	ll index;
    Flowers() {
        height = 0;
        beauty = 0;
        index = 0;
    }
};

bool compare(Flowers a, Flowers b) {
	return a.height < b.height;
}

vector<Flowers> arr;
vector<ll> tree;

ll query(ll l, ll r, ll v, ll tl, ll tr) {
	if(tl > r || tr < l) {
		return 0;
	}
    else if(tr >= r and tl <= l) {
		return tree[v];
	}
	else {
		ll mid = l + (r - l) / 2;
		ll a = query(l, mid, v * 2 + 1, tl , tr);
        ll b = query(mid + 1, r, v * 2 + 2, tl, tr);
		return max(a, b);
	}
}

void update(ll l, ll r, ll v, ll index, ll value) {
	if(l == r) tree[v] = value;
	else {
		ll mid = l + (r - l) / 2;
		if(index <= mid) {
			update(l, mid, v * 2 +1, index, value);		
		}
		else {
			update(mid + 1, r, v * 2 + 2, index, value);	
		}
		tree[v] = max(tree[v * 2 + 1], tree[v * 2 + 2]);
	}
}

int main() {
	ll n; cin >> n;
	arr.resize(n);
	tree.assign(getSize(n), 0);
	for(ll i = 0; i < n; i++) {
		cin >>  arr[i].height;
        arr[i].index = i;
	}
	for(ll i = 0; i < n; i++) {
		cin >> arr[i].beauty;
	}
	sort(arr.begin(), arr.end(), compare);
	ll maxi = LLONG_MIN;	
	for(ll i = 0; i < n; i++) {
		ll max_beauty = query(0, n - 1, 0, 0, arr[i].index - 1);
		maxi = max(maxi, max_beauty + arr[i].beauty);
		update(0, n - 1, 0, arr[i].index, max_beauty + arr[i].beauty);	
	}
    cout << maxi << endl;
}

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

int main()
{
	string s;
	cin.tie(0);
	getline(cin, s);

	for (int i = 0; i < s.length(); i++) {
		if (s[i] >= 'a' && s[i] <= 'z') {
			s[i] -= ' ';
		}
		else if (s[i] >= 'A' && s[i] <= 'Z') {
			s[i] += ' ';
		}
	}

	cout << s << "\n";
}


Measured memory_bytes: 3144
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

for i in range(1, int(N**0.5 + 2)):
	if i**2 > N:
		print((i-1)**2)
		break


Measured memory_bytes: 5460
// AOJ 1166

#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

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

typedef pair <int, int> P;

int main(void)
{
	int w, h;
	while (cin >> w >> h, w && h){
		int wall[128][128], floor[128][128];

		// wall[i][**]
		// floor[i][**]
		for (int i = 0; i < h-1; i++){
			for (int j = 0; j < w-1; j++){
				cin >> wall[i][j];
			}
			for (int j = 0; j < w; j++){
				cin >> floor[i][j];
			}
		}
			for (int j = 0; j < w-1; j++){
				cin >> wall[h-1][j];
			}


		int field[128][128];
		for (int i = 0; i < 128; i++){
			fill(field[i], field[i] + 128, 0);
		}
		field[0][0] = 1;
		queue <P> q;
		q.push(P(0, 0));
		// first = y, i, h ; second = x, j, w
		while (q.size()){
			P p = q.front();
			q.pop();
			int x = p.second, y = p.first;
			// cout << y << " " << x << endl;
			if (x == (w - 1) && y == (h - 1)){
				break;
			}
			for (int i = 0; i < 4; i++){
				int nx = x + dx[i], ny = y + dy[i];
				if (nx < 0 || ny < 0 || w-1 < nx || h-1 < ny) continue;
				// もうきてるよ
				if (field[ny][nx]) continue;

				if (i == 0 && floor[y][x]) continue;
/*
					// 下に行く
					// i,j -> floor[i][j]
					// 1 NG 0 OK
					if (floor[y][x]) continue;
					q.push(P(ny, nx));
					field[ny][nx] = field[y][x] + 1;
				}
*/
				if (i == 1 && floor[ny][nx]) continue;
/*
					// 上にいく
					// i,j -> floor[i-1][j]
					if (floor[ny-1][nx]) continue;
					q.push(P(ny, nx));
					field[ny][nx] = field[y][x] + 1;
				}
*/	
				if (i == 2 && wall[y][x]) continue;
/*
					// みぎ
					// i,j -> wall[i][j]
					if (wall[y][x]) continue;
					q.push(P(ny, nx));
					field[ny][nx] = field[y][x] + 1;
				}
*/				
				if (i == 3 && floor[ny][nx]) continue;
/*
					// ひだり
					// i,j -> wall[i][j-1]
					if (nx == 0 || floor[ny][nx-1]) continue;
					q.push(P(ny, nx));
					field[ny][nx] = field[y][x] + 1;
				}
*/
				field[ny][nx] = field[y][x] + 1;
				q.push(P(ny, nx));
			}
		}

		cout << field[h-1][w-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1316