akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <tuple>
using namespace std;

template <class T> void chmax(T &x, T y) {if(x<y) x=y;}
template <class T> void chmin(T &x, T y) {if(x>y) x=y;}



main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);

    long long h,w; cin>>h>>w;
    if(h==1 or w==1)
    {
        cout << 1 << "\n";
    }
    else cout<<(h/2)*(w/2)+(h+1)/2*((w+1)/2);
}


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

#define LL long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define vecprint(vec) for (int i=0;i<vec.size();i++)printf("%d ",vec[i]);
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MEM(v,x) memset(v,x,sizeof v)

const double eps=1e-7,PI=3.1415926;
const int N=100;

using namespace std;

int n,q,m,k,x,y,b[N],re[N],a[N],mx=-1,mn=1e9,sum,t;
char c[N];
string s,s1,s2;
map < int , int > mp;
vector < int > vec;

int main(){
    cin>>n;
    for (int i=0;i<n;i++){
        sc(a[i]);
        re[i]=i+1;
    }
    for (int j=0;j<n;j++){
        sc(b[j]);
    }
    int cnt=1;
    do {
        bool is1=1,is2=1;
        for (int i=0;i<n;i++){
            if (re[i]!=a[i])is1=0;
            if (re[i]!=b[i])is2=0;
        }
        if (is1)x=cnt;
        if (is2)y=cnt;
        cnt++;
    }while (next_permutation(re,re+n));
    cout<<abs(x-y)<<endl;
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    map<string, ll> m;
    rep (i, N) {
        string s;
        cin >> s;
        m[s]++;
    }

    ll max_count = 0;
    for (map<string, ll>::iterator it = m.begin(), end = m.end(); it != end; it++) {
        max_count = max(max_count, it->second);
    }

    vector<string> v;
    for (map<string, ll>::iterator it = m.begin(), end = m.end(); it != end; it++) {
        if (max_count == it->second) {
            v.push_back(it->first);
        }
    }

    sort(v.begin(), v.end());
    rep (i, v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 25584
N, *B = map(int, open(0).read().split())
A = []
for _ in range(N):
    for j in reversed(range(len(B))):
        if B[j] == j + 1:
            del B[j]
            A.append(j + 1)
            break
    else:
        print(-1)
        quit()
print(*reversed(A), sep="\n")


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#define FOR(i, n) for (int i = 0; i < n; i++)

typedef long long ll;
typedef std::pair<int, int> pii;

const int MAXN = 500100;
const int inf = 1e9;

int n, q;
pii queries[MAXN];
char s[MAXN];

void load() {
	scanf("%s", s);
	n = strlen(s);
	scanf("%d", &q);
	FOR(i, q) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		queries[i] = pii(a, b);
	}
}

int next[MAXN][30];
int next0[MAXN][23];

void solve() {
	FOR(i, (n + 1)) FOR(j, 30) next[i][j] = inf;
	FOR(i, (n + 1)) FOR(j, 18) next0[i][j] = inf;
	
	for (int i = n - 1; i >= 0; i--) {
		int c = s[i] - 'a';
		next[i][c] = i + 1;
		for (int j = c + 1; j < 26; j++) {
			if (next[i][j-1] == inf) next[i][j] = inf;
			else next[i][j] = next[next[i][j-1]][j - 1];
		}
		if (next[i][25] == inf) next0[i][0] = inf;
		else next0[i][0] = next[next[i][25]][25];
		for (int j = 1; j < 23; j++) {
			if (next0[i][j-1] == inf) next0[i][j] = inf;
			else next0[i][j] = next0[next0[i][j-1]][j-1];
		}
		for (int j = 0; j < c; j++) {
			if (next0[i][0] == inf) next[i][j] = inf;
			else next[i][j] = next[next0[i][0]][j];
		}
	}
	FOR(i, q) {
		pii p = queries[i];
		int a = p.first, b = p.second;
		int x = a;
		for (int j = 22; j >= 0; j--) {
			if (next0[x][j] <= b + 1) x = next0[x][j];
		}
		if (x == b + 1) printf("Yes\n");
		else printf("No\n");
	}
}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 107008
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

    sort(rall(a));
    sort(rall(b));

    int maxv = a[0];

    int ans = 0;
    rep(i, n){
        if(h <= 0 || maxv > b[i]) break;
        h -= b[i];
        ans++;
    }

    if(h > 0) ans += h/maxv + (h%maxv != 0);

    cout << ans << endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct DisjointSet{
    vector<int> p;
    DisjointSet(int n) : p(n){
        rep(i,n) p[i] = -1;
    } 

    int root(int x){
        if(p[x] < 0) return x;
        return p[x] = root(p[x]);
    }

    int size(int x){
        return -p[root(x)];
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(size(rx) < size(ry)) swap(rx, ry);
        p[rx] += p[ry]; // 親になるノードに子がもともと保持していたグループ数をプラスする
        p[ry] = rx; // 子ノードを親にくっつける
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    ll n, m; cin >> n >> m;
    int a[m], b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }
    reverse(a, a+m);
    reverse(b, b+m);    

    DisjointSet dis = DisjointSet(n);

    ll ans[m];
    ans[0] = n*(n-1)/2;

    rep(i,m-1){
        if(dis.same(a[i], b[i])){
            ans[i+1] = ans[i];
            continue;
        }
        ans[i+1] = ans[i] - dis.size(a[i])*dis.size(b[i]);
        dis.unite(a[i], b[i]);
    }

    reverse(ans, ans+m);
    rep(i,m) cout << ans[i] << endl;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  long long n, x = 0, sum = 0;
  cin >> n;
  long long a[n], ans[n];
  rep(i, n) ans[i] = 100000000000LL;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  rep(i, n - 1) {
    x += a[i];
    ans[i] = abs(sum - 2 * x);
  }
  cout << *min_element(ans, ans + n) << endl;
  return 0;
}


Measured memory_bytes: 3328
X = int(input())

if X >= 400 and X < 600:
    print('8')
if X >= 600 and X < 800:
    print('7')
if X >= 800 and X < 1000:
    print('6')
if X >= 1000 and X < 1200:
    print('5')
if X >= 1200 and X < 1400:
    print('4')
if X >= 1400 and X < 1600:
    print('3')
if X >= 1600 and X < 1800:
    print('2')
if X >= 1800 and X < 2000:
    print('1')


Measured memory_bytes: 9184
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    string S;
    map<string,ll> mp;
    REP(i,N){
        cin>>S;
        mp[S]=1;
    }
    cout<<mp.size()<<endl;
}

Measured memory_bytes: 19192
#include<iostream>

using namespace std;

#define VAR 100

struct S{
	int U,D,R,L,F,B,h,x,y;
};

int main(){

	int field[VAR][VAR][VAR];
	int n;
	int t,f;
	int tmp;
	int cnt[7];
	S dice;

	while(1){

		cin>>n;
		if(n==0) break;

		for(int i=0;i<VAR;i++){
			for(int j=0;j<VAR;j++){
				for(int k=0;k<VAR;k++){
					field[i][j][k]=-1;
				}
			}
		}

		for(int i=0;i<n;i++){
			cin>>t>>f;
			dice.U=t;
			dice.D=7-t;
			dice.F=f;
			dice.B=7-f;
			if(t==1&&f==2) dice.R=3,dice.L=4;
			if(t==1&&f==3) dice.R=5,dice.L=2;
			if(t==1&&f==4) dice.R=2,dice.L=5;
			if(t==1&&f==5) dice.R=4,dice.L=3;
			if(t==2&&f==1) dice.R=4,dice.L=3;
			if(t==2&&f==3) dice.R=1,dice.L=6;
			if(t==2&&f==4) dice.R=6,dice.L=1;
			if(t==2&&f==6) dice.R=3,dice.L=4;
			if(t==3&&f==1) dice.R=2,dice.L=5;
			if(t==3&&f==2) dice.R=6,dice.L=1;
			if(t==3&&f==5) dice.R=1,dice.L=6;
			if(t==3&&f==6) dice.R=5,dice.L=2;
			if(t==4&&f==1) dice.R=5,dice.L=2;
			if(t==4&&f==2) dice.R=1,dice.L=6;
			if(t==4&&f==5) dice.R=6,dice.L=1;
			if(t==4&&f==6) dice.R=2,dice.L=5;
			if(t==5&&f==1) dice.R=3,dice.L=4;
			if(t==5&&f==3) dice.R=6,dice.L=1;
			if(t==5&&f==4) dice.R=1,dice.L=6;
			if(t==5&&f==6) dice.R=4,dice.L=3;
			if(t==6&&f==2) dice.R=4,dice.L=3;
			if(t==6&&f==3) dice.R=2,dice.L=5;
			if(t==6&&f==4) dice.R=5,dice.L=2;
			if(t==6&&f==5) dice.R=3,dice.L=4;
			dice.h=VAR-1;
			dice.x=VAR/2,dice.y=VAR/2;

			while(1){
				while(dice.h!=0&&field[dice.h-1][dice.y][dice.x]==-1) dice.h--;
				int dir=-1; 
				int dirmax=-1;
				if(dice.h!=0&&field[dice.h-1][dice.y][dice.x+1]==-1){
					if(dirmax<dice.R&&dice.R>=4){
						dir=3;
						dirmax=dice.R;
					}
				}
				if(dice.h!=0&&field[dice.h-1][dice.y][dice.x-1]==-1){
					if(dirmax<dice.L&&dice.L>=4){
						dir=4;
						dirmax=dice.L;
					}
				}
				if(dice.h!=0&&field[dice.h-1][dice.y+1][dice.x]==-1){
					if(dirmax<dice.B&&dice.B>=4){
						dir=2;
						dirmax=dice.B;
					}
				}
				if(dice.h!=0&&field[dice.h-1][dice.y-1][dice.x]==-1){
					if(dirmax<dice.F&&dice.F>=4){
						dir=1;
						dirmax=dice.F;
					}
				}
				if(dir==-1){
					field[dice.h][dice.y][dice.x]=dice.U;
					break;
				}
				if(dir==1){
					dice.y--;
					tmp=dice.U;
					dice.U=dice.B;
					dice.B=dice.D;
					dice.D=dice.F;
					dice.F=tmp;
				}
				if(dir==2){
					dice.y++;
					tmp=dice.U;
					dice.U=dice.F;
					dice.F=dice.D;
					dice.D=dice.B;
					dice.B=tmp;
				}if(dir==3){
					dice.x++;
					tmp=dice.U;
					dice.U=dice.L;
					dice.L=dice.D;
					dice.D=dice.R;
					dice.R=tmp;
				}if(dir==4){
					dice.x--;
					tmp=dice.U;
					dice.U=dice.R;
					dice.R=dice.D;
					dice.D=dice.L;
					dice.L=tmp;
				}
			}
		}
		for(int i=0;i<7;i++) cnt[i]=0;
		for(int i=0;i<VAR;i++){
			for(int j=0;j<VAR;j++){
				for(int k=0;k<=VAR;k++){
					if(k==VAR||field[k][i][j]==-1){
						if(k!=0){
							cnt[field[k-1][i][j]]++;
						}
						break;
					}
				}
			}
		}
		for(int i=1;i<6;i++) cout<<cnt[i]<<" ";
		cout<<cnt[6]<<endl;
	}

}

Measured memory_bytes: 5068
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

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

	vector<int> mod(100001);
	int m = 1;
	rep(i, 100001) {
	  mod[i] = m;
		m *= 10;
		m %= 13;
	}

	reverse(s.begin(),s.end());

	vector<vector<ll>> dp(s.size()+1, vector<ll>(13,0));
	dp[0][0] = 1;
	rep(i, s.size()) rep(j,13) {
		if (s[i] == '?') {
			rep(si, 10) {
				dp[i + 1][(j + mod[i] * si) % 13] += dp[i][j];
				dp[i + 1][(j + mod[i] * si) % 13] %= MOD;
			}
	  }
		else {
			int si = static_cast<int>(s[i] - '0');
			dp[i + 1][(j + mod[i] * si) % 13] += dp[i][j];
			dp[i + 1][(j + mod[i] * si) % 13] %= MOD;
		}
	}
	//debug2D(dp);
	cout << dp[s.size()][5] << endl;
}




Measured memory_bytes: 14080
#include <stdio.h>

int binary_search(int *A, int n, int key)
{
	int left, right, mid;
	left = 0;
	right = n;
	while (left < right) {
		mid = (left + right) / 2;
		if (A[mid] == key) return 1;
		if (A[mid] < key) {
			left = mid + 1;
		} else {
			right = mid;
		}
	}
	return 0;
}

int main(int argc, char *argv[])
{
	int S[100000], key, i, n, q, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (binary_search(S, n, key))
			sum++;
	}

	printf("%d\n", sum);

	return 0;
}



Measured memory_bytes: 2124
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]

    inf = 1e7

    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        x, y = que.popleft()
        for i in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[i]
                ny += dy[i]
                if nx < 0 or nx >= h or ny < 0 or ny >= w: break
                if field[nx][ny] == '@' or dist[nx][ny] <= dist[x][y]: break
                if dist[nx][ny] > dist[x][y] + 1:
                    dist[nx][ny] = dist[x][y] + 1
                    que.append((nx, ny))
        
    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38368
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=10+10;

int main()
{

    int n;
    while(~scanf("%d",&n)){
        int sum=0;
        while(n){
            sum+=n%10;
            n/=10;

        }
        printf("%d\n",sum);
    }
    return 0;
}




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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

//条件式 ? 真の場合の文 : 偽の場合の文
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
//binary_search(all(p),x) bool型

int main(){

    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i< N; i++) cout << dist[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 10184
import java.util.Scanner;

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

		int ans = 1;
		for (int i = 2; i <= X; i++) {
			int pow = i * i;
			while (pow <= X) {
				ans = Math.max(ans, pow);
				pow *= i;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
n = int(input())
lists = list(map(int,input().split()))
count = 0

for i in range(n):
    if(lists[i] % 2 ==0):
        while(True):
            if(lists[i] % 2 ==0):
                lists[i] = lists[i]/2
                count+=1
            else :
                break
print(count)

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

int main(){
  int H,W;
  while(cin>>H>>W){
    if(H==0 && W==0) break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(i==0 || i==H-1) cout<<"#";
        else if(j==0 || j==W-1) cout<<"#";
        else{cout<<".";
      }
    }cout<<endl;
  }cout<<endl;

  }

  return 0;
}

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

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

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[i] == a[j] || a[j] == a[k] || a[k] == a[i])
                    continue;

                int b[3] = {a[i], a[j], a[k]};
                sort(b, b + 3);
                if (b[2] < b[0] + b[1])
                    ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N,i,j;

  cin >> N;
  vector<long int> C(N-1,0);
  vector<long int> S(N-1,0);
  vector<long int> F(N-1,0);
  vector<long int> O(N,0);

  for (i = 0; i < N-1; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }

  for (i = 0; i < N-1; i++) {
    O[i] = S[i] + C[i];
    for (j = i + 1; j < N-1; j++) {
      if(O[i] < S[j]) {
        O[i] = S[j];
      }
      if(O[i] % F[j] != 0){
        O[i] += (F[j] - (O[i] % F[j]));
      }
      O[i] += C[j];
    }
  }

  for (i = 0; i < N; i++) {
    cout << O[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    ll L = 0, R = N+1;
    while(R - L > 1){
        ll M = L + (R - L)/2;
        if((ll)(1.08 * M) == N){
            cout << M << endl;
            return 0;
        }else if(1.08 * M < N){
            L = M;
        }else{
            R = M;
        } 
    }
    cout << ":(" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
      
      char x = a.charAt(0);
      char y = b.charAt(1);
      char z = c.charAt(2);
      
      System.out.print(x);
      System.out.print(y);
      System.out.print(z);
      
    }
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A*B > C*D ) cout << A*B << endl;
  else cout << C*D << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int n;
	scanf("%d",&n);
	REP0(i,n){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		printf((a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b)?"YES\n":"NO\n");
	}
	return 0;
}

Measured memory_bytes: 1172
public class Main {

	
	public static void main(String[] args) {
		for(int i = 1; i <= 9; i++){
			for(int j = 1; j <= 9; j++){
				int k = i*j;
				System.out.println(i + "x" + j + "=" + k);
			}
		}

	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), d(1e6 + 1), cnt(1e6 + 1);
  rep(i, n) {
    cin >> a[i];
    if (cnt[a[i]] == 0) {
      for (int j = a[i] * 2; j < 1e6 + 1; j += a[i]) {
        d[j] = 1;
      }
    }
    cnt[a[i]]++;
  }

  int ans = 0;
  rep(i, n) if (d[a[i]] == 0 && cnt[a[i]] == 1) ans++;
  cout << ans << endl;
  return 0;
}


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

int n,fhy,fy,fhyv;

int main(){
	cin>>n;
	fhy = n/500;
	fhyv = 1000 * (n / 500);
	fy = 5 * ((n - (500*fhy)) / 5);
	cout<<fhyv + fy<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define FOR(hoge,a) for(hoge=0;hoge<a;hoge++)
int i,j;
int kyori[100001];
int nagasa[100000];
int main() {
	int n,m;
	cin>>n>>m;
	FOR(i,n-1){
		cin>>nagasa[i];
	}
	int ima=0;
	FOR(i,m){
		int u;
		cin>>u;
		if(u>0){
			kyori[ima]++;
			kyori[ima+u]--;
		}
		if(u<0){
			kyori[ima]--;
			kyori[ima+u]++;
		}
		ima+=u;
	}
	int ans=0;int kaisuu=0;
	FOR(i,n-1){
		kaisuu+=kyori[i];
		ans+=kaisuu*nagasa[i];
		ans%=100000;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1944
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long
using namespace std;

const int N = 100111;
const int inf = 1e10;
int n ,a , b;

signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;

    return 0;
}


Measured memory_bytes: 256
private fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}

private fun readInt(): Int {
    return readLine()!!.toInt()
}

private fun readTextArray(): List<String> {
    return readLine()!!.split(" ")
}

fun main(args: Array<String>) {
    val N = readInt()
    val A = readIntArray()

    var all: Long = 0
    for (i in 0 until N) {
        if(i == 0) {
            all += Math.abs(A[0])
        } else {
            all += Math.abs(A[i] - A[i - 1])
        }
    }
    all += Math.abs(A[N - 1])

    for (i in 0 until N) {
        if (i == 0) {
            println(all + Math.abs(A[1]) - Math.abs(A[0]) - Math.abs(A[1] - A[0]))
        } else if(i == N - 1) {
            println(all + Math.abs(A[N - 2]) - Math.abs(A[N - 1] - A[N - 2]) - Math.abs(A[N - 1]))
        } else {
            println(all + Math.abs(A[i + 1] - A[i - 1]) - Math.abs(A[i] - A[i - 1]) - Math.abs(A[i + 1] - A[i]))
        }
    }
}

Measured memory_bytes: 58736
#include<cstdio>
int v[100001];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		int l,r;
		scanf("%d %d",&l,&r);
		for(int j=l;j<=r;j++){
			if(!v[j]){
				v[j]=1;
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
from collections import deque
H, W = map(int, input().split())
grid = [list(input()) + [False] for _ in range(H)]
grid = grid + [[False for _ in range(W + 1)]]


def bfs(q):
    res_q = deque()
    while len(q):
        x, y = q.popleft()
        for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            nx = x + dx
            ny = y + dy

            if grid[nx][ny] == '.':
                res_q.append((nx, ny))
                grid[nx][ny] = '#'
    return res_q


q = deque()
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            q.append((i, j))

res = 0
while len(q):
    res += 1
    q = bfs(q)

print(res - 1)


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

int main() {
  int64_t a,aa,b,ba,k;
  int64_t zero = 0;
  cin >> a >> b >> k; 
  aa = max(a - k, zero);
  ba = b;
  if(aa == 0){
    k = k - a;
    ba = max(b - k, zero);
  }
  cout << aa << " " << ba << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(){
 
  char str[1002],ho[]="Hoshino";
  int n,i;
  char *a;
 
  scanf("%d\n",&n);
  for(i=0;i<n;i++)
    {
      fgets(str,sizeof(str),stdin);
      while((a=strstr(str,ho)) != NULL)
    {
      a[6] = 'a';
    }
      printf("%s",str);
    }
  return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 1000*100;
const int INF = 1e+9;
int n;
int a[N+1];
int dp[N+1];

int main() {
  int i;
  scanf("%d ", &n);
  REP(i,n) scanf("%d ", a+i);
  fill(dp, dp+n, INF);
  REP(i,n) *lower_bound(dp, dp+n, a[i]) = a[i];
  printf("%d\n", (int)(lower_bound(dp, dp+n, INF) - dp));
  return 0;
}

Measured memory_bytes: 1972
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=3500;
int n,mod,a[N],inv[N],inv2[N],res[N];
int dp[N][N];
//
inline int add(int x,int y){x+=y;if(x>=mod)x-=mod;return x;}
inline int sub(int x,int y){x-=y;return (x<0)?x+mod:x;}
inline int mul(int x,int y){int ans=x*y;return ans%mod;}
inline int modpow(int x,int y){
	int ans=1;
	while(y){
		if(y&1)ans=mul(ans,x);
		x=mul(x,x);
		y>>=1;
	}
	return ans;
}
inline int modinv(int x){
	return modpow(x,mod-2);
}
int main(){
	n=getint();mod=n;
	rep(i,n)a[i]=getint();
	rep(i,N)inv[i]=modinv(i);
	rep(i,N)inv2[i]=modinv(sub(0,i));
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--)
	for(int j=0;j<=n-i;j++)
	{
		dp[i][j]=mul(dp[i+1][j],sub(0,i));
		if(j)dp[i][j]=add(dp[i][j],dp[i+1][j-1]);
	}
	rep(i,n)if(a[i])
	{
		int ans=1;
		rep(j,i)ans=mul(ans,inv[i-j]);
		for(int j=i+1;j<n;j++)ans=mul(ans,inv2[j-i]);
		int tmp=0;
		if(!i)tmp=dp[1][0];
		res[0]=add(res[0],mul(tmp,ans));
		for(int j=1;j<n;j++)
		{
			tmp=mul(sub(dp[0][j],tmp),inv2[i]);
			if(!i)tmp=dp[1][j];
			res[j]=add(res[j],mul(tmp,ans));
		}
	}
	rep(i,n)printf("%d ",res[i]);
	return 0;
}

Measured memory_bytes: 43392
N=int(input())
D=[]
for i in range(N):
    D.append(list(map(int,input().split())))

counter=0
for d in D:
    if d[0]==d[1]:
        counter+=1
        if counter==3:
            print("Yes")
            exit()
    else:
        counter=0
print("No")

Measured memory_bytes: 62540
#include <bits/stdc++.h>
using namespace std;
int main(){
  
 int N,A,X,Y,Z;
 cin >> N >> A;
 Y = N / 500; 
 X = N % 500; 
   
 if(X <= A){
   cout << "Yes" << endl;
   
 
 }
 else{
   cout << "No" << endl;
  
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, Q;
string S;

int main() {
    cin >> N >> S >> Q;
    vector<ll> k(Q);
    for (int i = 0; i < Q; i++) {
        cin >> k.at(i);
    }

    vector<ll> ans(Q);
    for (int q = 0; q < Q; q++) {
        ll p = 0;
        ll m = 0;
        ll c = 0;
        for (int i = 1; i < k[q]; i++) {
            if (S[i] == 'M') {
                m++;
            } else if (S[i] == 'C') {
                p += m;
                c++;
            }
        }
        ll sum = 0;
        //cout << "k i m c p" << endl;
        for (int i = 0; i < N - 2; i++) {
            //cout << k[q] << " " << i << " " << m << " " << c << " " << p << endl;
            if (S[i] == 'D') sum += p;

            if (S[i + 1] == 'M') {
                p -= c;
                m--;
            } else if (S[i + 1] == 'C') {
                c--;
            }

            if (i + k[q] < N) {
                if (S[i + k[q]] == 'M') {
                    m++;
                } else if (S[i + k[q]] == 'C') {
                    p += m;
                    c++;
                }
            }
        }
        ans[q] = sum;
    }

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

    return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();

    vvl dp(n+1, vl(m+1));  // dp[i][j] : sのi文字目までとtのj文字目までのLCSの長さ
    rep(i, n) {
        rep(j, m) {
            chmax(dp[i+1][j+1], max(dp[i+1][j], dp[i][j+1]));
            if(s[i] == t[j]) {
                chmax(dp[i+1][j+1], dp[i][j] + 1);
            }
        }
    }

    string ans = "";
    ll i = n-1, j = m-1;
    while(i >= 0 && j >= 0) {
        if(dp[i+1][j+1] == dp[i][j] + 1 && s[i] == t[j]) {
            ans = s[i] + ans;
            i--;  j--;
        }
        else if(dp[i+1][j+1] == dp[i][j+1]) {
            i--;
        }
        else if(dp[i+1][j+1] == dp[i+1][j]) {
            j--;
        }
    }
    
    out(ans);
    re0;
}


Measured memory_bytes: 74048
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool> > vec2bool;
typedef vector<vector<int> > vec2int;
typedef vector<vector<double> > vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  int n;
  cin >> n;
  vecint a(n, 0);
  REP(i, n) cin >> a[i];
  int ans = 0;
  int i = 0;
  while (i < n) {
    int tmp = 0;
    int j = i;
    while (a[j] == j + 1) {
      j++;
      tmp++;
    }
    i = j + 1;
    // cout << tmp << endl;
    ans += (tmp + 1) / 2;
  }
  cout << ans << endl;
}

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

int main() {
    int N;
    string ans = "No";
    cin >> N;
    for (int i=0;i<26;i++) {
        for (int j=0;j<15;j++) {
            if (4 * i + 7 * j == N) {
                ans = "Yes";
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int l[1000];
int r[1000];
int N;
int sum;

int main(){
	cin >> N;
  	sum = 0;
  	for(int i=0;i<N;i++){
      cin >> l[i] >> r[i];
	  sum = sum -l[i]+r[i]+1;
    }
  	cout << sum << endl;
}

Measured memory_bytes: 384
// AOJ 0270: Modular Query
// 2017.8.24 bal4u@uu
// 2019.1.19

#include <stdio.h>

char tbl[300005];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int N, Q, i, k, q, max;
	char s[13];

	N = in(), Q = in();
	tbl[0] = 1, max = 0;
	while (N--) {
		tbl[k=in()] = 1;
		if (k > max) max = k;
		tbl[k & 1] = 1, tbl[k & 3] = 1, tbl[k & 7] = 1;
	}
	sprintf(s, "%d", max);
	while (Q--) {
		q = in();
		if (q > max) puts(s);
		else {
			for (k = q-1; ; k--) {
				for (i = k; i <= max; i += q)
					if (tbl[i]) { printf("%d\n", k); goto Done; }
			}
			Done:;
		}
	}
	return 0;
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

ll euclidean_gcd(int a, int b) {
    if (a < b) return euclidean_gcd(b, a);
    ll r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}


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

    ll res = 0;
    REP(a, 1, k + 1) {
        REP(b, 1, k + 1) {
            REP(c, 1, k + 1) {
                res += euclidean_gcd(euclidean_gcd(a, b), c);
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

long long M,N,K,ans;
long long A[200002],B[200002];

int main()
{
    cin >> N>>M>>K;
    long long i,j;
    rep0(i,N) {cin>>j; A[i+1]=j+A[i];}
    rep0(i,M) {cin>>j; B[i+1]=j+B[i];}
    
    j=M;
    rep0(i,N+1) {
        if(A[i]>K) break;
        while(A[i]+B[j]>K && j>=0) --j;
        ans=max(ans,i+j);
    }

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

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

long long n, k, sum=0;

int main(){
	cin >> n >> k;
	vector<long long>a(n);
	for (int i=0;i<n;i++) cin >> a[i];
	sort(a.begin(),a.end());
	for (int i=0;i<n-k;i++) sum+=a[i];
	cout << sum << "\n";
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


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

    int ans = 0;
    rep(i, n) if(h[i] >= k) ans++;

    cout << ans << endl;

    return 0;
}



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

typedef char String[1024];

int main(void)
{
    String len;
    String bre;
    scanf("%s %s", len, bre);
    int length = atoi(len);
    int breadth = atoi(bre);
    printf("%d %d\n", (length * breadth), ((length * 2) + (breadth * 2)));
    return (0);
}


Measured memory_bytes: 1988
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007

struct Q {
	int b_id;
	int steps;
	int q_id;

	Q(int b_id, int q_id) : b_id(b_id), q_id(q_id), steps(0) {}

	bool operator<(const Q& other) const
	{
		return std::tie(b_id, q_id) < std::tie(other.b_id, other.q_id);
	}
};

int ofs[1000000];
int ans[1000000];
vector<set<Q>> qs;

void merge_into(int from, int to)
{
	if (qs[from].size() > qs[to].size())
	{
		swap(qs[from], qs[to]);
		swap(ofs[from], ofs[to]);
	}
	for (auto x : qs[from])
	{
		x.steps += ofs[from] - ofs[to];
		qs[to].insert(x);
	}
	qs[from].clear();
}

int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

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

	qs.resize(n);

	int L;
	cin >> L;

	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;

		if (a > b)
			swap(a, b);
		qs[a].insert(Q(b, i));
	}

	for (int i = 0; i < n; i++)
	{
		while (qs[i].size() > 0 && qs[i].begin()->b_id <= i)
		{
			auto f = *qs[i].begin();
			qs[i].erase(qs[i].begin());
			ans[f.q_id] = f.steps + ofs[i];
		}
		ofs[i]++;
		int to = lower_bound(x.begin(), x.end(), x[i] + L + 1) - x.begin() - 1;
		merge_into(i, to);
	}

	for (int i = 0; i < q; i++)
		cout << ans[i] << "\n";

	return 0;
}


Measured memory_bytes: 16640
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string solve(string inputStr){
    int stralllength;
    stralllength = inputStr.size()-2;
    string lengthString = to_string(stralllength);
    string answerString = inputStr[0]+lengthString+inputStr[inputStr.size()-1]; 
    return answerString;
}
int main(void){
    string s,answer;
    cin >> s;
    answer = solve(s);
    cout << answer << endl;
}


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

#[fastout]
fn main() {
    input! {
        n: usize,
        d: [usize; n]
    };

    let mut d: Vec<usize> = d;
    d.sort();

    let l = d[n / 2 - 1];
    let h = d[n / 2];

    println!("{}", h - l);
}


Measured memory_bytes: 3816
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b, n;
  cin >> a >> b >> n;
  if(n >= b-1) print((a*(b-1))/b);
  else print((a*n)/b-a*(n/b));
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif

int main()
{
	char buf[3];
	cin >> buf;
	if (buf[0] == buf[2])
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int d[n+1];
    int sum=0;
    d[0]=a[0];
    sum+=0;
    int maxval=d[0];
    for(int i=1;i<n;i++)
    {
        d[i]=a[i]-a[i-1];
        sum+=d[i];
        maxval=max(maxval,d[i]);
       
    }
    
    d[n]=k-(sum);
    
    
    maxval=max(maxval,d[n]);
    // for(int i=0;i<=n;i++)
    // cout<<d[i]<<" ";
    cout<<k-maxval<<endl;

    

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n ;
    cin >> n ;
    ll m = 100000+1 ;
    vll cnt(m,0) ;
    vll a(n) ;
    ll sum = 0 ;
    REP(i,n){
        cin >> a[i] ;
        cnt[a[i]]++ ;
        sum += a[i] ;
    }
    ll q ;
    cin >> q ;
    REP(i,q){
        ll b, c ;
        cin >> b >> c ;
        sum -= cnt[b]*b ;
        sum += cnt[b]*c ;
        cnt[c] += cnt[b] ;
        cnt[b] = 0 ;
        cout << sum <<endl;
    }


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 4808
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int N, M, p;
int ans = 1000000;
vector<int> v;

int main(void){
	cin >> N >> M >> p;
	rep(i, M){
		int a;
		cin >> a;
		//??¶??????????????¢
		a = (N+a-p)%N;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	rep(i, M){
		//?????????
		if(i == 0){
			ans = min(ans, N-v[i]);
		}else{
			ans = min(ans, 2*(N-v[i]) + v[i-1]);
		}
		//?????????
		if(i == M-1){
			ans = min(ans, v[i]);
		}else{
			ans = min(ans, 2*v[i] - (v[i+1]) + N);
		}
	}
	cout << ans*100 << endl;

	return 0;	
}

Measured memory_bytes: 1324
n = str(input())
lis = [0 for i in range(26)]
ans = 1
for i in range(len(n)):
  ans += i
  lis[ord(n[i])-ord("a")] += 1
for i in range(26):
  for k in range(lis[i]-1):
    ans -= (k+1)
print(ans)

Measured memory_bytes: 3500