akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
  val n = scala.io.StdIn.readInt()
  val readV =  scala.io.StdIn.readLine()
  val vArray = readV.split(" ").map(_.toDouble).toVector.sorted
  var result = 0d
  var before = 0d

  vArray.zipWithIndex.foreach(v =>
    if(v._2 == 0) {
      result = v._1
    } else {
      result = (result + v._1) / 2d
    }
  )
  println(result)
}

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

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

  const int MAXP = 310000;
  vector<bool> prime(MAXP, true);
  for(int i=1;i*7+1<MAXP;++i){
	for(int j=-1;j<=1;j+=2){
	  int a = 7*i + j;
	  if(prime[a]){
		for(int k=1;a*(k*7+1)<MAXP;++k){
		  for(int d=-1;d<=1;d+=2){
			int b = 7*k + d;
			prime[a*b] = false;
		  }
		}
	  }
	}
  }
  while(true){
	int N; cin >> N; if(N == 1) break;
	cout << N << ":";
	for(int i=1;i*7-1<=N;++i){
	  for(int d=-1;d<=1;d+=2){
		int k = 7*i + d;
		if(prime[k] && N % k == 0){
		  cout << " " << k;
		}
	  }
	}
	//	if(N > 1)
	//  cout << " " << N;
	cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1240
N, M = gets.split.map(&:to_i)

grid = Array.new(N) {Array.new}
M.times do
	n1, n2 = gets.split.map(&:to_i)
	grid[n1-1] << n2-1
	grid[n2-1] << n1-1
end

ans = 0

[*(2..N)].permutation.to_a.map {|a| a.unshift(1)}.each do |pattern|
	flag = true
	
	(N-1).times do |i|
		if !grid[pattern[i]-1].include?(pattern[i+1]-1)
			flag = false
			break
		end
	end
	
	ans += 1 if flag == true
end

puts ans


Measured memory_bytes: 3196
if __name__ == '__main__':
    a1 = [int(i) for i in input().split()]
    a2 = [int(i) for i in input().split()]
    a3 = [int(i) for i in input().split()]
    n = int(input())

    b = [int(input()) for i in range(n)]

    result = "No"

    if all([i in b for i in a1]):
        result = "Yes"
    if all([i in b for i in a2]):
        result = "Yes"
    if all([i in b for i in a3]):
        result = "Yes"
    
    for i in range(3):
        if all([i in b for i in [a1[i], a2[i], a3[i]]]):
            result = "Yes"
    
    if all([i in b for i in [a1[0], a2[1], a3[2]]]):
        result = "Yes"
        
    if all([i in b for i in [a1[2], a2[1], a3[0]]]):
        result = "Yes"
    
    print(result)

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  FOR(j, 1, 10) FOR(i, 1, 10){
    printf("%dx%d=%d\n", j, i, j * i);
  }
}

Measured memory_bytes: 2988
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
#include<math.h>
#include<queue>
using namespace std;
#define MAX 300000
#define INF 3000
typedef long long ll;
typedef pair<int,int> P;




int main(){
  ll ans=0;
  ll x,y;
  cin>>x>>y;
  while(x<=y){
    ans++;
    x*=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
 Remember not to use arithmetic operation in double while comparision 

 priority of uses
 array > maps > unordered_maps
*/

#include<bits/stdc++.h>
#define lli long long int
#define vl vector<lli>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define pll pair<lli,lli>
lli inf = 1e9L+7;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

	lli n,w;
	cin>>n>>w;
	vl val(n),wt(n);
	lli sval=0;
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
		sval+=val[i];
	}	
	// lli DP[n+1][sval+1];
	lli DP[n+1][sval+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=sval;j++)
			DP[i][j]=inf;
	}
	for(int i=0;i<=n;i++)
		DP[i][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(lli j=1;j<=sval;j++)
		{
			if(val[i-1]>j)
				DP[i][j]=DP[i-1][j];
			else
				DP[i][j]=min(DP[i-1][j],wt[i-1]+DP[i-1][j-val[i-1]]);
		}
	}
	lli ans=LLONG_MIN;
	for(int i=0;i<=sval;i++)
	{
		if(DP[n][i]<=w)
			ans=i;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 79232
def counting_sort(A, n, k):
    C = [0 for _ in range(k)]
    B = [None] * n
    for j in range(n):
        C[A[j]] += 1

    for i in range(1, k):
        C[i] = C[i] + C[i - 1]

    for a in A[::-1]:
        B[C[a] - 1] = a
        C[a] -= 1

    return B


k = 10 ** 4 + 1
n = int(input())
A = list(map(int, input().split()))
B = counting_sort(A, n, k)
print(*B[:n])



Measured memory_bytes: 224544
n, m = map(int, input().split())

c = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    c[a].append(b)


def d(s, cnt):
    if s == n and cnt <= 2:
        print('POSSIBLE')
        exit()
    else:
        for i in c[s]:
            d(i, cnt + 1)


d(1, 0)
print('IMPOSSIBLE')


Measured memory_bytes: 29068
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

/*  <<bit全探索>>
 
    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/
 
/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 
typedef long long ll;

///////////////////////////////////////////////////////////////////////////


int main() {

    string S, T;
    cin >> S >> T;

    int s, t;
    s = S.size();
    t = T.size();
    
    int X = 0;

    if(s + 1 == t){
         rep(i,s){
             if(S.at(i) != T.at(i)){
                 X++;
             }
         }
    }

    else{
        X++;
    }

    if(X == 0){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}


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

bool f_sort(pair<int,int> a,pair<int,int> b){return a.first<b.first;};
bool s_sort(pair<int,int> a,pair<int,int> b){return a.second<b.second;};
int main(){
	int n; cin>>n;
	int cnt=0;
	pair<int,int> red[n],blue[n];
	for(int i=0;i<n;i++) cin>>red[i].first>>red[i].second;
	for(int i=0;i<n;i++) cin>>blue[i].first>>blue[i].second;
	sort(red,red+n,s_sort);
	sort(blue,blue+n,f_sort);	for(int i=0;i<n;i++){
		for(int j=n-1;j>=0;j--){
			if(red[j].first<blue[i].first && red[j].second<blue[i].second && red[j].first!=-1){
				cnt++;
				red[j].first=-1;
				break;
			}
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include <stack>
using namespace std;
#define ll long long
int main()
{
	//int t;
	//cin>>t;
	//for(int i=0;i<t;i++)
	//{
	ll n,l=1000010,sum=0;
	cin>>n;
	vector<ll> a(n);
	vector<ll> cnt(l);
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum=sum+a[i];
		cnt[a[i]]++;
	}
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++){
		ll b,c;
		cin>>b>>c;
		sum=sum+(c-b)*cnt[b];
		cout<<sum<<endl;
		cnt[c]+=cnt[b];
		cnt[b]=0;
	} 
	return 0;

}
	
	
	
	

		



Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	rep(i,n-1) a.at(i+1)+=a.at(i);
	ll ans=100000000000000000;
	rep(i,n-1) ans=min(ans,abs(a.at(i)-(a.at(n-1)-a.at(i))));
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h> 
int gcd(int a, int b) { 
if (a < b) 
{ 
int tmp = a; 
a = b; 
b = tmp; 
} 
int r = a % b;
 while (r != 0) 
{ 
a = b;
 b = r; 
r = a % b; 
} 
return b; 
} 
int main(void)
{ 
int a, b; 
while(scanf("%d %d\n", &a, &b) != EOF) 
{ 
printf("%d %d\n", gcd(a, b), a / gcd(a, b) * b); 
}
 return 0; 
} 


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
ll D = 365;
ll T = 26;//タイプ数
ll c[27];
ll s[366][27];

vvll last(D + 1,vll(T+1,0));

ll score(vll t) {

	repn(i, D) {
		repn(j, T) {
			if (t[i] == j) { last[i][j] = i; }
			else { last[i][j] = last[i - 1][j]; }

			cout << i << " " << j << last[i][j] << endl;
		}
	}

	ll ret = 0;
	repn(i, D) {
		ret += s[i][t[i]];
		repn(j, T) {
			ret -= c[j] * (i - last[i][j]);
		}
	}

	return ret;
	
}


int main() {
	cin >> D;
	repn(i, T) cin >> c[i];
	repn(i, D)repn(j, T) cin >> s[i][j];

	vll ans(D + 1);
	
	repn(i, D) {
		ll id = 1;
		repn(j, T) {
			if (s[i][id] < s[i][j]) { id = j; }
			}
		ans[i] = id;
	}

	repn(i, D) { cout << ans[i] << endl; }

	//cout << score(ans) << endl;
	
}

Measured memory_bytes: 3796
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
	int i;
	int a[100100];
	for(i=0;i<=n-1;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	int f;
	f=a[n/2]-a[n/2-1];
	printf("%d\n",f);
    }
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
int main()
{
	int n, k;
	LL ans = 0;
	scanf("%d%d", &n, &k);
	for (int i = k + 1; i <= n; i++) // 枚举的是除数 
		ans += (n / i) * (i - k) + max(0, ((n % i) - (k == 0 ? k : (k - 1)))); // n / i: 一共可以分成多少个格子, (n % i - k): 最后那个零散的格子提供的贡献 
	printf("%lld", ans);
	return 0;
}

/*
10: 0
9: 1
8: 2
7: 3
6: 4
5: 5
4: 6
3: 7
2: 8
1: 9
0: 10
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(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 ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



const int 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n,0);
    REPS(i, n){
        ll l = i;
        while (l<k) {
            l*=2;
            a[i-1]++;
        }
    }
    long double c = 0;
    REP(i, n){
        c+=pow(2, a[0]-a[i]);
    }
    long double ans = c/(pow(2, a[0])*n);
    DCOUT(ans, 15);
}


Measured memory_bytes: 4196
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main()
{
	long long int data[256];
	for (size_t i=0; i < 256; i++)data[i] = i*i;
	int a;

	while (1)
	{
		cin >> a;
		if (a == 0)
		{
			break;
		}
		int count = 0;
		for (size_t i = 0; i < 256&&data[i]<=a; i++)
		{
			for (size_t j = i; j < 256&&data[i]+data[j]<=a; j++)
			{
				for (size_t k = j; k < 256 && data[i] + data[j] + data[k] <= a; k++)
				{
					double x = sqrt(a - data[i] - data[j] - data[k]);
					if (x>=k&&x == (int)x)
					{
						count++;
					}
					
				}
				
			}
			
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

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;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/


Measured memory_bytes: 20456
n, k, q = map(int,input().split())
A = [int(input()) for i in range(q)]

P = [k-q] * n
for i in range(q):
    P[A[i]-1] += 1
for i in range(n):
    if P[i] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 10448
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

constexpr ll SIZE = 1LL << 17;
struct LazySegtree {
    int node[2*SIZE], lazy[2*SIZE];
    LazySegtree() {}
    LazySegtree(vector<int> v) {
        for(size_t i=0; i<v.size(); ++i) {
            node[SIZE-1+i] = v[i];
        }
        for(int i=SIZE-2; i>=0; i--) {
            node[i] = node[2*i+1] + node[2*i+2];
        }
    }

    void lazyUpdate(int a, int b, int k) {
        int rng = b - a;
        node[k] += lazy[k] * rng;
        if(rng > 1) {
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        lazy[k] = 0;
    }

    void add(int a, int b, int x, int l=0, int r=SIZE, int k=0) {
        lazyUpdate(l, r, k);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += x;
            lazyUpdate(l, r, k);
        }
        else {
            int mid = (l + r) / 2;
            add(a, b, x, l, mid, 2*k+1);
            add(a, b, x, mid, r, 2*k+2);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    int sum(int a, int b, int l=0, int r=SIZE, int k=0) {
        lazyUpdate(l, r, k);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = sum(a, b, l, mid, 2*k+1);
        int vr = sum(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

int N, Q;
LazySegtree seg;

signed main() {
    cin >> N >> Q;
    rep(i,0,Q) {
        int q; cin >> q;
        if(q == 0) {
            int s, t, x; cin >> s >> t >> x; s--;
            seg.add(s, t, x);
        }
        else {
            int x; cin >> x; x--;
            cout << seg.sum(x, x+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6288
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;

int main(){
	int n;
	cin >> n;
	int t[n];
	for(int i = 0; i < n; i++) cin >> t[i];
	int m;
	cin >> m;
	for(int i = 0; i < m; i++){
		int ans = 0;
		int p, x;
		cin >> p >> x;
		for(int j = 0; j < n; j++){
			if(j == p-1) ans += x;
			else ans += t[j];
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int n; cin >> n;
    long long cnt = 0;
    long long previous = 0;
    for (int i = 1; i <= n; i++){
        long long height; cin >> height;
        if (height < previous) {
            cnt += previous - height;
            height = previous;
        }
        previous = height;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x2 - x1;
	int b = y2 - y1;
	cout << x2 - b << " " <<  y2 + a << " " << x1 - b << " " << y1 + a;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 50

int f[maxn][4];
int p[maxn],t[maxn];
int maxint=2000000000;

int turn(int x)
{
	return (x>0?x:-x);
}

int min(int a,int b)
{
    return (a<b?a:b);
}

int main()
{
	int n;
	int flag;

	while (scanf("%d",&n)&&n)
	{
		int i,j;
		flag=0;
		for (i=1;i<=n;i++)
			scanf("%d %d",&p[i],&t[i]);
		for (i=1;i<=n;i++)
			for (j=0;j<4;j++)
				f[i][j]=maxint;
		if (p[1]<=t[1]) 
           f[1][1]=p[1];
        else
        {
            printf("NG 1\n");
            flag=1;
        }
		for (i=2;i<=n&&!flag;i++)
		{
			if (t[i]>=t[i-1]+2*p[i-1]+p[i])
				f[i][1]=min(f[i][1],f[i-1][1]+p[i-1]+p[i]);
			if (t[i]>=t[i-1]+2*turn(p[i]-p[i-1]))
				f[i][2]=min(f[i][2],f[i-1][1]+turn(p[i]-p[i-1]));
			if (t[i]>=t[i-1]+3*p[i-1]+p[i])
				f[i][1]=min(f[i][1],f[i-1][2]+p[i-1]+p[i]);
			if (t[i]>=t[i-1]+3*turn(p[i]-p[i-1]))
				f[i][3]=min(f[i][3],f[i-1][2]+turn(p[i]-p[i-1]));
			if (t[i]>=t[i-1]+4*p[i-1]+p[i])
				f[i][1]=min(f[i][1],f[i-1][3]+p[i-1]+p[i]);
			int num=0;
			for (j=1;j<=3;j++)
				if (f[i][j]==maxint) num++;
			if (num==3)
			{
				printf("NG %d\n",i);
				flag=1;
				break;
			}
		}
		if (!flag)
		{
			int ans=maxint;
			for (i=1;i<=3;i++)
				ans=min(ans,f[n][i]+p[n]);
			printf("OK %d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define a(x) x.begin(), x.end()
using namespace std;

int a, b, c;

signed main () {
  cin >> a >> b >> c;
  a -= b;
  cout << max (c - a, (int)0);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {
	
	int H, N;

	cin >> H >> N;

	vector<int> A(N);

	int sum = 0;

	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}

	bool ans = false;

	if (H <= sum) {
		ans = true;
	}

	puts(ans ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int a,n,i,j,s,r;
    scanf("%d%d", &n, &a);
    if(n<=a)
        printf("Yes\n");
    else
    {
        if(n%500<=a)
            printf("Yes\n");
        else
            printf("No\n");
    }

}


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

vector<vector<int> > edges;
vector<int> records;

int go(int idx){

    if(records[idx] != 0)
        return records[idx];

    int max_len = 0;
    for(int to : edges[idx]){
        int len = go(to);
        if(len > max_len)
            max_len = len;
    }

    records[idx] = max_len+1;

    return records[idx];
}

int main(){
    int n, m;
    cin >> n >> m;

    edges = vector<vector<int> >(n, vector<int>());
    records = vector<int>(n, 0);
    vector<int> tmp = vector<int>(n, 0);

    for(int i = 0; i < m; i++){
       int from, to;
       cin >> from >> to;
       from--;
       to--;
       edges[from].push_back(to);
       tmp[to] = 1;
    }
      
    vector<int> roots = vector<int>();

    for(int i = 0; i < n; i++)
        if(tmp[i] == 0)
            roots.push_back(i);

    int max_len = 0;
    for(int root : roots){
        int len = go(root);
        if(len > max_len)
            max_len = len;
    }

    cout << max_len-1 << "\n";

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
   ll a,b,c,d;
   cin >> a >> b >> c >> d;
   ll a1 = 0 , a2 = 0;
   while(a > 0)
   {
       a -= d;
       a1++;
       if(a <= 0)
       {
           break;
       }
   }
   while(c > 0)
   {
       c -= b;
       a2++;
       if(c <= 0)
       {
           break;
       }
   }
   if ( a1 < a2 )
   {
       cout << "No\n";
   }
   if(a1 >= a2)
   {
       cout << "Yes\n";
   }

}



Measured memory_bytes: 3628
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		int cnt = 0;
		// hを初めから見ていって、0になるまでループ
		for (int i = 0; i < N; i++) {
			while (h[i] > 0) {
				// 先の花を見ていって、0でなければ一緒に水をやる
				for (int j = i; j < N; j++) {
					if (h[j] == 0) {
						break;
					}
					h[j]--;
				}
				cnt++;
			}
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 36068
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

#define bsf __builtin_ctzll
ll gcd(ll a, ll b) {
  // a = abs(a); b = abs(b);
  if (!a || !b) return a|b;
  int t = bsf(a|b); a >>= bsf(a);
  do { b >>= bsf(b); if (a > b) swap(a, b); b -= a;} while (b);
  return a << t;
}
ll lcm(ll x, ll y) { return x/gcd(x,y)*y;}
bool solve() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if (d < b) return false;
  if (a < b) return false;
  ++c;
  if (c >= b) return true;
  d %= b;
  ll g = gcd(d,b);
  a %= b;
  a += (b-a-1)/g*g;
  if (c <= a && a < b) return false;
  return true;
}

int main() {
  int ts;
  scanf("%d",&ts);
  rep(ti,ts) {
    puts(solve()?"Yes":"No");
  }
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    int n;
    cin >> n;
    vector<ll> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    sort(all(c), greater<ll>());
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += c[i] * (i + 2);
        ans %= MOD;
    }
    ans *= modpow(4, n - 1, MOD);
    ans %= MOD;
    cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
struct line{
  int h;
  int s;
  int t;
  bool operator<(const line x){
    if(h < x.h) return true;
    else return false;
  }
};

int main(){
  int n, m, a;
  while(cin >> n >> m >> a and n + m + a){
    vector<int> place(n);
    vector<line> lines;
    iota(ALL(place), 1);
    REP(i, m){
      int h, p, q;
      cin >> h >> p >> q;
      lines.push_back({h, p, q});
    }
    sort(ALL(lines));
    REP(i, m){
      int tmp = place[lines[i].s-1];
      place[lines[i].s-1] = place[lines[i].t-1];
      place[lines[i].t-1] = tmp;
    }
    cout << place[a-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int A, B,C,D;
int main() {
    cin >> A >> B >> C >>D;
    while(A > 0 && C > 0) {
        C -= B;
        if(C <= 0) break;
        A -= D;
    }
    if(A > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
# ABC149 - virtual
# D
N,K=map(int,input().split())
R,S,P=map(int,input().split())
pnt={'r':R,'s':S,'p':P}
WIN={'s':'r','p':'s','r':'p'}
T=input()
ans=0
for k in range(K):
    t=list(T[i] for i in range(k,N,K))
    win=[WIN[x] for x in t]
    # print(t,win)
    prev=win[0]
    cnt=1
    for i in range(1,len(t)):
        if prev==win[i]:
            cnt+=1
        else:
            ans+=((cnt+1)//2)*pnt[prev]
            # print(ans)
            cnt=1
            prev=win[i]
    # print(prev)
    ans+=((cnt+1)//2)*pnt[prev]
    # print(ans)
print(ans)
        



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

int main(){
  int K,S,count = 0;
  cin >> K >> S;
  if(3 * K < S){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0;i <= K;i++){
    for(int j = 0;j <= K;j++){
      if((0 <= S - i - j)&&(S - i - j <= K))
        count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

char land[101][101];
int used[101][101];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int h, w;

void dfs(int y, int x, char c) {
  for(int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx > w || ny < 0 || ny > h) continue;
    else if(used[ny][nx] == 1) continue;
    else if(land[ny][nx] == c) {
      used[ny][nx] = 1;
      dfs(ny, nx, c);
    }
  }
}

int main() {
    while(1) {
    int count = 0;
    cin >> h >> w;
    if(h == 0 && w == 0) break;

    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        cin >> land[i][j];
        used[i][j] = 0;
      }
    }

    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        if(used[i][j] == 0) {
          used[i][j] = 1;
          count += 1;
          dfs(i, j, land[i][j]);
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}



Measured memory_bytes: 3620
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B

main=B.interact$B.pack.f.unfoldr(B.readInt.B.dropWhile isSpace)
f (n:txys) = sol 0 (0,0) n txys
sol _ _ 0 _ = "Yes"
sol t0 (x0,y0) n (t:x:y:txys)
    | dt < d = "No"
    | odd (dt-d) = "No"
    | otherwise = sol t (x,y) (n-1) txys
    where
        d  = abs(x-x0) + abs(y-y0)
        dt = t-t0

Measured memory_bytes: 3708
<?php
fscanf ( STDIN, '%d', $rowcnt );

for($row = 0; $row < $rowcnt; $row ++) {
	$dataset = explode ( ' ', rtrim ( fgets ( STDIN ) ) );
	$result = pushBall ( $dataset );
	if ($result) {
		echo "YES";
	} else {
		echo "NO";
	}
	echo PHP_EOL;
}
function pushBall($dataset) {
	$b = new Tube ();
	$c = new Tube ();

	foreach ( $dataset as $n ) {
		if ($b->isPushable ( $n ) && $c->isPushable ( $n )) {
			if ($b->peek () < $c->peek ()) {
				$c->push ( $n );
			} else {
				$b->push ( $n );
			}
		} else if ($b->isPushable ( $n )) {
			$b->push ( $n );
		} else if ($c->isPushable ( $n )) {
			$c->push ( $n );
		} else {
			return false;
		}
	}
	return true;
}
class Tube {
	private $tube = [ ];
	public function __construct() {
		$this->tube [] = 0;
	}
	public function isPushable($n) {
		if ($this->peek () < $n) {
			return true;
		} else {
			return false;
		}
	}
	public function push($n) {
		$this->tube [] = $n;
	}
	public function peek() {
		$idxLast = count ( $this->tube ) - 1;
		return $this->tube [$idxLast];
	}
}

Measured memory_bytes: 15380
import numpy as np
h, w = list(map(int, input().split()))
a = np.array([list(input()) for i in range(h)])
a = a[:, ~np.all(a=='.', axis=0)]
a = a[~np.all(a=='.', axis=1)]
for i in range(len(a)):
    print(''.join(a[i]))

Measured memory_bytes: 12536
n, m = map(int, input().split())
ab = []
for i in range(n):#h:高さ
    ab.append([int(m) for m in input().split()])
cd = []
for i in range(m):#h:高さ
    cd.append([int(m) for m in input().split()])
dis = [float("inf")]*n
dn = [-1]*n
for i in range(n):
    for j in range(m):
        t = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if t < dis[i]:
            dis[i] = t
            dn[i] = j
    print(dn[i] + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


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

    if(N % 2 == 1 || N < 10){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll base = 10;
    while(N >= base){
        ans += N / base;
        base *= 5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  string s;
  while(cin>>s,s!="0") {
    int dp[11] = {};
    int ans = 0;
    for (int i=s.size()-1; i>=0; --i) {
      int next[11] = {};
      dp[0]++;
      REP(j,11) {
        next[(j+(s[i]-'0')*(i%2?1:-1)+11)%11] += dp[j];
      }
      REP(j,11) dp[j]=next[j];
      // REP(j,11) cout << dp[j] << " "; cout << endl;
      if (s[i]!='0') ans += dp[0];
    }
    cout << ans << endl;
  }
}

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

int main(){
  char a[200],b[200];
  int s,h,i,n;

  scanf("%d",&n);
  i=0;
  h=0;
  while(n>0){
    scanf("%s %s", a,b);
    s=strcmp(a,b);
    if(s==0){
      i++;
      h++;
    }
    else if(s>0)
      i+=3;
    else
      h+=3;
    n--;
    }
  printf("%d %d\n",i,h);

  return 0;
}

Measured memory_bytes: 1752
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>	
#include<string>
#include<math.h>
#include <vector>
using namespace std;
int main() {
	string S;
	string fire;
	char f[100];
	int a = 0;
	int N = 0;
	int T = 0;
	int l = 0;
	double A[100000] = { 0 };
	double B[10000] = { 0 };
	int r = 0;
	int c = 0;
	int p = 0;
	int sum = 0;
	double ans = 0;


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

	cout << 1/ans;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a[20];
int main (){
	long long n;
	cin>>n;
	n++;
	long long a[n], b[n-1];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n-1; i++)cin>>b[i];
	long long sum=0,temp=0;
	if(b[0]>=a[0]){
		sum+=a[0];
		b[0]-=a[0];

	}
	else {
		sum+=b[0];
		b[0]=0;
	}
	if(n>2){
	for (int i=1 ; i<n-1; i++){
		if(b[i-1]>0){
			if(a[i]>=b[i-1]){
				sum+=b[i-1];
				a[i]-=b[i-1];
			}
			else {
				sum+=a[i];
				a[i]=0;
			}
		}
		if(a[i]>=b[i]){
			sum+=b[i];
			b[i]=0;
		}
		else{
			sum+=a[i];
			b[i]-=a[i];
		}
	}
}
	sum+=min(a[n-1],b[n-2]);
	cout<<sum;




}


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long)(1e15)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');
    cerr.write(names, name-names) << " = " << arg1 << endl;
    _F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}
const int MOD = 1e9+7;

void solve(){
    int n, k;
    cin >> n >> k;
    int l[n+2];
    l[0] = 0;
    int ans = 0;
    for(int i = n; i >= 0; i--){
        l[n-i+1] = l[n-i]+i;
    }
    for(int i = k; i <= n+1; i++){
        int mn = i*(i-1)/2;
        int mx = l[i];
        ans =(ans+mx-mn+1)%MOD;
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(12);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 5172
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a;
		int b;
		
		while(true) {
			a = scan.nextInt();
			b = scan.nextInt();
			if(a == 0 && b == 0) {
				break;
			} else {}
			
			if((a*b)%2 == 1) {
				System.out.println("no");
			} else {
				System.out.println("yes");
			}
		}
		
		
		
	}

}




Measured memory_bytes: 28892
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int r;
   if(400<=n and n<=599) r = 8;
   if(600<=n and n<=799) r = 7;
   if(800<=n and n<=999) r = 6;
   if(1000<=n and n<=1199) r = 5;
   if(1200<=n and n<=1399) r = 4;
   if(1400<=n and n<=1599) r = 3;
   if(1600<=n and n<=1799) r = 2;
   if(1800<=n and n<=1999) r = 1;
   cout << r;
   return 0;
} 

Measured memory_bytes: 3648