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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int a[500005];

int main(){
	int N;
	scanf("%d", &N);
	rep(i,0,3*N)
		scanf("%d", a+i);
	sort(a, a+(3*N));
	ll ans=0;
	for(int i=0; i < N; ++i)
		ans += a[3*N-2-2*i];
	cout << ans << endl;
}

Measured memory_bytes: 1408
//Keep Working hard
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int (i) = (a); (i) < (b) ;(i)++)

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
  //  fileIO();
    string a,b;
    cin >> a >> b;
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    if(a < b)cout <<"Yes";
    else cout <<"No";
    return 0;
}


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

int main() {
    string str;
    int N;
    cin >> str >> N;
    int ans = 0;
    while (N--) {
        string tmp;
        cin >> tmp;

        tmp = tmp + tmp;

        bool flag = false;
        for (int i = 0; i < (int)tmp.size() - (int)str.size() + 1; i++) {
            if (str[0] == tmp[i]) {
                bool check = true;
                for (int j = 0; check && j < (int)str.size(); j++) {
                    if (str[j] != tmp[j + i]) check = false;
                }
                if (check) flag = true;
            }
        }
        if (flag) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3124
def inpl(): return [int(i) for i in input().split()]

N, H = inpl()
maxa = 0
B = []
for i in range(N):
    a, b = inpl()
    B.append(b)
    maxa = max(maxa,a)
B = sorted(B)
ctr = N
for i in range(N):
    if maxa <= B[i]:
        ctr = i
        break
ans = 0
for i in range(N-1,i-1,-1):
    ans += 1 
    H -= B[i]
    if H <= 0:
        break
else: ans += -(-H//maxa)
print(ans)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

ll choose2(ll n) {
  return n * (n-1) / 2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> cnt(n, 0);
  rep(i,n) {
    cnt[a[i]]++;
  }
  ll tot = 0;
  rep(i, n) {
    tot += choose2(cnt[i]);
  }
  rep(i, n) {
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4096
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	void run() {
		int[] value = new int[8];
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			String str = sc.next();
			for(int j=0;j<8;j++) {
				value[j] = (int) (str.charAt(j) - '0');
			}
			Arrays.sort(value);
			System.out.println(max(value) - min(value));
		}
		
	}
	int min(int[] value) {
		String max = "";
		for (int i: value) max += i;
		return Integer.parseInt(max);
	}
	
	int max(int[] value) {
		String min = "";
		for (int i=7;i>=0;i--) min += value[i];
		return Integer.parseInt(min);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

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

bool is_prime(int p){
	if(p <= 1) return false;
	for(int i = 2; i*i < p; i++){
		if(p%i == 0) return false;
	}
	return true;
}

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

	int p = x;
	while(!is_prime(p)) p++;

	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0),cout<<fixed<<setprecision(15);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    cout<<a*b<<nl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
using namespace std;
int N,M,A,B,C,D,x1,x2,y1,y2;
int K[32][32];
const int inf =1001001111;

int main() {
for(int j=0;j<32;j++){
	for(int jj=0;jj<32;jj++){
		K[j][jj]=inf;
	}
}
	
scanf("%d%d",&N,&M);
for(int ii=0;ii<M;ii++){
	scanf("%d,%d,%d,%d",&A,&B,&C,&D);
	K[A][B]=C;
	K[B][A]=D;
}
for(int k=1;k<=N;k++){
for(int i=1;i<=N;i++){
	for(int j=1;j<=N;j++){
		if(K[i][j]>K[i][k]+K[k][j]){
			K[i][j]=K[i][k]+K[k][j];
		}
	}
}	
}

scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
int a;
a=y1-y2-K[x1][x2]-K[x2][x1];

printf("%d\n", a);


	return 0;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int solve(){
	int N;
	cin >> N;
	if(!N)return 1;
	vector<int> vec(N),dp(N);
	for(int i=0;i<N;i++)cin >> vec[i];
	dp[0]=vec[0];
	for(int i=1;i<N;i++)dp[i]=max(dp[i-1]+vec[i],vec[i]);
	cout << *max_element(dp.begin(),dp.end()) << endl;
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>
int main(void){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?'){
			break;
		}
		if(op == '+'){
			printf("%d\n",a+b);
		}
		else if(op == '-'){
			printf("%d\n",a-b);
		}
		else if(op == '*'){
			printf("%d\n",a*b);
		}
		else if(op == '/'){
			printf("%d\n",a/b);
		}
	}
	return 0;
}

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

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

int main() {
  int n, a, cnt = 0;
  cin >> n;
  rep(i, n) {
    cin >> a;
    if (a % 2 == 1) cnt++;
  }

  cout << (cnt % 2 ? "NO" : "YES") << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC135B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] pinput = Console.ReadLine().Split(' ');
            int[] p = new int[N];
            for(int i = 0; i < N; i++)
            {
                p[i] = int.Parse(pinput[i]);
            }
            bool hantei = true;
            int count = 0;
            for(int i = 1; i <= N; i++)
            {
                if (p[i - 1] != i)
                {
                    count += 1;
                    if (p[p[i - 1] - 1] != i) hantei = false;
                }
            }
            if (count > 2) hantei = false;
            if (hantei) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 27456
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>

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

  
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      string s;
      cin>>s;
      if(s=="RRR")cout<<3;
      else if(s=="RSR" or s=="RSS" or s=="SSR" or s=="SRS")cout<<1;
      else if(s=="RRS" or s=="SRR")cout<<2;
      else cout<<0;
    }



  






return 0;
}     



Measured memory_bytes: 3604
#include<stdio.h>
int main(){
    
    long long n,a,b,c;
    scanf("%lld",&n);
    
    for(a = 1;a <= 3500;a++)
    {
        for (b = a;b <= 3500;b++)
        {
            c = n*a*b/(4*a*b - n*b - n*a);
            if((4*a*b - n*b - n*a)>0){
                if(n*a*b%(4*a*b - n*b - n*a)==0 )
                {
                    printf("%lld %lld %lld\n",a,b,c);
                    return 0;
                }
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

vector<vector<int>> dist;
int N;
ll prim() {
    vector<int>mincost(N, INF);
    vector<int> used(N, false);
    mincost[0] = 0;
    priority_queue<P, vector<P>, greater<>> pque;
    pque.emplace(0, 0);
    ll res = 0;
    while(!pque.empty()) {
        P p = pque.top();
        pque.pop();
        if(used[p.second]) continue;
        used[p.second] = true;
        res += p.first;
        for(int i = 0; i < N; ++i) {
            if(dist[p.second][i] == 0) continue;
            if(!used[i]) {
                pque.push(mp(dist[p.second][i], i));
            }
        }
    }
    return res;
}



int main() {
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    rep(i, N)
        rep(j, N)
            cin >> A[i][j];

    dist = A;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            for(int k = 0; k < N; ++k) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    bool ok = true;
    rep(i, N) {
        rep(j, N) {
            if(dist[i][j] != A[i][j]) ok = false;
        }
    }
    ll ans = 0;
    if(!ok) {
        cout << -1 << endl;
    }else {
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < N; ++j) {
                for(int k = 0; k < N; ++k) {
                    if(i == k || j == i) continue;
                    if(dist[j][i] + dist[i][k] == dist[j][k])
                        dist[j][k] = INF;
                }
            }
        }
        rep(i, N) {
            for(int j = i + 1; j < N; ++j) {
                if(dist[i][j] != INF) ans += dist[i][j];
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;

char buf[100005];

int main(){
	int n,k;
	scanf("%d%d%s", &n, &k, buf);
	int a=0,b=0,ans=0;
	for(int i=1;i<n;++i){
		if(buf[i]=='L' && buf[i-1]=='R') ++a;
		else if(buf[i]=='R' && buf[i-1]=='L') ++b;
		else ++ans;
	}
	int c = min(k, min(a,b));
	ans += c * 2;
	if(a!=b && c<k) ++ans;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int a, b, c; cin >> a >> b >> c;
	cout << ((c-a-b>0 && 4*a*b < (c-a-b)*(c-a-b)) ? "Yes\n" : "No\n");
}

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

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<double> v(n);
  for (int i = 0; i < n; ++i)
    std::cin >> v.at(i);

  std::sort(v.begin(), v.end());
  double worth = v.at(0);
  for (int i = 1; i < n; ++i) {
    worth = (worth + v.at(i)) / 2.;
  }
  std::cout << worth << std::endl;
}


Measured memory_bytes: 256
import math

n=int(input())
t=int(input())
mint=t
t1=int(input())
if t1<t: mint=t1
maxtt=t1-t


for i in range(2,n):
    t=int(input())
 
    if t-mint>maxtt: maxtt=t-mint
    if t<mint: mint=t
    
print(int(maxtt))   


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, M; cin >> N >> M;
    vector<P> pv;
    rep(i, M){
        int a, b; cin >> a >> b;
        pv.push_back(make_pair(b, a));
    }

    sort(all(pv));
    int ans=0;
    int tmp=0;
    for(auto a: pv){
        if(a.second >= tmp){
            ans++;
            tmp = a.first;
        }
    }

    cout << ans << endl;
}

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


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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair

int main()
{
    ll A, B;
    cin >> A >> B;

    cout << A * B << endl;


    return 0;
}


Measured memory_bytes: 3636
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[] A = new int[N];
      for(int i = 0; i < N; i++){
        A[i] = sc.nextInt();
      }
      
      // 評価
      String[] judge = new String[N-K];
      for(int i = 0; i < N-K; i++){
        if(A[i] < A[i+K]){
          judge[i] = "Yes";
        }else{
          judge[i] = "No";
        }
        
        // 出力
        System.out.println(judge[i]);
      }
      
    }

}

Measured memory_bytes: 60284
import java.util.*;

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


		

	}
}




Measured memory_bytes: 21972
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	void make_set(int v){
		parent[v] = v;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b)
			parent[b] = a;
	}
};


//~ vector< vector<int> > edge;
//~ int main(){
	//~ int n, m; cin >> n >> m;
	//~ for(int i = 1; i <= m; i++){
		//~ int w, u, v; cin>> w >> u >> v;
		//~ edge.push_back({w,u,v});
	//~ }
	//~ sort(edge.begin(), edge.end());
	//~ vector< vector<int> > ans;
	//~ dsu d;
	//~ d.make_set(n);
	//~ for(int i = 0; i < (int)edge.size(); i++){
	//~ for(int i = 0; i < 1; i++){
		//~ int u = edge[i][1];
		//~ int v = edge[i][2];
		//~ int x = d.find_set(u);
		//~ int y = d.find_set(v);
		//~ cout<< x<<" "<<y<<endl;
		//~ if(u != v){
			//~ d.union_sets(u, v);
			//~ ans.push_back(edge[i]);
		//~ }
	//~ }
	
	//~ for(int i = 0; i < (int) edge.size(); i++){
		//~ cout<< ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2]<<endl; 
	//~ }
	//~ return 0;
//~ }

pair<double,double> p[50000];		
double d = 0;
int n;
double dist(pair<double,double>& a, pair<double,double>& b){
	return sqrt((a.f-b.f)*(a.f-b.f) + (a.s-b.s)*(a.s-b.s));
}

double fact(int n){
	double f = 1;
	for(int i = 1; i<= n; i++)
		f *= i;
	return f;
}

void path(int n){
	for(int i = 1; i <= n-1; i++){
		d += dist(p[i],p[i+1]);
	}
}

void permute(int l, int r){
	if(l == r)
		path(n);
	else{
		for(int i = l; i <= r; i++){
			swap(p[l],p[i]);
			permute(l+1,r);
			swap(p[l],p[i]);
		}
	}
}

int main(){
	cin>> n;
	for(int i = 1; i<=n; i++){
		cin>> p[i].f >> p[i].s;
	}
	permute(1,n);
	cout<<setprecision(11)<< d/fact(n);
	return 0;
}


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

inline int Input() {
	char c = getchar(); int x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * z;
}

const int maxn(1e5 + 5);

int n, sx, x[maxn];

inline int Gcd(int x, int y) {
	return !y ? x : Gcd(y, x % y);
}

int main() {
	n = Input(), sx = Input();
	for (int i = 1; i <= n; ++i) x[i] = abs(Input() - sx);
	int ans = x[1];
	for (int i = 2; i <= n; ++i) ans = Gcd(ans, x[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
n = int(input())
s = input()
d = {'R':0,'G':0,'B':0}
for c in s:
    d[c]+=1
all = d['R']*d['G']*d['B']
cnt = 0
for i in range(n):
    for j in range(i+1, n+1):
        k = (j*2)-i
        if k >= n:
            continue
        if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            cnt += 1
print(all-cnt)

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

using namespace std;

long long gkd(long long a,long long b){
    long long c;
    while(b){
        c=a;
        a=b;
        b=c%b;
    }
    return a;
}

int main()
{
	long long n;
	cin>>n;
	long long g,ans=1;
	//long long a[500];
	for(int i=0;i<n;i++){
		long long a;
		cin>>a;
		g=gkd(ans,a);
		ans *= a/g;
	}
//	long long k=a[0];
   // for(int i=1;i<n;++i){
    //    k=k*a[i]/gkd(k,a[i]);
   // }
    cout<<ans<<endl;
}

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


void solve(long long H){
    long long count = 2; 
    while (H > 1) {
        H = H / 2;
        count *= 2;
    }
    cout << count - 1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int n;
  char s[5001];
  int t[5001][5001] = {};
  char a[5001];
  int s_max;
  int s_max2;
  int _max;
 
  scanf("%d", &n);
  scanf("%s", s);
  
  for(int i = 0;i < n; i++){
    s_max = 0;
  	s_max2 = 0;
    for(int j = 0;j < n - i; j++){
      if (s[j + i] == s[j]){
      	a[j] = 1;
      	s_max2 = s_max2 + 1;
      } else {
      	a[j] = 0;
      	if (s_max < s_max2){
          s_max = s_max2;
        }
        s_max2 = 0;
      }
      if (s_max < s_max2){
        s_max = s_max2;
      }
  	}
  if (s_max > i){
    s_max = i;
  }
    
  if (_max < s_max){
    _max = s_max;
  }
  }
  
  printf("%d\n", _max);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.length()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3908
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] charArray = S.toCharArray();

        List<Integer> counts = new ArrayList<Integer>();
        int cnt = 0;
        for (int i = 0; i < charArray.length; i++) {
            if (charArray[i] == 'A' || charArray[i] == 'C' || charArray[i] == 'G' || charArray[i] == 'T') {
                cnt++;
                if (i == charArray.length -1) {
                    counts.add(cnt);
                }
            }
            else {
                if (cnt != 0) {
                    counts.add(cnt);
                    cnt = 0;
                }
            }
        }
        Collections.sort(counts, Collections.reverseOrder());
        if (counts.size() == 0) {
            System.out.print(0);
        }
        else {
            System.out.print(counts.get(0));
        }
    }

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

}


Measured memory_bytes: 21844
// 記述をスリム化して, 再提出.
// 解き直し.
// https://img.atcoder.jp/abc162/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[202020], dp[4][101010];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. 解説通り(dp更新).
    dp[1][1] = a[0];
    dp[2][1] = max(a[0], a[1]);
    if(N >= 3){
        dp[3][1] = max({a[0], a[1], a[2]});
        dp[3][2] = a[0] + a[2];
    }
    repx(i, 4, N + 1){
        // i に ついて, s個以上, e個以下 を 選択.
        int s = i / 2 - 1, e = (i + 1) / 2;
        int c = (i % 3 == 0) ? 3 : (i % 3); // 現在.
        int o = (c - 1 == 0) ? 3 : c - 1;   // 一つ前.
        int t = (o - 1 == 0) ? 3 : o - 1;   // 二つ前.
        dp[c][s]     = max(dp[t][s - 1] + a[i - 1], dp[o][s]);
        dp[c][s + 1] = max(dp[t][s] + a[i - 1],     dp[o][s + 1]);
        if(s + 2 == e) dp[c][s + 2] = dp[t][s + 1] + a[i - 1];
    }
    // rep(i, 4){
    //     rep(j, N + 1) printf("%lld ", dp[i][j]);
    //     puts("");
    // }
    
    // 3. 出力.
    int index = (N % 3 == 0) ? 3 : (N % 3);
    printf("%lld\n", dp[index][N / 2]);
    return 0;
    
}

Measured memory_bytes: 7684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] x = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        long ans = Long.MAX_VALUE;
        for (int i = 1; i <= 100; i++) {
            long tmp = 0;
            for (int j : x) {
                tmp += Math.pow(j - i, 2);
            }
            ans = Math.min(tmp, ans);
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 21204
N = int(input())
T, A = (int(i) for i in input().split()) 
h_list = [int(i) for i in input().split()]

min_diff = 10000
index = 1
min_index = 0
for h in h_list:
    t = T-h*0.006
    diff = abs(t-A)
    if min_diff > diff:
        min_diff = diff
        min_index = index

    index += 1

print(min_index)

Measured memory_bytes: 3064
while (line = gets) do
  n, r = line.split.map(&:to_i)
  #puts "n: #{n} , r:#{r}"
  array = (1..n).to_a
  r.times do
    p, c = gets.split.map(&:to_i)
    #puts "#{p} : #{c}"
    sliced_array = array.slice!(-p - c + 1..-p)
    array += sliced_array if sliced_array
  end
  p array.last if array.last != nil
end

Measured memory_bytes: 9436
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STR(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}

int main(){
	int n, m, a[55], b[55], uni[55], ans = 0;
	scanf("%d%d", &n, &m);
	REP(i, m){
		scanf("%d%d", a + i, b + i);
		a[i]--;
		b[i]--;
	}
	REP(i, m){
		REP(j, n) uni[j] = j;
		REP(j, m) if(i != j){
			while(uni[a[j]] != uni[uni[a[j]]]) uni[a[j]] = uni[uni[a[j]]];
			while(uni[b[j]] != uni[uni[b[j]]]) uni[b[j]] = uni[uni[b[j]]];
			uni[uni[b[j]]] = uni[a[j]];
		}
		while(uni[a[i]] != uni[uni[a[i]]]) uni[a[i]] = uni[uni[a[i]]];
		while(uni[b[i]] != uni[uni[b[i]]]) uni[b[i]] = uni[uni[b[i]]];
		if(uni[a[i]] != uni[b[i]]) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
from collections import Counter
n = int(input())
S = ['_']*n
for i in range(n):
    S[i] = input()
cS = Counter(S).most_common()
mx = cS[0][1]
ans = []
for i in range(len(cS)):
    if cS[i][1]==mx:
        ans.append(cS[i][0])
    else:
        break
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 45028
#include<iostream>
#include<string>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<cctype>
#include<climits>
#include<cstddef>
#include<typeinfo>

using namespace std;

int judge(const string s1, const string s2)
{
	if (s1 == s2) return 0;
	else if (s1 > s2) return 1;
	else return (-1);
}
int main()
{
	int n;
	int pt = 0, ph = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		string sa, sb;
		
		cin >> sa >> sb;

		if (judge(sa, sb) == 0) {
			pt += 1;
			ph += 1;
		}
		else if (judge(sa, sb) == 1) pt += 3;
		else ph += 3;
	}
	cout << pt << " " << ph << endl;
	
	return 0;
}


Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=500010;
int n,q;
char ch[MAXN];
struct node{
    int l,r;
    bitset<30> s;
}f[MAXN*4];
inline void pushup(int p)
{
    f[p].s=f[p<<1].s|f[p<<1|1].s;
}
void build(int p,int l,int r)
{
    f[p].l=l,f[p].r=r;
    if(l==r)
    {
        f[p].s.reset();
        f[p].s[ch[l]-'a'+1]=1;
        return;
    }
    int mid=(l+r)>>1;
    build(p<<1,l,mid),build(p<<1|1,mid+1,r);
    pushup(p);
}
void modify(int p,int x,int c)
{
    if(f[p].l==f[p].r)
    {
        f[p].s.reset();
        f[p].s[c]=1;
        return;
    }
    int mid=(f[p].l+f[p].r)>>1;
    if(x<=mid) modify(p<<1,x,c);
    else modify(p<<1|1,x,c);
    pushup(p);
}
bitset<30> query(int p,int l,int r)
{
    if(f[p].l>=l&&f[p].r<=r) return f[p].s;
    bitset<30> ret;
    ret.reset();
    int mid=(f[p].l+f[p].r)>>1;
    if(l<=mid) ret=ret|query(p<<1,l,r);
    if(r>mid) ret=ret|query(p<<1|1,l,r);
    return ret;
}
int main()
{
    read(n);
    scanf("%s",ch+1);
    build(1,1,n);
    read(q);
    for(int i=1;i<=q;i++)
    {
        int op;
        read(op);
        if(op==1)
        {
            int x;
            char y;
            read(x);
            scanf("%c",&y);
            modify(1,x,y-'a'+1);
        }
        else
        {
            int l,r;
            read(l),read(r);
            write(query(1,l,r).count()),putchar('\n');
        }
    }
	return 0;
}


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

using namespace std;

int main(){
	int N, T, H, L;
	cin >> N >> T >> H >> L;
	vector<int> t(N), h(N);
	for(int i = 0; i < N; ++i){
		cin >> t[i] >> h[i];
	}
	int i = 0, lt = 0, lh = 0;
	while(true){
		if(t[i] >= 1){
			++lt; ++T;
			if(T > L){ break; }
			--t[i];
		}else if(h[i] >= 1){
			++lh; ++H;
			--h[i];
		}else{
			break;
		}
		if(lt + lh * 10 >= 9){
			T -= (lt + lh * 10) - 9;
			if(T < 0){ break; }
			t[i] += (lt + lh * 10) - 9;
			lt = lh = 0;
		}
		i = (i + 1) % N;
	}
	cout << (i + 1) << endl;
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
struct node
{
    int x,v;
}f[N];
LL sum[N];
bool cmp(node a,node b)
{
    return a.x<b.x;
}
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    int a;
    rrr(n,m,a);
    FOR(i,1,n){
        r(f[i].x); r(f[i].v);
    }
    sort(f+1,f+n+1,cmp);
    LL now=0;
    LL ans=0;
    FOR(i,1,n){
        sum[i]+=sum[i-1];
        f[i].v+=sum[i];
        if(f[i].v<=0) continue;
        int l=i,r=n,res;
        while(l<=r){
            int mid=(l+r)>>1;
            if(f[mid].x<=f[i].x+2*m){
                res=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        //i ---- ans   都要-
        int t=f[i].v/a;
        if(f[i].v%a) t++;
        ans+=t;
        sum[i]-=t*a;
        sum[res+1]+=t*a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5888
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

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

using namespace std;



int main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int n, S;
    int r[20010];

    while (true) {
        cin >> n >> S;
        if (n == 0 && S == 0) break;

        rep(i,n) cin >> r[i];

        sort(r, r + n);

        int ans = 0;
        rep(i,n) {
            int needle = S + 1 - r[i];
            int* pos = lower_bound(r + i + 1, r + n, needle);
            ans += (int)((r + n) - pos);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){long n,x=0;cin>>n;vector<int>a(n,0);
           for(long i=0;i<n;i++){char c;cin>>c;
if(c=='W'){a.at(i)=1;x++;}}
           long y=n-x,p=0;
for(long i=0;i<y;i++)p+=a.at(i);
           cout<<p<<endl;}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;


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

    string first = s.substr(0, n/2);
    string second = s.substr(n/2);
    if (n%2 == 0 && first == second) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define MP make_pair
#define PB push_back
#define REP(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long LL;
typedef vector<int> VI;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int n;
	VI ans;

	while(1){
		int n;
		int sum = 0,cnt = 0;
		cin >> n;
		if(n == 0) break;
		VI s(n);
		
		for(int i = 0;i < n;i++){
			cin >> s[i];
		}

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

		for(int i = 1;i < s.size() - 1;i++){
			sum += s[i];
			cnt++;
		}

		ans.PB(sum / cnt);
	}

	for(int i = 0;i < ans.size();i++)
		cout << ans[i] << endl;;

	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li ma[100100];
li mi[100100];

li t[100100];
li a[100100];
li n;

int main() {
    cin >> n;
    rin{
        cin >> t[i];
    }
    ma[0] = mi[0] = t[0];
    repp(i, 1, n) {
        if (t[i] != t[i - 1]) {
            ma[i] = mi[i] = t[i];
        } else {
            ma[i] = t[i];
            mi[i] = 1;
        }
    }
    rin{
        cin >> a[i];
    }
    if (mi[n - 1] > a[n - 1] || ma[n - 1] < a[n - 1]) {
        puts("0");
        return 0;
    }
    ma[n - 1] = mi[n - 1] = a[n - 1];
    for (li i = n - 2; i >= 0; i--) {
        if (a[i] != a[i + 1]) {
            if (mi[i] > a[i] || ma[i] < a[i]) {
                puts("0");
                return 0;
            }
            ma[i] = mi[i] = a[i];
        } else {
            if (ma[i] == mi[i] && a[i] < ma[i]) {
                puts("0");
                return 0;
            }
            ma[i] = min(ma[i], a[i]);
        }
    }

    li res = 1;
    rin{
        res = (res * (ma[i] - mi[i] + 1)) % MOD;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
#define N 1000005
int c[N],n;
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n;
	int m=1e6;
	rep(i,1,m) for(int j=i;j<=m;j+=i) ++c[j];
	ll ret=0;
	rep(i,1,n-1){
		int num=c[i];
//		int sq=sqrt(i);
		ret+=num;
	}
	std::cout<<ret<<'\n';
	return 0;
}

Measured memory_bytes: 7560
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string a[10],b[10],s,t;
map<string,int> d;
string nst(string x,string a,string b){
	string nx;
	int L=x.size();
	int M=a.size();
	rep(j,L){
		if(j<L-M+1&&x.substr(j,M)==a){
			nx+=b;
			j+=M-1;
		}else{
			nx+=x[j];
		}
	}
	return nx;
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>a[i]>>b[i];
		cin>>s>>t;
		queue<string> que;
		d.clear();
		d[s]=0;
		que.push(s);
		while(!que.empty()){
			string x=que.front();
			que.pop();
			rep(i,N){
				string nx=nst(x,a[i],b[i]);
				if(x==nx||nx.size()>t.size()) continue;
				if(!d.count(nx)||d[nx]>d[x]+1){
					d[nx]=d[x]+1;
					que.push(nx);
				}
			}
		}
		if(d.count(t)) cout<<d[t]<<endl;
		else puts("-1");
	}
}

Measured memory_bytes: 1476
from math import sqrt
from itertools import combinations

def dist(y, z):
  return sqrt(sum([(yi - zi)**2 for yi, zi in zip(y, z)]))

def is_int(num):
  return num == int(num)


n, d = map(int, input().split())
x = [None]*n

for i in range(n):
  x[i] = list(map(int, input().split()))


cnt = 0
for i, j in combinations(range(n), 2):
  if is_int(dist(x[i], x[j])):
    cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N = 3e5+5;

bool ispalidrome(string s){
    for(int i=0;i<s.size()/2;++i){
        if(s[i]!=s[sz(s)-1-i])
            return false;
    }
    return true;
}


int main(){
    string s;
    cin>>s;
    const int n = s.size();
    if(ispalidrome(s) and ispalidrome(s.substr(0,(n-1)/2)) and ispalidrome(s.substr((n+3)/2,n-1-((n+3)/2))))
        return cout<<"Yes"<<endl,0;
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n; cin >> n;
	string s; cin >> s;
	int c1 = 0, c2 = 0;
	for (auto &c : s) {
		if (c == 'R') {
			++c1;
		} else {
			++c2;
		}
	}
	if (c1 > c2) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
class stackClass:

	def __init__(self):
		self.array = []

	def push(self, x):
		self.array.append(x)

	def pop(self):
		a = self.array[len(self.array)-1]
		del self.array[len(self.array)-1]
		return a

	def isFull(self):
		return False

	def isEmpty(self):
		if len(self.array) == 0:
			return True
		else:
			return False


ilst = input().split()
stack = stackClass()
for i in ilst:
	if i == '+':
		a = stack.pop()
		b = stack.pop()
		stack.push(b + a)
	elif i == '-':
		a = stack.pop()
		b = stack.pop()
		stack.push(b - a)
	elif i == '*':
		a = stack.pop()
		b = stack.pop()
		stack.push(b * a)
	else:
		stack.push(int(i))

print(stack.pop())



Measured memory_bytes: 5600
import bisect, copy

n = int(input())
a = list(map(int, input().split()))
a.sort()

b = copy.deepcopy(a)
for i in range(n - 1):
    b[i + 1] += b[i]

def ok(x):
    while True:
        y = bisect.bisect_right(a, b[x] * 2)
        if x == y - 1:
            return False
        if y == n:
            return True
        x = y - 1
    

lo = -1
hi = n
while abs(lo - hi) > 1:
    mi = (lo + hi) // 2
    if ok(mi):
        hi = mi
    else:
        lo = mi

print(n - hi)

Measured memory_bytes: 15080
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll n;
ll ans[500][110];
int main(){
	cin>>n;
	REP(i,500)
		REP(j,100)
		ans[i][j]=0;
	for(ll i=0;i<4;i++){
		for(ll j=0;j<40;j+=10){
			for(ll k=0;k<400;k+=100){
				ans[k+i+j][3]=1;
			}
		}
	}
	ans[21][3]=0;
	ans[12][3]=0;
	ans[201][3]=0;
	for(ll l=4;l<101;l++){
		for(ll i=0;i<4;i++){
			for(ll j=0;j<40;j+=10){
				for(ll k=0;k<400;k+=100){
					for(ll ne=0;ne<4;ne++){
						ll l1=i+j+k;
						ll k1=l1*10+ne;
						if(k1%1000==21||k1%1000==12||k1%1000==201||k1==121||k1==221||k1==321||k1==211||k1==221||k1==231){
							continue;
						}
						ans[k1%1000][l]+=ans[l1][l-1];
						ans[k1%1000][l]%=MOD;
					}
				}
			}
		}
	}
	ll ansl=0;
	for(ll i=0;i<4;i++){
		for(ll j=0;j<40;j+=10){
			for(ll k=0;k<400;k+=100){
				ansl+=ans[i+j+k][n];
				ansl%=MOD;
			}
		}
	}
	cout<<ansl<<endl;
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env ruby

def countingSort(a)
  k = a.max + 1
  b = []
  c = Hash.new(0)

  a.each do |aa|
    c[aa] += 1
  end

  c.sort.each do |k, j|
    j.times { b << k }
  end

  b
end

gets
a = gets.split.map(&:to_i)

puts countingSort(a).join(' ')

Measured memory_bytes: 151952
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let patterns: Vec<Vec<char>> = ["dream", "dreamer", "erase", "eraser"]
        .iter()
        .map(|s| s.chars().rev().collect())
        .collect();
    let s: Vec<char> = read::<String>().chars().rev().collect();
    let mut s = &s[..];
    let mut succeeded = true;
    while s.len() > 0 {
        //println!("{:?}", s);
        let matched = patterns.iter().find(|&p| s.starts_with(p));
        if let Some(p) = matched {
            s = &s[p.len()..];
        } else {
            succeeded = false;
            break;
        }
    }
    println!("{}", if succeeded {"YES"} else {"NO"});
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	string s; cin >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'o')cnt++;
	}
	cout << ((8 - cnt <= (15 - s.size()) ? "YES" : "NO")) << endl;
}

Measured memory_bytes: 256
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
  
n,k = (int(x) for x in input().split())
xk = Base_10_to_n(n, k)

print(len(str(xk)))

Measured memory_bytes: 38512
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y = readline().split()

    if X < Y:
        print('<')
    elif X > Y:
        print('>')
    else:
        print('=')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8988