akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int vlog[1000010];
int R, C, Q;
vector<vector<vector<int> > > rmq;
int grid[1000010];

inline void setvalue(int r, int c, int v){ grid[r*C+c] = v; }
inline int getvalue(int r, int c){ return grid[r*C+c]; }

void rmq_build()
{
    rmq.clear();
    for(int i = 0; i < R; i++){
        rmq.push_back(vector<vector<int> >());
        for(int k = 0; (1<<k)-1 < C; k++){
            rmq[i].push_back(vector<int>());
            for(int j = 0; j + (1<<k)-1 < C; j++){
                rmq[i][k].push_back(k==0 ? getvalue(i, j) : min(rmq[i][k-1][j], rmq[i][k-1][j+(1<<k-1)]));
            }
        }
    } 
}

inline int rmq_query(int r, int c1, int c2)
{
    int k = vlog[c2-c1+1];
    return min(rmq[r][k][c1], rmq[r][k][c2-(1<<k)+1]);
}

int main()
{
//    freopen("SchoolOfKillifish.in","r",stdin);
    int r1, c1, r2, c2, v;
    for(int i = 1; i <= 1000000; i++) vlog[i] = (int)log2((double)i);
    while(~scanf("%d%d%d", &R, &C, &Q)) {
        bool rot = (R > C);
        int rr = R, cc = C;
        if(rot) swap(R, C);
        for(int i = 0; i < rr; i++){
            for(int j = 0; j < cc; j++){
                scanf("%d", &v);
                if(rot) setvalue(j, i, v);
                else setvalue(i, j, v);
            }
        }
        rmq_build();
        for(int i = 0; i < Q; i++) {
            scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
            if(rot) swap(r1, c1), swap(r2, c2);
            int v = 0x7fffffff;
            for(int j = r1; j <= r2; j++)
                v = min(v, rmq_query(j, c1, c2));
            printf("%d\n", v);
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.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))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string s;
    cin >> s;
    if(s.size() == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2;
        }else{
            cout << -1 << " " << -1;
        }
        return 0;
    }
    REP(i, s.size() - 2){
        if(s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }
    cout << -1 << " " << -1;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 512
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2];
	return 0;
}

Measured memory_bytes: 768
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (A, B, C): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if A <= C && C <= B {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
       
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
       
/* 
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
       
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
       
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
       
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
       
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
       
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

int n;
vector <vector <int>> g;
vector <int> cl;
bool dfs(int v, int p = -1, int c = 0)
{
    cl[v] = c;
    bool f = true;
    for (auto &to : g[v])
    {
        if (to == p)
            continue;
        if (cl[to] == c)
            return false;
        if (cl[to] == -1)
            f = f && dfs(to, v, c ^ 1);
    }
    return f;
}

signed main()
{
    Start();
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            char c;
            cin >> c;
            if (c - '0')
                g[i].pb(j);
        }
    }
    cl.resize(n, -1);
    if (!dfs(0))
        return cout << -1, 0;
    const int INF = 1e9 + 7;
    cl.assign(n, INF);
    vector <int> tcl(n, INF);
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        cl.assign(n, INF);
    cl[i] = 0;
    queue <int> q;
    pair <int, int> p(-1, -1);
    q.emplace(i);
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        p = max(p, mp(cl[v], v));
        for (auto &to : g[v])
        {
            if (cl[to] > cl[v] + 1)
            {
                cl[to] = cl[v] + 1;
                q.emplace(to);
            }
        }
    }
    ans = max(ans, p.first + 1);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 640
// one stroke path
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 9
#define MAX_M 100
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, m;
int e[MAX_M][2];
bool not_visited[MAX_N];

int dfs(int v){
	FOR(i, 1, n+1){
		if(not_visited[i]) break;
		if(i == n) return 1;
	}

	int ret = 0;
	REP(i, m){
		REP(j, 2){
			if(e[i][j] == v && not_visited[e[i][1-j]]){
				not_visited[e[i][1-j]] = false;
				ret += dfs(e[i][1-j]);
				not_visited[e[i][1-j]] = true;
			}
		}
	}
	return ret;
}

signed main(){
	cin >> n >> m;
	REP(i, m) cin >> e[i][0] >> e[i][1];
	REP(i, n+1) not_visited[i] = true;
	not_visited[1] = false;
	int ret = dfs(1);
	cout << ret << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    map<int, int> num;
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        num[ai]++;
    }
    vector<int> divisible = vector<int>(1000100, false);
    int ans = 0;
    for (auto keyval: num) {
        if (keyval.second > 1) {
            for (int i = 1; keyval.first * i < 1000050; i++) {
                divisible[keyval.first * i] = true;
            }
            continue;
        } else {
            if (!divisible[keyval.first]) {
                ans++;
            }
            for (int i = 1; keyval.first * i < 1000050; i++) {
                divisible[keyval.first * i] = true;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 16232
t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(t[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> mod_num(K, 0);
  REP(i,1,N+1) mod_num[i%K]++;
  
  ll ans = 0;
  rep(i,K){
    ll a = i;
    ll b = (K-a)%K;
    ll c = (K-a)%K;
    
    if( (b+c)%K == 0 ){
      ans += mod_num[a] * mod_num[b] * mod_num[c];
    }
  }
  
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define MAX 200005

using namespace std;

ll a[MAX];

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans=0;
	ans=n/(a+b);
	ans*=a;
	n%=(a+b);
	if(n>=a){
		ans+=a;
	}
	else{
		ans+=n;
	}
	cout << ans << endl;
    return 0;
}


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

#define N 100000
#define INF 0x3f3f3f3f

int main() {
	static int aa[N];
	int n, i, i_, x, a, b, c;

	scanf("%d", &n);
	a = i_ = -1;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (a < aa[i]) {
			a = aa[i];
			i_ = i;
		}
	}
	b = INF;
	c = -1;
	for (i = 0; i < n; i++)
		if (i != i_) {
			x = abs(aa[i] - (a + 1) / 2);
			if (b > x) {
				b = x;
				c = i;
			}
		}
	printf("%d %d\n", a, aa[c]);
	return 0;
}

Measured memory_bytes: 512
from math import *
ip=[int(x) for x in input().split()]

a=ip[0]
b=ip[1]
h=ip[2]
m=ip[3]
hd=h*30+m*30/60
md=(m//5)*30+(m%5)*30/5
#print(md)
x=abs(hd-md)
#print(x)
ans=a*a+b*b-2*a*b*cos(radians(x))
#print(ans)
ans=sqrt(ans)
ans=round(ans,20)
f=str(ans)
for i in range(len(f)):
	if f[i]=='.':
		l=i
		break
l=len(f)-l
for i in range(l,20):
	f+='0'

print(f)

Measured memory_bytes: 9540
import sys
sys.setrecursionlimit(10**8)
N = int(input())
num_edges = N-1
edges = [list(map(int, input().split())) for i in range(num_edges)]

adj = [[] for i in range(N+1)]
for ed in edges:
    adj[ed[0]] += [[ed[1], ed[2]]]
    adj[ed[1]] += [[ed[0], ed[2]]]
col_list = [-1 for i in range(N+1)]
def recfun(v, col):
    col_list[v] = col #色を更新
    for ed in adj[v]: #隣接する頂点をみる
        if col_list[ed[0]] == -1: #更新していない場合
            if ed[1] % 2 == 0:
                recfun(ed[0], col) #偶数なら同じ色でその先をみる
            else:
                recfun(ed[0], 1-col) #奇数なら違う色でその先をみる
recfun(1, 0)
for col in col_list[1:]:
    print(col)

Measured memory_bytes: 98632
#include<vector>
#include<iostream>
using namespace std;
template <class data_t>
class dice{
public:
	vector<data_t> field;
	dice(vector<data_t> v);
	void roll(char ch);
	data_t top(){return field[0];}
};
template <class data_t>
dice<data_t>::dice(vector<data_t> v){
	typename vector<data_t>::iterator vi = v.begin();//vector<datat>::iterator???????????§??????????????§???????????¨???????????????
	while(vi!=v.end()){
		field.push_back(*vi);
		vi++;
	}
}
template <class data_t>
void dice<data_t>::roll(char ch){
	data_t tmp;
	switch(ch){
		case 'E':
			tmp = field[0];
			field[0] = field[3];
			field[3] = field[5];
			field[5] = field[2];
			field[2] = tmp;
			break;
		case 'N':
			tmp = field[0];
			field[0] = field[1];
			field[1] = field[5];
			field[5] = field[4];
			field[4] = tmp;
			break;
		case 'S':
			tmp = field[0];
			field[0] = field[4];
			field[4] = field[5];
			field[5] = field[1];
			field[1] = tmp;
			break;
		case 'W':
			tmp = field[0];
			field[0] = field[2];
			field[2] = field[5];
			field[5] = field[3];
			field[3] = tmp;
			break;
	}
	return;
}
template <class data_t>
void spin(dice<data_t> &d){
	data_t tmp;
	tmp = d.field[1];
	d.field[1] = d.field[3];
	d.field[3] = d.field[4];
	d.field[4] = d.field[2];
	d.field[2] = tmp;
	return;
}
int main(){
	vector<int> v(6);
	int q_num, num1, num2, i;
	cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4]>> v[5];
	dice<int> d(v);
	cin >> q_num;
	while(q_num--){
		cin >> num1 >> num2;
		if(d.field[0] != num1){
			for(i=0;i<3;i++){
				d.roll('N');
				if(d.field[0] == num1)
					break;
			}
			if(d.field[0] != num1){
				for(i=0;i<3;i++){
					d.roll('E');
					if(d.field[0] == num1)
						break;
				}
			}
		}
		if(d.field[1] != num2){
			while(true){
				spin(d);
				if(d.field[1] == num2){
					break;
				}
			}
		}
		cout << d.field[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int k;
  cin >> k;
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << a[k-1] << endl;


}


Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
double a[maxn];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n; cin>>n;
    double sum = 0;
    f1(i,n) 
    {
        cin>>a[i];
        sum += 1.0/a[i];
    }
    sum = 1.0/sum;
    cout << fixed << setprecision(12) << sum;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

ans = [0]*(N+1)

for i in range(1, N+1):
    n_i = i**2
    if n_i > N:
        break
    for j in range(i, N+1):
        n_j = n_i + j**2 + i*j
        if n_j > N:
            break
        for k in range(j, N+1):
            n_k = n_j + k**2 + j*k + k*i
            if n_k > N:
                break
            else:
                if i == j and j == k:
                    ans[n_k] += 1
                elif i != j and j != k and k != i:
                    ans[n_k] += 6
                else:
                    ans[n_k] += 3

for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 74324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  long double d,t,s;
  cin>>d>>t>>s;
  if(d<=s*t){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 3720
#include <stdio.h>
int main()
{
	long long int i,j,a,b,c,s[100000],s1[1000002],k;
	scanf("%lld",&a);
     scanf("%lld",&b);	
     scanf("%lld",&c);
  j=b-c;
     for(i=0;i<a;i++)
     {
     	s[i]=0;
     }
     for(i=0;i<c;i++)
     {scanf("%lld",&s1[i]);
     	s[s1[i]-1]+=1;
     	
     }
     for(i=0;i<a;i++)
     {k=j+s[i];
     	if(k>0)
     	{
     		printf("Yes\n");
     	}else
     	{
     		printf("No\n");
     	}
     }
     return 0;
     }

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

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 51
#define MAX_M 10

#define PI 3.141592

int n;
int m[MAX_N];
int x[MAX_N][MAX_M];
int y[MAX_N][MAX_M];
int vec_x[4][MAX_N];
int vec_y[4][MAX_N];

vector<int> ans[100000];
int ans_count = 0;

int main(){

	while (true){
	
		cin >> n;
		if (n == 0)
			break;

		ans_count++;

		//元の折れ線
		cin >> m[0];
		for (int i = 0; i < m[0]; i++){
			cin >> x[0][i] >> y[0][i];
			if (i > 0){
				vec_x[0][i - 1] = x[0][i] - x[0][i - 1];
				vec_y[0][i - 1] = y[0][i] - y[0][i - 1];

				if (vec_y[0][i - 1] == 0){
					vec_x[1][i - 1] = 0;
					vec_y[1][i - 1] = vec_x[0][i - 1];
				}

				else{
					vec_x[1][i - 1] = vec_y[0][i - 1] * -1;
					vec_y[1][i - 1] = 0;
				}

				vec_x[2][i - 1] = vec_x[0][i - 1] * -1;
				vec_y[2][i - 1] = vec_y[0][i - 1] * -1;

				vec_x[3][i - 1] = vec_x[1][i - 1] * -1;
				vec_y[3][i - 1] = vec_y[1][i - 1] * -1;

			}
		}

		//探す折れ線 1から添え字は始まる
		for (int i = 0; i < n; i++){
			cin >> m[i+1];
			for (int j = 0; j < m[i+1]; j++){
				cin >> x[i + 1][j] >> y[i + 1][j];
			}
		}

		for (int i = 1; i <= n; i++){
			bool flag1 = true, flag2 = true;
			int tmp;

			if (m[i] != m[0])
				continue;

			//視点が一致する場合
			for (int j = 0; j < m[i] - 1; j++){
				int vec_xx = x[i][j + 1] - x[i][j];
				int vec_yy = y[i][j + 1] - y[i][j];
				if (j == 0){
					for (tmp = 0; tmp < 4; tmp++){
						if (vec_xx == vec_x[tmp][0] && vec_yy == vec_y[tmp][0]){
							break;
						}
					}
					if (tmp == 4){
						flag1 = false;
						break;
					}
				}

				else{
					if (vec_xx != vec_x[tmp][j] || vec_yy != vec_y[tmp][j]){
						flag1 = false;
						break;
					}
				}

			}

			//始点と終点が一致する場合
			for (int j = m[i] - 1; j > 0; j--){
				int vec_xx = x[i][j - 1] - x[i][j];
				int vec_yy = y[i][j - 1] - y[i][j];
				if (j == m[i] - 1){
					for (tmp = 0; tmp < 4; tmp++){
						if (vec_xx == vec_x[tmp][0] && vec_yy == vec_y[tmp][0]){
							break;
						}
					}
					if (tmp == 4){
						flag2 = false;
						break;
					}
				}

				else{
					if (vec_xx != vec_x[tmp][m[i] - 1 - j] || vec_yy != vec_y[tmp][m[i] - 1 - j]){
						flag2 = false;
						break;
					}
				}

			}

			if (flag1 || flag2)
				ans[ans_count - 1].push_back(i);

		}
	
	
	}

	for (int i = 0; i < ans_count; i++){
		for (int j = 0; j < ans[i].size(); j++){
			cout << ans[i][j] << endl;
		}
		cout << "+++++" << endl;
	}



	return 0;

}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
ll n,c=0,l=0,p=0;cin>>n;
for(int i=0; i<n; i++){
    ll a,b;
    cin>>a>>b;
    p++;


    if(a==b){c++;}

    else{c=0;}

    if(c%3==0 && c!=0){l++;}




}
if(l!=0){cout<<"Yes";}
else{
cout<<"No";}
return 0;
}


Measured memory_bytes: 3628
while True:
    N = int(input())
    if N == 0 : break

    b = list(map(int, input().split()))
    cnt = 0
    while cnt <= 10000 :
        tri_num = True
        if b[0] != 1 : tri_num = False
        for i in range( 1, len(b) ) :
            if b[i] != b[i-1]+1 :
                tri_num = False
                break
        if tri_num : break

        new_column = len(b)
            
        b_tmp = []
        for i in b :
            if i > 1 : b_tmp.append( i-1 )
        b = b_tmp
        b.append( new_column )

        cnt += 1
    if cnt <= 10000 : print(cnt)
    else : print(-1)
    



Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int anjay[777];//biar hoki
int a[100001];
int n;
int main(){
cin>>n;
    for(int i=0;i<=n-1;i++){
        cin>>a[i];
        if(a[i]%4==0){
            anjay[2]++; //anjay mabar
        }else if(a[i]%2==0){
            anjay[1]++; //anjay mabar
        }else{
            anjay[0]++; //anjay mabar
        }
    }
    if(anjay[1])anjay[0]++; //anjay mabar
    if(anjay[0]-1>anjay[2]){ //anjay mabar
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 4020
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	if(n < m){
		cout << 0 << endl;
 	}else{
 		cout << 10 << endl;
	 }
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
int main(){
ll n;
cin >>n;
ll a[5];
for(int i=0;i<5;i++)
{
  cin>>a[i];
}
sort(a,a+5);
ll ans=ceil(n/double(a[0]));
ans+=4;
cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans += n / (a + b);
    ll t = n / (a + b);
    ans *= a;
    ans += min(a, n - (a + b) * t);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define x first
#define y second
#define x1 X1 
#define x2 X2
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
 
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
inline int read ()
{
	int sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}
 
const int Maxn = 2e5 + 100;
 
int N, A[Maxn], delta[Maxn];
 
int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	N = read();
	for (int i = 1; i <= N; ++i) A[i] = read(), delta[i] = A[i] - A[i - 1];
	if (A[1])
	{
		cout<<"-1"<<endl;
		return 0;
	}
	int Max = 0, fl = 0;
	LL ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		if (delta[i] >= 2) { cout<<"-1"<<endl; return 0; }
		if (delta[i] == 1)
		{
			fl = 1;
			Max = A[i];
		}
		else
		{
			if (fl) ans += Max, fl = 0;
			if (delta[i + 1] == 1)
			{
				Max = A[i];
			}
			else
			{
				fl = 0;
				ans += A[i];
			}
		}
//		cout<<ans<<endl;
	}
	if (fl) ans += Max;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<vector<int>> a(n,vector<int>(n)),b(n,vector<int>(n,1));
    REP(i,n) REP(j,n) cin>>a[i][j];
    REP(k,n){
        REP(i,n){
            REP(j,n){
                if(k!=i && k!=j){
                    if(a[i][j]>a[i][k]+a[k][j]){
                        cout<<-1<<endl;
                        return 0;
                    }
                    if(a[i][j]==a[i][k]+a[k][j]){
                        b[i][j]=0;
                    }
                }
            }
        }
    }
    ll ans=0;
    REP(i,n) REP(j,i) if(b[i][j]) ans+= a[i][j];
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
n,m,k = map(int,input().split())
mod = 998244353
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = 2*10 ** 5 
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)
s = m
x = m
for i in range(k):
  s = (m*s)%p
for i in range(n-k-1):
  y = x*cmb(k+i,i,p)
  s = (m*s-y)%p
  x = (x*(m-1))%p
print(s)

Measured memory_bytes: 111688
def main():
    import os

    INF = 10 ** 9 + 10

    D = int(input())
    *C, = map(int, input().split())
    # C[type]
    # sum(ci*(d-last(d,i) for ci in C)だけ下がる
    S = [[int(x) for x in input().split()] for _ in range(D)]
    # S[day][type]:=happiness

    last = [-1] * 26

    def diff(d, t):
        ret = S[d][t]
        ret -= sum(ci * (d - last[i]) for i, ci in enumerate(C) if i != t)
        for k in range(1, 21):
            if d < D - k:
                ret -= sum(ci * (d + k - last[i]) for i, ci in enumerate(C) if i != t)
                ret -= k * C[t]
        return ret

    T = []
    score = 0
    for d in range(D):
        delta = -INF
        take_t = -1
        for t_ in range(26):
            buf = diff(d, t_)
            if delta < buf:
                delta = buf
                take_t = t_
            elif delta == buf and C[t_] > C[take_t]:
                delta = buf
                take_t = t_

        last[take_t] = d
        score += buf
        T.append(take_t + 1)
    print(*T, sep='\n')
    # print(os.path.join(os.path.dirname(__file__), 'output_file.txt'))
    # with open(file=os.path.join(os.path.dirname(__file__), 'output_file.txt'), mode='w', encoding='utf-8') as f:
    #     for t in map(str, T):
    #         f.write(t)
    #         f.write('\n')

    # print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70820
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N, K;
	cin >> N >> K;


	Int len = max(K, N - K + 1);
	vector<mint> kai(len+ 1);
	kai[0] = 1;

	for (Int i = 1; i < len+1; i++) {
		kai[i] = kai[i - 1] * i;
	}

	vector<mint> ans(K + 1);
	for (Int i = 1; i <=K; i++) {
		if (N - K + 1 >= i) {
			ans[i] = kai[K - 1] / kai[i - 1] / kai[K - i] * kai[N - K + 1] / kai[i] / kai[N - K + 1 - i];
		}
		else break;
    }

	for (Int i = 1; i <= K; i++) {
		cout << ans[i] << "\n";
	}
}

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

int main() {
  int n,a,b,c,d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  for(int i = a;i < d;i++){
    if(s[i] == '#' && s[i+1] == '#'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(c < d){
    cout << "Yes" << endl;
    return 0;
  }
  else{
    for(int i = b-2;i <= d-2;i++){
      if(s[i] == '.' && (s[i+1] == '.' && s[i+2] == '.')){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
h, w, k = gets.chomp.split.map(&:to_i)
board = h.times.map { gets.chomp.chars }

ans = 0

(2 ** h).times do |n|
  # 塗られていない行
  rows = n.to_s(2).rjust(h).chars.map {|c| c != "1" }

  (2 ** w).times do |m|
    # 塗られていない列
    cols = m.to_s(2).rjust(w).chars.map {|c| c != "1" }

    count = 0
    # p [rows, cols]
    h.times do |i|
      w.times do |j|
        if rows[i] && cols[j] && board[i][j] == "#"
          count += 1
        end
      end
    end
    if count == k
      ans += 1
    end
  end
end

puts ans

Measured memory_bytes: 14388
#include <stdio.h>

int main(void){
    int n,k,sum,max,i,o,line[100000];
    for(;max=-30000,sum=0,scanf("%d %d",&n,&k),k;){
        for(i=0;i<n;i++)scanf("%d",&line[i]);
        for(i=0;i<k;i++)sum+=line[i];
        for(i=1;i<=n-k;i++){
            sum-=line[i-1];
            sum+=line[i+k-1];
            if(sum>max)
                max=sum;
        }
        printf("%d\n",max);
    }
    return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) { std::cin >> A[i], sum += A[i]; }
    int min = 1000000, mini = -1;
    for (int i = 0; i < N; i++) {
        if (min > std::abs(sum - A[i] * N)) { min = std::abs(sum - A[i] * N), mini = i; }
    }
    std::cout << mini << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 31
#define M 100010
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
 int b[N][M];
int main(){
     int n,m;
     int s,t,c;
     int ans,maxn;
    ios::sync_with_stdio( false );
    cin>>n;
    cin>>m;
   for (int i=1;i<=n;i++) {
        cin>>s;
        cin>>t;
        cin>>c;
        for (int j=s-1;j<t;j++)
            b[c][j]=1;
    }
      maxn=0;
    for (int i=1;i<=100000;i++){
        ans=0;
        for (int j=1;j<=m;j++)
           if (b[j][i])
            ans++;
        maxn=max(maxn,ans);
    }
    cout << maxn << endl;
    return 0;
}


Measured memory_bytes: 12032
sub f{$_-$u[$_]?(map$_=&f,$u[$_])[0]:$_}
map{
	@u=0..$`;
	($==f$_=<>=~$"*$')-($%=f$_=$`)and$u[$%]=$=for 1..$_;
	@{$|--}=map f,@u
}<>=~/ \d+/g;
print$$_,$/for map{++${$t=\${$0[$_]}{$1[$_]}};$t}1..$`


Measured memory_bytes: 164608
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    using namespace std ;
    int main(){
          string s;
          int ans=0;
          cin>>s;
          for(int i=0;i<3;i++){
              if(s.substr(i,1)=="1")ans++;
          }
          cout<<ans<<endl;
        return 0 ;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  set<char> s = {
    'a',
    'e',
    'i',
    'o',
    'u',
  };
  char c; cin >> c;
  auto ans = s.count(c) > 0;
  cout << (ans ? "vowel" : "consonant") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[11],l=0,r=0,flag,n;
int main()
{
    void solve();
    cin>>n;
    while(n--){
        flag=0;
        for(int i=0;i<10;i++)
            cin>>a[i];
        solve();
        if(flag)
            cout<<"YES"<<endl;
        else
           cout<<"NO"<<endl;
    }
    return 0;
}
void solve()
{
    int dfs(int i);
    dfs(0);
}
int dfs(int i)
{
    int iv;
    if(i==10){
        flag=1;
        return(flag);
    }
    if(a[i]>l){
        iv=l;
        l=a[i];
        dfs(i+1);
        l=iv;
    }
    if(a[i]>r){
        iv=r;
        r=a[i];
        dfs(i+1);
        r=iv;
    } 
}


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

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int p = 0;
    if (A < K) {
        p += A;
        K -= A;
    } else {
        p += K;
        cout << p << endl;
        return 0;
    }

    if (B < K) {
        K -= B;
    } else {
        cout << p << endl;
        return 0;
    }

    p -= K;
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N;
	cin >> N;
	char S[N];
	cin >> S;
	int K;
	cin >> K;
	char tmp;
	tmp = S[K-1];
	rep(i,0,N){
		if(tmp == S[i]){
			cout << tmp;
		}else{
			cout << "*";
		}
	}
	cout << endl;
}


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

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

Node *root,*NIL;

Node* find(Node *x,int key);
void insert(int k);
void inorder(Node *u);
void preorder(Node *u);
void deleteNode(int key);
void deleteNode(Node *z);
Node *getSuccessor(Node *x);
Node *getMinimum(Node *x);

int main(){
	int m; cin>>m;
	string command;
	int key;
	for(int i=0;i<m;i++){
		cin>>command;
		if(command=="insert"){
			cin>>key;
			insert(key);
		}else if(command=="delete"){
			cin>>key;
			deleteNode(key);
			//deleteNode(find(root,key));
		}else if(command=="find"){
			cin>>key;
			Node *x = find(root,key);
			if(x==NIL) cout<<"no"<<endl;
			else cout<<"yes"<<endl;
		}else if(command=="print"){
			inorder(root);
			cout<<endl;
			preorder(root);
			cout<<endl;
		}
	}
}

void deleteNode(int key){
	Node *x,*y,*z;
	z = find(root,key);
	if(z->right==NIL || z->left==NIL){
		y = z;
	}else{
		y = getSuccessor(z);
	}

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

	if(x!=NIL) x->parent = y->parent;

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

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

void deleteNode(Node *z){//Ok
	Node *x,*y;
	if(z->right==NIL || z->left==NIL){
		y = z;
	}else{
		y = getSuccessor(z);
	}

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

	if(x!=NIL) x->parent = y->parent;

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

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


Node *getSuccessor(Node *x){
	if(x->right!=NIL) return getMinimum(x->right);

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

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

void insert(int k){
	Node *x,*y,*z;
	x = root,y = NIL;
	z = (Node *)malloc(sizeof(Node));
	z->key = k; z->left = 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(y->key>z->key)
			y->left = z;
		else
			y->right = z;
}

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

void inorder(Node *u){
	if(u==NIL) return ;
	inorder(u->left);
	cout<<" "<<u->key;
	inorder(u->right);
}

void preorder(Node *u){
	if(u==NIL) return ;
	cout<<" "<<u->key;
	preorder(u->left);
	preorder(u->right);
}

Measured memory_bytes: 21904
#include <cstdio>
using namespace std;

int n, a, b, ans;

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

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> ac(N), pena(N);
    rep (i, M) {
        ll p;
        string S;
        cin >> p >> S;
        p--;
        if (ac[p]) {
            continue;
        }
        if (S == "AC") {
            ac[p] = 1;
        } else {
            pena[p]++;
        }
    }

    ll ans1 = 0;
    ll ans2 = 0;
    rep (i, N) {
        if (ac[i]) {
            ans1++;
            ans2 += pena[i];
        }
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

int main()
{
	string str = "";

	while (getline (cin, str)){
		int n = 0;
		int res = 0;
		stringstream ss(str);
		ss >> n;
		for (int i = 0; i < 10000; ++i){
			int a = i/1000;
			int b = (i/100) % 10;
			int c = (i/10) % 10;
			int d = i % 10;
			
			if (a + b + c + d == n){
				++res;
			} // end if
		} // end for
		cout << res << endl;	
	} // end while

	return 0;
}

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

ll n,a,sum=0,k,cont=0;
std::vector<ll> arr,arr1;

int main() {
    cin>>n;
    rep(i,0,n){
    	cin>>a;
    	arr.pb(a);
    }
    if(n>1){
        sort(arr.rbegin(),arr.rend());
        arr1.pb(arr[0]);
        k=n-2;
        int i=1;
        while(k>0){
            if(cont<2){
                arr1.pb(arr[i]);
                cont++;
                k--;
            }
            else{
                i++;
                cont=0;
            }
        }
        for(int j=0;j<arr1.size();j++){
            sum+=arr1[j];
        }
        cout<<sum<<'\n';
    }
    else {
    	cout<<0<<'\n';
    }
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A;
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int ai; cin >> ai; A.push_back(ai);
        sum += ai;
    }
    double th = sum / (4.0 * M);
    int cnt = 0;
    for (const auto& ai : A) {
        if (ai >= th) { cnt++; }
    }
    if (cnt >= M) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S,ans = "";
int main(){
    cin >> S;
    rep(i,sz(S)){
        if(S[i] == 'B' && !ans.empty()) ans.pop_back();
        else if(S[i] == 'B') ans = ans;
        else ans += S[i];
    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 256
def count(sum)
  rsl = 0
  while sum != 0
    rsl = rsl + 1
    sum = sum/10
  end
  return rsl
end

ltd = 1000000

while n = gets
  #print '(a,b) >>> '
  a,b = n.chomp.split
  a = a.to_i
  b = b.to_i
  puts count(a+b)
  if a < 0 || b < 0 || a > ltd || b > ltd || a = nil || b = nil
    break
  end
end



Measured memory_bytes: 6872