akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::pair;
using std::string;
using std::stack;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

struct edge {
	ll to;
	ll cost;
};

vector<bool> used(100001, false);
vector<ll> d(100001, -1);
bool f = true;
void dfs(ll a, const unordered_multimap<ll, edge>& graph) {
	if (used[a]) { return; }
	used[a] = true;

	auto p = graph.equal_range(a);
	for (auto itr = p.first; itr != p.second; ++itr) {
		if (d[itr->second.to] == -1) {
			d[itr->second.to] = d[a] + itr->second.cost;
			dfs(itr->second.to, graph);
		} else if (d[itr->second.to] != d[a] + itr->second.cost) {
			f = false;
			return;
		}
	}}

int main() {
	ll n, m;
	cin >> n >> m;

	unordered_multimap<ll, edge> graph;

	REP(i, m) {
		ll l, r, d;
		cin >> l >> r >> d;
		graph.emplace(l, edge{ r,d });
		graph.emplace(r, edge{ l,-1 * d });
	}
	FOR(i, 1, n + 1) {
		if (used[i]) { continue; }
		d[i] = 0;
		dfs(i, graph);
		if (!f) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 27508
dic = {}
while True:
	try:
		word, page = raw_input().split()
		if word in dic.keys():
			dic[word].append(int(page))
			dic[word].sort()
		else:
			dic[word] = [int(page)]
	except:
		dic = sorted(dic.items(), key=lambda x: x[0])
		for d in dic:
			print d[0]
			print " ".join(map(str, d[1]))
		break

Measured memory_bytes: 4212
N = int(input())
A = list(map(int, input().split()))
ans = len(set(A))

cnt = [0]*(int(1e5)+2) # not 0-indexed
for ai in A:
    cnt[ai] += 1
    if cnt[ai]==3:
        cnt[ai] -= 2

s = sum(cnt) - ans
s_i = 0

for i in range(1, len(cnt)):
    if cnt[i-1]==2:
        s_i += 1
        s -= 1
    if s_i == s:
        break
else:
    ans -= 1
        
print(ans)
    

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

int main(){
  int h,w;
  char img[101][100];
  char out[202][100];

  cin >> h >> w;
  for(int i = 0;i < h;i++){
    cin >> img[i];
    cout << img[i] << endl;
    cout << img[i] << endl;
  }

  // for(int i = 0; i < h*2; i++){
    
  // }
  return 0;
}


Measured memory_bytes: 256
// @author: arch_

#include <bits/stdc++.h>
using namespace std;

vector<int> hmw;

int main(void) {
    int n, x, count = 0;
    while (cin >> n >> x,
           n != 0 || x != 0) {
        count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                for (int k = j; k <= n; k++) {
                    if (i == j || j == k || k == i) {}
                    else {
                        count += static_cast<int>(i + j + k == x);
                    }
                }
            }
        }
        hmw.emplace_back(count);
    }
    for (auto&& i : hmw) cout << i << "\n";
    return 0;
}

Measured memory_bytes: 3160
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        x: usize,
        t: usize,
    }
    let ans = (n + x - 1) / x * t;
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  rep(i,5){
    int x; cin>>x;
    if(x==0) out(i+1);
  }
}

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


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

int cmp(const void* a, const void* b){
    int *x=(int *)a;
    int *y=(int *)b;
    return *x==*y?0:(*x>*y?1:-1);
}
main(){
    int N,x;
    scanf("%d%d",&N,&x);
    int a[N];
    for (int i=0;i<N;++i)scanf("%d",&a[i]);

    qsort(a, (size_t) N, sizeof(int), cmp);

    for (int i=0;i<N;++i) {
        x-=a[i];
        if(x==0){
            printf("%d",i+1);
            return 0;
        }else if(x<0 || i+1==N){
            printf("%d",i);
            return 0;
        }
    }
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, L, logN;
	static int[] X;
	static int[][] table;

	public static void main(String[] args) {
		N = sc.nextInt();
		X = new int[N];
		for (int i = 0; i < N; ++i) {
			X[i] = Integer.parseInt(sc.next());
		}
		L = sc.nextInt();
		logN = 1;
		while ((1 << logN) < N) {
			logN++;
		}
		build();
		int Q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < Q; ++i) {
			int A = Integer.parseInt(sc.next()) - 1;
			int B = Integer.parseInt(sc.next()) - 1;
			sb.append(solve(Math.min(A, B), Math.max(A, B)) + "\n");
		}
		System.out.print(sb);
	}

	static void build() {
		table = new int[logN + 1][N];
		for (int i = 0; i < N; ++i) {
			int pos = Arrays.binarySearch(X, X[i] + L);
			if (pos < 0) {
				pos = -pos - 2;
			}
			table[0][i] = pos;
		}
		for (int i = 1; i <= logN; ++i) {
			for (int j = 0; j < N; ++j) {
				int next = table[i - 1][j];
				table[i][j] = table[i - 1][next];
			}
		}
	}

	static int solve(int l, int r) {
		int len = 0;
		for (int i = 0; i <= logN; ++i) {
			if (table[i][l] < r) {
				++len;
			} else {
				break;
			}
		}
		if (len == 0) return 1;
		return (1 << (len - 1)) + solve(table[len - 1][l], r);
	}

}


Measured memory_bytes: 37376
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    char c; cin >> c;
    if (c != 'z') c++;
    cout << c;
    return 0;
}



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

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

  vector<int> answer(n);
  for (int i = 1; i <= n - 1; i++) {
    answer[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int d = j - i;
      if        (i <= x                     && j >= y) {
        d = (x - i) + 1 + (j - y);
      }
      if (i > x && j < y) {
        d = min(d, (i - x) + 1 + (y - j));
      }
      if (i > x && j >= y) {
        d = min(d, (i - x) + 1 + (j - y));
      }
      if (i <= x && j < y) {
        d = min(d, (x - i) + 1 + (y - j));
      }
      answer[d]++;
    }
  }

  for (int i = 1; i <= n - 1; i++) {
    cout << answer[i] << endl;
  }
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 1000, k = 4;
const int dx[k] = {1, 0, -1, 0};
const int dy[k] = {0, 1, 0, -1};
int n, m, sx, sy, rx, ry;
int a[mxn][mxn];
int d[mxn * mxn];
vector<int> g[mxn * mxn];
queue<int> q;
int s;

void dfs(int x, int y){
	a[x][y] = s;
	for(int i = 0; i < 4; i++){
		int fx = x + dx[i], fy = y + dy[i];
		if(fx >= 0 && fy >= 0 && fx < n && fy < m && a[fx][fy] < -1) dfs(fx, fy);
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> sx >> sy >> rx >> ry;
	sx--, sy--, rx--, ry--;
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < m; j++){
		char c;
		cin >> c;
		a[i][j] = -1 - (c == '.');
	}
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < m; j++){
		if(a[i][j] == -2) dfs(i, j), d[s++] = -1;
	}
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < m; j++) if(~a[i][j])
	for(int x = max(0, i - 2); x < min(n, i + 3); x++)
	for(int y = max(0, j - 2); y < min(m, j + 3); y++){
		if(~a[x][y] && a[i][j] != a[x][y]) g[a[i][j]].push_back(a[x][y]);
	}
	
	for(int i = 0; i < s; i++){
		sort(g[i].begin(), g[i].end());
		g[i].erase(unique(g[i].begin(), g[i].end()), g[i].end());
	}
	
	d[a[sx][sy]] = 0;
	q.push(a[sx][sy]);
	while(!q.empty()){
		int c = q.front();
		q.pop();
		for(int i : g[c]) if(!~d[i]){
			d[i] = d[c] + 1;
			q.push(i);
		}
	}
	
	cout << d[a[rx][ry]] << endl;

	return 0;
}

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

int main() {
  int N;
  int p[4];
  int t[4];
  int temp;
  int ans	= 100000;

  cin >> N;
  for(int i = 0; i < 4; i++)
    cin >> p[i];
  for(int i = 0; i < 4; i++)
    cin>> t[i];

  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= N; j++) {
      for(int k = 0; k <= N; k++) {
        for(int l = 0; l <= N; l++) {
          if(i*t[0]+j*t[1]+k*t[2]+l*t[3] >= N) {
            temp = i*p[0]+j*p[1]+k*p[2]+l*p[3];
            if(temp < ans) {
              ans = temp;
            }
          }
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3108
//const int N=1e5;
#define INF 1e9
#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int nn = 2e5;
ll a[nn + 1], b[nn + 1];
void sol() {
	int n, m; ll k;

	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}
	int cnt = 0;
	for (int i = 0, j = m; i <= n; i++) {
		if (k < a[i])break;
		while (a[i] + b[j] > k)
			j--;

		cnt = max(cnt, i + j);
	}
	cout << cnt << "\n";
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		sol();
	}

	return 0;
}

Measured memory_bytes: 6780
import math

a, b = map(int, input().split())
limit = int(100 / 0.08) + 1
ans = limit

for i in range(1, limit):
    x = math.floor(i * 0.08)
    y = math.floor(i * 0.1)
    if x == a and y == b:
        ans = min(ans, i)

print(ans) if not ans == limit else print(-1)


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N, nN, root; ll L;
char S[MAX_N];
int Ed[MAX_N][2], H[MAX_N];
int main() {
	cin >> N >> L;
	nN = root = 1; H[root] = 0;
	for(int n=0; n<N; n++) {
		scanf("%s", S);
		int sN = strlen(S);
		int now = root;
		for(int i=0; i<sN; i++) {
			int v = S[i] - '0';
			if(Ed[now][v] == 0) Ed[now][v] = ++nN, H[nN] = H[now] + 1;
			now = Ed[now][v];
		}
	}
	ll grundy = 0;
	for(int i=1; i<=nN; i++) {
		for(int k=0; k<2; k++) if(Ed[i][k] == 0) {
			ll h = L - H[i];
			grundy ^= (h & -h);
		}
	}
	if(grundy) puts("Alice");
	else puts("Bob");
	return 0;
}


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

const int maxn = 4010;
int n, a[maxn], f[maxn][maxn], pos1[maxn], pos2[maxn];
int c1[maxn][maxn], c2[maxn][maxn];
char s[maxn][2];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= 2 * n; i++) {
        scanf("%s %d", s[i], &a[i]);
        if (s[i][0] == 'W') pos1[a[i]] = i;
        else pos2[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) {
            if (pos1[j] > pos1[i]) c1[i][0]++;
        }
        for (int j = 1; j <= n; j++) {
            c1[i][j] = c1[i][j - 1] + (pos2[j] > pos1[i]);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) {
            if (pos2[j] > pos2[i]) c2[0][i]++;
        }
        for (int j = 1; j <= n; j++) {
            c2[j][i] = c2[j - 1][i] + (pos1[j] > pos2[i]);
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (!i && !j) continue;
            f[i][j] = INT_MAX;
            if (i) f[i][j] = f[i - 1][j] + c1[i][j];
            if (j) f[i][j] = min(f[i][j], f[i][j - 1] + c2[i][j]);
        }
    }
    printf("%d\n", f[n][n]);
    return 0;
}

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

using namespace std;
using i64 = std::int_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  priority_queue<pair<i64, i64>> que;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    que.push(make_pair(a, 1));
  }
  for (int i = 0; i < M; i++) {
    i64 b, c;
    cin >> b >> c;
    que.push(make_pair(c, b));
  }

  i64 res = 0;
  while (N > 0) {
    auto q = que.top();
    que.pop();
    i64 a = q.first, cnt = q.second;
    if (cnt <= N) {
      res += a * cnt;
    } else {
      res += a * N;
    }
    N -= cnt;
  }

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 6512
import itertools
n = int(input())
p_inputs = tuple([int(i) for i in input().split()])
q_inputs = tuple([int(i) for i in input().split()])

#順列の組み合わせを出力する
li = list(itertools.permutations(range(1,n+1),n))

print(abs(li.index(p_inputs)-li.index(q_inputs)))

Measured memory_bytes: 8052
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

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

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

typedef unsigned long long u64;
typedef long long i64;

int x,a;

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

        cin >> x >> a;

        cout << (x < a ? 0 : 10) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int count;
    string t,h;
    int m=0,n=0;

    cin >> count;

    while(count>0){
        cin >> t;
        cin >> h;

        if(t>h){
            m += 3;
        }
        else if(t<h){
            n += 3;
        }
        else{
            m++;
            n++;
        }
        count--;
    }

    cout << m <<" "<<n <<endl;

    return 0;
}



Measured memory_bytes: 3200
IDENTIFICATION DIVISION.
PROGRAM-ID. 165A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 K          PIC 9(4).
01 A          PIC 9(4).
01 B          PIC 9(4).
01 S1         PIC 9(4).
01 S2         PIC 9(4).
01 A1         PIC 9(4).
01 A2         PIC 9(4).
*>
PROCEDURE DIVISION.
  ACCEPT K.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B.
*>
  DIVIDE A BY K GIVING S1 REMAINDER A1.
  DIVIDE B BY K GIVING S2 REMAINDER A2.
  IF ((S1 > 1) AND (S2 > 1)) OR
     ((A <= K) AND (B >= K))
    DISPLAY 'OK'
  ELSE
    DISPLAY 'NG'
  END-IF.
*>
  STOP RUN.


Measured memory_bytes: 3924
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = list(A)
    ans, n = bubbleSort(a, N)
    print(*ans, sep=' ')
    print(n)

def bubbleSort(a, n):
    j = 0
    flag = 1
    while flag:
        flag = 0
        for i in range(1, n):
            if a[i] < a[i-1]:
                a[i], a[i-1] = a[i-1], a[i]
                flag = 1
                j += 1
    return a, j

main()

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

 
int main() {
    ll n,m;
    cin >> n >> m ;
    vector<ll> h(n);
    for(int i= 0 ; i < n ;i++ ){
        cin >> h[i];
    }
    vector<vector<ll>> graph(n);
    ll a,b;
    for(int i= 0 ; i < m ;i++ ){
        cin >> a >> b;
        graph[--a].push_back(--b);
        graph[b].push_back(a);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll max=h[i];
        bool judge=true;
            for(auto tmp : graph[i]){
                    if(max<=h[tmp]) {
                            judge=false;
                            break;
                    }
                    if(!(judge)) break;
            }
        
        if(judge) ans++;
    }
    cout << ans << endl;
    return 0;


}


Measured memory_bytes: 9788
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define MAX 2000000
#define INF 100000000

int H,h[MAX+1];

void maxheapify(int i){
  int l,r,largest,a;
  l=2*i;
  r=2*i+1;

  if(l<=H&&h[l]>h[i])largest=l;
  else largest=i;
  if(r<=H&&h[r]>h[largest])largest=r;

  if(largest!=i){
    a=h[i];
    h[i]=h[largest];
    h[largest]=a;
    maxheapify(largest);
  }
}

void extract(){
  printf("%d\n",h[1]);
  h[1]=h[H];
  H--;
  maxheapify(1);
}

void increasekey(int i,int key){
  int a;

  h[i]=key;
  while(i>1&&h[i/2]<h[i]){
    a=h[i];
    h[i]=h[i/2];
    h[i/2]=a;
    i=i/2;
  }
}

void insert(int key){
  H++;
  h[H]=-INF;
  increasekey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else extract();
  }
  return 0;
}



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

int main(){
  int n,m; cin>>n>>m;
   int left=1;
   int right=n;
  for(int i=0;i<m;i++){
    int l,r;
    cin>>l>>r;
    if(l>left)left=l;
    if(r<right)right=r;
    
  }
  int a=right-left+1;
  if(a<0)a=0;
  cout<<a<<endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int N,A[100],i,j,k;
void d(){int x;for(x=0;x<N;x++)printf("%d%s",A[x],x==N-1?"\n":" ");}
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    for(i=1;i<N;A[j+1]=k,i++)
        for(k=A[i],j=i-1,d();A[j]>k;j--)
            A[j+1]=A[j];
    d();
    return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    ll diff = abs(b-a);
    ll ds = v-w;
    ds*=t;
    if(diff<=ds) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;		cin>>N;
	string S,T;	cin>>S>>T;
	FOR(i,0,N){
		cout<<S[i]<<T[i];
	}
  cout<<endl;


    return 0;
}




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

int dice[120][6];
int i,j,k,t,clear=0;

int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;

void Move2(int j,int k);
void rndMove();
void eMove();
void nMove();
void sMove();
void wMove();

int main(){
	int n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<6;j++){
			scanf("%d",&dice[i][j]);
		}
	}
	for(j=0;j<n-1;j++){
		for(k=j+1;k<n;k++){
			Move2(j,k);
		}
	}
	
	if(clear==1)printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

void Move2(j,k){
	for(i=0;i<100;i++){
		rndMove();
		
		if((dice[j][0]==dice[k][ue-1])&&(dice[j][1]==dice[k][mae-1])&&
			(dice[j][2]==dice[k][mig-1])&&(dice[j][3]==dice[k][hid-1])&&
			(dice[j][4]==dice[k][usi-1])&&(dice[j][5]==dice[k][sit-1])){
			clear=1;
			break;
		}
	}
	return;
}

void rndMove(){
	int rnd=rand()%4;
		
	if(rnd==0)eMove();
	else if(rnd==1)nMove();
	else if(rnd==2)sMove();
	else wMove();
	
	return;
}

void eMove(){
	t=ue;
	ue=hid;
	hid=sit;
	sit=mig;
	mig=t;
	return;
}

void nMove(){
	t=ue;
	ue=mae;
	mae=sit;
	sit=usi;
	usi=t;
	return;
}

void sMove(){
	t=ue;
	ue=usi;
	usi=sit;
	sit=mae;
	mae=t;
	return;
}

void wMove(){
	t=ue;
	ue=mig;
	mig=sit;
	sit=hid;
	hid=t;
	return;
}


Measured memory_bytes: 2100
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = readline().strip()
    T = readline().strip()

    ans = 0
    for s, t in zip(S, T):
        if s != t:
            ans += 1
    
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 9424
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=1000000;
  for(int i=0;i<n;i++){
    int sub=0;
    int top=0;
    sub=accumulate(a,a+i,0);
    top=accumulate(a+i,a+n,0);
    // cout<<"i="<<i<<" "<<"sub="<<sub<<" "<<"top="<<top<<endl;
    if(abs(top-sub)<ans) ans=abs(top-sub);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	long long int h;
	cin >> h;

	long long int x = 0;
	long long int y = 1;
	while (h != 1) {
		h /= 2;
		y *= 2;
	}
	y *= 2;
	y -= 1;
	cout << y << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

struct Data
{
	int point;
	char name[32];
	
	bool operator> (const Data& d)const
	{
		return point > d.point;
	}
};

int main()
{
	int n;
	bool first = true;
	while(scanf("%d", &n), n){
		if(!first)
			puts("");
		else
			first = false;
		
		vector<Data> data(n);
		rep(i, n){
			int won, lose, tie;
			scanf("%s%d%d%d", data[i].name, &won, &lose, &tie);
			data[i].point = won*3 + tie;
		}
		stable_sort(data.begin(), data.end(), greater<Data>());
		rep(i, n)
			printf("%s,%d\n", data[i].name, data[i].point);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <list>
#include <set>
#include <map>

using namespace std;

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

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

    array<map<int, int>, 2> c;
    for (int i = 0; i < n; i++) {
        if (c[i % 2].find(v[i]) == c[i % 2].end()) c[i % 2][v[i]] = 1;
        else c[i % 2][v[i]]++;
    }

    array<vector<pair<int, int>>, 2> c1;
    for (auto x : c[0]) c1[0].push_back({ x.second, x.first });
    for (auto x : c[1]) c1[1].push_back({ x.second, x.first });
    sort(c1[0].rbegin(), c1[0].rend());
    sort(c1[1].rbegin(), c1[1].rend());

    if (c1[0][0].second == c1[1][0].second) {
        if (c1[0].size() == 1 && c1[1].size() == 1) 
            cout << n / 2 << endl;
        else if (c1[0].size() == 1) {
            cout << (n / 2 - c1[0][0].first) << endl;
        } else if (c1[1].size() == 1) {
            cout << (n / 2 - c1[1][0].first) << endl;
        } else {
            cout << min((n / 2 - c1[0][0].first) + (n / 2 - c1[1][1].first), (n / 2 - c1[0][1].first) + (n / 2 - c1[1][0].first)) << endl;
        }
    } else {
        cout << (n - (c1[0][0].first + c1[1][0].first)) << endl;
    }



}

Measured memory_bytes: 6520
s = input()
lis = ['A', 'T', 'C', 'G']
ans = 0
for i in range(len(s)):
    temp = 0
    for j in range(i, len(s)):
        if s[j] in lis:
            temp += 1
        else:
            break
    ans = max(ans, temp)
print(ans)

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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //角度をラジアンに変換する
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int k, s;

    cin >> k >> s;

    int c = 0;
    for (int i = 0; i <= k; i++){
        for (int j = 0; j <= k; j++){
            int a = s - i - j;
            if (0 <= a && a <= k){
                c++;
            }
        }
    }

    CL(c);

    return (0);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int a,b[256],i;

scanf("%d",&a);

for(i=0;i<a;i++){
  scanf("%d",&b[i]);
}

int ans=b[0];
int q=0;

for(i=0;i<a;i++){
  if(ans<b[i]){
     ans = b[i];
  }
  q += b[i];
}
q -= ans;

//printf("%d\n",q);

if(ans<q){

printf("Yes");

}else{
printf("No");
}

return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        if(a[0]==a[1] && a[1] == a[2]) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }
}


Measured memory_bytes: 13396
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }

c = Array.new(n){0} << 3 
m = 10 ** 9 + 7
ans = 1
a.each do |t|
  ans *= c[t-1]
  ans %= m
  c[t-1] -= 1
  c[t] += 1
end

puts ans

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

int main() {

  int n, q;
  cin >> n >> q;

  deque <pair<string, int>> que;

  for (int i = 0; i < n; i++) {
    string name;
    int time;
    cin >> name >> time;
    que.push_back(make_pair(name, time));
  }

  int current = 0;

  while(!que.empty()) {
    pair<string, int> p = que.front(); 
    que.pop_front();
    if (p.second <= q) {
      cout << p.first << " " << p.second + current << endl;
    } else {
      que.push_back(make_pair(p.first, p.second - q));
    }
    current += min(q, p.second);
  }

  return 0;
}


Measured memory_bytes: 6180
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * シェルソート
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=ja">ALDS1_2_D</a>
 */
public class Main{

	private static List<Integer> g = new ArrayList<>();
	private static int count = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		shellSort(a, n);

		System.out.println(g.size());
		for (int i = 0; i < g.size(); i++) {
			if (i == g.size() - 1) {
				System.out.print(g.get(i));
			} else {
				System.out.print(g.get(i) + " ");
			}
		}

		System.out.println();

		System.out.println(count);

		for (int i = 0; i < n; i++) {
			System.out.println(a[i]);
		}

		sc.close();
	}

	private static void shellSort(int[] a, int n) {
		for (int h = 1; ;) {
			if (h > n) break;
			g.add(0, h);
			h = 3 * h + 1;
		}

		for (int i = 0; i < g.size(); i++) {
			insertionSort(a, n, g.get(i));
		}
	}

	private static void insertionSort(int[] a, int n, int g) {
		for (int i = g; i < n; i++) {
			int v = a[i];
			int j = i - g;
			while (j >= 0 && a[j] > v) {
				a[j + g] = a[j];
				j -= g;
				count++;
			}
			a[j + g] = v;
		}
	}

}



Measured memory_bytes: 299196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const ll MOD = 998244353;
const ll MAX = 210000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//べき乗計算
ll modpow(ll a,ll n,ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    
void Main(){
    COMinit();
    ll n;cin>>n;
    ll m;cin>>m;
    ll k;cin>>k;
    ll pattern=0;
    For(i,0,k+1){
        ll color = modpow(m-1,n-i-1)*m%MOD;
        pattern=(pattern+COM(n-1,i)*color%MOD)%MOD;
    }
    cout << pattern << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 8520
X ,N = map(int,input().split())
P = list(map(int,input().split()))
if N == 0:
    print(X)
    exit(0)
A = list(range(0,102))
ans = 0
mins = 100


for a in A:
    if a not in P:
        if abs(a-X) < mins:
            mins = abs(a-X)
if (X - mins) not in P:
    print(X-mins)
else:
    print(X+mins)

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string ans = "yes";
    for(int i=0; i < n; ++i){
        for(int j=i+1; j < n; ++j){
            if(s[i] == s[j]){
                ans = "no";
            }
        }
    }
    cout << ans << endl;
}

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

template<class T> inline bool chmin(T &a, T b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

int N;
long long h[110000];

long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    for (int i = 1; i <= N; i++) {
        dp[i] = INF;
    }
    dp[1] = 0;
    for (int i = 1; i <= N; i++) {
        for (int k = 1; k <= K; k++) {
            chmin(dp[i+k], dp[i] + abs(h[i] - h[i+k]));
        }
    }
    cout << dp[N] << endl;
    return 0;
}

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



#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }




int N, K;
vector<vector<int> > tree;

// 頂点 v を根として、p のある側は切り落としてできる部分木について
// v から各頂点への距離を depth に格納する
// (特に p = -1 のときは、ツリー全体について v を根とすることを表す)
void rec(int v, int p, vector<int> &depth) {
    if (p != -1) depth[v] = depth[p] + 1;
    for (auto nv : tree[v]) {
        if (nv == p) continue;
        rec(nv, v, depth);
    }
}

int main() {
    cin >> N >> K;
    tree.assign(N, vector<int>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    int res = N; // INF の気持ち
    vector<int> depth(N);

    if (K % 2 == 0) {
        for (int v = 0; v < N; ++v) {
            depth[v] = 0;
            rec(v, -1, depth);
            int num = 0;
            for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;
            res = min(res, num);
        }
    }
    else {
        for (int u = 0; u < N; ++u) {
            for (auto v : tree[u]) {
                int num = 0;

                // u
                depth.assign(N, -1);
                depth[u] = 0;
                rec(u, v, depth);
                for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;

                // v
                depth.assign(N, -1);
                depth[v] = 0;
                rec(v, u, depth);
                for (int i = 0; i < N; ++i) if (depth[i] > K/2) ++num;
                
                res = min(res, num);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String[] line = in.nextLine().split(" ");
        final int n = Integer.parseInt(line[0]);
        final int k = Integer.parseInt(line[1]);
        final int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        in.nextLine();
        int low = 1, high = (int) 1e9;
        while (low < high) {
            final int mid = low + high >>> 1;
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                cnt += (arr[i] - 1) / mid;
            }
            if (cnt > k) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        System.out.println(low);
    }
}


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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int a;cin >> a;
    int ans = 2;
    set<int> v{a};
    while(true){
        if(a&1) a = 3*a + 1;
        else a = a/2;
        if(v.find(a) != v.end()) break;
        v.insert(a);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
P mp[]={P(0,1),P(1,2),P(1,0),P(2,1)};
int N,M;
void printst(stack<int> st[3]){
  puts("print");
  for(int i=0;i<3;i++){
    if(st[i].empty()) printf("no\n");
    else printf("%d\n",st[i].top());
  }
}
int solve(stack<int> st[3],P p,int id){
  int pr = p.F, ne = p.S;
  st[ne].push( st[pr].top() );
  st[pr].pop();
  int co=1;
  for(int i=co;i<=M;i++){
    //    printf("%d番目\n",i);
    //  printst(st);
    if(st[0].size() == N  || st[2].size() == N ) break;
    for(int j=0;j<4;j++){
      if(j==(id+2)%4) continue;
      pr=mp[j].F; ne=mp[j].S;
      if(st[pr].empty()) continue;
      bool f=false;
      if(st[ne].empty()) f=true;
      else if(st[pr].top() > st[ne].top()) f=true;
      if(f){
	st[ne].push( st[pr].top() );
	st[pr].pop();
	id = j;
	break;
      }
    }
      co++;
  }
  return co;
}
int main(){
  while(1){
    scanf("%d %d",&N,&M);
    if(!N && !M) break;
    stack<int> st[3];
    vector<int> sta[3];
    for(int i=0;i<3;i++){
      while(!st[i].empty()) st[i].pop();
      sta[i].clear();
    }
    for(int i=0;i<3;i++){
      int num;
      scanf("%d",&num);
      for(int j=0;j<num;j++){
	int a;
	scanf("%d",&a);
	st[i].push(a);
	sta[i].push_back(a);
      }
    }
    //    printst(st);
    if(st[0].size() == N  || st[2].size() == N ){
      printf("0\n");
      continue;
    }
    int res = M+1;
    for(int i=0;i<4;i++){
      //   printst(st);
      int pr=mp[i].F; int ne=mp[i].S;
      bool f=false;
      if(st[pr].empty()) continue;
      if(st[ne].empty()) f=true;
      else if(st[pr].top() > st[ne].top()) f=true;
      if(f)
	res = min(res,solve(st,mp[i],i));
      //      printf("%d  %d\n",i,res);
      for(int j=0;j<3;j++){
	while(!st[j].empty()) st[j].pop();
	for(int k=0;k<(int)sta[j].size();k++){
	  st[j].push( sta[j][k] );
	}
      }
    }
    if(res == M+1) printf("-1\n");
    else printf("%d\n",res);
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    set <int> s1,s2;
    s1.insert(1);
    s1.insert(3);
    s1.insert(5);
    s1.insert(7);
    s1.insert(8);
    s1.insert(10);
    s1.insert(12);
    s2.insert(4);
    s2.insert(6);
    s2.insert(9);
    s2.insert(11);
    int x=nxt(),y=nxt();
    if(s1.count(x)&&s1.count(y)||s2.count(x)&&s2.count(y))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 256
n = int(input())
H_l = list(map(int, input().split()))
tmp_max = 0
flg_nd = True
for i in range(n):
    if tmp_max - H_l[i] >=2:
        flg_nd = False
        break;
    if H_l[i] > tmp_max:
        tmp_max = H_l[i]

if flg_nd:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
def minbe(b, e):
    B = A[b : e]
    print(min(B))

def maxbe(b, e):
    B = A[b : e]
    print(max(B))

n = int(input())
A = list(map(int, input().split()))
q = int(input())
for i in range(q):
    queryi = list(map(int, input().split()))
    if queryi[0] == 0:
        minbe(queryi[1], queryi[2])
    else:
        maxbe(queryi[1], queryi[2])


Measured memory_bytes: 5632
#include <stdio.h>

int main () {
	int test;
	scanf("%d", &test);
	char alpha[10000], hasil[10000];
	scanf("%s", &alpha);
	for (int i = 0 ; alpha[i] != '\0' ; i++){
			hasil[i] = alpha[i] + test;
			if(hasil[i] > 'Z'){
				hasil[i]-= 26;
			}
		printf("%c", hasil[i]);
		}
	return 0;
}

Measured memory_bytes: 1628
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define ll long long
#define vel vector<int>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
#define pin pair<int,int>
#define mkp make_pair
#define mot pair<D,D>//time,dist
#define root pair<int,mot>
using namespace std;
vvel ta_min(0);
vvel ta_max(0);
int leth = 1024 * 512;
int siz = leth * 2;
void mmax(ll &a, ll b) { a = max(a, b); }
void mmin(ll &a, ll b) { a = min(a, b); }
int sum(int n) {
	if (n == 0) { return 0; }
	return n % 10 + sum(n / 10);
}
int main() {
	int n, a, b; cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a <= sum(i) and sum(i) <= b) { ans+=i; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int num2(int x){
    int value = 0;
    while(x > 0){
        if(x % 10 == 2){
            value++;
        }
        x /= 10;
    }
    return value;
}

int main(){
    int n;
    cin >> n;
    cout << num2(n) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for(int i = 0; i <= 3000; i++){
    for(int j = 0; j <= 3000; j++){
      int nokori = n - r*i - j*g;
      if(nokori >= 0 and nokori % b == 0) ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
int main() {
  ll L,R,d;
  cin >> L >> R >> d;
  ll ans = 0;
  for(ll x=L; x<=R; x++) {
    if(x%d==0) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E15;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

 
int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n],f[n];
    rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1)cin>>f[i];
    sort(a,a+n);sort(f,f+n);
    ll ok=inf,ng=-1;
    while(abs(ok-ng)>1){
        ll m=(ok+ng)/2;
        ll sum=0;
        rep(i,0,n-1){
            ll x=a[i];
            ll y=f[n-1-i];
            ll mul=x*y;
            if(mul<=m)continue;
            ll t=x-m/y;
            sum+=t;
            if(sum>k)break;
        }
        if(sum>k){
            ng=m;
        }else{
            ok=m;
        }
    }
    cout<<ok<<endl;
    
    return 0;
}


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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< vector<string> > v(N);
    for(int i=0; i<M; i++) {
        int p;
        string S;
        cin >> p >> S;
        v[p-1].push_back(S);
    }

    int ac = 0, pe = 0;
    for(int i=0; i<N; i++) {
        auto f = find(v[i].begin(), v[i].end(), "AC");
        if(f != v[i].end()) {
            ++ac;
            pe += distance(v[i].begin(), f);
        }
    }

    cout << ac << " " << pe << endl;
    return 0;
}


Measured memory_bytes: 10368