akhauriyash/Code-Regression huggingface dataset:
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag,vis[5000][5000],deger[5000][5000],deger1[5000][10000],deger2[5000][5000],deger3[5000][5000],mx;
lo cev;
char s[5000][5000];
vector<lo> v[5000];
vector<lo> vv[5000];

void YES(lo xxxxxxx){
	if(xxxxxxx==1){cout<<"YES\n";exit(0);}
	printf("YES\n");
	exit(0);
}

void NO(lo xxxxxxx){
	if(xxxxxxx==1){cout<<"NO\n";exit(0);}
	printf("NO\n");
	exit(0);
}

void solve(){
	cin>>n>>m;
	FOR{
		for(lo j=1;j<=m;j++){
			cin>>s[i][j];
			if(s[i][j]=='#'){vis[i][j]=1;v[i].pb(j);vv[j].pb(i);}
			//~ if(v[i].size())
			deger[i][j]=v[i].size();
			deger1[i][j]=vv[j].size();
			//~ cout<<deger<<" "<<deger1<<endl;
		}
	}
	//~ cout<<"**";
	FOR{
		//~ cin>>s[i];
		for(lo j=1;j<=m;j++){
			if(s[i][j]=='#'){continue;}
			if(deger[i][j]!=(int)v[i].size()) deger2[i][j]=v[i][deger[i][j]]-1;
			else if(deger[i][j]==(lo)v[i].size()) deger2[i][j]=m;
			if(deger[i][j]!=0) deger[i][j]=v[i][deger[i][j]-1];
			if(deger1[i][j]!=(lo)vv[j].size()) deger3[i][j]=vv[j][deger1[i][j]]-1;
			else if(deger1[i][j]==(lo)vv[j].size()) deger3[i][j]=n;
			if(deger1[i][j]!=0) deger1[i][j]=vv[j][deger1[i][j]-1];
			cev=0;
			cev+=deger3[i][j]-deger1[i][j];
			//~ cout<<cev<<" ";
			cev+=deger2[i][j]-deger[i][j];
			//~ cout<<cev<<endl;
			mx=max(mx,cev-1);
		}
	}
	cout<<mx<<endl;
}

int main(void){
	fio();
	solve();
	return 0;
}


Measured memory_bytes: 558464
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    string ans="No";
    if(a<b&&b<c)ans="Yes";
    cout<<ans<<endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>

using namespace std;

constexpr int MAX = 300000;
bool isprime[MAX + 1];

int main()
{
    for (int i = 2; i <= MAX; i++) {
        isprime[i] = true;
    }
    for (int i = 2; i <= MAX; i++) {
        if (i % 7 == 1 or i % 7 == 6) {
            if (isprime[i]) {
                for (int j = 2; i * j <= MAX; j++) {
                    isprime[i * j] = false;
                }
            }
        } else {
            isprime[i] = false;
        }
    }

    vector<int> prime;
    for (int i = 2; i <= MAX; i++) {
        if (isprime[i]) {
            prime.push_back(i);
        }
    }


    while (true) {
        int n;
        cin >> n;
        if (n == 1) {
            break;
        }
        cout << n << ":";
        for (const int p : prime) {
            if (n % p == 0) {
                cout << " " << p;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
char a;
int kotae[26],b;
int main(void){
    while(1){
        if(scanf(" %c",&a) == EOF)break;
        for(int j=0;j<26;j++){
            if(a=='a'+j ||a=='A'+j){
                kotae[j]+=1;
            }
        }
    }
    for(int i=0;i<26;i++){
        cout<<(char)('a'+i)<<" : "<<kotae[i]<<endl;
    }
}



Measured memory_bytes: 3156
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    string c[9] = {
        ".,!? ",
        "abc",
        "def",
        "ghi",
        "jkl",
        "mno",
        "pqrs",
        "tuv",
        "wxyz"
    };
    int t;
    cin >> t;
    REP(ttt, t){
        string s;
        cin >> s;
        string ans;
        ll k = -1, cnt = -1;
        REP(i, s.size()){
            if(s[i] != '0'){
                cnt++;
                k = s[i] - '1';
            }
            else{
                if(k == -1) continue;
                ans += c[k][cnt % c[k].size()];
                k = -1;
                cnt = -1;
            }
        }
        cout << ans << endl;
    }
}


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

void swap(int a[],int x,int y){
  int t=a[x];
  a[x]=a[y];
  a[y]=t;
  return;
}

int main(){
  int a[100]={};
  int n,w;
  cin>>w>>n;
  for(int i=1;i<=w;i++){
    a[i]=i;
  }
  for(int i=0;i<n;i++){
    int e,f;
    scanf("%d,%d",&e,&f);
    swap(a,e,f);
  }
  for(int i=1;i<=w;i++){
    cout<<a[i]<<endl;
  }
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    int k; cin >> k;
    string s; cin >> s;
    if(s.size() <= k) {
        cout << s << endl;
    }else{
        string tmp = s.substr(0, k);
        cout << tmp << "..." << endl;
    }
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#define max_q 200000
#define max_n 200000
using namespace std;
bool q1[max_n+1],eq1[max_n+2];
bool q2[max_n+1],eq2[max_n+2];
struct node{
	int op,x;
};
node que[max_q+1];
int main(){
	int n,q,gt1,gt2;
	long long ans;
	scanf("%d%d",&n,&q),memset(q1,0,sizeof(q1)),memset(q2,0,sizeof(q2)),memset(eq1,0,sizeof(eq1)),memset(eq2,0,sizeof(eq2));
	for(int i=0; ++i<=q; ){
		scanf("%d%d",&que[i].op,&que[i].x);
		if(que[i].op==1)
			q1[que[i].x]=1;
		else
			q2[que[i].x]=1;
	}
	ans=(long long)(n-2)*(n-2),gt1=gt2=n-2,eq1[n]=eq2[n]=1;
	for(int i=0,x; ++i<=q; ){
		if(que[i].op==1){
			if(!q1[x=que[i].x])
				continue;
			ans-=gt1,gt2=x-2,eq1[x]=1;
			for(int j=x; !eq1[++j]; q1[j]&&(q1[j]=0,ans-=gt1));
		}
		else{
			if(!q2[x=que[i].x])
				continue;
			ans-=gt2,gt1=x-2,eq2[x]=1;
			for(int j=x; !eq2[++j]; q2[j]&&(q2[j]=0,ans-=gt2));
		}
//		printf("%d:%lld %d %d\n",i,ans,gt1,gt2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4068
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    a = [0] * n
    for i in range(n):
        a[i] = int(input().strip())
    if all(True if v % 2 == 0 else False for v in a):
        print('second')
    else:
        print('first')

if __name__ == '__main__':
    main()


Measured memory_bytes: 40940
n = int(input())
d = {}
for i in range(n):
    x = input()
    if x not in d.keys():
        d[x] = 1
    else:
        d[x] += 1
l = []
m = 0
for i in d.keys():
    m = max(m, d[i])
for i in d.keys():
    if d[i] == m:
        l.append(i)
l = sorted(l)
for i in l:
    print(i)


Measured memory_bytes: 32988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
	 cout<<k;
	else if(k<=a+b)
	 cout<<a;
	else
	 cout<<a-(k-a-b);
	return 0;
	
}

Measured memory_bytes: 3556
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] input = new int[N];
    for (int i=0; i<N; i++) {
      input[i] = sc.nextInt();
    }
    System.out.println(minCost(N, K, input));
  }
  
  public static int minCost(int N, int K, int[] h) {
    int[] dp = new int[N];
    for(int i=0;i<N;i++) {
			dp[i] = Integer.MAX_VALUE;
		}
    dp[0] = 0;
    dp[1] = Math.abs(h[1] - h[0]);
		for(int i=2;i<N;i++) {
			for(int j = Math.max(0, i-K);j<i;j++) {
				dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[j] - h[i]));
			}
		}
    return dp[N-1];
  }
}

Measured memory_bytes: 50376
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	long int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%ld %ld %.6lf\n", d, r, f);
	return 0;
}

Measured memory_bytes: 1192
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[N];
    for (int i =0; i<N; i++) {
      a[i] = sc.nextInt();
    }
    long count =0;
    if (a[0] > x) {
      count += a[0] - x; 
      a[0] = x;
    }
    for (int i =0; i<N-1; i++) {
      if (a[i] + a[i+1] <= x) {
        continue;
      } else {
      count += (long)(a[i] + a[i+1] - x);
      a[i+1] -= (a[i] + a[i+1] - x);
    }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 50204
def main()
  n = gets.chomp.to_i
  a = gets.chomp.strip
  b = gets.chomp.strip
  c = gets.chomp.strip
  count = 0
  for i in 0..(n-1) do
    if ((a[i] == b[i]) && (b[i] == c[i]))
      next;
    elsif ((a[i] == b[i]) || (b[i] == c[i]) || (c[i] == a[i]))
      count += 1
    else
      count += 2
    end
  end
  puts "#{count}"
end
main

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

//macro
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(){
    int x;

    cin  >> x;

    if(x < 1200){
        cout << "ABC" << endl;
        return 0;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] arsg){
        Scanner sc = new Scanner(System.in);
        String[] str = sc.next().split("");
        int ans = 0;
        int count = 0;
        for(int i = 0;i < str.length;i++){
            String s = str[i];
            if(s.equals("A") || s.equals("C") || s.equals("G") || s.equals("T")){
                count++;
            }else{
                if(ans < count){
                    ans = count;
                }
                count = 0;
            }
        }
        if(ans < count){
            ans = count;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int i = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int i = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int i = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    ll n,a,b,c,d,e; cin >> n >> a >> b >> c >> d >> e;

    cout << (n+min({a,b,c,d,e})-1)/min({a,b,c,d,e}) + 4 << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3684
package main

import "fmt"

func getWin(h rune) rune {
	if h == 'r' {
		return 'p'
	}
	if h == 's' {
		return 'r'
	}
	return 's'
}

func main() {
	var (
		n, k, r, s, p int
		t             string
	)
	fmt.Scan(&n, &k, &r, &s, &p, &t)

	hs := []rune{'r', 's', 'p'}
	ans := 0
	for i := 0; i < k; i++ {
		bh := 'x'
		for j := i; j < n; j += k {
			h := getWin(rune(t[j]))
			if h == bh {
				if j+k >= n {
					break
				}

				nh := getWin(rune(t[j+k]))
				for _, v := range hs {
					if v == bh || v == nh {
						continue
					}
					h = v
				}
			} else {
				switch h {
				case 'r':
					ans += r
				case 's':
					ans += s
				case 'p':
					ans += p
				}
			}
			bh = h
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double

#define data etokek

//#define int lll

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 2.5e5 + 32;
//const int M = 1e9 + 7;
const int mod = 998244353;
const int rx[4] = {-1, -1, 1, 1};
const int ry[4] = {-1, 1, -1, 1};
const lld eps = 1e-11;
const double pi = acos(-1.0);
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("mushrooms.in", "r", stdin);
//    freopen("mushrooms.out", "w", stdout);
#endif
    lld r;
    cin >> r;
    cout << fixed << setprecision(3) << 2.0 * pi * r;
    return 0;
}


Measured memory_bytes: 3824
import numpy as np

MOD = 10**9 + 7
 
N = int(input())
aff = np.array([map(int, input().split()) for i in range(N)])
dpt = np.zeros((N+1, 1<<N), dtype='int64')
dpt[0][0] = 1

for i, row in enumerate(aff):
    for idx, v in enumerate(row):
        if v == 1:
            dpt[i+1][(1<<idx):] += dpt[i][:-(1<<idx)]
    dpt[i+1] %= MOD

print(dpt[N][(1<<N)-1])


Measured memory_bytes: 370900
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

int n,m,k,s;
int p,q;

int land[200005];
bool is_safe[200005];
bool is_zonbi[200005];
vector<int> zonbi;
vector<int> road[200005];
priority_queue<P,vector<P>,greater<P> > que;
int fin[200005];
int d[200005];

int solve(){
	int ans=INF;
	que.push(mk(0,1));
	d[1]=0;
	while(!que.empty()){
		int now=que.top().second,dis=que.top().first; que.pop();
		if(d[now]<dis) continue;
		if(now==n){ 
			ans=min(ans,dis);
			continue;
		}
		for(int i=0; i<road[now].size(); i++){
			int to=road[now][i];
			if(is_zonbi[to]) continue;
			int a=(is_safe[to])? p:q;
			if(to==n) a=0;
			if(d[to]>dis+a){
				d[to]=dis+a;
				que.push(mk(dis+a,to));
			}
		}
	}
	return ans;
}

signed main(){
	cin>>n>>m>>k>>s;
	cin>>p>>q;
	
	for(int i=1; i<=n; i++){ 
		is_safe[i]=true;
		is_zonbi[i]=false;
		d[i]=INF;
	}
	for(int i=0; i<k; i++){
		int a; cin>>a;
		zonbi.push_back(a);
		is_zonbi[a]=true;
	}
	
	for(int i=0; i<m; i++){
		int a,b; cin>>a>>b;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	
	queue<P> p_que;
	for(int i=0; i<zonbi.size(); i++){
		p_que.push(mk(zonbi[i],0));
	}
	while(!p_que.empty()){
		int now=p_que.front().first, dis=p_que.front().second; p_que.pop();
		is_safe[now]=false;
		if(dis==s) continue;
		for(int j=0; j<road[now].size(); j++){
			int to=road[now][j];
			if(!is_safe[to]) continue;
			is_safe[to]=false;
			p_que.push(mk(to,dis+1));
		}
	}
	cout<<solve()<<en;
}
	
	
	


Measured memory_bytes: 15428
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 50010;
//const int MAXM = 100010;
const int MAXK = 30;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int B = 31;
const int MOD = 1000000007;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

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

#define rep(i,a,b) for (int i = (a), I = (b); i <= I; ++ i)

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return y%4 == 0 && y%100 != 0 || y%400 == 0;
}

int n, l, k;
char s[MAXN];
int L[MAXN][10], R[MAXN][10];

void solve()
{
	scanf("%d%s", &n, s+1);
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 0; j <= 9; ++ j)
			L[i][j] = L[i-1][j];
		L[i][s[i]-'0'] = 1;
	}
	for (int i = n; i >= 1; -- i)
	{
		for (int j = 0; j <= 9; ++ j)
			R[i][j] = R[i+1][j];
		R[i][s[i]-'0'] = 1;
	}
	set<int> H;
	for (int i = 1; i <= n; ++ i)
	{
		for (int x = 0; x <= 9; ++ x) if (L[i-1][x])
			for (int y = 0; y <= 9; ++ y) if (R[i+1][y])
				H.insert(x*100+(s[i]-'0')*10+y);
	}
	cout << H.size() << endl;
}

int main()
{
	
	int T;
	T = 1;
	//scanf("%d", &T);
	while (T --)
	solve();
	
	return 0;
}


Measured memory_bytes: 2688
def rot_n(c, n):
    if 'a' <= c and c <= 'z':
        return chr((ord(c) - ord('a') + int(n)) % 26 + ord('a'))
    
    if 'A' <= c and c <= 'Z':
        return chr((ord(c) - ord('A') + int(n)) % 26 + ord('A'))
    
    return c

def rot(s, n):
    c = (rot_n(c, n) for c in s)
    return "".join(c)

while(True):
    try:
        s = input()
        for i in range(1,28):
            d = rot(s,i)
            if "this" in d.split() or "the" in d.split() or "that" in d.split():
                print(d)
    except:
        break


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

int main(void){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if ((x-r>=0 && x+r<=W)&&(y-r>=0 && y+r<=H)){
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        int maxv = array[1] - array[0];
        int minv = array[0];
        for (int i = 1; i < array.length; i++) {
            maxv = Math.max(maxv, array[i] - minv);
            minv = Math.min(minv, array[i]);
        }
        System.out.println(maxv);
    }
}



Measured memory_bytes: 101972
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
 
//***********************************
//mintを定義
//***********************************
const int mod = 1000000007;
struct mint {
  int x;
  mint(int x=0):x(x%mod){}   //メンバ変数xをx%modで初期化
  int get() const { return (int)x; }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;           //thisは暗黙的に左辺のポインタ
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
 
  //累乗
  mint mpow(int t) const {
    if (!t) return 1;
    mint a = mpow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  //除算
  mint minv() const {
    return mpow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.minv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
//標準出力
ostream& operator<<(ostream& st, const mint a) 
{ st << a.get(); return st; };
//--------------------------------------------------
 
//***********************************
//場合の数の計算
//***********************************
const int MAX = 200010;
mint fac[MAX], finv[MAX];
 
//前計算
inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(int i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*mint(i));
        finv[i] = (finv[i-1]/mint(i));
    }
}
 
//nCk
mint mcomb(int n, int k) {
    if(n<k || k<0) return 0;
    else return ((fac[n]*finv[k])*finv[n-k]);
}
 
//nHk
mint mhcomb(int n, int k) {
  return mcomb(n+k-1, k);
}
//--------------------------------------------------

signed main() {
    INIT_F();
    int N;
    string S;
    cin >> N >> S;

    vi cnts(26, 0);
    rep(i, N) cnts[S[i]-'a']++;

    mint res = 1;
    rep(i, 26) {
        res *= cnts[i]+1;
    }
    res -= 1;


    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(ll a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in2(a,b)  a=read(),b=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define in(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define in3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 998244353
#define maxn 300010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
ll f[maxn],inv[maxn],invf[maxn];
ll C(int n,int m){
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
int main(){
	ll n;
	in(n);
	inv[1]=inv[0]=f[0]=f[1]=invf[0]=invf[1]=1;
    FOR(i,2,n){
        inv[i]=(mod-mod/i)*inv[mod%i]%mod; 
        f[i]=f[i-1]*i%mod;
        invf[i]=invf[i-1]*inv[i]%mod;
    }
    ll a,b,c;
    in3(a,b,c);
    ll ans=0;
    FOR(i,0,n){
    	if(a*i>c)break;
    	if((c-a*i)%b==0){
    		ll j=(c-a*i)/b;
    		if(0<=j&&j<=n)ans+=C(n,i)*C(n,j)%mod,ans%=mod;
    	}
    }
    outl(ans);
}

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

int main(void){
	string s1,s2;
	int n,p1,p2;
	cin >> n;
	p1 = 0;
	p2 = 0;
	for(int i = 0; i < n;i++){
		cin >> s1 >> s2;
		if(s1.compare(s2) == 0){
			p1++;
			p2++;
		}else if(s1.compare(s2) < 0){
			p2 += 3;
		}else {
			p1 += 3;
		}
	}
	cout << p1 << " " << p2 << endl;
}


Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int w[100010];

int main() {
    int n, k,mx=0, sum = 0;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
        mx = max(mx,w[i]);
        sum += w[i];
    }
    int minMax = max((sum + k - 1) / k,mx);
    while (true) {
        int num = 0;
        sum = 0;
        for (int i = 0; i < n; ++i) {
            if (sum + w[i] > minMax) {
                num++;
                sum = 0;
            }
            sum += w[i];
        }
        if (sum > 0) num++;
        if (num <= k) break;
        minMax++;
    }
    cout << minMax << endl;
    return 0;
}



Measured memory_bytes: 3496
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    input!{
        w: chars,
    }

    let mut hash = HashMap::new();

    for ch in w {
        let val = hash.get(&ch).unwrap_or(&0)+1;
        hash.insert(ch, val);
    }

    let ans = hash.into_iter().fold(true, |acc, (_, v)| acc && (v % 2 == 0));

    println!("{}", if ans { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = input()
    t = input()

    for i in range(n + 1):
        flag = True
        for j in range(n - i):
            if s[i + j] != t[j]:
                flag = False
                break
        if flag:
            return print(n + i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61916
fun main() {
    val P = 1000000007L
    val PP: Long = 2*P
    readLine()
    val list = readLine()!!.split(" ").map(String::toLong)
    val sum = list.sum()%PP
    var mod = (sum*sum)%PP - list.map { (it*it)%PP }.sum()%PP
    if(mod<0)
        mod += PP
    println((mod/2)%P)
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

string s,t;
int idx;
set<string> st;

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

	cin>>s>>t;
	REP(i,s.size()) {
		bool flg=true;
		REP(j,t.size()) {
			if(s[i+j]=='?') continue;
			if(s[i+j]!=t[j]) {
				flg=false;
				break;
			}
		}
		if(flg) {
			string tmp;
			REP(k,i) tmp+=(s[k]=='?'?'a':s[k]);
			tmp+=t;
			REP(k,s.size()-i-t.size()) tmp+=(s[k+i+t.size()]=='?'?'a':s[k+i+t.size()]);
			st.insert(tmp);
		}
	}
	if(st.size()) cout<<*st.begin()<<endl;
	else cout<<"UNRESTORABLE"<<endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	int a, b;
	cin >> a >> b;

	int c = 0;

	if (b == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; ; i++)
	{
		c += a;
		if (c >= b)
		{
			cout << i + 1 << endl;
			break;
		}
		c--;
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=998244353;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
 string s;
  ll k;
  cin >> s >> k;
 ll n=s.length();
 
  bool flag=true;
  rep(i,1,n) if(s[i-1]!=s[i]) flag=false;
  
  if(flag){ cout << (n*k)/2 << endl;
            return 0;
  }
  
  ll cnt=1,res=0;
  rep(i,1,n) {
    if(s[i]==s[i-1]) cnt++;
    else res+=cnt/2,cnt=1;
  }
  res+=cnt/2;
  res*=k;
  
  if(s[0]!=s[n-1]) {
    cout << res << endl;
    return 0;
  }
  
  ll a=1,b=1,index=1;
  while(s[index-1]==s[index++]) a++;  
  index=n-1;
  while(s[index-1]==s[index--]) b++;  
  
  res-=((a/2)+(b/2)-(a+b)/2)*(k-1);
  
  cout << res << endl;
  
}


Measured memory_bytes: 256
N=int(input())
S=list(input() for _ in range(N))

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)

for i in sorted(ans):
	print(i)
	

Measured memory_bytes: 137916
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int v[1 << 20];
    for (int i = 1;i <= n;++i)
        fi>>v[i];
    static vi s[1 << 20];
    for (int i = 1;i < n;++i)
    {
        int a,b;
        fi>>a>>b;
        s[a].pb(b);
        s[b].pb(a);
    }
    int Root = -1;
    for (int i = 1;i <= n;++i)
        if (s[i].size() == 1)
            Root = i;
    function < ll(int,int) > dfs = [&](int node,int prev)
    {
        if (s[node].size() == 1 && s[node][0] == prev)
            return 1ll * v[node];
        ll sum = 0;
        ll mx = 0;
        for (auto it : s[node])
            if (it != prev)
            {
                ll cnt = dfs(it,node);
                sum += cnt;
                mx = max(mx,cnt);
            }
        if (sum < v[node])
        {
            no;
            exit(0);
        }
        ll take = 2 * (sum - v[node]);
        ll shit = sum - mx + min(mx,sum / 2);
        if (take > shit)
        {
            no;
            exit(0);
        }
        return sum - take;
    };
    if (dfs(Root,0) != v[Root])
        no;
    else
        yes;
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 37760
#include<iostream>
#include<climits>
using namespace std;
int main()
{
	int max = INT_MIN, min = INT_MAX;
	int n, i, x;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x;
		max = (max > (x - min)) ? max : x - min;
		min = (min > x) ? x : min;
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define Lim 9999991
#define Jmp 100003

int dic[Lim];

int toint(string s) {
    int ret = 0;
    for (int i = 0; i < s.size(); ++i) {
        ret *= 5;
        switch (s[i]) {
            case 'A':
                ret += 1;
                break;
            case 'T':
                ret += 2;
                break;
            case 'G':
                ret += 3;
                break;
            case 'C':
                ret += 4;
                break;
        }
    }
    return ret;
}

void push(string s) {
    int a = toint(s);
    int i = a;
    while (true) {
        if (!dic[i]) {
            dic[i] = a;
            return;
        }
        i = (i + Jmp) % Lim;
    }
}

int find(string s) {
    int a = toint(s);
    int i = a;
    while (true) {
        if (!dic[i]) {
            return 0;
        }
        if (dic[i] == a) {
            return 1;
        }
        i = (i + Jmp) % Lim;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s, t;
        cin >> s >> t;
        if (s == "insert") {
            push(t);
        }
        else {
            if (find(t)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 31040
#include<bits/stdc++.h>
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
using namespace std;
typedef long long ll;
vector<int> v[30];
int main(){
	int t=1;
//	cin>>t;
	while(t--){
          int a,b;
          cin>>a>>b;
          if(a+b==15) cout<<'+';
          else if(a*b==15) cout<<'*';
          else cout<<'x';
          cout<<endl;
   }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    string s;
    cin >> s;
    rep(i,s.length()){
        cout << 'x';
    }
}

Measured memory_bytes: 256
import bisect


def resolve():
    n = int(input())
    li = list(map(int, input().split()))
    ans = 0

    li.sort()

    for i in range(n):
        for j in range(i + 1, n):
            cnt = bisect.bisect_left(li, li[i] + li[j])

            ans += cnt - j - 1

    print(ans)

resolve()

Measured memory_bytes: 3188
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }
    var answer = 0L

    for (i in 0 until N - 1) {
        for (j in i + 1 until N ) {
            answer += d[i] * d[j]
        }
    }
    println(answer)
}

Measured memory_bytes: 35944
#include<iostream>
using namespace std;
int m,D[1401][1401]={m=0},h,w,f,i,j;
main(){
	cin>>h>>w;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		cin>>f;
		D[i+1][j+1]=(min(D[i][j],min(D[i+1][j],D[i][j+1]))+1)*(!f);
		m=max(m,D[i+1][j+1]);
	}
	cout<<m*m<<endl;
}


Measured memory_bytes: 10740
#input
import sys
sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
z = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    z[x-1].append(y-1)

#output
#便宜的にすべての点を-1しておく。
#dp[i]を頂点iから始まるpathで最長の長さとする。
#dp[i] = max(dp[v]+1)(vは頂点iから到達できる任意の頂点)

visited = [False] * N
memo = [0] * N

def dp(v):
    if visited[v]:
        return memo[v]
    else:
        res = 0
        for u in z[v]:
            res = max(res, dp(u)+1)
        memo[v] = res
        visited[v] = True
        return res
for i in range(N):
    dp(i)

print(max(memo))

Measured memory_bytes: 59824
#include<cstdio>
#include<queue>
#define NIL (-1)

using namespace std;

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

node tree[500001];
int treesize;
int root = NIL;

void pre(int id){
    if(id == -1)
        return;
    printf(" %d",tree[id].key);
    if(tree[id].left >= 0)
        pre(tree[id].left);
    if(tree[id].right >= 0)
        pre(tree[id].right);
}

void in(int id){
    if(id == -1)
        return;
    if(tree[id].left >= 0)
        in(tree[id].left);
    printf(" %d",tree[id].key);
    if(tree[id].right >= 0)
        in(tree[id].right);
    
}


void insert(int key){
    int y = NIL;
    int x = root;
    while(x != NIL){
        y = x;
        if(key < tree[x].key)
            x = tree[x].left;
        else
            x = tree[x].right;
    }
    tree[treesize].parent = y;

    if(y == NIL)
        root = treesize;
    else if(key < tree[y].key)
        tree[y].left = treesize;
    else
        tree[y].right = treesize;
    tree[treesize].left = NIL;tree[treesize].right = NIL;tree[treesize].key = key;

    treesize++;
        
}
bool find(int key){
    int x = root;

    while(x != NIL){
        if(key < tree[x].key)
            x = tree[x].left;
        else if(key > tree[x].key)
            x = tree[x].right;
        else
            return true;
    }
    return false;
}


int main(void){
    int n;
    scanf("%d",&n);

    for(int i = 0;i < n;i++){
        char s[20];
        scanf("%s",s);

        if(s[0] == 'i'){
            int key;
            scanf("%d",&key);
            insert(key);
        }else if(s[0] == 'f'){
            int key;
            scanf("%d",&key);
            if(find(key))
                printf("yes\n");
            else
                printf("no\n");
        }
        else{
            in(root);
            printf("\n");
            pre(root);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 8940
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
bool used[200000];
vector<int> hen[200000];

void dfs(int a){
     used[a]=true;
     for(auto&& i :hen[a])if(!used[i])dfs(i);
     return ;
}
     signed main(){
 int n,m,k,l;
 cin>>n>>m;
 for(int i=0;i<n;i++){
      cin>>k;
      for(int j=0;j<k;j++){
           cin>>l;l--;
           hen[i].push_back(n+l);
           hen[n+l].push_back(i);
      }
 }
 fill(used,used+n+m,false);
 dfs(0);
 for(int i=0;i<n;i++)if(!used[i]){
      cout<<"NO"<<endl;
      return 0;
 }
 cout<<"YES"<<endl;
 return 0;
 }






    





      

        


Measured memory_bytes: 9216
#include <iostream>
#include <cstdlib>
#include <queue>

using namespace std;
const static int SIDE_LEN_MAX = 1000;
int field[ SIDE_LEN_MAX + 2 ][ SIDE_LEN_MAX + 2 ];
int visit_data[ SIDE_LEN_MAX + 2 ][ SIDE_LEN_MAX + 2 ]; // zero-initialized.
struct position {
  int r, c;
  int step_n;
};

bool enqueue( queue<position> &posq, int r, int c, int step_n, int level ) {
  position newpos;
  if( visit_data[ r ][ c ] != level && field[ r ][ c ] != 'X' ) {
    newpos.r = r;
    newpos.c = c;
    newpos.step_n = step_n;
    visit_data[ r ][ c ] = level;
    posq.push( newpos );
    return true;
  }
  return false;
}

int main() {
  int h, w, n;
  position pos;
  queue<position> posq;
  int level = 1;

  cin >> h >> w >> n;
  for( int c = 0; c <= SIDE_LEN_MAX + 1; c++ ) {
    field[ 0 ][ c ] = 'X';
    field[ h + 1 ][ c ] = 'X';
  }

  for( int r = 1; r <= h; r++ ) {
    string line;
    cin >> line;
    field[ r ][ 0 ] = 'X';
    for( int c = 1; c <= w; c++ ) {
      field[ r ][ c ] = line[ c - 1 ];
      if( field[ r ][ c ] == 'S' ) {
        enqueue( posq, r, c, 0, level );
      }
    }
    field[ r ][ w + 1 ] = 'X';
  }

  while( 1 ) {
    pos = posq.front();
    posq.pop();
    if(
        '1' <= field[ pos.r ][ pos.c ] &&
        field[ pos.r ][ pos.c ] <= '9' &&
        level == field[ pos.r ][ pos.c ] - '0'
    ) {
      while( posq.size() > 0 ){ posq.pop(); }
      posq.push( pos );
      if( ++level == n + 1 ) {
        cout << pos.step_n << endl;
        break;
      }
    }
    enqueue( posq, pos.r - 1, pos.c    , pos.step_n + 1, level );
    enqueue( posq, pos.r    , pos.c - 1, pos.step_n + 1, level );
    enqueue( posq, pos.r + 1, pos.c    , pos.step_n + 1, level );
    enqueue( posq, pos.r    , pos.c + 1, pos.step_n + 1, level );
  }
  

  return EXIT_SUCCESS;
}

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}


const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

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

  modint all = modint(10).pow(n);
  modint non_0 = modint(9).pow(n);
  modint non_9 = modint(9).pow(n);
  modint non_09 = modint(8).pow(n);

  //cerr << all << endl;
  //cerr << non_0 << endl;
  //cerr << non_9 << endl;
  //cerr << non_09 << endl;

  modint ans = all - (non_0 + non_9 - non_09);
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define watch(x) cerr << (#x) << ": " << (x) << endl
 
const int N = 83, TP = 6401;
int h, w, a[N][N], b[N][N];
 
int c[N][N];
bool dp[N][N][TP];
 
int32_t main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin >> h >> w;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < h; ++i) {
        for(int j =0; j < w; ++j) {
            cin >> b[i][j];
        }
    }
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            c[i][j] = abs(a[i][j] - b[i][j]);
        }
    }
 
    dp[0][1][0] = true;
    dp[1][0][0] = true;
    
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            for(int t = 0; t < TP; ++t) {
                if(!dp[i][j+1][t] && !dp[i+1][j][t]) continue;
                int cand1 = abs(t - c[i][j]);
                dp[i+1][j+1][cand1] = true;
                int cand2 = t+c[i][j];
                if(cand2 < TP)
                    dp[i+1][j+1][cand2] = true;
            }
        }
    }

    int ans = 0;

    while(ans < TP && !dp[h][w][ans]) ans++;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 42752
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define RFor(i,b,a) for(ll i = b;i>=a;i--)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define mpll map<pll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 2e18;
const ll MAX = 405;


int main() {
    
    ll tc;
    tc = 1;
    //cin>>tc;
    while(tc--){
        ll n;
        cin>>n;
        cout<<(n>=30?"Yes":"No")<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
map<string,int> mp;
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;

	while(n--) {
		string s; cin>>s;
		mp[s]++;
	}
	vector<string> ve={"AC", "WA", "TLE","RE"};
	for(string a:ve) {
		cout<<a<<" x "<<mp[a]<<endl;
	}

	return 0;
}


Measured memory_bytes: 3664