akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cassert>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <limits.h>
#include <fstream>

#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define pll pair <ll, ll>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
#define uint unsigned int

const int maxlog = 8;
const int maxn = (1 << 8);

int a[maxn + 10];
char s[maxn + 10];

vector <pii> ans;

void go(int &x, int &y, int dx, int dy) {
	x += dx;
	y += dy;
	ans.push_back(mp(x, y));
}

vector <pii> build(vector <int> p) {
	if ((int)p.size() == 1) {
		return { mp(p[0], 1) };
	}

	int x = p.back();
	p.pop_back();

	vector <pii> ans = build(p);
	vector <pii> res;

	for (int i = 0; i < (int)ans.size(); i++) {
		res.push_back(mp(ans[i].first, -ans[i].second));
	}

	reverse(all(res));
	ans.insert(ans.end(), all(res));
	res.clear();

	for (int i = 0; i < (int)ans.size(); i++) {
		res.push_back(mp(x, (i % 2 == 0 ? 1 : -1)));
		res.push_back(ans[i]);
	}

	return res;
}

void make(int &x, int &y, pii f) {
	int ps = f.first;
	if (f.second == -1) {
		ps++;
	}

	while (x < ps) {
		x++;
		ans.push_back(mp(x, y));
	}

	while (x > ps) {
		x--;
		ans.push_back(mp(x, y));
	}

	y--;
	ans.push_back(mp(x, y));
	x += f.second;
	ans.push_back(mp(x, y));
	y++;
	ans.push_back(mp(x, y));
}

int main() {
	int n;

	cin >> n;
	cin >> s;

	for (int i = 0; i < (1 << n); i++) {
		a[i] = s[i] - '0';
	}

	for (int i = (1 << n) - 1; i >= 0; i--) {
		if (a[i] == 0) {
			for (int j = 0; j < n; j++) {
				if ((i >> j) & 1) {

				}
				else {
					if (a[i | (1 << j)] == 1) {
						cout << "Impossible\n";
						return 0;
					}
				}
			}
		}
	}

	if (a[0] == 0) {
		cout << "Impossible\n";
		return 0;
	}

	ans.push_back(mp(0, 0));

	for (int i = 0; i < (1 << n); i++) {
		if (a[i] == 1) {
			continue;
		}

		vector <int> p;

		bool nd = true;

		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				if (a[i ^ (1 << j)] == 0) {
					nd = false;
				}
				p.push_back(j);
			}
		}

		if (!nd) {
			continue;
		}

		int x = 0, y = 0;

		vector <pii> to = build(p);

		y++;
		ans.push_back(mp(x, y));

		for (pii f : to) {
			make(x, y, f);
		}

		while (x > 0) {
			x--;
			ans.push_back(mp(x, y));
		}

		y--;
		ans.push_back(mp(x, y));
	}

	cout << "Possible\n";
	cout << (int)ans.size() - 1 << '\n';

	for (pii f : ans) {
		cout << f.first << ' ' << f.second << '\n';
	}
}

Measured memory_bytes: 2412
#include <iostream>
#include <string>

using namespace std;

int main() {
    long N;
    cin >> N;

    long cnt[5] = {};
    for (long n = 0; n < N; n++) {
        string name;
        cin >> name;
        switch (name[0]) {
            case 'M':
                cnt[0]++;
                break;
            case 'A':
                cnt[1]++;
                break;
            case 'R':
                cnt[2]++;
                break;
            case 'C':
                cnt[3]++;
                break;
            case 'H':
                cnt[4]++;
                break;
        }
    }

    long res = 0;
    for (long i = 0; i < 5; i++)
        for (long j = i + 1; j < 5; j++)
            for (long k = j + 1; k < 5; k++)
                res += cnt[i] * cnt[j] * cnt[k];

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    set<int> st;
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        while(d--){
            int x;
            cin >> x;
            st.insert(x);
        }
    }
    cout << n - st.size();

    return 0;

}


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

int main() {
   int n,d;
   cin >> n >> d;
   int x[20][20];
   rep(i,n){
      rep(j,d)
      cin >> x[i][j];
   }
   int ans=0;
   rep(i,n){
      rep(j,i){
         int sq=0;
         rep(k,d){
            int s=x[i][k]-x[j][k];
            sq+=s*s;
         }
         int s=sqrt(sq)+0.5;
         if(s*s==sq)
         ans++;
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool isprime(int n);
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=n;i<=120000;i++)
	{
		if(isprime(i))
		{
			printf("%d",i);
			return 0;
		}
	}
}
bool isprime(int n)
{
	for(int i=2;i<=sqrt(n);i++)
	{
		if(n%i==0)
		return false;
	}
	return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
  
int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll num1 = b / c - (a - 1) / c;
    ll num2 = b / d - (a - 1) / d;
    ll num3 = b / lcm(c, d) - (a - 1) / lcm(c, d);
    ll ans = (b - a + 1) - (num1 + num2 - num3);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long int ans=0;
    string str;
    cin >> str;
    
    for(int i=0; i<(1<<(str.size()-1)); i++) {
        long long int tmp=0;
        for(int j=0; j<str.size()-1; j++) {
            if(i & (1<<j)) {
                tmp *= 10;
                tmp += (long long int)(str[j]-'0');
                ans += tmp;
                tmp = 0;
            } else {
                tmp *= 10;
                tmp += (long long int )(str[j]-'0');
            }
        }
        ans += tmp*10;
        ans += (long long int)(str[str.size()-1]-'0');
    }
    
    cout << ans << endl;


    return 0;
    
}

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

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<double> A(N);
    
    double denom = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        denom += 1.0 / A[i];
    }
    cout << 1.0 / denom << endl;
    return 0;
}


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

template<typename T>
T largestSquare(vector<vector<T>> &dp) {
	T maxv = 0;
	int H = dp.size();
	int W = dp[0].size();
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i && j && dp[i][j]) {
				dp[i][j] = min({dp[i-1][j-1], dp[i][j-1], dp[i-1][j]}) + 1;
			}
			maxv = max(maxv, dp[i][j]);
		}
	}
	return (maxv);	
}

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>> dp(H, vector<int>(W, 0));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> dp[i][j];
			dp[i][j] = 1 - dp[i][j];
		}
	}
	int d = largestSquare(dp);

	cout << d*d << endl;
	return (0);
}



Measured memory_bytes: 10540
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define maxx ((ll)1e6+5)
#define pb push_back
#define ins insert
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*int sv[1000000]={0};
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<=maxx;i++){if(!sv[i]){for(int j=2*i;j<=maxx;j+=i)sv[j]=1;}}}//0 hai to prime
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}*/
int d[1003][1003];
using namespace std;
signed main()
{
    int r,c,i,j;
    cin >> r >> c;
    char a[r][c];
    for(i=0 ; i<r ; i++)
    	for(j=0 ; j<c ; j++)
    		cin >> a[i][j];
    d[0][0] = 1;
    for(i=0 ; i<r ; i++)
    	for(j=0 ; j<c ; j++)
    	{
    		if(a[i][j] == '#')
    			continue;
    		if(j>0) d[i][j] = (d[i][j] + d[i][j-1])%mod;
    		if(i>0) d[i][j] = (d[i][j] + d[i-1][j])%mod;
    	}
    cout << d[r-1][c-1] <<"\n";
    return 0;
}

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

int main(){
    string s;
    int k;
    cin >> s >>k;
    string a[6]={"zzzzzz","zzzzzz","zzzzzz","zzzzzz","zzzzzz","zzzzzz"};
    int l=s.length();
    if (l>=5){
        for (int i=0; i<l-4; i++){
            for (int j=0; j<5; j++){
                string t=s.substr(i,j+1);
                if (a[0]==t || a[1]==t || a[2]==t || a[3]==t || a[4]==t){
                    continue;
                }
                else {
                    a[5]=t;
                    sort(a,a+6);
                }
            }
        }    
        for (int i=l-4; i<l; i++){
            for (int j=0; j<l-i; j++){
                string t=s.substr(i,j+1);
                if (a[0]==t || a[1]==t || a[2]==t || a[3]==t || a[4]==t){
                    continue;
                }
                else {
                    a[5]=t;
                    sort(a,a+6);
                }
            }
        }
    }
    else {
        for (int i=0; i<l; i++){
            for (int j=0; j<l-i; j++){
                string t=s.substr(i,j+1);
                if (a[0]==t || a[1]==t || a[2]==t || a[3]==t || a[4]==t){
                    continue;
                }
                else {
                    a[5]=t;
                    sort(a,a+6);
                }
            }
        }
    }
    cout << a[k-1] <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int A[10],x[3],y[3];

int main()
{
	int i,j;
	bool judge = true;
	for(i=0;i<3;i++)
		for(j=0;j<3;j++)
			scanf("%d",&A[3*i+j]);
			
	x[1] = A[1]-A[0]; x[2] = A[2]-A[0];	
	y[1] = A[3]-A[0]; y[2] = A[6]-A[0];
	for(i=0;i<3;i++)
		for(j=0;j<3;j++)
			if(A[i*3+j]-A[0]!=x[j]+y[i])judge = false;
		
	if(judge)printf("Yes");
	else printf("No");
	return 0;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a, b, c, d[1000];
pair<int,pii> e[2000];

// sからtに辿り着くまでに閉路が存在すればtrueを返す
// グラフに閉路が存在してもそこを経由できない場合は閉路を検出しない
bool bford(int n, pair<int,pair<int,int>> *e, int *d, int s, int t = -1) {
	fill(d, d+n, linf), d[s] = 0;
	for (int i=0; i<n*2; ++i) {
		for (int j=0; j<m; ++j) {
			int from = e[j].first, to = e[j].second.first, cost = e[j].second.second;
			if(d[from]!=linf && d[to]>d[from]+cost){
				d[to] = d[from] + cost;
				if(to==t && n-1<=i) return true;
			}
		}
	}
	return false;
}

signed main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> a >> b >> c;
		a--, b--;
		e[i] = {a, {b, -c}};
	}
	if (bford(n,e,d,0,n-1)) cout << "inf" << ln;
	else cout << -d[n-1] << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 220000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	ll N, P;
	cin >> N >> P;
	vl A(N);
	vl Asum(N + 1, 0);
	map<ll, ll> Acount;
	rep(i, N) {
		cin >> A[i];
		Acount[A[i]]++;
	}
	sort(A.begin(), A.end(), greater<ll>());
	rep(i, N) {
		Asum[i + 1] = Asum[i] + A[i];
	}
	ll L = 0;
	ll R = nmax_def;
	ll ans = 0;
	while (1) {
		ll M = (L + R) / 2;
		ll Psum = 0;
		ll Psum_Meq = 0;
		ans = 0;
		ll j = N - 1;
		rep(i, N) {
			while (1) {
				if (j == -1)
					break;
				if (A[i] + A[j] >= M)
					break;
				j--;
			}
			Psum += (j + 1);
			ans += A[i] * (j + 1);
			ans += Asum[j + 1];
			if (j != -1) {
				Psum_Meq += Acount[A[j]];
				ans -= M * Acount[A[j]];
			}
		}
		//cout << L << " " << M << " " << R << endl;
		//cout << P << " " << Psum << " " << Psum_Meq << endl;

		if (L == M) {
			//cout << ans << endl;
			ll Prem = P - (Psum - Psum_Meq);
			ans += (Prem * M);
			break;
		}
		if (Psum > P)
			L = M;
		else
			R = M;
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
  int n,i;
  cin >> n;
  double sum;
  vector<double> x(n);
  vector<string> u(n);
  for(i=0;i<n;++i){
    cin >> x[i] >> u[i];
  }
  for(i=0;i<n;++i){
    if(u[i]=="JPY"){
      sum=sum+x[i];
    }else{
      sum=sum+x[i]*380000.0;
    }
  }
  cout << sum << endl;
  return 0;


}


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

using namespace std;

int main() {
	int k, x;
	cin >> k >> x;
	if (500 * k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            out.println(s.replace("2017", "2018"));
        }

    }
}



Measured memory_bytes: 25044
# frozen_string_literal: true

def chmin(a, b)
  a > b ? b : a
  end

def chmax(a, b)
  a > b ? a : b
end

n, m = gets.split.map(&:to_i)
l = []
r = []
m.times do
  k, b = gets.split.map(&:to_i)
  l << k
  r << b
end
c = 0
d = 1_000_010
(0..m - 1).each do |i|
  c = chmax(c, l[i])
  d = chmin(d, r[i])
end

puts c <= d ? d - c + 1 : 0


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;



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

    ll sum = 0;

    if(y < x){
        swap(x, y);
        swap(a, b);
    }

    if(2*c < a+b){
        sum += x * 2*c;
        y -= x;
        x = 0;
    }
    else{
        cout << x*a + y*b << endl;
        return 0;
    }

    if(b < 2*c){
        sum += y*b;
        y = 0;
    }
    else{
        sum += y*2*c;
        y = 0;
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string str[] = {"ABC","ARC","AGC"};
    int a;
    cin >> a;
    if(a >= 2800)cout << str[2] << endl;
    else if(a >= 1200)cout << str[1] << endl;
    else   cout << str[0] << endl;
}

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

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

using namespace std;

int main() {
  int m,n;
  cin >> m >> n;
  int k;
  cin >> k;
  vector<string> t(m);
  for (int i = 0; i < m; ++i) {
    cin >> t[i];
  }
  vector<vector<int>> J(m+1, vector<int>(n+1));
  vector<vector<int>> O(m+1, vector<int>(n+1));
  vector<vector<int>> I(m+1, vector<int>(n+1));
  for (int i = 0; i < m; ++i) {
    int sum[3] = {0,0,0};
    for (int j = 0; j < n; ++j) {
      char joi[] = {'J','O','I'};
      for (int l = 0; l < 3; ++l) {
        if (t[i][j] == joi[l]) {
          ++sum[l];
        }
      }
      J[i+1][j+1] = J[i][j+1] + sum[0];
      O[i+1][j+1] = O[i][j+1] + sum[1];
      I[i+1][j+1] = I[i][j+1] + sum[2];
    }
  }
  for (int i = 0; i < k; ++i) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int s[3] = {0,0,0};
    s[0] =  J[c][d] - J[c][b-1] - J[a-1][d] + J[a-1][b-1];
    s[1] =  O[c][d] - O[c][b-1] - O[a-1][d] + O[a-1][b-1];
    s[2] =  I[c][d] - I[c][b-1] - I[a-1][d] + I[a-1][b-1];
    cout << s[0] << ' ' << s[1] << ' ' << s[2] << endl;
  }
  return 0;
}

Measured memory_bytes: 13932
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	double p[200005];
	for (i = 0; i < n; i++)
		scanf("%lf", &p[i]);
	for (i = 0; i < n; i++)
		p[i] = (p[i] + 1) / 2;
	double sum[200005];
	sum[0] = 0;
	for (i = 0; i < n; i++)
		sum[i + 1] = sum[i] + p[i];
	double ans = 0;
	for (i = 0; i <= n - k; i++)
		if (ans < sum[i + k] - sum[i])
			ans = sum[i + k] - sum[i];
	printf("%.20lf\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n,m,x,y;
    while (~scanf("%d %d %d %d",&n,&m,&x,&y)) {
        int ans = x*m + y*n - x*y;
        printf("%d\n", n*m - ans);
    }
    
    return 0;
}



Measured memory_bytes: 256
import collections

n = int(input())
# n = 840

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    
    a = collections.Counter(a)
    return dict(a)



dic = prime_factorize(n)
# print(dic)


list_keys = list(dic.keys())

cnt = 0
for key in list_keys:
    c = 1
    while True:
        dic[key] -= c
        c += 1
        cnt += 1
        if dic[key] < c:
            break

print(cnt)

Measured memory_bytes: 9468
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] normalTime = new int[N];
        for(int n=0;n<N;n++)normalTime[n]=sc.nextInt();
        
        int totalTime =0;
        for(int n=0;n<N;n++)totalTime += normalTime[n];
        
        int M = sc.nextInt();
        for(int m=0;m<M;m++){
        	int qNumber = sc.nextInt();
        	int drinkTime = sc.nextInt();
        	System.out.println(totalTime - normalTime[qNumber-1] + drinkTime);
        }
    }
}

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

#define ascent(i, a, b) for(int (i) = (a); (i) < (b); (i) ++)

using namespace std;

int main() {
  int tmp;
  vector<int> n;
  while(cin >> tmp) {
    n.push_back(tmp);
  }

  ascent(i, 0, n.size()) {
    int ans = 0;
    ascent(a, 0, 10) {
      ascent(b, 0, 10) {
	ascent(c, 0, 10) {
	  ascent(d, 0, 10) {
	    if(a + b + c + d == n[i]) {
	      ans ++;
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int MAX_N = 8;
int n, m, p, a, b;
int t[MAX_N];

struct state {
	int city, used;
	double dist;
	state(int c, int t, double d):city(c), used(t), dist(d){}
	bool operator>(const state& s) const {
		return dist > s.dist;
	}
};

struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c){}
};

vector<vector<edge> > es;

double dijkstra() {
	vector<vector<double> > dist(m, vector<double>(1 << n, INT_MAX));
	priority_queue<state, vector<state>, greater<state> > que;
	dist[a][0] = 0;
	que.push(state(a, 0, 0));

	while(!que.empty()) {
		const state s = que.top();
		que.pop();

		if(dist[s.city][s.used] < s.dist)
			continue;

		if(s.city == b)
			return s.dist;

		for(int i = 0; i < (int)es[s.city].size(); ++i) {
			const edge& e = es[s.city][i];
			for(int j = 0; j < n; ++j) {
				if(s.used & (1 << j))
					continue;

				const double d = s.dist + ((double)e.cost / t[j]);
				const int next_used = (s.used | (1 << j));
				if(dist[e.to][next_used] > d) {
					dist[e.to][next_used] = d;
					que.push(state(e.to, next_used, d));
				}
			}
		}
	}

	return -1;
}

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

	while(cin >> n >> m >> p >> a >> b, n) {
		--a;
		--b;

		for(int i = 0; i < n; ++i)
			cin >> t[i];

		es.clear();
		es.resize(m);

		for(int i = 0; i < p; ++i) {
			int x, y, z;
			cin >> x >> y >> z;
			--x;
			--y;
			es[x].push_back(edge(y, z));
			es[y].push_back(edge(x, z));
		}

		double ans = dijkstra();
		if(ans < 0)
			cout << "Impossible" << endl;
		else
			cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S; cin >> S;
  int L = S.length()-1;
  LL total = 0;
  for (int i = 0; i < (1 << L); ++i) {
    bitset<10> b(i);
    LL sum = 0;

    string ss;
    ss = S[0];
    for (int j = 0; j < L; ++j) {
      if (b.test(j)) {
        sum += stol(ss);
        ss = S[j+1];
      } else {
        ss += S[j+1];
      }
    }
    sum += stol(ss);
    total += sum;
  }
  cout << total << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

ll n,W; vll weights(100003),values(100003);
ll dp[103][100003];

ll solve(ll i, ll wi)
{
	if(i==n){return 0;}

	if(dp[i+1][wi]==-1)dp[i+1][wi]=solve(i+1,wi);

	if(wi<weights[i]) return dp[i+1][wi];
	else
	{
		if(dp[i+1][wi]==-1)dp[i+1][wi]=solve(i+1,wi);
		if(dp[i+1][wi-weights[i]]==-1)dp[i+1][wi-weights[i]]=solve(i+1,wi-weights[i]);
		return max(dp[i+1][wi], values[i]+dp[i+1][wi-weights[i]]);
	}

}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	cin>>n>>W; forA(i,0,n,1)cin>>weights[i]>>values[i];
	forA(i,0,103,1)forA(j,0,100003,1)dp[i][j]=-1;
	cout<<solve(0,W);
	return 0;
}

Measured memory_bytes: 85260
// author : Kartikey Tewari
// date: 2020-02-22   17:50:19
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
#define pii pair<ll,ll>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    ll n,k;
    cin >> n >> k;

    double a=log10(n+1)/log10(k);

    if (floor(a)!=a)
    {
        cout << floor(a)+1 << endl;
    }
    else
    {
        cout << a << endl;
    }
    
    return 0;
}

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

int main(){
  int N, X, Y; cin >> N >> X >> Y;
  map<int, int> A;
  rep(i, N){
    rep(j, N){
      if (i < j) {
        int dist = min(j-i, abs((X-1)-i) + abs((Y-1)-j) + 1);
        A[dist]++;
      }
    }
  }
  
  int count = 0;
  for (auto p : A) count++, cout  << p.second << endl;
  int redun = N - count - 1;
  rep(i, redun){
    cout << 0 << endl;
  }
      
}

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

int main(){
   char s[3];
   cin>>s[0]>>s[1]>>s[2];
   int t[3];
   t[0]=s[0]-'0';
   t[1]=s[1]-'0';
   t[2]=s[2]-'0';
   cout<<t[0]+t[1]+t[2]<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 2019
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	string s; cin >> s;
	long long  n = s.length();
	vector<long long > suff(n + 2, 0);
	vector<long long > pw(n + 2, 1);
	for (long long  i = 1; i <= n + 1; i++) pw[i] = (pw[i - 1] * 10) % MOD;
	debug(pw);
	map<long long , long long > freq;
	freq[0] = 1;
	long long  ans = 0;
	for (long long  i = n - 1; i >= 0; i-- ) {
		suff[i] = (suff[i + 1] + ((s[i] - '0') * pw[n - 1 - i]) % MOD) % MOD;
		ans += freq[suff[i]];
		debug(i, ans);
		freq[suff[i]]++;
	}

	debug(suff);
	cout << ans;



	return 0;
}

Measured memory_bytes: 6224
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b;
    sfl(a),sfl(b);
    ll res = a*b;
    pfl(res);
    return 0;
}

Measured memory_bytes: 3816
s = input()[::-1]
#sは文字列 逆向きにしている
sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10         #dを１０倍
    d %= 2019       #dを2019で割る（2019は10と素なので意味はないかも）
    cnts[sum_of_digits] += 1
    #cntは2019個ある　modの値が同じごとに個数を計算して足したもの

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2  
                    #cnt conbination 2
                    #mod ごとに m(m − 1)/2
        
#(i, j)が条件をみたすのはTi−1 == Tj (mod2019)のとき
#Ti−1 - Tj == 0 (mod2019) と等価 Ti−1 == Tj (mod2019)

print(ans)


Measured memory_bytes: 9260
A, B = map(int, input().split())



def R (D):
    bins=""
    for i in range(1,50):
        d = 2**i
        ans = False
        if i == 1:
            if(D%4==1 or D%4==2):
                ans = True
        if i > 1:
            if(D%d>=d//2 and D%d%2==0):
                ans = True
        bins = str(int(ans)) + bins
    return int(bins,2)

print(R(A-1)^R(B))

Measured memory_bytes: 3064
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    ll x, y;
    cin >> x >> y;
    
    
    if (x % y == 0)
    {
        cout << -1 << '\n';
        return 0;
    }
    
    ll num = x;
    
    while (num < 1e18)
    {
        num += x;
        if (num % x == 0 && num % y != 0)
        {
            cout << num << '\n';
            return 0;
        }
    }
    
    cout << -1 << '\n';
    
    return 0;
    
}




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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k,q;cin>>k>>q;
  vector<ll>d(k);
  rep(i,0,k)cin>>d[i];
  rep(i,0,q){
    ll n,x,m;cin>>n>>x>>m;
    ll cnt=0;
    ll sum=0;
    ll sum2=0,cnt2=0;
    n--;
    rep(j,0,k){
      if(j==n%k){
        cnt=sum;
        cnt2=sum2;
      }
      sum2+=(d[j]%m==0);
      sum+=d[j]%m;
    }
    ll tmp1=(cnt+sum*(n/k)+x%m)/m;//>の回数
    ll tmp2=cnt2+sum2*(n/k);//=の回数
    //cout<<cnt spa cnt2 spa sum spa sum2<<endl;
    //cout<<n spa tmp1 spa tmp2<<endl;
    cout<<n-tmp1-tmp2<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
s=list(input())
s.sort()
if len(s)%2==1 and s[0]==s[-1]:
  print("No")
  
else:
  ans=0
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      ans+=1
    else:
      if ans%2==0:
        print("No")
        break
      else:
        ans=0
        pass
  else:
    print("Yes")

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

int bubble_sort(int A[], int N) {
    int cnt = 0;
    bool flag = true;

    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = true;
                cnt++;
            }
        }
    }

    return cnt;
}

int main() {
    int N, cnt, A[100];

    cin >> N;

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

    cnt = bubble_sort(A, N);

    cout << A[0];
    for (int i = 1; i < N; i++) {
        if (i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3128
import math
arr = input().split()
n = int(arr[0])
m = int(arr[1])

if n == m:
    print((math.factorial(n) * math.factorial(m) * 2) % (10**9 + 7))
elif n == m + 1 or m == n + 1:
    print((math.factorial(n) * math.factorial(m)) % (10**9 + 7))
else:
    print(0)


Measured memory_bytes: 5184
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC123A_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];
            for (int i = 0; i < 5; i++)
            {
                a[i] = ReadInt;
            }

            int k = ReadInt;
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (a[i] - a[j] > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }

            Console.WriteLine("Yay!");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 11220
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class UnionFind:
    def __init__(self, N): self.N, self.root, self.rank, self.group_count = N, [-1] * N, [0] * N, N
    def __repr__(self): return '\n'.join(f"{r}: {self.members(r)}" for r in self.roots())

    def find(self, x):
        while self.root[x] >= 0: x = self.root[x]
        return x

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        if self.rank[x] > self.rank[y]: x, y = y, x
        self.root[y] += self.root[x]
        self.root[x] = y
        if self.rank[x] == self.rank[y]: self.rank[y] += 1
        self.group_count -= 1

    def same(self, x, y): return self.find(x) == self.find(y)
    def count(self, x): return -self.root[self.find(x)]
    def members(self, x): return [i for i in range(self.N) if self.same(x, i)]
    def roots(self): return [i for i, x in enumerate(self.root) if x < 0]
    def all_groups(self):
        d = defaultdict(lambda: [])
        for i in range(self.N): d[self.find(i)].append(i)
        return dict(d)


def main():
    N, Q = LI()
    TUV = LIR(Q)

    uf = UnionFind(N)

    for t, u, v in TUV:
        if t == 0:
            uf.union(u, v)
        else:
            print(int(uf.same(u, v)))

if __name__ == '__main__':
    main()

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

int main()
{
	int n,a[200];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	bool f=1;
	int v=-1;
	while(f){
		for(int i=0;i<n;i++){
			if(a[i]%2==1) f=0;
			a[i]/=2;
		}
		v++;
	}
	
	cout<<v<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int A,B,ans=0;
    cin >> A>>B;
    
    ans += max(A, B);
    (A >= B) ? A-- : B--;
    ans += max(A, B);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m, a[N];

ll id[N];
ll sz[N];
void ini()
{
	for (ll i = 0; i < N; i++) { id[i] = i, sz[i] = 1; }
}
ll root (ll i)
{
	while (i != id[i]) { id[i] = id[id[i]], i = id[i]; }
	return i;
}
void uni (ll a, ll b)
{
	ll ra = root (a);
	ll rb = root (b);
	if (ra == rb) { return; }
	if (sz[ra] > sz[rb]) { id[rb] = ra, sz[ra] += sz[rb]; }
	else { id[ra] = rb, sz[rb] += sz[ra]; }
}
vector<PII>v[2];
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	ini();
	ll n, m, q;
	cin >> n >> m >> q;
	for (ll i = 1; i <= q; i++)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		a++;
		b++;
		v[c].pb ({a, b});
		if (!c)
		{
			uni (a, b);
		}
	}
	for (auto w : v[1])
	{
		if (root (w.f) == root (w.s))
		{
			cout << "No";
			return 0;
		}
	}
	ll cmp = 0;
	for (ll i = 1; i <= n; i++)
	{
		if (root (i) == i) { cmp++; }
	}
	ll l = n;
	ll r = cmp * (cmp - 1) / 2 + (n - cmp);
	if (v[1].size() == 0)
	{
		l--;
	}
	if (l <= m && m <= r)
	{
		cout << "Yes";
	}
	else { cout << "No"; }
	return 0;
}


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

int main()
{
	int x;
	cin>>x;
	if(x>=400 && x<600){
		cout<<8<<endl;
	}
	else{
		if(x>=600 && x<800){
			cout<<7<<endl; 
		}
		else{
			if(x>=800 && x<1000){
				cout<<6<<endl;
			}
			else{
				if(x>=1000 && x<1200){
					cout<<5<<endl;
				}
				else{
					if(x>=1200 && x<1400){
						cout<<4<<endl;
					}
					else{
						if(x>=1400 && x<1600){
							cout<<3<<endl;
						}
						else{
							if(x>=1600 && x<1800){
								cout<<2<<endl;
							}
							else{
								cout<<1<<endl;
							}
						}
					}
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
ll a,b,c;
int main()
{
        cin >> a>>b>>c;
        ll anti = a+b;
        if(c <= anti) {
                cout << b + c << endl;
        }else {
                cout << b + b + a + 1 << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

int main() {
    int n, t; scanf("%d%d", &n, &t);
    ll offset = 0, interval = 0;
    while (n --) {
        int h; scanf("%d", &h);
        chmax<ll>(interval, h);
        ll p = (t - offset) / interval;
        ll q = (t - offset) % interval;
        int result = max<ll>(0, p + (q >= h));
        printf("%d\n", result + 1);
        offset += h;
    }
    return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}


int main(){
	
	int N,i,ans=0,k,count;
	long long int A[100010],j;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	
	qsort(A,N,sizeof(long long int),compare);
	
	
	i=0;
	
	while(i<N){
		count=0;
		j=A[i];
		for(k=i;k<N;k++){
			if(A[k]!=j){
				break;
			}else {count++;
			}
		}
		ans+=count%2;
		i+=count;
	}
	
	printf("\n%d\n\n",ans);
	
	return 0;
}

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

using namespace std;
#define int long long

signed main(){
    int N,K;
    cin >> N >> K;
    
    if(N%2==0){
        if(N/2>=K){
            cout << "YES" << endl;
            return 0;
        }
    }else{
        if(N/2+1>=K){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import math
n,d = map(int,input().split())
#l = list(map(int, input().split()))
x = [0] * n
y = [0] * n

for i in range(n):
    x[i], y[i] = map(int, input().split())
#print(n,d,x,y)

count = 0
for i in range(n):
  #print(math.sqrt(x[i]**2 + y[i]**2))
  if math.sqrt(x[i]**2 + y[i]**2)<=d:
    count += 1
print(count)

Measured memory_bytes: 24812
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5) + 5;
ll n, m;
 
void solve(){
    cin >> n;
    ll l[n];
    for(int i=0; i<n; i++) cin >> l[i];
    // sort(l, l+n);
    ll ans = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            for(int k=j+1; k<n; k++) {
                if((l[i] != l[k]) && (l[k] != l[j]) && (l[j] != l[i])) {
                    ll s = l[i] + l[j] + l[k];
                    m = max(max(l[i], l[j]), l[k]);
                    if(s > 2*m) {
                        // cout << i << j << k << endl;
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans;
}
 
int main(){
    fast;
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
    #endif 
     // tt
        solve();
    return 0;
}

Measured memory_bytes: 3612
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

if __name__ == "__main__":
    N, M = map(int, input().split())
    A = sorted(LI(), reverse=True)
    sum = sum(A)
    if A[M-1] < sum/(4*M):
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3060