akhauriyash/Code-Regression huggingface dataset:
/// 28-01-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(x)
#define nur 100000
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpll;
typedef pair<int,int> Pll;
typedef map<string,int>msi;
typedef set<int>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}

///------------------------------------------------------------------------------------------------------------------------------------


int main()
{
    ll n,c=0,check[100005]={0};
    r(n);
    ll ar[n];

    rep(i,n){
        r(ar[i]);

        if(ar[i]>nur)
        {
            c++;
        }
        else if(ar[i]<=nur)
        {
            check[ar[i]]++;
        }
    }

    rep(i,nur){
        if(check[i]>i)
        {
            c = c+(check[i]-i);
        }
        else if(check[i]<i)
        {
            c = c+check[i];
        }
    }

    w(c);
}


Measured memory_bytes: 1792
import itertools,math

N=int(input())
X,Y=[],[]
for _ in range(N):
    x,y=map(int,input().split())
    X.append(x)
    Y.append(y)

d=0
d_all=[]
for i in itertools.permutations(range(N),N):
    for j in range(N-1):
        d+=math.sqrt((X[i[j+1]]-X[i[j]])**2+(Y[i[j+1]]-Y[i[j]])**2)
    d_all.append(d)
    d=0
print(sum(d_all)/math.factorial(N))

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

int main() {
	
	int r;
	cin >> r;
	cout << r * r << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
	int n,i,f,g=1,sum=0;
	int a[100000];
	int b[100000];
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++)
	{
		if(a[i]==i+1)
		{
			int t;
			t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			b[i]++;
		}
	}
	if(a[n-1]==n)
	{
			int t;
			t=a[n-2];
			a[n-2]=a[n-1];
			a[n-1]=t;
			b[n-1]++;
	}
	for(i=n-2;i>=0;i--)
	{
		if(a[i]==i+1)
		{
			int t;
			t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			b[i]--;
		}
	}
	for(i=0;i<n;i++)
	{
		if(b[i]<0)b[i]=-b[i];
		sum=sum+b[i];
	}
	printf("%d\n",sum);
	return 0;
}

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

int main(){
    int ans=0,sum=0;
    int n,d;
    cin >> n >> d;

    ans = (n+2*d)/(2*d+1);


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int main() {
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF) {
		if((a+b)==0) {
			printf("1\n");
		}else {
			printf("%d\n",(int)log10((double)(a+b))+1);
		}
	}
}

Measured memory_bytes: 1072
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

bool f;
bool t(std::string &s) {
	if (s[0] == 'F') return f;
	else return !f;
}

int main(void) {
	std::ios::sync_with_stdio(false);
	uint32 n;
	std::cin >> n;
	uint32 l = 0, r = n;
	std::cout << '0' << std::endl;
	std::string s;
	std::cin >> s;
	f = s[0] == 'F';
	if (s[0] == 'V') return 0;
	while (1) {
		uint32 mid = (l + r) / 2;
		std::cout << mid << std::endl;
		std::cin >> s;
		if (s[0] == 'V') return 0;
		bool temp = t(s);
		if (temp) {
			if ((mid - l) % 2 == 1) {
				r = mid;
			}
			else {
				l = mid;
			}
		}
		else {
			if ((mid - l) % 2 == 1) {
				l = mid + 1;
			}
			else {
				r = mid + 1;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200005, mod = 1000000007;
int n, pos[N], sz, fl, X, Y, Z, s[N], st[N], top, w[N], vis[N];
ll ans = 1, res;
struct edge { int y, nex, z; } g[N * 2];
void init(int x, int y, int z) { g[++ sz] = (edge) { y, pos[x], z }, pos[x] = sz; }
ll power(ll x, int y) {
	ll z = 1;
	while (y) {
		if (y & 1) (z *= x) %= mod;
		y >>= 1; (x *= x) %= mod;
	}
	return z;
}
void dfs1(int x, int fa) {
	vis[x] = 2; st[++ top] = x;
	RepE(i, x) if (ev != fa) {
		if (vis[ev] == 2) {
			X = x, Y = ev, Z = g[i].z;
			int k = top - 1;
			do {
				if (w[k] > Z) X = st[k], Y = st[k + 1], Z = w[k];
				k --;
			} while (st[k] != ev);
			fl ++;
		}
		if (!vis[ev]) w[top] = g[i].z, dfs1(ev, x);
	}
	vis[x] = 1; top --;
}
void dfs2(int x, int fa, int z) {
//	cout << x <<" - "<<s[x]<<endl;
	s[x] = 1;
	RepE(i, x) if (ev != fa && ev != X && (x != X || ev != Y)) {
		dfs2(ev, x, g[i].z);
		if (g[i].z < z) s[x] += s[ev];
	}
	(res *= power(s[x], mod - 2)) %= mod;
}
int main()
{
	scanf ("%d", &n);
	Rep(i, 1, n * 2) {
		int x, y;
		scanf ("%d%d", &x, &y);
		init(x, y + n, x + y);
		init(y + n, x, x + y);
	}
	n = n * 2;
	Rep(i, 1, n) ans = ans * i % mod;
	Rep(i, 1, n) if (!vis[i]) {
		fl = 0;
		dfs1(i, 0);
		if (fl != 1) { ans = 0; break ; }
		res = 1; dfs2(X, 0, Z);
		ll k = res;
		swap(X, Y);
		res = 1; dfs2(X, 0, Z);
		// cout << i<<" "<<k<<" " <<res<< endl;
		ans = ans * (k + res) % mod;
	}
	printf("%lld\n", ans);

	return 0;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
constexpr int mod = 1e9 + 7;

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
// mを法とするaの逆元
// O(log a)
inline LL invMod(LL a, LL m = mod) {
	LL b = m, u = 1, v = 0;
	while (b) {
		LL t = a / b;
		swap(a -= t * b, b);
		swap(u -= t * v, v);
	}
	return (u % m + m) % m;
}


// 階乗
// O(n)
constexpr int SZ = 1123456;
LL fact[SZ];
LL rfact[SZ];
struct fact_ {
	fact_() {
		fact[0] = 1;
		for (int i = 1; i<SZ; i++)
			fact[i] = fact[i - 1] * i%mod;
		rfact[SZ - 1] = invMod(fact[SZ - 1]);
		for (int i = SZ - 1; i>0; i--) {
			rfact[i - 1] = rfact[i] * i%mod;
		}
	}
}fact_init;


// 組み合わせnCk (mod mod)
// O(1)
LL Comb(LL n, LL k) {
	LL u = fact[n];
	LL d = (rfact[k] * rfact[n - k]) % mod;
	return u * d%mod;
}
int main() {
	int R, C;
	cin >> R >> C;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	LL ret = 1;
	int tate = abs(c - a);
	{
		chmin(tate, 1 + c);
		chmin(tate, 1 + (R - 1 - c));
		LL cnt = 0;
		if (abs(c - a) == tate)cnt++;
		if (1+c == tate)cnt++;
		if (1+R-1-c == tate)cnt++;
		ret *= cnt;
	}
	int yoko = abs(d - b);
	{
		chmin(yoko, 1 + d);
		chmin(yoko, 1 + (C - 1 - d));
		LL cnt = 0;
		if (abs(d-b) == yoko)cnt++;
		if (1 + d == yoko)cnt++;
		if (1 + C - 1 - d == yoko)cnt++;
		ret *= cnt;
	}
	cout << tate+yoko<<" "<<ret * Comb(tate + yoko, yoko) % mod << endl;

	return 0;
}



Measured memory_bytes: 20756
#include <bits/stdc++.h>
#define Isqaq_Baqdaulet_NTiger ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e6 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

string s;

llong n, dp[1001][1001], sum = 0, used[mxn];

string alph = "abcdefghijklmnopqrstuvwxyz";

llong summ (llong x){
    return (x * (x - 1) / 2);
}

int main(){
    Isqaq_Baqdaulet_NTiger
    cin >> s;
    for (int i = 0; i < s.size(); i ++){
        used[s[i] - 'a'] ++;
    }for (int i = 0; i < 26; i ++){
        sum += summ(used[alph[i] - 'a']);
    }cout << summ(s.size()) - sum + 1;
    return 0;
}


Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n;
	ll a[100000];
	cin >> n;
	REP(i, n) cin >> a[i];

	map<ll, ll> mp;
	REP(i, n) mp[a[i]]++;

	sort(a, a+n);

	for(int i = n-1;i >= 0;i--){
		if(mp[a[i]] >= 4){
			cout << a[i] * a[i] << endl;
			return 0;
		}
		else if(mp[a[i]] >= 2){
			for(int j = n-1;j >= 0;j--){
				if(a[j] < a[i] and mp[a[j]] >= 2){
					cout << a[i] * a[j] << endl;
					return 0;
				}
			}
		}
	}
	cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		String line = "";
		int a = 0, b = 0, o = 0, ab = 0;
		while ((line = br.readLine()) != null) {
			String[] str = line.split(",");
			String BloodType = str[1];
			if (BloodType.equals("A")) a++;
			if (BloodType.equals("B")) b++;
			if (BloodType.equals("AB")) ab++;
			if (BloodType.equals("O")) o++;
		}
		System.out.println(a + "\n" + b + "\n" + ab +"\n" + o);
	}

}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


bool isPrime(ll n)
{
    bool f = true;
    if(n == 1 || (n % 2 == 0 && n != 2)) f = false;
    else {
        for(ll i=3; i*i<=n; i+=2) {
            if(n % i == 0){
                f = false;
                break;
            }
        }
    }
    return f;
}

int main()
{
    ll X;
    cin >> X;

    REP(i,X,100004) {
        if(isPrime(i)) {
            PR(i);
            break;
        }
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3524
import sys
input = sys.stdin.readline
H, W, M = map(int, input().split())


vert = [0] * (2*W)

def update(i, d):
	i += W
	vert[i] += d
	while i > 1:
		i >>= 1
		vert[i] = max(vert[i*2], vert[i*2+1])


lines = [[] for _ in range(H)]
for _ in range(M):
	y, x = map(lambda s: int(s)-1, input().split())
	lines[y].append(x)
	update(x, 1)

best = 0

for l in lines:
	for x in l: update(x, -1)
	best = max(best, len(l) + vert[1])
	for x in l: update(x, 1)

print(best)


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w) { this->w = w; }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo inline operator + (const modulo &b) { modulo r = *this; r += b; return r; }
	modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	
	modulo inline operator - (const modulo &b) { modulo r = *this; r -= b; return r; }
	modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	
	modulo inline operator * (const modulo &b) { modulo r = *this; r *= b; return r; }
	modulo& operator *= (const modulo &b) { w = (num) w * b.w % mod, fix(); return *this; }
	
	modulo inline operator / (const modulo &b) { modulo r = *this; r /= b; return r; }
	modulo& operator /= (const modulo &b) { *this *= b.inv(); return *this; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, res = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1)  res *= a;
		return res;
	}
};

typedef modulo<998244353> rem;

const int nsz = int(2e5);
rem n, m, k, fac[nsz + 5], ifc[nsz + 5], ans;

void inline init() {
	fac[0] = ifc[0] = 1;
	cont (i, nsz) {
		fac[i] = fac[i - 1] * rem(i);
		ifc[i] = fac[i].inv();
	}
}

rem inline C(int n, int m) { return n >= m ? fac[n] * ifc[m] * ifc[n - m] : rem(0); }

rem inline f(int n, int k) { return C(n - 1, k) * m * (m - rem(1)).pow(n - k - 1); }
	
int main() {
	ios::sync_with_stdio(0);
	init();
	cin >> n >> m >> k;
	if (m == 1) {
		cout << (k == n - rem(1)) << ln;
		return 0;
	}
	ans = m.pow(n);
	circ (i, int(k) + 1, int(n)) {
		ans -= f(n, i);
	}
	cout << ans << ln;
}


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

// http://chiwawa-star.hatenablog.com/entry/2016/11/25/015503
bool IS_PRIME[100010];
vector<int> PRIMES;
vector<int> C_PRIMES;
int MAX_N = 100010;

void init_prime() {
  rep(i, MAX_N) {
    IS_PRIME[i] = true;
  }

  for(int i = 2; i <= MAX_N; i++) {
    if(!IS_PRIME[i]) continue;

    PRIMES.push_back(i);
    if(binary_search(PRIMES.begin(), PRIMES.end(), (i + 1) / 2)) {
      C_PRIMES.push_back(i);
    }

    for(int j = i * 2; j <= MAX_N; j += i) {
      IS_PRIME[j] = false;
    }
  }
}

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

  int Q;
  cin >> Q;
  init_prime();

  rep(i, Q) {
    int l,r; cin >> l >> r;

    auto l_ite = lower_bound(C_PRIMES.begin(), C_PRIMES.end(), l);
    int l_ind = distance(C_PRIMES.begin(), l_ite);
    auto r_ite = lower_bound(C_PRIMES.begin(), C_PRIMES.end(), r);
    int r_ind = distance(C_PRIMES.begin(), r_ite);

    int nums = r_ind - l_ind + 1;
    if(r != C_PRIMES[r_ind] && r_ind != 0) nums--;

    cout << nums << endl;
  }

  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int d[10] = {};
    for (int i = 0; i < k; i++) {
        int D;
        cin >> D;
        d[D] = 1;
    }
    for (int num = n;; num++) {
        int tmp = num, f = 1;
        while (tmp) {
            if (d[tmp % 10]) f = 0;
            tmp /= 10;
        }
        if (f) {
            cout << num << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  vll d(n+1);
  ll ten=1;
  for(int i=n-1;i>=0;i--){
    ll a=ten*(s[i]-'0')%2019;
    d[i]=(d[i+1]+a)%2019;
    ten*=10; ten%=2019;
  }
  map<ll,ll> p;
  ll ans=0;
  rep(i,n+1){
    p[d[i]]++;
  }
  for(auto u:p){
    ans+=u.S*(u.S-1)/2;
  }
  COUT(ans);
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,x;
    int res=0;
    cin >> a >> b >> c >> x;
    
    for (int i = 0; i < a+1; i++){
        for (int j = 0; j < b+1; j++){
            for (int k = 0; k < c+1; k++){
                if(500*i+100*j+50*k==x) res++;
            }
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
// たて a cm よこ b cm の長方形の面積と周の長さを求めるプログラムを作成して下さい。
// 【入力】
// a と b が１つの空白で区切られて与えられます。
// 【出力】
// 面積と周の長さを１つの空白で区切って１行に出力して下さい。
// 【制約】
// ・1 ≤ a, b ≤ 100
// 【例】
// ・入力：3 5、出力：15 16
#include <stdio.h>

int main( void) {
  int a, b;	// 長方形の縦と横の長さ（cm）
  int area;	// 長方形の面積
  int length;	// 長方形の周の長さ

  scanf( "%d %d", &a, &b);

  area = a * b;
  length = 2*a + 2*b;

  printf( "%d %d\n", area, length);

  return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int AMAX = 100000;
ll cnt[AMAX+1];

// Problem Specific Parameter:

int main() {
  ll n, k; cin >> n >> k;
  for(ll i = 0; i < n; ++i) {
    ll a, b; cin >> a >> b;
    cnt[a] += b;
  }

  for(ll ans = 1; ans <= AMAX; ++ans) {
    if(k <= cnt[ans]) {
      cout << ans << endl;
      break;
    }
    k -= cnt[ans];
  }

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ev[] = new int[N+1];

        ev[0] = 0;
        for(int i=1; i<=N; i++){
            int p = sc.nextInt() + 1;
            ev[i] = ev[i-1] + p;
        }

        int max = 0;
        
        for(int i=0;i<N-K+1;i++){
            if(max < ev[K+i] - ev[i]){
                max = ev[K+i] - ev[i];
            }
        }

        System.out.println(((double)max)/2);

    }
}

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

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    
    long long array[n] = {0};
    long long array2[n] = {0};
    long long sum = 0;
    int escape = 0;

    for(int i = 0 ; i < n ; i++){
        cin >> array2[i];
        array[array2[i] - 1] ++;
    }

    for(int j = 0 ; j < n ; j++){
        sum += array[j] * (array[j] - 1) / 2;
    }

    for(int i = 0 ; i < n ; i++){
        int after = 0;
        escape = array[array2[i] - 1] * (array[array2[i] - 1] - 1) / 2;
        after = (array[array2[i] - 1] - 1) * (array[array2[i] -1 ] - 2) / 2;
        cout << sum - escape + after << endl;
    }
    return 0;
}

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

int main() {
    int n;
    while (cin >> n, n != 0) {
        vector<int> imos(100000, 0);
        for (int i=0; i<n; i++) {
            int h, m, s, start, goal;
            char colon;
            cin >> h >> colon >> m >> colon >> s;
            start = s + m*60 +h*60*60;
            cin >> h >> colon >> m >> colon >> s;
            goal = s + m*60 +h*60*60;

            imos[start] += 1;
            imos[goal]  -= 1;
        }
        int sum = 0;
        for (int i=0; i<100000; i++) {
            sum += imos[i];
            imos[i] = sum;
        }
        cout << *max_element(imos.begin(), imos.end()) << endl;
    }
}


Measured memory_bytes: 3364
a = gets.chomp
b = gets.chomp

o = nil

a = a.chars.sort
b = b.chars.sort.reverse

len = 0
if a.size > b.size
  len = b.size - 1
else
  len = a.size - 1
end

(0..len).each do |i|
  if a[i] > b[i]
    o = false
    break
  elsif a[i] < b[i]
    o = true
    break
  end
end

if o.nil?
  if a.size < b.size
    o = true
  else
    o = false
  end
end

if o
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define MAXN 309
#define MAXM 4000009
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
typedef pair<int, int> ii;
typedef long long ll;

int dp[MAXN][MAXN][MAXN];
char w[MAXN];

int compute(int l, int r, int k) {
	if (l == r) return 1;
	if (l > r) return 0;

	if (w[l] == w[r]) return compute(l+1, r-1, k) + 2;
	int &ans = dp[l][r][k];
	if (ans != -1) return ans;

	ans = max(ans, compute(l+1, r, k));
	ans = max(ans, compute(l, r-1, k));
	if (k > 0) ans = max(ans, compute(l+1, r-1, k-1) + 2);
	return ans;
}
int main() {
	int k;
	scanf("%s %d", w, &k);
	int n = strlen(w);
	memset(dp, -1, sizeof(dp));
	cout << compute(0, n-1, k) << endl;
	return 0;
}

Measured memory_bytes: 115584
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)3e5 + 5;
const int mod = (int)1e9 + 7;

int n;
pi x[505];

int ans[MAX_N];

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i].f;
        x[i].s = i;
    }
    sort(x + 1, x + n + 1);
    queue < int > have;
    for (int i = 1, last = 0; i <= n; i++) {
        while(last + 1 < x[i].f) {
            last++;
            have.push(last);
        }
        last++;
        ans[x[i].f] = x[i].s;
        for (int j = 1; j < x[i].s; j++) {
            if (have.empty()) {
                cout << "No\n";
                return 0;
            }
            ans[have.front()] = x[i].s;
            have.pop();
        }
    }
    
    while(!have.empty())
        have.pop();
    for (int i = n, last = n * n + 1; i > 0; i--) {
        while(last - 1 >= x[i].f) {
            last--;
            if (!ans[last])
                have.push(last);
        }
        for (int j = x[i].s + 1; j <= n; j++) {
            if (have.empty()) {
                cout << "No\n";
                return 0;
            }
            ans[have.front()] = x[i].s;
            have.pop();
        }
    }
    
    for (int i = 1; i <= n * n; i++)
        assert(ans[i] > 0);
    cout << "Yes\n";
    for (int i = 1; i <= n * n; i++)
        cout << ans[i] << ' ';
    return 0;
}


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


int main() {
  
  int N;
  cin  >> N;
  
  vector<int> blue(N);
  
  rep(i,N){
    cin >> blue.at(i);
  }
  
  int num=0;
  
  
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      if(blue.at(i)==0)
        continue;
      else if(blue.at(i) == blue.at(j)){
        num++;
        blue.at(j)=0;
      }
    }
  }
  cout << N-num <<endl;
  
  
}

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

int main() {
  int n,p[N+1],m[N+1][N+1];
  cin>>n;
  for (int i=1;i<=n;i++) cin>>p[i-1]>>p[i];

  for (int i=1;i<=n;i++) m[i][i]=0;
  for (int l=2;l<=n;l++) {
    for (int i=1;i<=n-l+1;i++) {
      int j=i+l-1;
      m[i][j]=(1<<21);
      for (int k=i;k<=j-1;k++) {
        m[i][j]=min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout<<m[1][n]<<endl;
  return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N, M;
    cin >> N;
    set<string> s;
    REP(i, N){
        string str;
        cin >> str;
        s.insert(str);
    }
    bool opend = false;
    cin >> M;
    REP(i, M){
        string str;
        cin >> str;
        if(s.count(str)>0){
            cout << (opend?"Closed by ":"Opened by ") << str << endl;
            opend=!opend;
        }else{
            cout << "Unknown " << str << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a;
cin>>a;
double pi=3.14159266358979,ans=a*2*pi;
cout<<fixed << setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3784
/*
 * Reference: https://www.geeksforgeeks.org/sum-xor-pairs-array/
 */

#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
const ll MOD = 1000000007LL;
const ll MAX = 100010LL;

template <typename T> T gcd(T a, T b) { 
    if(b == 0) 
        return a; 
    return gcd(b, a % b); 
}
template <typename T> T power(T x, T y, ll m = MOD) {
    T ans = 1; 
    x %= m; 
    while (y > 0) { 
        if (y & 1LL) {
            ans = (ans * x) % m;   
        } 
        y >>= 1LL; 
        x = (x * x) % m; 
    } 
    return (ans % m); 
}

int main() {

    FAST_IO;

    int n;
    cin >> n;

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

    ll res = 0;
    ll mul = 1;
    for (int k = 0; k < 60; ++k) {
        ll set = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] & (1ll << k)) {
                ++set;
            }
        }
        res += ((set * (n - set)) % MOD) * mul;
        res %= MOD;
        mul *= 2;
        mul %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
ans = True
for i in range(n - 1)[::-1]:
    if h[i] - 1 == h[i + 1]:
        h[i] -= 1
    if h[i] > h[i + 1]:
        ans = False
print(['No', 'Yes'][ans])


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define traverse(container,it)  for(auto it = container.begin(); it != container.end(); it++)
typedef long long ll;

int main()
{
    //freopen("in.txt","r",stdin);
    ll time=0;
    int n;
    cin >> n;
    multimap< int,int > jobs;
    for(int i=0;i<n;i++){
        int x,y;
        cin >> x >> y;
        jobs.insert({y,x});
    }
    map< int,int >::iterator it = jobs.begin();
    while(it != jobs.end()){
        time += it->second;
        if(time > it->first)   break;
        it++;
    }
    if(it == jobs.end()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
int main(void){
    int n;
    int a;
    int i;
    int max = 0;
    int min = 1000;
    
    scanf("%d", &n);
    for( i = 0; i < n; ++i){
        scanf("%d", &a);
        if( a > max){
            max = a;
        }
        if( a < min){
            min = a;
        }
    }
    printf("%d\n", max - min);
    return 0;
    
}

Measured memory_bytes: 128
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
    cin >> s;
  	string x;
    cin >> x;
  	string l;
  	cin >> l;
  	cout<<s[0]<<x[0]<<l[0];
    return 0;
}

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

int main(){
  int a, b, c, A, B, C;
  cin >> a >> b >> c;
  A = max(max(a,b),c);
  C = min(min(a,b),c);
  B = a+b+c-A-C;
  cout << 10*A+B+C;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, t);
  vector<pair<int, int>> f(n);
  rep(i, n) cin >> f[i].first >> f[i].second;
  sort(all(f));
  vector<int> dp(t + 3001);
  int ans = 0;
  rep(i, n) {
    for (int j = t - 1; j >= 0; --j) {
      dp[j + f[i].first] = max(dp[j + f[i].first], dp[j] + f[i].second);
      ans = max(ans, dp[j + f[i].first]);
    }
  }
  out(ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int N, K; 
	string S; 
	cin >> N >> S >> K; 
	char c = S.at(K-1); 
	for(int i = 0; i < N; i++){
		if(S.at(i) == c) cout << c; 
		else cout << '*'; 
	}
	cout << endl; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MOD 1000000007
string s;
int d;
long long dp[10001][101][2];
bool vis[10001][101][2];
long long solve (int pos, int val, bool top) {
	if (pos == s.length()) return val == 0;
	if (vis[pos][val][top]) return dp[pos][val][top];
	vis[pos][val][top] = true;
	if (top) {
		for (int i=0; i<s[pos]-'0'; i++) {
			dp[pos][val][top] += solve(pos+1, (val+i)%d, false);
			dp[pos][val][top] %= MOD;
		}
		dp[pos][val][top] += solve(pos+1, (val+(s[pos]-'0'))%d, true);
		dp[pos][val][top] %= MOD;
		return dp[pos][val][top];
	}
	for (int i=0; i<10; i++) {
		dp[pos][val][top] += solve(pos+1, (val+i)%d, false);
		dp[pos][val][top] %= MOD;
	}
	return dp[pos][val][top];
}
int main () {
	cin >> s >> d;
	cout << (MOD+solve(0, 0, true)-1)%MOD << endl;
}

Measured memory_bytes: 22160
index = int(input())
nodes = [int(n) for n in input().split(' ')]
for i in range(index):
    i += 1
    print("node " + str(i) + ': key = ' + str(nodes[i-1]) + ', ',end = "")
    if i // 2 > 0:
        print("parent key = " + str(nodes[i//2 - 1]) + ", ",end = "")
    if i * 2 < index + 1:
        print("left key = " + str(nodes[i*2 - 1]) + ", ",end = "")
    if i * 2 + 1 < index + 1:
        print("right key = " + str(nodes[i*2]) + ", ",end = "")
    print("")

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

int main(){
    int a,b ;
    cin >> a >> b ;
    while( a != 0 || b != 0){
    if (a > b){
        int k = a ;
        a = b ;
        b = k ;
    }
    cout << a << " " << b << endl; 
    cin >> a >> b ;
    }
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(void) {
  
  int d,count,s;

  while(scanf("%d",&d)!=EOF) {

    count=0;
    s=0;

    for(;count<600;count=count+d) {
      s+=count*count*d;
    }

    printf("%d\n",s);
  }

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 1145148931919810;
int main(){
    ll a, b;
    cin >> a >> b;
    cout << (a + b == 15 ? '+' : (a * b == 15 ? '*' : 'x')) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
cnts = [0]*n
alist = list(map(int,input().split()))
mod = 10**9+7

for i in range(n):
    cnts[alist[i]] += 1

p = n%2
if p == 1:
    cnts[0] += 1

for i in range(n):
    if p != (i%2):
        if cnts[i] != 2:
            print(0)
            exit()
    else:
        if cnts[i] != 0:
            print(0)
            exit()
print(pow(2,(n//2))%mod)

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    string s = to_string(n);
    for (int i = 0; i < s.length(); ++i) {
        if(s[i] == '1') cout << '9';
        else cout << '1';
    }


}









Measured memory_bytes: 3720
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define ll          long long int
#define T           long long int t;scanf("%lld",&t);while(t--)
#define CS          cout<<"Case "<<cs++<<": "
#define nd          endl
#define dd          double
#define ss          string
#define Y           cout<<"YES"<<endl
#define N           cout<<"NO"<<endl
#define for0(i,n)   for( i=0;i<n;i++)
#define forn(n,i)   for( i=n-1;i>=0;i--)
deque<ll>dq;
vector<ll>v;
map<ll,ll>m;


int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt", "w", stdout);
    ll n,m,a,b,k,j,sum=0,sum1=0,i=1,even=0,odd=0,temp=0,temp1=0;
    ss s,s1;
    ll mod=1e9 +7;
    cin>>n;
    while(n>0)
    {
        n=n-i;
        sum++;
        i++;
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	int res = 0;
	int c = 0;
	int last = -1;
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		if (h > last) {
			last = h;
			c = 0;
		} else {
			last = h;
			c++;
			res = max(res, c);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#include <string.h>
#include <algorithm>
#include <set>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
struct node
{
    long long num,val;
}a[111111];
int cmp(node a,node b)
{
    return a.val<b.val;
}
int main()
{
    int n,m;
    long long sum = 0;
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i ++)
    {
        cin >> a[i].val >> a[i].num;
    }
    sort(a+1,a+1+n,cmp);
    for(int i = 1 ; i <= n ; i ++)
    {
        if(m>=a[i].num)
        {
            m-=a[i].num;
            sum += (a[i].val*a[i].num);
        }
        else
        {
            sum += (m*a[i].val);
            break;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    int cnt = x;
    rep(i,n)
    {
        int di = 1;
        while(di<=d)
        {
            cnt++;
            di += a[i];
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int CMax = 27;

int n, m, A[CMax], ats, dal;
string S;

int main ()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        cin >> S;
        for (int j = 0; j < m; j++) {
            A[(int)S[j] - (int)'a']++;
        }
    }

    if (n % 2 == 0 && m % 2 == 0) {
        for (int i = 0; i < 27; i++) {
            if (A[i] % 4 != 0) {
                printf("No");
                return 0;
            }
        }
    } else if (n % 2 != 0 && m % 2 != 0) {
        int vidur = 0;
        int nelyg = 0;
        for (int i = 0; i < 27; i++) {
            if ((A[i] % 2 != 0 && vidur > 0) || (A[i] % 4 != 0 && nelyg + vidur + A[i] % 4 > (n + m - 1))) {
                printf("No");
                return 0;
            }
            if (A[i] % 2 != 0) {
                vidur++;
                A[i]--;
            }
            nelyg += A[i] % 4;
        }
    } else {
        int nelyg = 0;
        for (int i = 0; i < 27; i++) {
            if (A[i] % 2 != 0 || (A[i] % 4 != 0 && nelyg + A[i] % 4 > (n % 2 != 0 ? m : n))) {
                printf("No");
                return 0;
            }
            nelyg += A[i] % 4;
        }
    }

    printf("Yes\n", ats);
}


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

const int N=200;

int n,m,q,arr[N],a[N],b[N],c[N],d[N],ans;

void f(int i,int pv)
{
	if(i==n+1)
	{
		int cost=0;
		for(int i=0;i<q;i++)
		{
			if(arr[b[i]]-arr[a[i]]==c[i]) cost+=d[i];
		}
		ans=max(ans,cost);
		return;
	}
	for(int j=pv;j<=m;j++)
	{
		arr[i]=j;
		f(i+1,j);
	}
}

int main()
{
	cin>>n>>m>>q;
	for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	f(1,1);
	cout<<ans;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));

    int k;
    cin >> k;
    OP(a[0] + a[1] + a[2] * (int)pow(2, k));
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << ((abs(x - a) > abs(x - b)) ? 'B' : 'A') << "\n";

    return 0;
}


Measured memory_bytes: 3652
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;
struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};
int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  vP es(m);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    es[i] = {a, b};
  }

  ll ans = 0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j, m) {
      if (i == j) continue;
      uf.unite(es[j].first, es[j].second);
    }
    if (uf.count() != 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	VLL A(N);
	for (int n = 0; n < N; n++) { cin >> A[n]; }
	VLL AA(N);
	for (int n = 0; n < N - 1; n++) {
		AA[n] = A[n] ^ A[n + 1];
	}
	VLL sum(N, 0);
	sum[1] = AA[0];
	for (int n = 3; n < N; n += 2) {
		sum[n] = sum[n-2] ^ AA[n - 1];
	}
	for (int n = 0; n < N; n++) {
		LL a = A[n] ^ sum.back();
		cout << a << "\n";
	}
	return 0;
}

Measured memory_bytes: 7520
function Main(input) {
  var args = input.split('\n');
  var coin500 = parseInt(args[0], 10);
  var coin100 = parseInt(args[1], 10);
  var coin50 = parseInt(args[2], 10);
  var coinTotal = parseInt(args[3], 10);
  var pat = 0;
  for(var i = 0; i <= coin500; i++){
    for(var j = 0; j <= coin100; j++){
      for(var k = 0; k <= coin50; k++){
        if((500 * i + 100 * j + 50 * k) === coinTotal) pat++;
      }
    }
  }
  console.log(pat);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [usize; n]
   }

   let mut l = vec![0; n + 1];
   let mut r = vec![0; n + 1];
   for i in 0..n {
      l[i + 1] = l[i] ^ a[i];
   }
   for i in (0..n).rev() {
      r[i] = r[i + 1] ^ a[i];
   }
   for i in 0..n {
      print!("{} ", l[i] ^ r[i + 1]);
   }
}


Measured memory_bytes: 9512
amo = gets.to_i
t, goal = gets.split.map(&:to_i)
places = gets.chomp.strip.split.map(&:to_i)

temps = places.map{|place| t - place * 0.006}

temps.map!{|temp| (goal - temp).abs}

puts temps.rindex(temps.min) + 1

Measured memory_bytes: 1788
n = int(input())
a = list(map(int,input().split()))

flag = True
judge = True
count=0

while flag:
    for i in range(n-1,0,-1):
        if a[i] < a[i - 1]:
            a[i],a[i - 1] = a[i - 1], a[i] #swap
            count+=1
    if sorted(a) == a: flag = False

print(' '.join(map(str,a)))
print(count)



Measured memory_bytes: 5600