akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll INF=1e13;
const int N=1e6+4;
const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int n,m,K;
int sx,sy,tx,ty;
char s[N];
struct Node {
	int dir,x,y;
};
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
inline void smin(ll &x,ll y) {
	x=x>y?y:x;
}
inline ll f(ll x) {
	ll res=x%K;
	return res?x+K-res:x;
}
int main() {
//	freopen("in4.txt","r",stdin);
	n=read(),m=read(),K=read();
	sx=read(),sy=read(),tx=read(),ty=read();
	vector<vector<vector<ll> > > dis(4,vector<vector<ll> >(n+1,vector<ll>(m+1,INF)));
	vector<vector<vector<bool> > > vis(4,vector<vector<bool> >(n+1,vector<bool>(m+1,false)));
	vector<vector<char> > mp(n+1,vector<char>(m+1,'\0'));
	for (int i=1;i<=n;++i) {
		scanf("%s",s+1);
		for (int j=1;j<=m;++j) mp[i][j]=s[j];
	}
	//SPFA
	queue<Node> q;
	for (int dir=0;dir<4;++dir) {
		dis[dir][sx][sy]=0;
		vis[dir][sx][sy]=true;
		q.push((Node){dir,sx,sy});
	}
	while (!q.empty()) {
		Node cur=q.front();
		q.pop();
		int cdir=cur.dir,cx=cur.x,cy=cur.y;
		vis[cdir][cx][cy]=false;
		int nx=cx+dx[cdir],ny=cy+dy[cdir];
		if (nx&&nx<=n&&ny&&ny<=m&&mp[nx][ny]=='.') {
		//when this is false, mp[][] might explode if nx==n+1 or ny==m+1
			if (dis[cdir][nx][ny]>dis[cdir][cx][cy]+1) {
				dis[cdir][nx][ny]=dis[cdir][cx][cy]+1;
				if (!vis[cdir][nx][ny]) {
					vis[cdir][nx][ny]=true;
					q.push((Node){cdir,nx,ny});
				}
			}
		}
		for (int dir=0;dir<4;++dir) {
			if (dis[dir][cx][cy]>f(dis[cdir][cx][cy])) {
				dis[dir][cx][cy]=f(dis[cdir][cx][cy]);
				if (!vis[dir][cx][cy]) {
					vis[dir][cx][cy]=true;
					q.push((Node){dir,cx,cy});
				}
			}
		}
	}/*
	for (int dir=0;dir<4;++dir) {
		for (int i=1;i<=n;++i) {
			for (int j=1;j<=m;++j)
				printf("%lld ",dis[dir][i][j]);
			puts("");
		}
		puts("");
	}*/
	ll ans=INF;
	for (int dir=0;dir<4;++dir) {
		dis[dir][tx][ty]=f(dis[dir][tx][ty]);
		smin(ans,dis[dir][tx][ty]);
	}
	printf("%d\n",ans<INF?ans/K:-1);
	return 0;
}

Measured memory_bytes: 89124
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
 
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n+1),bs(n);
  for(Int i=0;i<=n;i++) cin>>as[i];
  for(Int i=0;i<n;i++) cin>>bs[i];
 
  Int ans=0;
  for(Int i=0;i<n;i++){
    {
      Int num=min(as[i],bs[i]);
      bs[i]-=num;
      ans+=num;
    }
    {
      Int num=min(as[i+1],bs[i]);
      as[i+1]-=num;
      ans+=num;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio> //{{{
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>

#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) std::cerr << #x << ':' << (x) << '\n';

typedef long long ll;

inline int in(){int x;scanf("%d",&x);return x;}
template<typename T, typename U>inline bool chmax(T&x,U a){if(x>=a)return 0;x=a;return 1;}
template<typename T, typename U>inline bool chmin(T&x,U a){if(x<=a)return 0;x=a;return 1;}
//}}}

using namespace std;

#include <cmath>

double X[550];
int R[550];

inline double sq(double x){ return x * x; }

int main()
{
  int N = in();
  for (int i = 0; i < N; i++) R[i] = in();
  for (int i = 0; i < N; i++) {
    X[i] = R[i];
    for (int j = 0; j < i; j++){
      if (R[i] == R[j]) {
        chmax(X[i], X[j] + R[i] + R[j]);
      }
      else {
        chmax(X[i], X[j] + sqrt(sq(R[i] + R[j]) - sq(R[i] - R[j])));
      }
    }
  }
  double maxi = 0;
  for (int i = 0; i < N; i++) chmax(maxi, X[i] + R[i]);
  printf("%.10lf\n", maxi);

  return 0;
}

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

using namespace std;

int main(){
  vector<int> a(3);
  for(int i = 0; i < 3; i++)cin >> a[i];
  sort(a.begin(), a.end());  
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3140
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int main() {
  int arr[100];
  int _sum = 0;
  cin >> N >> M;
  rep(i, N){
    cin >> arr[i];
    _sum += arr[i];
  }
  int count = 0;
  rep(i, N){
    if(_sum % (4 * M) == 0 && arr[i] >= _sum / (4*M)){
      count++;
    }
    else if(_sum % (4 * M) != 0 && arr[i] > _sum / (4 * M)) count++;
  }
  if(M <= count) cout << "Yes";
  else cout << "No";
} 



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

int n, m;
priority_queue<int> a;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push(t);
	}
	for (int i = 0; i < m; i++) {
		int t = a.top(); a.pop();
		a.push(t / 2);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a.top(); a.pop();
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 892
//A - Station and Bus

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;

    cin >> s;

    bool flag = false;

    string sr = s;
    reverse(sr.begin(), sr.end());
    
    int len  = s.length();

    if (s == sr) {
        string s1 = s.substr(0, (s.length()-1)/2);
        string s1r = s1;
        reverse(s1r.begin(), s1r.end());
        if (s1 == s1r) {
            string s2 = s.substr(((s.length()+3)/2) -1, s.length());
            string s2r = s2;
            reverse(s2r.begin(), s2r.end());
            if (s2 == s2r) {
                flag = true;
            }

        }
    }

    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

constexpr i64 mod = 1000000007;

i64 f(const i64 n, const i64 a) {
    i64 t = 1;
    for (int i = 0; i < a; i++) t = t * (n - i) % mod;
    for (int i = 1; i <= a; i++) t = t * inverse(i, mod) % mod;
    return t;
}

int main() {
    int n, a, b;
    std::cin >> n >> a >> b;

    i64 ret = (pow(2, n, mod) - 1 + 2 * mod - f(n, a) - f(n, b)) % mod;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if( N%1000%111 == 0 || N%1000 == 0 ){
    cout << "Yes" << endl;
  }
  else if( N%1110 < 10 || N%2220 < 10 || N%3330 < 10 || N%4440 < 10 || N%5550 < 10 || N%6660 < 10 || N%7770 < 10 || N%8880 < 10 || N%9990 < 10 || N < 10){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

int A, B, H, M;

long double PI = 3.14159265358979;

int main(void) {

	cin >> A >> B >> H >> M;

	M = M;

	long double h = H + 1.0L*(M % 60) / 60.0L;

	long double x1, x2, y1, y2;

	x1 = 1.0L*A*cos(1.0L*h*30.0L*PI/180.0L);
	y1 = 1.0L*A*sin(1.0L*h*30.0L*PI/180.0L);

	x2 = 1.0L*B*cos(1.0L*M*6.0L*PI/180.0L);
	y2 = 1.0L*B*sin(1.0L*M*6.0L*PI/180.0L);

	long double ans;
	ans = sqrt(pow(x1 - x2, 2.0L) + pow(y1 - y2, 2.0L));

	cout <<setprecision(15)<<fixed<< ans << endl;

	//cout << 1.0L*H*30.0L << endl;
	//cout << 1.0L*M*6.0L << endl;

	return 0;
}

Measured memory_bytes: 4152
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

const ll MOD = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

const int NMAX = int(2e5 + 5);

struct Comb {
    vector<ll> fact, finv, inv;

    Comb(int nmax): fact(nmax + 1), finv(nmax + 1), inv(nmax + 1) {
        REP(i, 2) {
            fact[i] = 1;
            finv[i] = 1;
            inv[i] = 1;
        }

        FOR(i, 2, nmax + 1) {
            fact[i] = fact[i-1] * i % MOD;
            inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }

    mint operator()(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;

        return mint(fact[n]) * finv[k] * finv[n-k];
    }

    mint perm(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;

        return mint(fact[n]) * finv[n-k];
    }

} comb(NMAX);

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll n, k;
    cin >> n >> k;

    FOR(i, 1, k + 1) print(comb(k - 1, i - 1) * comb(n - k + 1, i));
    
}


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

const int N = 100;
char ans[N][N+1];

int main()
{
	int A, B; scanf("%d%d", &A, &B);
	for(int i=0; i<N/2; ++i)
		for(int j=0; j<N; ++j)
			ans[i][j] = '#';
	for(int i=N/2; i<N; ++i)
		for(int j=0; j<N; ++j)
			ans[i][j] = '.';
	--A; --B;
	for(int i=1; A; i+=2) for(int j=2; j<N && A; j+=2)
	{
		ans[i][j] = '.'; --A;
	}
	for(int i=N/2+1; B; i+=2) for(int j=2; j<N && B; j+=2)
	{
		ans[i][j] = '#'; --B;
	}
	printf("%d %d\n", N, N);
	for(int i=0; i<N; ++i) puts(ans[i]);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a, b, c;
    cin >>  a >> b >> c;
    vector<int>fvf = {5,7,5};
    vector<int>abc = {a,b,c};
    sort(all(fvf));
    sort(all(abc));
    if (fvf == abc)cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	char S[64];
	char D[64];
	int A,B=0;
	scanf("%s",D);
	for(A=0;D[A];A++)
		if('A'<=D[A]&&D[A]<='Z')
			D[A]+='a'-'A';
	while(1){
		scanf("%s",S);
		if(!strcmp(S,"END_OF_TEXT"))
			break;
		for(A=0;S[A];A++)
			if('A'<=S[A]&&S[A]<='Z')
				S[A]+='a'-'A';
		if(!strcmp(S,D))
			B++;
	}
	printf("%d\n",B);
	return 0;
}

Measured memory_bytes: 548
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(const int N) : cusum(N + 1) {}
	void add(const int i, const T &x) { cusum[i + 1] += x; }
	void build() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r)
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	const T &operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

template<class T>
inline bool chmax(T &a, const T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> V(N);
	for (int i = 0; i < N; i++) cin >> V[i];

	int ans = 0;
	CuSum<int> CuV(V);
	for (int i = 0; i <= min(N, K); i++) {

		for (int j = 0; j <= i; j++) {

			int sum = CuV(0, j) + CuV(N - (i - j), N);

			vector<int> minus;
			minus.reserve(i);
			for (int k = 0; k < j; k++) if (V[k] < 0) minus.emplace_back(V[k]);
			for (int k = N - (i - j); k < N; k++) if (V[k] < 0) minus.emplace_back(V[k]);

			sort(minus.begin(), minus.end());
			sum -= accumulate(minus.begin(), minus.begin() + min(K - i, (int)minus.size()), 0);

			chmax(ans, sum);
		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/22.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

/*#include <bits/stdc++.h>
using namespace std;

struct fk{
    int a, b;   // )))))) a + ((((((( b
};

bool cmp1(fk a, fk b){
    return a.a<b.a || (a.a==b.a && a.b>b.b);
}
bool cmp2(fk a, fk b){
    return a.b>b.b || (a.b==b.b && a.a<b.a);
}

int main(int argc, const char * argv[]) {
    int n; cin>>n;
    vector<fk> pos, neg; //in terms of a-b
    
    string s;
    for(int i=0; i<n; i++){
        cin>>s;
        int Mi=0, Ma=0, cnt;
        cnt=0;
        for(int j=0; j<s.length(); j++){
            if(s[j] == '(') cnt++;
            else cnt--;
            Mi=min(Mi, cnt);
        } Mi = 0 - Mi;
        cnt=0;
        for(int j=s.length()-1; j>=0; j--){
            if(s[j] == '(') cnt++;
            else cnt--;
            Ma=max(Ma, cnt);
        }
        if(Ma>=Mi) pos.push_back((fk){Mi, Ma});
        else       neg.push_back((fk){Mi, Ma});
        //cout<<Mi<<" "<<Ma<<endl;
    }
    sort(pos.begin(), pos.end(), cmp1);
    sort(neg.begin(), neg.end(), cmp2);
    int st=0;
    for(auto f: pos){
        st -= f.a;
        if(st<0){ cout<<"No\n"; return 0;}
        st += f.b;
    }
    for(auto f:neg){
        st -= f.a;
        if(st<0){ cout<<"No\n"; return 0;}
        st += f.b;
    }
    if(st!=0){ cout<<"No\n"; return 0;}
    cout<<"Yes\n";

    return 0;
}
*/

#include<bits/stdc++.h>
using namespace std;
int n,ac,bc;
const int N = 1e6+5;
struct str{int m;string st;}a[N],b[N];
bool cmp(const str&a,const str&b){return a.m>b.m;}
string last="";
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        string s; cin>>s;
        int sum=0,mx=-1e9,mn=1e9;
        for(int j=0;j<s.size();j++){
            if(s[j]=='(') sum++;
            else sum--;
            mn=min(mn,sum);
        } sum=0;
        for(int j=s.size()-1;j>=0;j--){
            if(s[j]=='(') sum++;
            else sum--;
            mx=max(mx,sum);
        }
        if(sum>=0) a[++ac]=(str){mn,s};
        else b[++bc]=(str){mx,s};
    }
    sort(a+1,a+ac+1,cmp), sort(b+1,b+bc+1,cmp);
    for(int i=1;i<=ac;i++) last+=a[i].st;
    for(int i=1;i<=bc;i++) last+=b[i].st;
    int sum=0;
    for(int i=0;i<last.size();i++){
        if(last[i]=='(') sum++;
        else sum--;
        if(sum<0) return puts("No"),0;
    }
    if(sum==0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 83904
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct node {
	int key;
	node* left, * right, * parent;
};

node* nil, * root;

void insert(int k) {
	node* y = nil;
	node* x = root;
	node* z;

	z = (node*)malloc(sizeof(node));
	z->key = k;
	z->left = nil;
	z->right = nil;

	while (x != nil) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;

	if (y == nil) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

node* find(node *root,int k) {
	while (root != nil && k != root->key) {
		if (k < root->key) {
			root = root->left;
		}
		else if (k > root->key) {
			root = root->right;
		}
	}
	return root;
}

void inorder(node* root) {
	if (root == nil) return;
	if (root->left != nil) inorder(root->left);
	cout << " " << root->key;
	if (root->right != nil) inorder(root->right);
}

void preorder(node* root) {
	if (root == nil) return;
	cout << " " << root->key;
	if (root->left != nil) preorder(root->left);
	if (root->right != nil) preorder(root->right);
}

int main()
{
	int key, m;
	char com[20];
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		cin >> com;
		if (com[0] == 'i') {
			cin >> key;
			insert(key);
		}
		else if (com[0] == 'p') {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (com[0] == 'f') {
			cin >> key;
			node* ans = find(root, key);
			if (ans) cout << "yes\n";
			else cout << "no\n";
		}
	}

	return 0;
}


Measured memory_bytes: 21976
n,k=map(int, input().split())
a=list(map(int, input().split()))
from itertools import accumulate
for _ in range(min(50,k)):
    new=[0]*n
    for i in range(n):
        j=a[i]
        l=max(0,i-j)
        r=min(n-1,i+j)
        new[l]+=1
        if r+1<n:
            new[r+1]-=1
    new=list(accumulate(new))
    a=new
print(*a)


Measured memory_bytes: 214836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    ll  ans;
    if(K%2==0){
        ll O =K/2;
        ll L1 = N/K;
        ll L2 = N/O - L1;
        
        ans = L1*L1*L1+L2*L2*L2;
    }else{
        ll L = N/K;
        ans = L*L*L;
    }

    

    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3620
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

S = input()
N = len(S)

# dp[i][k]: i桁目までのkで割った余りの数
dp = create_grid(N+1, 13)

dp[0][0] = 1 # 0桁目

s = [1]
for i in range(N):
  s.append((s[-1]*10)%13)

for i in range(N):
    c = S[N-i-1]
    if c == "?":
        v = range(10)
    else:
        v = [int(c)]
    for vi in v:
        for j in range(13):
            amari = (vi*s[i] + j) % 13
            dp[i+1][amari] = (dp[i][j] + dp[i+1][amari]) % MOD

print(dp[N][5])



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

int W,H,N;
int X1[111],X2[111],Y1[111],Y2[111];
int fie[1001][1001];

bool used[11];
int res[11];
int cnt;

void view(){
  cout << "view() " << endl;
  for(int i=0;i<2*H;i++){
    for(int j=0;j<2*W;j++)
      printf("%2d",fie[j][i]);
    cout << endl;
  }
}

void solve(int l,int r,int up,int dow){
  // view();
  for(int x=l;x<r;x++){
    for(int y=up;y<dow;y++){
      int id = fie[2*x+1][2*y+1];
      if(id == -1 ) continue;
      if( !used[id]  ){
	used[id] = true;
	res[id] = cnt++;
	
	for(int nx=2*X1[id]+1;nx<=2*W;nx++){
	  int ny = 2*Y2[id];
	  if( fie[nx][ny] != -1 || nx == 2*W ){
	    solve(X1[id],nx/2,0,Y2[id]);
	    break;
	  }
	} 

      }
    }
  }
}

int zatu(int *x1, int *x2){
  vector<int> xs;
  for(int i=0;i<N;i++){
    xs.push_back( x1[i] );
    xs.push_back( x2[i] );    
  }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  for(int i=0;i<N;i++){
    x1[i] = find(xs.begin(),xs.end(),x1[i]) - xs.begin();
    x2[i] = find(xs.begin(),xs.end(),x2[i]) - xs.begin();
  }
  return xs.size();
}

int main(){
  int ttt=0;
  while( cin >> N && N ){
    W=H=0;
    memset(used,0,sizeof(used));
    memset(res,-1,sizeof(res));
    cnt = 1;
    for(int i=0;i<N;i++) {
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
      if( X1[i] > X2[i] ) swap(X1[i],X2[i]);
      if( Y1[i] > Y2[i] ) swap(Y1[i],Y2[i]);
      W = max(X2[i],W);
      H = min(Y2[i],H);
    }
    W=zatu(X1,X2);
    H=zatu(Y1,Y2);
    fill(fie[0],fie[2*W],-1);
    for(int i=0;i<N;i++){
      for(int x=X1[i];x<X2[i];x++){
	for(int y=Y1[i];y<Y2[i];y++){
	  fie[2*x+1][2*y+1] = i;
	}
      }
      for(int y=2*Y1[i]+1;y<2*Y2[i];y++){
	fie[2*X1[i]][y] = i;
	fie[2*X2[i]][y] = i;
      }
    }
    solve(0,W,0,H);
    if( ttt++ ) cout << endl;
    for(int i=0;i<N;i++) cout << res[i] << endl;

  }  
}

Measured memory_bytes: 1368
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int a,b;
	while(cin>>a>>b,a||b){
		double ans = INFL;
		rep(i,a+1){
			int j = a-i;
			mins(ans, abs(sqrt(i*i+j*j)-b)*1.);
		}
		cout<<ans<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int INF = 1e9+5;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> dp(3);
    for(int i=0;i<n;++i){
        vector<int> c(3);
        vector<int> newdp(3,0);
        for(int j=0;j<3;++j)
            scanf("%d",&c[j]);
        for(int j=0;j<3;++j){
            for(int l=0;l<3;++l){
                if(j!=l){
                    newdp[l]=max(newdp[l],dp[j]+c[l]);
                }
            }
                
        }   
        dp=newdp;
    }
    printf("%d",max({dp[0],dp[1],dp[2]}));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp(x,y)     make_pair(x,y) 
#define exit(x)     cout<<x<<"\n",return
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)
const ll N=500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
  ll T=1;
  //cin>>T;
  while(T--)
  {
 // string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>m;
 if(m%n==0)
 {
  cout<<n+m;
 }
else c(m-n);

 }
}

signed main(){

        ios_base::sync_with_stdio(false);   
        cin.tie(NULL);
       solve();
    return 0;
    }


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

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;

int main() {
	ll N, X; cin >> N >> X;
	ll m[100];
	ll minV = 1 << 21;
	rep(i, 0, N) {
		ll tm; cin >> tm;
		m[i] = tm;
		X -= tm;
		if (minV > tm) {
			minV = tm;
		}
	}

	cout << X / minV + N << endl;

	return 0;
}

Measured memory_bytes: 256
#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> v(n);
  rep(i,n)cin>>v.at(i);
  int c,ans=0;
  rep(i,n){
    cin>>c;
    v.at(i)-=c;
    if(v.at(i)>0)ans+=v.at(i);
  }
  cout<<ans;
}

Measured memory_bytes: 256
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

int main() {
  int n, k;
  cin  >> n >> k;
  if (k == 1) {
    cout << 0 << "\n";
  } else {
    cout << n-k << "\n";
  }
}


Measured memory_bytes: 256
// Squid Ink
// ??????????????????C++11????????????????????¨?????????????????¨??????

#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

typedef struct{
	int to, cost;
} Edge;

typedef std::pair<int, int> P;	//<cost, pos>

const int kMaxSize	= 32;
const int kMaxField = kMaxSize*kMaxSize;
const int kCostFriendlyInk = 1;
const int kCostShot = 2;
const int kCostBlank = 2;
const int kShotRange = 3;

const char kWall = '#';
const char kFriend = 'o';
const char kEnemy = 'x';
const char kStart = 'S';
const char kGoal = 'G';
const char kBlank = '.';

char field[kMaxField];
int way[4] = { -1, 1, -kMaxSize, kMaxSize };

const int kInf = 1 << 16;
int d[kMaxField];
std::vector<Edge> cost[kMaxField];
int R, C;

inline int xy2pos(const int x, const int y){
	return x + y*kMaxSize;
}

void initCost(){
	for (int y = 1; y <= R; y++){
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			if (field[pos] == kWall) continue;
			for (int i = 0; i < 4; i++){
				for (int j = 1; j <= kShotRange; j++){
					int newpos = pos + j*way[i];
					if (field[newpos] == kWall) break; //?£?????????????????????????
					if (j == 1){
						if (field[newpos] == kFriend) cost[pos].push_back({ newpos, kCostFriendlyInk });
						else if (field[newpos] == kEnemy) cost[pos].push_back({ newpos, kCostShot + kCostFriendlyInk });
						else cost[pos].push_back({ newpos, kCostBlank });
					}else{
						cost[pos].push_back({ newpos, kCostShot + kCostFriendlyInk * j});
					}
				}
			}
		}
	}
}

void dijkstra(int spos){
	std::priority_queue<P, std::vector<P>, std::greater<P>> q;
	std::fill(d, d + kMaxField, kInf);
	d[spos] = 0;
	q.push({ 0, spos });

	while (!q.empty()){
		P p = q.top(); q.pop();
		if (d[p.second] < p.first) continue;
		for (unsigned int i = 0; i < cost[p.second].size(); i++){
			Edge e = cost[p.second][i];
			if (d[e.to] > d[p.second] + e.cost){
				d[e.to] = d[p.second] + e.cost;
				q.push({ d[e.to], e.to });
			}
		}
	}
}

int main(){
	int start, goal;

	std::fill(field, field + kMaxField, '#');

	std::scanf("%d %d", &R, &C);
	for (int y = 1; y <= R; y++)
		for (int x = 1; x <= C; x++){
			int pos = xy2pos(x, y);
			std::scanf(" %c", &field[pos]);
			if (field[pos] == kStart) start = pos;
			else if (field[pos] == kGoal) goal = pos;
		}
	initCost();
	dijkstra(start);
	printf("%d\n", d[goal]);
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

const int MAX = 310000;

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

void combinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; ++i){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD-inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}


ll com(int n, int k){
    if(n < k) return 0;
    if(n < 0 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    ll n, m, k;
    cin >> n >> m >> k;
    combinit();

    ll res = 0LL;
    for(ll i = 1; i <= n-1; ++i){
        res += i*(n-i)%MOD*m%MOD*m%MOD;
        res %= MOD;
    }
    for(ll i = 1; i <= m-1; ++i){
        res += i*(m-i)%MOD*n%MOD*n%MOD;
        res %= MOD;
    }

    res *= com(n*m-2, k-2);
    res %= MOD;

    ppp(res);



    return 0;
}


Measured memory_bytes: 7552
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> w(n), v(n);
  rep(i,n) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(n+1,vector<ll>(m+1));
  for(int i=1; i<=n; i++){
    for(int j=1; j<=m; j++){
      if(j-w[i-1]>=0)
        chmax(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
      chmax(dp[i][j], dp[i-1][j]);
    }
  }
  cout << dp[n][m] << endl;
  return 0;
}

Measured memory_bytes: 80256
#include<stdio.h>
int main(void)
{
    int x,y,r,h,w,a,b;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	a=x+r;
	b=y+r;
	if(w>=a && h>=b && y>=0 && x>=0){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	int magic[3][3];
	cin >> magic[0][0] >> magic[0][1] >> magic[1][1];
	magic[2][1] = 2 * magic[1][1] - magic[0][1];
	magic[2][2] = 2 * magic[1][1] - magic[0][0];
	magic[1][0] = 2 * magic[2][2] - magic[0][1];
	magic[0][2] = (magic[1][0] + magic[2][1]) / 2;
	magic[2][0] = 2 * magic[1][1] - magic[0][2];
	magic[1][2] = 2 * magic[1][1] - magic[1][0];
	cout << magic[0][0] << " " << magic[0][1] << " " << magic[0][2] << endl;
	cout << magic[1][0] << " " << magic[1][1] << " " << magic[1][2] << endl;
	cout << magic[2][0] << " " << magic[2][1] << " " << magic[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    string s; cin>>s;
    long long k; cin>>k;
    char ans='1';
    rep(i,k){
        if(s[i]!='1'){
            ans=s[i]; break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

class Main {

	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			Map<String, List<Integer>> map = new LinkedHashMap<String, List<Integer>>();
			List<Integer> list = new ArrayList<Integer>();
			map.put("S", new ArrayList<Integer>());
			map.put("H", new ArrayList<Integer>());
			map.put("C", new ArrayList<Integer>());
			map.put("D", new ArrayList<Integer>());
			String input = br.readLine();
			int sheet = Integer.parseInt(input);
			int i;
			for (i = 0; i < sheet; i++) {
				String[] inputList = br.readLine().split(" ");
				list = map.get(inputList[0]);
				list.add(Integer.parseInt(inputList[1]));
				map.put(inputList[0], list);
			}

			for (Map.Entry<String, List<Integer>> e : map.entrySet()) {
				list = e.getValue();
				for (i = 1; i <= 13; i++) {
					if (!list.contains(i)) {
						System.out.println(e.getKey() + " " + i);
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17088
#include <stdio.h>
#include <math.h>

int cmpnum(const void * n1, const void * n2)
{
	if (*(int *)n1 > *(int *)n2)
	{
		return 1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(){
  int N;
  scanf("%d", &N);
  int A[N];
  int i;
  for (i = 0; i < N; i++) {
    A[i] = 0;
    scanf("%d", &A[i]);
  }
  qsort(A, sizeof(A) / sizeof(A[0]), sizeof(int), cmpnum);
  for (int i = 0; i < N; i++) {
    if (A[i] == A[i + 1]){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


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

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> t(n),f(n);
  for(Int i=0;i<n;i++) cin>>t[i]>>f[i],f[i]--;

  auto NG=[](){cout<<-1<<endl;exit(0);};
  Int ans=0,tmp=0,lst=0,num=0;
  for(Int i=0;i<n;i++){
    if(abs(tmp-f[i])>(t[i]-lst)) NG();
    if(tmp+f[i]<=(t[i]-lst)){
      ans+=tmp*num;
      num=1;
    }else{
      if(num==d) NG();
      ans+=abs(t[i]-lst)*num;
      num++;      
    }
    lst=t[i];
    tmp=f[i];
  }
  // cout<<ans<<" "<<tmp<<" "<<num<<endl;
  ans+=tmp*num;
  cout<<ans<<endl;
  return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> test;
  for(int i = 1; i <= n; i++) test.push_back(i);
  int cnt = 0;
  int a, b;
  do{
    cnt++;
    if(test == p) a = cnt;
    if(test == q) b = cnt;
  }while(next_permutation(test.begin(), test.end()));
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

signed main() {
    INIT;
    cin >> A >> B;
    if (A == 1)
        A = 14;
    if (B == 1)
        B = 14;
    if (A > B)
        cout << "Alice" << endl;
    else if (A < B)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll i,j,n,t=1,k=0,cnt=0,mini=LLONG_MAX,maxi=LLONG_MIN,ans=0;
    ll m;
    cin>>n;
    cnt=0;
    k=n;
    while(n>=1)
    {
        ll d=n%10;
        cnt+=d;
        n/=10;
    }
    if(k%cnt==0) ret("Yes")
    ret("No")
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    string s;
    cin >> s;
    cout << s.substr(0, 3) << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

#define NMAX 101

int main (void)
{
  int i,j,n,k[NMAX],u[NMAX],v[NMAX][NMAX],a[NMAX][NMAX];

  scanf ("%d",&n);
  for (i = 1 ; i < n+1 ; i++){
    scanf ("%d %d",&u[i],&k[i]);
    for (j = 1 ; j < k[i]+1 ; j++)
      scanf ("%d",&v[i][j]);
  }

  //make adjacency matrices
  for (i = 1 ; i < n+1 ; i++){
    for (j = 1 ; j < n+1 ; j++)
      a[i][j] = 0;
    for (j = 1 ; j < k[i]+1 ; j++)
      a[i][v[i][j]] = 1;
  }

  for (i = 1 ; i < n+1 ; i++){
    for (j = 1 ; j < n+1 ; j++){
      printf ("%d",a[i][j]);
      if (j < n) printf (" ");
    }
    printf ("\n");
  }

  return 0;
}

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

int main(){
  int n; cin>>n;
  vector<vector<int>> num(n,vector<int>(2));
  for(int i=0;i<n;i++){
    cin>>num[i][0];
  }
  for(int i=0;i<n;i++){
    cin>>num[i][1];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int now=0,y=0;
    for(int j=0;j<n;j++){
      now+=num[j][y];
      if(j==i){
        now+=num[j][1];
        y++;
      }
    }
    ans=max(ans,now);
  }
  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

int main(){
    int N;
    ll T, A;
    cin >> N >> T;
    vector<ll> sell(N);
    sell[0] = 0;

    cin >> A;

    ll A_min, max_sell;
    max_sell = 0ll;
    A_min = A;
    for(int i=1;i<N;i++){
        cin >> A;
        A_min = min(A_min, A);
        max_sell = max(max_sell, A-A_min);
        sell[i] = A - A_min;
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        if(sell[i] == max_sell) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import collections

n,k=map(int,input().split())
a=list(map(int,input().split()))
a=collections.Counter(a)
A=a.most_common()[::-1]
x=len(A)-k

if x<=0:
  print("0")
else:
  ans=0
  for i in range(x):
    ans+=A[i][1]
  print(ans)


Measured memory_bytes: 37780
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define ctoi(x) (x - '0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, ans;
vi v(200010);
unordered_map<int, int> M;

int main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> v[i + 1];
		M[v[i + 1]]++;
	}
	for (int i = 1; i <= n; i++) {
		int flag = 1;
		for (ll j = 1; j * j <= v[i]; j++) {
			if (v[i] % j == 0) {
				//v[i]/j, j
				if (j == v[i] && M[j] >= 2 || j != v[i] && M[j] >= 1 || v[i]/j == v[i] && M[v[i]/j] >= 2 || v[i]/j != v[i] && M[v[i]/j] >= 1) {
					flag = 0;
					break;
				}
			}
		}
		if (flag) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 32424