akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		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 pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	int r = 0;
	ll sum = 0;
	ll x = 0;
	for (int l = 0; l < n; ++l) {
		while (r < n && sum + a[r] == (x ^ a[r])) {
			sum += a[r];
			x ^= a[r];
			r++;
		}
		ans += r - l;
		sum -= a[l];
		x ^= a[l];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    auto x = lread();
    if ((400 <= x) && (x <= 599))
    {
        writeln(8);

    }
    else if ((600 <= x) && (x <= 799))
    {
        writeln(7);

    }
    else if ((800 <= x) && (x <= 999))
    {
        writeln(6);

    }
    else if ((1000 <= x) && (x <= 1199))
    {
        writeln(5);
    }
    else if ((1200 <= x) && (x <= 1399))
    {
        writeln(4);
    }
    else if ((1400 <= x) && (x <= 1599))
    {
        writeln(3);
    }
    else if ((1600 <= x) && (x <= 1799))
    {
        writeln(2);
    }
    else if ((1800 <= x) && (x <= 1999))
    {
        writeln(1);
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3560
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    char[] cs = sc.next().toCharArray();
    int count = 0;
    for (int i = 0; i < N - 1; i++)
      if (cs[i] == cs[i + 1])
        count++;
    System.out.println((int) Math.min(count + K * 2, N - 1));
  }
}

Measured memory_bytes: 26936
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false); cin.tie(NULL)
#define ultimo 26;
using namespace std;
int main(){
fast_io;
int n;
string s;
cin>>n;
cin>>s;
int j=0;
char aux;
int aux2;
for(int i=0;i<s.size();i++){
    if(s[i]+n<='Z'){
    aux= s[i]+n;
    cout<<aux;
    }
    else {
    aux2=(s[i]+n)-ultimo;
    aux=aux2;
    cout<<aux;
    }
    j=j+1;
}
    return(0);
}


Measured memory_bytes: 3668
//2013/06/17    パソコン甲子園２０１１[1]
#include<iostream>
using namespace std;

int main()
{

        int t;
        int n;
        int s,f;

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

                for(int i=0; i<n; i++){
                        cin >> s >> f;
                        sum += (f-s);
                }
                if(sum >= t)
                        cout << "OK" << endl;
                else
                        cout << t-sum << endl;
        }
        return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
  int n,ma=-1,k,s;
  cin>>n;

  for(int i=1;i<=n;i++)
  {
     if(i%2==0)
     {    int b=i;
           k=0;
         while(b%2==0)
         {
             k++;
             b=b/2;
         }
     }
     if(k>ma)
     {
         ma=k;
         s=i;
     }
     else continue;

  }
  if(n==1) cout<<n<<endl;
  else cout<<s;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var w,h,x,y float64
	fmt.Scan(&w, &h, &x, &y)
	
	if w == 2*x && h == 2*y {
		fmt.Println(w*h/2.0, 1)
	} else {
		fmt.Println(w*h/2.0, 0)
	}
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

            char[] s = sc.next().toCharArray();
            StringBuilder sb = new StringBuilder();
            char[] t = sc.next().toCharArray();
            int dp[][] = new int[s.length + 1][t.length + 1];
            for(int i =1; i<=s.length; i++){
                for(int j =1; j<=t.length; j++){
                    if(s[i-1]==t[j-1]){
                        dp[i][j] = dp[i-1][j-1]+1;
                    }else
                        dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]); 
                }
            }

            int i = s.length;
            int j = t.length;
            while(i>0 && j>0){
                if(dp[i-1][j] == dp[i][j])
                    i--;
                else if(dp[i][j-1] == dp[i][j])
                    j--;
                else{
                    sb.insert(0, s[i-1]);
                    i--;
                    j--;
                }
            }
        
            System.out.println(sb.toString());
    }
	static final Random random = new Random();
	
	static void sort(int[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			int cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static void sortl(long[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			long cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (st == null  || !st.hasMoreTokens()) {
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		String nextLine() { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
		} 
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
	}

}


Measured memory_bytes: 84088
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>
#include <algorithm>

using namespace std;

using veci = vector<int>;
using pii = pair<int, int>;
using vecii = vector<pii>;
using ll = long long;
using vecl = vector<ll>;
#define fi first
#define se second
#define endl '\n'

ll const MOD = ll(1e9+7);
void solve() {
    int n;
    cin >> n;

    vector<int> cnt(60,0);
    ll ai;
    for (int i=0; i<n; ++i) {
        cin >> ai;
        for (int j=0; j<60; ++j) {
            if (ai & (1LL << j)) {
                cnt[j] += 1;
            }
        }
    }

    ll ans = 0;
    for (int j=0; j<60; ++j) {
        ll base = (1LL << j) % MOD;
        base *= cnt[j];
        base %= MOD;
        base *= n-cnt[j];
        base %= MOD;

        ans += base;
        ans %= MOD;
    }
    cout << ans << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#if defined(LOCAL_TEST)
    (void)argc;
    freopen(string(argv[0]).append("-test.in").c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}


Measured memory_bytes: 256
import std;

void calc(int n, int m) {
    int lo = 1;
    int hi = n;
    bool[int] used;
    foreach (i; 0..m) {
        int a = abs(lo - hi);
        int b = n - a;
        if (a == b || a in used || b in used) {
            hi--;
        }

        writeln(lo, " ", hi);
        lo++;
        hi--;
        used[a] = used[b] = true;
    }
}

void main() {
    int n, m; scan(n, m);
    calc(n, m);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 17620
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && k == 0 && m == 0) break;

			LinkedList<Integer> list = new LinkedList<Integer>();
			for(int i=1;i<=n;i++){
				list.add(i);
			}

			int idx = m - 1;
			while(list.size() != 1){
				list.remove(idx);
				idx = (idx + k - 1) % list.size();
			}

			System.out.println(list.get(0));
		}
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
vector<int>v[100000];
int a[2][100000];
int t;
void dfs(int k1,int k2=-1)
{
	if(k2!=-1)
		a[t][k1]=a[t][k2]+1;
	for(int i=0;i<v[k1].size();i++)
	{
		if(v[k1][i]!=k2)
			dfs(v[k1][i],k1);
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	t=0;
	dfs(0);
	t=1;
	dfs(n-1);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(a[0][i]<=a[1][i])
			sum++;
	}
	if(sum>=n/2+1)
		cout<<"Fennec";
	else
		cout<<"Snuke";

	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  if (n == 0) return cout << "0\n", 0;
  vi ans;
  while (n != 0) {
    if (abs(n % -2) == 1) {
      n--;
      ans.PB(1);
    } else {
      ans.PB(0);
    }
    n /= -2;
  }
  for (auto it = ans.rbegin(), end = ans.rend(); it != end; it++) {
    cout << *(it);
  }
  cout << endl;
}


Measured memory_bytes: 256
s = str(input())
s += "B"
l = len(s)
c = 0
mx = 0
for i in range(l):
  if s[i] in ["A","G","C","T"]:
    c += 1
  else:
    if c > mx:
      mx = c
      c = 0
    else:
      c = 0
print(mx)   
    

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n;
  while(true){
    cin >> n;
    if(n==0)break;
    int mp[101][101]={0};
    int w,h;
    cin >> w >> h;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      mp[x][y]=1;
    }
    int s,t;
    cin >> s >> t;
    int res=0;
    for(int i=1;i<=w-s+1;i++){
      for(int j=1;j<=h-t+1;j++){
        int temp=0;
        for(int k=0;k<s;k++){
          for(int l=0;l<t;l++){
            temp += mp[i+k][j+l];
          }
        }
        res=max(res,temp);
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3220
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    matrix[l][r] += 1
for i in range(N+1):
    for j in range(N):
        matrix[i][j+1] += matrix[i][j]
for i in range(N+1):
    for j in range(N):
        matrix[j+1][i] += matrix[j][i]
for i in range(Q):
    p,q = map(int,input().split())
    ans = matrix[q][q]-matrix[q][p-1]-matrix[p-1][q]+matrix[p-1][p-1]
    print(ans)

Measured memory_bytes: 13748
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

bool is753(int x)
{
    bool is3, is5, is7;
    is3 = is5 = is7 = false;
    while (x > 0) {
         int t = x % 10;
         if (t == 3) is3 = true;
        else if (t == 5) is5 = true;
        else if (t == 7) is7 = true;
        else return false;
        x /= 10;
    }
    return is3 && is5 && is7;
}

int main(int, char**)
{
       int n;
	int ans = 0;
	std::cin >> n;
       if (n < 357) ans = 0;
       else if (n < 375) ans = 1;
       else if (n < 537) ans =2;
       else if (n < 573) ans = 3;
       else if (n < 735) ans = 4;
       else if (n < 753) ans = 5;
       else { ans = 6;
       int t = 1000;
       int s = 100;
       int u = 10;
       for(int i = 3357; i <= n; i++) {
            if ((i / t)  > 9)  { t *= 10; s*=10; u*=10; }
            if ((i / t) != 3 && (i / t) !=5 && (i/t) !=7) {
                    i += (t - 1); continue;
           }
           int k = i % t;
           if ((k/s)!=3 && (k/s)!=5&&(k/s)!=7) {
                    i += (s -1); continue;
          }
          k = i % s;
           if (( k/u)!=3&&(k/u)!= 5 && (k/u)!=7) {
                   i += (u - 1); continue;
          }
            if (is753(i))  ans++;
       }
      }
       cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def solve(h, w):
  ans = 10**10
  for h1 in range(1, h):
    h2 = (h-h1)//2
    h3 = h-h1-h2
    M = w*max(h1, h2, h3)
    m = w*min(h1, h2, h3)
    if M-m < ans:
      ans = M-m
    h2 = h-h1
    w1 = w//2
    w2 = w-w1
    M = max(h1*w, h2*w1, h2*w2)
    m = min(h1*w, h2*w1, h2*w2)
    if M-m < ans:
      ans = M-m
  return ans
H, W = map(int, input().split())
print(min(solve(H, W), solve(W, H)))

Measured memory_bytes: 3064
import sys

x,n = map(int,input().split())
p = list(map(int,input().split()))
pp = [i for i in range(-103,103)]
ans = 1000
m = 1000

for j in range(n):
    pp.remove(p[j])

for k in pp:
    if m > abs(x-k):
        m = abs(x-k)
        ans = k

print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <atcoder/dsu>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using namespace atcoder;

int main() {
    int N, Q; cin >> N >> Q;
    dsu uni(N);
    int t,a,b;
    for (int i=0; i<Q; i++) {
        cin >> t >> a >> b;
        if (t == 0) {
            uni.merge(a, b);
        } else {
            cout << (uni.same(a, b) ? 1 : 0) << endl;
        }
    }    
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
const double eps = 1e-6;

double a[N];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	
	a[0] = 0.0;
	double p;
	for(int i = 1;i <= n;++i){
		scanf("%lf",&p);
		a[i] = a[i-1]+p;
	}
	
	for(int i = 2;i+k-1 <= n;++i){
		int pos = i+k-1;
		double l = a[pos-1] - a[i-2];
		double r = a[pos] - a[i-1];
		
		if(r-l > eps) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 5308
s = str(input())
r = ''.join(list(reversed(s)))
flag = [0,0,0,0]
t = ['maerd', 'remaerd', 'esare', 'resare']
while len(r) >= 0:
    if r[0:5] == t[0]:
        r = r[5:]
        flag[0] +=1
    elif r[0:7] == t[1]:
        r = r[7:]
        flag[1] +=1
    elif r[0:5] == t[2]:
        r = r[5:]
        flag[2] +=1
    elif r[0:6] == t[3]:
        r = r[6:]
        flag[3] +=1
    elif len(r) == 0:
        print('YES')
        break
    else:
        print('NO')
        break
# print(flag)

Measured memory_bytes: 9584
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

ll count_from_top(int i, vector<bool>& used, const vector<ll>& p, const vector<ll>& partial_sum, ll G){
  if(G <= 0) return 0;
  if(used[i] == true) return count_from_top(i-1, used, p, partial_sum, G);
  if(G > partial_sum[i]){
    return p[i] + count_from_top(i-1, used, p, partial_sum, G-partial_sum[i]);
  }
  if(G%(100*(i+1))==0){
    return G/(100*(i+1));
  }else{
    return G/(100*(i+1))+1;
  }
}

ll search(int i, vector<bool>& used, const vector<ll>& p, const vector<ll>& partial_sum, ll G, int D){
  if(i==D) return count_from_top(D-1, used, p, partial_sum, G);
  ll tmp1 = search(i+1, used, p, partial_sum, G, D);
  used[i] = true;
  ll tmp2 = p[i] + search(i+1, used, p, partial_sum, G-partial_sum[i], D);
  used[i] = false;
  return min(tmp1, tmp2);
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  int D;
  ll G;
  cin >> D >> G;
  vector<ll> p(D);
  vector<ll> c(D);
  vector<ll> partial_sum(D);
  vector<bool> used(D, false);
  rep(i, 0, D){
    cin >> p[i] >> c[i];
    partial_sum[i] = 100*(i+1)*p[i]+c[i];
  }

  cout << search(0, used, p, partial_sum, G, D) << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

 
public class Main {
  
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int L = sc.nextInt();
    int R = sc.nextInt();
    int d = sc.nextInt();
    double defValue = Math.ceil( ((double)L) / ((double)d));
    
    
    int i = (int)defValue;
    while(i * d <= R)
    {
 		i++;
    }
    
        System.out.println( (int)( i -  defValue) );
      
  }
}

Measured memory_bytes: 35832
#include <stdio.h>

int main(void){
  int n,a=0,b=0;
  scanf("%d",&n);
  if(n==1){
    printf("Hello World\n");
  }else{
    scanf("%d %d",&a,&b);
    printf("%d\n",a+b);
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))

from collections import defaultdict
dic = defaultdict(int)
dic[0] = 3
ans = 1

mod = 1000000007
for a in A:
  ans *= dic[a]
  ans = ans % mod
  dic[a] -= 1
  dic[a+1] += 1
print(ans)

Measured memory_bytes: 88712
s = input()
t = input()

s_prime = "".join(sorted(list(s)))
t_prime = "".join(sorted(list(t), reverse=True))

if s_prime == t_prime:
  print("No")
elif [s_prime, t_prime] == sorted([s_prime, t_prime]):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int a,b,c,tmp = 0;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    printf("%d",a + b);

}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
//#include <unordered_map>
//#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound
#define INF32 10e9
#define INF64 10e18

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]
#define print(a) if(DEBUG) cout << a << endl;
#define print2(a,b) if(DEBUG) cout << a << ' ' << b << endl;
#define print3(a,b,c) if(DEBUG) cout << a << ' ' << b << ' ' << c << endl;
#define print4(a,b,c,d) if(DEBUG) cout << a << ' ' << b << ' ' << c << ' ' << d << endl;


#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)

#define DEBUG true
//##############################################################################

vi arr[2000];
bool visited[2000];
int dist[2000];
int rep[2000];
int n;

void dfs(int src){

	/*for0(i, src + 1){
		visited[i] = true;
	}*/
	fori(i, 0, n){
		visited[i] = false;
	}
	for0(i, n) dist[i] = 0;
	visited[src] = true;

	list<int> queue;
	queue.pb(src);
	//int dist_x = 0;

	while(!queue.empty()){
		int u = queue.front();
		queue.pop_front();
		for0(i, arr[u].size()){
			if(!visited[arr[u][i]]){
				dist[arr[u][i]] = dist[u] + 1;
				visited[arr[u][i]] = true;
				queue.pb(arr[u][i]);
			}
		}
	}

	fori(i, src + 1, n){
		rep[dist[i]]++;
		//cout << dist[i] << " dist " << src + 1 << ' ' << i + 1<< endl;
	}

}

void solve(){
	cin >> n;
	for0(i,n-1){
		arr[i].pb(i+1);
		arr[i+1].pb(i);
		rep[i] = 0;
	}
	rep[n-1] = 0;
	int x, y;
	cin >> x >> y;
	arr[x-1].pb(y-1);
	arr[y-1].pb(x-1);

	for0(i, n){
		dfs(i);
	}

	fori(i, 1 ,n){
		cout << rep[i] << endl;
	}

}

int main(){
	int Q = 1;
	//cin >> Q;
	for0(q,Q) solve();

  return 0;
}


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

using namespace std;

int n;
vector<int> cnt(4);
vector<vector<vector<double>>> dp;

int main(){
    cin>>n;
    dp.resize(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1)));
    for(int i = 0; i < n; i++){
        int tmp; cin>>tmp;
        cnt[tmp]++;
    }
    dp[0][0][0] = 0.0;
    for(int k = 0; k <= n; k++){
        for(int j = 0; j <= n; j++){
            for(int i = 0; i <= n; i++){
                double kk = i + j + k;
                if(kk == 0 || n < kk) continue;
                dp[i][j][k] = (n/kk) + (1/kk) * ((i ? i*dp[i-1][j][k] : 0) + (j ? j*dp[i+1][j-1][k] : 0) + (k ? k*dp[i][j+1][k-1] : 0));
            }
        }
    }
    auto res = dp[cnt[1]][cnt[2]][cnt[3]];
    cout<<setprecision(20)<<res<<endl;
    return 0;
}

Measured memory_bytes: 220012
# -*- coding: utf-8 -*-
from itertools import takewhile
def solve():
    N,M,X,Y = list(map(int, input().split()))
    Xs = list(map(int, input().split()))
    Ys = list(map(int, input().split()))
    X1 = max(Xs)
    Y1 = min(Ys)
    Z0 = set(range(X+1, Y+1))
    Z1 = set(range(X1+1, Y1+1))
    Z = Z0&Z1
    if Z:
        res = "No War"
    else:
        res = "War"
    return str(res)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3064
# 解説動画の通り
import sys

# grobalにmdを設定すること
class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __neg__(self):
        return mint(-self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10 ** 9 + 7

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def nCr(com_n, com_r):
    if com_n < com_r: return 0
    return fac[com_n] * ifac[com_r] * ifac[com_n - com_r]

n_max = 200005
fac = [mint(1)]
for i in range(1, n_max + 1): fac.append(fac[-1] * i)
ifac = [mint(1)] * (n_max + 1)
ifac[n_max] /= fac[n_max]
for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1)

class SubTree:
    # vが場合の数、sが頂点数（根を除く）
    def __init__(self, v, s):
        self.v = v
        self.s = s

    def __add__(self, other):
        t = other.s + 1
        v = self.v * other.v * nCr(self.s + t, t)
        s = self.s + t
        return SubTree(v, s)

    def __sub__(self, other):
        t = other.s + 1
        s = self.s - t
        v = self.v / (other.v * nCr(self.s, t))
        return SubTree(v, s)

def main():
    def dfs1(u=0, pu=-1):
        for v in to[u]:
            if v == pu: continue
            dfs1(v, u)
            dp[u] += dp[v]

    def dfs2(u=0, pu=-1):
        dpu = dp[u]
        for v in to[u]:
            if v == pu: continue
            dp[v] += dpu - dp[v]
            dfs2(v, u)

    n = II()
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        to[a].append(b)
        to[b].append(a)
    dp = [SubTree(mint(1),0) for _ in range(n)]
    dfs1()
    dfs2()
    for a in dp: print(a.v)

main()


Measured memory_bytes: 174384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
ll dp[1001][1001];
char s[1001][1001];
main()
{
     ll n,m,i,j;
     cin>>n>>m;
     for(i=0;i<n;i++)
     {
         cin>>s[i];
     }
     for(i=0;i<n;i++)
     {
         if(s[i][0]=='.')
         {
             dp[i][0]=1;
         }
         else
         {
             break;
         }
     }
     for(i=0;i<m;i++)
     {
         if(s[0][i]=='.')
         {
             dp[0][i]=1;
         }
         else
         {
             break;
         }
     }
     for(i=1;i<n;i++)
     {
         for(j=1;j<m;j++)
         {
             if(s[i][j]=='#')
             {
                 dp[i][j]=0;continue;
             }
             ll a=0;
             a+=dp[i-1][j];
             a+=dp[i][j-1];a=a%mod;
             dp[i][j]=a;
         }
     }
     printf("%lld\n",dp[n-1][m-1]);
}


Measured memory_bytes: 12436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int s=N%10;
  if(s==3) cout<<"bon"<<endl;
  else if(s==0||s==1||s==6||s==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}


Measured memory_bytes: 3592
S = str(input())
n = len(S)

c = [1] * n
for i in range(n):
  if S[i] == 'R' and S[i+1] == 'R':
    c[i+2] += c[i]
    c[i] = 0

for i in range(n-1, -1, -1):
  if S[i] == 'L' and S[i-1] == 'L':
    c[i-2] += c[i]
    c[i] = 0

print(' '.join(map(str, c)))

Measured memory_bytes: 10484
#!/usr/bin/env python3

import sys
from math import gcd, sqrt
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


A, B = map(int, input().split())
g = gcd(A, B)


def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a


primes = prime_factorize(g)
print(len(primes)+1)



Measured memory_bytes: 9056
#include <stdio.h>

int main()
{
	int N, i,j;
	scanf("%d", &N);

	for(i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			if(i * 4 + j * 7 == N){
				printf("Yes\n");
				return 0;
			}
			
			
		}
		
		
	}
	printf("No\n");
	
	
	return 0;
}

Measured memory_bytes: 128
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , m ;
	cin>> n >> m ;
	ll arr[m];
	for(ll i=0;i<m ;i++)cin>>arr[i];
	ll sum=0;
	for(ll i=0;i<m ;i++)sum+=arr[i];
	ll ans = n-sum;
	if(ans<0)cout<<-1<<endl;
	else cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3640
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "numeric"
using namespace std;

long gcm(long a,long b) {
	if (a < b)swap(a, b);
	while (b%a != 0) {
		a -= b % a;
		if (a < b)swap(a, b);
	}
	return a;
}

int main() {
	long a, b;
	cin >> a >> b;
	cout << a * b / gcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e6 + 10;
int N;
int A[MAXN];
int ans;

int main() {
	register int i;
	scanf("%d", &N);
	for(i = 1; i <= N << 1; ++i)
		scanf("%d", A + i);
	sort(A + 1, A + (N << 1) + 1);
	for(i = 1; i <= N << 1; i += 2)
		ans += A[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

#define fo(i,a,b) for (register int i = a;i <= b;i ++)
#define fd(i,a,b) for (register int i = a;i >= b;i --)
#define wr(a,b) printf("%s = %d\n",a,b)
#define mem(a,b) memset(a,(b),sizeof(a))

using namespace std;

const int N = 100010;

int n;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 //   freopen("in.txt","r",stdin);
     
    cin >> n;
    if (n <= 9) {
		cout << n << endl;
		return 0;
    }
    int a = 1, ans = 0, k = 0, b;
	fo (i,1,6){
		if (n / a <= 1)  {
			k = i;
			if (n / a < 1) k -- , a /= 10;
			ans += (k % 2) * (n - a + 1);
			break;
		}
	    a *= 10;
	}
	a = 0, b = 9;
	fo (i,1,k - 1){
		if (i & 1) ans += b - a;
		b = b * 10 + 9;
		a = a * 10 + 9;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int h, w, dot = 0;
    char s[52][52];           //入力
    int d[52][52];            //距離
    queue<pair<int, int>> q;  // x,y

    fill(s[0], s[52], '#');
    fill(d[0], d[52], 0);

    cin >> h >> w;
    for (int y = 1; y <= h; y++) {
        for (int x = 1; x <= w; x++) {
            cin >> s[x][y];
            if (s[x][y] == '.') {
                dot++;
            }
        }
    }

    q.push(make_pair(1, 1));

    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        //cout << "x:" << p.first << "y:" << p.second << endl;
        //到達
        if (p.first == w && p.second == h) {
            cout << dot - d[p.first][p.second] - 1 << endl;
            return 0;
        }

        if (s[p.first][p.second + 1] == '.' && d[p.first][p.second + 1] == 0) {
            q.push(make_pair(p.first, p.second + 1));
            d[p.first][p.second + 1] = d[p.first][p.second] + 1;
        }
        if (s[p.first + 1][p.second] == '.' && d[p.first + 1][p.second] == 0) {
            q.push(make_pair(p.first + 1, p.second));
            d[p.first + 1][p.second] = d[p.first][p.second] + 1;
        }
        if (s[p.first][p.second - 1] == '.' && d[p.first][p.second - 1] == 0) {
            q.push(make_pair(p.first, p.second - 1));
            d[p.first][p.second - 1] = d[p.first][p.second] + 1;
        }
        if (s[p.first - 1][p.second] == '.' && d[p.first - 1][p.second] == 0) {
            q.push(make_pair(p.first - 1, p.second));
            d[p.first - 1][p.second] = d[p.first][p.second] + 1;
        }

        /*
        for (int y = 1; y <= h; y++) {
            for (int x = 1; x <= w; x++) {
                cout << d[x][y];
            }
            cout << endl;
        }
        cout << "------" << endl;*/
    }

    cout << -1 << endl;
    return 0;
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 100005
int p[N], pi[N], cid[N], id, x, y;
bool vis[N];
vector<vi > g(N);

void dfs(int u) {
    cid[u] = id;
    vis[u] = true;
    for(auto v:g[u]) {
        if(!vis[v]) dfs(v);
    }
}

int main() {
	ios::sync_with_stdio(0);
    INN(n, m);
    FI(n) {
        cin>>p[i];
        pi[p[i]] = i;
    }
    F(m) {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    id=0;
    mems(vis, false);
    FI(n) {
        if(vis[i]) continue;
        dfs(i);
        id++;
    }
    int cnt=0;
    FI(n) {
        if(p[i]==i) {
            cnt++;
            continue;
        }
        int v = p[i];
        int pos = pi[i];
        if(cid[i]==cid[pos]) {
            cnt++;
            p[i] = i;
            p[pos] = v;
            pi[i] = i;
            pi[v] = pos;
        }
    }
    cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<int>> ans(h, vector<int>(w));
    int idx = 0;
    rep(i, h) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; ++j) {
                ans[i][j] = idx;
                a[idx]--;

                if (a[idx] == 0)
                    ++idx;
            }
        } else {
            for (int j = w - 1; j >= 0; --j) {
                ans[i][j] = idx;
                a[idx]--;

                if (a[idx] == 0)
                    ++idx;
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (j != 0)
                cout << " ";
            cout << ans[i][j] + 1;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <set>
using namespace std;

typedef pair<string, int> S;

vector<pair<string, string> > conv;


void put(string &t, int n) {
  for(int i = 0; i+conv[n].first.size() <= t.size(); ++i) {
    if(t.substr(i, conv[n].first.size()) == conv[n].first) {
      t = t.substr(0, i) + conv[n].second + t.substr(i+conv[n].first.size());
      i += -1 + conv[n].second.size();
    }
  }
}

int solve(string from, string to) {
  queue<S> que;
  S s;
  s = make_pair(from, 0);
  que.push(s);
  set<string> vis;
  vis.insert(s.first);
  while(!que.empty()) {
    s = que.front(); que.pop();
    if(s.first == to) {
      return s.second;
    }
    if(s.first.size() >= to.size()) continue;

    for(int i = 0; i < conv.size(); ++i) {
      string t = s.first;
      put(t, i);
      //cout << t << endl;
      if(vis.find(t) != vis.end()) continue;
      vis.insert(t);
      que.push(make_pair(t, s.second+1));
    }
  }
  return -1;
}

int main() {
  int N;
  string s1, s2;
  while(cin >> N && N) {
    conv.clear();
    for(int i = 0; i < N; ++i) {
      cin >> s1 >> s2;
      conv.push_back(make_pair(s1, s2));
    }
    cin >> s1 >> s2;
    cout << solve(s1, s2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1104
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

ll a[100010],b[100010],ans[100010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,q;scanf("%d%d",&n,&q);
	int m=1;a[1]=n;
	for (int i=1;i<=q;i++)
	{
		ll x;scanf("%lld",&x);
		while (m&&a[m]>=x) m--;
		a[++m]=x;
	}
	memset(b,0,sizeof(b));b[m]=1;
	ll s=0;memset(ans,0,sizeof(ans));
	for (int i=m;i;i--)
	{
		ll x=a[i];int k=i-1;
		while (k)
		{
			int l=1,r=k;
			while (l<=r)
			{
				int mid=(l+r)>>1;
				if (a[mid]<=x) l=mid+1; else r=mid-1;
			}
			if (!r) break;
			b[r]+=x/a[r]*b[i];
			x%=a[r];k=r-1;
		}
		s+=b[i];ans[x]-=b[i];
	}
	for (int i=0;i<n;i++)
	{
		s+=ans[i];printf("%lld\n",s);
	}
	return 0;
}


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

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

    // cin >> cells.at(0);

    int res = 0;

    for (int i=0; i<n; i++) {
        if ((i+1)%2 != 0 && cells[i]%2 != 0) {
            res++;
        }
    }

    cout << res << endl;
}


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

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

Node *root, *NIL;

void insert(int key)
{
    Node *newnode = (Node *)malloc(sizeof(Node));
    newnode -> key = key;
    newnode -> parent = NIL;
    newnode -> left = NIL;
    newnode -> right = NIL;

    Node *x = root;
    Node *y = NIL;

    while (x != NIL)
    {
        y = x;

        if (x -> key >= newnode -> key)
        {
            x = x -> left;
        }
        else
        {
            x = x -> right;
        }
    }

    newnode -> parent = y;

    if (y == NIL)
    {
        root = newnode;
    }
    else
    {
        if (y -> key >= newnode -> key)
        {
            y -> left = newnode;
        }
        else
        {
            y -> right = newnode;
        }
    }
}

bool find(int key)
{
    Node *x = root;
    Node *y = NIL;

    while (x != NIL)
    {
        if (x -> key == key)
        {
            return true;
        }
        else if (x -> key > key)
        {
            x = x -> left;
        }
        else
        {
            x = x -> right;
        }
    }
    return false;
}

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

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

int main()
{
    int m, key;
    string command;

    cin >> m;

    for (int i = 0; i != m; ++i)
    {
        cin >> command;

        if (command == "insert")
        {
            cin >> key;
            insert(key);
        }
        else if(command == "find")
        {
            cin >> key;
            if (find(key))
            {
                cout << "yes" << endl;
            }
            else
            {
                cout << "no" << endl;
            }
            
        }
        else if (command == "print")
        {
            inParse(root);
            cout << endl;
            preParse(root);
            cout << endl;
        }
    }

    return 0;
}



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


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

    int slen = s.size() - 2;
    string t = to_string(slen);

    cout << s.substr(0, 1) + t + s.substr(s.size() - 1, 1) << endl;

}


Measured memory_bytes: 3652
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: i32 = read_as_vec()[0];
    let mut ans = 0;

    for i in 1..n+1{
        let mut n = i;
        let mut div_counter = 0;
        while n / 10 != 0{
            div_counter += 1;
            n /= 10;
        }

        if div_counter%2 == 0{
            ans += 1;
        }
    }

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


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	s+="00";
	n+=2;
	int out=0;
	vi in;
	int co=0;
	rep(i,n){
		if(s[i]=='1')co++;
		else{
	//		cout<<i<<" "<<in.size()<<" "<<co<<endl;
			if(co==0){
				if(in.size()==0)continue;
				if(in.size()==1){
					in=vi(0);
					continue;
				}
				vvi dp(in.size(),vi(4));
				rep(j,in.size()-1)rep(k,4){
					if(j==0&&k)continue;
					cmax(dp[j+1][0],dp[j][k]);
					//left
					int t=in[j];
					if(k==1)t--;
					if(k==2)t=1;
					if(k==3){
						cmax(dp[j+1][0],dp[j][k]);
						continue;
					}
					if(in[j+1]==1){
						cmax(dp[j+1][3],dp[j][k]+t);
					}else cmax(dp[j+1][1],dp[j][k]+t);
					//right
					t=in[j+1];
					if(t==1){
						cmax(dp[j+1][3],dp[j][k]+t);
					}else{
						cmax(dp[j+1][3],dp[j][k]+t);
						cmax(dp[j+1][2],dp[j][k]+t-1);
					}
				}
	//			rep(j,dp.size()){rep(k,4)cout<<" "<<dp[j][k];cout<<endl;}
				int q=0;
				q=max(q,dp[in.size()-1][0]);
				q=max(q,dp[in.size()-1][1]);
				q=max(q,dp[in.size()-1][2]+1);
				q=max(q,dp[in.size()-1][3]);
				out+=q;
//				rep(j,in.size())cout<<" "<<in[j];cout<<endl;
//				cout<<q<<endl;
				in=vi(0);
			}else{
				in.pb(co);
				co=0;
			}
		}
	}
	cout<<out<<endl;
}



Measured memory_bytes: 900
#include <stdio.h>
 
int f[45];
int fibonacci(int n){
  int i;
  f[0]=1;
  f[1]=1;
  if(n>1){
    for(i=2; i<=n; i++){
      f[i]=f[i-1]+f[i-2];
    }
  }
  return f[n];
}
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  return 0;
}

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


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

  for(int i=1; i<=n; i++){
    x = i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
        cout << " " << i;
        break; 
      }
     x /= 10;
    }
  }
  cout << endl;
}

Measured memory_bytes: 3068
n = int(input())
a = [list(map(int, input().split(' '))) for i in range(n)]
for x in range(101):
    for y in range(101):
        for i in range(n):
            if a[i][2] > 0:
                htop = a[i][2] + abs(x-a[i][0]) + abs(y-a[i][1])
                break
        for i in range(n):
            if a[i][2] == 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) > 0:
                    break
            if a[i][2] > 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) != a[i][2]:
                    break
        else:
            print(x,y,htop)
            exit()


Measured memory_bytes: 3064
from collections import deque
S = input()
L = deque([])
for i in range(len(S) - 1):
    L.append(S[i:i+2])
RL = [i for i, x in enumerate(L) if x == "RL"]
LR = [i for i, x in enumerate(L) if x == "LR"]
LR.insert(0, -1)
LR.append(len(S) - 1)
ans = [0] * len(S)

for j in range(len(LR) - 1):
    a = LR[j + 1] - LR[j]
    
    if a % 2:
        if (RL[j] - LR[j]) % 2:
            ans[RL[j]] = int(a/2) + 1
            ans[RL[j] + 1] = int(a/2)
        else:
            ans[RL[j]] = int(a/2)
            ans[RL[j] + 1] = int(a/2) + 1
    else:
        ans[RL[j]] = int(a / 2)
        ans[RL[j] + 1] = int(a / 2)
anss = ""
for i in ans:
    anss = anss + str(i) + " "
print(anss)

Measured memory_bytes: 15152