akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
 */
public class Main 
{
	public static void main(String[] args) throws IOException
	{
		int a[]=nia(3);
		Arrays.sort(a);
		if(a[0]==a[1])
			pr(a[2]-a[0]);
		else
			pr(a[2]-a[1]+(a[1]-a[0])/2+2*((a[1]-a[0])%2));
		System.out.println(ans);
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static final boolean debug=false;
	static Reader in=new Reader();
	static StringBuilder ans=new StringBuilder();
	static long powm(long a, long b, long m)
	{
		long an=1;
		long c=a;
		while(b>0)
		{
			if(b%2==1)
				an=(an*c)%m;
			c=(c*c)%m;
			b>>=1;
		}
		return an;
	}
	static Random rn=new Random();
	static void pd(){if(debug)ans.append("hola");}
	static void pd(Object a){if(debug)ans.append(a+"\n");}
	static void pr(Object a){ans.append(a+"\n");}
	static void pr(){ans.append("\n");}
	static void p(Object a){ans.append(a);}
	static void sop(Object a){System.out.println(a);}
	static int ni(){return in.nextInt();}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[][]nim(int n, int m){int a[][]=new int[n][m];for(int i=0; i<n; i++)for(int j=0; j<n; j++)a[i][j]=ni();return a;}
	static int[] ria(int n){int a[]=new int[n];for(int i=0; i<n; i++){a[i]=rn.nextInt(100);p(a[i]+" ");}pr();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static node[] graph(int n) {
		node[] ho=new node[n];
		for(int i=0; i<n; i++)
			ho[i]=new node();
		return ho;
	}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static long nl(){return in.nextLong();}
	static String ns(){return in.next();}
	static double nd(){return in.nextDouble();}
	static String pr(String a, long b)
	{
		String c="";
		while(b>0)
		{
			if(b%2==1)
				c=c.concat(a);
			a=a.concat(a);
			b>>=1;
		}
		return c;
	}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
    }
}
class node
{
	List<Integer> adj=new ArrayList<Integer>();
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s.at(i) != t.at(i)) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
ll gcd(ll a,ll b)
{
    if(!b)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
    cin>>a>>b;
    ll res = gcd(a,b);
    ll ans = 0;
    for(ll i=2;i*i<res;i++)
    {
        if(res%i==0)
        {
            ans++;
            while(res%i==0)
                res /= i;
        }
    }
    if(res>1)
        ans++;
    cout<<++ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long int ll;
const int MAX_N = 100000;


ll foo(ll *a, ll *b) {
    ll ret;
    if (*a < *b) {
        ret = *a;
        *b -= *a;
        *a = 0;
    } else {
        ret = *b;
        *a -= *b;
        *b = 0;
    }
    return ret;
}

int main() {
    int n;
    ll a[MAX_N + 1], b[MAX_N];

    cin >> n;

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

    ll ans = 0;

    for (int i = n-1; i >= 0; i--) {
        ans += foo(&a[i + 1], &b[i]);
        ans += foo(&a[i], &b[i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N, D;
  get(N, D);
  vector<vector<int> > X(N, vector<int>(D));
  FOR(i, N) {
    FOR(j, D) { cin >> X[i][j]; }
  }
  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int sum = 0;
      for (int d = 0; d < D; ++d) {
        sum += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
      }
      int c = 0;
      while (c * c < sum) {
        c++;
      }
      if (c * c == sum)
        ans++;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

    lld n, m, c; cin >> n >> m >> c;
    vector<lld> b(m);
    _input(b);
    lld ans = 0ll;
    for4(i, 0, n, 1) {
        lld total = 0LL;
        for4(j, 0, m, 1) {
            lld temp; cin >> temp;
            total += temp * b[j];
        }

        if (total + c > 0) ans++;
    }
    cout << ans;
    cout << "\n";

    return;
}


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

    lld T3X0 = 0, T353 = 1;

    // TESTCASES()
    solveEachTest(T353 - T3X0);
    return 0;
}
// Random Thought :  null

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

int main(){
  int N; cin >> N;
  vector<int> x(N);
  rep(i,N){
    cin >> x.at(i);
  }
  sort(all(x));
  int ans=INF;
  for(int i=x[0];i<=x[x.size()-1];i++){
    int sum=0;
    for(int j=0;j<N;j++){
      sum+=abs(i-x[j])*abs(i-x[j]);
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;
}


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

int main()
{
	int a,n;
    cin>>a>>n;
    for(int i=0;i<=a;i++)
    {
        if((4*i)+2*(a-i)==n)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
int x,y,i;
cin>>x>>y;
for(i=0;i<=x;i++){
    ll z=i*2+(x-i)*4;
    if(z==y)
        break;
}
if(i<=x)
    cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin >> n;
    vec(a,n+1);
    vec(b,n);
    REP(i,n){
        cin >> b[i];
        a[b[i]] ++;
    }
    int ans = 0;
    REP(i,n+1){
        ans += a[i] * (a[i]-1) / 2;
    }
    REP(i,n){
        if(a[b[i]] < 2){
            print(ans);
        }
        else{
            int x = ans;
            x -= a[b[i]] * (a[b[i]]-1) / 2;
            print(x+((a[b[i]]-2) * (a[b[i]]-1) / 2));
        }
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,q;
    cin>>n>>q;
    vector<ll> sum(n,0);
    vector<int> visited(n,0);
    vector<vector<ll>> G(n);
    
    for(int i =1;i<n;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i=1;i<=q;i++){
        int p;
        ll x;
        cin>>p>>x;
        p--;
        sum[p] += x;
    }

    queue<int> que;
    que.push(0);
    visited[0] = 1;
    while(!que.empty()){
        int u = que.front(); que.pop();
        for(int j =0; j<G[u].size(); j++){
            int v = G[u][j];
            if(visited[v] == 0){
                que.push(v);
                visited[v] = 1;
                sum[v] += sum[u];
            }
        }
    }
    
    for(int i=0; i<n; i++){
        ll ans = sum[i];
        cout<< ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 17904
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>
#include <cmath>
#include <deque>
#include <numeric>

using namespace std;

pair <long long, int> dt[100000];

int main(){
  int N;
  int K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    int t;
    long long d;
    cin >> t >> d;
    dt[i] = make_pair(d, t);
  }

  sort(dt, dt + N);

  long long ans = 0;
  map <int, int> type_counts;
  for(int i = 0; i < K; i ++){
    ans += dt[N - 1 - i].first;
    if(type_counts.find(dt[N - 1 - i].second) != type_counts.end()){
      type_counts[dt[N - 1 - i].second] ++;
    } else {
      type_counts[dt[N - 1 - i].second] = 1;
    }
  }

  long long type_num = type_counts.size();
  ans += type_num * type_num;

  vector <long long> discard_order;
  for(int i =  N - K; i < N; i++){
    if(type_counts[dt[i].second] != 1){
      discard_order.push_back(dt[i].first);
      type_counts[dt[i].second] --;
    }
  }

  if(discard_order.size() == 0){
    cout << ans << endl;
    return 0;
  }

  long long tmp_ans = ans;
  int discard_ind = 0;
  for(int i = N - 1 - K; i >= 0; i--){
    if(type_counts.find(dt[i].second) != type_counts.end()){
      continue;
    }
    tmp_ans = tmp_ans - type_num * type_num + (type_num + 1) * (type_num + 1)
                                  + dt[i].first - discard_order[discard_ind];
    ans = max(ans, tmp_ans);
    type_num ++;
    discard_ind ++;
    type_counts[dt[i].second] = 1;

    if(discard_ind >= discard_order.size()){
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

string s;

map<string,int> mapu;
int output = 0 ;
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		sort(s.begin(),s.end());
		mapu[s]+=1;
	}
	for(auto it = mapu.begin();it!=mapu.end();it++)
		output += (((it->se)*(it->se-1))/2);
		cout<<output;
	return 0;
}

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


int ispal(string s, int i ,int j)
{
    while(i<=j)
    {
        if(s[i]!=s[j])
        return 0;
        i++;
        j--;
    }
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	int L;
	cin>>L;
	//double out = (s/3.0)*(s/3.0)*(s/3.0);
	printf("%.12f\n",(double)L*L*L/27.0);
	return 0;
}

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

int main()
{
    int d;
    cin >> d;
    cout << "Christmas" << " ";
    switch (d) 
    {
    case 22:
        cout << "Eve" << " ";
    case 23:
        cout << "Eve" << " ";
    case 24:
        cout << "Eve" << " ";
    case 25:
        break;
        
    
    default:
        break;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n,c = map(int,input().split())
xv = [[int(i) for i in input().split()] for j in range(n)]

jun1 = [0]*n
jun2 = [0]*n

rev1 = [0]*n
rev2 = [0]*n

tmpj = 0
oldj = 0

tmpr = 0
oldr = 0

rv = [[0 for i in range(2)] for j in range(n)]

for i in range(n):
    rv[i][0] = c - xv[n-1-i][0]
    rv[i][1] = xv[n-1-i][1]

for i in range(n):
    #old += xv[i][1]
    tj = xv[i][1] - (xv[i][0]-oldj)
    tmpj += tj
    oldj = xv[i][0]
    jun1[i] = tmpj
    
    
    tr = rv[i][1] - (rv[i][0]-oldr)
    tmpr += tr
    oldr = rv[i][0]
    rev1[i] = tmpr

tmpj = 0
oldj = 0

tmpr = 0
oldr = 0
   
for i in range(n):
    tj = xv[i][1] - (xv[i][0]-oldj)*2
    tmpj += tj
    oldj = xv[i][0]
    jun2[i] = tmpj
    
    tr = rv[i][1] - (rv[i][0]-oldr)*2
    tmpr += tr
    oldr = rv[i][0]
    rev2[i] = tmpr
    
tmp = 0    
for i in range(n):
    tmp = max(tmp,jun2[i])
    jun2[i] = tmp
    
tmp = 0
for i in range(n):
    tmp = max(tmp,rev2[i])
    rev2[i] = tmp

#print(jun2,rev1,rev2,jun1)
ans = 0

for i in range(n):
    if i == n-1:
        ans = max(ans,jun1[i],rev1[i])
        break
    ans = max(max(0,jun1[i])+rev2[n-i-2],ans)
    ans = max(max(0,rev1[i])+jun2[n-i-2],ans)

print(ans)

Measured memory_bytes: 81624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int n,m;
	cin>>n>>m;
	//vector<int> an(n);
	priority_queue<int> pa;
	rep(i,n){
		int a;
		cin>>a;
		pa.push(a);
	}
	rep(i,m){
		int r=pa.top();
		pa.pop();
		r=r/2;
		pa.push(r);
	}
	ll ans=0;
	rep(i,n){
		ans+=pa.top();
		pa.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(void){
    
    int S,h,m,s;
    cin >>S;
    
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;
    
    cout <<h<<":"<<m<<":"<<s<<endl;
    
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
string s;
int p[110];
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		int num=0;
		for(int j=0;j<i;j++)
		{
			if(s[i]==s[j]) num=0;
			else num++;
		}
		for(int j=0;j<i;j++)
		{
			if(s[i]==s[j]) num=max(num,p[j]);
		}
		p[i]=num;
	}
	int ans=s.size();
	for(int i=0;i<s.size();i++)
	{
		int pp=0;
		for(int j=i+1;j<s.size();j++)
		{
			if(s[i]==s[j])
			{
				pp=1;
				break;
			}
		}
		if(pp==0)
		{
			ans=min(ans,max(p[i],(int)s.size()-i-1));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, a, N);
  map<ll, int> m;
  each(x, a) {
    m[x]++;
  }
  ll ans = 0;
  each(x, m) {
    if (x.first > x.second) {
      ans += x.second;
    } else if (x.first < x.second) {
      ans += x.second - x.first;
    }
  }
  print(ans);
}


Measured memory_bytes: 7040
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, a = 0, w = 0, t = 0, r = 0;
    cin >> n;
    while (n--)
    {
        string s;
        cin >> s;
        if (s == "AC")
            a++;
        else if (s == "WA")
            w++;
        else if (s == "TLE")
            t++;
        else
            r++;
    }
    cout << "AC x " << a << '\n';
    cout << "WA x " << w << '\n';
    cout << "TLE x " << t << '\n';
    cout << "RE x " << r << '\n';
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int n, k, a[200], dp[N][2], p;

bool dfs(int num, int person) {
   if(dp[num][person]) return dp[num][person];
   int ans=0;
   for1(i, n) {
      if(a[i] <= num) ans |= !dfs(num - a[i], person^1);
   }
   dp[num][person] = ans;
   return ans;
}


int main() {
   scanf("%d %d", &n, &k);
   for1(i, n) scanf("%d", &a[i]);
   bool ans = dfs(k, 1);
   ans ? puts("First") : puts("Second");
   return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N, 0);

    REP(i, N-1){
        ll a;
        cin >> a;
        A[a-1]++;
    }
    REP(i, N){
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4776
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

long long n;
char a[1000],b[1000];
int main(){
	int A = 0,B = 0;
	scanf("%s %s",a,b);
	for(int i = 1;i <= (strlen(a) + strlen(b));i++){
		if(i % 2 == 1){
			printf("%c",a[A]);
			A++;
		}
		else{
			printf("%c",b[B]);
			B++;
		} 
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;



public class Main {

	public static void main(String[] args) {
		char a[];
		Scanner sc = new Scanner(System.in);
		a = sc.nextLine().toCharArray();
		for(int i=0;i<a.length;i++){
			if((char)('a')<=a[i]&&a[i]<=(char)('z')){
				a[i]=(char) (a[i]-'a'+'A');
			}
		}
		System.out.println(a);
	}
}

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

#define H 50
#define W 50

int xyt[H][3];
int plant[H][W];
int x,y,cnt,when;

int main(void){

  int i,j,k;
  int length=0;
  
  cin >> x >> y >> when;
  cin >> cnt;

  for(i=0;i<cnt;i++) cin >> xyt[i][0] >> xyt[i][1] >> xyt[i][2];
  
  
  for(i=0;i<y;i++)
    for(j=0;j<x;j++)
      cin >> plant[i][j];

  for(i=0;i<cnt;i++){
    if(plant[xyt[i][1]][xyt[i][0]] == 1 && xyt[i][2] <= when) length++;
  }

  cout << length << endl;
  
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }


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

	int h, w;
	cin >> h >> w;
	vector<int> cnt(26);
	rep(i, h*w) {
		char c;
		cin >> c;
		cnt[c - 'a']++;
	}
	int one = (h % 2)*(w % 2);
	int two = (h % 2)*(w / 2) + (h / 2)*(w % 2);
	int four = (h / 2)*(w / 2);
	rep(i, 26) {
		if (cnt[i] % 2 == 1) {
			if (one == 0) {
				cout << "No" << endl;
				return 0;
			}
			cnt[i]--; one--;
		}
		if (cnt[i] % 4 == 2) {
			if (two == 0) {
				cout << "No" << endl;
				return 0;
			}
			cnt[i] -= 2; two--;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 10000

int isprime(int);
int main(void) {
  int n, cnt;
  int i;
  int a[N];
  int b;
  cnt = 0;
  scanf("%d",&n);
 for(i=0;i<n;i++){
   scanf("%d",&a[i]);
 }
 
 for(i=0;i<n;i++){
   b = isprime(a[i]);
   if(b==1)cnt++;
 }

 printf("%d\n",cnt);
 return 0;
}

int isprime(int x){
  int i;
  
  if (x == 2){
    return 1;
  }

  else if(x < 2 || x % 2 == 0){
    return 0;
  }
 
  for(i=3;i*i<=x;i=i+2){
    if(x%i==0)return 0;
  }
  return 1;
  }

Measured memory_bytes: 628
def resolve():
    A, B, K = [int(i) for i in input().split()]
    offset = 0
    while offset < K and A + offset <= B:
        print(A + offset)
        offset += 1
    begin = A + offset
    r = max(B - K + 1, begin)
    while r <= B:
        print(r)
        r += 1


resolve()


Measured memory_bytes: 9016
inpl = lambda: list(map(int,input().split()))
def bisect_left_withkey(a, x, lo=0, hi=None, key=lambda x: x, keyvalue_x=False):
    left = lo
    right = len(a) if hi is None else hi
    kx = x if keyvalue_x else key(x)
    while left + 1 < right:
        new = (left + right)//2
        kn = key(a[new])
        if kx <= kn:
            right = new
        else:
            left = new
    if key(a[left]) == kx:
        return left
    else:
        return right

N, K = inpl()
A = inpl()
F = inpl()
A.sort(reverse=True)
F.sort()
score = [A[i]*F[i] for i in range(N)]

def achievable(m):
    k = 0
    for i in range(N):
        k += max(0, (score[i]-m-1)//F[i] + 1)
        if k > K:
            return False
    return True

M = max(score)
print(bisect_left_withkey(range(M+1), True, key=achievable, keyvalue_x=True))

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

int main()
{
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++)
  {
    cin >> a[i];
  }
  vector<int> at(a, a + N);
  sort(at.begin(),at.end(),std::greater<int>());
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
    {
      alice += at[i];
    }
    else
    {
      bob += at[i];
    }
  }
  cout << (alice - bob);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	string s;
	cin>>s;
	if(s=="Sunny") cout<<"Cloudy"<<endl;
	if(s=="Cloudy") cout<<"Rainy"<<endl;
	if(s=="Rainy") cout<<"Sunny"<<endl;
	return 0;
}

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


#define MAX 100002

long long int im[MAX];

long long int im2[MAX];

int n;
int k;

long long int rng_im(int a, int b){
	if (a > b)return 0;
	long long int r = im[b];
	if (a){
		r -= im[a - 1];
	}
	return r;
}
long long int rng_im2(int a, int b){
	if (a > b)return 0;
	long long int r = im2[b];
	if (a){
		r -= im2[a - 1];
	}
	return r;
}
int main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		im[i] = a;
		if (a >= 0){
			im2[i] = a;
		}
		if (i){
			im[i] += im[i - 1];
			im2[i] += im2[i - 1];
		}
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++){
		int lef = i;
		int rig = i + k - 1;
		if (rig >= n)break;
		long long int S = 0;
		if (i){
			S += im2[i - 1];
		}
		if (rig + 1 < n){
			S += rng_im2(rig + 1, n - 1);
		}
		ans = max(ans, S);
		S += rng_im(lef, rig);
		ans = max(ans, S);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
#include <functional>
using namespace std;

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

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

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

typedef struct node * Node;

#define NIL NULL

Node root;

void inorder(Node x){
  if(x==NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

void preorder(Node x){
  if(x==NIL) return;
  printf(" %d",x->key);
  preorder(x->left);
  preorder(x->right);
}

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL) x=x->right;
  return x;
}



Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u; 
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  if(x->right!=NIL) return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
Node y;
Node x;
 if(z->left==NIL || z->right==NIL) y=z;
 else y=treeSuccessor(z);

 if(y->left != NIL) x=y->left;
 else x=y->right;

 if(x != NIL) x->parent=y->parent;
 if(y->parent==NIL) root=x;
 else if(y==y->parent->left) y->parent->left=x;
 else y->parent->right=x;

 if(y!=z) z->key=y->key;
}


void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct 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;
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n); //n=命令の数//

  for(i=0;i<n;i++){
    scanf("%s",com);
    
    if(com[0]=='f'){
      scanf("%d",&x);
      Node t=treeSearch(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else  if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
  return 0;
}



Measured memory_bytes: 20452
#include<stdio.h>
void sp(int n, int m) {
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (i == 0 && n - 1 && m - 1 || j == 0 && n - 1 && m - 1 
					|| i == n - 1 && n - 1 && m - 1 || j == m - 1 && m - 1 && m - 1)
				putchar('#');
			else
				putchar('.');
		}putchar('\n');
	}
}


int main() {
	int H[300], W[300];
	int i;

	for (i = 0;; i++) {
		scanf("%d %d", &H[i], &W[i]);
		if (H[i] == 0 && W[i] == 0)
			break;
	}

	for (int k = 0; k < i; k++) {
		sp(H[k], W[k]);
		putchar('\n');
	}

	return 0;
}

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

int n,m;
vector<int> g[200005];
int sz;
bool vis[200005];

void dfs(int x){
    vis[x]=1;
    sz++;
    for(int &y:g[x])if(!vis[y]){
        dfs(y);
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=1;i<=m;i++){
        static int u,v;
        cin>>u>>v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++)if(!vis[i]){
        sz=0;
        dfs(i);
        ans=max(ans,sz);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 20904
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int maxRemain = 0;
      int sum = 0;

      for (int i = 0; i < 5; ++i) {
        int dish = in.nextInt();
        int remain = dish % 10 > 0 ? 10 - (dish % 10) : 0;
        maxRemain = Math.max(maxRemain, remain);
        sum += dish + remain;
      }
      
      sum -= maxRemain;
      
      System.out.println(sum);
    }
  }
}

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

const long long MOD=1000000007;

int main(){
    long long N;
    cin >> N;
    long long A[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> A[i];
    }
    long long sum_from[N+1];
    sum_from[N]=A[N];
    for(i=N-1; i>=1; i--){
        sum_from[i]=sum_from[i+1]+A[i];
        sum_from[i]%=MOD;
    }
    long long ans=0;
    for(i=1; i<N; i++){
        ans+=A[i]*sum_from[i+1];
        ans%=MOD;
    }
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 6752
#include<stdio.h>
#define N 200000

int main(){
    
    int i,n,maxv,minv;
    int arr[N];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    
    maxv = arr[1] - arr[0];
    minv = arr[0];
    
    for(i=1;i<n;i++){
        if(maxv<arr[i]-minv){
            maxv = arr[i]-minv;
        }
        if(minv>arr[i]){
            minv = arr[i];
        }
    }
    
    printf("%d\n",maxv);
    
    return 0;
}

Measured memory_bytes: 1376
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int n=scan.nextInt();
		if(n==0)break;
		int s[]=new int[n];
		char x[]=new char[100];
		int f=0;
		String str=scan.next();
		for(int i=0;i<100;i++)
		    {
			x[i]=str.charAt(i);
			if(x[i]=='S')
			    {
				f+=s[i%n]+1;
				s[i%n]=0;
			    }
			else if(x[i]=='M')s[i%n]++;
			else 
			    {
				s[i%n]+=f+1;
				f=0;
			    }
		    }
		for(int i=0;i<n;i++)
		    {
			for(int j=n-1;j>i;j--)
			    {
				if(s[j]<s[j-1])
				    {
				int t=s[j];
				s[j]=s[j-1];
				s[j-1]=t;
				    }
			    }
		    }
		for(int i=0;i<n;i++)
		    {
			System.out.print((i!=n)?s[i]+" ":"");
		    }
		System.out.print(f);
		System.out.println();
	    }
    }
}

Measured memory_bytes: 21680
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') P("vowel");
  else P("consonant");
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        bool a[21][21] = {};
        rep(i,n){
            int x,y;
            cin >> x >> y;
            a[x][y] = true;
        }
        int m;
        cin >> m;
        int x = 10;int y=10;
        a[10][10] = false;
        rep(i,m){
            string s;
            int d;
            cin >> s >> d;
            switch(s[0]){
                case 'N':
                rep(k,d){
                    y+=1;
                    a[x][y] = false;
                }
                break;
                case 'E':
                rep(k,d){
                    x+=1;
                    a[x][y] = false;
                }
                break;
                case 'S':
                rep(k,d){
                    y-=1;
                    a[x][y] = false;
                }
                break;
                case 'W':
                rep(k,d){
                    x-=1;
                    a[x][y] = false;
                }
                break;
            }
        }
        [&]()->void{
            rep(x,21) rep(y,21) if(a[x][y]){
                cout << "No" << endl;
                return;
            }
            cout << "Yes" << endl;
        }();


    }
    return 0;

}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);
// len2: aa, ab
// aa: aaa
// aa: aab
// ab: aba
// ab: abb
// ab: abc
int use_char(string s) {
    vector<int> used(15, 0);
    for(char c: s)
        used[c-'a'] = 1;
    return accumulate(used.begin(), used.end(), 0);
}
int main() {
    int n;
    cin >> n;
    unordered_map<int, vector<string>> dp;
    dp[1] = {"a"};
    for(int i = 2; i <= n; i++) {
        unordered_map<int, vector<string>> new_dp;
        for(auto p: dp) {
            int len = p.first;
            for(string s: p.second) {
                for(int i = 0; i <= len; i++) {
                    string s2 = s;
                    s2 += ('a'+i);
                    new_dp[use_char(s2)].push_back(s2);
                }
            }
        }
        dp = new_dp;
    }
    set<string> ans;
    for(auto p: dp) {
        for(string s: p.second) {
            ans.insert(s);
        }
    }
    for(string s: ans)
        cout << s << endl;

    return 0;
}




Measured memory_bytes: 13340
n=int(input())
a,b=map(int,input().split())
p=[int(i) for i in input().split()]
x,y,z=0,0,0
for i in p:
    if i>b:
        z+=1
    elif i<=a:
        x+=1
    else:
        y+=1
print(min(x,y,z))

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  if(x->left==NIL) return x;
  else treeMinimum(x->left);
  //return 0;

}

Node treeMaximum(Node x){
  if(x->right==NIL) return x;
  else treeMaximum(x->right);
  //return 0;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  else if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
  //return 0;

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x->key == y->right->key){
    x = y;
    y = y->parent;
  }
  return y;
  //return 0;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);
  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;
  if(x != NIL)
    x->parent = y->parent;
  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  if(y != z)
    z->key = y->key;
  return ;

}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z= malloc(sizeof(struct 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->key==NIL) return;

  if(u->left!=NIL){ 
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right!=NIL){ 
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u->key==NIL) return;
  printf(" %d",u->key);
  
  if(u->left != NIL){ 
    preorder(u->left);
    }
  
    if(u->right != NIL){ 
    preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int N;

int order(vector<int> &A) {
    vector<int> O(N);
    for (int i = 0; i < N; i++) O[i] = i + 1;

    int cnt = 0;
    do {
        cnt++;
        bool flag = true;
        for (int i = 0; i < N; i++) {
            if (O[i] != A[i]) flag = false;
        }
        if (flag) return cnt;
    } while (next_permutation(O.begin(), O.end()));
}

int main() {
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    int a = order(P);
    int b = order(Q);

    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N-1)]

ans = []
for i in range(N-1):
    t = 0
    for c,s,f in src[i:]:
        if t <= s:
            t = s+c
        else:
            t += (-t%f) + c
    ans.append(t)
ans.append(0)
print(*ans,sep='\n')

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

matrix = list()
vector = list()
result = list()

for i in range(m):
    matrix.append(list(map(int,input().split())))

for i in range(n):
    vector.append(int(input()))
    
for j in range(m):
    suma = 0
    for i in range(n):
        suma += matrix[j][i] * vector[i]
    result.append(suma)

for s in result:
    print(s)


Measured memory_bytes: 6012
import sys
readline = sys.stdin.readline

def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    # A = readline().rstrip().split()
    A = input().split()
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()



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

using namespace std;
typedef long long ll;

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

    int vmin = p[0];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] <= vmin) {
            ans += 1;
            vmin = p[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int diff = b - a;
		int eastTowerHeight = 0;

		for (int i=1; i<=diff; i++){
			eastTowerHeight += i;
		}
		System.out.println(eastTowerHeight - b);
	}
}


Measured memory_bytes: 22996
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) (a*a)
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 100005;
LL sx[N], sy[N];
LL a[3*N];
int main() {
	int n;
	scanf("%d", &n);
	REP(i, 3*n)scanf("%lld", &a[i]);
	priority_queue<LL, vector<LL>, greater<LL>> qx;
	REP(i, n) {
		sx[0] += a[i];
		qx.push(a[i]);
	}
	REP(i, n) {
		sx[i + 1] = sx[i];
		LL tmp = qx.top();
		if (a[i + n] > tmp) {
			qx.pop();
			qx.push(a[i + n]);
			sx[i + 1] += a[i + n] - tmp;
		}
	}
	priority_queue<LL> qy;
	REP(i, n) {
		sy[n] += a[i + 2 * n];
		qy.push(a[i+2*n]);
	}
	REP(i, n) {
		sy[n-i-1] = sy[n-i];
		LL tmp = qy.top();
		if (a[2*n - 1- i] < tmp) {
			qy.pop();
			qy.push(a[2 * n - 1 - i]);
			sy[n - i - 1] += a[2 * n - 1 - i] - tmp;
		}
	}
	LL ret = -1e18;
	REP(i, n + 1) {
		ret = max(ret, sx[i] - sy[i]);
	}
	cout << ret << endl;

	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int cnt_digits(ll n) {
    int cnt = 0;
    while (n) {
        cnt++;
        n /= 10;
    }
    return cnt;
}

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

    int ans = cnt_digits(n);

    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll a = i, b = n/i;
        chmin(ans, max(cnt_digits(a), cnt_digits(b)));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
	double x, y, x1, x2, y1, y2, eps = 0.00001;
	cin >> x1 >> y1 >> x2 >> y2;
	x = fabs(x2 - x1);
	y = fabs(y2 - y1);
	if( x < eps ) {
		cout << fixed << setprecision(5) << y << "\n";
		return 0;
	} else if( y < eps ) {
		cout << fixed << setprecision(5) << x << "\n";
		return 0;
	}

	int c = 0;

	double v = x*x + y*y,
	       d = max(x, y);
	do
	{
		d = (d + v / d ) / 2.0L;
		++c;
	}
	while( c < 5 );

	cout << fixed << setprecision(5) << d << "\n";

	return 0;
}

Measured memory_bytes: 1284
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define DescSort(a) sort(a.begin(),a.end(),std::greater<LL>())
#define Sort(a) sort(a.begin(),a.end())

int main(int argc, const char * argv[]) {

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

	LL N, M;
	LL ans = 0;

	cin >> N >> M;

	vector<LL>X((UI)M);

	for (UI i = 0; i < M; i++) {
		cin >> X.at(i);
	}

	Sort(X);

	vector<LL>L((UI)M - 1, 0);	// 差分

	for (UI i = 1; i < M; i++) {
		L[i - 1] = X[i] - X[i - 1];
	}

	Sort(L);

	for (UI i = 0; i < M - N; i++) {
		ans += L[i];
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 1792