akhauriyash/Code-Regression huggingface dataset:
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $amari = $n % 10;

  if($amari == '2' || $amari == '4' ||$amari == '5' ||$amari == '7' ||$amari == '9'){
    echo "hon";
    exit;
  }else if($amari == '0' || $amari == '1' || $amari == '6' || $amari == '8'){
    echo "pon";
  }else{
    echo "bon";
  }

Measured memory_bytes: 16116
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 2005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char A[MAXN], B[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%s %s", A, B);
    string S = A, T = B;
    if (T.substr(0, S.size()) == S) {
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

def ln():
    return map(int, input().split())

XY = list(ln())
p1 = np.array(XY[0:2])
p2 = np.array(XY[2:4])

p12 = p2 - p1

p4  = np.array((-1*p12[1],p12[0])) + p1
p3  = p12 + p4

print(p3[0],p3[1],p4[0],p4[1])


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    cout << max({A + B, A - B, A * B}) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n, x, y; cin >> n >> x >> y; 
    vector<int> G(n);
    for(int i = 1; i <= n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            G.at(std::min({
                j-i,
                abs(i-x) + 1 + abs(y-j),
                abs(i-y) + 1 + abs(x-j)
            }))++;
        }
    }

    for(int k = 1; k < n; ++k) {
        cout << G.at(k) << endl;
    }
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import itertools

n,m = map(int,input().split())
path_list = [list(map(int,input().split())) for _ in range(m)]

path_dict = {}
count = 0

for path in path_list:
    if path[0] in path_dict:
        path_dict[path[0]].append(path[1])
    else:
        path_dict[path[0]] = [path[1]]
    if path[1] in path_dict:
        path_dict[path[1]].append(path[0])
    else:
        path_dict[path[1]] = [path[0]]

order_list = list(range(2,n+1))
order_list = list(itertools.permutations(order_list))
# print(list(itertools.permutations(order_list)))
for order in order_list:
    order = list(order)
    order.insert(0,1)
    for i,num in enumerate(order):
        if i >= 1:
            if num not in target_list:
                break
        if i == len(order)-1:
            count += 1
        target_list = path_dict[num]

print(count)

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n, k; cin >> n >> k;
	V v(n); input(v);
	V like(n + 1);
	V sum(n + 1);
	rep(i, n) {
		like[i + 1] = max(like[i], like[i] + v[i]);
		sum[i + 1] += sum[i] + v[i];
	}
	int ans = 0;
	rep(i, 0, n - k + 1) {
		maxup(ans, like[i] + max(0ll, sum[i + k] - sum[i]) + (like[n] - like[i + k]));
	}
	cout << ans << endl;
	system("pause");
}

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

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


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

	 if(s < t){
		 cout << "Yes" << endl;
	 } else {
		 cout << "No" << endl;
	 }
}


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF INT_MAX;
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    return res;
}

int main(){
  ll N;
  cin>>N;

  vector<ll>m=divisors(N);
  ll ans=0;
  for(auto it:m){
    if(it<(N/it-1))ans+=N/it-1;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 384
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    string s;cin >> s;
    for(int i=1;i<int(s.size());i++){
        if(s[i] == s[i-1]){
            cout << i << " " << i+1 << endl;
            return 0;
        }
        if(i > 1){
            if(s[i] == s[i-2]){
                cout << i-1 << " " << i+1 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int sm=0;
	int u; 
	for(int i=0;i<m;i++)
	{
		cin>>u;
		sm+=u;
	}
	if(sm<=n)
	{
		cout<<n-sm;
		return 0;
	}
	else
	{
		cout<<"-1";
		return 0;
	}	
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int ctoi(char c){
    switch(c){
        case '0':{return 0;}
        case '1':{return 1;}
        case '2':{return 2;}
        case '3':{return 3;}
        case '4':{return 4;}
        case '5':{return 5;}
        case '6':{return 6;}
        case '7':{return 7;}
        case '8':{return 8;}
        case '9':{return 9;}
        default:{return -1;}
    }
}

int main(){
  int sum = 0;
  int c = getchar();
  if( c == '0' ){return 0;}
  ungetc(c,stdin);
  while( (c = getchar()) != '\n'){
      sum += ctoi(c);
  }
  printf("%d\n",sum);
  main();
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;


bool Y(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b)
{
	if (a.first.first != b.first.first)
	{
		return a.first.first < b.first.first;
	}
	else
	{
		return a.first > b.first;
	}
}

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

	vector<pair<pair<string, int>, int>> rest;
	int N, temp;
	string town;

	cin >> N;

	REP(i, N)
	{
		cin >> town >> temp;
		rest.push_back(make_pair(make_pair(town, temp), i + 1));
	}

	stable_sort(rest.begin(), rest.end(), Y);

	REP(i, N)
	{
		cout << rest[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 998244353;
const int inf = 9e18;
const int N = 2e5 + 5;

void solve(){
    int r;
    cin>>r;
    ld ans=2*pi*r;
    cout<<fixed<<setprecision(10)<<ans;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

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

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

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

/*
 * Union Find Tree
 */
ll par[100002]; // 親
ll rnk[100002]; // 木の深さ

void init(ll n) {
    rep(i, n+1) par[i] = i, rnk[i] = 0;
}

ll find(ll x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    
    if (rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(ll x, ll y) {
    return find(x) == find(y);
}

/*
 * kruskal
 */
struct edge {
    ll u, v, cost; 
    edge(ll a, ll b, ll c): u(a), v(b), cost(c) {}
};

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

vector<edge> es;
ll V;

ll kruskal() {
    sort(es.begin(), es.end(), comp);
    init(V);
    ll res = 0;
    rep(i, es.size()) {
        edge e = es[i];
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    ll N; cin >> N;
    vector<pair<ll, ll>> x(N), y(N);
    rep(i, N) {
        ll xi, yi; cin >> xi >> yi;
        x[i] = make_pair(xi, i);
        y[i] = make_pair(yi, i);
    }
    
    sort(x.begin(), x.end());
    rep(i, N-1) es.push_back(edge(x[i].second, x[i+1].second, abs(x[i].first - x[i+1].first)));
    
    sort(y.begin(), y.end());
    rep(i, N-1) es.push_back(edge(y[i].second, y[i+1].second, abs(y[i].first - y[i+1].first)));
    
    V = N;
    cout << kruskal() << endl;
    return 0;
}


Measured memory_bytes: 11632
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n;
      cin>>n;
      vector<int> a(n);
      for(int i=0;i<n;i++){
        cin>>a[i];
      }
      vector<int> x(n);
      for(int i=n;i>=1;i--){
        if(i>n*0.5){
          x[i-1]=a[i-1];
        }
        else{
          int sum=0;
          int k=2;
          while(i*k<=n){
            sum+=x[i*k-1];
            k++;
          }
          if(sum%2==a[i-1]){
            x[i-1]=0;
          }
          else x[i-1]=1;
        }
      }
      int cnt=0;
      for(auto& e:x){
        //cout<<e<<" ";
        if(e==1) cnt++;
      }//cout<<endl;
      cout<<cnt<<endl;
      for(int i=0;i<n;i++){
        if(x[i]==1) cout<<(i+1)<<" ";
      }
     
    }

Measured memory_bytes: 2432
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define prr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define pri(a) cout << a << endl;
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(a) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(n, r);
	if (n >= 10) cout << r;
	else cout << r + 100*(10 - n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001007;

int main(){
    ll n, m; cin >> n >> m;
    ll a = n % m;
    ll ans = min(a, abs(a - m));
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int K = sc.nextInt();
		List<Long> a = new ArrayList<Long>(x);
		List<Long> b = new ArrayList<Long>(y);
		List<Long> c = new ArrayList<Long>(z);
		for (int i = 0; i < x; i++) {
			a.add(sc.nextLong());
		}
		for (int i = 0; i < y; i++) {
			b.add(sc.nextLong());
		}
		for (int i = 0; i < z; i++) {
			c.add(sc.nextLong());
		}
		sc.close();

		Collections.sort(a);
		Collections.reverse(a);
		Collections.sort(b);
		Collections.reverse(b);
		Collections.sort(c);
		Collections.reverse(c);

		List<Long> ans = new ArrayList<Long>();
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < y; j++) {
				if ((i + 1) * (j + 1) > K) break;
				for (int k = 0; k < z; k++) {
					if ((i + 1) * (j + 1) * (k + 1) > K) break;
					ans.add(a.get(i) + b.get(j) + c.get(k));
				}
			}
		}

		Collections.sort(ans);
		Collections.reverse(ans);

		for (int i = 0; i < K; i++) {
			System.out.println(ans.get(i));
		}

	}
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
const int MAX_N = 110000; 
constexpr double EPS = 1E-11;

using namespace std;

//fixed << setprecision(10)

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

	vector<double>a(n);
	double sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}

	double avr = (double)sum / n;

	vector<pair<double, int> >ans;

	for (int i = 0; i < n; i++) {
		ans.push_back(make_pair(abs(a[i] - avr), i));
	}
	sort(all(ans));
	cout << ans[0].second << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int D;
    cin>>D;
    int c[26];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    map<int,int> m;
    int y=0;
    rep(i,D){
        int a=ans;
        int an=-INF;
        int x=0;
        rep(k,26){
            map<int,int> ma=m;
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    ma[k]=0;
                }else{
                    ma[j]++;
                    a-=ma[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                m[y]=0;
            }else{
                m[j]++;
                ans-=m[j]*c[j];
            }
        }
        y++;
        cout << y <<endl;
    }


    



}


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

const int INF=0x3f3f3f3f;

template<class T,class U>
class LazySegtree{
	int n;
	vector<T>dat;
	vector<U>lazy;
	T INIT;
	T E0;
	U E1;
	function<T(T,U,int)>F0;
	function<U(U,U)>F1;
	function<T(T,T)>F2;
public:
	LazySegtree(int n_,T INIT,T E0,U E1
	,function<T(T,U,int)>F0,function<U(U,U)>F1,function<T(T,T)>F2):
		INIT(INIT),E0(E0),E1(E1),F0(F0),F1(F1),F2(F2){
		n=1;while(n<n_)n<<=1;
		dat=vector<T>(2*n,INIT);
		lazy=vector<U>(2*n,E1);
	}
	inline void push(int k,int s){
		if(lazy[k]==E1)return;
		dat[k]=F0(dat[k],lazy[k],s);
		if(k<n-1){
			lazy[k*2+1]=F1(lazy[k*2+1],lazy[k]);
			lazy[k*2+2]=F1(lazy[k*2+2],lazy[k]);
		}
		lazy[k]=E1;
	}
	inline void upnode(int k){
		dat[k]=F2(dat[k*2+1],dat[k*2+2]);
	}
	inline void update(int a,int b,U x,int k,int l,int r){
		push(k,r-l);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=F1(lazy[k],x);
			push(k,r-l);
			return;
		}
		update(a,b,x,k*2+1,l,(l+r)/2);
		update(a,b,x,k*2+2,(l+r)/2,r);
		upnode(k);
	}
	inline T query(int a,int b,int k,int l,int r){
		push(k,r-l);
		if(b<=l||r<=a)return E0;
		if(a<=l&&r<=b)return dat[k];
		T lb=query(a,b,k*2+1,l,(l+r)/2);
		T rb=query(a,b,k*2+2,(l+r)/2,r);
		upnode(k);
		return F2(lb,rb);
	}
	inline void update(int a,int b,U x){
		update(a,b,x,0,0,n);
	}
	inline void update(int a,U x){
		update(a,a+1,x);
	}
	inline T query(int a,int b){
		return query(a,b,0,0,n);
	}
	inline T query(int a){
		return query(a,a+1);
	}
};

template<class T>
class RAQ_RMQ:public LazySegtree<T,T>{
public:
	RAQ_RMQ(int n_,T INIT,T E0,function<T(T,T)>F2=[](T a,T b){return min(a,b);})
	:LazySegtree<T,T>(n_,INIT,E0,0,
	[](T a,T b,int s){return a+b;},
	[](T a,T b){return a+b;},
	F2){}
};

template<class T>
class RAQ_RSQ:public LazySegtree<T,T>{
public:
	RAQ_RSQ(int n_,T INIT,T E0)
	:LazySegtree<T,T>(n_,INIT,E0,0,
	[](T a,T b,int s){return a+b*s;},
	[](T a,T b){return a+b;},
	[](T a,T b){return a+b;}){}
};

template<class T>
class RUQ_RMQ:public LazySegtree<T,T>{
public:
	RUQ_RMQ(int n_,T INIT,T E0,function<T(T,T)>F2=[](T a,T b){return min(a,b);})
	:LazySegtree<T,T>(n_,INIT,E0,numeric_limits<T>::min(),
	[](T a,T b,int s){return b;},
	[](T a,T b){return b;},
	F2){}
};

template<class T>
class RUQ_RSQ:public LazySegtree<T,T>{
public:
	RUQ_RSQ(int n_,T INIT,T E0)
	:LazySegtree<T,T>(n_,INIT,E0,numeric_limits<T>::min(),
	[](T a,T b,int s){return b*s;},
	[](T a,T b){return b;},
	[](T a,T b){return a+b;}){}
};

int a[300000],b[300000];
int ans[300000];

int main(){
	int h,w;cin>>h>>w;
	rep(i,h)scanf("%d%d",&a[i],&b[i]),a[i]--;
	RUQ_RMQ<int>seg(w,0,INF),seg2(w,0,INF);
	rep(i,w){
		seg.update(i,i+1,-i);
		seg2.update(i,i+1,0);
	}
	rep(i,h){
		if(b[i]<w){
			int c=min(seg2.query(b[i],b[i]+1),seg.query(a[i],b[i])+b[i]);
			seg.update(b[i],c-b[i]);
			seg2.update(b[i],c);
		}
		seg.update(a[i],b[i],INF);
		seg2.update(a[i],b[i],INF);
		ans[i]=seg2.query(0,w);
	}
	rep(i,h){
		if(ans[i]>=INF)puts("-1");
		else printf("%d\n",ans[i]+i+1);
	}
}

Measured memory_bytes: 13840
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(LL)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int BITSIZE=1<<17;
const LL p=7+1e9;
const int SIZE=2*1e5;
int a[SIZE];
int minium=INF,N;
int sol(int x){
	int ans=0;
	REP(i,N){
		ans+=pow(x-a[i],2);
	}
	return ans;
}
int main(){
	cin >> N;
	REP(i,N){
		cin >> a[i];
	}
	FOR(i,-100,101){
		minium=min(minium,sol(i));
	}
	cout << minium << endl;
	return 0;
}

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

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

using namespace std;

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  sort(x.begin(), x.end());

  // 座標間の距離
  vector<int> xDist(m - 1);
  rep(i, m - 1) {
    xDist[i] = x[i + 1] - x[i];
  }
  sort(xDist.rbegin(), xDist.rend());

  // 全体の距離から
  int res = abs(x[m - 1] - x[0]);
  // 長いところを飛ばしたのが答え
  rep(i, min(n - 1, (int) xDist.size())) {
    res -= xDist[i];
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
int main(){
    int a,b;
    int i,j;
    for(;;){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0) break;
        for(i=0;i<a;i++){
            for(j=0;j<b;j++){
                printf("#");
            }
            puts("");
        }
        puts("");
    }
    return 0;
}



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

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

    vector<vector<int>> graph(n);
    vector<int> included(n);
    deque<int> path;

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

        graph[a].push_back(b);
        graph[b].push_back(a);

        if(i == 0){
            path.push_front(a);
            path.push_back(b);
            included[a] = 1;
            included[b] = 1;
        }
    }

    
    while(1){
        int a = path.front();
        bool flag = true;
        for(int v : graph[a]){
            if(included[v] == 0){
                included[v] = 1;
                path.push_front(v);
                flag = false;
                break;
            }
        }
        if(flag == true) break;
    }
    while(1){
        int b = path.back();
        bool flag = true;
        for(int v : graph[b]){
            if(included[v] == 0){
                included[v] = 1;
                path.push_back(v);
                flag = false;
                break;
            }
        }
        if(flag == true) break;
    }

    cout << path.size() << endl;
    while(1){
        cout << path.front() + 1;
        path.pop_front();
        if(path.empty() == true) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll x;
    cin >> x;

    if(x){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    set<ll> even;
    Rep (i, N) {
        cin >> A[i];
        if (i % 2 == 0) {
            even.insert(A[i]);
        }
    }

    sort(A.begin(), A.end());
    ll ans = 0;
    for (ll i = 0; i < N; i += 2) {
        if (even.count(A[i]) == 0) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

void chmin(int &a, int b){a = min(a, b);}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, a = 1e9;
    cin >> n;
    vector<vector<int> > v(n, vector<int> (2));
    for(int i=0;i<n;i++) cin >> v[i][0];
    for(int i=0;i<n;i++) cin >> v[i][1];
    int maki = 1 << n;
    vector<vector<int> > dp(maki, vector<int> (51, a));
    dp[0][0] = 0;
    for(int bit=0;bit<maki;bit++){
    	int cnt = 0;
    	vector<int> d(n);
    	for(int i=0;i<n;i++) if(!(bit>>i&1)) d[i] = cnt++;
    	for(int i=0;i<n;i++){
    		int k = abs(i - n + cnt);
    		for(int j=0;j<=v[i][k&1];j++)
    			chmin(dp[bit|(1<<i)][v[i][k&1]], dp[bit][j] + d[i]);
    	}
    }
    for(int i=0;i<=50;i++) chmin(a, dp[maki-1][i]);
    cout << (a==1e9? -1: a) << endl;
    return 0;
}


Measured memory_bytes: 65792
#pragma GCC optimize("O3")
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const ll INF=1e17;

main(){
    int n=in();
    multiset<int> s;
    rep(i,1<<n)s.ep(in());
    multiset<int> t;
    auto it=s.end();it--;
    t.ep(*it);
    s.erase(it);
    rep(iii,n){
        for(auto e:t){
            auto it=s.lower_bound(e);
            if(it==s.begin()){
                cout<<"No";return 0;
            }
            else{
                it--;
                t.insert(*it);
                s.erase(it);
            }
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 12544
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto s=readln.chomp.to!(char[]);

  int f=0;
  int k=0;
  foreach(i; 0..n){
    if(s[i]=='('){
      k++;
    }else{
      if(k==0){
        f++;
      }else{
        k--;
      }
    }
  }
  foreach(_; 0..f) write("(");
  write(s);
  foreach(_; 0..k) write(")");
  writeln();

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = [False] * n

for i in range(n//2, n):
    ans[i] = a[i]

for i in range(n//2-1, -1, -1):
    mod = False
    for j in range(i, n, i+1):
        if ans[j] == 1:
            mod = not mod

    mod = 1 if mod else 0

    ans[i] = True if mod != a[i] else False

cnt = 0
ind = []
for i in range(n):
    if ans[i] == True:
        cnt += 1
        ind.append(i+1)

print(cnt)
if cnt > 0:
    print(" ".join(map(str, ind)))

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

int main(){
  int i,array[100001],n[100001]={},c=0,a,b;
  string s[101];
  cin>>a>>b;
  for(i=0;i<a;i++){
    cin>>s[i];
  }
  for(i=0;i<b+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(i=0;i<a;i++){
    cout<<"#"<<s[i]<<"#"<<endl;
  }
  for(i=0;i<b+2;i++){
    cout<<"#";
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    int wa[110000];
    bool ac[110000];
    cin>>n>>m;
    int p[m]; string s[m];
    int ans1=0,ans2=0;
    rep(i,m){
        cin>>p[i]>>s[i];
        if(s[i]=="WA"){
            wa[p[i]]++;
        }
        else{
            if(ac[p[i]]==false){
                ans1+=wa[p[i]];
                ac[p[i]]=true;
                ans2++;
            }
            else{
                continue;
            }
        }
    }
    cout<<ans2<<" "<<ans1<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define print(x) cout << x << '\n';


int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    
    int n, X, a;
    int mn;
    cin >> n >> X;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(i == 0) mn = abs(X-a);
        if(i > 0){
            mn = __gcd(abs(X-a), mn);
        }
    }
    cout << mn;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int dp[18][1<<18];
int main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    //i->j
    auto getnum = [&](int i, int j){
        if(abs(i-j)%2){
            return b[i];
        }else{
            return a[i];
        }
    };
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 1<< n; j++){
            dp[i][j] = 1<<30;
        }
    }
    for(int i = 0; i < n; i++){
        dp[i][1<<i] = i;
    }
    for(int i = 1; i < 1 << n; i++){
        int c = __builtin_popcount(i);
        for(int j = 0; j < n; j++){
            if(i >> j & 1){
                int last = getnum(j, c - 1);
                show(i, j, c, last, dp[j][i]);
                int cnt = 0;
                for(int k = 0; k < n; k++){
                    if(i >> k & 1){
                        continue;
                    }
                    int next = getnum(k, c);
                    show(k, last, c, next);
                    if(last <= next){
                        dp[k][i+(1<<k)] = min(dp[k][i+(1<<k)], dp[j][i] + cnt);
                    }
                    cnt++;
                }
            }
        }
    }
    int ans = 1<<30;
    for(int i = 0; i < n; i++){
        ans = min(ans, dp[i][(1<<n)-1]);
        
    }
    if(ans == 1<<30)ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 18688
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define dom 998244353
#define all(c) begin(c),end(c)
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
#define long long long
#define List vector
#define var auto
#define Count size()
#define Length size()
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

template <typename T>
struct SegTree {
	typedef function<T(T, T)> F;
	int n;
	F f;
	T exnum;
	vector<T> dat;

	SegTree(int n_, F f, T ex,
		vector<T> v = vector<T>()) {
		this->f = f;
		this->exnum = ex;
		init(n_);
		if (n_ == (int)v.size()) build(n_, v);
	}
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, exnum);
	}
	void build(int n_, vector<T> v) {
		for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)
			dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	void update(int k, T x) {
		k += n - 1;
		dat[k] = x;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return exnum;
		if (a <= l && r <= b) return dat[k];
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
	// return node[s, t] 閉区間クエリ
	T query(int a, int b) {
		b++;
		return query(a, b, 0, 0, n);
	}

	//デバッグ用
	T look(int k) {
		return dat[k + n - 1];
	}
	vector<T> items()
	{
		vector<T> ret(n);
		for (int i = 0; i < n; i++)
		{
			ret[i] = look(i);
		}
		return ret;
	}
};
//呼び出し方
//SegTree<int> rmq(n,
//	[](int a, int b) {return min(a, b); },
//	INT_MAX);


void solve()
{
	int N, Q;
	cin >> N >> Q;
	SegTree<int> rmq(N,
		[](int a, int b) {return min(a, b); },
		INT_MAX);
	rep(i, Q)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)
		{
			rmq.update(x, y);
		}
		else
		{
			cout << rmq.query(x, y) << endl;
		}
	}
}

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



Measured memory_bytes: 3920
#include<iostream>
using namespace std;
int main()
{
	int n,k,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		k=0;
		for(int j=1;j<=i;j++){
			if(i%j==0){
				k++;
			}
		}
		if(k==8 && i%2==1) sum++;
	}
	cout<<sum<<endl;
}

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

int main()
{
  int A,B,ans=0;scanf("%d %d",&A,&B);
  for(int ioooi=1;ioooi<10;ioooi++)for(int oioio=0;oioio<10;oioio++)for(int i=0;i<10;i++)if(ioooi*10001+oioio*1010+i*100>=A&&ioooi*10001+oioio*1010+i*100<=B)ans++;
  printf("%d\n",ans);
}

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

using namespace std;

int main(){
    int64_t a,b,c,d,g,x=0;
    cin >>a >>b >>c >>d;

    
    
    x = c*d/ __gcd(c,d);

    cout << (b-a+1) - (b/c + b/d + (a-1)/x) + ((a-1)/c + (a-1)/d + b/x)  <<endl;
   
}

Measured memory_bytes: 256
$h, $w = gets.split.map(&:to_i)
$maze = []
$h.times do
  $maze << gets.chomp.chars
end
def dfs(j, i)
  $maze[j][i] = "."
  if j+1 <= $h-1 && $maze[j+1][i] == "#"
    dfs(j+1,i)
  elsif i+1 <= $w-1 && $maze[j][i+1] == "#"
    dfs(j,i+1)
  end
end
dfs(0,0)
puts $maze.flatten.count("#") > 0 ? 'Impossible' : 'Possible
'

Measured memory_bytes: 1788
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define N 10001

#define MAX 100000
#define SE 98765432

struct Node{
  char suit;
  int value;
};

struct Node L[MAX /2+2],R[MAX /2+2];

void merge(struct Node A[],int n,int left, int mid,int right);
void mergeSort(struct Node A[],int n,int left,int right);
int partition(struct Node A[],int n,int p,int r);
void quickSort(struct Node A[],int n,int p,int r);

int main(){
  int n,i,x,y=1;
  struct Node A[MAX], B[MAX];
  char c[10];
 

  scanf("%d",&n);

  for(i=0;i<n;i++){
    
    scanf("%s%d",c,&x);
    
    A[i].suit=B[i].suit=c[0];
    
    A[i].value=B[i].value=x;
    
  }

  mergeSort(A,n,0,n);
  
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    
    if(A[i].suit!=B[i].suit)y=0;
    
  }

  if(y==1){
    
    printf("Stable");
    
  printf("\n");}
  
  else printf("Not stable\n");
  
  for(i=0;i<n;i++){
    
    printf("%c %d\n",B[i].suit,B[i].value);
    
  }
  return 0;
}

void merge(struct Node A[],int n,int left, int mid,int right){
  
  int i,j,k;
  
  int o = mid-left;
  
  int r = right-mid;
  
  for(i=0;i<o;i++)L[i]=A[left+i];
  
  for(i=0;i<r;i++)R[i]=A[mid+i];
  
  L[o].value =R[r].value=SE;
  
  i=j=0;
  
  for(k=left;k<right;k++){
    
    if(L[i].value<=R[j].value){
      
      A[k]=L[i++];

    }
    
    else{
      A[k]=R[j++];
      
    }
  }
}
void mergeSort(struct Node A[],int n,int left,int right){
  int mid;
  
  if(left+1<right){
    
    mid=(left+right)/2;
    
    mergeSort(A,n,left,mid);
    
    mergeSort(A,n,mid,right);
    
    merge(A,n,left,mid,right);
  }
}

int partition(struct Node A[],int n,int p,int r){
  int i,j;
  
  struct Node t,x;
  
  x=A[r];
  
  
  i=p-1;
  
  for(j=p;j<r;j++){
    
    if(A[j].value<=x.value){
      
      i++;
      
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t= A[i+1];A[i+1]=A[r];A[r]=t;
  
  return i+1;
}

void quickSort(struct Node A[],int n,int p,int r){
  int q;
  
  if(p<r){
    
    q=partition(A,n,p,r);
    
    quickSort(A,n,p,q-1);
    
    quickSort(A,n,q+1,r);
  }
}



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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 100000;
  string temp;
  for (int i=0; i<(s.size()-t.size()+1); i++){
    int cnt = 0;
    for (int j=i, k=0; k<t.size() ; j++, k++){
      if (s[j] != t[k]){
        cnt += 1;
      }
    }
    if (cnt < ans) ans = cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;

using ll = long long;



int main() {

    int n;

    cin >> n;

    map<map<char, int>, int> stringList;

    for(int i = 0; i < n; ++i) {
        
        map<char, int> m;

        for(int j = 0; j < 10; ++j) {
            
            char ch;
            cin >> ch;
            
            if(m.find(ch) == m.end())
                m.emplace(ch, 0);
            else
                m[ch]++;

        }

        if(stringList.find(m) == stringList.end()) 
            stringList.emplace(m, 0);
        else {
            stringList[m]++;
        

        }
    }

    ll count = 0;

    for(const auto &m : stringList) {
        
        ll sum = 0;
        for(int i = 1; i <= m.second; ++i) {
            sum += i;

        }
        count += sum;
    }

    cout << count << endl;

    return 0;

}

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

using namespace std;
int main(){
  vector <int> w(10);
  vector <int> k(10);
  for(int i = 0 ; i < 10 ; i++ ){
    cin >> w[i];
  }
  for(int i = 0 ; i < 10 ; i++ ){
    cin >> k[i];
  }
  sort(w.begin(),w.end());
  sort(k.begin(),k.end());
  reverse(w.begin(),w.end());
  reverse(k.begin(),k.end());

  cout << w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;

  return 0;
}


Measured memory_bytes: 3148
#include<iostream>
using namespace std;
typedef long long int ll;

ll p2[100]={};

ll pow2(ll a){
  if(a<2) return a+1;
  else if(p2[a]!=0) return p2[a];
  else{
    p2[a]=pow2(a/2)*pow2(a/2)*pow2(a-2*(a/2));
    return p2[a];
  }
}

ll mac(ll n,ll x){
  if(x==0) return 0;
  else if(n==0) return 1;
  else if(x<=pow2(n+1)-2) return mac(n-1,x-1);
  else if(x==pow2(n+2)-3) return pow2(n+1)-1;
  else return pow2(n)+mac(n-1,x-pow2(n+1)+1);
}

int main(){
  ll n,x,ans=0;
  cin>>n>>x;
  cout<<mac(n,x);
}

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

using namespace std;
typedef unsigned long long int ull;

int main(){
   ull N;
   cin >> N;
   ull arr[200005];
   ull mem[200005];

   long cnt = 0;
   for(int i = 0; i < N; ++i){
      ull A;
      cin >> A;
      ull v = arr[A];
      cnt += v;
      arr[A]++;
      mem[i] = A;
   }

   for(int i = 0; i < N; ++i){
      cout << cnt-arr[mem[i]]+1 << endl;
   }

   return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int dp[100010];
vector<vector<int> >g;
int n,m;

int dfs(int i)
{
  if(dp[i]!=-1)
     return dp[i];
     
     int res=0;
     
     for(int j=0;j<g[i].size();j++)
     {
       int c=g[i][j];
        res=max(res, dfs(c)+1);
      }
      
      dp[i]=res;
      
      return res;
 }



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(dp, -1, sizeof(dp));
	cin>>n>>m;
	g.resize(n+1);
	for(int i=0;i<m;i++)
	 {
	   int a, b;
	   cin>>a>>b;
	   g[a].pb(b);
	  }
	  
	  int ans=0;
	  for(int i=1;i<=n;i++)
	  {
	   ans=max(ans,dfs(i));
	  }
	  
	  cout<<ans<<endl;
	  
	  
	
return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = a + b;
		
		if (c <= 23) { 
			System.out.println(c);
		} else {
			System.out.println(c-24);
		}
	}
}

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

const vector<char> C = {'M', 'A', 'R', 'C', 'H'};

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<int> t(q), f(q);
  vector<char> c(q);
  for (int i = 0; i < q; i++) {
    cin >> t[i];
    if (t[i] == 2) cin >> f[i] >> c[i];
  }

  deque<char> ans;
  for (int i = 0; i < s.length(); i++) ans.push_back(s[i]);

  bool forward = false;
  for (int i = 0; i < q; i++) {
    if (t[i] == 1) {
      forward = !forward;
      continue;
    }
    if (f[i] == 1 && !forward || f[i] == 2 && forward) {
      ans.push_front(c[i]);
    } else {
      ans.push_back(c[i]);
    }
  }

  if (forward) reverse(ans.begin(), ans.end());

  for (int i = 0; i < ans.size(); i++) printf("%c", ans[i]);
  printf("\n");
}


Measured memory_bytes: 5292
N,K = map(int,input().split())
A = list(map(int,input().split()))

def isable(n):
    tmp = 0
    for i in range(N):
        tmp += (A[i]-0.5)//n
    if K >= tmp:
        return True
    else:
        return False


left = 0
right = 10**9

while right-left != 1:
    if isable((right+left)//2):
        right=(right+left)//2
    else:
        left=(right+left)//2

print(right)

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

int main(void){
    long int a,b;int check[4],count = 0;
    bool c = true;
    cin >> a >> b;
    //a <= i <= b
    for(int i = a;i < b + 1;i++,c = true){
        //回分数かどうか
        for(int j = i,k = 0;j > 0;j /= 10,k++)check[k] = j % 10;
        for(int k = 0;k < 3;k++){
            if(check[k] != check[4-k]){
                c = false;
                break;
            }
        }
        if(c == true)count += 1;
    }
    cout << count << endl;
}

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

int main(){
    int m, f, b;
    cin >> m >> f >> b;

    if(m+f >= b){
        if(m < b){
            cout << b-m << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n;
	cin >> n;
	int ans = 1;
	for(int i=1;i*i<=n;i++){
		if(n%i == 0){
			ans = max(ans,i);
		}
	}
	ans = n/ans;
	int t=1;
	while(ans >= 10){
		ans /=10;
		t++;
	}
	cout << t << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans,sum;
int a[1005];
int main()
{
	int i,j;
	cin>>n;
	ans=50000000;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(j=a[1];j<=a[n];j++)
	{
		sum=0;
		for(i=1;i<=n;i++)
			sum+=(j-a[i])*(j-a[i]);
		ans=min(ans,sum); 
	}
	cout<<ans;
}


Measured memory_bytes: 256