akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int solve() {
	var(int, n);
	vec(int, a, n);
	int sum_a = sum(all(a), 0);
	double mean_a = (double)sum_a / n;
	vector<pair<double, int>> v(n);
	rep(i, 0, n) {
		v[i].fi = abs(a[i] - mean_a);
		v[i].se = i;
	}
	sort(all(v));
	return v[0].se;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define CL(x) (x << 1)
#define CR(x) ((x << 1) + 1)
#define sqr(x) ((x) * (x))
#define Task ""

typedef long long cc;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 100005;
vector <int> e[N];
bool le[N], chan[N];
int n, m;
int res;
bool was[N];
int odd, even;
bool ok;
void dfs(int u, int p) {
    was[u] = true;
    if (le[u]) odd++;
    if (chan[u]) even++;
    if (le[u] && chan[u]) ok = true;
    for (auto v: e[u])
        if (v != u) {
            le[v] = le[v] | (chan[u] & 1);
            chan[v] = chan[v] | (le[u] & 1);
            if (!was[v]) dfs(v, u);
        }
}
int main() {
    std :: ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen("input.inp", "r", stdin);
    //-------------------------------------------------------------------------------------------------------
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
    }
    le[1] = 1;
    dfs(1, -1);
    for (int i = 1; i <= n; i++)
        ok = ok | (le[i] && chan[i]);
    if (ok) cout << 1ll * n * (n - 1) / 2 - m;
    else {
        cc tmp = 0;
        for (int i = 1; i <= n; i++) {
            if (!le[i]) tmp += 1ll * even - 1;
            if (!chan[i]) tmp += 1ll * odd - 1;
        }
        cout << max(0ll, 1ll * n * (n - 1) / 2 - m - tmp / 2);
    }
    //-------------------------------------------------------------------------------------------------------
    return 0;
}

Measured memory_bytes: 6912
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
std::vector<char> odata;
char tmp;
int jd=0;

void solve(){
    rep(i,3){
        if(odata.at(i)=='7') {
            jd=1;
        }
    }
    if(jd==0) {
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

int main(){
    rep(i,3){
        cin>>tmp;
        odata.emplace_back(tmp);
    }

    solve();
    return 0;
}


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

using namespace std;
 
int main(){
    string S;

    cin >> S;

    string s = S.substr(0, S.size() - 2);

    for(int i = 0; i < S.size()/2; i++){
        string a = s.substr(0, s.size()/2 - 1);
        string b = s.substr(s.size()/2, s.size()/2 - 1);

        bool flag = true;
        int j = 0;

        while(flag && j < s.size()/2){
            if(a[j] != b[j]){
                flag = false;
            }
            j++;
        }

        if(flag){
            cout << j*2 << endl;
            exit(0);
        }

        s = s.substr(0, s.size() - 2);
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=30005;
char s[N];
int l[12],r[12],sum[N][12];
int main (){
	int n;scanf ("%d",&n);
	scanf ("%s",s+1);
	for (int i=1;i<=n;i++){
		s[i]-='0';
		if (!l[s[i]]) l[s[i]]=i;
		r[s[i]]=i;
		for (int j=0;j<=9;j++) sum[i][j]=sum[i-1][j];
		sum[i][s[i]]++;
	}
	int ans=0;
	for (int i=0;i<=999;i++){
		int a=i/100,b=(i/10)%10,c=i%10;
		if (l[a]==0||l[b]==0||l[c]==0) continue; 
		if (sum[r[c]-1][b]-sum[l[a]][b]>0) ans++;
	}
	printf ("%d",ans);
	return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Dice {
	
	int[] dice = new int[6];
	int tmp;
	String[] num;
	
	public Dice(String s){
		num = s.split(" ");
		for(int i = 0 ; i < dice.length ; i++){
			dice[i] = Integer.parseInt(num[i]) ;
		}
	}
	
	int e(int n){
		tmp = dice[0];
		dice[0] = dice[3] ;
		dice[3] = dice[5] ;
		dice[5] = dice[2];
		dice[2] = tmp;
		return dice[n];
	}
	
	int n(int n){
		tmp = dice[0];
		dice[0] = dice[1] ;
		dice[1] = dice[5] ;
		dice[5] = dice[4];
		dice[4] = tmp;
		return dice[n];
	}
	
	int s(int n){
		tmp = dice[0];
		dice[0] = dice[4] ;
		dice[4] = dice[5] ;
		dice[5] = dice[1];
		dice[1] = tmp;
		return dice[n];
	}
	
	int w(int n){
		tmp = dice[0];
		dice[0] = dice[2] ;
		dice[2] = dice[5] ;
		dice[5] = dice[3];
		dice[3] = tmp;
		return dice[n];
	}

}

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		int n = 0 ;
		String num = input.readLine();
		Dice dice = new Dice(num);
		String com = input.readLine();
		for(int i = 0 ; i < com.length() ; i ++){
		if(com.charAt(i) == 'E') n = dice.e(0);
		if(com.charAt(i) == 'N') n = dice.n(0);
		if(com.charAt(i) == 'S') n = dice.s(0);
		if(com.charAt(i) == 'W') n = dice.w(0);
		}
		
		System.out.println(n);
		
	}
}

Measured memory_bytes: 17076
#include <iostream>
#define REP(i, a, n) for(int i = (a); i <= (n); i++)
using namespace std;

int N, M[51], X[51][11], Y[51][11], l[51][10], d[51][10], c[2][51][9];

int corner(int d1, int d2) {
  return (d2 - d1 + 4) % 4;
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) {
      cin >> M[i];
      REP(j, 1, M[i]) cin >> X[i][j] >> Y[i][j];

      REP(j, 1, M[i] - 1) {
        if(X[i][j] == X[i][j + 1] && Y[i][j + 1] - Y[i][j] > 0) {
          l[i][j] = Y[i][j + 1] - Y[i][j];
          d[i][j] = 0;
        }
        if(X[i][j] == X[i][j + 1] && Y[i][j + 1] - Y[i][j] < 0) {
          l[i][j] = Y[i][j] - Y[i][j + 1];
          d[i][j] = 2;
        }
        if(Y[i][j] == Y[i][j + 1] && X[i][j + 1] - X[i][j] > 0) {
          l[i][j] = X[i][j + 1] - X[i][j];
          d[i][j] = 1;
        }
        if(Y[i][j] == Y[i][j + 1] && X[i][j + 1] - X[i][j] < 0) {
          l[i][j] = X[i][j] - X[i][j + 1];
          d[i][j] = 3;
        }
      }

      REP(j, 1, M[i] - 2) {
        c[0][i][j] = (d[i][j + 1] - d[i][j] + 4) % 4;
        c[1][i][j] = (d[i][M[i] - j - 1] - d[i][M[i] - j] + 4) % 4;
      }
    }

    REP(i, 1, N) {
      if(M[i] != M[0]) continue;
      bool same = true;
      REP(j, 1, M[i] - 1) if(l[i][j] != l[0][j]) same = false;
      REP(j, 1, M[i] - 2) if(c[0][i][j] != c[0][0][j]) same = false;
      bool reverse = true;
      REP(j, 1, M[i] - 1) if(l[i][M[i] - j] != l[0][j]) reverse = false;
      REP(j, 1, M[i] - 2) if(c[1][i][j] != c[0][0][j]) reverse = false;
      if(same || reverse) cout << i << endl;
    }
    cout << "+++++" << endl;
  }

  return 0;
}

Measured memory_bytes: 3056
s = input()
while s != '':
    if s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    elif s[-5:] == 'dream' or s[-5:] == 'erase':
        s = s[:-5]
    else:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    ll ans = 0;
    rep(i,0,1<<(SZ(s)-1)){
        ll sum = 0;
        ll tmp = 0;
        rep(j,0,SZ(s)){
            if(j > 0){
                if(i & (1<<(SZ(s)-1-j))){
                    sum += tmp;
                    tmp = 0;
                    tmp += ((ll)(s[j]-'0'));
                }else{
                    tmp *= 10;
                    tmp += ((ll)(s[j]-'0'));
                }
            }else{
                tmp += ((ll)(s[j]-'0'));
            }
        }
        ans += (sum+tmp);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

const int INF = 1000000000;

void solve() {
    int N; cin >> N;

    vector<int> money;
    money.push_back(1);
    int tmp = 6;
    while (tmp <= 100000) {
        money.push_back(tmp);
        tmp *= 6;
    }
    tmp = 9;
    while (tmp <= 100000) {
        money.push_back(tmp);
        tmp *= 9;
    }
   
   vector<int> dp(N+1, INF);

    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int e : money) {
            if (i + e <= N) dp[i+e] = min(dp[i+e], dp[i] + 1);
        }
    }

    cout << dp[N] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline

S = input()
T = input()

SL = list(S)
TL = list(T)

diffcnt = 0
for i in range(len(TL)):
    s = SL[i]
    t = TL[i]
    if s != t:
        diffcnt += 1

print(diffcnt)


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  ans += n / (a + b) * a;
  n %= (a + b);
  ans += min(n, a);
  cout << ans << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 100000 + 5;
const int M = 3000 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline ll read() {
    ll res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

int a, b, c;
int ans;

int main() {
    std::cin >> a >> b >> c;
    if ((a & 1) || (b & 1) || (c & 1)) {
        puts("0");
        return 0;
    }
    while (!(a == b && b == c) && !(a % 2) && !(b % 2) && !(c % 2)) {
        int ta = (b + c) / 2;
        int tb = (a + c) / 2;
        int tc = (a + b) / 2;
        a = ta, b = tb, c = tc;
        ans++;
    }
    if (a == b && b == c) {
        if (a & 1) printf("%d\n", ans);
        else puts("-1");
    } else {
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
typedef long long ll;
using namespace std;
int main()
{
    string s,t;
    cin >> s >> t;

    int len = s.size() ;

    int counter = 0;
    for(int i =0 ; i<len ; i++)
    {
        if(s[i] != t[i])
            counter++;
    }

    cout << counter << endl;

    return 0;
}



Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    vector<ll >a(n);
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll x=1000;
    for(ll i=0; i<n-1; i++)
    {
        int s=a[i];
        int t=a[i+1];
        if(s<t)
        {
            ll k=x/s;
            x=x%s;
            x+=k*t;
        }
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi f(n);
    f[0]=1;
    vi b(n);
    rep(i,n){
        b[i]=1;
    }
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        b[x]--;
        b[y]++;
        f[y]|=f[x];
        if(b[x]==0){
            f[x]=0;
        }
    }
    cout<<endl;
    int ans=0;
    rep(i,n){
        ans+=f[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import numpy as np
N = input()
A = map(int, input().split())
A = list(A)

A = [0] + A + [0]
total_sum = 0
for i in range(0, len(A) - 1):
    total_sum += abs(A[i + 1] - A[i])

for i in range(1, len(A) - 1):
    partial_sum = total_sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1])
    print(partial_sum)


Measured memory_bytes: 31832
a = int(input())
b = input().split()
c = "APPROVED"
for i in range(a):
    if int(b[i]) % 2 == 0:
        if int(b[i]) % 3 == 0 or int(b[i]) % 5 == 0:
            c = "APPROVED"
        else:
            c = "DENIED"
            break
print(c)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	return x * f;
}

const int MOD = 1e9 + 7;
const int Inv2 = (MOD + 1) / 2;
inline int inc(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline void add(int &x, int y) {y += x; x = y >= MOD ? y - MOD : y;}
inline int mul(int x, int y) {return (ll)x * y % MOD;}
inline int qpow(int x, int y)
{
	int res = 1;
	for (; y; y >>= 1, x = mul(x, x))
		if (y & 1) res = mul(res, x);
	return res;
}

const int MAXN = 3005;
int n, Q, f[MAXN][MAXN], A[MAXN], tmp[MAXN][MAXN];

int main()
{
	n = read(), Q = read();
	for (int i = 1; i <= n; i ++) A[i] = read();
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++)
			if (A[i] > A[j]) f[i][j] = 1;
	for (int i = 1; i <= Q; i ++)
	{
		int x = read(), y = read();
		if (x == y) continue;
		if (x > y) swap(x, y);
		for (int j = 1; j <= n; j ++)
			tmp[x][j] = f[x][j], tmp[j][x] = f[j][x],
			tmp[y][j] = f[y][j], tmp[j][y] = f[j][y];
		for (int j = 1; j <= n; j ++) if (j != x && j != y)
			f[y][j] = f[x][j] = mul(Inv2, inc(tmp[x][j], tmp[y][j])),
			f[j][x] = f[j][y] = mul(Inv2, inc(tmp[j][x], tmp[j][y]));
		f[x][y] = f[y][x] = mul(Inv2, inc(tmp[x][y], tmp[y][x]));
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			add(ans, f[i][j]);
	printf("%d\n", mul(ans, qpow(2, Q)));
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  bool ans=1;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==0){
      if(a%3!=0 && a%5!=0) ans=0;
    }
  }
  if(ans) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

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

int N;

void solve() {
    cin >> N;
    for (int a = 0; a <= N; a++) {
        int b = N - a;
        if (a % 4 == 0 && b % 7 == 0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
count = [[0] * 10 for i in range(10)]
ans = 0

for i in range(N + 1):
    l, r = int(str(i)[0]), int(str(i)[-1])
    count[l][r] += 1

for i in range(1, 10):
    for j in range(1, 10):
        ans += count[i][j] * count[j][i]
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    vi L(m), R(m);
    REP(i, m) cin >> L[i] >> R[i];

    const int MAX = 1000;
    vector<vll> s(MAX, vll(MAX, 0));
    REP(i, m) {
        s[MAX-L[i]][R[i]]++;
    }

    FOR(i, 1, MAX) FOR(j, 1, MAX) {
        s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }

    debug(s);

    REP(_, q) {
        int l, r; cin >> l >> r;
        int sl = MAX - l, sr = MAX - r;

        print(s[sl][r] + s[sr - 1][l - 1] - s[sl][l - 1] - s[sr - 1][r]);
    }

}

Measured memory_bytes: 12604
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int age = sc.nextInt();
        if(age == 1){
            System.out.println("Hello World");
        }else{
            int a = sc.nextInt(),b = sc.nextInt();
            System.out.println(a + b);
        }
    }
}

Measured memory_bytes: 23764
N = int(input().strip())
S = input().strip()
x = 0
maxOfx = 0
'''
if(not len(S) == N):
    print('String length match the given value of N')
    exit()
else:
    for i in range(N):
        if not (S[i] is 'I' or S[i] is 'D'):
            print('The character at %d is not I or D'%(i+1))
            exit()
'''
for i in S:
    if i is 'I':
        x+=1
        if x > maxOfx:
            maxOfx = x
    else:
        x-=1
        if x > maxOfx:
            maxOfx = x
print(maxOfx)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;

    cout << count(ALL(S), '1') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n,mx=0,smx=0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (mx < a[i])mx = a[i];
		else if (smx < a[i] && a[i] <= mx)smx = a[i];

	}
	for (int i = 0;i < n;i++) {
		int ans;
		if (a[i] != mx)ans = mx;
		else ans = smx;
		cout << ans << endl;
	}

}

Measured memory_bytes: 2432
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input().strip()[-1])
    if N in [2,4,5,7,9]:
        print('hon')
    elif N in [0,1,6,8]:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
use strict;
use warnings;
use v5.18;

chomp( my $N = <> );
my @A = split( / /, <> );

my $state = 'undef';
my $ans   = 0;

if ( $N == 1 ) {
    print "1\n";
}
else {
    for ( 1 .. $N - 1 ) {

        # print "$_, $state, $ans\n";
        if ( $A[ $_ - 1 ] < $A[$_] ) {
            if ( $state eq 'dec' ) {
                $ans++;
                $state = 'undef';
            }
            elsif ( $state eq 'undef' ) {
                $state = 'inc';
            }
        }
        elsif ( $A[ $_ - 1 ] > $A[$_] ) {
            if ( $state eq 'inc' ) {
                $ans++;
                $state = 'undef';
            }
            elsif ( $state eq 'undef' ) {
                $state = 'dec';
            }
        }
    }
    $ans++;
    print "$ans\n";
}


Measured memory_bytes: 18252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARegistration solver = new ARegistration();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARegistration {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.nextLine().toCharArray();
            char[] t = in.nextLine().toCharArray();
            for (int i = 0; i < s.length; i++) {
                if (s[i] != t[i]) {
                    out.println("No");
                    return;
                }
            }

            out.println("Yes");
        }

    }

    static class FastReader {
        BufferedReader br;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 25588
N, K = [int(i) for i in input().split()]
d = [s for s in input().split()]
ans = N

while(True):
    sAns = str(ans)
    for i in range(len(sAns)):
        if sAns[i] in d:
            ans += 1
            break
    else:
        break

print(ans)

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

int main()
{

int K,X;cin>>K>>X;

int minX= X - (K-1);

int maxX= X + (K-1);

for(int i=minX; i <= maxX ;i++)
{
    cout<<i<<" ";
}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	for (int i = 0; i < 3; i++) {
		cout << S[i];
	}
	cout << endl;
	

	
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }
 
int main()
{
	ios::sync_with_stdio(0);
 
	int i, j, k, n;
 
	cin>>n;
	double dp[n+1][n+1];
	memset(dp, 0, sizeof dp);
	
	dp[0][0] = 1;
 
	double ans = 0;
	for(i=1;i<=n;++i)
	{
		double temp;
		cin>>temp;
		for(j=0;j<=n;++j)
		{
			dp[i][j] = ( j > 0 ? dp[i-1][j-1] * temp : 0 ) + dp[i-1][j] * (1-temp);
			if(i == n and j > (n/2))
				ans += dp[i][j];
		}
	}
 
	printf("%.10lf\n", ans);
 
	return 0;
}

Measured memory_bytes: 70528
#include <iostream>
#include <algorithm>
#include <cmath>
#include<string>
#include <array>
#include <vector>
using namespace std;

int main() {
	int a, b, c,i=3;
	cin >> a >> b >> c;
	if (a == b)i--;
	if (a == c)i--;
	if (b == c)i--;
	if (i == 0)i = 1;
	cout << i << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)

void solve(int n) {
    string s = "";
    string t;
    rep(i,n) {
        cin>>t;
        s += t;
    }

    set<string> S;
    for(int len=1; len<=n; len++) {
        for(int i=0; i<n-len+1; i++) {
            string ss = s.substr(i,len);
            S.insert(ss);
        }
    }

    for(int i=0; ; i++) {
        if(S.count(to_string(i)) == 0) {
            cout << i << "\n";
            break;
        }
    }
    return ;
}

int main() {
    int n;
    while(cin>>n) solve(n);
    return 0;
}

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

using pii = pair<int, int>;
using ll = long long;

template <typename T>
class fenwick_tree {
public:
    fenwick_tree(int n) : n(n), dat(n, 0) {}

    void add(int i, T value) {
        for(; i<n; i |= i + 1) {
            dat[i] += value;
        }
    }

    T sum(int i) const {
        T res = 0;
        for(; i>=0; i = (i & (i+1)) - 1) {
            res += dat[i];
        }
        return res;
    }
    T sum(int l, int r) const {
        return sum(r-1) - sum(l-1);
    }

private:
    const int n;
    std::vector<T> dat;
};


int main() {
    int n;
    scanf("%d", &n);
    vector<pair<ll, int>> v(n);
    vector<int> l(n);
    for(int i = 0; i < n; ++i) {
        int p;
        scanf("%d", &p);
        if(i == 0) {
            v[i] = make_pair(p, i);
        } else {
            v[i] = make_pair(v[i - 1].first + p, i);
        }
    }
    for(int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(v.begin(), v.end() - 1);
    bool check = v[0].first >= l[0];
    for(int i = 1; i < n; ++i) {
        check &= v[i].first - v[i - 1].first >= l[i];
    }
    if(!check) {
        cout << -1 << endl;
        return 0;
    }

    fenwick_tree<int> bit(n);
    ll res = 0;
    for(int i = 0; i < n - 1; ++i) {
        res += i - bit.sum(v[i].second);
        bit.add(v[i].second, 1);
    }
    printf("%lld\n", res);
}


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

using namespace std;

int main()
{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	int a, b;

	cin >> a >> b;

	if (a - 2* b <= 0)
	{

		cout << "0";

	}

	else
	{
      
      cout<< a - 2*b <<"\n";

	}

    return 0;

}

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

using namespace std;

int main() {
    int base[2];
    for (int i = 0; i < 2; ++i) {
        scanf("%d", &base[i]);
    }

    int input[2];
    for (int j = 0; j < 2; ++j) {
        scanf("%d", &input[j]);
    }

    cout << base[0]*base[1] - input[0]*base[1] - input[1]*base[0] + input[0]*input[1];
}

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

int main(){
  int x,y,z;
  cin >> x >> y >>z;
  int ans =0;
  for(int i=1;i<x+1;i++){
    if((z+y)*i+z <=x){
      ans++;
    }
    else {
      cout << ans << endl;
      break;
    }
  }
}


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

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;

    cout << x/500*1000 + x%500/5*5 << "\n";

    return 0;
}

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

#define maxN 10000
bool isNotPrime[ maxN + 1 ] = { true, true};
int prime[maxN], numPrime = 0;

void sleve(){
    for(int i = 2 ; i <= maxN ; i ++)
    {
        if( !isNotPrime[i] )
            prime[numPrime ++] = i;
        //?????????1
        for(int j = 0 ; j < numPrime && i * prime[j] <=  maxN ; j ++)
        {
            isNotPrime[i * prime[j]] = true;
            if( i % prime[j] == 0 )  //?????????2
                break;
        }
    }
}


int main(){
    sleve();
    queue<int> result;
    int N;
    
    while (cin>>N) {
        int count = 0;
        for (int i = 1; i <= N; i++) {
            if(!isNotPrime[i] && !isNotPrime[N+1-i]){
                count++;
            }
        }
        result.push(count);
    }
    
    while (!result.empty()) {
        cout<<result.front()<<endl;
        result.pop();
    }
    
    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a=2000,b=2000;
  for(int i=0,k;i<3;i++){
    cin>>k;
    a=min(a,k);
  }
  for(int i=0,k;i<2;i++){
    cin>>k;
    b=min(b,k);
  }
  cout<<a+b-50<<endl;
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll 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)1E18;
#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 endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct U_F{
    vector<ll> par;
    vector<ll> rank;
private:
    vector<ll> num;
public:
    void init(ll n){
        rep(i,0,n-1){
            par.pb(i);
            rank.pb(0);
            num.pb(1);
        }
    }
    ll find(ll x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(ll x,ll y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(rank[x]<rank[y]){
            par[x]=y;
            num[y]=num[x]+num[y];
        }else if(rank[x]==rank[y]){
            par[y]=x;
            rank[x]++;
            num[x]=num[x]+num[y];
        }else{
            par[y]=x;
            num[x]=num[x]+num[y];
        }
    }
    bool same(ll x,ll y){
        return find(x)==find(y);
    }
    ll g_num(ll x){
        x=find(x);
        return num[x];
    }
};

int main(){fastio
    ll n,m;cin>>n>>m;
    ll p[n];
    rep(i,0,n-1){
        cin>>p[i];
        p[i]--;
    }
    ll x[m],y[m];
    U_F uf;
    uf.init(n);
    rep(i,0,m-1){
        cin>>x[i]>>y[i];
        x[i]--;
        y[i]--;
        
        uf.unite(x[i],y[i]);
    }
    map<ll,vector<ll>> mp;
    rep(i,0,n-1){
        ll par=uf.find(i);
        auto it=mp.find(par);
        if(it==mp.end()){
            vector<ll> v;
            v.pb(i);
            mp[par]=v;
        }else{
            mp[par].pb(i);
        }
    }
    
    
    
    vector<set<ll>> v[2];
    for(auto it=mp.begin();it!=mp.end();++it){
        vector<ll> u=(it->second);
        set<ll> st[2];
        rep(i,0,(ll)u.size()-1){
            st[0].insert(u[i]);
            st[1].insert(p[u[i]]);
        }
        v[0].pb(st[0]);
        v[1].pb(st[1]);
    }
    
    
    
    ll ans=0;
    rep(i,0,v[0].size()-1){
        for(auto it=v[0][i].begin();it!=v[0][i].end();++it){
            ll k=(*it);
            auto itr=v[1][i].find(k);
            if(itr!=v[1][i].end()){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    
    
        
    return 0;
}





Measured memory_bytes: 37444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   int a, b, c;
   cin >> a >> b >> c;
   if (c <= b && c >= a)
   {
      cout << "Yes" << endl;
   }
   else
   {
      cout << "No" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
int A[MAX],n;
int partition(int p,int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            t=A[i];A[i]=A[j];A[j]=t;
        }
    }
    t=A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}
int main(){
    int i,q;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    q=partition(0,n-1);
    for(i=0;i<n;i++){
        if(i) printf(" ");
        if(i==q) printf("[");
        printf("%d",A[i]);
        if(i==q) printf("]");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

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

    int arr[3][3];
    for(int i = 0; i<3; i++){
        for(int j = 0; j<3; j++) cin>>arr[i][j];
    }

    int n, x;
    cin>>n;
    loop(n){
        cin>>x;
        for(int p = 0; p<3; p++){
            for(int q = 0; q<3; q++){
                if(arr[p][q]==x) arr[p][q] = 0;
            }
        }
    }

    bool b = 0;
    if(arr[0][0]==0 && arr[0][1]==0 && arr[0][2]==0) b = 1;
    if(arr[1][0]==0 && arr[1][1]==0 && arr[1][2]==0) b = 1;
    if(arr[2][0]==0 && arr[2][1]==0 && arr[2][2]==0) b = 1;
    if(arr[0][0]==0 && arr[1][0]==0 && arr[2][0]==0) b = 1;
    if(arr[0][1]==0 && arr[1][1]==0 && arr[2][1]==0) b = 1;
    if(arr[0][2]==0 && arr[1][2]==0 && arr[2][2]==0) b = 1;
    if(arr[0][0]==0 && arr[1][1]==0 && arr[2][2]==0) b = 1;
    if(arr[2][0]==0 && arr[1][1]==0 && arr[0][2]==0) b = 1;

    if(b) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define pb push_back
#define ll long long
ll a[200005];
int main(int argc, char** argv) {
ll n;
ll kk;
scanf("%lld%lld",&n,&kk);
vector<ll>f,z; 
for(int i=1;i<=n;i++)
{
	scanf("%lld",&a[i]);
	if(a[i]<0)f.pb(a[i]);
	else z.pb(a[i]);
}
sort(f.begin(),f.end());
sort(z.begin(),z.end());
ll p=f.size(),q=z.size();
kk=(n*(n-1))/2-kk+1;
if(p*(p-1)/2+(q*(q-1))/2>=kk)
{
	ll l=0,r=1e18,ans=0;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		ll p=0;
		for(int i=0;i<z.size();i++)
		{
			int lll=i+1,rr=z.size()-1,k=-1;			 
			while(lll<=rr)
			{
				int mi=(lll+rr)>>1;
				if(z[mi]*z[i]>=mid)
				{	k=mi;
					rr=mi-1;
				}
				else
				{
					lll=mi+1;
				}
			}
			if(k==-1)continue;
		//	if(mid==12)cout<<k<<"??"<<" "<<i<<endl;
			p+=z.size()-k;
		}
		//if(mid==12)cout<<p<<endl;
		for(int i=0;i<f.size();i++)
		{
			int lll=0,rr=i-1,k=-1;			 
			while(lll<=rr)
			{
				int mi=(lll+rr)>>1;
				if(f[mi]*f[i]>=mid)
				{	k=mi;
					lll=mi+1;
				}
				else
				{
					rr=mi-1;
				}
			}
			if(k==-1)continue;
			p+=k+1;
		}
		if(p>=kk)
		{
		//	printf("%lld ?%lld\n",mid,p);
			ans=mid;
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	
	printf("%lld",ans);
}
else
{
	kk-=p*(p-1)/2+(q*(q-1))/2;
	ll l=-1e18,r=0,ans=0;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		ll p=0;
		for(int i=0;i<z.size();i++)
		{
			int lll=0,rr=f.size()-1,k=-1;	
			//cout<<rr<<endl;		 
			while(lll<=rr)
			{
				//cout<<lll<<" "<<rr<<endl;
				int mi=(lll+rr)>>1;//cout<<mi<<endl;
				if(f[mi]*z[i]>=mid)
				{	k=mi;
					rr=mi-1;
				}
				else
				{
					lll=mi+1;
				}
			}
			
			if(k==-1)continue;
			p+=f.size()-k;
		}
		
		if(p>=kk)
		{
			ans=mid;
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	printf("%lld\n",ans);
}

	return 0;
}

Measured memory_bytes: 3700
h, w = map(int, input().split())
l = []
for i in range(h):
    retu = list(input())
    if "#" in retu:
        l.append(retu)
ll = []
for i in zip(*l):
    if "#" in i:
        ll.append(i)
for i in zip(*ll):
    print("".join(i))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int N;
int A[100005];

int solve(){
  int i=0;
  int ans=1;

  while(i<N&&A[i]==A[0])i++;
  
  while(i<N){
    if( A[i-1] > A[i] ){
      while(i<N&& A[i-1]>=A[i] ) i++;
    }else{
      while(i<N&& A[i-1]<=A[i] ) i++;
    }
    if(i>=N)break;
        ans++;

    int key=A[i];
    while(i<N&&A[i]==key)i++;
  }
  return ans;
}

int main() {
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];

  cout<< solve() <<endl;
  return 0;
} 


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int pa[3],ju[2],temp=4001;
	
	for(int i=0;i<3;i++) scanf("%d",&pa[i]);
	for(int i=0;i<2;i++) scanf("%d",&ju[i]);
	for(int i=0;i<3;i++){
		for(int j=0;j<2;j++){
			if(temp>pa[i]+ju[j]-50)
			temp=pa[i]+ju[j]-50;
		}
	}
	printf("%d\n",temp);
}

Measured memory_bytes: 3200
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints


if A <= 5
  puts '0'
elsif A <= 12
  puts B / 2
else
  puts B
end


Measured memory_bytes: 14352
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  string S; cin >> S;
  stack<string> st;

  for (int i=0;i<S.size();i++){
    if (st.empty() || st.top().size()==2 || S.substr(i,1)!=st.top()) { //1文字追加
      st.push(S.substr(i,1));
    }
    else if (i<S.size()-1 ){ 
      st.push(S.substr(i,2));
      i++;
    }
    else {
      st.pop();
      st.push(S.substr(i-1,2));
    }
    
  }

  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 11012
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

const int MAX = 200000;

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

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int 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;
    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    int n;
    cin >> n;
    vector<int> a(n + 1);
    map<int, int> cnt;
    for(int i = 0; i < n + 1; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int num, id1 = -1, id2 = -1;
    for(auto p : cnt) {
        if(p.second > 1) {
            num = p.first;
            break;
        }
    }
    for(int i = 0; i < n + 1; i++) {
        if(id1 == -1 && a[i] == num) {
            id1 = i;
        } else if(id2 == -1 && a[i] == num) {
            id2 = i;
        }
    }
    // cout << id1 << ' ' << id2 << endl;
    for(int k = 1; k <= n + 1; k++) {
        ll ans = COM(n + 1, k);
        ll y = COM(id1 + (n - id2), k - 1);
        cout << (MOD + ans - y) % MOD << endl;
    }
}

Measured memory_bytes: 11008
#include<iostream>   
#include<string>
#include<vector>
using namespace std; 
 
int main()
{
	char a; 
	cin >> a; 
	if (a=='a'||a=='i'||a=='u'||a=='e'||a=='o')
	{
		cout << "vowel\n";
	}
	else
	{
		cout << "consonant\n";
	}
	

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long i64;

int main()
{
	int n, k;
	char temp[200005];
	vector<bool> state;

	scanf("%d%d%s", &n, &k, temp);
	state.resize(n);
	for(int i = 0; i < n; ++i)
		state[i] = (temp[i] == 'A');

	int step = k % (2 * n);
	if(k >= 2 * n)
		step += 2 * n;

	int left = 0;
	bool flip = false;

	for(int s = 0; s < step; ++s) {

		bool is_a = (state[left] != flip);

		if(is_a) {
			//printf("%d: %d first\n", s, left);
			state[left] = !state[left];
			continue;
		}

		//printf("%d: %d second\n", s, left);

		left = (left + 1) % n;
		flip = !flip;
	}

	char ans[200005] = {0};
	for(int i = 0; i < n; ++i) {
		int pos = (left + i) % n;
		bool is_a = (state[pos] != flip);
		ans[i] = (is_a ? 'A' : 'B');
	}

	printf("%s\n", ans);

	return 0;
}


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


int main(){
  string s;
  priority_queue<ll> q;
  vector<ll> ans;
  while(cin >> s,s!="end"){
    ll x;
    if(s=="insert"){
      cin >> x;
      q.push(x);
    }
    if(s=="extract"){
      ll tmp=q.top();
      q.pop();
      ans.push_back(tmp);
    }
  }
  int n=ans.size();
  for(int i=0;i<n;++i){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 18592
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, count, num;
		while (true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			// conditions to terminate
			if (n == 0 && x == 0) {
				break;
			}
			// count
			count = 0;
			for (i = 1; i <= n; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					for (int k = j + 1; k <= n; ++k) {
						num = i + j + k;
						if (num == x) {
							++count;
						}
					}
				}
			}
			System.out.println(count);
		}
		sc.close();
	}

}



Measured memory_bytes: 26500