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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n; cin >> n, n;){
        vs str(n);
        rep(i, n) cin >> str[i];

        set<int> del;
        rep(i, n){
            rep(j, n){
                if(i == j || str[j].size() < str[i].size()) continue;

                rep(k, str[j].size() - str[i].size()){
                    if(str[j].substr(k, str[i].size()) == str[i]){
                        del.insert(i);
                    }
                }
            }
        }
        for(auto itr = del.rbegin(); itr != del.rend(); itr++){
            str.erase(str.begin() + *itr);
        }
        n -= del.size();

        vector<vs> sub(n, vs(n));
        rep(i, n){
            rep(j, n){
                if(i == j) continue;

                sub[i][j] = str[j];
                for(int k = min(str[i].size(), str[j].size()); k > 0; k--){
                    if(str[j].substr(0, k) != str[i].substr(str[i].size() - k, k)) continue;

                    sub[i][j].erase(0, k);
                    break;
                }
            }
        }


        vector<vs> dp(1 << n, vs(n));

        rep(i, 1 << n){
            rep(j, n){
                if(dp[i][j] == "" && i != 0) continue;

                rep(k, n){
                    if(i & (1 << k)) continue;
                    int next_idx = i | (1 << k);

                    string next_str = dp[i][j] + (i == 0 ? str[k]:sub[j][k]);

                    if(dp[next_idx][k] == ""){
                        dp[next_idx][k] = next_str;
                        continue;
                    }
                    
                    if(dp[next_idx][k].size() > next_str.size()) dp[next_idx][k] = next_str;
                    else if(dp[next_idx][k].size() == next_str.size()) dp[next_idx][k] = min(dp[next_idx][k], next_str);
                }
            }
        }

        string res = dp[(1 << n) - 1][0];
        range(i, 1, n){
            if(res.size() > dp[(1 << n) - 1][i].size()) res = dp[(1 << n) - 1][i];
            else if(res.size() == dp[(1 << n) - 1][i].size()) res = min(res, dp[(1 << n) - 1][i]);
        }

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

	return 0;
}

Measured memory_bytes: 31288
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int R;
  in(R);
  out(2.0*R*M_PI);
}
int main(void){
  BEGIN;
  solve();
  END;
}


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

using namespace std;
typedef long long int ll;

#define debug(val) "[ " << #val " : " << (val)
#define space " "
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define pi pair<int , int >
#define ff first
#define ss second
#define INF 2000000000
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};
const int Mod = 1000 * 1000 * 1000 + 7;
const int maxN = 100000 * 5 + 3;
int fen[maxN], last[maxN], a[maxN];
int n;

struct Query {
    int l, r, idx;

    bool operator<(Query const &other) {
        return r < other.r;
    }
};

void build() {
    for (int i = 0; i <= n; i++) fen[i] = 0;
    for (int i = 0; i <= n; i++) last[i] = -1;
}

int sum(int l) {
    int res = 0;
    while (l > 0) {
        res += fen[l];
        l -= (l & (-l));
    }
    return res;
}

int range_sum(int l, int r) {
    return sum(r) - sum(l - 1);
}

void update(int l, int delta) {
    while (l <= n) {
        fen[l] += delta;
        l += l & (-l);
    }
}

void solve() {
    int q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    build();
    vector<Query> queries;
    vector<int> res(q);
    for (int i = 0; i < q; i++) {
        int L, R;
        cin >> L >> R;
        queries.pb({L , R , i });
    }
    sort(queries.begin(), queries.end());
    int ptr = 1;
    for (int i = 0; i < q; i++) {
        int l = queries[i].l, r = queries[i].r;
        int q_idx = queries[i].idx;
        for (int j = ptr; j <= r; j++) {
            int val = a[j];
            if (last[val] != -1) {
                update(last[val], -1);
            }
            ptr = r;
            last[val] = j;
            update(last[val], 1);
        }
        //   cout << "Solution of " << l << space << r << " is " << space;
        res[q_idx] = range_sum(l, r);
    }
    for (int v : res) {
        cout << v << endl;
    }
}


int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}

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

int main() {
  bool f[3];
  for (int i = 0; i < 3; ++i)
    cin >> f[i];

  f[2] = !f[2];
  cout << (f[0] == f[1] && f[1] == f[2] ? "Open" : "Close") << endl;
}

Measured memory_bytes: 3072
class Grid:
    def __init__(self, H, W, grid, road_wall=(".", "#")):
        self.road, self.wall = road_wall
        self.H = H
        self.W = W
        self.grid = grid
        self.parent = [[0] * self.W for _ in range(self.H)]
        self.move = [(1, 0), (-1, 0), (0, 1), (0, -1)]     # 動ける場所の候補

    def bfs(self, start=(0,0), goal=-3, time=0, save=False):
        """
        :param start: スタート地点
        :param goal: ゴール地点
        :param save: True = 前回の探索結果を保持する
        :return: （ループがあっても）最短距離。存在しなければ -1
        """
        if save:
            parent = self.parent
        else:
            parent = [[0] * self.W for _ in range(self.H)]
        p, t = start, time
        parent[p[0]][p[1]] = 1
        next_set = deque([(p, t)])
        while next_set:
            p, t = next_set.popleft()
            h, w = p
            for dh, dw in self.move:
                q = (h + dh, w + dw)
                if q[0] < 0 or q[0] >= self.H or q[1] < 0 or q[1] >= self.W:
                    continue
                if self.grid[q[0]][q[1]] == self.wall:         # 壁があったら進まない
                    continue
                if parent[q[0]][q[1]] != 0:
                    continue
                if t >= K:
                    continue
                #### (debug code) ######
                # self.debug(start, goal, q, t)
                ########################
                if q == goal:
                    return t + 1
                parent[q[0]][q[1]] = 1
                next_set.append((q, t + 1))
        return parent

    def debug(self, start, goal, p, t):
        player = p
        debug_grid = list(list(self.grid[h]) for h in range(self.H))
        if start != (None, None):
            debug_grid[start[0]][start[1]] = "S"
        if goal != -3:
            debug_grid[goal[0]][goal[1]] = "G"
        debug_grid[player[0]][player[1]] = "P"
        print("~~~~~~~~~ t = " + str(t + 1) + "  ~~~~~~~~")
        for debug_h in range(self.H):
            print("".join(str(debug_grid[debug_h][debug_w]) for debug_w in range(self.W)))


###########################################################

from collections import deque
import sys
from math import ceil
import marshal
input = sys.stdin.readline



road, wall = ".", "#"                         # (進行可能を意味する記号, 進行不可を意味する記号)

H, W, K = map(int,input().split())                # 左上は(h,w)=(0,0)、右下は(h,w)=(H-1,W-1)

grid = []
for h in range(H):
    grid.append(input().rstrip())
    for w, s in enumerate(grid[-1]):
        if s == "S":
            start = (h,w)
g = Grid(H, W, grid, (road, wall))
visit = g.bfs(start=start)
res = float("inf")
for h in range(H):
    for w in range(W):
        if visit[h][w]:
            res = min(ceil(h/K)+1,ceil(w/K)+1,ceil((H-1-h)/K)+1,ceil((W-1-w)/K)+1,res)
print(res)


Measured memory_bytes: 92488
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define des greater<ll>()
#define fi first
#define se second
ll mul(ll a,ll b,ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a,ll b,ll p=mod){return (a%p + b%p)%p;}
void input(ll a[],ll sz){fr(i,0,sz) cin>>a[i];}
void print(ll a[],ll sz){fr(i,0,sz){if(i==sz-1) cout<<a[i]<<"\n";else cout<<a[i]<<" ";}}
ll maxr(ll a[],ll sz){ll ma;fr(i,0,sz){if(i==0) ma=a[i];else if(a[i]>ma) ma=a[i];}return ma;}
ll minr(ll a[],ll sz){ll mi;fr(i,0,sz){if(i==0) mi=a[i];else if(a[i]<mi) mi=a[i];}return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
    if (n%2 == 0 || n%3 == 0) return 0; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0; 
    return 1;}
/*ll spf[MAXN];
void sieve() 
{
    spf[1]=1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for(ll i=3;i*i<MAXN;i++) 
    {
        if (spf[i]==i) 
        {
            for (int j=i*i;j<MAXN;j+=i) 
                if (spf[j]==j) 
                    spf[j]=i; 
        }
    }
}*/
ll power(ll x,ll y,ll p=mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n,ll p=mod) 
{ 
    return power(n, p-2, p); 
} 
ll ncrMod(ll n,ll r,ll p=mod) 
{
   if (r==0) 
      return 1;
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
//a+b=xor(a,b)+2*(a&b)//
bool comp(const pair<int,int> &a, 
              const pair<int,int> &b) 
{
    if(a.fi==b.fi)
    {
        return (a.se>b.se);//second elem in descending
    }
    return (a.first < b.first);//first elem in ascending 
}
ll n,h[100005],dp[100005];
ll solve(ll i)
{
    if(i>=n-1)
    return 0;
    if(dp[i]!=-1)
    return dp[i];
    ll k1=mod,k2=mod;
    if((i+1)<n)
    k1=abs(h[i]-h[i+1])+solve(i+1);
    if((i+2)<n)
    k2=abs(h[i]-h[i+2])+solve(i+2);
    ll mi=min(k1,k2);
    dp[i]=mi;
    //cout<<k1<<" "<<k2<<" "<<mi<<"\n";
    return mi;
}










int main()
{
	fio;
	cin>>n;
	input(h,n);
	fr(i,0,100005)
	dp[i]=-1;
	ll ans=solve(0);
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

int main(){
    int n, m;
    cin >> n >> m;
    vint dp(n+1, 1e9);
    vint c(m);
    sort(all(c));
    rep(i,m){
        cin >> c[i];
    }
    dp[0] = 0;
    rep(i,n+1){
        rep(j,m){
            if(i >= c[j]) dp[i] = min(dp[i], dp[i-c[j]] + 1);
        }
        // printf("dp[%d] = %d\n", i, dp[i]);
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <map> // pair
#include <vector>
using namespace std;

int main(){
  int n, m;
  int a[100000];
  int b, c, i;
  long long int ans = 0;
  cin >> n >> m;
  
  vector<pair<int, int> > pairs(m);
  
  for( i = 0; i < n; i++){
    cin >> a[i];
  }
  
  sort(a, a + n);
  
  for( i = 0; i < m; i++){
    cin >> b >> c;
    pairs[i] = make_pair(c, b);
  }
  
  sort(pairs.begin(), pairs.end());
  
  int count = 0;
  
  for( i = m - 1; count < n && i >= 0; i--){
    for(int j = 0; j < pairs[i].second && count < n; j++){
      if(a[count] < pairs[i].first){
        a[count] = pairs[i].first;
        count++;
      }else{
        count = n;
      }
    }
  }
  
  for( i = 0; i < n; i++){
    ans += a[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for(auto& i : v){
        cin >> i;
        ans += i;
    }
    if(ans%10 != 0){
        cout << ans << endl;
        return 0;
    }
    sort(v.begin(), v.end());
    for(auto i : v){
        if((ans - i)%10 != 0){
            cout << ans - i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if 10000*i+5000*j+1000*k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main(void){ 
int A,B;
scanf("%d%d",&A,&B);
if(A+B<10)
printf("%d\n",A+B);
else printf("error\n");
return 0;
}

Measured memory_bytes: 128
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString("\n");
      println(solve(input).trim());
    }
  }

  def solve(input:String):String={
    if(input.split(" ").map(_.toInt).product%2==0){"Even"}else{"Odd"}
  }

  val tests=List("""3 9""" -> """12""",
    """31 32""" -> """63""",
    """1 2""" -> """3""",
    """-1 2""" -> """1""",
    """10 1""" -> """11""");

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    int count = 0;
    for(int i = a; i <= b; i++){
        if(c%i == 0){
            count++;
        }
    }
    cout << count << endl;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n, m;

ll lcm(ll x, ll y){
  return (x * y) / __gcd(x, y);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  cin >> n >> m;
  ll t = 1;
  vector<int> a(n+1);
  For(i, 1, n) {
    cin >> a[i]; a[i] /= 2; t = lcm(t, a[i]);
    if (t > m){
      cout << 0; return 0;
    }
  }
  For(i, 1, n){
    if ( (t / a[i]) % 2 == 0){
      cout << 0; return 0;
    }
  }
  cout << ((m / t) + 1) / 2;

}


Measured memory_bytes: 640
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
l=0
r=1000000000
while r-l>1
  m=(l+r)/2
  c=0
  a.each do |b|
    c+=(b-1)/m
  end
  if c<=k
    r=m
  else
    l=m
  end
end
puts r


Measured memory_bytes: 27748
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    map<string,int> w;
    
    vector<string> v;
    cin>>n;
    rep(i,0,n){
        string u;
        cin>>u;
        if(w.find(u)==w.end()){
            v.push_back(u);
            w[u]=1;
        }
        else
        w[u]++;
    }
    sort(v.begin(),v.end());
    m=0;
    rep(i,0,v.size()){
        if(w[v[i]]>m)
        m=w[v[i]];
    }
    rep(i,0,v.size()){
        if(w[v[i]]==m)
        cout<<v[i]<<endl;
    }

}

Measured memory_bytes: 26736
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<ll> B_l;
    vector<ll> B_r;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        if(i % 2 == 0) B_r.push_back(A);
        else B_l.push_back(A);
    }
    reverse(all(B_l));
    B_l.insert(B_l.end(), all(B_r));
    if(N % 2 == 1) reverse(all(B_l));
    for(int i  = 0; i < N; i++)cout << B_l[i] << ' ';
}

Measured memory_bytes: 4700
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T> inline T gcd(T&a,T&b){return b==0?a:gcd(b,a%b);}
template<typename T> inline T lcm(T&a,T&b){return a/gcd(a,b)*b;}
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n,a[maxn],b[maxn];
int main(){
    read(n);
    for (int i=1;i<=n;i++) b[i]=read(a[i]);
    int cnt=0,ans;
    for (int i=1;i<n;i++){
        if (a[i]==i) swap(a[i],a[i+1]),cnt++;
    }
    if (a[n]==n) cnt++;
    ans=cnt;
 /*   cnt=0;
    for (int i=n;i>1;i--){
        if (b[i]==i) swap(b[i],b[i-1]),cnt++;
    }
    if (b[1]==1) cnt++;
    ans=min(ans,cnt);*/
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i <= n; i++) {
		if (i < 10) {
			count++;
		}
		if (i >= 100 && i <= 999) {
			count++;
		}
		if (10000 <= i && 99999 >= i) {
			count++;
		}
	}
	cout << count << endl;
	return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
	


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

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace D
{
    internal class Program
    {
        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            CR.Get();
            var blocks = CR.GetIntegers().ToList();

            // 不可能判定
            if (!blocks.Any(x => x == 1)) return -1;

            // 0判定
            if (blocks.Select((x, i) => new { Val = x, SEQ = i })
                .All(x => x.Val == x.SEQ)) return 0;

            var nextTarget = 1;
            var count = 0;
            for (int i = 0; i < blocks.Count; i++)
            {
                var b = blocks[i];
                if (b == nextTarget)
                {
                    nextTarget++;
                }
                else
                {
                    count++;
                }
            }

            return count;
        }
    }
}


Measured memory_bytes: 35676
$mod = 10**9+7

def pow(a,b)
  if b == 1
    a
  elsif b%2 == 0
    (pow(a,b/2)**2)%$mod
  else
    (a*pow(a,b/2)**2)%$mod
  end
end

def create_fact(n)
  for i in 2..n
    $fact[i] = ($fact[i-1]*i)%$mod
  end
end

def create_fact_inv(n)
  $fact_inv[n] = pow($fact[n],$mod-2)
  n.downto(1) do |i|
    $fact_inv[i-1] = ($fact_inv[i]*i)%$mod
  end
end

def create_inv(n)
  for i in 1..n
    $inv[i] = ($fact[i-1]*$fact_inv[i])%$mod
  end
end

def init(n)
  $fact = Array.new(n+1,1)
  $fact_inv = Array.new(n+1,1)
  $inv = Array.new(n+1,0)
  create_fact(n)
  create_fact_inv(n)
  create_inv(n)
end

def combi(a,b)
  (($fact[a]*$fact_inv[b])%$mod)*$fact_inv[a-b]%$mod
end

init(1000010)
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 1
a.each do |i|
    ans = ans.lcm(i)
end
# ans %= $mod
c = 0
a.each do |i|
    c += $inv[i]
    # c -= $mod if c > $mod
end
puts ans*c%$mod

Measured memory_bytes: 73752
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    string S;
    cin >> S;

    bool flag = false;

    int i1,i2,i3,i4;

    i1 = 0;
    i2 = 1;
    i3 = 2;
    i4 = 3;
    if(S.substr(i1,1)==S.substr(i2,1) && S.substr(i3,1)==S.substr(i4,1) && S.substr(i1,1)!=S.substr(i4,1))   flag = true;
    
    i1 = 0;
    i2 = 2;
    i3 = 1;
    i4 = 3;
    if(S.substr(i1,1)==S.substr(i2,1) && S.substr(i3,1)==S.substr(i4,1) && S.substr(i1,1)!=S.substr(i4,1))   flag = true;
    

    i1 = 0;
    i2 = 3;
    i3 = 1;
    i4 = 2;
    if(S.substr(i1,1)==S.substr(i2,1) && S.substr(i3,1)==S.substr(i4,1) && S.substr(i1,1)!=S.substr(i4,1))   flag = true;
    
    if(flag) cout << ans_Yes << endl;
    else cout << ans_No << endl;


}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < 1;
	}

	int[] A;

	public void readBody(String str) {
		// System.out.println(str);]
		String[] strArr = str.split(" ");
		A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = Integer.parseInt(strArr[i]);
		if (A[0] != 0) {
			long cnt1 = cnt();
			long cnt2;
			if (A[0] > 0) {
				cnt2 = A[0] + 1;
				A[0] = -1;
			} else {
				cnt2 = -1 * A[0] + 1;
				A[0] = 1;
			}
			cnt2 += cnt();
			if (cnt1 < cnt2)
				System.out.println(cnt1);
			else
				System.out.println(cnt2);
		} else {
			A[0] = 1;
			long cnt1 = cnt() + 1;
			A[0] = -1;
			long cnt2 = cnt() + 1;
			if (cnt1 < cnt2)
				System.out.println(cnt1);
			else
				System.out.println(cnt2);
		}
		cnt++;
	}

	private long cnt() {
		int s = 1;
		if (A[0] < 0)
			s = -1;
		long ans = 0;
		int sum = A[0];
		for (int i = 1; i < N; i++) {
			s = s * -1;
			sum = sum + A[i];
			if (s == -1 && sum >= 0) {
				ans += (sum + 1);
				sum = -1;
			} else if (s == 1 && sum <= 0) {
				ans += (-sum + 1);
				sum = 1;
			}
		}
		return ans;
	}
}


Measured memory_bytes: 39252
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll ans=0,n; cin>>n;
  vector<ll>v(n);
  rep(i,n) cin>>v[i];
  rep(i,n-1){
  for(ll k=i+1;k<n;k++){
  ans+=v[i]*v[k];
  }
  }
  
  cout<<ans<<endl;
  
}

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

#define int long long 

void max_self(int &a, int b)
{
	a = max(a,b);
}

signed main()
{
	int n,w;
	cin >> n >> w;
	vector<int> dp(w+1); // 0...W
	// dp[i] - max total value that can be obtained with total weight exactly i
	dp[0] = 0;
	for(int item = 0;item < n; ++item)
	{
		int weight,val;
		cin >> weight >> val;
			for(int weight_added = w-weight; weight_added >= 0; --weight_added)
			max_self(dp[weight_added + weight],dp[weight_added] + val);
		
	}
	int ans = 0;
	for(auto x:dp)
	{
		max_self(ans,x);
	}
	cout << ans;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const ll INF = 100100100100100100;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
} 

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin >> a >> b >> c;
    if(a + b + c == 17){
        cout << "YES" << "\n";
    }
    else{
        cout << "NO" << "\n";
    }
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		input = reader.readLine().split(" ");
		int n = Integer.parseInt(input[0]);
		long d = Integer.parseInt(input[1]);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			input = reader.readLine().split(" ");
			long x = Integer.parseInt(input[0]), y = Integer.parseInt(input[1]);
			if (Math.sqrt(x * x + y * y) <= d) {
				ans++;
			}
		}
		out.print(ans);
		out.flush();
		out.close();
    }

}


Measured memory_bytes: 58544
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int N;
vector<vector<ll>> a(16, vector<ll>(16));
vector<ll> ps(1 << 16, 0), dp(1 << 16, -1e15);

ll calc(int mask)
{
    if (dp[mask] != -1e15)
        return dp[mask];
    dp[mask] = ps[mask];
    for (int b = (mask - 1) & mask; b > 0; b = (b - 1) & mask)
    {
        dp[mask] = max(dp[mask], calc(b) + calc(mask ^ b));
    }
    return dp[mask];
}

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

    cin >> N;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> a[i][j];
    for (int i = 0; i < (1 << N); i++)
    {
        for (int j = 0; j < N; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                if ((i & (1 << j)) && (i & (1 << k)))
                {
                    ps[i] += a[j][k];
                }
            }
        }
    }
    cout << calc((1 << N) - 1) << endl;
}


Measured memory_bytes: 1280
from scipy.sparse.csgraph import dijkstra
from collections import deque
import sys
input = sys.stdin.readline
def isbipart(n,graph):  
  colors = [0 for i in range(n)]
  stack = deque([(0,1)])
  while stack:
    v,color = stack.pop()
    colors[v] = color
    for to in graph[v]:
      if colors[to] == color:
        return False
      if colors[to] == 0:
        stack.append((to,-color))
  return True

def solve():
  n = int(input())
  graph = []
  for i in range(n):
    tmp = []
    s = input()
    for j in range(n):
      tmp.append(int(s[j]))
    graph.append(tmp)
  d = dijkstra(graph)
  #csgraphを変換
  newgraph = [[] for _ in range(n)]
  for i in range(n):
    for j in range(n):
      if graph[i][j] == 1:
        newgraph[i].append(j)
  ans = -1 * float("Inf")
  for i in range(n):
    for j in range(n):
      ans = max(ans,d[i][j])
  if isbipart(n,newgraph):
    print(int(ans)+1)
  else:
    print(-1)
solve()

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	
	string s, m; int c = 0;
	cin >> s >> m;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] != m[i])
			c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <tuple>

using namespace std;

char arr[1000];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int l;
    scanf("%s", arr);

    l = strlen(arr);

    printf("%c%d%c", arr[0], l-2, arr[l-1]);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using st = size_t;
#define reps(i, n) for(size_t i = 0; i < (size_t)(n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    reps(i, n) { cin >> v.at(i); }
    sort(v.begin(), v.end());
    int min = 1000000000, c;
    for(st i = 0; i < 100; ++i) {
        c = 0;
        for(st j = 0; j < v.size(); ++j) {
            c += (v.at(j) - i) * (v.at(j) - i);
        }
        min = ::min(min, c);
    }
    cout << min << "\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 +5;
int N, A[MAX];
map<int, int> mp;
int main(){
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        scanf("%d", A + i);
        mp[A[i]]++;
    }
    long long ans = 0;
    for(auto &i : mp){
        int cur = i.first;
        int cnt = i.second;
        if(cur > cnt){
            ans += cnt;
        }
        else{
            ans += cnt - cur;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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


def max2(x, y):
    """ pythonの組み込み関数 max は2変数に対しては遅い！！ """
    if x > y:
        return x
    else:
        return y


def knapsack_weight(single=True):
    """
    重さが小さい時のナップサックDP
    :param single: True = 重複なし
    """
    """ dp[weight <= W] = 重さ上限を固定した時の最大価値 """
    dp_min = 0  # 総和価値の最小値
    dp = [dp_min] * (W + 1)

    for item in range(N):
        if single:
            S = reversed(range(weight_list[item], W + 1))
        else:
            S = range(weight_list[item], W + 1)
        for weight in S:
            dp[weight] = max2(dp[weight], dp[weight - weight_list[item]] + price_list[item])
    return dp[W]

#######################################################################################################


N, W = map(int, input().split())                                # N: 品物の種類 W: 重量制限

price_list = []
weight_list = []
for _ in range(N):
    weight, price = map(int, input().split())
    price_list.append(price)
    weight_list.append(weight)

print(knapsack_weight(single=True))

################################################################################################################################################



Measured memory_bytes: 74288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   ll a,b;cin>>a>>b;
   if(a==b)cout<<0;
   else {
       if((b+a)&1)cout<<"IMPOSSIBLE";
       else cout<<(b+a)/2;
   }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int> vs(n + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int w = x * x + y * y + z * z + x * y + y * z + z * x;
        if (w <= n) {
          vs[w]++;
        }
      }
    }
  }

  for (int k = 1; k <= n; k++) {
    cout << vs[k] << endl;
  }
}

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

int main(){
    
    int a, b, c, s;
    cin >> a >> b >> c ;
    
    if (b < a) {
        s = a ;
        a = b ;
        b = s ;
        
    }
    
    if (c < a) {
        s = c ;
        c = a ; 
        a = s ;
        
    }
    
    if (c < b) {
        s = b ;
        b = c ;
        c = s ;
        
    }
    
    
    cout << a << " " << b << " " << c << endl ;

    return 0 ;
}



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


namespace cfA
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());
            
            int p;
            for (int i = 0; i < s.Length; i++)
            {
                p = s[i] - 'a';
                if(i == s.Length -1)
                {
                    Console.Write(Convert.ToChar('a' + (p + K) % 26));
                }
                else if (p == 0)
                {
                    Console.Write('a');
                }
                else if (p + K > 25)
                {
                    K -= 26 - p;
                    Console.Write('a');
                }
                else if (i != s.Length - 1)
                {
                    Console.Write(s[i]);
                }
            }
        }
    }
}


Measured memory_bytes: 11360
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

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

#define MAX_N 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化
void init(int n){
    for(int i=0;i<=n-1;i++){
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}
//////////////////////////////////////
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}
#define MAX_E 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
edge es[MAX_E];
int v,e;//頂点数vと辺数e

int kruskal(){
    sort(es,es+e,comp);
    init(v);
    int res=0;
    for(int i=0;i<e;i++){
        edge e=es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}
///////////////////////////////////////////

struct P{
    int num,x,y;
};

bool ascx(const P &l,const P &r){
    return l.x<r.x;
}
bool ascy(const P &l,const P &r){
    return l.y<r.y;
}


int main(){
    int n;cin>>n;
    P p[n];
    for(int i=0;i<=n-1;i++){
        cin>>p[i].x>>p[i].y;
        p[i].num=i;
    }
    sort(p,p+n,ascx);
    for(int i=1;i<=n-1;i++){
        es[i-1]=edge{p[i-1].num,p[i].num,abs(p[i].x-p[i-1].x)};
    }
    sort(p,p+n,ascy);
    for(int i=1;i<=n-1;i++){
        es[n+i-2]=edge{p[i-1].num,p[i].num,abs(p[i].y-p[i-1].y)};
    }
    init(n);
    v=n;e=2*n-2;
    cout<<kruskal()<<endl;
    return 0;
}


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

int main(){
  int N,K;
  long int ANS=0;
  scanf("%d %d", &N,&K);
  ANS+=(long int)pow((int)(N/K),3);
  if(K%2==0){
    if(N>=K/2){
      N=N-K/2;
      ANS+=(long int)pow((int)(N/K)+1,3);
    }
  }
  printf("%ld", ANS);
  return 0;
}
    


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c,tyou = 0,hishi = 0;
    while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
        if(a*a+b*b==c*c)tyou++;
        else{
            if(a == b)hishi++;
        }
    }
 
    cout << tyou << endl << hishi << endl;
    return 0;
}


Measured memory_bytes: 3164
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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 n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  int v;
    cin >> n>>m>>v;
  if(n<=v&&n+m>=v)YES;
  else NO;
}



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

int main() {
  double x, cnt=0;
  vector<double> a;
  while(cin >> x) {
    a.push_back(x);
    cnt++;
  }
  sort(a.begin(), a.end());
  double ans=a[cnt-1]-a[0];
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

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

struct SegTree {
  int size;
  vector<ll> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,0); }
  ll operator[](const ll &x) const { return pos[x+size]; }

  void build() { per(i,size) operate(i); }
  void set(ll x, const ll v) { pos[x+size] = v; }
  void update(ll x, const ll v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  ll query(ll a, ll b) {
    ll L = 0, R = 0;
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(R,pos[b]); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = max(pos[i*2],pos[i*2+1]); }
  ll q(ll x, ll y) { return max(x,y); }
};

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

struct robot { ll X; ll Y; };



int main() {
  int N; cin >> N;
  robot r[N]; rep(i,N) { ll X, D; cin >> X >> D; r[i] = {X,X+D}; }
  sort(r,r+N,[](const robot &x, const robot &y){ return x.X<y.X; });

  SegTree st(N);
  per(i,N) {
    if (i==N-1) st.update(i,N-1);
    else {
      auto pos = lower_bound(r,r+N,(robot){r[i].Y,0},[](const robot &x, const robot &y){ return x.X<y.X; });
      st.update(i,max((ll)i,st.query(i,pos-r)));
    }
  }
  // rep(i,N) cout << r[i].X << "-" << r[i].Y << endl;
  // rep(i,N) cout << st[i] << " "; cout << endl;

  ll result[N+1] = {}; result[0] = 1;
  rep(i,N) {
    result[i+1] = (result[i]+result[i+1])%MOD;
    result[st[i]+1] = (result[i]+result[st[i]+1])%MOD;
  }
  // debug(result,result+(N+1));
  cout << result[N] << endl;
  return 0;
}

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

int main(){
  int R;
  cin >>R;
  
  string ans;
  if(R<1200) ans="ABC";
  else if(1200<=R and R<2800) ans="ARC";
  else ans = "AGC";
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define pb push_back
#define f first
#define s second 
#define int long long
#define all(c) (c).begin(), (c).end()
#define endl '\n'



int32_t main()
{
 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin >> t;
    // while(t--){

    // }
    int n;
    cin >> n;
    int arr[n+1];
    fo(i,1,n+1){
    	cin >> arr[i];
    }
    int count = 0;
    fo(i,1,n+1){
    	if((i&1) && (arr[i]&1))count++;
    }
cout << count << endl;

return 0;
}

 

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int ss = s.size();
    for (int i = 0; i<ss; i++)
        s[i] = 'x';
    for (int i = 0; i < ss; i++)
        cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[110];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  set<int> values;
  for(int i=0;i<N;i++){
    values.insert(d[i]);
  }
  cout << values.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  for(int a=1;a<10;a++){
    for(int b=1;b<10;b++){
      if(a*b==N){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3604