akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define int long long
string s;
int n, pref[500005], suff[500005], power[500005], used[30], reach1[500005], reach[500005], mx[500005], mx1[500005];
const int mod = 1e9 + 7;
vector<int> d[500005];
int hs(int x, int y, int type){
    return ((pref[y] - (pref[x] * power[y - x] * 1ll) % mod) % mod + mod) % mod;
}
signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> s;
    n = s.length();
    s = "+" + s;
    power[0] = 1;
    for(int i = 1; i <= 500000; i++){
        for(int j = 2; j <= 500000 / i; j++)
            d[i * j].pb(i);
    }
    for(int i = 1; i <= n; i++)
        power[i] = (1ll * power[i - 1] * 30) % mod;
    for(int i = 1; i <= n; i++)
        pref[i] = ((1ll * pref[i - 1] * 30) % mod + s[i] - 'a' + 1) % mod;
    int ck = 0;
    for(int i = 1; i <= n / 2; i++){
        long long val = hs(0, i, 1);
        for(int l = i; l + i <= n; l += i){
            if(hs(l, l + i, 1) == val)
                reach[i] = l + i;
            else
                break;
        }
        mx[i] = max(mx[i - 1], reach[i]);
    }
    for(int i = 1; i <= n / 2; i++){
        long long val = hs(n - i, n, 1);
        reach1[i] = n + 1;
        for(int l = n - i; l - i >= 0; l -= i){
            if(hs(l - i, l, 1) == val)
                reach1[i] = l - i + 1;
            else
                break;
        }
    }
    if(mx[n / 2] < n)
        cout << "1\n1\n";
    else{
        int ans = 0, sum = 0;
        for(int i = 1; i <= n; i++)
            used[s[i] - 'a']++;
        for(int i = 0; i <= 25; i++){
            if(used[i] > 0)
                sum++;
        }
        if(sum == 1){
            cout << n << "\n" << 1 << "\n";
            return 0;
        }
        for(int i = 1; i <= n; i++){
            int len = n - i, ck = 0;
            if(i >= 2){
                for(int j = 0; j < d[i].size(); j++){
                    if(reach[d[i][j]] >= i)
                        ck = 1;
                }
            }
            if(len >= 2){
                for(int j = 0; j < d[len].size(); j++){
                    if(reach1[d[len][j]] <= i + 1)
                        ck = 1;
                }
            }
            if(ck == 0)
            ans++;
        }
    cout << "2\n";
    cout << ans << "\n";
    }
}


Measured memory_bytes: 110772
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int n, q;
  std::vector<int> s, t;

  std::cin >> n;
  s.resize(n);
  for (int i = 0; i < n; ++i) std::cin >> s[i];
  std::cin >> q;
  t.resize(q);
  for (int i = 0; i < q; ++i) std::cin >> t[i];

  int res = 0;
  for (auto&& num : t) {
    if (std::binary_search(begin(s), end(s), num)) {
      res++;
    }
  }

  std::cout << res << std::endl;
}

Measured memory_bytes: 3272
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << 1.0 * (a + b) * h / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
	long double a, b, c, d, e, f, x, y;
	while (cin >> a >> b >> c >> d >> e >> f) {
		x = (long double)(b*f - e * c) / (d*b - a * e);
		y = (long double)(a*f - d * c) / (a*e - d * b);
		if (x < 0)
			x = (long double)((int)(x * 1000 - 0.5)) / 1000;
		else
			x = (long double)((int)(x * 1000 + 0.5)) / 1000;
		if (y < 0)
			y = (long double)((int)(y * 1000 - 0.5)) / 1000;
		else
			y = (long double)((int)(y * 1000 + 0.5)) / 1000;
		printf("%.3llf %.3llf\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <set>

using namespace std;

int main (){
  int q,t,x,y;
  set<int> a;

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> t;
    cin >> x;
    if (t==0){
      a.insert(x);
      cout << a.size() << endl;
    }else if(t==1){
      cout << a.count(x) << endl;
    }else if(t==2){
      a.erase(x);
    }else{
      cin >> y;
      auto it = a.lower_bound(x);
      auto last = a.upper_bound(y);

      while (it != last) {
        cout << *it << endl;
        ++it;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 12476
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a, int b) {
    int c;
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int lcm(int a, int b) {
    int c = gcd(a, b);
    a /= c;
    return a * b;
}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI = acos(-1.0);

using namespace std;

// #define int long long

signed main() {


    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    int ans = 0;

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


    cout << max(a + (a - 1), max(a + b, b + (b - 1))) << endl;

    return 0;

}

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

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;}

int main(){

  ll a,b,Q;
  cin >> a >> b >> Q;
  vector<ll> s(a);
  vector<ll> t(b);
  rep(i,a){
    cin >> s[i];
  }
  rep(i,b){
    cin >> t[i];
  }

  sort(s.begin(), s.end(), less<ll>());
  sort(t.begin(), t.end(), less<ll>());

  rep(i,Q){
    ll x;
    cin >> x;

    ll sl=0,sr=0;
    ll tl=0,tr=0;

    sr = distance(s.begin(),lower_bound(s.begin(), s.end(), x));
    if(sr!=0) sl = sr-1;
    if(sl==a-1) sr = sl;
    tr = distance(t.begin(),lower_bound(t.begin(), t.end(), x));
    if(tr!=0) tl = tr-1;
    if(tl==b-1) tr = tl;

    // cout << s[sl] << " " << s[sr] << " " << t[tl] << " " << t[tr] << endl;
    vector<ll> ans;
    if(s[sr]>=x&&t[tr]>=x) ans.push_back(max(s[sr],t[tr])-x);
    if(s[sl]<=x&&t[tl]<=x) ans.push_back(x-min(s[sl],t[tl]));
    if(s[sr]>=x&&t[tl]<=x) ans.push_back(min(s[sr]-x,x-t[tl])*2 + max(s[sr]-x,x-t[tl]));
    if(s[sl]<=x&&t[tr]>=x) ans.push_back(min(t[tr]-x,x-s[sl])*2 + max(t[tr]-x,x-s[sl]));
    
    sort(ans.begin(), ans.end(), less<ll>());
    cout << ans[0] << endl;
  }

  return 0;
} 

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

typedef long double ld;

const ld pi = acos(-1);
const ld eps = 1e-9;

struct Point {
	ld x, y;

	Point() {}

	Point (ld x_, ld y_) {
		x = x_;
		y = y_;
	}

	Point rotate() const {
		return Point(-y, x);
	}

	Point normalize(ld len) const {
		ld c = sqrt(x * x + y * y);
		return Point(x * len / c, y * len / c);
	}

	Point operator+(const Point &other) const {
		return Point(x + other.x, y + other.y);
	}

	Point operator-(const Point &other) const {
		return Point(x - other.x, y - other.y);
	}

	ld dist (const Point &other) const {
		return hypot(x - other.x,  y - other.y);
	}
};

int n, k;
vector<Point> p;
vector<ld> c;
vector<ld> r;

int ans = 0;

void relax(Point to) {
	int u = 0;
	for (int i = 0; i < n; i++) {
		if (p[i].dist(to) < r[i] + eps) u++;
	}
	ans = max(ans, u);
} 

ld msqrt(ld x) {
	if (x < 0) return 0;
	else return sqrt(x);
}

pair<Point, Point> inter(const Point &A, const Point &B, ld ra, ld rb) {
	ld d = A.dist(B);
	ld a = (ra * ra - rb * rb + d * d) / 2 / d;
	ld h = sqrt(ra * ra - a * a);
	Point v = B - A;
	Point u = v.rotate();
	v = v.normalize(a);
	u = u.normalize(h);
	Point H = A + v;
	return {H - u, H + u};
}

void solve() {
	ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (p[i].dist(p[j]) > r[i] + r[j] + eps) continue;
			if (p[i].dist(p[j]) + eps < fabs(r[i] - r[j])) continue;
			auto t = inter(p[i], p[j], r[i], r[j]);
			relax(t.first);
			relax(t.second);
		}
		relax(p[i]);
	}
}

int check(ld t) {
	for (int i = 0; i < n; i++) {
		r[i] = t / c[i];
	}
	solve();
	return ans >= k;
}


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

	cout << fixed << setprecision(16);

	cin >> n >> k;
	p.resize(n);
	c.resize(n);
	r.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i].x >> p[i].y >> c[i];
	}
	ld ll = 0;
	ld rr = 1e18 + 239;
	for (int i = 0; i < 100; i++) {
		ld m = (rr + ll) / 2;
		if (check(m)) rr = m;
		else ll = m;
	}
	cout << rr << endl;
}


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

int main() {
  char C;
  cin >> C;
  if (C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std; 
ll N = pow(10,5);
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int x,y;cin>>x>>y;
	ll sum=0;
	if(x<4){
		sum += (4-x)*N;
	}
	if(y<4){
		sum += (4-y)*N;
	}
	if(x==1 && y==1){
		sum += 4*N;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long



int main() {
	int n, v[100];
	double hoge, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v, v + n);
	ans = ((double)v[0] + v[1]) / 2.0;
	for (int i = 2; i < n; i++) {
		ans = (ans + v[i]) / 2.0;
	}
	printf("%.8f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int main()
{   
    int x;
    for(int i=0; i<5; i++){
        cin >> x;
        if(x==0){
            cout << i+1 << endl;
            return 0;
        }
    }
  
}


Measured memory_bytes: 3632
'use strict'

const main = (INPUT) => {
  const N = Number(INPUT.split('\n')[0].split(' ')[0])
  const K = Number(INPUT.split('\n')[0].split(' ')[1])

  let cnt = 0
  for (let i = 1; i <= N; i += 2) {
    cnt++
  }
  if (cnt >= K) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


#define FORA(i, a, n) for (int i = (a); i < (n); ++i)


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


int64_t sqr(int64_t x) { return x * x; }


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto C = next<int64_t>(in);
  auto h = next_vec<int64_t>(in, n);
  deque<int> convex;
  convex.push_front(0);
  vec<int64_t> f(n, 0);

  auto get = [&](int i, int j) -> double {
    return double(f[i] + sqr(h[i]) - f[j] - sqr(h[j])) / double(h[i] - h[j]);
  };

  FORA(i, 1, n) {
    while (convex.size() >= 2) {
      int l = convex.front(); convex.pop_front();
      int l2 = convex.front();
      double v = get(l, l2);
      if (v <= 2.0 * double(h[i])) {
        continue;
      } else {
        convex.push_front(l);
        break;
      }
    }
    f[i] = f[convex.front()] + C + sqr(h[i] - h[convex.front()]);
    while (convex.size() >= 2) {
      int r = convex.back(); convex.pop_back();
      int r2 = convex.back();
      double v1 = get(r2, r);
      double v2 = get(r, i);
      if (v1 >= v2) {
        continue;
      } else {
        convex.push_back(r);
        break;
      }
    }
    convex.push_back(i);
  }
  out << f[n-1] << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e12;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int a, b;
    cin >> a >> b;
    cout << (6 - a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
struct Po{
    int j, o, i;
    void operator += (Po p){
        this->j += p.j;
        this->o += p.o;
        this->i += p.i;
    }
    Po operator - (Po p){
        return Po{this->j - p.j, this->o - p.o, this->i - p.i};
    }
    Po operator + (Po p){
        return Po{this->j + p.j, this->o + p.o, this->i + p.i};
    }
};
int main(){
    int N, M, K;
    cin >> N >> M >> K;
    string s[N];
    for(int i = 0; i < N; i++) cin >> s[i];
    Po sum[N + 1][M + 1];
    for(int i = 0; i <= N; i++) sum[i][0] = Po{0, 0, 0};
    for(int i = 0; i <= M; i++) sum[0][i] = Po{0, 0, 0};
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < M; j++){
            sum[i][j + 1] = sum[i][j];
            if(s[i - 1][j] == 'J') sum[i][j + 1].j++;
            if(s[i - 1][j] == 'O') sum[i][j + 1].o++;
            if(s[i - 1][j] == 'I') sum[i][j + 1].i++;
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= M; j++){
            sum[i + 1][j] += sum[i][j];
        }
    }
    for(int i = 0; i < K; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        auto tmp = sum[c][d] + sum[a - 1][b - 1] - sum[a - 1][d] - sum[c][b - 1];
        cout << tmp.j << " " << tmp.o << " " << tmp.i << endl;
    }
    return 0;
}


Measured memory_bytes: 15672
let rec select acc trace = function
  | [] -> acc
  | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs
let select xs = select [] [] xs

let rec perm : int -> 'a list -> 'a list list = fun n xs ->
  match n, xs with
  | 0, _ -> [[]]
  | _, [] -> []
  | n, xs ->
      List.concat @@
        List.map (fun (xs, x, ys) ->
          List.map (fun xs -> x :: xs) @@
            perm (n - 1) @@ List.rev_append xs ys) @@ select xs

let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun x y -> x, y in
  let routes =
    List.map (fun is ->
      let is' = Array.of_list is in
      Array.fold_left ( +. ) 0. @@
      Array.init (n - 1) @@ fun i ->
        let (x, y) = xys.(is'.(i)) in
        let (x', y') = xys.(is'.(i + 1)) in
        sqrt @@ float_of_int @@ (x - x') * (x - x') + (y - y') * (y - y')) @@
    perm n @@
    Array.to_list @@
    Array.init n @@ fun i -> i in
  Printf.printf "%.10f\n" @@ List.fold_left ( +. ) 0. routes /. float_of_int (List.length routes)



Measured memory_bytes: 14336
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

struct mint {

  ll x; 

  mint(ll x=0):x((x%mod+mod)%mod){} //コンストラクタを呼んで自動的にmodを取っている。

  mint operator-() const { return mint(-x);}

  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    //メンバ関数にはthisポインタがある。メンバ変数の値を返す。
    return *this;
  }

  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }

  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }

  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }

  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1); //a=x/2
    a *= a; //繰り返し二乗法
    if (t&1) a *= *this; //tが奇数のときはxを1回かける
    return a;
  }



  // for prime mod

  mint inv() const {
    return pow(mod-2);
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
    
};

vector<mint> m(200001);
mint choose(ll n,ll r){
  return m[n]/(m[r]*m[n-r]);
}

int main()
{
    ios;
    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    h--;
    w--;
    ll ans=0;
    m[0]=1;
    for(ll i=1;i<=200000;i++){
        m[i]=m[i-1]*i;
    }
    for(ll i=b;i<=w;i++){
        mint s=choose(h-a+i,i);
        mint t=choose(w-i+a-1,a-1);
        mint u=s*t;
        ans+=u.x;
        ans%=mod;
    }
    cout << ans <<endl;
    return 0;
} 


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

using namespace std;

int main(){
  long start = 0;
  long end = 0;
  long d = 0;
  
  cin >> start >> end >> d;
  
  start += (start % d == 0 ? 0 : d - (start % d));
  
  if(end >= start){
    cout << (end - start) / d + 1;    
  } else {
    cout << 0;
  }
  
  return 0;
}

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

signed main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S;
    int w;

    cin >> S >> w;

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


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long T = nm[1] * 1900 + (nm[0] - nm[1]) * 100;
            Console.WriteLine((long)Math.Pow(2, nm[1]) * T);
        }
    }
}

Measured memory_bytes: 11220
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
lim = N+10  # 必要そうな階乗の限界を入れる
fact = [1] * (lim+1)
fact_inv = [1] * (lim+1)
for n in range(1, lim+1):
    fact[n] = (fact[n-1] * n) % mod
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
    fact_inv[n-1] = (n * fact_inv[n]) % mod

tree = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
	a, b = MAP()
	tree[a].append(b)
	tree[b].append(a)

root = 1
parent = [0] * (N + 1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
 
size_d = [0] * (N + 1)
dp_d = [1] * (N + 1)

for v in order[::-1]:  # 根に遠いほうから(down方向のボトムアップ)
    dp_d[v] *= fact[size_d[v]]
    dp_d[v] %= mod
    p = parent[v]
    s = size_d[v] + 1
    size_d[p] += s
    dp_d[p] *= fact_inv[s] * dp_d[v]
    dp_d[p] %= mod
size_u = [N - 1 - x for x in size_d]
dp_u = [1] * (N + 1)

for v in order[1:]:  # 根に近いほうから(up方向のトップダウン)
    p = parent[v]
    x = dp_d[p]
    x *= dp_u[p]
    x *= fact_inv[size_d[p]]
    x *= fact[size_d[v] + 1]
    x *= pow(dp_d[v], mod - 2, mod)
    x *= fact[size_u[v]-1]
    x *= fact_inv[size_u[p]]
    dp_u[v] = x % mod

for xd, xu, sd, su in zip(dp_d[1:], dp_u[1:], size_d[1:], size_u[1:]):
    x = xd * xu * fact[sd + su] * fact_inv[sd] * fact_inv[su] % mod
    print(x)


Measured memory_bytes: 121928
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N;
	cin >> N;
	set<pair<int,int>> ans;
	if(N%2==0){
		for(int i=1;i<=N;i++){
			for(int j=i+1;j<=N;j++){
				if(i+j==N+1)continue;
				ans.insert(pair<int,int>(i,j));
			}
		}
	}else{
		for(int i=1;i<=N;i++){
			for(int j=i+1;j<=N;j++){
				if(i+j==N)continue;
				ans.insert(pair<int,int>(i,j));
			}
		}
	}
	cout << ans.size() << endl;
	for(auto x:ans)cout << x.first << " " << x.second << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int gcd(int x, int y)
{
	int a = x, b = y, t = a%b;
	while (t > 0)
	{
		a = b;
		b = t;
		t = a%b;
	}
	return b;
}

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

	int n;
	cin >> n;

	int lcm = -1;
	int a;

	rep(i, 0, n)
	{
		cin >> a;
		if (lcm == -1)
		{
			lcm = a;
		}
		else
		{
			lcm = (lcm*a) / gcd(lcm, a);
		}
	}

	cout << lcm << endl;

	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ull unsigned long long
#define ll long long

int main() {
	fastio();
	int k;
	cin >> k;
	set<int> s1 = {1, 2, 3, 5, 7, 11, 13, 15, 17, 19, 23, 29, 31};
	set<int> s2 = {4, 6, 9, 10, 14, 21, 22, 25, 26};
	set<int> s4 = {28, 30};
	set<int> s5 = {8, 12, 18, 20, 27};

	if(k == 32)	cout << 51 << "\n";
	else if(k == 16)	cout << 14 << "\n";
	else if(k==24)	cout << 15 << "\n";
	else if(s1.count(k))	cout << 1 << "\n";
	else if(s2.count(k))	cout << 2 << "\n";
	else if(s4.count(k))	cout << 4 << "\n";
	else	cout << 5 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){

    int n,W; cin >> n >> W;

    int v[n];
    int w[n];

    rep(i,n){
        cin >> v[i] >> w[i];
    }

    int dp[n+10][W+10];
    rep(i,n+10) rep(j,W+10) dp[i][j] = 0;

    rep(i,n){
        rep(j,W+1){
            if(j - w[i] >= 0) dp[i+1][j] = max(dp[i][j-w[i]] + v[i] , dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[n][W] << endl;



}


Measured memory_bytes: 7388
#include<stdio.h>
#include<string.h>
//abc120-A
/*
int main(void)
{
	int a, b, c,d;
	scanf("%d %d %d", &a, &b, &c);

	if (b >= a * c)
	{
		printf("%d", c);
	}

	else
	{
		d = b / a;
		printf("%d", d);
	}
	return 0;
}
//abc120-B
int main(void)
{
	int a, b, k, tmp;
	int ans = 0, i, j;

	scanf("%d %d %d", &a, &b, &k);

	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}

	for (i = b; i > 0; i--)
	{
		if ((a % i + b % i) == 0)
		{
			ans += 1;
		}
		if (ans == k)
		{
			break;
		}

	}
	printf("%d", i);
	return 0;
}
//abc119-A
int main(void)
{
	int a, b, c;
	scanf("%d/%d/%d", &a, &b, &c);
	if (b < 5)
	{
		printf("Heisei");
	}
	else
	{
		printf("TBD");
	}

	
	return 0;
}
//abc119-b
int main(void)
{
	int a, i;
	float sum = 0;
	char s[15];
	float y;

	scanf_s("%d", &a);
	for (i = 0; i < a; i++)
	{
		scanf_s("%f", &y);
		scanf_s("%s", s, 15);
		if (strcmp(s, "JPY") == 0)
		{
			sum += y;
		}

		else
		{
			sum += y * 380000;
		}
	}
	printf("%f", sum);
	return 0;
}*/

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (b % a == 0)
	{
		printf("%d", a + b);
	}
	else
	{
		printf("%d", b - a);
	}

	return 0;
}

Measured memory_bytes: 128
x, y = gets.split.map(&:to_i)
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
puts (g1.include?(x) && g1.include?(y) || g2.include?(x) && g2.include?(y)) ? 'Yes' : 'No'

Measured memory_bytes: 1788
unittest
{
	assert( [ "3", "ABCA", "XBAZ", "BAD" ].parse.expand.solve == 2 );
	assert( [ "9", "BEWPVCRWH", "ZZNQYIJX", "BAVREA", "PA", "HJMYITEOX", "BCJHMRMNK", "BP", "QVFABZ", "PRGKSPUNA" ].parse.expand.solve == 4 );
	assert( [ "7", "RABYBBE", "JOZ", "BMHQUVA", "BPA", "ISU", "MCMABAOBHZ", "SZMEHMA" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	return tuple( ss );
}

auto solve( dchar[][] ss )
{
	// 1単語に含まれるABの数をカウント、単語の先頭文字と末尾文字で分類
	auto ans = 0L;
	auto bxa = 0L;
	auto xa = 0L;
	auto bx = 0L;
	foreach( s; ss )
	{
		ans += s.count( "AB" );
		if(      s[ $ - 1 ] == 'A' && s[ 0 ] == 'B' ) bxa++;
		else if( s[ $ - 1 ] == 'A'                  ) xa++;
		else if( s[ 0     ] == 'B'                  ) bx++;
	}
	
	if( 0 < bxa )
	{
		// 先頭文字がBで末尾文字がAの単語を全部連結
		ans += bxa - 1;
		
		// 更に先頭に末尾文字がAの単語を連結
		if( 0 < xa )
		{
			xa--;
			ans++;
		}
		
		// 更に末尾に先頭文字がBの単語を連結
		if( 0 < bx )
		{
			bx--;
			ans++;
		}
	}
	
	// 末尾文字がAの単語と先頭文字がBの単語を連結
	ans += min( xa, bx );
	
	return ans;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
vector<pair<ll,ll>> x;
ll ans[220000];
int main(){
    ll n,y;
    cin>>n;
    rep(i,0,n){cin>>y;x.pb({y,i});}
    sort(x.begin(),x.end());
    ll c1=x[n/2-1].first,c2=x[n/2].first;
    rep(i,0,n){
        ll pos=x[i].second;
        if(i<n/2)ans[pos]=c2;
        else ans[pos]=c1;
    }
    rep(i,0,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 7532
#!/usr/bin/env python3
class SegTree:
    def __init__(self, segfunc, e, v, init_val = None):
        """
        segfunc: function 区間にしたい操作\n
        e: Any 単位元\n
        v: int or List 要素数か格納する配列\n
        init_val: Any 初期値
        """
        self.segfunc = segfunc
        self.e = e
        self.init_val = init_val if init_val != None else e
        if isinstance(v, int):
            v = [self.init_val] * v
        self.n = len(v)
        self.log = (self.n).bit_length()
        self.size = 1 << self.log
        self.tree = [e] * 2 * self.size
        # 1-indexedなのでtree[1:self.size]がN-1要素
        # tree[self.size:self.size + N]が配列
        for i in range(self.n):
            self.tree[self.size + i] = v[i]
        for i in range(self.size - 1, 0, -1):
            self._update(i)

    def set(self, k, x) -> None:
        """
        k番目の値をxに更新\n
        k: index(0-indexed)\n
        x: update value
        """
        k += self.size
        self.tree[k] = x

        for i in range(1, self.log + 1):
            self._update(k >> i)

    def get(self, k):
        """
        a[k]を返す\n
        k: index(0-indexed)
        """
        assert 0 <= k < self.size
        return self.tree[k + self.size]

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る\n
        l: index(0-indexed)\n
        r: index(0-indexed)
        """
        res = self.e
        l += self.size
        r += self.size
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

    def all_query(self):
        """
        全範囲にsegfuncしたものを得る
        """
        return self.tree[1]

    # 二分探索実装、いる？

    def _update(self, k):
        self.tree[k] = self.segfunc(self.tree[k * 2], self.tree[k * 2 + 1])

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

MAX_A = 300005

dp = SegTree(max, 0, MAX_A, 0)
for i in range(N):
    x = A[i]
    now = dp.query(max(0, x - K), min(x + K + 1, MAX_A)) + 1
    dp.set(x, now)

ans = dp.all_query()
print(ans)


Measured memory_bytes: 120612
from sys import stdin

def max_heapify(A, i):
    l = i*2
    r = i*2+1
    largest = i
    if l <= A[0] and A[i] < A[l]:
        largest = l
    else:
        largest = i
    if r <= A[0] and A[largest] < A[r]:
        largest = r

    if largest != i:
        A[largest],A[i] = A[i],A[largest]
        max_heapify(A,largest)

heap = [0]*2000000
for c in stdin:
    if c[0] == 'i':
        heap[0] += 1
        heap[heap[0]] = int(c[7:])
        i = heap[0]
        p = i/2
        while p > 0 and heap[p] < heap[i]:
            heap[p],heap[i] = heap[i],heap[p]
            i = p
            p = i/2
    elif c[1] == 'x':
        print heap[1]
        heap[1] = heap[heap[0]]
        heap[0] -= 1
        max_heapify(heap,1)
    else:
        break

Measured memory_bytes: 45476
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,M,Q = map(int,input().split())
    cum = np.zeros((N+1,N+1),dtype=int)
    
    for i in range(M):
        l,r = map(int,input().split())
        cum[l,r] += 1

    cum = np.cumsum(np.cumsum(cum,axis=1),axis=0)
    
    for _ in range(Q):
        p,q = map(int,input().split())
        print(cum[q,q]-cum[p-1,q]-cum[q,p-1]+cum[p-1,p-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 18276
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const ll inf = (ll)1e15;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, a, b; cin >> n >> a >> b;
	vi pos(n);
	rep(i, n){
		int p; cin >> p;
		pos[p - 1] = 2 * i + 1;
	}
	
	vector<ll> dp(2 * n + 1, inf);
	rep(i, n){
		vector<ll> next(2 * n + 1, inf);
		ll mn = i ? inf : 0;
		rep(j, next.size()){
			int cost = j < pos[i] ? b : j == pos[i] ? 0 : a;
			mn = min(mn, dp[j]);
			next[j] = mn + cost;
		}
		dp = next;
	}
	cout << *min_element(all(dp)) << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=2e3+10;
const LL mod=1e9+7;
int n,k,maxx;
LL inv[N*N]={0,1},fac1[N*N]={1},fac2[N*N]={1},dp[N][N];
LL C(int nn,int mm){return fac1[nn]*fac2[mm]%mod*fac2[nn-mm]%mod;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&k); maxx=n*k;
	if(k==1)
	{
		printf("1\n");
		return 0;
	}
	for(RG int i=1;i<=maxx;i++) fac1[i]=fac1[i-1]*i%mod;
	for(RG int i=2;i<=maxx;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(RG int i=1;i<=maxx;i++) fac2[i]=fac2[i-1]*inv[i]%mod;
	dp[0][0]=1;
	for(RG int i=1;i<=n;i++)
	 for(RG int j=0;j<=i;j++)//
	  dp[i][j]=(dp[i-1][j]+(j!=0)*C(n-i+(n-j+1)*(k-1)-1,k-2)*dp[i][j-1]%mod*(n-j+1)%mod)%mod;
	printf("%lld",dp[n][n]);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 124288
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

ll t,l,h,x,y,p,q,mid;

ll chk(ll m)
{
	return (p*m>=x && q*m-p*m>=y-x);
		
}

int main()
{
	
	ll k,n;
	cin>>k>>n;
	ll a[200010];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	ll ans=INT_MAX,now;
	if(n==2)
	{
		ans=min(a[1]-a[0],k-(a[1]-a[0]));
		cout<<ans<<endl;
		return 0;
	}
	
	ans=min(a[n-1]-a[0],a[0]+k-a[1]);
	now=min(a[n-2]+k-a[n-1],a[n-1]-a[0]);
	ans=min(ans,now);
	for (int i = 1; i < n-1; ++i)
	{
		now=min(k-a[i]+a[(i-1+n)%n],k-a[(i+1)%n]+a[i]);
		ans=min(ans,now);

	}
	
	cout<<ans<<endl;
}



Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static void swap(ref long x,ref long y)
        {
            var tmp = x;
            x = y;
            y = tmp;
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
            var p = Reads();
            long ans = 0;

         
            for (int i = 0; i < n-1; i++)
            {
                if (p[i] == i + 1)
                {
                    swap(ref p[i], ref p[i + 1]);
                    ans++;
                }
            }
            if (p[n - 1] == n) { swap(ref p[n - 1], ref p[n - 1]); ans++; }
            

            Console.WriteLine(ans);





            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 21344
n=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if A[i]==i+1:
    ans=ans+1
    b=A[i+1]
    A[i+1]=A[i]
    A[i]=b
if A[n-1]==n:
  ans=ans+1
print(ans)

Measured memory_bytes: 14004
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

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

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

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

    vector<string> city;
    vector<int> point;
    for (int i = 0; i < N; i++) {
        string s; int p;
        cin >> s >> p;
        city.push_back(s);
        point.push_back(p);
    }

    map<pair<string,int>, int> mp;
    for (int i = 0; i < N; i++) {
        mp[make_pair(city[i], point[i])] = i+1;
    }

    map<string, vector<int>> m;
    for (int i = 0; i < N; i++) {
        m[city[i]].push_back(point[i]);
    }

    for (auto itr = m.begin(); itr != m.end(); itr++) {
        sort(all(itr->second));
        reverse(all(itr->second));
    }

    for (auto itr = m.begin(); itr != m.end(); itr++) {
        for (int k = 0; k < (itr->second).size(); k++)
            cout << mp[make_pair(itr->first, (itr->second)[k])] << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int a[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 0;i < n; ++i){
		int x;
		cin >> x;
		a[x]++;
	}
	bool valid = true;
	if(n&1){
		valid = a[0] == 1;	
		for(int i = 2;i < n; i+=2){
			if(a[i] != 2)valid = false;	
		}
	}
	else{
		for(int i = 1;i < n; i+=2){
			if(a[i] != 2)valid = false;	
		}
	}
	if(!valid){
		cout << 0 << '\n';
	}
	else{
		n/=2;
		int ans = 1;
		while(n--){
			ans = (ans * 2) % MOD;	
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dizi[100007];
long long int dp[100007];
int main()
{
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	cin >> n;k=2;
	for(int i=1;i<100007;i++)
		dp[i]=INT_MAX;
	for(int i=0;i<n;i++)
		cin >> dizi[i];
	for(int i=0;i<n;i++)
	{
		for(int ka=i+1;ka<=min(i+k,n);ka++)
		{
			dp[ka]=min(dp[ka],dp[i]+abs(dizi[i]-dizi[ka]));
		}
	}
	cout << dp[n-1];
}

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

int main() {
  string s;
  cin>>s;
  int si=s.size();
  int ans=0;
  if(si%2==0){
    for(int i=0;i<si/2;i++){
      if(s[i]!=s[si-i-1]){
        ans++;
      }
    }
  }
  else{
    for(int i=0;i<si/2;i++){
      if(s[i]!=s[si-1-i]){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;

ll dp[3000];

int main()
{
    fastInp;

    ll s;
    cin >> s;
    
    dp[0] = 1;
    for (int i = 0; i < s; i++) {
        vector<ll> pr(1);
        for (int j = 0; j <= s; j++) {
            pr.push_back(pr.back() +  dp[j]);
            pr.back() %= MOD;
        }
        for (int j = 3; j <= s; j++) {
            dp[j] = pr[j - 2];
            dp[j] %= MOD;
        }
    }

    cout << dp[s];
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <bitset>
#include <cmath>

int main()
{

	int weight = 0;
	while (std::cin >> weight)
	{
		std::bitset<10> bit(weight);
		int count = bit.count();

		for (int i = 0; i < 10; i++)
		{
			if (bit[i])
			{
				std::cout << std::pow(2, i);
				count--;
				if (count != 0)
				{
					std::cout << " ";
				}
			}
		}
		std::cout << std::endl;
		
	}

	return 0;
}

Measured memory_bytes: 3324
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String str;
    char[] ch, ch2;
    int i, j, k, l, n, m, o;

    n = sc.nextInt(); str = sc.nextLine();
    for(;n-- > 0;){
      str = sc.nextLine(); m = str.length();
      ch = new char[m]; ch2 = new char[m];
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i); ch2[i] = ch[i];
      }

      o = 0;
      for(k = 1;k < 10000;k++){
        if(iscoprime(k, 26)){
          l = inv(k, 26);

          for(i = 0;i < 26;i++){
            for(j = 0;j < m;j++){
              if(ch[j] >= 'a' && ch[j] <= 'z'){
                ch2[j] = (char)(ch[j] - 'a' + 26 - i);
                ch2[j] %= 26;
                ch2[j] = (char)((ch2[j] * l) % 26);
                ch2[j] += 'a';
              }
            }

            for(j = 0;j < m - 3;j++){
              if(ch2[j] == 't' && ch2[j + 1] == 'h'
              && ch2[j + 2] == 'a' && ch2[j + 3] == 't'){
                o = 1; break;
              }else if(ch2[j] == 't' && ch2[j + 1] == 'h'
              && ch2[j + 2] == 'i' && ch2[j + 3] == 's'){
                o = 1; break;
              }
            }
            if(o == 1)break;
          }
        }
        if(o == 1)break;
      }

      for(j = 0;j < m;j++)out.print(ch2[j]);
      out.println();
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean iscoprime(int a, int b){
    int i;
    if(a == 1)return true;
    for(i = 2;i < a + 1;i++)if(a % i == 0 && b % i == 0)return false;
    return true;
  }
  private static int inv(int a, int b){
    int i;
    for(i = 1;i < b;i++)if((a * i) % b == 1)return i;
    return -1;
  }
}

Measured memory_bytes: 21468
#include <stdio.h>
#include <math.h>

int main(void){
	double a;
	while(scanf("%lf",&a) != EOF){
		if(a<=48){
			printf("light fly\n");
		}
		else if(a<=51){
			printf("fly\n");
		}
		else if(a<=54){
			printf("bantam\n");
		}
		else if(a<=57){
				printf("feather\n");
			}
		else if(a<=60){
				printf("light\n");
			}
		else if(a<=64){
				printf("light welter\n");
			}
		else if(a<=69){
				printf("welter\n");
			}
		else if(a<=75){
				printf("light middle\n");
			}
		else if(a<=81){
				printf("middle\n");
			}
		else if(a<=91){
				printf("light heavy\n");
			}
		else{
				printf("heavy\n");
			}
	}
return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(args...) do { cout << "DEBUG: " << #args << " -> "; err(args); } while (0)
#else
#define dbg(...)
#endif
void err() { cout<< endl; }
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }
// -----------------------------------------------------------------------------

const int N = 2E5 + 100;
int n, a[N];
map<int, int> loc;
int len;

int check(int ans) {
    len = 0; loc.clear();
    FOR (i, 1, n + 1) {
        if (a[i] > len) len = a[i];
        else {
            if (a[i] < len) {
                for (auto it = loc.upper_bound(a[i]); it != loc.end(); )
                    loc.erase(it++);
            }
            len = a[i]; loc[len]++;
            FORD (j, len, 0) {
                if (loc[j] == ans) {
                    if (j == 1) return 0;
                    loc[j - 1]++;
                    loc[j] = 0;
                } else break;
            }
        }
    }
    return 1;
}

int check1() {
    FOR (i, 2, n + 1)
        if (a[i] <= a[i - 1]) return 0;
    return 1;
}

int main() {
    cin >> n;
    FOR (i, 1, n + 1) scanf("%d", a + i);
    if (check1()) {
        puts("1");
        return 0;
    }
    int l = 2, r = n;
    while (l < r) {
        int mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1024