akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,c,k; cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    sort(all(t));
    ll min_ = 0;
    ll cnt = 0;
    ll ans = 0;
    rep(i,n){
        if(t[min_]+k < t[i]){
            min_ = i;
            cnt = 0;
            ans++;
            // continue;
        }
        cnt++;
        if(cnt == c){
            min_ = i+1;
            cnt = 0;
            ans++;
        }
    }
    if(0 < cnt)++ans;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int a[N];
int main(int argc, char const *argv[]) {
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
  }

  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);

  for (int i = 1; i <= n; ++ i) {
    if (i >= a[i + 1]) {
      bool res = 1;
      for (int j = i+1; j <= n && a[j] == i; ++ j) {
        res ^= 1;
      }
      res &= (a[i]-i+1)&1;
      return puts(res ? "Second" : "First"), 0;
    }
  }
  return 0;
}
/*
排序，将每堆糖果看成一个 ai*1 的矩阵。

x
x x
x x x
-----
3 2 1

每次操作相当于删除最下面一行或者删除最左边一列。

可以发现 (x, y) = (x - 1, y - 1)

于是开局直接往右上角走，有三种情况。
(0-first,1-second)

1)

xxx 1
xxx 0
xx/ 1
x/x 0
/xx 1
  i

ans = !odd(a[i]-i)

2)

010101

xx/xxx
x/xxxx
/xxxxx
  i  j

ans = !odd(j-i)

3)

xxx
xxx
xx/xxx
x/xxxx
/xxxxx
  i  j

ans = !odd(a[i]-i) && !odd(a[i]-i)

*/

Measured memory_bytes: 640
#include <stdio.h>

#define N 200000

int main(){

  int num, i, min, max;
  int n[N];

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


  min = n[0];
  max = n[1]-n[0];
  for(i=1; i<num; i++){
    if(max < n[i]-min) max = n[i]-min;
    if(min > n[i]) min = n[i];
  }

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

  return 0;
}

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

using namespace std;
string orign;
vector<string> ans;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,n) for(int i = a; i < n; i++)
bool zflag = false;
void decode(int idx, string s, vector<bool> alph){
  //cout << s << endl;
  //cout << s << endl;
  // bから戻ってきたaかもともとaなのか区別がつかないので探索
  if(idx == orign.size()){
    ans.push_back(s);
    return;
  }

  if(orign[idx] == 'z'){
    if(alph['z' - 'a'] == false) return;
    else decode(idx+1, s + (char)(orign[idx]), alph);
  }
  else if(orign[idx] != 'a' && alph[ orign[idx] - 'a' + 1] == true && alph[ orign[idx] - 'a'] == false){
    return;
  }
  // もう出ている場合
  else if(orign[idx] == 'a' || alph[ orign[idx] - 'a']){
    // cout << "2 " << endl;
    // 元々 その文字
    decode(idx+1, s + orign[idx], alph);

    if(alph[ orign[idx] - 'a' + 1] == false){
      alph[orign[idx] - 'a' + 1] = true;
      decode(idx+1, s + (char)(orign[idx] + 1), alph);
    }
  }
  // まだ出ていない場合
  else {
    alph[orign[idx] - 'a' + 1] = true;
    decode(idx+1, s + (char)(orign[idx]+1), alph);
  }
}

void solve(){
  vector<bool> alph(26,false);
  decode(0,"",alph);
  sort(ans.begin(), ans.end());
  if(ans.size() <= 10){
    cout << ans.size() << endl;
    rep(i,ans.size()) cout << ans[i] << endl;
  }else{
    cout << ans.size() << endl;
    rep(i,5) cout << ans[i] << endl;
    FOR(i,ans.size()-5, ans.size()) cout << ans[i] << endl;
  }
  ans.clear();
}

int main(){
  string s;
  while(true){
    cin >> orign;
    if(orign == "#") break;
    solve();
  }
}



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

bool ATGC(int A,string B){
    if(B[A]=='A'||B[A]=='G'||B[A]=='C'||B[A]=='T'){
        return true;
    }
    return false;
    }

    int main()
    {
        string S;
        cin >> S;
        int len,ans=0;
        len = S.size();
        for (int i = 1; i <= len; i++)
        {
            for (int j = 0; j < len-i+1; j++)
            {
                int l = 0;
                for (int k = j; k < j + i ; k++)
                {
                    if(ATGC(k,S)){
                        l++;
                    }else{
                        break;
                    }

                }
                ans = max(ans, l);
            }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cctype>

#define rep(a,b) for(register int i=a;i<=b;i++)
#define red(a,b) for(register int i=a;i>=b;i--)
#define ULL unsigned long long
#define LL long long

using namespace std;
string s,t;
set<int>x[26],y[26];
int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
		x[s[i]-'a'].insert(t[i]-'a'),
		y[t[i]-'a'].insert(s[i]-'a');
	for(int i=0;i<26;i++)
		if(x[i].size()>1||y[i].size()>1)
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
}

Measured memory_bytes: 776
import Control.Monad
import Control.Applicative
import Data.Char
import Data.List

solve :: String -> String
solve s =
    let chunk = group $ sort [toLower c | c<-s, isAlpha c] in
    let sets = [(c,length s) | s@(c:_)<-chunk] in
    unlines $ map (showchr sets) ['a'..'z']
    where
    showchr :: [(Char,Int)] -> Char -> String
    showchr sets c =
        let n = maybe 0 id (lookup c sets) :: Int in
        [c] ++ " : " ++ (show n)

main =
    putStr =<< solve <$> getContents



Measured memory_bytes: 3936
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
vector< int > d;
bool dfs(vector< vector< int > > &G, int x) {
	rep(i, G[x].size()) {
		int j = G[x][i];
		int n = 1 - d[x];
		if (d[j] == n)
			continue;
		if (d[j] == -1)
			d[j] = n;
		if (n != d[j])
			return false;
		if (!dfs(G, j))
			return false;
	}
	return true;
}
signed main() {
	cin >> N >> M;
	vector< vector< int > > G(N);
	d.assign(N, -1);
	rep(i, M) {
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	d[0] = 0;
	bool f = dfs(G, 0);
	int ans;
	if (!f) {
		ans = N * (N - 1) / 2 - M;
	} else {
		int one = 0;
		rep(i, N) if (d[i])++ one;
		ans = one * (N - one) - M;
	}
	//cout << d;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7424
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String p = sc.nextLine();
        String x = s + s;
        boolean b = false;
        for(int ix = 0; ix < s.length(); ix++) {
            for(int ip =0; ip < p.length(); ip++) {
            	b = (x.charAt(ix+ip) == p.charAt(ip));
                if(b == false)
                    break;
            }
            if (b == true)
                break;
        }
        if(b)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<long> v(N+1);
  v[0]=2;
  v[1]=1;
  if(N>1){
    for(int i=2;i<N+1;i++){
      v.at(i)+=v[i-1];
      v.at(i)+=v[i-2];
    }
  }
  cout << v[N] << endl;
}


Measured memory_bytes: 256
from collections import deque
H,W = map(int,input().split())
grid = [0] * H
for i in range(H):
    grid[i] = input()

ans = 0

done = [[0]*W for _ in range(H)]
for sy in range(H):
    for sx in range(W):
        if done[sy][sx]:
            continue
        # 初期状態
        q = deque()
        q.append([sy,sx])
        done[sy][sx] = 1
        n_white = 0
        n_black = 0
        if grid[sy][sx] == '.':
            n_white += 1
        else:
            n_black += 1

        while q:
            y,x = q.popleft()
            for new_y, new_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
                if 0<= new_y < H and 0<= new_x < W and not done[new_y][new_x]:
                    if grid[y][x] != grid[new_y][new_x]:
                        # 色ごとの数更新
                        if grid[new_y][new_x] == '.':
                            n_white += 1
                        else:
                            n_black += 1
                        
                        done[new_y][new_x] = 1
                        q.append([new_y,new_x])
        ans += n_black*n_white
print(ans)

Measured memory_bytes: 77580
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define F first
#define re return
#define S second
#define ll long long
#define f(i) return cout<<i<<"\n",0;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define lp(i,a,b) for (int i=(a);i<=(int)(b);++i)
#define lp2(i,a,b) for (int i=(a);i>=(b);--i)
#define clr(c,x) memset(c,x,sizeof(c))
#define allr(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
const int N=2e5+5,mod=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int k,sum=0;
    cin>>k;
    for (int i=2;i<=k;i+=2)
    {
        for (int j=1;j<=k;j+=2)
        {
            sum++;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e4+10;
const int INF=0x3f3f3f3f;
int dp[N];
int main()
{
    int h,n; scanf("%d%d",&h,&n);
    memset(dp,INF,sizeof dp);
    dp[0]=0;
    for(int i=0;i<n;i++){
        int x,y; scanf("%d%d",&x,&y);
        for(int j=0;j+x<N;j++)
            dp[j+x]=min(dp[j+x],dp[j]+y);
    }
    int res=dp[h];
    for(int i=h;i<N;i++)
        res=min(res,dp[i]);
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cassert>
#include <tuple>
#include <algorithm>
using namespace std;

const int inf = 2e9 + 42;

const int N = 100500;
int A[N];

bool stup(vector<int> X) {
    if (X.empty())
        return true;
    auto Y = X;
    Y.erase(Y.begin());
    bool vy = stup(Y);
    auto Z = X;
    for (int& v : Z)
        --v;
    while (!Z.empty() && Z.back() == 0)
        Z.pop_back();
    bool vz = stup(Z);
    return !vy || !vz;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    sort(A, A + n);
    reverse(A, A + n);
    vector<pair<int, int>> pts;
    for (int i = 0; i < n; i++) {
        if (A[i] > A[i + 1])
            pts.emplace_back(i + 1, A[i]);
    }
    assert(!pts.empty());
    vector<int> divs;
    for (int i = 0; i + 1 < pts.size(); i++) {
        int x1, y1;
        int x2, y2;
        tie(x1, y1) = pts[i];
        tie(x2, y2) = pts[i + 1];
        assert(y1 > y2 && x2 > x1);
        if ((y1 - y2) % 2 == (x2 - x1) % 2)
            continue;
        if ((y1 - y2) % 2 == 0) {
            divs.push_back(2 * y2 + 1 - 2 * x1);
        } else {
            divs.push_back(2 * y2 - 1 - 2 * x1);
        }
    }
    bool win;
    if (divs.empty()) {
        win = (pts.back().first + pts.back().second) % 2;
    } else {
        bool wasl = false, wasr = false;
        int l = inf, r = -inf;
        for (int x : divs) {
            if (x > 0)
                wasl = true, l = min(l, x);
            else if (x < 0)
                wasr = true, r = max(r, x);
            else
                assert(false);
        }
        if (wasl) {
            win = (l / 2) % 2 == 0;
        } else {
            assert(wasr);
            win = ((-r) / 2) % 2 == 0;
        }
    }

    //bool stans = stup(vector<int>(A, A + n));
    //assert(stans == win);
    puts(win ? "First" : "Second");
}


Measured memory_bytes: 1784
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan =new Scanner(System.in);
		int N=scan.nextInt();
		int sum=N/1000;
		if(N%1000==0) {
			System.out.println(0);
		}else  {
			sum+=1;
			int goukei=(1000*sum)-N;
			System.out.println(goukei);
		}
	}

}


Measured memory_bytes: 35588
#include <iostream>
#include <cstdio>
using namespace std;
//@date: 2020-02-16 20:15:33
//@state:
//@purpose:

int f[10];

int main()
{
    int t,mx=-999;
    for(int i=0;i<3;i++){
        cin>>t;
        f[t]++;
        if(f[t]>mx)mx=f[t];
    }
    if(mx==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    long n, m;
    scan(n, m);
    auto graph = new long[][](n, 0);
    foreach (_; iota(m))
    {
        long a, b;
        scan(a, b);
        a--, b--;
        graph[a] ~= b;
        graph[b] ~= a;
    }
    auto visit = new bool[](n);
    visit[0] = true;
    dfs(graph, 0, visit);
    cnt.writeln();
}

void dfs(T)(T g, long current, bool[] visit)
{
    // current.writeln();
    foreach (e; g[current])
    {
        if (!visit[e])
        {
            visit[e] = true;
            dfs(g, e, visit);
            visit[e] = false;
        }
    }
    if (visit.all_true())
        cnt++;
}

bool all_true(bool[] a)
{
    bool ret = true;
    foreach (e; a)
        ret &= e;
    return ret;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	#define LOCAL_INPUT_FILE
#else
	//~ #define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

struct Store {
	int64_t a, b;
};

inline bool operator<(const Store &a, const Store &b) {
	return a.b * b.a < a.a * b.b;
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int n, t; cin >> n >> t;
	if (t == 0) {
		cout << 0 << endl;
		return 0;
	}
	++t;
	vector<Store> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].a >> v[i].b; ++v[i].b;
	}
	sort(begin(v), end(v));
	
	vector<int64_t> dp(n+1, LLONG_MAX);
	dp[0] = 1;
	int bound = n;
	for (int i = 0; i < n; ++i) {
		if (v[i].a == 0) {
			bound = i;
			break;
		}
		for (int j = min(40, i+1); j > 0; --j) {
			if (dp[j-1] > t) continue;
			dp[j] = min(dp[j], dp[j-1] * (v[i].a + 1) + v[i].b);
			if (dp[j] > t) dp[j] = LLONG_MAX;
		}
	}
	
	vector<int64_t> x;
	for (int i = bound; i < n; ++i) {
		x.push_back(v[i].b);
	}
	sort(begin(x), end(x));
	
	for (int i = 1; i < (int)x.size(); ++i) {
		x[i] += x[i-1];
	}
	
	int ans = 0;
	for (int i = 0; i < (int)dp.size(); ++i) {
		if (dp[i] > t) continue;
		int64_t add = t - dp[i];
		int pp = upper_bound(begin(x), end(x), add) - begin(x);
		ans = max(ans, i+pp);
	}
	cout << ans << endl;
	
	return 0;
} 


Measured memory_bytes: 7156
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
i = a.max
j = a.bsearch_index{|x| x >= i/2}
if j == 0
  j = a[0]
elsif i % 2 == 0
  if a[j] - i/2 < i/2 - a[j-1]
    j = a[j]
  else
    j = a[j-1]
  end
elsif i % 2 == 1
  if a[j] - i/2 - 1 < i/2 - a[j-1]
    j = a[j]
  else
    j = a[j-1]
  end
end

puts "#{i} #{j}"

Measured memory_bytes: 23144
#include <stdio.h>
#include <string.h>

char out[4] = "OUT";
char homerun[8] = "HOMERUN";
char hit[4] = "HIT";

int main(void)
{
    char input[8];
    int point, ining, outcount, b1, b2, b3;
    for (scanf("%d", &ining); ining > 0; ining--) {
        outcount = 0;
        point = 0;
        b1 = b2 = b3 = 0;
        while (outcount != 3) {
            scanf("%s", input);
            if (!strcmp(input, out)) {
                outcount++;
            } else if (!strcmp(input, homerun)) {
                point += b1 + b2 + b3 + 1;
                b1 = b2 = b3 = 0;
            } else if (!strcmp(input, hit)) {
                if (b1) {
                    if (b2) {
                        if (b3) {
                            point++;
                        } else {
                            b3 = 1;
                        }
                    } else {
                        b2 = 1;
                    }
                } else {
                    b1 = 1;
                }
            }
        }
        printf("%d\n", point);
    }
    return 0;
}


    

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

int yakusimaruhiroko(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, M;
int X[114514];

int yosinagasayuri[114514];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &X[i]) != 1) return 1;
	}
	if (N >= M) {
		puts("0");
	} else {
		int horieyui = 0;
		qsort(X, M, sizeof(*X), yakusimaruhiroko);
		for (i = 1; i < M; i++) {
			yosinagasayuri[i - 1] = X[i] - X[i - 1];
		}
		qsort(yosinagasayuri, M - 1, sizeof(*yosinagasayuri), yakusimaruhiroko);
		for (i = 0; i < M - N; i++) {
			horieyui += yosinagasayuri[i];
		}
		printf("%d\n", horieyui);
	}
	return 0;
}


Measured memory_bytes: 1396
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


ll chmin(ll &a, ll b) {
	return a = min(a, b);
}

int main() {
	string s; cin >> s;
	reverse(s.begin(), s.end());
	int n = s.size();
	vector<vector<ll>> dp(n + 2, vector<ll>(2, 1e18));
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		ll d = s[i] - '0';
		chmin(dp[i + 1][0], dp[i][0] + d);
		chmin(dp[i + 1][0], dp[i][1] + d + 1);
		chmin(dp[i + 1][1], dp[i][0] + 10 - d);
		chmin(dp[i + 1][1], dp[i][1] + 9 - d);
	}
	cout << min(dp[n][0], dp[n][1] + 1) << endl;
	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1e9+7;
ll dp[1001][1001],n,m;
string st[1001];
ll solve(ll i,ll j)
{
	if(i == n-1 && j == m-1)
		return 1;
	if(i>=n || j>=m)
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	ll ans=0;
	if(j+1<m && st[i][j+1] == '.')
		ans=solve(i,j+1);
	if(i+1<n && st[i+1][j] == '.')
		ans=(ans+solve(i+1,j)+mod)%mod;
	return dp[i][j]=ans;
}
int main()
{
	cin>>n>>m;
	for(ll i=0;i<n;i++)
	{
		cin>>st[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
vector<int> g[200005];
vector<int> l,r;
int n;
int ans[200005];
void dfs(int v,int lst,int co){
    if(co) l.pb(v);
    else r.pb(v);
    for(int i=0;i<g[v].size();i++)
        if(g[v][i]!=lst)
            dfs(g[v][i],v,co^1);
}
int main(){
    scanf("%d",&n);
    int on=n/3+(n%3!=0),tw=n/3+(n%3==2),th=n/3;
    for(int i=1;i<=n-1;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1,-1,0);
    if(l.size()>r.size()) swap(l,r);
    if(l.size()<=n/3){
        int non=0,ntw=0,nth=0;
        for(int i=0;i<l.size();i++)
            ans[l[i]]=nth*3+3,nth++;
        int i=0;
        while(nth!=th) ans[r[i]]=nth*3+3,nth++,i++;
        while(ntw!=tw) ans[r[i]]=ntw*3+2,ntw++,i++;
        while(non!=on) ans[r[i]]=non*3+1,non++,i++; 
    }
    else{
        int non=0,ntw=0,nth=0;
        int i=0,j=0;
        while(non!=on) ans[l[i]]=non*3+1,non++,i++;
        while(ntw!=tw) ans[r[j]]=ntw*3+2,ntw++,j++;
        while(nth!=th && i<l.size()) ans[l[i]]=nth*3+3,nth++,i++;
        while(nth!=th) ans[r[j]]=nth*3+3,nth++,j++;
    }
    for(int i=1;i<=n;i++)
        printf("%d ",ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 19188
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let mut sum = 0;
    for i in 1..n {
        sum += i;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <stdio.h>

#define N 500000

void Merge(int,int,int);
void Merge_Sort(int,int);

int S[N],c=0;
main(){
  int i,n;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  Merge_Sort(0,n);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n%d\n",c);
  return 0;
}

void Merge(int left,int mid,int right){
  int n1=mid-left,n2=right-mid,i,j,k;
  int L[n1],R[n2];

  for(i=0;i<n1;i++){
    L[i]=S[left+i];
  }

  for(i=0;i<n2;i++){
    R[i]=S[mid+i];
  }

  L[n1] = 1000000001;
  R[n2] = 1000000001;

  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      S[k]=L[i];
      i++;
    }
    else{
      S[k]=R[j];
      j++;
    }
    c++;
  }
}

void Merge_Sort(int left,int right){
  int mid;
  if (left+1<right){
    mid = (left + right)/2;
    Merge_Sort(left,mid);
    Merge_Sort(mid,right);
    Merge(left,mid,right);
  }
}

Measured memory_bytes: 4508
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int parent[200100],n,m,sum,cnt[200100];
//parent数组存储的是每个强盗的父亲即boss、sum用来记录犯罪团伙的数量
void Init() //初始化
{
    for(int i = 1;i <= n;i++)
        parent[i] = i;
    return;
}

int get_boss(int v)
{
    if(parent[v] == v)
        return v;
    else
    {
        //路径压缩(使搜索祖宗的过程中，路径中搜索的结点的父亲的变为祖宗)
        parent[v] = get_boss(parent[v]);
        return parent[v];
    }
}

void Merge(int v,int u)
{
    int t1 = get_boss(v);
    int t2 = get_boss(u);
    parent[t2] = t1;
    return;
}

int main()
{
    cin >> n >> m;
    Init();
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin >> u >> v;
        Merge(u,v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int k=get_boss(i);
        //cout << k << " ";
        cnt[k]++;
        ans = max(cnt[k],ans);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int main() {
    long long n, b;
    cin >> n;
    b = n-1;
    for(long long i=2;i*i<=n;i++) if(n%i == 0) b = min(b,i+n/i-2);
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main( String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if( a < b ) {
            System.out.println("a < b");
        }else if( a > b ){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26304
#include<bits/stdc++.h>
#include <string>
using namespace std;
int main() {
    int N,K; cin>>N>>K;
    string S; cin>>S;

    if(S[K-1]=='A'){
        S[K-1]='a';
    }
    else if(S[K-1]=='B'){
        S[K-1]='b';
    }
    else{
        S[K-1]='c';
    }
    cout<<S<<endl;

    return 0;
}

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

std::vector<int> P(10000);

int main() {
    int m, nmin, nmax;
    int i;
    while(std::cin >> m >> nmin >> nmax) {
        if(m == 0 && nmin == 0 && nmax == 0) break;
        for(i=0; i<m; ++i) {
            std::cin >> P[i];
        }
        std::sort(P.begin(), P.begin()+i, std::greater<int>());

        int max = 0;
        int maxN = 0;
        for(i=nmax; i>=nmin; --i) {
            int gap = P[i-1] - P[i];
            if(gap > max) {
                max = gap;
                maxN = i;
            }
        }
        std::cout << maxN << std::endl;
    }
}


Measured memory_bytes: 3124
#include <iostream>

using namespace std;
int Fibonacci(int n)
{
    int dp[n];
    for(int i=0;i<=n;i++)
    {
        if(i==0||i==1) dp[i]=1;
        else dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[n];
}
int main()
{
    int n;
    while(cin>>n)
        cout<<Fibonacci(n)<<endl;
}

Measured memory_bytes: 3120
# -*- coding: utf-8 -*-
import sys

N = int(input())
next_max_num = 0
max_num = 0
max_idx = 0
for i in range(N):
    this_num = int(input())
    if max_num < this_num:
        next_max_num = max_num
        max_num = this_num
        max_idx = i
    elif max_num == this_num:
        next_max_num = max_num
        max_idx = -1
    elif next_max_num < this_num:
        next_max_num = this_num

if max_idx == -1:
    for i in range(N):
        print(max_num)
else:
    for i in range(N):
        if i == max_idx:
            print(next_max_num)
        else:
            print(max_num)

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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  ll n;
  while(cin >> n) {
    if(n == 0) return 0;

    ll p[n], j[n - 1], na = 0, h = n;
    rep(i, 0, n) cin >> p[i], na += p[i];
    rep(i, 0, n - 1) cin >> j[i];

    sort(j, j + n - 1);
    ll ma = 0;
    rep(i, 1, n) {
      ma = max(ma, na * h);
      na += j[n - (i + 1)];
      h--;
    }

    ma = max(ma, na * h);
    cout << ma << endl;
  }
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,a,b,c,d,tmp[ohara],tmpp,m,h,w,x,y,sum,pos,k,dp[3005][3005];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t,ans;
bool fl;
struct edge{int to,cost;};
map<ll,ll> cous;
map<ll,ll> couut;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s>>t;
    rep(i,Size(s)){
        rep(j,Size(t)){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else{
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    rrrep(i,Size(s),0){
        rrrep(j,Size(t),0){
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
            cnt=max(cnt,dp[i][j]);
        }
    }
    tmp[0]=Size(s)+1;
    tmp[1]=Size(t)+1;
    rrrep(i,Size(s),0){
        rrrep(j,Size(t),0){
            if(cnt==dp[i][j]){
                if(s[i-1]==t[j-1]&&i<tmp[0]&&j<tmp[1])ans+=t[j-1],cnt--,tmp[0]=i,tmp[1]=j;
                if(cnt==0)break;
            }
            if(cnt==0)break;
        }
        if(cnt==0)break;
    }
    reverse(all(ans));
    Cout(ans);
    return 0;
}


Measured memory_bytes: 71936
#include<iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int x = b - a;
	int y = c - b;

	if (x == y){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* AtCoder コピペ */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repEq(i, n) for (int i = 0; i <= (int)(n); i++)
#define repVector(i, v) for (auto i = v.begin(); i != v.end(); ++i)

#define ifBetween(n, a, b) if (n > a && n < b)
#define ifBetweenEq(n, a, b) if (n >= a && n <= b)

int main() {
	int x[3];
  
  	rep(i, 3) {
    	cin >> x[i];
    }
 
  	std::vector<int> vec(x, x + sizeof x / sizeof x[0]);
    sort(vec.begin(), vec.end(), greater<>());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

  	cout << vec.size() << endl;
}


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

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
int C[10001];

int main(){
	int n,a;
	cin >> n;
	REP(i,n){
		cin >> a;
		C[a]++;
	}
	int k=0;
	while(!C[k])k++;
	cout << k;C[k]--;
	for(int i=k;i<10001;i++){
		while(C[i]--)cout << " " << i ;
	}
	cout << endl;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, u, v, w;
    cin >> n;
    unordered_map<int, vector<pair<int, int>>> e;
    vector<int> ans(n+1, -1);
    for(int i = 0; i < n-1; i++) {
        cin >> u >> v >> w;
        e[u].push_back({v, w});
        e[v].push_back({u, w});
    }
    vector<int> dq = {1};
    ans[1] = 0;
    while (!dq.empty()) {
        vector<int> new_dq;
        for(int node: dq) {
            for(auto p: e[node]) {
                if (ans[p.first] == -1) {
                    if (p.second % 2 == 0)
                        ans[p.first] = ans[node];
                    else
                        ans[p.first] = 1 - ans[node];
                    new_dq.push_back(p.first);
                }
            }
        }
        dq.swap(new_dq);
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;

    return 0;
}




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

int main() {
	int N, M;
  	int total = 0;
  	cin >> N >> M;
  	vector<int> data(M);
  	for(int i=0; i<M; i++){
      cin >> data.at(i);
      total += data.at(i);
    }
  	if((N-total)<0){
    	cout << -1 << endl;
    }
  	else{
      	cout << N-total << endl;
    }
}


Measured memory_bytes: 3640
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
// clang-format off
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {
  REP(i, v.size()) print(v[i]);
}
template <typename T> inline void print(const vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) cout << s;
    cout << v[i];
  }
  cout << '\n';
}
// clang-format on
/* }}} */

struct State {
  int parts[3];
  bool res;
  void input() {
    REP(i, 3) parts[i] = in();
    cin >> res;
  }
  bool operator<(const State& rhs) const {
    return res > rhs.res;
  }
};

signed main() {
  for (int a, b, c; cin >> a >> b >> c, a || b || c; ) {
    int n = in();
    bool ok[301] = {}, ng[301] = {};
    vector<State> state(n);

    REP(i, n) state[i].input();
    sort(ALL(state));
    REP(i, n) {
      if (state[i].res) {
        REP(j, 3) ok[state[i].parts[j]] = true;
      } else {
        int cnt = 0, idx;
        REP(j, 3) {
          if (!ok[state[i].parts[j]]) {
            ++cnt;
            idx = state[i].parts[j];
          }
        }
        if (cnt == 1) {
          ng[idx] = true;
        }
      }
    }
    RREP(i, a + b + c) {
      print(ok[i] ? 1 : ng[i] ? 0 : 2);
    }
  }

  return 0;
}

Measured memory_bytes: 3172
#include<stdio.h>

#define MAX 500
static const int INFTY = (1<<21);
 
int main(){
  int n, i, j, e, sum,k,a,v1;
  int key,p[MAX],v[MAX],u,c[MAX],m[MAX][MAX];
   
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      m[i][j] = INFTY;
    }
  }
   
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v1, &a);
      m[u][v1] = a;
    }
  }
  for(i=0;i<n;i++){
    c[i]=INFTY;
    p[i]=-1;
    v[i]=0;
  }
  c[0]=0;
 
  while(1){
    key=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(key>c[i] && !v[i]){
    u=i;
    key=c[i];
      }
    }
    if(u==-1)break;
    v[u]=1;
    for(j=0;j<n;j++){
      if(m[u][j]+c[u]<c[j] && !v[j]){
    p[j]=u;
    c[j]=c[u]+m[u][j];
      }
    }
  }
   
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (c[i]==INFTY?-1:c[i]));
  }
   
  return 0;
}

Measured memory_bytes: 2780
X, K, D = map(int, input().split())
if X + K * D <= 0:
    print(-X - K * D)
elif X - K * D >= 0:
    print(X - K * D)
else:
    div = abs(X) // D
    if (K-div) % 2 == 0:
        print(abs(X) - D * div)
    else:
        print(abs(abs(X) - D * (div + 1)))


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>
#define vc vector
#define a first
#define b second
#define pb pusu_back

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  int N = 100001;
  vc<bool> pr(N, true);
  pr[0] = pr[1] = false;
  rep(n, 2, N){
    if(pr[n]){
      int k = 2 * n;
      while(k < N){
        pr[k] = false;
        k += n;
      }
    }
  }
  vc<int> cum(N, 0);
  rep(n, 1, N){
    cum[n] = cum[n - 1];
    if(n % 2 && pr[n] && pr[(n + 1) / 2]) cum[n]++;
  }
  int Q; cin >> Q;
  rep(i, 0, Q){
    int l, r; cin >> l >> r;
    cout << cum[r] - cum[l - 1] << endl;
  }
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8832
fn main() {
    let v: Vec<u32> = read_vec();
    if v[0] < v[1] {
        println!("0");
    } else {
        println!("10");
    }
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;

map<ll, ll> getPrimeFactors(int n) {
  map<ll, ll> p;

  if (n == 0) return p;

  p[1] = 1;

  int num = n;
  for (int i = 2; i * i <= n; i++) {
    while (num % i == 0) {
      num /= i;
      p[i]++;
    }

    if (num == 1) break;
  }

  if (num != 1) p[num]++;

  return p;
}

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

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

  map<ll, ll> lcmP;
  for (int k = 0; k < n; k++) {
    map<ll, ll> primes = getPrimeFactors(a[k]);

    for (auto p : primes) {
      lcmP[p.first] = max(lcmP[p.first], p.second);
    }
  }

  ll lcmNum = 1;
  for (auto lp : lcmP) {
    lcmNum *= modpow(lp.first, lp.second, MOD);
    lcmNum %= MOD;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += lcmNum * modpow(a[i], MOD - 2, MOD) % MOD;
    ans %= MOD; 
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>

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

using namespace std;

typedef long long ll;

int a, b, p;
bool x[16][16][2];
ll dp[16][16];

int main(){
	int z;
	scanf("%d", &z);
	rep(k, z){
		scanf("%d%d%d", &a, &b, &p);
		rep(i, p){
			int s, t, u, v;
			scanf("%d%d%d%d", &s, &t, &u, &v);
			if(s > u){
				swap(s, u);
			}
			if(t > v){
				swap(t, v);
			}
			x[u][v][s == u] = true;
		}

		dp[0][0] = 1;
		rep(i, b){
			dp[0][i + 1] = dp[0][i] * !x[0][i + 1][1];
		}
		rep(i, a){
			dp[i + 1][0] = dp[i][0] * !x[i + 1][0][0];
		}
		rep(i, a){
			rep(j, b){
				dp[i + 1][j + 1] = dp[i][j + 1] * !x[i + 1][j + 1][0] + dp[i+ 1][j] * !x[i + 1][j + 1][1];
			}
		}

		/*rep(i, a + 1){
			rep(j, b + 1){
				printf("[%d %d] ", int(x[i][j][0]), int(x[i][j][1]));
			}
			printf("\n");
		}

		printf("\n");
		rep(i, a + 1){
			rep(j, b + 1){
				printf("%lld ", dp[i][j]);
			}
			printf("\n");
		}*/

		if(dp[a][b] == 0){
			puts("Miserable Hokusai!");
		}
		else{
			printf("%lld\n", dp[a][b]);
		}

		rep(i, a + 1){
			rep(j, b + 1){
				x[i][j][0] = x[i][j][1] = false;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1040
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();

    let mut v: Vec<char> = s.chars().collect();
    v.sort();
    v.dedup();

    let mut alphabet = String::from("abcdefghijklmnopqrstuvwxyz");

    for i in alphabet.chars() {
        if let None = s.find(i) {
            println!("{}", i);
            return;
        } 
    }

    println!("None");
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
    // Your code here!
   char str[100001];
   int cnt = 1;
   char next;
   
   scanf("%100000s",str);
   
   next = str[0];
   for(int i = 1;str[i] !='\0';i++){
       if(next != str[i]){
           cnt++;
           next = str[i];
       }
   }
   
   printf("%d\n",cnt-1);

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var NL = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();
        var N = NL[0];
        var L = NL[1];
        var ans = 0;
        if (0 <= L)
        {
            for(int i=2;i<=N;++i){
                ans += (L+i-1);
            }
        }
        else
        {
            var num = Math.Abs(L)+1;
            if (num <= N)
            {
                for (int i=1;i<=N;++i)
                {
                    ans+= (L + i - 1);
                }
            }
            else
            {
                for (int i=1;i<N;++i)
                {
                    ans += (L + i - 1);
                }
            }
        }
        Console.WriteLine(ans);
    }
}



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

int main(){
    int n,c,r;
    while(1){
        cin>>n;
        if(n==0) break;
        c=r=0;
        for(int i=1;i<n;i++){
            r+=i;
            if(n-r<=0) break;
            if((n-r)%(i+1)==0) c++;
        }
        cout<<c<<endl;
    }
    return 0;
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll Q;
ll ret = 0;

struct Event {
  ll t, type, X;
  bool operator<(const Event& a) {
    return t < a.t;
  }
};

vector<Event> eves;
multiset<ll> ms;

int main(void){
  
  I(N);
  I(Q);
  ll S, T, X;
  REP(i, N) {
    I(S);
    I(T);
    I(X);
    Event a = {S-X, 1, X};
    Event b = {T-X, -1, X};
    eves.pb(a);
    eves.pb(b);
  }
  sort(ALL(eves));

  ll d;
  ll k = 0;
  REP(i, Q) {
    I(d);
    while (k < eves.size() && eves[k].t <= d) {
      Event e = eves[k];
      if (e.type == 1) {
        ms.insert(e.X);
      } else {
        ms.erase(ms.find(e.X));
      }
      k++;
    }

    if (ms.empty()) {
      P(-1);
    } else {
      P(*ms.begin());
    }
    
  }
}


Measured memory_bytes: 21224