akhauriyash/Code-Regression huggingface dataset:
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100, MAXI = 5000, D = 9;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 10, flag = 1;
//     cout << tc << "\n";
//     int n = 1;
//     while (tc--)
//     {
//     	int n = rand()%N + 1;
//     	int k = rand()%MAXI + 1;

//     	cout << n << " " << k << "\n";

//     	for(int i=0;i<n;i++)
//     	{
//     		for(int j=0;j<n;j++)
//     		{
//     			cout << rand()%2 << " ";
//     		}
//     		cout << "\n";
//     	}
    	
//     	cout << "~\n";
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
//#define ll long long
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 405
#define M 100005

int n;
int a[N];
pair<int, int> dp[N][N];

pair<int, int> MEM(int i, int j)
{
	if(i==j)
	{
		return dp[i][j] = {0, a[i]};
	}

	pair<int, int> &ans = dp[i][j];

	if(ans.first!=-1)
		return ans;

	ans = {MAXI, MAXI};

	for(int l=i;l<j;l++)
	{
		pair<int, int> x = MEM(i, l);
		pair<int, int> y = MEM(l+1, j);

		pair<int, int> z;

		z.first = x.second + y.second + x.first + y.first;
		z.second = x.second + y.second;

		if(z.first<ans.first)
			ans = z;

	}

	return ans;
}


// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	cout.tie(NULL);

	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];

	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			dp[i][j] = {-1, -1};

	pair<int,int> ans = MEM(0, n-1);

	cout << ans.first;

	
    return 0;
 
} 


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

int main() {
  string s,t;
  cin>>s>>t;
  int a,b,i,j;
  a=s.size();
  b=t.size();
  for(i=a-1;i>b-2;i--){
    for(j=0;j<b;j++){
      if(s[i-j]!=t[b-j-1]&&s[i-j]!='?')break;
  }
  if(j==b)break;
}
  if(j==b){
    for(int k=0;k<i-b+1;k++){
      if(s[k]!='?')cout<<s[k];
      else cout<<'a';
    }
    for(int k=0;k<b;k++) cout<<t[k];
    for(int k=i+1;k<a;k++){
      if(s[k]!='?')cout<<s[k];
      else cout<<'a';
    }
    }
    else cout<<"UNRESTORABLE";
    cout<<endl;
  }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long x = sc.nextLong();
        
        if(500*k<x){
            System.out.print("No");
        }else{
            System.out.print("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,x,y;
    cin>>n>>x>>y;
    
    vector<int> s(n-1);
    
    int dist;
    for(int i=1;i<n;i++){
      for(int j=i+1;j<=n;j++){
        dist = min(j-i, abs(x-i)+abs(y-j)+1);
        s[dist-1]++;
      }
    }
    
    for(int i=0;i<n-1;i++){
      cout<<s[i]<<endl;
    }   
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
#define MAX_LEN (80)
 
int main(void)
{
    int no;
     
    scanf("%d", &no);
     
    while (no--){
        char num_str[MAX_LEN + 2];
        char add_str[MAX_LEN + 2];
        int num_len, add_len;
        int i;
        int tmp;
         
        scanf("%81s", num_str);
        scanf("%81s", add_str);
        num_len = strlen(num_str);
        add_len = strlen(add_str);
         
        memmove(&num_str[MAX_LEN - num_len + 1], num_str, num_len);
        for (i = 0; i < MAX_LEN - num_len + 1; i++) num_str[i] = '0';
        num_str[MAX_LEN + 1] = '\0';
         
        memmove(&add_str[MAX_LEN - add_len + 1], add_str, add_len);
        for (i = 0; i < MAX_LEN - add_len + 1; i++) add_str[i] = '0';
        add_str[MAX_LEN + 1] = '\0';
         
        tmp = 0;
        for (i = MAX_LEN; i + 1; i--){
            num_str[i] = num_str[i] + (add_str[i] - '0') + tmp;
            if (num_str[i] > '9'){
                num_str[i] = num_str[i] - 10;
                tmp = 1;
            }
            else tmp = 0;
        }
         
        if (num_str[0] != '0') puts("overflow");
        else {
            for (i = 1; num_str[i] == '0'; i++);
            if (i == MAX_LEN + 1) puts("0");
            else puts(&num_str[i]);
        }
    }
     
    return (0);
}

Measured memory_bytes: 592
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int l_max = -1, r_min = 1000000000;
	int N, M;
	cin >> N >> M;
	int l, r;
	for (size_t i = 0; i < M; i++) {
		cin >> l >> r;
		l_max = max(l_max, l);
		r_min = min(r_min, r);
	}
	if (r_min < l_max)cout << 0 << endl;
	else cout << r_min - l_max + 1 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
d = {}
for i in range(m):
    tmp = list(map(int, input().split()))
    k = tmp[0]
    for s in tmp[1:]:
        if s in d:
            d[s].append(i)
        else:
            d[s] = [i]
p = list(map(int, input().split()))

def on_off(s):
    if len(s) == n:
        states.append(s)
        return
    on_off(s+str(0))
    on_off(s+str(1))

states = []
ans =0
on_off("")
for state in states:
    d_count = [0 for _ in range(m)]
    for i in range(len(state)):
        if state[i] == '1' and i +1 in d:
            for j in d[i+1]:
                d_count[j] += 1
    c = 1
    for k in range(m):
        if d_count[k] % 2 != p[k]:
            c = 0
            break
    ans += c

print(ans)


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

int main(){

  int n,k,ans=0;
  cin >> n >> k;
  
  vector<int> h(n);
  
  for(int i = 0; i < n; i++){

    cin >> h.at(i);
  if(h.at(i) >= k)
    ans++;
  
  }
  
  cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 100100;
const int A = 10;
int n;
int s[N];
char ss[N];
int a[N];
int SA[N], nSA[N];
int ord[N], nord[N];
int revSA[N];

void buildSA() {
	for (int i = 0; i <= A; i++)
		a[i] = 0;
	for (int i = 0; i < n; i++)
		a[s[i] + 1]++;
	for (int i = 1; i <= A; i++)
		a[i] += a[i - 1];
	for (int i = 0; i < n; i++)
		SA[a[s[i]]++] = i;
	ord[SA[0]] = 0;
	for (int i = 1; i < n; i++) {
		ord[SA[i]] = ord[SA[i - 1]];
		if (s[SA[i]] != s[SA[i - 1]]) ord[SA[i]]++;
	}
	for (int len = 1; ord[SA[n - 1]] != n - 1; len <<= 1) {
		for (int i = 0; i <= n; i++)
			a[i] = 0;
		for (int i = 0; i < n; i++) {
			int p = SA[i];
			p -= len;
			if (p < 0) p += n;
			a[ord[p] + 1]++;
		}
		for (int i = 1; i <= n; i++)
			a[i] += a[i - 1];
		for (int i = 0; i < n; i++) {
			int p = SA[i];
			p -= len;
			if (p < 0) p += n;
			nSA[a[ord[p]]++] = p;
		}
		nord[nSA[0]] = 0;
		for (int i = 1; i < n; i++) {
			int p1 = nSA[i], p2 = nSA[i - 1];
			int q1 = p1 + len, q2 = p2 + len;
			if (q1 >= n) q1 -= n;
			if (q2 >= n) q2 -= n;
			nord[p1] = nord[p2];
			if (ord[p1] != ord[p2] || ord[q1] != ord[q2]) nord[p1]++;
		}
		for (int i = 0; i < n; i++) {
			SA[i] = nSA[i];
			ord[i] = nord[i];
		}
	}
	for (int i = 0; i < n; i++)
		revSA[SA[i]] = i;
}

int solve(int L, int B) {
	int p = 0;
	int res = 0;
	while(res <= n && p < n) {
		res++;
		if (revSA[p] <= B)
			p += L;
		else
			p += L - 1;
	}
	return res;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int k;
	scanf("%d %s", &k, ss);
	n = strlen(ss);
	for (int i = 0; i < n; i++)
		s[i] = (int)(ss[i] - '0');
	s[n++] = 0;
	buildSA();
	n--;

	k++;
	int L = (n + k - 1) / k;
	int l = -1, r = n;
	while(r - l > 1) {
		int x = (l + r) / 2;
		if (solve(L, x) <= k)
			r = x;
		else
			l = x;
	}
	r = SA[r];
	for (int i = 0; i < L; i++)
		printf("%c", ss[r + i]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 6000
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N; cin>>N;
    vector<ll>l(N);
    rep(i,N)cin>>l[i];
    sort(l.begin(),l.end());
    ll ans =0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            int a=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
            ans+=a-(j+1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def typing(s, ans):
    for i in range(len(s)):
        if s[i] == '0':
            ans += '0'
        if s[i] == '1':
            ans += '1'
        if s[i] == 'B' and ans != '':
            ans = ans[:len(ans)-1]

    print(ans)

S = str(input())
ANS = ''
typing(S, ANS)

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char x,b,c,d;
	while(cin>>x>>b>>c>>d){
		int ans=0;
		if(x==b&&b==c)
			ans=1;
		if(b==c&&c==d)
			ans=1;
		if(ans)
			puts("Yes");
		else
			puts("No");
	}
	
	return 0;
}

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

int main() {
    int n;
    char str[10], com[13];
    map<string, bool> T;
    
    cin >> n;
    for (int i=0; i<n; i++) {
        scanf("%s%s", com ,str);
        if(com[0] == 'i') T[string(str)] = true;
        else {
            if(T[string(str)]) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 47472
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int D = in.nextInt();
		if (D == 25) {
			System.out.println("Christmas");
		} else if (D == 24) {
			System.out.println("Christmas Eve ");
		} else if (D == 23) {
			System.out.println("Christmas Eve Eve");
		} else if (D == 22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}


Measured memory_bytes: 23764
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 2e5 + 10;
#define singleCase
// #define multipleCase
ll n,k,a[N];

ll updiv(ll a , ll b) {
   ll q = a / b;
   return q * b < a ? q + 1 : q;
}

bool valid(ll x) {
   ll use = 0;
   for (ll i = 1 ; i <= n ; i++) {
      use += updiv(a[i] , x) - 1;
   }
   return use <= k;
}

void work() {
   scanf("%lld%lld" , &n , &k);
   for (ll i = 1 ; i <= n ; i++) {
      scanf("%lld" , &a[i]);
   }
   sort(a + 1 , a + n + 1);
   ll l = 1, r = a[n], mid, sol = -1;
   while (l <= r) {
      mid = (l + r) / 2;
      if (valid(mid)) {
         r = mid - 1;
         sol = mid;
      } else {
         l = mid + 1;
      }
   }
   printf("%lld\n" , sol);
   return;
}

int main() {
   #ifdef multipleCase
      ll nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(ll &x) {
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 5284
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
typedef long long LL;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define FOREACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define PI 3.1415926535897
#define INF 1000000000
//#define INF 9

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


int main(){
	int h,w;
	int i,j;
	int minh = 0,minw = 0;;
	int taikaku;
	long long min = 999999999999999;

	while(1){
		
		cin >> h >> w;
		if(h == 0 &&  w == 0)break;
		min = 99999999999999999;
		taikaku = h * h + w * w;
		
		for(i =1;i <= 150 && i * i < taikaku;i++){
			j = i + 1;
			while(1){//925
				
				int  x = i * i + j * j;

				
				if(x == taikaku){
					if(x < min && h < i ){
						
						min = x;
						minh = i;
						minw = j;
						break;
						
					}
					
				}
				
				if(x > taikaku){
					if(i != h || j != w){
						if(min > x){
							min = x;
							minh = i;
							minw = j;

						}
					}
					break;
				}
			j++;
			}


		}

		cout << minh << " " << minw << endl;
	}
	
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    int x = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        x ^= a[i];
    }

    for(int i = 0; i < n; ++i) {
        x ^= a[i];
        cout << x << " ";
        x ^= a[i];
    }
    return 0;
}


Measured memory_bytes: 3956
def prime_table(N):
    P = [False]*2+[True]*(N-1)
    for i in range(2,int(N**.5)+1):
        if P[i]: P[2*i::i] = [False]*(N//i-1)
    return P

N=int(input())
print(*[i for i, p in enumerate(prime_table(55555)) if p and i % 10 == 1][:N])

Measured memory_bytes: 3904
//
// Created by Myabu on 2020/01/15.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    string c;
    cin>>c;

    string boin = "aiueo";

    if(boin.find(c) != string::npos){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
from collections import deque, OrderedDict

class Puzzle:
    def __init__(self, field=None, path=''):
        self.f = field
        self.space = None
        for i in range(9):
            if self.f[i] == 9:
                self.space = i
        self.path = path

    def __lt__(self, pzl): # <
        for i in range(9):
            if self.f[i] == pzl.f[i]:
                continue
            return self.f[i] > pzl.f[i]
        return False

    def __gt__(self, pzl): # >
        for i in range(9):
            if self.f[i] == pzl.f[i]:
                continue
            return self.f[i] < pzl.f[i]
        return False

dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
dir = ['u', 'l', 'd', 'r']

def is_target(pzl):
    for i in range(9):
        if pzl.f[i] != i+1:
            return False
    return True

def bfs(pzl):
    queue = deque([])
    V = {}
    pzl.path = ''
    queue.append(pzl)
    V[str(pzl.f)] = True
    if is_target(pzl):
      return pzl.path

    while len(queue) != 0:
        u = queue.popleft()
        sx, sy = u.space//3, u.space%3
        for r in range(4):
            tx, ty = sx + dx[r], sy + dy[r]
            if tx < 0 or ty < 0 or tx >= 3 or ty >= 3:
                continue
            v = Puzzle(field=[u.f[i] for i in range(9)], path=u.path)
            v.f[u.space], v.f[tx*3+ty] = v.f[tx*3+ty], v.f[u.space]
            v.space = tx*3 + ty
            if str(v.f) not in V:
                V[str(v.f)] = True
                v.path += dir[r]
                if is_target(v): return v.path
                queue.append(v)
    return 'unsolvable'

field = []
for i in range(3):
    field.extend(list(map(int, input().split(' '))))

for i in range(9):
    if field[i] == 0: field[i] = 9

pzl = Puzzle(field=field)
ans= bfs(pzl)
print(len(ans))



Measured memory_bytes: 45408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define F first
#define S second 
using namespace std;
typedef pair<int,int> Pi;

int main(){
    int M,T,P,R;
    while(cin >> M >> T >> P >> R,M|T|P|R){
        vector<Pi> ST(T);
        vector<vector<int> > cnt(T, vector<int>(P));
        rep(i,R){
            int m,t,p,r;
            cin >> m >> t >> p >> r;
            t--; p--;
            if(r == 0){
                ST[t].F++;
                ST[t].S -= m+20*cnt[t][p];
            }
            else cnt[t][p]++;
        }
        vector<int> num(T);
        iota(num.begin(),num.end(),0);
        reverse(num.begin(),num.end());
		stable_sort(num.begin(),num.end(),[&](int i,int j){return ST[i]>ST[j];});
		cout << num[0]+1;
        for(int i=1; i<T; i++){
            if(ST[num[i]]==ST[num[i-1]]) cout << '=';
            else cout << ',';
            cout << num[i]+1;
        }
        cout << endl;
    }
    return 0;
}


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

//create arrays outside of main()

int a[100];

int main(){

    int a;
    int b;
    
    cin >> a >> b;

    if (a<b){
        cout << "0";
    } else {
        cout << "10";
    }

    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> c(n);
	vector<int> s(n);
	vector<int> f(n);
	rep(i,n-1) cin >> c.at(i) >> s.at(i) >> f.at(i);
	int ans=0;
	rep(i,n-1){
		ans=0;
		for(int j=i;j<n-1;++j){
			if(ans<=s.at(j)){
				ans=s.at(j)+c.at(j);
			}
			else{
				if(ans%f.at(j)!=0) ans+=f.at(j)-ans%f.at(j);
				ans+=c.at(j);
			}
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let n = s.len();
    let m = t.len();
    let mut ans = std::i64::MAX;

    for i in 0..n - m + 1 {
        let mut count = 0;
        for j in 0..m {
            if s[i + j] != t[j] {
                count += 1;
            }
        }
        if count < ans {
            ans = count;
        }
    }

    println!("{}", ans)
}


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

int main(){
    string s, ans="";
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='B'){
            if(ans.length() != 0){
                int last = ans.length()-1;
                ans.erase(last);
            }
        }
        else ans +=s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
int dp[100005][2],n;
int recurse(int a[],int i,int dec){
    if(dp[i][dec]!=-1)
        return dp[i][dec];
    if(i==n-1)
        return 1;
    int ans=0;
    if(!dec){
        if(a[i+1]<a[i])
            ans=0;
        else{
            if(a[i]<=a[i+1]-1)
                ans=ans|recurse(a,i+1,dec);
            ans=ans|recurse(a,i+1,!dec);
        }
    }
    else{
        if(a[i]-1>a[i+1])
            ans=0;
        else{
            if(a[i+1]-1>=a[i])
                ans=ans|recurse(a,i+1,dec);
            ans=ans|recurse(a,i+1,!dec);
        }
    }
    dp[i][dec]=ans;
    return ans;
}
int main(){
IOS;
int i;
cin>>n;
int a[n];
for(i=0;i<n;i++)
    cin>>a[i];
for(i=0;i<=n;i++){
    dp[i][0]=-1;
    dp[i][1]=-1;
}
int ans=recurse(a,0,1)|recurse(a,0,0);
if(ans)
    cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int age;
  cin >> age;
  if(age == 1){
    cout << "Hello World" << endl;
  }
  else{
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }


  return 0;
}

Measured memory_bytes: 256
S = list(input())
Q = int(input())
re = False
top = []
end = []
for i in range(Q):
    line = list(map(str,input().split()))
    if line[0] == '1':
        if re == True:
            re = False
        else:
            re = True
    else:
        if (re == False and line[1] == '1') or (re == True and line[1] == '2'):
            top.append(line[2])
        else:
            end.append(line[2])

if re == True:
    S.reverse()
    end.reverse()
    ans = end + S + top
else:
    top.reverse()
    ans = top + S + end
print(''.join(ans))
    

Measured memory_bytes: 15640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int count=0,x,i=0;
  string s;
  cin>>s;
  x=s.size();
  while(i<x){
    if((s[i]=='0' && s[i+1]=='1') || (s[i]=='1' && s[i+1]=='0')){
      count+=2;
      s.erase(i,2);
      if(i!=0) i--;
      continue;
    }
    i++;
  }
  cout<<count<<endl;
  return 0;
}

      


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int a, b;
    cin >> a >> b;
    int c = (a + b);
    int d = c / 2 + (c % 2);
    cout << d << endl;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int,input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
o = 0

for i in range(n):
	s = 0
	for j in range(m):
		s += b[j] * a[i][j]

	s += c
	if s > 0:
		o += 1
	s = 0

print(o)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main( ){
    ll x,i,j,k,s = 0;
    cin >> x;
    s += ((x / 11) * 2);
    j = x % 11;
    if (j <= 6 && j > 0) {
        s++;
    }
    else if (j > 0) {
        s += 2;
    }
    cout << s << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() 
{ 
    fastio
    string s;
    cin>>s;
    cout<<s.substr(0, 3)<<endl;
} 

Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
 
typedef pair<int,int> pii;
 
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
     
    vector<pii> rel(m + n + 1);
    vector<vector<int> > G(n + 1), from(n + 1);
    vector<int> cnt(n + 1);
    for(int i = 1; i <= m; ++i){
        scanf("%d%d", &rel[i].first, &rel[i].second);
        G[rel[i].first].push_back(i);
        ++cnt[rel[i].second];
    }
    for(int i = 1; i <= n; ++i){
        rel[i + m] = pii(i, 0);
        G[i].push_back(i + m);
        ++cnt[0];
    }
 
    vector<int> d(n + 1, -1);
    queue<int> q;
    for(int i = 0; i <= n; ++i){
        if(cnt[i] == 0){
            d[i] = 0;
            q.push(i);
        }
    }
    q.push(-1);
    int t = 0;
    while(q.size() > 1){
        int a = q.front();
        q.pop();
        if(a == -1){
            q.push(-1);
            ++t;
        }
        else if(d[a] == t){
            for(int i = 0; i < G[a].size(); ++i){
                int u = rel[G[a][i]].second;
                if(d[u] <= t){
                    d[u] = t + 1;
                    from[u].clear();
                }
                if(d[u] == t + 1){
                    from[u].push_back(G[a][i]);
                }
                 
                if(--cnt[u] == 0){
                    q.push(u);
                }
            }
        }
    }
     
    vector<int> ans;
    q.push(0);
    vector<char> vis(n + 1);
    vis[0] = 1;
    while(q.size() > 1){
        int a = q.front();
        q.pop();
        if(a == -1){
            q.push(-1);
        }
        else{
            if(a != 0 && q.size() == 1 && from[a].size() == 1){
                ans.push_back(from[a][0]);
            }
             
            for(int i = 0; i < from[a].size(); ++i){
                int u = rel[from[a][i]].first;
                if(!vis[u]){
                    vis[u] = 1;
                    q.push(u);
                }
            }
        }
    }
     
    sort(ans.begin(), ans.end());
    if(ans.empty()){ ans.push_back(-1); }
    for(int i = 0; i < ans.size(); ++i){
        printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 16392
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
cnt = 0


for i in range(N):
  A.append(list(map(int, input().split())))
  
for a in range (N):
  tl = 0
  for b in range (M):
    tl += A[a][b]*B[b]
  if tl+C > 0:
    cnt += 1
print(cnt)


Measured memory_bytes: 3064
fn read_usizepair() -> (usize, usize) {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input);
    let v: Vec<usize> = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    (v[0], v[1])
    }

fn read_vec() -> Vec<usize> {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input);
    input.trim().split_whitespace().map(|x| x.parse().unwrap()).collect()
}

fn gcd(x: usize, y: usize) -> usize {
    if y % x == 0 {
        return x;
    }
    gcd(y, y % x)
}

fn main() {
    let (n, x) = read_usizepair();
    let mut points = read_vec();
    let mut deltas = Vec::with_capacity(n);
    points.push(x);
    points.sort();
    for i in 0..n {
        deltas.push(points[i+1] - points[i]);
    }
    deltas.sort();
    if deltas.len() != 1 {
        let mut gcd_value = gcd(deltas[0], deltas[1]);
        for delta in &deltas[2..] {
            gcd_value = gcd(gcd_value, *delta);
        }
        println!("{}", gcd_value);
    } else {
        println!("{}", deltas[0]);
    }
}

Measured memory_bytes: 6396
#include <iostream>
#include <set>
#include <map>

#define rep(xx, n) for (int xx = 1; xx <= n; ++xx)

int to[2 * (int)1e5 + 1];

using ll = long long int;

std::set<int> used;
std::map<int, int> mp;

int main()
{

    int n;
    ll k;
    std::cin >> n >> k;

    rep(i, n)
    {
        std::cin >> to[i];
    }

    int goal = 1;
    used.insert(1);
    mp[1] = 0;

    rep(i, k)
    {
        goal = to[goal];

        if (used.count(goal))
        {
            int diff = i - mp[goal];
            //std::cerr << "DE" << diff << std::endl;
            diff = (k - i) % diff;

            rep(j, diff)
                goal = to[goal];

            break;
        }

        used.insert(goal);
        mp[goal] = i;
    }

    std::cout << goal << std::endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll ans = 0;
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if (m1 == m2)
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 256
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 一  9/ 4 18:39:14 2017
 *Ended  Time*  : 一  9/ 4 18:42:03 2017
*********************************************/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
int a[MaxN + 5];
int n;

int main(){
    while(~scanf("%d", &n)){
        for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
        int cnt = 0;
        for(int i = 1; i <= n; i++)
            if(a[i] == i){
                i++;
                cnt++;
            }
        printf("%d\n", cnt);
    }
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class ADodecagon
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());

            Console.WriteLine(3 * Math.Pow(r, 2));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(){
    long long N, M;
    long long sum, sub;
    scanf("%lld %lld", &N, &M);

    sum = N*M;
    if(N==1 && M==1){
        sub=0;
    }else if(N==1 || M==1){
        sub=2;
    }else{
        sub=N*2+M*2-4;
    }

    printf("%lld", sum-sub);

    return 0;
}

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

struct data{
    int a, b;
    data(int _a, int _b) : a(_a), b(_b) {}
    bool operator<(const data other) const{
        return a < other.a;
    }
};

int main(){
    long long n, k;
    cin >> n >> k;

    int a, b;

    vector<data> v;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        v.push_back(data(a,b));
    }

    sort(v.begin(), v.end());

    long long accum = 0;
    for(data x : v){
        accum += x.b;
        if(accum >= k){
            cout << x.a << endl;
            return 0;
        }
    }

}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	int N, M, Q, l, r, p, q;
	cin >> N >> M >> Q;
	vector<vector<int>> v(N);
	FOR(i, 0, M) {
		cin >> l >> r;
		l--; r--;
		v[l].emplace_back(r);
	}

	FOR(i, 0, N) {
		sort(ALL(v[i]));
	}

	FOR(_, 0, Q) {
		cin >> p >> q;
		p--; q--;

		LL ans = 0;
		FOR(i, p, q + 1) {
			ans += upper_bound(ALL(v[i]), q) - v[i].begin();
		}
		print(ans);
	}

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(){
  int a,b;
  char op;
  for(;;){
  cin >> a >> op >> b;
if(op=='?')return 0;
else if(op=='+')cout<<a+b<<endl;
else if(op=='-')cout<<a-b<<endl;
else if(op=='*')cout<<a*b<<endl;
else if(op=='/')cout<<a/b<<endl;
}
return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
vector<string> mat;
int visited[2000][2000];
int main()
{
	int h,w,sx,sy,dx,dy;
	cin>>h>>w;
	cin>>sx>>sy>>dx>>dy;

	for (int i = 0; i < h; ++i)
	{
		string s;
		cin>>s;

		mat.push_back(s);
	}
	queue <pair<int,int> > q;
	q.push(make_pair(sx-1,sy-1));
	visited[sx][sy] = 1;
	int ans = 0;
	dx--;
	dy--;
	while(!q.empty())
	{
		std::vector<pair<int,int> > v;
		while(!q.empty())
		{
			pair<int,int> p = q.front();
			q.pop();

			int a = p.first;
			int b = p.second;

			v.push_back(p);

			if(a-1 >= 0 && visited[a-1][b]==0 && mat[a-1][b] !='#')
			{
				q.push(make_pair(a-1,b));
				visited[a-1][b] = 1;
			}
			if(b-1 >= 0 && visited[a][b-1]==0 && mat[a][b-1] !='#')
			{
				q.push(make_pair(a,b-1));
				visited[a][b-1] = 1;
			}
			if(a+1 < h && visited[a+1][b]==0 && mat[a+1][b] !='#')
			{
				q.push(make_pair(a+1,b));
				visited[a+1][b] = 1;
			}
			if(b+1 < w && visited[a][b+1]==0 && mat[a][b+1] !='#')
			{
				q.push(make_pair(a,b+1));
				visited[a][b+1] = 1;
			}
		}
		if(visited[dx][dy]==1)
		{
			printf("%d\n",ans );
			return 0;
		}

		ans++;

		for (int i = 0; i < v.size(); ++i)
		{
			int a = v[i].first;
			int b = v[i].second;
			for(int j = -2+a; j <= 2+a;j++)
			{
				for (int k = -2+b; k <= 2+b ; ++k)
				{
					if(j>=0 && k>=0 && j<h && k<w && mat[j][k] !='#')
					{
						if(visited[j][k]==0)
						{
							q.push(make_pair(j,k));
							visited[j][k] = 1;
						}
					}
				}	
			}
		}
	}
	printf("-1\n");
	
	return 0;
}

Measured memory_bytes: 12220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int n, a, c[100009];
int main(){
    
    cin >> n;
	rep(i,n)cin >> a, c[a]++;
    int ans =0;
    rep(i,100001)ans = max(ans,c[i]+c[i+1]+c[i+2]);
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#define f(x) (x)*(x)

using namespace std;

int n;
int a[1001];
int cnt;
int ans;
int ans2;
int ans3;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt+=a[i];
    }
    int t=cnt/n;
    for(int i=1;i<=n;i++)
    {
        ans+=f(a[i]-t);
        ans2+=f(a[i]-t-1);
        ans3+=f(a[i]-t+1);
    }
    int tt=ans<ans2? ans:ans2;
    tt=tt>ans3? ans3:tt;
    cout<<tt;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int s[n];
    int S=0;
    vector<int> rem;
    rep(i, n){
        cin >> s[i];
        S += s[i];
        if(s[i]%10!=0){
            rem.emplace_back(s[i]);
        }
    }

    if(S%10!=0){
        cout << S << endl;
        return 0;
    }

    if(rem.size()==0){
        cout << 0 << endl;
        return 0;
    }

    sort(rem.begin(), rem.end());
    cout << S-rem[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  ll X,Y; cin >> X >> Y;
  ll count = 1;
  while(X*2 <= Y) {
    X *= 2;
    count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static int n;
    static string[] S;
    static void input()
    {
        cin = new Scanner();
        n = cin.nextInt();
        S = new string[n];
        for (int i = 0; i < n; i++)
            S[i] = cin.next();
    }
    static void solve()
    {
        input();
        int[] ans = Enumerable.Repeat(int.MaxValue, 26).ToArray();
        for(int i = 0; i < n; i++)
        {
            int[] tmp = new int[26];
            for(int j = 0; j < S[i].Length; j++)
                tmp[S[i][j] - 'a']++;

            for(int j = 0; j < ans.Length; j++)
                ans[j] = Min(ans[j], tmp[j]);
        }
        for(int i = 0; i < ans.Length; i++)
        {
            for (int j = 0; j < ans[i]; j++)
                Write(Convert.ToChar('a' + i));
        }
        WriteLine();
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

struct SplayNode{
    SplayNode *left, *right, *parent;
    int size, value;

    SplayNode(){
        left = nullptr;
        right = nullptr;
        parent = nullptr;
        size = 1;
    }

    void rotate(){
        SplayNode *pp, *p, *c;
        p = this->parent;
        pp = p->parent;

        if(p->left == this){
            c = this->right;
            this->right = p;
            p->left = c;
        }
        else{
            c = this->left;
            this->left = p;
            p->right = c;
        }
        if(pp && pp->left == p)pp->left = this;
        if(pp && pp->right == p)pp->right = this;
        this->parent = pp;
        p->parent = this;
        if(c)c->parent = p;

        p->update();
        this->update();
    }

    int state(){
        if(!this->parent)return 0;
        if(this->parent->left == this)return 1;
        if(this->parent->right == this)return -1;
        return 0;
    }
    
    void splay(){
        while(this->state() != 0){
            if(this->parent->state() == 0){
                this->rotate();
            }
            else if(this->state() == this->parent->state()){
                this->parent->rotate();
                this->rotate();
            }else{
                this->rotate();
                this->rotate();
            }
        }
    }
    
    void update(){
        this->size = 1;
        if(this->left)this->size += this->left->size;
        if(this->right)this->size += this->right->size;
    }    
};

SplayNode *get(int ind, SplayNode *root){
    SplayNode *now = root;
    while(true){
        int lsize = now->left ? now->left->size : 0;
        if(ind < lsize){
            now = now->left;
        }
        if(ind == lsize){
            now->splay();
            return now;
        }
        if(ind > lsize){
            now = now->right;
            ind = ind - lsize - 1;
        }
    }
}

SplayNode node[220000];

int main(){
    int q, ord, x;
    cin >> q;
    int vecsize = 0;

    for(int i = 0;i < q;i++){
        node[i].parent = &node[i+1];
        node[i+1].left = &node[i];
        node[i+1].update();
    }
    
    SplayNode *root = &node[q];
    
    for(int i = 0;i < q;i++){
        cin >> ord;
        if(ord == 0){
            cin >> x;
            root = get(vecsize++, root);
            root->value = x;
        }
        if(ord == 1){
            cin >> x;
            root = get(x, root);
            cout << root->value << endl;
        }
        if(ord == 2){
            vecsize--;
        }
    }
}


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

using namespace std;

#define N 300000

int n,mx[N],ok[N],a[N];
long long ans;
char s[N];
vector<int> g[N];

void dfs(int u,int fa){
	mx[u]=1; ok[u]=a[u];
	for (int v:g[u])
		if (v!=fa){
			dfs(v,u);
			mx[u]=max(mx[u],mx[v]+1);
			ok[u]+=ok[v];
		}
}

void calc(int u,int fa,int len){
	int t1=len,t2=0;
	for (int v:g[u])
		if (v!=fa){
			if (mx[v]>t2) t2=mx[v];
			if (t2>t1) swap(t1,t2);
		}
	for (int v:g[u])
		if (v!=fa){
			int x=mx[v],y=(x!=t1?t1:t2)+1;
			if (x==y) ans+=ok[1]>0;
			if (x<y) ans+=ok[v]>0;
			if (x>y) ans+=ok[1]-ok[v]>0;
		}
	if (a[u]) ans+=t2+1;
	else{
		int mn=ok[1]-ok[u]?len:n;
		for (int v:g[u])
			if (ok[v]) mn=min(mn,mx[v]);
		if (t2>=mn) ans+=t2-mn+1;
	}
	for (int v:g[u])
		if (v!=fa) calc(v,u,(mx[v]!=t1?t1:t2)+1);
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		int x,y; scanf("%d%d",&x,&y);
		g[x].push_back(y); g[y].push_back(x);
	}
	scanf("%s",s+1);
	for (int i=1;i<=n;++i) a[i]=s[i]-'0';
	dfs(1,0);
	calc(1,0,0);
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 31232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw"<<endl;

      else if(a!=1&&b!=1){
       if(a>b)
       cout<<"Alice"<<endl;
       else
        cout<<"Bob"<<endl;}
        else if(a==1)
            cout<<"Alice"<<endl;
         else if(b==1)
            cout<<"Bob"<<endl;
   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	string S;
	cin >> S;
	if (S[0] == '7') {
		cout << "Yes" << endl;
	}
	else if (S[1] == '7') {
		cout << "Yes" << endl;
	}
	else if (S[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  string s;
  cin >> n >> s;
  vector<ll> v(26,0);
  rep(i,n)v[s[i]-'a']++;
  ll res = 1;
  rep(i,26)(res *= (v[i]+1))%= MOD;
  res = (res-1+MOD)%MOD;
  cout << res << endl;




  return 0;
}

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

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

    if((A+B)>(C+D))
        cout << "Left" <<endl;

    else if((A+B)==(C+D))
        cout <<"Balanced" <<endl;

    else if((A+B)<(C+D))
        cout <<"Right" <<endl;


    return 0;
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    x, k, d = map(int, input().split())
    x = abs(x)
    kd = k * d

    # See:
    # https://www.youtube.com/watch?v=auQRcs5JMwE&feature=youtu.be
    # KeyInsight:
    # △: 対称性から、x>=0の場合を考えれば良い。実装も楽になる。

    if kd <= x:
        # ◯: 原点付近で往復する前に、シミュレーションが終わる。
        print(x - kd)
    else:
        # ◯: 原点付近で往復する
        count = x // d
        k_dash = k - count  # 残りの移動回数
        x -= count * d

        # △: 移動回数の残りが偶奇で変わる
        if k_dash % 2 == 0:
            print(x)
        else:
            print(d - x)


if __name__ == '__main__':
    main()


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define nl "\n"
#define ump unordered_map<ll , ll>

void doit(){
	ll n,m,i,j,k,c,ans=0,x;
	c=26;
	cin >> n;
	string s="";
	x=1;
	while(n){
		k=n%26;
		n/=26;
		k--;
		if(k==-1)k=25;
		if(k == 25)n--;
		s+=(char)('a'+k);

	}
	reverse(s.begin() , s.end());
	cout <<s<<nl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3636
#include<iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int H,W;
char f[55][55];
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};

int main(){
  cin >> H >> W;
  r(i,H)r(j,W) cin >> f[i][j];
  r(i,H)r(j,W) if(f[i][j]=='#'){
    int sum = 0;
    r(k,4){
      int y = i+dy[k];
      int x = j+dx[k];
      if(y<0||x<0||y>=H||x>=W) continue;
      if(f[y][x]=='#') sum++;
    }
    if(!sum){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,r,D,x;
  scanf("%d %d %d",&r,&D,&x);
  for(i=0;i<10;i++){
  	printf("%d\n",r*x-D);
  	x=r*x-D;
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a,b,sta,stb;
    cin>>a>>b;

    for (int i=0;i<stoi(a);i++){
        stb +=b;
    }

    for(int i=0;i<stoi(b);i++){
        sta +=a;
    }
    if(stoi(a)>stoi(b)){
        cout<<stb<<endl;
    }else{
        cout<<sta<<endl;
    }
    return 0;
}

Measured memory_bytes: 256