akhauriyash/Code-Regression huggingface dataset:
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int K,n;

lint C[2005][2005];
const int mod=1000000007;

int dp[2005][2005];
void chadd(int& a,int b){
  a+=b;
  if(a>=mod) a-=mod;
}

int brute(int m){
  int perm[15];
  REP(i,m) perm[i]=i;
  int cnt=0;
  do{
    bool ok=false;
    REP(i,1<<m){
      bool fail=false;
      int pv=-1;
      REP(j,m) if(i>>j&1){
        if(pv>perm[j]) fail=true;
        pv=perm[j];
      }
      pv=-1;
      REP(j,m) if(!(i>>j&1)){
        if(pv>perm[j]) fail=true;
        pv=perm[j];
      }
      if(!fail) ok=true;
    }
    if(ok) ++cnt;
  }while(next_permutation(perm,perm+m));
  return cnt;
}

int sum[2005][2005];
int main(){
  REP(i,2005){
    C[i][0]=1;
    REP(j,i) C[i][j+1]=(C[i-1][j+1]+C[i-1][j])%mod;
  }

  cin>>n>>K;
  --K;
  dp[K][0]=1;
  for(int i=K;i>=0;--i) REP(j,K+1){
    chadd(dp[i][j],sum[i+1][j+1]);
    chadd(dp[i][j],dp[i+1][j]);
    sum[i][j]=dp[i][j];
    if(j) chadd(dp[i][j],dp[i][j-1]);
  }
  lint res=0;
  int rest=n-1-K;
  if(rest==0){
    res=dp[0][0];
  }else{
    for(int i=rest;i<n;++i){
      int cons=i-rest;
      lint tmp=C[i-1][rest-1]*dp[cons][cons]%mod;
      res+=tmp;
    }
    res%=mod;
    REP(hoge,rest-1) res=res*2%mod;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 63104
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<cstdio>
#include<ctime>

#define endl '\n'
#define ll long long
#define ull unsigned ll
#define x first
#define y second

using namespace std;

set<char> q;

int main(){
    string x;
    cin>>x;
    for(int i=0;i<x.length();i++){
        q.insert(x[i]);
    }
    bool flag=false;
    for(char i='a';i<='z';i++){
        if(q.find(i)!=q.end())flag=true;
        else{
            cout<<i<<endl;
            goto w;
        }
    }
    if(flag){
        cout<<"None"<<endl;
    }
    w:return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int t;
double hoge=1000;
int ans;

signed main(){
    int n;cin>>n;
    double a;
    cin>>t>>a;
    rep(i,n){
        int h;cin>>h;
        double temp=t-0.006*h;
        if(abs(temp-a)<hoge){
            hoge=abs(temp-a);
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int a,b,c;
  cin >> a >> b;
  rep(i,b-a)c+=i;
  printf("%d",c-a);
}

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

using namespace std;

int main() {

    int d;
    cin >> d;
    if(d == 25) cout << "Christmas" << endl;
    else if(d == 24) cout << "Christmas Eve" << endl;
    else if(d == 23) cout << "Christmas Eve Eve" << endl;
    else if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
counta=0
countb=0
countspec=0
re=0
for i in range(n):
    s=input()
    re+=s.count("AB")
    if (s[0]=='B') and s[len(s)-1]=='A':
        countspec+=1
    else:
        if s[0]=='B':
            countb+=1
        else:
            if (s[len(s)-1]=='A'):
                counta+=1
if countspec>=1:
    re+=countspec-1
if countspec>=1:
    if counta>=1:
        counta-=1
        re+=1
    if countb>=1:
        countb-=1
        re+=1
re+=min(counta,countb)
print(re)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  rep(i, l, r + 1) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll N;
  cin>>N;
  if(N%2==0){
    cout<<N/2-1<<endl;
  }else{
    cout<<N/2<<endl;
  }
  return 0;
}


Measured memory_bytes: 888
def solve():
     n,lim = map(int,input().split())
     que = []
     for i in range(n):
          ni,ti = input().split()
          que.append([ni,int(ti)])
          
     time = 0
     while que != []:
          now = que.pop(0)
          if now[1] <= lim:
               time += now[1]
               print(now[0],time)
          else:
               now[1] -= lim
               time += lim
               que.append(now)
solve()


Measured memory_bytes: 13020
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,j,k,N;

        int[] ans=new int[(int)1e5];
        for(i=1;i<=100;i++)
        {
            for(j=1;j<=100;j++)
            {
                for(k=1;k<=100;k++)
                {
                    int sum=i*(i+j+k)+j*(j+k)+k*k;
                    ans[sum]++;
                }
            }
        }
        N=Integer.parseInt(br.readLine().trim());
        StringBuilder sb=new StringBuilder();
        for(i=1;i<=N;i++) sb.append(ans[i]).append("\n");
        System.out.println(sb);
    }
}

Measured memory_bytes: 33184
import java.util.Scanner;
import java.util.Arrays;

class Main {
	private static	int num;
	private static	int[]  array;
	
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		num = scanner.nextInt();//要素数
		array = new int[num];
		//配列作成
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
		}
		//計算結果を出力
		System.out.println( cost() );
		
		scanner.close();
	}
	//最小コスト
	public static int cost(){ 
		int sorted[] = array.clone();		//クローンを作って
        Arrays.sort(sorted);			//昇順にしておいて比べる
		int mincost = 0;
		int sub;
		int comp = 0;

		for(int i = 0; i < num; i ++ ){
			comp = indexOf(sorted[i]);		//比較結果
            int count = 0;
			//比較結果によって中へ
            while (comp > i) {
                count ++;								//whileの中に入った数
                sub = indexOf(sorted[comp]);	//比較結果
                mincost += array[sub];
                int work = array[comp];
                array[comp] = array[sub];
                array[sub] = work;
                comp = sub;								//比較対象をずらしていく
            }
			//値の小さいほうをコストに
            mincost += Math.min(sorted[i] * count,
            		sorted[i] * 2 + sorted[0] * (count + 2));
        }
		return mincost;
	}
	
	public static int indexOf(int comp) {
        //一致した場所を返し、一致しなかったら-1
		for (int i = 0; i < num; i++) {
            if (array[i] == comp) {
                return i;
            }
        }
        return -1;
    }
}


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

int main() {
	int n;
	cin >> n;
	string ans = "NO";
	if (n == 3 || n == 5 || n == 7) {
		ans = "YES";
	}
	cout << ans;
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

constexpr ll MOD = 1'000'000'007;
int N, K;
Combinatorics<ll> comb(5000, MOD);

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

    std::cin >> N >> K;

    for(int i=1;i<=K;++i){
        ll res = 0;

        if(N - K - (i - 1) >= 0){
            res = comb.nCk(K - 1, i - 1) * comb.nHk(i + 1, N - K - (i - 1)) % MOD;
        }
        
        std::cout << res << std::endl;
    }
}


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

int main()
{

    int n;
    cin >> n;
    vector<int> DP(n, 0);
    int height [n];

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

    DP[1]=abs(height[1]-height[0]);

    for (int i=2;i<n;i++){
        DP[i] = min(abs(height[i]-height[i-1]) + DP[i-1], abs(height[i]-height[i - 2])+DP[i-2]);
    }

    cout<<DP[n-1];
}


Measured memory_bytes: 4012
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;

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

int main(){
	int n, m;
	cin>>n;
	vl a(n); 
	rep(i, n) cin>>a[i];
	cin>>m;
	vl b(m), c (m);
	rep(i, m) cin>>b[i];
	rep(i, m) cin>>c[i];

	sort(all(a));
	vl s(n+1);
	rep(i, n) s[i+1] = s[i]+a[i];

	for(int i = 0; i < m; i++){
		auto it = upper_bound(all(a), b[i]) - a.begin();
		//cout<<s[it]<<" ";
		if(s[it] >= c[i]) printf("Yes\n");
		else printf("No\n");
	}	
}

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

int getRank(char c){
	if(c == 'S') return 0;
	if(c == 'H') return 1;
	if(c == 'C') return 2;
	return 3;
}
int main(){
	int n;
	int cards[4][14] = {};
	char rank[] = {'S', 'H', 'C', 'D'};
	
	cin >> n;
	for(int i=0; i<n; i++){
		char c;
		int r;
		
		cin >> c;
		cin >> r;
		
		cards[getRank(c)][r] = 1;
	}
	for(int i=0; i<4; i++){
		for(int j=1; j<=13; j++){
			if(cards[i][j] == 0){
				cout << rank[i] << " " << j << "\n";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
from collections import defaultdict
n = int(input())

ij = defaultdict(int)
ji = defaultdict(int)

As = list(map(int, input().split()))
for j in range(n):
  ij[j+1+As[j]] += 1
  ji[j+1-As[j]] += 1
keys = set(ji.keys()) | set(ij.keys())
print(sum(ij[k] * ji[k] for k in keys if k > 1))

Measured memory_bytes: 96964
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ful = 0
for i in range(n):
  ful += b[a[i]-1]
  if(i < n-1):
    if (a[i+1] - a[i]) == 1:
      ful += c[a[i]-1]

print(ful)

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

using namespace std;

const int N = 1e5 + 5;

int n, A[N], g;

int main()
{
	scanf("%d", &n);
	for(int i = 0 ; i < n ; ++i)	scanf("%d", A + i);
	g = A[0];
	for(int i = 1 ; i < n; ++i)
		g = __gcd(g, A[i]);
	printf("%d\n", g);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}

const int MAXX=2e5+5;
const int INF=1e7+5;
const int mod=998244353;

//vector<int> vt;
//pair<int,int> p;
map<int,int> m;
int x,y,l,r,n,len;
int a[2005][2005];
int main() {
	ios::sync_with_stdio(false);
	
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=1;j+i<=n;j++){
			a[j][j+i]=i;
			a[j+i][j]=i;
		}
	}
	a[x][y]=1;a[y][x]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j+i<=n;j++){
			if(j<=x){/*x左*/
				len=(x-j)+1;
				if(len<=i){//可用 
					l=y+(i-len);
					r=y-(i-len);
					if(l>=1&&l<=n){
						a[j][l]=min(a[j][l],i);
						a[l][j]=min(a[l][j],i);
					}
					if(r>=1&&r<=n){
						a[j][r]=min(a[j][r],i);
						a[r][j]=min(a[r][j],i);
					}
				}
			}else if(j>x&&j<y){
				len=(j-x)+1;
				if(len<=i){//可用 
					l=y+(i-len);
					r=y-(i-len);
					if(l>=1&&l<=n){
						a[j][l]=min(a[j][l],i);
						a[l][j]=min(a[l][j],i);
					}
					if(r>=1&&r<=n){
						a[j][r]=min(a[j][r],i);
						a[r][j]=min(a[r][j],i);
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			m[a[i][j]]++;
		}
	}
	for(int i=1;i<n;i++){
		cout<<m[i]/2<<endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 16000
import numpy as np

N = int(input())
A = []
for i in range(N):
        a = int(input())
        A.append(a)
 
idx = np.argmax(np.array(A))
idx2 = np.argmax(np.array(A[:idx] + A[idx+1:]))
if idx2 >= idx:
        idx2 += 1

for i in range(N):
        if i != idx:
                print(A[idx])
        else:
                print(A[idx2])


Measured memory_bytes: 24640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi A(n);
  for(auto &a:A){cin>>a;a--;}
  ll now = 0;
  vi li;
  vi vis(222222);
  vis[0] = 1;
  li.pb(0);
  ll cnt = 1;
  while(true){
    now = A[now];
    if(cnt == k){
      cout<<now+1<<endl;return 0;}
    //cout<<now<<endl;
    if(vis[now]){
      break;
    }
    vis[now] = ++cnt;
    li.pb(now);
  }
  k-=vis[now]-1;
  k%=li.size()-(vis[now]-1);
  // cout<<li.size()<<endl;
  // cout<<k<<endl;
  cout<<li[vis[now]-1+k]+1<<endl;
  return 0;
}


Measured memory_bytes: 8636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int a, b; cin >> a >> b;
    cout << (a % 500 <= b ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    set<ll> st;
    rep(i,n){
        ll a;
        cin >> a;
        if(st.count(a)){
            st.erase(a);
        }
        else{
            st.insert(a);
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 8244
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}

n=int(input())
if n%2==1:
    print(2*n)
else:
    print(n)

Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <unordered_map>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define ll long long
#define INF ((1<<30)-1)
#define NEG (-1)
#define MOD 1000000007
#define MAXN 100100
#define EPS 1e-9
#define INFLL 1e18
using namespace std;
FILE *in,*out;

int N,M,K;

int read()
{
    int i,j,k;
    fscanf(in,"%d%d",&N,&M);
    printf("%d\n",(N-1)*(M-1));
    
    return 0;
}

int main()
{
    // in = fopen("A.in","r");
    // out  = fopen("A.out","w");
    in = stdin;
    out = stdout;
    read();
    return 0;
}
//////////// Local Snippets
// forx
// fory
// vectorx
// pairx
// sizex

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i, 0, n) cin >> h[i];

  ll ans = 0;
  vector<ll> c(n, 0);
  bool ok = false;
  while(1){
    rep(i, 0, n){
      if(c[i] < h[i]){
        if(ok == false){
          ans++;
          ok = true;
        }
        c[i]++;
      }else ok = false;
    }


    bool end = true;
    rep(i, 0, n){
      if(h[i] != c[i]) end = false;
    }
    if(end) break;
    ok = false;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
ope = {"+": lambda a, b: a + b, "-": lambda a, b: b - a, "*": lambda a, b: a * b, "/": lambda a, b: a / b}
stack =[]

for i in input().split():
    if i in ope:
        stack.append(ope[i](stack.pop(),stack.pop()))
    else:
        stack.append(int(i))

print(stack[0])

Measured memory_bytes: 7728
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


A = LIR(3)
n = I()
for _ in range(n):
    a = I()
    for i in range(3):
        for j in range(3):
            if A[i][j] == a:
                A[i][j] = 0

flg = 0
for i in range(3):
    if not sum(A[i]):
        flg = 1

for i in range(3):
    ret = 0
    for j in range(3):
        ret += A[j][i]
    if ret == 0:
        flg = 1

ret = 0
for i in range(3):
    ret += A[i][i]
if ret == 0:
    flg = 1

ret = 0
for i in range(3):
    ret += A[i][2 - i]

if ret == 0:
    flg = 1


if flg:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 39024
#include<bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;

const int N=1002;
const int M=1002;
int dp[N][M]; int h; char arr[N][M]; int brr[M]; int crr[M]; 
int INF=10000000000000000;
int w;

int go(int height, int width){
	if(height==h && width==w)
	return 1;
	
	if(dp[height][width]!=-1)
	return dp[height][width];
	
	int ans=0;
	if(arr[height+1][width]=='.')
	ans=go(height+1,width);
	if(arr[height][width+1]=='.')
	ans=(ans%MOD+go(height,width+1)%MOD)%MOD;
	
	return dp[height][width]=ans;
}

#undef int
int main(){
	#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t=1;
	while(t--){
		cin >> h >> w;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++)
			cin>>arr[i][j];
		}
		memset(dp,-1,sizeof(dp));
		cout<<go(1,1);
	}
	return 0;
}


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

using ll=long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 105, MAX_V = 1e5+10;
int N, W;
ll dp[MAX_V];
int w[MAX_N];
int v[MAX_N];

void solve()
{
	memset(dp, 0x3f, sizeof(dp));
	dp[0]=0;
	for(int i=0; i<N; ++i){
		for(int j=MAX_V; j>= v[i]; --j){
			dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
		}
	}
	int ans = 0;
	for(int i=0; i<= MAX_V; ++i) if(dp[i] <= W) ans = i;
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> W;
	for(int i=0;i<N;++i) cin >> w[i] >> v[i];
	solve();
	return 0;
}

Measured memory_bytes: 1024
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

auto cmp = [&](pii &p, pii &q)
{
    return p.S<q.S;
};
void solve()
{ 
    int n; cin>>n;
    vector<pii> p(n);
    rep(i,0,n) cin>>p[i].F>>p[i].S;
    sort(all(p),cmp);
    ll time = 0;
    rep(i,0,n)
    {
        time+=p[i].F;
        if(time>p[i].S)
        {
            cout<<"No"; return;
        } 
    }    
    cout<<"Yes";
} 
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> count(N);
	for (auto i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		++count[a - 1];
		++count[b - 1];
	}

	for (auto i = 0; i < N; ++i)
	{
		cout << count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
li = []
l_dic={}
counter = 0
n = int(input())
for i in range(n):
    l = "".join(sorted(list(input())))
    if l in l_dic.keys():
        l_dic[l] += 1
        
    else:
        l_dic[l] =1
    
for d in l_dic.values():
    counter+=(d-1)*d*0.5
print(int(counter))

Measured memory_bytes: 17808
#include <cstdio>

int main() {
    int a, b, c, x = 0;
    scanf("%d%d%d", &a, &b, &c);
    for(int i = a; i <= b; i++) {
        if(c % i == 0) {
            x++;     
        }
    }
    printf("%d\n", x);
}


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

signed main()
{
    showoff;
    int n,l,mi = mod,ts = 0;
    cin >> n >> l;
    FOR(i,1,n+1)ts += l+i-1;
    FOR(i,1,n+1)if(abs(l+mi-1) > abs(l+i-1))mi = i;
    cout << ts-(l+mi-1);
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 256
// Problem: C - Repsept
// Contest: AtCoder - AtCoder Beginner Contest 174
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//===========================================================

int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}

//===========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897932384626433832795;
const ll mod = 1000000007LL;
const int INF = 1000000000;
const ll LINF = 1000000000000000000LL;

int main() {
	TEZ;

	ll n;
	cin >> n;

	ll s = 7;

	for (int i = 1; i <= n; i++) {
		if (s % n == 0) {
			cout << i << endl;
			return 0;
		}

		s = (s * 10 + 7) % n;
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'
 
 
 
int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep (i, n) {
    cin >> a[i];
  }
 
  rep (_, n - 1) {
    sort(all(a));
    double x = a[0], y = a[1];
    a.erase(a.begin());
    a.erase(a.begin());
    a.push_back((x + y) / 2.0);
  }
  Sp(a[0]);
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			int b = sc.nextInt();
			int e = sc.nextInt();
			int k = sc.nextInt();
			int res = 0;
			for(int j = b; j < e; j++)
				if(a[j] == k) res++;
			System.out.println(res);
		}
	}
}



Measured memory_bytes: 37952
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

	string a;

	cin >> a;
	if (a == S[0]) {
		cout << 7 << endl;
	}
	if (a == S[1]) {
		cout << 6 << endl;
	}
	if (a == S[2]) {
		cout << 5 << endl;
	}
	if (a == S[3]) {
		cout << 4 << endl;
	}
	if (a == S[4]) {
		cout << 3 << endl;
	}
	if (a == S[5]) {
		cout << 2 << endl;
	}
	if (a == S[6]) {
		cout << 1 << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

typedef string::const_iterator State;
int countMinus(State&);
int negative(int,int);
int number(State&);
int factor(State&);
int expression(State&);

int p, q, r;

int countMinus(State &begin){
    int ng = 0;
    while(*begin == '-'){
        ng++;
        begin++;
    }
    return ng;
}

int negative(int ret, int ng){
    if(ng % 2){
        if(ret == 0) ret = 2;
        else if(ret == 2) ret = 0;
    }
    return ret;
}

// ??°??????????????????????????????????????°????????????
int number(State &begin) {
    int ret = 0;
    if(*begin == 'P') ret = p;
    else if(*begin == 'Q') ret = q;
    else if(*begin == 'R') ret = r;
    else if(isdigit(*begin)) ret = *begin - '0';
    else return 0;

    begin++;
    return ret;
}

// ??¬??§?????°???????????????????????????????????????????????????
int factor(State &begin) {
    int ng = countMinus(begin);
    if (*begin == '(') {
        begin++; // '('????£???°??????
        int ret = expression(begin);
        begin++; // ')'????£???°??????
        return negative(ret, ng);
    } else {
        return negative(number(begin), ng);
    }
    return -1;
}

// ?????????????????????????????????????????????????????????????????????
int expression(State &begin) {
    int ret = factor(begin);

    for (;;) {
        if (*begin == '+') {
            begin++;
            ret = max(ret, factor(begin));
        } else if (*begin == '*') {
            begin++;
            ret = min(ret, factor(begin));
        } else {
            break;
        }
    }

    return ret;
}


int main(){
    string s;
    while(cin >> s, s[0] != '.'){
        int cnt = 0;
        rep(i,3){
            rep(j,3){
                rep(k,3){
                    State tmp = s.begin();
                    p = i; q = j; r = k;
                    if(expression(tmp) == 2){
                        //cout << p << ' ' << q << ' ' << r << endl;
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
}

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

class Node {
public:
  int key;
  Node* left;
  Node* right;
  Node(int key) {
    this->key = key;
    this->left = NULL;
    this->right = NULL;
  }
  void append_left(Node* left) {
    this->left = left;
  }
  void append_right(Node* right) {
    this->right = right;
  }
};

void insert(Node* root,Node* z) {
  Node* cur = root;
  Node* x = root;
  while(cur != NULL) {
    x = cur;
    if(z->key > cur->key) {
      cur = cur->right;
    }
    else {
      cur = cur->left;
    }
  }

  if(z->key > x->key) {
    x->append_right(z);
  }
  else {
    x->append_left(z);
  }
}

void print_crawl_preorder(Node* node) {
  cout << " " << node->key;
  if(node->left != NULL) {
    print_crawl_preorder(node->left);
  }
  if(node->right != NULL) {
    print_crawl_preorder(node->right);
  }
  return;
}
void print_crawl_inorder(Node* node) {
  if(node->left != NULL) {
    print_crawl_inorder(node->left);
  }
  cout << " " << node->key;
  if(node->right != NULL) {
    print_crawl_inorder(node->right);
  }
  return;
}

int main() {
  int n; cin >> n;
  Node* parent = NULL;
  for(int i=0;i<n;i++) {
    string command; cin >> command;
    if(command == "insert") {
      int key; cin >> key;
      if(parent == NULL) {
        parent = new Node(key);
      }
      else {
        Node* z = new Node(key);
        insert(parent,z);
      }
    }
    else if(command == "print") {
      print_crawl_inorder(parent); cout << endl;
      print_crawl_preorder(parent); cout << endl;
    }
  }
}

Measured memory_bytes: 16840
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


bool foo(char c) {
  return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < (int)S.size(); i++) {
    if (foo(S.at(i))) cnt += 1;
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, K;
  cin >> N >> K;
  VEC<LL> H(N);
  REP(i, 0, N) cin >> H[i];
  sort(ALL(H), greater<LL>());
  LL sum = 0;
  REP(i, K, N) { sum += H[i]; }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
/*
 * created   : 2019-08-04 23:56:25
 * accepted  : 2019-08-04 23:56:25
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  iota(b.begin(), b.end(), 0);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] + 1 != a[i]) {
      cnt++;
    }
  }
  cout << ((cnt == 0 || cnt == 2) ? "YES" : "NO") << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


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

int sum, ans;
signed main(){
    
    int n,m;
    cin >> n >> m;

    map<int,int>mp;
    mp[0] = 1;
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;

        sum+=a;
        ans+=mp[sum%m];
        mp[sum%m]++;
    }

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


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define int unsigned long long
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int32_t main()
{
    FastIO;
    int n,c=0;
    double d,ans;
    cin>>n>>d;
    int x,y;
    while(n--)
    {
        cin>>x>>y;
        ans=sqrt(x*x + y*y);
        if(ans<=d)
        ++c;
    }
    cout<<c;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map<ll, int> mp;
	for (int i = 0; i < n; ++i) {
		ll a;
		cin >> a;
		mp[a]++;
	}
	int ans = 0;
	for (auto c : mp) {
		if (c.second < c.first) ans += c.second;
		else ans += c.second - c.first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9604
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i=a+b,j=c+d;
    if(i>j)
    {
        cout<<"Left"<<endl;
    }
    else
        if(i<j)
    {
        cout<<"Right"<<endl;
    }
    else
    {
        cout<<"Balanced"<<endl;
    }
}


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

using namespace std;

#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
///////

int const N = 3e3 + 41;
int const MOD = 1e9 + 7;

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int n, m;
int d[N][N][2];
int dx[2][2] = {{-1, 0}, {0, -1}};

void solve(){
	cin >> n >> m;
	fi(0, n+1) d[0][i][0] = 1;
	fi(0, m){
		fj(0, n+1){
			fk(0, 2){
				for(int i1=0;i1<2;++i1){
					for(int j1=0;j1<2;++j1){
						int f = j;
						int s = n - j;
						int mask = k;
						f += dx[0][i1];
						s += dx[1][i1];
						if(f < 0 || s < 0) continue;
						if(f == 0) mask = 1;
						++f;++s;
						f += dx[0][j1];
						s += dx[1][j1];

						if(f < 0 || s < 0) continue;
						if(f == 0) mask = 1;
						add(d[i+1][f][mask], d[i][j][k]);
					}
				}
			}
		}
	}

	int ans = 0;
	fi(0, n+1) add(ans, d[m][i][1]);
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

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

using namespace std;

const string Symbol[] = { "101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000" };
const string Alphabet = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string InputStr, BinaryStr,OutputStr;

bool judge(const string& tmp) {

	for (int i = 0; i < 32; i++) {
		if (Symbol[i] == tmp) {
			OutputStr += Alphabet[i];
			return true;
		}
	}
	return false;
}

void convertBinaryToString() {
	int len;
	string tmp;

	len = BinaryStr.size();
	for (int i = 0; i < len; i++) {
		tmp += BinaryStr[i];
		if (tmp.size() > 2) {
			//cout << "tmp:" << tmp << endl;
			if (judge(tmp)) {
				tmp = "";
			}
		}
	}
}

void convertStringToBinary() {
	int len;
	stringstream ss;

	len = InputStr.size();
	for (int i = 0; i < len; i++) {
		switch (InputStr[i]) {
			case ' ' :BinaryStr += "11010"; break;
			case '.' :BinaryStr += "11011"; break;
			case ',' :BinaryStr += "11100"; break;
			case '-' :BinaryStr += "11101"; break;
			case '\'':BinaryStr += "11110"; break;
			case '?' :BinaryStr += "11111"; break;
			default  :ss << bitset<5>(InputStr[i] - 'A');
					  BinaryStr += ss.str();
					  ss.clear();
					  ss.str("");
		}
	}
	//cout << "Binay:" << BinaryStr << endl;
	return;
}

int main() {

	while (getline(cin, InputStr)) {
		//cout << "Input:" << InputStr << endl;
		convertStringToBinary();
		convertBinaryToString();
		cout << OutputStr << endl;
		cin.clear();
		InputStr = BinaryStr = OutputStr = "";
	}

	return 0;
}


Measured memory_bytes: 3132