akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 1e5 + 7;

int ans[N], num;
vector <pi> g[N];

void dfs(int v, int p, int lstc) {
    int cnt = 1;
    for (pi u : g[v])
        if (u.F != p) {
            if (cnt == lstc)
                ++cnt;
            num = max(num, cnt);
            ans[u.S] = cnt++;
            dfs(u.F, v, ans[u.S]);
        }
}

void solve() {
    int n; cin >> n;
    loop(i, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u].pb({v, i});
        g[v].pb({u, i});
    }
    dfs(1, 1, 0);
    cout << num << "\n";
    loop(i, n - 1)
        cout << ans[i] << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

int main() {
    int n; cin >> n;
    double t, a; cin >> t >> a;
    vector<int> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if(abs(a - (t - h[i] * 0.006)) < abs(a - (t - h[ans] * 0.006))) {
            ans = i;
        }
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int lcs[1001][1001];
/*int lcs(string a,string b)
{
    if(a.length()<=0||b.length()<=0)
    {
        return 0;
    }
    else if(a[a.length()-1]==b[b.length()-1])
    {
        return 1+lcs(a.substr(0,a.length()-1),b.substr(0,b.length()-1));
    }
    else
    {
        return max(lcs(a.substr(0,a.length()),b.substr(0,b.length()-1)),lcs(a.substr(0,a.length()-1),b.substr(0,b.length())));
    }
};*/
int main()
{
    int num;
    cin>>num;
    for(int l=0;l<num;l++)
    {

        for(int i=0;i<1001;i++)
            for(int j=0;j<1001;j++)
                lcs[i][j]=0;
        string a,b;
        cin>>a>>b;
        //cout<<lcs(a,b)<<endl;
        for(int i=0;i<a.length()+1;i++)
        {
            for(int j=0;j<b.length()+1;j++)
            {
                if(i==0||j==0)
                {
                    lcs[i][j]=0;
                }
                else if(a[i-1]==b[j-1])
                {
                    lcs[i][j]=lcs[i-1][j-1]+1;
                }
                else
                {
					if(lcs[i][j-1]>lcs[i-1][j])
						lcs[i][j]=lcs[i][j-1];
					else
						lcs[i][j]=lcs[i-1][j];
                }
            }
        }
        cout<<lcs[a.length()][b.length()]<<endl;
    }
}

Measured memory_bytes: 7136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
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; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<string>
using namespace std;
int n,k,q,y,a[2001],b[2001],t,ll,s[2001],ss,ans=2e9;
bool cmp(int a,int b){
  return a<b;
}
int main(){
  scanf("%d %d %d",&n,&k,&q);
  for(register int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  for(register int j=1;j<=n;j++){
  	y=a[j];//枚举能被删除的最小元素y
  	memset(s,0,sizeof(s));
  	ss=0;
	t=0;
	for(register int i=1;i<=n+1;i++){
  	   if(i==n+1||a[i]<y){//如果a[i]为一段的边界
		 sort(b+1,b+t+1,cmp);
		 ll=t-k+1;//当前这段能删的数的个数 
		 for(register int l=1;l<=ll;l++)
		    s[++ss]=b[l];//把能删的数存在s数组里
		 memset(b,0,sizeof(b));
		 t=0;//清空b数组 
	   }
	   else{
	   	 b[++t]=a[i];//不是边界就加入到当前这段 
	   }
	}
	if(ss<q){//如果能被删的数不足q个，就直接枚举下个y 
	  continue;
	}
	  sort(s+1,s+ss+1,cmp);
	  //printf("%d %d\n",s[q],y);
	  ans=min(ans,s[q]-y);//s[q]就是x,这里是更新ans
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string a, s, c;
    cin >> a >> s >> c;
    cout << "A" << s[0] << "C" << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> m;
    for(auto & b: a){
        cin>>b;
        m[b]++;
    }
    sort(a.begin(),a.end());
    vector<bool> el(1000050);
    int count = 0;
    for(int i=0;i<n;++i)if(!el[a[i]]){
        if(m[a[i]] == 1)count++;
        for(int j=a[i];j<=1000005;j+=a[i]){
            el[j] = true;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	
	int i;
	for (i = 0; i < n && i <= 10000; i += 1000);
	if (n == 0)
		cout << 0 << endl;
	else
		cout << i - n << endl;

	return 0;
}

Measured memory_bytes: 3640
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){
    string a; cin>>a;
    if(a == "ABC") cout<<"ARC";
    else cout<<"ABC";
    return 0; 
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.size()/2; i++) if(s[i] != s[s.size() - i - 1]) cnt++;
    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char a[100005];
int main(){
    while(~scanf("%s",a)){
        int n=strlen(a);
        int p=1;
        int i=n;
        while(i>0){
            if(a[i-1]=='r'&&a[i-2]=='e'&&a[i-3]=='m'&&a[i-4]=='a'&&a[i-5]=='e'&&a[i-6]=='r'&&a[i-7]=='d'){
                i=i-7;
            }
            else{
                if(a[i-1]=='r'&&a[i-2]=='e'&&a[i-3]=='s'&&a[i-4]=='a'&&a[i-5]=='r'&&a[i-6]=='e'){
                    i=i-6;
                }
                else{
                    if(a[i-1]=='m'&&a[i-2]=='a'&&a[i-3]=='e'&&a[i-4]=='r'&&a[i-5]=='d'){
                        i=i-5;
                    }
                    else{
                        if(a[i-1]=='e'&&a[i-2]=='s'&&a[i-3]=='a'&&a[i-4]=='r'&&a[i-5]=='e'){
                            i=i-5;
                        }
                        else{
                            p=0;
                            break;
                        }
                    }
                }
            }
        }
        if(p){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int A, B, C, D;
    cin >> A >> B >> C >> D;
    int ans1 = A * B;
    int ans2 = C * D;
    
    if (ans1 > ans2)
    {
    cout << ans1 <<endl;
    }
    if(ans1 < ans2)
    {
        cout << ans2 <<endl;
    }
    if(ans1 == ans2)
    {
        cout << ans1 << endl;
    }
    
}


Measured memory_bytes: 256
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a, b, c = sc.next
//  val list = List.fill(3)(sc.nextInt)

  val ans = if (a.last == b.head && b.last == c.head) YES else NO

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25424
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}
 
/* brownsands :Arpit */			

void solve()
{ int n,m,i,s=0,x,cnt=0;
  cin >> n >> m;int A[n+5];
  for(i=1;i<=n;i++)
  {
    cin >> A[i];
    s+=A[i];
  }
  x=s/(4*m);
  for(i=1;i<=n;i++)
  {
    if((A[i]*4*m)>=s)cnt++;
  }
  if(cnt>=m)cout<<"Yes";else cout<<"No";
}
signed main()
{ 
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int test=0,t;
  //cin>>t;
    t=1;
   while(test++ <t){         
   	//cout<<"Case# "<<test<<": ";
        solve();}
  //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
} 
               
			
 

				
		
		




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

int main() {
 int N,K;
 string S;
 cin >> N >> K >> S ;
 if(S[K-1] == 'A'){
 	 S[K-1] = 'a' ;
 }
 else if(S[K-1] == 'B'){
 	 S[K-1] ='b';
 }
else{
	 S[K-1] = 'c';
}
cout << S << endl;
}

Measured memory_bytes: 256
n=int(input())
xy=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append([x,y])
from itertools import permutations
ans=[]
for a in list(permutations(xy)):
    d=0.0
    for i in range(len(a)-1):
        d+=((a[i+1][0]-a[i][0])**2+(a[i+1][1]-a[i][1])**2)**0.5
    ans.append(d)
print(sum(ans)/len(ans))


Measured memory_bytes: 9204
#include <cstdio>
#include <vector>
#include <cmath>
const double pi = acos(-1);
int TC, N, M, W, NK, ref[200003], cnt[200003], L, p[524288];
long long ans[200003];
long long POWER(long long a, long long b, long long c)
{
	long long r = 1;
	for (; b; b >>= 1)
	{
		if (b & 1)
			r = r * a % c;
		a = a * a % c;
	}
	return r;
}
void NK_MAKE()
{
	std::vector < int > V;
	int tmp = M - 1;
	for (int i = 2; i * i <= tmp; i++)
		if (tmp % i == 0)
		{
			V.push_back((M - 1) / i);
			do tmp /= i; while (tmp % i == 0);
		}
	if (tmp > 1)
		V.push_back((M - 1) / tmp);
	NK = 0;
	bool ok;
	do
	{
		NK++;
		ok = true;
		for (std::vector < int >::iterator i = V.begin(); ok && i != V.end(); i++)
			if (POWER(NK, *i, M) == 1)
				ok = false;
	}
	while (!ok);
}
struct com
{
	double x, y;
	friend inline com operator + (const com &a, const com &b)
	{
		return (com) { a.x + b.x, a.y + b.y };
	}
	friend inline com operator - (const com &a, const com &b)
	{
		return (com) { a.x - b.x, a.y - b.y };
	}
	friend inline com operator * (const com &a, const com &b)
	{
		return (com) { a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x };
	}
}
a[524288];
void FFT(com *a, int f = 1)
{
	if (f == 1)
		for (int i = 1; i < L; i++)
			p[i] = i & 1 ? p[i - 1] | L >> 1 : p[i >> 1] >> 1;
	for (int i = 0; i < L; i++)
		if (i < p[i])
			std::swap(a[i], a[p[i]]);
	for (int i = 1; i < L; i <<= 1)
	{
		com w, wn = (com) { cos(pi / i), sin(pi / i) * f }, x, y;
		for (int j = 0; j < L; j += i + i)
		{
			w = (com) { 1, 0 };
			for (int k = j; k < j + i; k++)
			{
				x = a[k];
				y = a[k + i] * w;
				a[k] = x + y;
				a[k + i] = x - y;
				w = w * wn;
			}
		}
	}
	if (f == -1)
		for (int i = 0; i < L; i++)
			a[i].x /= L;
}
int main()
{
		scanf("%d", &N);
		M = 200003;
		NK_MAKE();
		for (int i = 0, j = 1; i < M - 1; i++, j = j * NK % M)
			ref[j] = i;
		for (int i = 0; i < M; i++)
		{
			cnt[i] = 0;
			ans[i] = 0;
		}
		for (int i = 0, x; i < N; i++)
		{
			scanf("%d", &x);
			cnt[x % M]++;
		}
		L = 1;
		while (L <= M + M - 4)
			L <<= 1;
		for (int i = 0, w = 1; i < M - 1; i++, w = w * NK % M)
			a[i] = (com) { double(cnt[w]), 0 };
		for (int i = M - 1; i < L; i++)
			a[i] = (com) { 0, 0 };
		FFT(a);
		for (int i = 0; i < L; i++)
			a[i] = a[i] * a[i];
		FFT(a, -1);
		for (int i = 0, w = 1; i < L; i++, w = w * NK % M)
			ans[w] += (long long)(a[i].x + 0.5);
		ans[0] = (long long)N * N - (long long)(N - cnt[0]) * (N - cnt[0]);
		for (int i = 0; i < M; i++)
			ans[(long long)i * i % M] -= cnt[i];
		long long Ans = 0;
		for (int i = 0; i < M; i++)
			Ans += i * ans[i] >> 1;
		printf("%lld\n", Ans);
	return 0;
}

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

int N, m, x, cnt = 0;

int main()
{
    scanf("%d", &N);
    m = N;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &x);
        if (x <= m) cnt++;
        m = min(x, m);
    }
    printf("%d\n", cnt);
    return 0;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    vector<ll> b(n, 0);
    map<ll, ll> mp;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
        if(mp[a[i]] == 2) b.push_back(a[i]);
    }
    sort(b.begin(), b.end(), greater<int>());
    if(mp[b[0]] >= 4) cout << b[0]*b[0] << endl;
    else if(mp[b[1]] < 2) cout << 0 << endl;
    else cout << b[0] * b[1] << endl;
    return 0;
}

Measured memory_bytes: 8048
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.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){
    
    
}

Node treeSearch(Node u, int k){
    
    
}

Node treeSuccessor(Node x){
    
    
}

void treeDelete(Node z){
    Node y; // node to be deleted
    Node x; // child of y
    
    
    
}
*/

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = (Node)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 == NIL) return;
    
    if (u->left != NIL) inorder(u->left);
    
    printf(" %d", u->key);
    
    if(u->right != NIL) inorder(u->right);
    
}

//?????????
void pre_order(Node u){
    if (u == NIL) return;
    
    printf(" %d", u->key);
    if(u->left != NIL) pre_order(u->left);
    if(u->right != NIL) pre_order(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");
            pre_order(root);
            printf("\n");
        } else if ( com[0] == 'd' ){
            scanf("%d", &x);
            /*treeDelete(treeSearch(root, x));*/
        }
    }
    
    return 0;
}

Measured memory_bytes: 24468
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int  long long
#define endl '\n'
int vis[200000];
int ans[200000];
int32_t main()
{
    int n,m;
    cin>>n>>m;
    int p[m];
    string s[m];
    for(int i=0;i<m;i++)
        cin>>p[i]>>s[i];
    set<int> ac;
    for(int i=0;i<m;i++)
    {
        if(s[i]=="AC")
            ac.insert(p[i]);
    }
    cout<<ac.size()<<" ";
    for(int i=0;i<m;i++)
    {
        if(s[i]=="AC")
        {
            vis[p[i]]=1;
            continue;
        }
        if(vis[p[i]]==0)
            ans[p[i]]++;
    }
    int fin=0;
    for(int i=0;i<200000;i++)
    {
        if(vis[i])
            fin+=ans[i];
    }
    cout<<fin;
}

Measured memory_bytes: 12032
// 2020-06-30 23:44:39
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll a, b;
  cin >> a >> b;
  ll la = a * 100 / 8 + !!(a * 100 % 8), ra = (a * 100 + 99) / 8;
  ll lb = b * 100 / 10 + !!(b * 100 % 10), rb = (b * 100 + 99) / 10;
  if(ra < lb || rb < la) cout << -1 << '\n';
  else cout << max(la, lb) << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3640
// Lucky7 Program
// 16,Apl,2020

#include <iostream>

int main(void)
{
	int n, a, b, c;
	
	std::cin >> n;
	a = n / 100;
	b = (n - a*100)/10;
	c = n - 100*a - 10*b;

	if ((a==7) || (b==7) || (c==7)) {
		std::cout << "Yes";
	} else {
		std::cout << "No";
	}

	return 0;

}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){
  if (n==0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x, y, ans;
  x = 1;
  y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1; 
  }
  ans = x / y;
  return ans;
}

int main(){
  int n, a, b;
  mint ans;
  cin >> n >> a >> b;
  ans = f(n) - 1 - choose(n,a) - choose(n,b);
  cout << ans.x;
  return 0;
}

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

int main() {
  int H , W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++){
    cin >> a.at(i);
  }
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i ++){
    cout << "#" << a.at(i) << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++){
    cout << "#";
  }
}

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

int main(){
  int N,O;
  cin >> N;
  if(N<=111){
    O=111;
  }else if(N<=222){
    O=222;
  }else if(N<=333){
    O=333;
  }else if(N<=444){
    O=444;
  }else if(N<=555){
    O=555;
  }else if(N<=666){
    O=666;
  }else if(N<=777){
    O=777;
  }else if(N<=888){
    O=888;
  }else if(N<=999){
    O=999;
  }
  cout << O <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

struct UnionFind {
  vll par;
  vll wcnt;
  vll bcnt;
  ll cnt;
  UnionFind(ll N, vector<string>& mp) : par(N), wcnt(N, 0), bcnt(N, 0), cnt(N) {
    for (ll i = 0; i < N; i++) {
      par[i] = i;
      ll w = (ll)mp[0].size();
      if (mp[i / w][i % w] == '.')
        wcnt[i] = 1;
      else
        bcnt[i] = 1;
    }
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll get_wcnt(ll x) { return wcnt[find(x)]; }
  ll get_bcnt(ll x) { return bcnt[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    ll sizex = wcnt[x] + bcnt[x];
    ll sizey = wcnt[y] + bcnt[y];
    if (sizex < sizey) swap(x, y);
    par[y] = x;
    wcnt[x] += wcnt[y];
    bcnt[x] += bcnt[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> mp(h);
  rep(i, h) { cin >> mp[i]; }

  UnionFind uf(h * w, mp);
  rep(i, h) rep(j, w) rep(k, 4) {
    ll y = i + dy[k];
    ll x = j + dx[k];
    bool cond = 0 <= x && x < w && 0 <= y && y < h;
    if (!cond) continue;
    if (mp[y][x] != mp[i][j]) {
      uf.unite(x + y * w, j + i * w);
    }
  }
  ll ans = 0;
  rep(i, h * w) {
    if(i == uf.find(i)){
      ans += uf.get_bcnt(i) * uf.get_wcnt(i);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4224
/*Name:- Prince Soni
College:- Jalpaiguri Government Engineering College*/
 
// this is how we declare a constant value
// const int xyz=2500000;
 
 
#include <bits/stdc++.h> 
using namespace std; 
 
#define ll long long int
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fr(i,n) for(ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define endl "\n"
 
int a[100005][4];
int dp[100005][4];
int n;

int max_happiness(int ind,int flag)
{
    if(ind==n)return 0;
    
    if(dp[ind][flag]!=-1) return dp[ind][flag];

    int maxi=0;
    if(flag==0)
    {
        maxi=max(maxi,a[ind][1]+max_happiness(ind+1,1));
        maxi=max(maxi,a[ind][2]+max_happiness(ind+1,2));
        maxi=max(maxi,a[ind][3]+max_happiness(ind+1,3));
    }
    else if(flag==1)
    {
        maxi=max(maxi,a[ind][2]+max_happiness(ind+1,2));
        maxi=max(maxi,a[ind][3]+max_happiness(ind+1,3));
    }
    else if(flag==2)
    {
        maxi=max(maxi,a[ind][3]+max_happiness(ind+1,3));
        maxi=max(maxi,a[ind][1]+max_happiness(ind+1,1));
    }
    else
    {
        maxi=max(maxi,a[ind][1]+max_happiness(ind+1,1));
        maxi=max(maxi,a[ind][2]+max_happiness(ind+1,2));
    }
    return dp[ind][flag]=maxi;
}
 
int main() 
{ 
    fio;
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(ll i=0;i<n;i++)
    {
        for(ll j=1;j<=3;j++)
        cin>>a[i][j];
    }
    cout<<max_happiness(0,0);
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char O[100], E[100];
	scanf("%s%s", O, E);

	for (int i = 0; i < strlen(E); i++) {
		printf("%c%c", O[i], E[i]);
	}
	if (strlen(O) != strlen(E)) {
		printf("%c", O[strlen(O) - 1]);
	}












}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}


int main(void) {
	int n;
	cin >> n;
	int count;
	int ans = 0;
	for (int i = 1; i <= n; i+=2) {
		count = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) {
				count++;
			}
		}
		if (count == 8) {
			ans++;
		}
		
	}
	cout << ans;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int r, c;
    int r_sum, c_sum;
    vector<vector<int>> a;

    cin >> r >> c;

    a.resize(r + 1, vector<int>(c + 1));

    for (int i = 0; i < r; i++)
    {
        r_sum = 0;
        for (int j = 0; j < c; j++)
        {
            cin >> a[i][j];
            r_sum += a[i][j];
        }
        a[i][c] = r_sum;
    }

    for (int i = 0; i < c + 1; i++)
    {
        c_sum = 0;
        for (int j = 0; j < r; j++)
        {
            c_sum += a[j][i];
        }
        a[r][i] = c_sum;
    }

    for (int i = 0; i < r + 1; i++)
    {
        for (int j = 0; j < c + 1; j++)
        {
            if (j == c)
            {
                cout << a[i][j];
            }
            else
            {
                cout << a[i][j] << " ";
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> a_sum_left(n);
    vector<ll> a_sum_right(n);

    a_sum_left[0] = a[0];  
    a_sum_right[0] = a[n - 1];  
    _rep(i, 1, n){
        a_sum_left[i] = gcd(a_sum_left[i - 1], a[i]);
        a_sum_right[i] = gcd(a_sum_right[i - 1], a[(n - 1) - i]);
    }
    /*rep(i, n){
        cout << a_sum_left[i] << " " << a_sum_right[i] << endl;
    }*/
    ll ans = 0;
    ll ans_max = 0;
    rep(i, n){
        if(i == 0)ans = a_sum_right[n - 2];
        else if(i == n - 1)ans = a_sum_left[n - 2];
        else ans = gcd(a_sum_left[i - 1], a_sum_right[(n - 3) - (i - 1)]);
        ans_max = max(ans, ans_max);
    }
    cout << ans_max << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main() {
	int N, K,h;
	int X, Y = 0;

	scanf("%d", &N);
	scanf("%d", &K);
	scanf("%d", &X);
	scanf("%d", &Y);


	if (N <= K) {
		h = N * X;
	}
	else {
		h = K * X + (N - K) * Y;
	}

	printf("%d", h);

	//printf("%d %d %d %d", N, K, X, Y);

	return 0;

}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(void){
    string str;
    cin>>str;
    for(int i=0; i<str.length(); i++){
            if(str[i]=='1') str[i]='9';
            else if(str[i]=='9') str[i]='1';
    }
    cout<<str<<endl;
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	cout << N*(N-1)/2 - N/2 << endl;
	int d;
	if (N % 2 == 0) d = N + 1;
	else d = N;
	for (int i = 1; i < N; ++i)
	{
		for (int j = i+1; j <= N; ++j)
		{
			if (i+j != d) cout << i << " " << j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  string S, T;
  cin >> S >> T;
  cout << T << S << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
char s[maxx],s1[maxx],s2[maxx];
int main(){
	scanf("%s",s+1);
    ll k; cin>>k;
    ll n; n=strlen(s+1);
    ll f=0;
    for(int i=2;i<=n;i++){
        if(s[i]!=s[i-1]){
            f=1; break;
        }
    }
    if(!f){
        cout<<n*k/2<<endl;
        return 0;
    }
    ll cnt=0,tot=0,res=0;
    for(int i=2;i<=n;i++){
        if(s[i]==s[i-1]){
            cnt++;
        }else{
            break;
        }
    }
    for(int i=n-1;i;i--){
        if(s[i]==s[i+1]){
            tot++;
        }else break;
    }
    //cout<<tot<<" "<<cnt<<endl;
    for(int i=cnt+2;i<=n-tot;i++){
        if(s[i]==s[i-1]){
            res++,i++;
        }
    }
    //cout<<res<<endl;
    tot++,cnt++;
    if(s[1]==s[n]){
        cout<<res*k+cnt/2+tot/2+(cnt+tot)/2*(k-1)<<endl;
    }else{
        cout<<(res+cnt/2+tot/2)*k<<endl;
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
int A[555][555];

signed main(){
    cin>>H>>W;
    rep(i,H)rep(j,W)cin>>A[i][j];


    vector<tuple<int,int,int,int>>ans;

    int s=0;
    int y=0,x=0;
    while(true){
        int ny,nx;
        int d;
        if(y&1)d=-1;
        else  d=1;
        if(x+d>=0&&x+d<W){
            ny=y;
            nx=x+d;
        }
        else{
            ny=y+1;
            nx=x;
        }
        if(ny==H)break;

        if(A[y][x]&1)s^=1;
        if(s){
            ans.pb(make_tuple(y,x,ny,nx));
        }
        y=ny;x=nx;
    }
    cout<<ans.size()<<endl;
    for(auto &t:ans)cout<<get<0>(t)+1<<" "<<get<1>(t)+1<<" "<<get<2>(t)+1<<" "<<get<3>(t)+1<<endl;
    return 0;
}


Measured memory_bytes: 8560
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int N, page;
        cin >> N;

        if(N%2 == 0){
            page = N / 2;
        }
        else
        {
            page = N / 2 + 1;
        }
        
        cout << page <<endl;
    }

Measured memory_bytes: 256
from sys import stdin

# read data
a_mat = []
for _ in range(3):
  a_mat.append([int(x) for x in stdin.readline().strip().split()])
n = int(stdin.readline().strip())
b_lst = []
for _ in range(n):
  b_lst.append(int(stdin.readline().strip()))
  
op_mat = []
for a in a_mat:
  op_mat.append([x in b_lst for x in a])
op_mat_t = list(map(list, zip(*op_mat)))
  
# tate
if(all(op_mat[0]) or all(op_mat[1]) or all(op_mat[2])):
  print("Yes")
# yoko
elif(all(op_mat_t[0]) or all(op_mat_t[1]) or all(op_mat_t[2])):
  print("Yes")
# naname
elif(all([op_mat[0][0], op_mat[1][1], op_mat[2][2]]) or all([op_mat[0][2], op_mat[1][1], op_mat[2][0]])):
  print("Yes")
else:
  print("No")

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

using namespace std;

int main()
{
    string input_str;
    cin >> input_str;

    vector<char> char_vec;
    for (auto c : input_str) {
        if (c == 'B') {
            if (char_vec.size() > 0) {
                char_vec.pop_back();
            }
        } else {
            char_vec.push_back(c);
        }
    }

    string ans(char_vec.begin(), char_vec.end());

    cout << ans << endl;

    return 0;
}

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

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    vector<pair<int, int>> vec(H*W+1);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int a;
            cin >> a;
            vec[a] = make_pair(i, j);
        }
    }

    vector<long long> d(H*W+1, 0);
    for(int i=D+1; i<=H*W; i++){
        int x1, y1, x2, y2;
        int j = i-D;
        x1 = vec[i].first;
        y1 = vec[i].second;
        x2 = vec[j].first;
        y2 = vec[j].second;
        d[i] = d[i-D] + abs(x1-x2) + abs(y1-y2);
    }

    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
        int L, R;
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long ;


int main() {
    ll n;
    cin >> n;
    vector<int> c(4) ;

    for (int i = 0; i < n; i++)
    {
        string s ;
        cin >> s ;
        if(s=="AC")
            c[0]++ ; 
        else if(s=="WA")
            c[1]++ ; 
        else if(s=="TLE")
            c[2]++ ; 
        else if(s=="RE")
            c[3]++ ; 
    }
     cout << "AC x " << c[0] << endl;
     cout << "WA x " << c[1] << endl;
     cout << "TLE x " << c[2] << endl;
     cout << "RE x " << c[3] << endl;
}

Measured memory_bytes: 3632
/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                                          |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                                          ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll t,h,w,a,b,ans=0;
int main()
{
	optimization();
        cin >> t>>h>>w;
    rep(i,t)
{
cin >> a>>b;
if(a>=h&&b>=w)
ans++;
}
cout<<ans<<endl;
}

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

using namespace std;

inline int read () {
    int ret = 0, t = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') t = -1, c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret * t;
}

int main () {
    long long n, a, b, ans = 0;
    cin >> n >> a >> b;
    ans += (n / (a + b)) * a;
    n %= a + b;
    if (n >= a) ans += a; else ans += n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def class_weight(w):
    if 48.00>=w:
        print("light fly")
    elif 48.00<w<=51.00:
        print("fly")
    elif 51.00<w<=54.00:
        print("bantam")
    elif 54.00<w<=57.00:
        print("feather")
    elif 57.00<w<=60.00:
        print("light")
    elif 60.00<w<=64.00:
        print("light welter")
    elif 64.00<w<=69.00:
        print("welter")
    elif 69.00<w<=75.00:
        print("light middle")
    elif 75.00<w<=81.00:
        print("middle")
    elif 81.00<w<=91.00:
        print("light heavy")
    else:
        print("heavy")
while True:
    try:
        w=float(input())
    except:
        break
    class_weight(w)



Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define lson(v) ((v)<<1)
#define rson(v) (((v)<<1)^1)
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,fa[200005],dep[200005],tf[200005],dp[200005][2],cnt[200005];
vector < int > adj[200005],vs[200005];
map < pii , vector < int > > sor;
priority_queue < pii > vers;
void dfs(int ver,int lsv){
    int xb;
    dep[ver]=(fa[ver]==-1?0:(dep[fa[ver]]+1));
	++cnt[dep[ver]];
	vs[dep[ver]].push_back(ver);
	tf[ver]=lsv;
    for(xb=0;xb<adj[ver].size();++xb){
        dfs(adj[ver][xb],(adj[ver].size()>1)?adj[ver][xb]:lsv);
    }
}
inline int pow(int num,int pw,LL moD){
    LL ret=1,cur=num;
    while(pw){
        if(pw&1) ret=(ret*cur)%moD;
        cur=(cur*cur)%moD;
        pw>>=1;
    }
    return (int)ret;
}
inline int inv(int val,int moD){
	return pow(val,moD-2,moD);
}
map < pii , int > vis;
int main(){
    int xb,x2;
    scanf("%d",&n);
    ++n;
    fa[0]=-1;
    for(xb=1;xb<n;++xb){
        scanf("%d",fa+xb);
        adj[fa[xb]].push_back(xb);
    }
    dfs(0,0);
	LL res=0LL;
	for(xb=0;xb<n;++xb){
		while(!vers.empty()) vers.pop();
		for(x2=0;x2<vs[xb].size();++x2){
			vers.push(mpr(dep[vs[xb][x2]],vs[xb][x2]));
		}
		dp[0][0]=dp[0][1]=0;
		while(!vers.empty()){
			int cv=vers.top().second;
			vers.pop();
			while(vis.count(mpr(xb,cv))){
				cv=vers.top().second;
				vers.pop();
			}
			++vis[mpr(xb,cv)];
			vector < int* > sr;
			LL tot=1LL,ts=1LL;
			dp[cv][1]=0;
			for(x2=0;x2<sor[mpr(xb,cv)].size();++x2){
				sr.push_back(dp[sor[mpr(xb,cv)][x2]]);
				tot*=(LL)(sr.back()[0]+sr.back()[1]);
				tot%=MOD1;
				ts*=(LL)(sr.back()[0]);
				ts%=MOD1;
			}
			for(x2=0;x2<sr.size();++x2){
				LL tv=(LL)inv(sr[x2][0],MOD1)*ts%MOD1*(LL)sr[x2][1]%MOD1;
				dp[cv][1]=(dp[cv][1]+tv)%MOD1;
			}
			if(sr.empty()){
				dp[cv][1]=1;
				tot=2LL;
			}
			dp[cv][0]=(tot-dp[cv][1]+MOD1)%MOD1;
			dp[tf[cv]][0]=dp[cv][0];
			dp[tf[cv]][1]=dp[cv][1];
			if(tf[cv]){
				int nv=fa[tf[cv]];
				vers.push(mpr(dep[nv],nv));
				sor[mpr(xb,nv)].push_back(tf[cv]);
			}
			else break;
		}
		res=(res+(LL)dp[0][1]*(LL)pow(2,n-cnt[xb],MOD1))%MOD1;
	}
	printf("%I64d\n",res);
    return 0;
}

Measured memory_bytes: 262016