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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {
	int n;
	cin >> n;
	vector<pair<int, int >> v;
	REP(i, n) {
		int a;
		cin >> a;
		v.push_back({ a,i });
	}

	sort(ALL(v));
	int ans = 0;
	REP(i, n) {
		if (i % 2 == 1 && v[i].second % 2 == 0)ans++;
	}

	cout << ans << endl;
}

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

int main() {
  int i, a, b;
  vector<int> x(b), y(b), z(b);
  cin >> a >> b;
  
  for(i=0;i<b;i++){
    cin >> x.at(i) >> y.at(i);
    z.at(x.at(i)-1)++;
    z.at(y.at(i)-1)++;
  }
  for(i=0;i<a;i++){
    cout << z.at(i) << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int N = 2e5+7;
const int MOD = 1e9+7;

int a[N];

int main(){

  int n; cin >> n;
  ll sum = 0;
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  ll cnt = 0,res = 1e18;
  REP(i,n-1){
    cnt += a[i];
    ll k = abs(2*cnt - sum);
    res = min(res,k);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> V; typedef vector<P> Vp; typedef map<int,int> MP;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while(b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if(u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}

	bool operator==(ModInt that) const { return x == that.x; }
	bool operator!=(ModInt that) const { return x != that.x; }
	ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while(k) {
		if(k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}
typedef ModInt<mod> mint;

vector<mint> fact, factinv;

void COMinit(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	rer(i, 1, N) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for(int i = N; i >= 1; i --) factinv[i - 1] = factinv[i] * i;
}

mint C(int n, int r) {
	if(n >= mint::Mod)
		return C(n % mint::Mod, r % mint::Mod) * C(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}

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

    Int n,m; cin>>n>>m; mint xs=0,ys=0;
    COMinit(100000);
    for (Int i = 1; i <= n; i++){
      Int x; cin>>x;
      xs+=x*(2*i-1-n);
    }
    for (Int i = 1; i <= m; i++){
      Int y; cin>>y;
      ys+=y*(2*i-1-m);
    }
    mint ans=xs*ys;
    cout<<ans.get()<<'\n';
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
using namespace std;
int a[3], cnt, rt, at, ot, tmp;
int main() {
    while (cin >> a[0] >> a[1] >> a[2]) {
        sort(a, a + 3);
        if (a[0] + a[1] <= a[2]) {
            cout << cnt << " " << rt << " " << at << " " << ot << endl;
            return 0;
        }
        cnt++;
        tmp = a[0] * a[0] + a[1] * a[1] - a[2] * a[2];
        if (tmp == 0) rt++;
        if (tmp > 0) at++;
        if (tmp < 0) ot++;
    }
}


Measured memory_bytes: 3160
while true
    n = gets.to_i
    break if n == 0
    arr = []
    n.times{arr << gets.to_i}
    k = gets.to_i
    count = 0
    left, right = 0, n - 1
    while left <= right
        count += 1
        center = (left + right) / 2
        if arr[center] == k
            break
        elsif arr[center] < k
            left = center + 1
        else
            right = center - 1
        end
    end
    puts count
end


Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	map<char,char> mp;
	for (int i=0;i<s.size();i++) mp[s[i]]=t[i];
	for (char c='a';c<='z';c++){
		for (char d='a';d<='z';d++){
			if (mp.count(c)==0 || mp.count(d)==0 || c==d) continue;
			if (mp[c]==mp[d]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	for (int i=0;i<s.size();i++) s[i]=mp[s[i]];
	cout<<(s==t ? "Yes" : "No")<<endl;
	return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int c = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (0 <= s - i - j && s - i - j <= k) {
        c++;
      }
    }
  }
  p(c);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll fact[10005];
int main(){
    ll n,i,j,k;
    cin>>n;
    for(i=1;i<=100;i++){
        for(j=1;j<=100;++j){
            for(k=1;k<=100;++k){
                ll temp = i*i+j*j+k*k+i*j+j*k+i*k;
                if(temp <= 10000)
                    fact[temp]++;
            }
        }
    }
    for(i=1;i<=n;++i)
        cout<<fact[i]<<endl;
}

Measured memory_bytes: 3696
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int a,b,c,n,i,j,k,sum=0;
    scanf("%d%d%d%d",&a,&b,&c,&n);
    for(i=0;i<=a&&i*500<=n;i++)
    {
        for(j=0;j<=b&&j*100<=n;j++)
        {
            for(k=0;k<=c&&k*50<=n;k++)
            {
                if((i*500+j*100+k*50)==n)
                    sum++;
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;





int main() {

	ll n;
	cin >> n;
	ll ans = 0;

	VS v;


	REP(i, n) {
		string s;
		cin >> s;
		sort(ALL(s));
		v.push_back(s);
	}

	sort(ALL(v));

	ll cnt = 1;
	string t = v[0];

	FOR(i, 1, n) {
		if (t == v[i])cnt++;
		else {
			t = v[i];
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;

	cout << ans << endl;



}

Measured memory_bytes: 5748
from sys import stdin
input = stdin.readline

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

cum = 1
over = False
for x in a:
    if x == 0:
        cum = 0
        break

if cum == 0:
    print(0)
else:
    for x in a:
        cum *= x
        if (cum > 1e18):
            over = True
            break
    print(-1) if over else print(cum)


Measured memory_bytes: 21720
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double			de_PI	= 3.14159265358979323846;
const static unsigned int	de_MOD	= 1000000007;
const static int			de_MAX	= 999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	int N = 0;
	std::cin >> N;
	std::vector<int> A(N);
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
	}

	std::cout << A[0];
	for (int i = 1; i < N; i++) {
		std::cout << " " << A[i];
	}
	std::cout << std::endl;

	for (int i = 1; i < N; i++) {
		int key = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > key) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = key;

		std::cout << A[0];
		for (j = 1; j < N; j++) {
			std::cout << " " << A[j];
		}
		std::cout << std::endl;
	}

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int ans = 0;
		int min = n + 1;
		for (int i = 0; i < n; i++) {
			if (p[i] < min) {
				ans++;
				min = p[i];
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int INF = 1e9 + 5;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int> (3));
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            int add = -1;
            for (int k = 0; k < 3; k++) {
                if (k != j)
                    add = max(add, a[i-1][k]);
            }
            a[i][j] += add;
        }
    }
    
    cout << max(a[n-1][0], max(a[n-1][1], a[n-1][2]));
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
int main(){
  ll a, b, c, ans = 0;
  cin >> a >> b >> c;
  if ((a%2)*(b%2)*(c%2) != 0) ans = min({a*b, b*c, c*a});
  cout << ans << endl;
}

Measured memory_bytes: 256
def dist(a, b)
  (a - b).abs
end

dists = []

dists << STDIN.gets.to_i
dists << STDIN.gets.to_i
dists << STDIN.gets.to_i
dists << STDIN.gets.to_i
dists << STDIN.gets.to_i

threshold = STDIN.gets.to_i

if dists.combination(2).any? {|a, b| dist(a, b) > threshold}
  STDOUT.puts ':('
else
  STDOUT.puts 'Yay!'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define debug(x) cout<<#x<<"="<<x<<endl;
using namespace std;
const int N=1e5+10;
multiset<int> cnt[2]; 
int main()
{
	string a,b;
	cin>>a>>b;
	cnt[0].clear();
	cnt[1].clear();
	//cout<<a.size();
	rep(i,0,a.size())
	{
		cnt[0].insert(a[i]-'a');
	} 
	rep(i,0,b.size())
	{
		cnt[1].insert(-b[i]+'a');
	} 
	int cnta=a.size();
	int cntb=b.size();
	bool flag=true;
	int mx=max(cnta,cntb);
	rep(i,0,max(a.size(),b.size()))
	{
		if(*cnt[0].begin()<(-*cnt[1].begin()))
		{
			flag=true;
			break;
		}
		else if(*cnt[0].begin()>(-*cnt[1].begin()))
		{
			flag=false;
			break;
		}
		else
		{
			cnt[1].erase(cnt[1].begin());
			if(cnt[1].size()==0)
			{
				flag=false;
				break;
			}
			cnt[0].erase(cnt[0].begin());
			if(cnt[0].size()==0)
			{
				flag=true;
				break;
			}
		}
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#define endl '\n'
#define ll long long

using namespace std;

int *arr;
int N;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N;
    vector<int> A(N), B(N), C(N);

    arr = new int[N]();
    for(int i = 0; i < N; i++)
        cin >> A[i];
    for(int i = 0; i < N; i++)
        cin >> B[i];
    for(int i = 0; i < N; i++)
        cin >> C[i];
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    ll ret = 0;
    
    for(int i = 0; i < N; i++)
    {
        ll pos1 = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll pos2 = N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
        
        ret += pos1 * pos2;
    }
    
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 2048
n,k = gets.split.map &:to_i
ps = gets.split.map &:to_i

point = ps[0...k].inject(:+)
max = point

(k ... n).each{ |i|
	point = point - ps[i - k] + ps[i]
	if point > max then
		max = point
	end
}

puts (max + k) / 2.0

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[100010];

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }

  Fill(dp, INF);
  dp[0] = 0;

  REP(i, 1, N) {
    REP(j, 1, K + 1) {
      if (i - j < 0) continue;
      chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }

  cout << dp[N - 1] << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1792
mountain_heights = []
for i in range(10):
    mountain_heights.append(int(input()))

for i in range(3):
    maximum = 0
    index = i
    for j in range(i, 10):
        if mountain_heights[j] > maximum:
            maximum = mountain_heights[j]
            index = j
    temp = mountain_heights[i]
    mountain_heights[i] = mountain_heights[index]
    mountain_heights[index] = temp
    print(maximum)


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

template<unsigned mod=1000000007>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
template<unsigned mod=1000000007>struct factorial {
   using Mint=mint<mod>;
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};
using Mint=mint<>;
factorial<> fact(2010000);

int main(){
   int r1,c1,r2,c2; scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
   r1--; c1--;
   Mint res=fact.nCr(r2+c2+2,r2+1);
   res-=fact.nCr(r1+c2+2,c2+1);
   res-=fact.nCr(r2+c1+2,c1+1);
   res+=fact.nCr(r1+c1+2,r1+1);
   printf("%d\n",res.val);
   return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>

int main(){

	int n, i;
	int num;
	char mar, sim[]={'S','H','C','D'};
	int card[52];

	for(i=0; i<52; i++) card[i]=0;

	scanf( "%d", &n);


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

		switch(mar){
		case 'S': card[ 0+num-1] = 1; break;
		case 'H': card[13+num-1] = 1; break;
		case 'C': card[26+num-1] = 1; break;
		case 'D': card[39+num-1] = 1; break;
		} 
	}

	for( i=0; i<52; i++ ){
		if( card[i] == 0 ){
			printf( "%c %d\n", sim[i/13], (i%13)+1  );
		}
	}
		



	return 0;

}

Measured memory_bytes: 600
#include <stdio.h>
int main(){
	int h,w;
	scanf("%d %d",&h,&w);
	char s[51][51];
	int i,j;
	for(i=0;i<h;i++){
			scanf("%s",&s[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){	
			if(s[i][j]=='#'){
				if(s[i-1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'&&s[i+1][j]=='.'){
					printf("No");
					return 0;
				}
			}
		}
	}
	printf("Yes");
	return 0;
	}

Measured memory_bytes: 128
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU

// Author : Ritik Patel
// Institution: Pandit Deendayal Petroleum University
 
#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;

template<typename T> T fast_power(T x,T y,T m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
template<typename T>
T extgcd(T a, T b, T &x, T &y) {  //when a and b are coprimes(or gcd(a,b)==1) in ax+by = t*gcd(a,b);
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}

typedef long long ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

/******************* MAIN PROGRAM ***************/

int main(){
	FAST
	const int N = 2 * 1e5 + 5;
	vector<bool> prime(N , true);
	prime[0] = false;
	prime[1] = false;
	for ( int i = 2; i*i <= N; ++i){
		if( prime[i]){
			for (int j = i*i; j < N; j += i){
				prime[j] = false;
			}
		}
	}
	vi primes;
	for ( int i = 2; i < N; ++i){
		if( prime[i]) primes.push_back(i);
	}
	int  x;
	cin >> x;
	cout << *lower_bound(all(primes), x) << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, D;

  std::cin >> N >> D;

  int x = D + D + 1;

  std::cout << (N + x - 1) / x << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
# counts of i yen will be given as cnt[i]
cnt = list(range(n+1))
options = [1]


p = 1
while 9**p <= n:
    options.append(9**p)
    p += 1
p = 1
while 6**p <= n:
    options.append(6**p)
    p += 1

options = sorted(options)
for i in range(n+1):
    for j in options:
        if i>=j:
            """If (i-j) yen could be withdrawn at less than (i-j) times,
            i yen will be done by additional j yen-withdrawal.
            """
            cnt[i] = min(cnt[i], cnt[i-j]+1)

print(cnt[n])

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  S='.'+S+'.';
  N+=2;
  vector<char> t(Q);
  vector<char> d(Q);
  rep(i,Q)  cin >> t.at(i) >> d.at(i);
  reverse(all(t));
  reverse(all(d));

  int l=0;
  int r=N-1;
  rep(i,Q){
    if(d.at(i)=='L'){
      if(S.at(l+1)==t.at(i))  l++;
      if(S.at(r)==t.at(i))  r++;
    }
    else if(d.at(i)=='R'){
      if(S.at(l)==t.at(i))  l--;
      if(S.at(r-1)==t.at(i))  r--;
    }
    if(l+1>=r){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << r-1-l << endl;

  return 0;
}

Measured memory_bytes: 3940
N,A,B=map(int,input().split())
S=list(input())
cnt=0
cnt_b=0
for s in S:
  if cnt<A+B:
    if s=="a":
      cnt+=1
      print("Yes")
    elif s=="b":
      cnt_b+=1
      if cnt_b<=B:
        cnt+=1
        print("Yes")
      else:
        print("No")
    else:
      print("No")        
  else:
    print("No")

Measured memory_bytes: 4712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    ll ans = 0;
    int ct = 0;
    rep(i,n) {
        if (s[i] == 'W') {
            ans += i - ct;
            ct++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

void solve(){
    ll a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    
   
   int d;
   cin>>d;
   
   if(d==22)
   cout<<"Christmas Eve Eve Eve";
   
   if(d==23)
   cout<<"Christmas Eve Eve";
   
   if(d==24)
   cout<<"Christmas Eve";
   
   if(d==25)
   cout<<"Christmas";
   
   
   
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long n;
  scanf("%lld",&n);

  long long temp = n;
 

  long long ans[100] = {0};
  int count = 0;
  while(temp  > 0){
    if(temp%26 != 0){
    //printf("%c",'a' + temp%26-1);
    ans[count] += temp%26 - 1;
    count ++;
    }
    else{
      //printf("z");
      ans[count] += 25;
      temp -= 1;
      count ++;
    }
    
    temp /= 26;
  }

  for(int i = count -1;i >= 0;i --){
    printf("%c",'a' + ans[i]);
  }

  return 0;
}

Measured memory_bytes: 1732
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
	if(S.size()%2){
		cout << NO << endl;
		return;
	}
	for(int i=0;i<S.size();i+=2){
		if(S[i]!='h'||S[i+1]!='i'){
			cout << NO << endl;
			return;
		}
	}
	cout << YES << endl;


}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<ll> calc(ll x, const vector<ll>& v){
  vector<ll> yama;
  yama.push_back(x);
  ll prev_yama = x;
  rep(i,v.size()){
    ll rhs = v[i] - prev_yama/2;
    yama.push_back(rhs*2);
    prev_yama = rhs*2;
  }
  yama[yama.size()-1] -= x;
  return yama;
}

int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll lb = 0, ub = 1000000000000000LL;
  while(ub-lb>1){
    ll mid = (lb+ub)/2;
    vector<ll> res = calc(mid*2, v);
    if(res[res.size()-1]>=0) lb = mid;
    else ub = mid;
  }

  vector<ll> ret = calc(lb*2, v);
  rep(i,ret.size()-1){
    if(i>0) cout << " ";
    cout << ret[i];
  }
  cout << endl;
  
  return 0;
}



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

using namespace std;
int n,a[100100];

int main()
{
    int Ans = 0;
    cin >> n;
    for(int i=0;i<n;i++)  cin >> a[i];
    for(int i=0;i<n;i++){
        int cnt = 0;
        while(i + 1 < n && a[i] >= a[i + 1])  i++ , cnt++;
        Ans = max(Ans , cnt);
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 640
a = gets.chomp.to_i + 1
b = gets.chomp.to_i + 1
c = gets.chomp.to_i + 1
x = gets.chomp.to_i
ans = 0
a.times do |i|
    b.times do |j|
        c.times do |l|
            ans += 1 if i*500 + j*100 + l*50 == x
        end
    end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

ll get_diff(ll n, ll k) {
  ll temp = n;
  ll i = 0;
  while(temp <= k) {
    temp *= 2;
    i++;
  }

  return i;
}

int main() {
  // Happy hacking!
  ll n, k;
  double res = 0;

  cin >> n >> k;

  double klog = log2(k-1);
  ll u = 0; ll d = 0;
  ll d_idx = 0;
  for(ll i=1; i<=n; i++) {
    double ilog = log2(i);
    if(i == 1) {
      d_idx = get_diff(i, k-1);
      d = 1 << d_idx;
      u += 1;
    } else {
      if(i <= k-1) {
        u += 1 << (d_idx - get_diff(i, k-1));
      } else {
        u += d;
      }
    }
  }

  //cout << u << "/" << d << "/" << n << endl;

  cout << setprecision(12) << (double)u / (double)d / (double)n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define BIT(n, m) (((n) >> (m)) & 1)

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

const ll inf = 1e15;
const ll mod = 1000 * 1000 * 1000 + 7;
const double eps = 1e-9;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

pair<string, string> read(){
  string str;
  pair<string, string> res;
  cin >> str;
  replace(ALL(str), '-', ' ');
  istringstream iss(str);
  iss >> res.first >> res.second;
  return res;
}

int main(){
  int N, M;
  const int INF = 1e9;
  while (cin >> N && N){
    string A, B;
    map<string, int> I;
    map<int, string> S;
    map<int, vector<int> > E;
    
    REP(i, N){
      tie(A, B) = read();
      if (I.count(A) == 0) {
        int id = I.size();
        I[A] = id;
        S[I[A]] = A;
      }

      if (I.count(B) == 0) {
        int id = I.size();
        I[B] = id;
        S[I[B]] = B;
      }
      E[I[A]].push_back(I[B]);
    }

    int n = I.size();
    REP(i, n) sort(ALL(E[i]));
    
    vector<vector<int> > D_(n, vector<int>(n, 0));
    REP(u, n) for (int v : E[u]) D_[u][v] = true;

    
    vector<vector<int> > D(n, vector<int>(n, INF));
    REP(i, n) REP(j, i){
      bool ok = false;
      REP(k, n) if ((D_[i][k] || D_[k][i]) && (D_[j][k] || D_[k][j])) ok= true;
      REP(k, n) if (D_[i][k] && D_[k][j]) ok = false;
      REP(k, n) if (D_[k][i] && D_[j][k]) ok = false;
      if (ok) D[i][j] = D[j][i] = 0;
    }
    REP(i, n) REP(j, n) if (D_[i][j]) D[i][j] = 1;
    
    REP(k, n) REP(i, n) REP(j, n) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
    
    cout << n << endl;
    cin >> M;
    REP(i, M){
      tie(A, B) = read();
      if (I.count(A) && I.count(B) && D[I[A]][I[B]] % 2 == 1) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1608
#include <iostream>
int main() {
    int a,b; 
    auto c = [](int a,int b){
       if(a*b==15)return '*';
       if(a+b==15)return '+';
       return 'x';
    };
    std::cin >> a;
    std::cin >> b;
    std::cout << c(a,b) << std::endl;
}

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

int main(){
    string s;
    cin >> s;
    int l = s.length();
    bool can = true;
    for(int i = 1; i <= l; i++){
        if(i % 2 && !(s[i-1] == 'R' || s[i-1] == 'U' || s[i-1] == 'D')) can = false;
        if(i % 2 == 0 && !(s[i-1] == 'L' || s[i-1] == 'U' || s[i-1] == 'D')) can = false;
    }
    cout << (can? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ary = [list(map(int,input().split())) for _ in range(n)]
nv = [0,0]
count = 0
for i in range(n):
    a,b = abs(nv[0]-ary[i][1]),abs(nv[1]-ary[i][2])
    c = ary[i][0] - count
    if c < a+b:print("No");exit()
    elif (c - (a+b)) % 2 == 1:print("No");exit()
    nv = [ary[i][1],ary[i][2]]
    count += c
else:print("Yes")

Measured memory_bytes: 27300
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>

using namespace std;

void FSimplifiedReversi(std::istream& in, std::ostream& out) {
    int n, q;
    in >> n >> q;
    int min_d = n - 2;
    int min_r = n - 2;
    vector<int> ans_r(n - 2), ans_d(n - 2);
    int lastest_r = n, lastest_d = n;
    long long ans = 1LL * (n - 2) * (n - 2);
    set<int> st_d, st_r;
    while (q--) {
        int type;
        in >> type;
        int x;
        in >> x;
        x -= 2;
        if (type == 1) {
            min_d = min(min_d, x);
            if (st_d.empty()) {
                ans_d[x] = min_r;
                st_d.insert(x);
            } else {
                st_d.insert(x);
                auto it = st_d.find(x);
                if (it == st_d.begin()) {
                    ans_d[x] = min_r;
                } else {
                    --it;
                    ans_d[x] = ans_d[*it];
                }
            }
            ans -= ans_d[x];
        } else {
            min_r = min(min_r, x);
            if (st_r.empty()) {
                ans_r[x] = min_d;
                st_r.insert(x);
            } else {
                st_r.insert(x);
                auto it = st_r.find(x);
                if (it == st_r.begin()) {
                    ans_r[x] = min_d;
                } else {
                    --it;
                    ans_r[x] = ans_r[*it];
                }
            }
            ans -= ans_r[x];
        }
    }
    out << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    FSimplifiedReversi(in, out);
    return 0;
}

Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int h1, m1, h2, m2, k;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if (h1 > h2 || h1 == h2 && m1 > m2) {
        cout << max(0, (24 - h1 - 1) * 60 + 60 - m1 + h2 * 60 + m2 - k);
    } else if (h1 == h2) {
        cout << max(0, m2 - m1 - k);
    } else {
        cout << max(0, (h2 - h1 - 1) * 60 + 60 - m1 + m2 - k);
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll inf = 1LL << 60;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const ll max = 500010;
ll num, M, N, ans=0, count=0;
int main() {
  cin >> M >> N;
  cout << M*(M-1)/2+N*(N-1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect


def mizuyari(flowers):
    if flowers == []:
        return 0
    # print(flowers)
    minheight = min(flowers)
    if minheight == 0:
        if max(flowers) == 0:
            return 0
        leftindex = flowers.index(0)
        # print("分割" + str(leftindex))
        if leftindex == len(flowers):
            count = mizuyari(flowers[0:leftindex])
        else:
            count = mizuyari(flowers[0:leftindex]) + \
                mizuyari(flowers[leftindex+1:])

        return count
    else:
        count = mizuyari([i - minheight for i in flowers]) + minheight
        return count


N = int(input())
h_list = list(map(int, input().split()))

print(mizuyari(h_list))



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    long long int a, b, c, d;
    cin>>a>>b>>c>>d;
    vector<ll> pos = {a*c, a*d, b*c, b*d};
    cout<<*max_element(pos.begin(), pos.end())<<endl;
}

Measured memory_bytes: 3644
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

Vodd = V[: len(V):2]
Veven = V[1: len(V):2]

Voc = Counter(Vodd)
Vec = Counter(Veven)

Voc_val, Voc_cnt = zip(*Voc.most_common())
Vec_val, Vec_cnt = zip(*Vec.most_common())

Voc_val, Voc_cnt = list(Voc_val), list(Voc_cnt)
Vec_val, Vec_cnt = list(Vec_val), list(Vec_cnt)

num = Voc.most_common()[0][1] + Vec.most_common()[0][1]

if Voc_val[0] == Vec_val[0]:
    Voc_cnt.append(0)
    Vec_cnt.append(0)
    num += max(Voc_cnt[1] - Voc_cnt[0], Vec_cnt[1] - Vec_cnt[0])

print(n - num)


Measured memory_bytes: 22660
#include <bits/stdc++.h>
using namespace std;
#define P(s) cout<<s<<"\n"


int main() {
    int32_t n; cin >> n;
    vector<int32_t> t(n, 0);
    
    auto idx = n / 2;
    auto f = (n%2)? 1: -1;
    auto d = 1;
    for (auto i = 0; i < n; ++i) {
        int32_t a; cin >> a;
        t[idx] = a;
        idx += d * f;
        ++d; f *= -1;

    }
    
    for (auto i = 0; i < n; ++i) {
        if (i) {
            cout << " ";
        }
        cout << t[i];
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int n, d;
vector<Vec> x;

bool	check(int i, int j)
{
	int sq_dist = 0;
	for (int it = 0; it < d; it++)
		sq_dist += pow(x[i][it] - x[j][it], 2);
	ld dist = sqrt(sq_dist);
	return ((floor(dist) == dist));
}

int		main(void)
{
	cin >> n >> d;
	x = vector<Vec>(n, Vec(d));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
			cin >> x[i][j];
	}
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
			 if (check(i, j))
				 count++;
	}
	cout << count << endl;
}


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

namespace ConsoleApp5
{
    class Program
    {
        static void Main()
        {
            var b = Console.ReadLine();
            var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long ans = 0;

            for (int i = 0; i < int.Parse(b); i++)
            {
                if (i == int.Parse(b) - 1)
                {
                    break;
                }

                if (a[i] > a[i + 1])
                {
                    ans += a[i] - a[i + 1];
                    a[i + 1] = a[i];
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 47460
def comb1(n, x)
    if n<x || x <= 0
    return 0
  else
    @cnt += 1
  end
end

def comb2(n, x)
  for i in 1..(n-1)
    comb1(i, x-i-1)
  end
end

def comb3(n, x)
  for i in 1..(n-1)
    comb2(i, x-i-1)
  end

end

input_values = []

while true
  input_value  = gets.chomp.split.map(&:to_i)
  if input_value == [0, 0]
    break
  end
  input_values.push(input_value)
end

length = input_values.length
answers = []

for i in 0..(length-1)
  n = input_values[i][0]
  x = input_values[i][1]
  @cnt = 0
  comb3(n, x)
  answers.push(@cnt)
end

for i in 0..(length-1)
  puts answers[i]
end

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

N,M = map(int, input().split())

l,r = 1,N
for i in range(M):
    l1,r1 = map(int, input().split())
    if l1>l:
        l = l1
    if r1<r:
        r = r1
if r-l<0:
    print(0)
else:
    print(r-l+1)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>

int main() {
  int X, A;
  scanf("%d %d", &X, &A);

  if (X < A) {
    puts("0");
  } else {
    puts("10");
  }
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int>c(n);
    vector<vector<int>>a(n,vector<int>(m));
    int ans=inf;
    rep(i,0,n){
        cin>>c.at(i);
        rep(j,0,m){
            cin>>a.at(i).at(j);
        }
    }
    for(int bit=0; bit<(1<<n); bit++){
        vector<int>s(m,0);
        int cost=0;
        for(int i=0; i<n; i++){
                if(bit&(1<<i)){
                    cost+=c.at(i);
                    rep(j,0,m){
                    s.at(j)+=a.at(i).at(j);
                    }
                }
        }
        bool ch=true;
        rep(j,0,m){
            if(s.at(j)<x) ch=false;
        }
        if(ch)ans=min(ans,cost);
    }
    if(ans==inf){
        cout<<"-1"<<endl;
        return 0;
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = 1;
  int C;
  vector<int> vec(N);
  for ( int i = 0 ; i < N ; i++ ) {
    cin >> vec.at(i);
  }
  for ( int i = 0 ; i < N ; i++ ) {
    A = vec.at(A - 1);
    if ( A == 2 ) {
      cout << i + 1 << endl;
      break;
    }
    else {
      C++;
    }
  }
  if ( C == N ) {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include<stdio.h>
int main (void){
int N = 0;
int a,b;
int c=0;
int br[200100];
scanf("%d",&N);

for(a=1;a<N+1;a++){
scanf("%d",&b);
br[a] = b;
}
for(long int e=1;e<N+1;e++){

if(br[e] == e-c){
}else if(br[e] != e-c){
    c++;
}
}
  
if(N<=c){
    printf("-1");
}else if(N>c){
    printf("%d",c);

}
return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
template<typename T> void rd(T &t) {
	char ch=getchar(); t=0; int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9');
	t*=f;
}
const int maxn=100010;
int n,d[maxn],a1,a2;
int main() {
//	freopen("1.txt","r",stdin);
	rd(n);
	for (int i=1;i<=n;i++) rd(d[i]);
	sort(d+1,d+(n+1));
	a1=(1e9)+10;
	for (int i=1;i<n;i++) {
		int tmp=abs(d[i]-(d[n]+1)/2);
		if (tmp<a1) {
			a1=tmp; a2=d[i];
		}
	}
	printf("%d %d\n",d[n],a2);
	return 0;
}

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

int main(){
    string S, T, U;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    cin >> U;
  
  	int res_s=A, res_u=B;

    if(U == S){
        res_s = res_s - 1;
    }
    else if(U == T){
        res_u = res_u - 1;
    }

    cout << res_s << " " << res_u << endl;
}

Measured memory_bytes: 256