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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m;
		// n=s.length();
		ll a[n];
		vector<pair<ll,ll> > h;
		rep(i,n)
		{
			cin>>a[i];
		}
		ll b;
		sort(a,a+n);
		rep(i,m)
		{
			cin>>b>>k;
			h.pb({k,b});
		}
		sort(h.rbegin(),h.rend());
		ll idx=0;
		rep(i,n)
		{
			if(idx>m)
				c+=a[i];
			else
			{
				c+=max(a[i],h[idx].ff);
				h[idx].ss--;
				if(h[idx].ss==0)
					idx++;
			}
		}
		cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

int main() {
    ll N, K;
    cin >> N >> K;

    auto check = [&](ll mid) {
        ll left = mid;
        for(ll i = 0; i < N - 1; i++) {
            if(left == 0) return false;
            left--;
            left -= left / K;
        }
        return left > 0;
    };
    
    ll ok = 1e18 + 10, ng = 0;
    while(ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok - 1 << endl;
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]=='1')cout << 9;
        else cout << 1;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x, y, ans, i, b, c=1;

int main(){
cin >> x >> y;
for(i=0;b<y;i++){
    b = 1LL *pow(2,i) * x;
    if(b>y)break;
}
cout << i << endl;

return 0;}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: i64 = s.next().unwrap().parse().unwrap();
	let a: Vec<_> = s.map(|a| a.parse::<i64>().unwrap() - k).collect();
	let mut cum: Vec<_> = vec![(0, 0)].into_iter().chain(a.iter().scan((0, 0u32), |s, a|{ *s = (s.0 + a, s.1 + 1); Some(*s) })).collect();
	cum.sort();
	let c: Vec<_> = {
		let mut r = vec![(0, 0); n + 1];
		let mut last = cum.first().unwrap().0;
		let mut j = 0;
		for (a, i) in cum {
			if a != last {
				last = a;
				j += 1;
			}
			r[i as usize] = (i, j);
		}
		r.sort();
		r.into_iter().map(|r| r.1).collect()
	};
	let mut bit = BIT::new(n + 1);
	let mut ans = 0;
	for i in c {
		ans += bit.sum(i + 1) as u64;
		bit.add(i, 1);
	}
	println!("{}", ans);
}

struct BIT<T> {
	data: Vec<T>
}

impl<T> BIT<T>
where
	T: Clone + Default + std::ops::AddAssign
{
	fn new(n: usize) -> BIT<T> {
		BIT { data: vec![T::default(); n + 1] }
	}
	fn sum(&self, i: usize) -> T {
		let mut r = T::default();
		let mut i = i;
		while i > 0 {
			r += self.data[i].clone();
			i &= i - 1;
		}
		r
	}
	fn add(&mut self, i: usize, value: T) {
		let mut i = i + 1;
		while i < self.data.len() {
			self.data[i] += value.clone();
			i += i & (!i + 1);
		}
	}
}


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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll k,a,b, ans = 1;
    cin >> k >> a >> b;

    if(a+2 < b) {
        ans = a;
        k -= a-1;
        ans += (b-a) * (k/2);
        k %= 2;
        if(k) ++ans;
    } else {
        ans += k;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b;
string b1;
signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> a >> b1;
    b = (b1[0] - '0') * 100ll + (b1[2] - '0') * 10ll + (b1[3] - '0') * 1ll;
    a = a * b / 100;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3640
import * as fs from 'fs';

// main
function main(input: string[]) {
    // param
    var d: number = 0;
    var t: number = 0;
    var s: number = 0;
    var ans: string = "";
    // init
    [d, t, s] = input[0].split(" ").map(x => Number(x));
    // solve
    ans = (d <= s * t) ? "Yes" : "No";
    // answer
    console.log(ans);
}

// entrypoint
function entrypoint() {
    try {
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29596
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a;
  cin >> a;
  int n = 0;
  int w = 0;
  int s = 0;
  int e = 0;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == 'N') {
      n = 1;
    }
    if (a[i] == 'W') {
      w = 1;
    }
    if (a[i] == 'S') {
      s = 1;
    }
    if (a[i] == 'E') {
      e = 1;
    }
  }
  if (n == 0 and s == 1) {
    cout << "No";
  } else if (n == 1 and s == 0) {
    cout << "No";
  } else if (e == 0 and w == 1) {
    cout << "No";
  } else if (e == 1 and w == 0) {
    cout << "No";
  } else {
    cout << "Yes";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np

a,b = map(int, input().split())
if(a <= 2 * b):
  print('0')
else:
  print(a - b * 2)


Measured memory_bytes: 23156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String weather[] = {"Sunny", "Cloudy", "Rainy"};
		for (int i=0;i<3;i++) {
			if (s.equals(weather[i])==true) {
				System.out.println(weather[(i+1)%3]);
				return ;
			}
		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main(){
	ll n;
	cin>>n;
	if(n==1){
		cout <<1;
		return 0;
	}
	ll sum=0;
	ll ch2;
	for(int i=1;i<=n;i++){
		sum+=i;
		if(sum>=n){
			ch2=i;
			break;
		}
	}
	ll ch=sum-n;
	for(int i=1;i<=ch2;i++){
		if(ch==i){
			continue;
		}
		cout << i<<endl;
	}
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int N, M;
    cin >> N >> M;

    tuple<int, int, int> cities[M];

    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        cities[i] = make_tuple(y, p, i);
    }

    sort(cities, cities + M);

    int pref[N+1];
    fill(pref, pref + N+1, 0);
    pair<int, int> pairs[M];

    for (int i = 0; i < M; i++) {
        tuple<int, int, int> city = cities[i];
        int year, pre, idx;
        tie(year, pre, idx) = city;
        pref[pre]++;
        pairs[idx] = make_pair(pre, pref[pre]);
    }

    for (int i = 0; i < M; i++) {
        printf("%06d%06d\n", pairs[i].first, pairs[i].second);
    }

    return 0;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  vector<int> v(8);
  {
    auto a {1};
    for (auto& e: v) {
      e = a;
      a *= 2;
    }
  }

  cout << *prev(upper_bound(v.begin(), v.end(), get_value<int>(cin))) << '\n';
  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
  if A[i] % 10 != 0:
    B.append(A[i])
S = sum(A[i] for i in range(N))
if S % 10 != 0:
  print(S)
else:
  if len(B) != 0:
    print(S - min(B))
  else:
    print(0)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace B
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = Console.ReadLine();
			var N = int.Parse(line);
			var P = new List<int>();
			for (int i = 0; i < N; i++) {
				P.Add(int.Parse(Console.ReadLine()));
			}

			var sum = P.Sum();
			sum -= P.Max() / 2;
			Console.WriteLine(sum);
		}
	}
}

Measured memory_bytes: 11220
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
 int a,b;cin >>a >>b;
 if(a%500 <= b)cout << "Yes" <<endl;
 else cout << "No" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

int main(){
	int n,a[10],c;
	
	while(cin>>n){
		c=0;
		for(int i=0;i<10;i++) a[i]=0;
		for(int i=9;i>=0;i--){
			if(n>=pow(2,i)){
				n-=pow(2,i);
				a[i]++;
			}
		}
		for(int i=0;i<10;i++){
			if(a[i]!=0){
				if(c!=0) cout << " ";
				cout << pow(2,i);
				c++;
			}
		}
		cout << endl;
	}
}

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

static const int MAX_N = 100010;
int N, sum=0;
int A[MAX_N], cost[MAX_N];

int main(int argc, char* argv[]){
  cin >> N;
  for(int i = 1; i <= N; i++) cin >> A[i];
  A[0] = A[N+1] = 0;
  for(int i = 1; i <= N+1; i++){
	cost[i] = abs(A[i]-A[i-1]);
	sum+=cost[i];
  }
  for(int i = 1; i <= N; i++)
	cout << sum-cost[i]-cost[i+1]+abs(A[i+1]-A[i-1]) << endl;
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n == 0)
    {
        cout << 0;
        return 0;
    }
    string res = "";
    while(n != 0)
    {
        int r = n % -2;
        n /= -2;
        if(r < 0)
        {
            r += 2;
            n++;
        }
        res = to_string(r) + res;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


int main() {
    ll N, M;
    cin >> N >> M;

    priority_queue<ll> q;

    for(ll i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        q.push(tmp);
    }

    for(ll i = 0 ; i < M; i++) {
        ll l = q.top();q.pop();
        q.push(l/2);
    }

    ll ret = 0;
    while(q.size() > 0) {
        ll l = q.top(); q.pop();
        ret += l;
    }

    cout << ret << endl;


    return 0;    
}



Measured memory_bytes: 1400
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def count_check(n):
    result = 0
    while n % 2 == 0:
        n /= 2
        result += 1
    return result

def main():
    n = i_input()
    num_list = i_list()

    count = 0 

    for num in num_list:
        if num % 2 != 0:
            continue
        count += count_check(num)

    print(count)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 78528
<?php

// ファイルパス指定し、任意のファイルを読み取り専用でファイルオープン
$line = fgets(STDIN); 
$arr = [];
for ($i = 1; $i <= $line; $i++) {
    if ($i % 2 === 1) {
        array_push($arr , $i);
    }
}

$answer = count($arr) / $line;
echo $answer;

?>

Measured memory_bytes: 16144
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n;
int a[100005];
int b[100005];
int c[100005];
long long ans;
long long ansb[100005];
int main()
{
	read(n);
	for(int i=0;i<n;i++)
		read(a[i]);
	for(int i=0;i<n;i++)
		read(b[i]);
	for(int i=0;i<n;i++)
		read(c[i]);
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	int it=n;
	for(int i=n-1;i>=0;i--)
	{
		while(it && c[it-1]>b[i])	it--;
		ansb[i]=n-it;
	}
	it=n;
	long long tmp=0;
	for(int i=n-1;i>=0;i--)
	{
		while(it && b[it-1]>a[i])
		{
			it--;
			tmp+=ansb[it];
		}
		ans+=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

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


int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0)
    cout<<1<<endl;
    if(x2==0)
    cout<<2<<endl;
    if(x3==0)
    cout<<3<<endl;
    if(x4==0)
    cout<<4<<endl;
    if(x5==0)
    cout<<5<<endl;
    
    
	
	
	return 0;
}

Measured memory_bytes: 3616
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


int main(void)
{
	//変数の宣言
	int n,m;

	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%d",&n);
//	scanf_s("%d",&n);

/*	fri(m){
		scanf("%d",x[i]);
		scanf_s("%d",&x[i]);
	}
*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	if(n==1){
		printf("1\n");
		return 0;
	}

	for(i=1;i<=n;i++){
		count=count+i;
		if(count>n) break;
	}

	temp=i;
	for(i=1;i<=temp;i++){
		if(i!=count-n){
			printf("%d\n",i);
		}
	}


	//	printf("計算部分終了\n");

	//出力

//	printf("%d",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define reff(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long int
#define pll pair<ll,ll>
#define fill(a,x) memset(a,x,sizeof(a))
#define mb make_pair
#define pb push_back
#define F first
#define S second
#define M 1000000007
#define sc(x) scanf("%d",&x)
#define scc(x1,x2) scanf("%d%d",&x1,&x2)
#define sccc(x1,x2,x3) scanf("%d%d%d",&x1,&x2,&x3)
#define pr(x) printf("%lld ",x)
#define dbg(a)          std::cerr<<#a<<"="<<(a)<<"\n"
#define dbg1(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define dbg2(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define dbg3(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define all(v) v.begin(),v.end()
#define PI 3.14159265
#define co cout<<"fuck"<<endl
const int INF = 2034567891;
const ll INF64 = 4234567890123456789ll;
long long nc3(long long v){return (v * (v - 1ll) * (v - 2ll)) / 6ll;}
long long nc2(long long v){return (v * (v - 1ll)) / 2ll;}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
const int N = 10+2e5;
bool isprime(ll n) {
    if (n < 2) return 0;
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;
    return 1;
}
double dist(pll p1, pll p2)
 {
    return (p1. F - p2.F)*(p1.F - p2.F) +
          (p1.S - p2.S)*(p1.S - p2.S);
 }
ll power(ll x,ll y)
{
    ll ans=1;
    while(y>0){
        if(y&1)
            ans=(ans*x)%M;
        x=(x*x)%M;
        y/=2;
    } 
    return ans;
}
int main()
{
     fast;
     ll n;
     cin>>n;
     ll A[n+1];
     repp(i,1,n)
     cin>>A[i];
     map<ll,ll>m;
     m[A[1]+1]++;
     ll ans=0;
     repp(i,2,n)
     {
        ans+=m[i - A[i]];
        m[A[i]+i]++;
	 }
	 cout<<ans;
}   

Measured memory_bytes: 27964
import math

h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = h * w

if h == 1:
    print(math.ceil("1".count(s[0])/k))
    exit()

for i in range(2 ** (h-1)):
    ss = str(format(i,"b").zfill(h-1))
    cnt = 0
    zero = 0
    key = 1
    for j in range(len(ss)):
        if ss[j] == "0":
            zero += 1
    now = [0 for i in range(zero+1)]

    for j in range(w):
        next = []
        num = 0
        for n in range(h):
            if s[n][j] == "1":
                num += 1
            if num > k:
                key = 0
            if n < h-1 and ss[n] == "0":
                next.append(num)
                num = 0
        next.append(num)
        
        keykey = 1
        for n in range(zero+1):
            if keykey:
                if now[n] + next[n] > k:
                    now = next
                    cnt += 1
                    keykey = 0
                else:
                    now[n] += next[n]
                    
    if key:ans = min(ans,cnt+zero)
print(ans)


Measured memory_bytes: 50268
import sys
input = sys.stdin.readline

n = int(input())
# s = [list(input().split()) for _ in range(n)]

s = []
m = 0
a = 0
r = 0
c = 0
h = 0

for i in range(n):
    temp = list(input())
    if temp[0] == 'M': m+=1
    if temp[0] == 'A': a+=1
    if temp[0] == 'R': r+=1
    if temp[0] == 'C': c+=1
    if temp[0] == 'H': h+=1

ans = 0

ans += m*a*r
ans += m*a*c
ans += m*a*h
ans += m*r*c
ans += m*c*h
ans += m*r*h
ans += a*r*c
ans += a*r*h
ans += a*c*h
ans += r*c*h

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL p[610],f[610][610],g[610],n,K,cnt[610][610];
int main()
{
	scanf("%lld %lld",&n,&K);
	n<<=1;
	for(LL i=1;i<=K;i++)
	{
		LL x,y;scanf("%lld %lld",&x,&y);
		p[x]=y;p[y]=x;
	}
	g[0]=1;
	for(LL i=2;i<=n;i+=2) g[i]=(g[i-2]*(i-1))%mod;
	for(LL i=1;i<=n;i++)
		for(LL j=i;j<=n;j++) cnt[i][j]=cnt[i][j-1]+(!p[j]);
	for(LL i=1;i<=n;i++)
		for(LL j=i;j<=n;j++)
		{
			//printf("%lld %lld\n",i,j);
			bool flag=false;
			for(LL k=i;k<=j;k++)
				if(p[k]&&(p[k]<i||p[k]>j))
				{
					flag=true;
					break;
				}
			if(flag) continue;
			f[i][j]=g[cnt[i][j]];
			for(LL k=i+1;k<j;k++) (f[i][j]-=f[i][k]*g[cnt[k+1][j]])%=mod;
			//printf("%lld\n",f[i][j]);
		}
	LL ans=0;
	for(LL i=1;i<=n;i++)
		for(LL j=i;j<=n;j++)
			(ans+=f[i][j]*g[(n/2-K)*2-cnt[i][j]]%mod)%=mod;
	printf("%lld",(ans+mod)%mod);
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    string s;
    cin>>s;
    if(n%2)
    {
        cout<<"No\n";
    }
    else
    {bool flag=1;
        for(int i=0;i<n/2;i++)
            if(s[i]!=s[i+n/2])
            {
                flag=0;
                break;
            }
        if(flag)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    

    return 0;   
}


 
 


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

#define int long long

int N;
int a[100010];
int ans;

main()
{
	ios::sync_with_stdio(false);
	
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>a[i];
	}
	
	for(int i=1;i<=N;i++)
	{
		if(a[i]>=3)
		{
			if(a[i]%2==1)
			{
				ans+=(a[i]-1)/2;
				a[i]=1;
			}
			else
			{
				ans+=(a[i]-2)/2;
				a[i]=2;
			}
		}
	}
	for(int i=1;i<=N;i++)
	{
		if(a[i]==0) continue;
		else if(a[i]==1)
		{
			if(a[i+1]>0)
			{
				ans++;
				a[i]=0;
				a[i+1]--;
			}
		}
		else
		{
			ans++;
			a[i]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct N {
  int p, l ,r;
} Node;

Node T[MAX];
int n;

void preParse(int u){
  if( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if( u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    T[i].p = NIL;
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if( l != NIL ) T[l].p = v;
    if( r != NIL ) T[r].p = v;
  }

  for( i = 0 ; i < n ; i++ ) if( T[i].p == NIL ) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
#define BRANCH 4
#define FLOOR 3
#define ROOM 10

int main(void)
{
  int b; /*branch*/
  int f; /*floor*/
  int r; /*room*/
  int v; /*resident*/
  int ninzuu[BRANCH][FLOOR][ROOM] = {0};
  int n;
  int i, j, k;

/******************input*****************/

  scanf("\n%d",&n);
  for(i=0; i<n; i++) {

 scanf("\n%d %d %d %d",&b, &f, &r, &v);
 ninzuu[b-1][f-1][r-1]=ninzuu[b-1][f-1][r-1] + v;

  }

/*****************output*****************/
  for(i=0; i<BRANCH; i++){
    for(j=0; j<FLOOR; j++){
      for(k=0; k<ROOM; k++){
	printf(" %d",ninzuu[i][j][k]);
      }
          printf("\n");
    }
    if(i==BRANCH-1){break;}
    else {printf("####################\n");}
  }

  return 0;
}

Measured memory_bytes: 612
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String answer = "";
        int length = line.length();
        int i;
        char c;
        
        for(i=0;i<line.length();i++){
            if(Character.isLowerCase(line.charAt(i))){
                c = Character.toUpperCase(line.charAt(i));
                answer = answer + c;
            }else{
                c = Character.toLowerCase(line.charAt(i));
                answer = answer + c;
            }

        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 31256
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i, n) for (int i = 0; i < n; i++)
#define R(i, c, n) for (int i = c; i < n; i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a)            \
  REP(d, a.size())         \
  {                        \
    cout << a[d];          \
    if (d != a.size() - 1) \
      cout << " ";         \
    else                   \
      cout << endl;        \
  }
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) \
  sort(ALL(v));   \
  v.erase(unique(ALL(v)), v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

  int n,m;
  cin >> n >> m;
  vector<pair<long long ,long long>> p(n);
  r(i,n) {
    int a,b;
    cin >> a >> b;
    p[i] = make_pair(a,b);
  }
  sort(ALL(p));
  long long sum = 0;
  long long counti = 0;
  r(i,n) {
    if (p[i].second <= m-counti) {
      sum += p[i].first * p[i].second;
      counti += p[i].second;
      continue;
    }else{
      sum += p[i].first * (m-counti);
      break;
    }
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1792
import bisect
def MLI():
    return map(int, open(0).read().split())

def main():
    N, A, B, *X = MLI()
    
    ret = 0
    for s, e in zip(X[:-1], X[1:]):
        diff = e - s
        if diff * A < B:
            ret += diff * A
        else:
            ret += B
            
    print(ret)
            

if __name__ == "__main__":
    main()

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream& os,const Tuple& t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream& os,const Tuple& t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
   os << "(" << e.to << ", " << e.cost << ")";
   return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

   int sum = accumulate(w.begin(), w.end(), 0);

   int s = 0;
   int ans = sum;
   for (int i = 0; i < n; ++i) {
      s += w[i];
      chmin(ans, abs(sum - 2*s));
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int loc[200005];
set<int> seen;

ll numIntervals(int n) {
    return n*(n+1LL)/2;
}

int main() {
    int n;
    scanf("%d", &n);
    seen.insert(-1);
    seen.insert(n);
    for(int i = 0; i < n; i++) {
        int t;
        scanf("%d", &t);
        loc[t] = i;
    }
    ll ret = 0;
    for(int i = 1; i <= n; i++) {
        int rhs = *seen.upper_bound(loc[i]);
        int lhs = -1;
        {
            set<int>::iterator it = seen.lower_bound(loc[i]);
            it--;
            lhs = *it;
        }
        ll amt = rhs - lhs - 1;
        ll ints = numIntervals(amt);
        ints -= numIntervals(loc[i] - lhs - 1);
        ints -= numIntervals(rhs - loc[i] - 1);
        ret += i * ints;
        seen.insert(loc[i]);
    }
    printf("%lld\n", ret);
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> v(N+1, vector<int>(N+1, -1));
	for(int i=0; i<M; ++i){
	    int a, b, c;
	    cin >> a >> b >> c;
	    v[a][b]=c;
	    v[b][a]=c;
	}
	int cnt=0;
	for(int i=1; i<=N; ++i){
	    vector<int> dijk(N+1, -1), det(N+1, 0);
	    dijk[i]=0;
	    int now=i, nx;
	    while(now>0){
	        det[now]=1;
	        nx=-1;
	        for(int p=1; p<=N; ++p){
	            if(v[now][p]>0 && det[p]==0){
	                if(dijk[p]<0) dijk[p]=dijk[now]+v[now][p];
	                else dijk[p]=min(dijk[p], dijk[now]+v[now][p]);
	            }
	            if(dijk[p]>0 && det[p]==0){
	                if(nx<0) nx=p;
	                else if(dijk[nx]>dijk[p]) nx=p;
	            }
	        }
	        now=nx;
	    }
	    for(int p=1; p<=N; ++p){
	        if(dijk[p]<v[i][p]) ++cnt;
	    }
	}
	cnt /= 2;
	cout << cnt << endl;
	return 0;
}


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


long long inv(long long i, long long p){
	long long retval = 1;
	long long multiple_num = i;
	long long power = p-2;
	while (power) {
		//printf("power=%lld\n",power);
		if ((power&1)!=0){
			//printf("multple_num=%lld\n",multiple_num);
			retval *= multiple_num%p;
			retval %= p;
			//printf("retval=%lld\n",retval);
		}
		multiple_num *= multiple_num;
		multiple_num %=p;
		power = (power>> 1);
	}
	return retval;
}

/*int main (){
	printf("%lld\n", inv(2,1000000007));
	return 0;
}*/
int main (){
	long long p = 1000000007;
	long long X;
	long long Y;
	scanf("%lld",&X);
	scanf("%lld",&Y);
	if ((2*Y-X)%3!=0 || (2*X-Y)%3!=0 || (2*Y-X)<0 || (2*X-Y)<0){
		printf("0\n");
		return 0;
	}
	long long a = (2*X-Y)/3;
	long long b = (2*Y-X)/3;
	//printf("a=%lld\n",a);
	//printf("b=%lld\n",b);
	// a+bCaを求める
	long long ans =1;
	for (long long i=b+1; i<=b+a; i++){
		ans *= i;
		ans %= p;
	}
	//printf("ans_temp=%lld\n",ans);
	for (long long i=1; i<=a; i++){
		//printf("inv(%lld, %lld)=%lld\n",i,p,inv(i, p));
		ans *= inv(i, p);
		ans %= p;
	}
	printf("%lld\n",ans);
	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 T = sc.nextInt();
		int t[] = new int[N + 1];
		long ans = 0;
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
			if(i == 0) {
				ans = T;
			} else {
				if(t[i] - t[i - 1] > T) {
					ans = ans + T;
				} else {
					ans = ans + T - (T - (t[i] - t[i - 1]));
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 64716
#https://qiita.com/masashi127/items/88436e16e3672b387a58
#--------------------------------------------
import math

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0  else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

n=100000
input_list = sieve_of_erastosthenes(n)
prime_list = [i for i, b in enumerate(input_list) if b == True]
#print(prime_list)
#print(sum(prime_list))

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

count=[0 for i in range(100002)]
for i in prime_list:
  count[i]=1
#print(count)

nitakazu_count=[0 for i in range(100002)]
for i in range(50001):
  if count[2*i+1]==1 and count[i+1]==1:
    nitakazu_count[2*i+1]=1
  
  
ruiseki_count=[0 for i in range(100002)]
for i in range(100000):
  ruiseki_count[i+1]=ruiseki_count[i]+nitakazu_count[i+1]
#print(ruiseki_count)

nn=int(input())

for i in range(nn):
  aa,bb=[int(i) for i in input().split()]
  print(ruiseki_count[bb]-ruiseki_count[aa-1])




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

int countDivisors(long long int n) 
{ 
    int cnt = 0; 
    for (long long int i = 1; i *i <= n; i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    cnt--;
    return cnt; 
} 
int main() {
  long long int n;
  cin>>n;
  int ans=countDivisors(n-1);
 // cout<<ans<<endl;
  for(long long int i=1;i*i<=n;i++)
   {
   	if(n%i==0){
   	if(i!=1 && n%i==0)
   	 {
   	 	long long int f=n;
   	 	while(f%i==0)
   	 	 f=f/i;
   	 	if((f-1)%i==0)
   	 	  ans++;
   	 }
   	if(i*i != n )
   	{
   		long long int s=n/i;
   	long long int f=n;
   	 	while(f%s==0)
   	 	 f=f/s;
   	 	if((f-1)%s==0)
   	 	  ans++;	
   	}
   	}
   }
	cout<<ans<<endl;
	 return 0;
}

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

int n;

#define MAX 100002

map<int, vector<int> > x;
map<int, vector<int> > y;
vector < pair<int, int> > v;

struct st{
	int dif;
	bool flag;
	int val1;
	int val2;
};
bool cmp(st a, st b){
	return a.dif < b.dif;
}
vector<st> vv;

struct UF{
	vector<int> belong;
	vector<int> size;
	void resize(int n){
		belong.assign(n + 1, -1);
		size.assign(n + 1, 1);
	}
	inline int root(int b){
		if (belong[b] == -1){
			return b;
		}
		belong[b] = root(belong[b]);
		return belong[b];
	}
	void merge(int a, int b){
		a = root(a);
		b = root(b);
		if (a == b)return;
		belong[a] = b;
		size[b] += size[a];
	}
};

UF uf;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		v.push_back(make_pair(a, b));
		x[a].push_back(i);
		y[b].push_back(i);
	}
	uf.resize(100002);
	for (auto it = x.begin(); it != x.end(); it++){
		for (int j = 1; j < (*it).second.size(); j++){
			uf.merge((*it).second[0], (*it).second[j]);
		}
	}
	for (auto it = y.begin(); it != y.end(); it++){
		for (int j = 1; j < (*it).second.size(); j++){
			uf.merge((*it).second[0], (*it).second[j]);
		}
	}
	for (auto it = x.begin(); it != x.end(); it++){
		auto nex = it;
		nex++;
		if (nex != x.end()){
			vv.push_back({ (*nex).first - (*it).first, false, (*it).first, (*nex).first });
		}
	}
	for (auto it = y.begin(); it != y.end(); it++){
		auto nex = it;
		nex++;
		if (nex != y.end()){
			vv.push_back({ (*nex).first - (*it).first, true, (*it).first, (*nex).first });
		}
	}
	sort(vv.begin(), vv.end(), cmp);
	long long int ans = 0;
	for (int i = 0; i < vv.size(); i++){
		if (vv[i].flag == false){
			vector<int> &A = x[vv[i].val1];
			vector<int> &B = x[vv[i].val2];
			A.resize(1);
			for (int j = 0; j < B.size(); j++){
				if (uf.root(A[0]) != uf.root(B[j])){
					ans += vv[i].dif;
					uf.merge(A[0], B[j]);
				}
			}
		}
		else{
			vector<int> &A = y[vv[i].val1];
			vector<int> &B = y[vv[i].val2];
			A.resize(1);
			for (int j = 0; j < B.size(); j++){
				if (uf.root(A[0]) != uf.root(B[j])){
					ans += vv[i].dif;
					uf.merge(A[0], B[j]);
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 29808
N = int(input())
H = list(map(int,input().split()))
output = "Yes"
if len(H) == 1:
    output = "Yes"
else:
    if H[1] - H[0] <= 0:
        H[0] += -1

    if len(H)==2:
        sa1 = H[1] - H[0]
        if sa1 < 0:
            output = "No"
    else:
        for i in range(2,N):
            sa1 = H[i-1] - H[i-2]
            sa2 = H[i]-H[i-1]
            if sa1 < 0:
                output = "No"
            elif sa1 == 0:
                    continue
            elif sa1 > 0:
                if sa2 <= 0:
                    H[i-1] += -1

        if H[N-1]-H[N-2] <0:
            output = "No"

print(output)

Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using III = tuple<int,int,int>;
using VIII = vector<III>;
void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }

// bool solve(int N, vi &T, vi &X, vi &Y){
// 	bool ans = true;
// 	// vprn(T);vprn(X);vprn(Y);//


// 	return ans;
// }

int main(){
	int N; cin>>N;
	// vi T(N),X(N),Y(N);
	// rp(i, 0, N) cin>>T[i]>>X[i]>>Y[i];

	bool ans=true;
	rp(i,0,N){
		int t,x,y; cin>>t>>x>>y;
		if(t%2 != (x+y)%2){
			ans = false;
			break;
		}
		else{
			if(t < x+y){
				ans = false;
				break;
			}
		}
	}
	ote(ans?"Yes":"No");
	// ote(solve(N,T,X,Y)?"Yes":"No");
}


Measured memory_bytes: 256
mod=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,mod)[0]%mod
N,A,B,C=map(int,input().split())
ONE=(100*inv(100-C))%mod
P=(A*inv(A+B))%mod
Q=(B*inv(A+B))%mod
MAX_N=200000
Fact=[0 for i in range(MAX_N+1)]
Finv=[0 for i in range(MAX_N+1)]
Fact[0]=1;Finv[0]=1
for i in range(MAX_N):
    Fact[i+1]=((i+1)*Fact[i])%mod
    Finv[i+1]=inv(Fact[i+1])
def Comb(n,k):
    return (Fact[n]*(Finv[k]*Finv[n-k])%mod)%mod
PN=[0 for i in range(N+1)]
QN=[0 for i in range(N+1)]
PN[0]=1
QN[0]=1
for i in range(N):
    PN[i+1]=(P*PN[i])%mod
    QN[i+1]=(Q*QN[i])%mod
ans=0
for M in range(N):
    ans+=((M+N)*(PN[N]*(QN[M]*Comb(M+N-1,M))%mod)%mod)%mod
    ans%=mod
    ans+=((M+N)*(QN[N]*(PN[M]*Comb(M+N-1,M))%mod)%mod)%mod
    ans%=mod
print((ans*ONE)%mod)

Measured memory_bytes: 58572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A>>B>>C;
  D = A;
  if(A>B){
    A = B;
    B = D;
  }
  int a[2000];
  a[0] = 1;
  int k = 1;
  for(int i = 2;i<= A;i++){
    if(A%i==0&&B%i==0){
      a[k] = i;
      k++;
    }
  }
  cout << a[k-C] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

ll F(ll x){
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x+1;
    else return 0;
}

int main(){
    ll A, B;
    cin >> A >> B;
    cout << (F(B)^F(A-1)) << endl;
    return 0;
}


Measured memory_bytes: 256