akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (a == b) cout << "a == b" << endl;
	else if (a < b) cout << "a < b" << endl;
	else cout << "a > b" << endl;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N, ans= 1e18;
  cin >> N;
  vector<ll> x(N);
  rep(i, N)
    cin >> x[i];
  sort(begin(x), end(x));
  for (ll x0=x[0]; x0 <= x[N-1]; x0++) {
    ll t = 0;
    rep(i, N) {
      t += (x[i]-x0) * (x[i]-x0);
    }
    chmin(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

  static int n, a, b, c;
  static int[] d, ord, ans;

  static String[] ordStr;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    d = new int[3];

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    a = Integer.parseInt(in[1]);
    b = Integer.parseInt(in[2]);
    c = Integer.parseInt(in[3]);
    d[0] = a;
    d[1] = b;
    d[2] = c;

    ord = new int[n];
    ordStr = new String[n];

    for(int i = 0; i < n; i++){
      ordStr[i] = br.readLine();
      if(ordStr[i].equals("AB")) ord[i] = 2;
      if(ordStr[i].equals("AC")) ord[i] = 1;
      if(ordStr[i].equals("BC")) ord[i] = 0;
    }

    br.close();

    ans = new int[n];

    long sum = a + b + c;

    PrintWriter out = new PrintWriter(System.out);

    boolean ok = true;

    if(sum == 0){
      ok = false;
    }else if(sum == 1){

      for(int i = 0; i < n; i++){
        if(d[ord[i]] == 1){
          ok = false;
          break;
        }else{
          for(int th = 0; th < 3; th++){
            if(th == ord[i]) continue;
            if(d[th] == 0) ans[i] = th;
            d[th] = 1 - d[th];
          }
        }
      }
    }else if(sum == 2){
      for(int i = 0; i < n; i++){
        int ord1 = 0;
        int ord2 = 1;
        if(ord[i] == 0) {
          ord1 = 2;
        }else if(ord[i] == 1){
          ord2 = 2;
        }

        if(d[ord1] + d[ord2] == 0){
          ok = false;
          break;
        }

        if(d[ord1] < d[ord2]){
          d[ord2]--;
          d[ord1]++;
          ans[i] = ord1;
        }else if(d[ord1] > d[ord2]){
          d[ord1]--;
          d[ord2]++;
          ans[i] = ord2;
        }else{
          if(i == n - 1) continue;
          if(ord[i+1] == ord[i]){
            d[ord1]++;
            d[ord2]--;
            ans[i] = ord1;
          }else if(ord[i+1] == ord1){
            d[ord1]--;
            d[ord2]++;
            ans[i] = ord2;
          }else{
            d[ord2]--;
            d[ord1]++;
            ans[i] = ord1;
          }
        }
      }
    }else{
      for(int i = 0; i < n; i++){
        int ord1 = 0;
        int ord2 = 1;
        if(ord[i] == 0) {
          ord1 = 2;
        }else if(ord[i] == 1){
          ord2 = 2;
        }

        if(d[ord1] + d[ord2] == 0){
          ok = false;
          break;
        }

        if(d[ord1] < d[ord2]){
          d[ord2]--;
          d[ord1]++;
          ans[i] = ord1;
        }else{
          d[ord1]--;
          d[ord2]++;
          ans[i] = ord2;
        }
      }
    }


    if(ok){
      out.println("Yes");
      for(int i = 0; i < n; i++){
        out.println((char)('A' + ans[i]));
      }
    }else{
      out.println("No");
    }

    out.flush();

  }

}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
//    vector<ll> a(n);
    priority_queue<ll> a;
    for(ll i=0; i<n; i++) {
        ll tmp;
    	cin>>tmp;
    	a.push(tmp);
    }

    for (ll i = 0; i < m; i++) {
        ll tmp = a.top();
        a.pop();
        tmp = tmp / 2;
        a.push(tmp);
    }
    ll ans=0;
    for (ll i = 0; i < n; i++) {
        ans += a.top();
        a.pop();
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 4244
#include <iostream>

using namespace std;
#define MAX 101
int M[MAX][MAX],p[MAX];
int n;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i-1]>>p[i];
    }
    for(int i=1;i<=n;i++){
        M[i][i] = 0;
    }
    for(int l=2;l<=n;l++){
        for(int i=1;i<=n-l+1;i++){
            int j = i+l-1;
            M[i][j] = (1<<21);
            for(int k=i;k<=j-1;k++){
                M[i][j] = min(M[i][j],M[i][k]+M[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout<<M[1][n]<<endl;
    return 0;
}



Measured memory_bytes: 3132
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
 
def dist(a, b):
  return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))

ANS = [0] * N
for i in range(N):
  for j in range(i):
    ANS[dist(i, j)] += 1

        
for a in ANS[1:]:
  print(a)

Measured memory_bytes: 47708
N=~-int(input())
C=[list(map(int,input().split())) for _ in range(N)]

for i in range(N):
 p,q,r=C[i]
 A=q+p
 for j in range(i+1,N):
  c,s,f=C[j]
  if A<s:A=s
  m=(A-s)%f
  if m!=0:A+=f-m
  A+=c
 print(A)
print(0)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  string s;
  cin >> s;
  vector<int> v(26);
  rep (i, s.size()) {
    v[s[i] - 'a']++;
    if (v[s[i] - 'a'] > 1) {
      no;
      return 0;
    }
  }
  yes;
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <iomanip>

int main() {
	int H, W;
   	while(true){
   		std::cin >> H >> W;
   		if(H == 0 && W == 0)
   			break;
   		for(int y = 0; y < H; y++){
   			for(int x = 0; x < W; x++){
   				if( x == 0 || y == 0 || x == W-1 || y == H-1)
   					std::cout << "#";
   				else
   				    std::cout << ".";
   			}
   			std::cout << std::endl;
   		}
   		std::cout << std::endl;
   	}
   	return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<int> x(n), y(n);
    iota(x.begin(), x.end(), 0);
    sort(x.begin(), x.end(), [&](int i, int j) { return a[i] < a[j]; });
    iota(y.begin(), y.end(), 0);
    sort(y.begin(), y.end(), [&](int i, int j) { return b[i] < b[j]; });
    bool unique = true;
    for (int i = 0; i < n; i++) {
        if (a[x[i]] > b[y[i]]) { cout << "No\n" << endl; return 0; }
        if (i > 0 && a[x[i]] <= b[y[i - 1]]) unique = false;
    }
    if (unique) {
        vector<int> p(n);
        for (int i = 0; i < n; i++) p[y[i]] = x[i];
        int c = 1, i = p[0];
        while (i != 0) {
            i = p[i]; c++;
        }
		cout << (c < n ? "Yes\n" : "No\n");
    } else {
        cout << "Yes\n";
    }
}

Measured memory_bytes: 2176
#include<stdio.h>

int main()
{
 int N;
 int K;
 long x[100005];
 long dist;
 long mindist;
 long distp;
 long distm;
 int i;

 scanf("%d %d",&N,&K);
 for(i=0;i<N;i++) scanf("%ld",&x[i]);
 mindist=2*(x[N-1]-x[0]);
 for(i=K-1;i<N;i++)
 {
  if(x[i]<0) dist=-x[i-K+1];
  if(x[i-K+1]>0) dist=x[i];
  if((x[i]>=0)&(x[i-K+1]<=0))
  {
   distp=2*x[i]-x[i-K+1];
   distm=x[i]-2*x[i-K+1];
   if(distp<distm)
   {
    dist=distp;
   }else{
    dist=distm;
   }
  }
  if(mindist>dist) mindist=dist;
 }
 printf("%ld\n",mindist);
 return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	int n = s.size();
	if(n <= k) {
		cout << s << endl;
	} else {
		cout << s.substr(0, k) << "..." << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int head,tail;
int main(){
    string s;
    getline(cin,s);
    for(int i=0;i<s.length();++i){
        if(s[i]=='A'){
            head=i+1;
            break;
        }
    }
    for(int i=s.length();i>=0;--i){
        if(s[i]=='Z'){
            tail=i+1;
            break;
        }
    }
    int cha=tail-head;
    cout<<cha+1<<endl;
    return 0;
}

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

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

use std::cmp::min;

fn main() {
    let mut map: Vec<Vec<char>> = vec![vec!['.'; 100]; 100];
    let a: usize = read();
    let b: usize = read();
    let k = 50;

    for i in 0..k {
        map[i] = vec!['#'; 100];
    }

    let mut ahead = 0;
    let mut arow = 0;
    for _ in 1..a {
        map[arow][ahead] = '.';
        ahead += 2;
        if ahead >= map[0].len() {
            arow += 2;
            ahead = 0;
        }
    }
    let mut ahead = 0;
    let mut arow = 51;
    for _ in 1..b {
        map[arow][ahead] = '#';
        ahead += 2;
        if ahead >= map[0].len() {
            arow += 2;
            ahead = 0;
        }
    }

    println!("{} {}", 100, 100);
    for i in 0..map.len() {
        let mut row: String = String::new();
        for j in 0..map[i].len() {
            row += &map[i][j].to_string();
        }
        println!("{}", row);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

bool checkOK(vector<LL>& check){
    for(LL i = 0; i+1 < check.size(); ++i){
        if(check[i] == -1 || check[i+1] == -1) return false;
        if(check[i] > check[i+1]) return false;
    }
    return true;
}

LL iabs(LL v){
    if(v < 0) return -v;
    return v;
}

LL moveCount(vector<LL>& index){
    LL cnt = 0;
    for(LL i = 0; i < index.size(); ++i){
        for(LL j = i+1; j < index.size(); ++j){
            if(index[i] > index[j]) ++cnt;
        }
    }
    return cnt;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n), b(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(LL i = 0; i < n; ++i){
        cin >> b[i];
    }
    LL ans = -1;
    for(LL i = 0; i < (1<<n); ++i){
        vector<pair<LL,LL>> even;
        vector<pair<LL,LL>> odd;
        for(LL cur = 0; cur < n; ++cur){
            if(((i>>cur)&1) == 0){
                if((cur&1) == 0){
                    even.emplace_back(a[cur], cur);
                }else{
                    odd.emplace_back(a[cur], cur);
                }
            }else{
                if((cur&1) == 0){
                    odd.emplace_back(b[cur], cur);
                }else{
                    even.emplace_back(b[cur], cur);
                }
            }
        }
        //cerr << "even=" << even << endl;
        //cerr << "odd=" << odd << endl;
        sort(even.begin(), even.end());
        sort(odd.begin(), odd.end());
        vector<LL> index(n), check(n);
        LL even_cur = 0, odd_cur = 0;
        for(LL cur = 0; cur < n; ++cur){
            index[cur] = -1;
            check[cur] = -1;
            if((cur&1) == 0){
                if(even_cur >= even.size()) break;
                check[cur] = even[even_cur].first;
                index[cur] = even[even_cur++].second;
            }else{
                if(odd_cur >= odd.size()) break;
                check[cur] = odd[odd_cur].first;
                index[cur] = odd[odd_cur++].second;
            }
        }
        if(checkOK(check)){
            //cerr << "debug i=" << i << ", " << moveCount(index) << ", " << index <<  check<< endl;
            if(ans == -1){
                ans = moveCount(index);
            }else{
                ans = min(ans, moveCount(index));
            }
        }
    }
    cout << ans << endl;
    return 0;
}




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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] v = sc.intarr;
            int[] c = sc.intarr;
            int cost = 0;

            for (int i = 0; i < n; i++)
            {
                int tmp = v[i] - c[i];
                if (tmp > 0)
                {
                    cost += tmp;
                }
            }
            wr.wri(cost);


        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 11348
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M := nextInt(), nextInt()
	lb := make([][]int, M)
	for i := 0; i < M; i++ {
		k := nextInt()
		lb[i] = make([]int, k)
		for j := 0; j < k; j++ {
			lb[i][j] = nextInt() - 1
		}
	}
	Pm := make([]int, M)
	for i := range Pm {
		Pm[i] = nextInt()
	}
	var cnt int
	// fmt.Println(lb)
	for bit := uint(0); bit < 1<<uint(N); bit++ {
		checkSwitchesOn := make([]int, M)
		for i := 0; i < N; i++ {
			if bit>>uint(i)&1 == 1 {
				for j := 0; j < M; j++ {
					for k := 0; k < len(lb[j]); k++ {
						if lb[j][k] == i {
							checkSwitchesOn[j]++
							// break
						}
					}
				}
			}
		}
		ok := true
		for i := 0; i < M; i++ {
			// fmt.Println("check", checkSwitchesOn[i], Pm[i])
			if checkSwitchesOn[i]%2 != Pm[i] {
				ok = false
				// break
			}
		}
		if ok {
			cnt++
		}
		// fmt.Println(cnt, bit, checkSwitchesOn)
	}
	// fmt.Println(cnt, Pm)
	fmt.Println(cnt)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //auto a = make_v<ll>(n, m);
    int n,r;
    cin >> n >> r;
    if(n >= 10){
      print(r);
    } else {
      print(r + 100 * (10 - n));
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  N%=10;
  if (N==2 || N==4 || N==5 || N==7|| N==9) cout << "hon";
  else if (N==0 || N==1 || N==6 || N==8) cout << "pon";
  else cout << "bon";
  cout <<  "\n";
  return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 100000 + 9;
ll n,cap,mem[109][N],w[N],v[N];

ll dp(int i,int  tot)
{
    if(tot == 0) return 0;
    if(i > n) return 0;
    if(mem[i][tot] != -1) return mem[i][tot];
    ll c1 = 0, c2 = 0;
    if(w[i]<= tot) c1 = v[i] + dp(i+1, tot - w[i]);
    c2 = dp(i+1, tot);

    return mem[i][tot] = max(c1,c2);
}

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n>>cap;
        forr(i,1,n)cin>>w[i]>>v[i];

        memset(mem,-1,sizeof mem);

        cout<<dp(1,cap)<<endl;





return 0;
}


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

int main(){
    
    int N, v;
    cin >> N;
    int A[N];
    
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    bool flag = 1;
    int count =0;
    for(int i=0; flag; i++){
        flag = 0;
        for(int j = N-1; j>= i+1; j--){
            if(A[j] < A[j-1]){
                
                int x= A[j];
                A[j] = A[j-1];
                A[j-1] = x;
                
                count++;
            }
            flag = 1;
            
        }
        
    }
    for(int k=0; k<N; k++){
        if(k != 0){
            cout << " ";
        }
        cout << A[k];
    }
    cout << endl;
    
    cout << count << endl;
    
    return 0;
}



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

using namespace std;

int n;

long long a[200010];

map < long long, int > h; 

long long ans;

int main() {
	scanf("%d", &n); ++h[0];
	for (int i = 1; i <= n; ++i)
		scanf("%lld", a + i), a[i] += a[i - 1], ans += h[a[i]], ++h[a[i]];
	printf("%lld\n", ans);
	return 0;
} 

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<string, int> P;


string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}

class Queue {
    int start = -1, end = -1;
    vector<P> buffer;
public:
    Queue() : buffer(1000000) {}

    bool isEmpty() {
        return start == end;
    }

    void push(P i) {
        end++;
        buffer[end] = i;
    }

    P pop() {
        assert(!isEmpty());
        start++;
        return buffer[start];
    }
};

int main() {

    int n, q;
    cin >> n >> q;

    Queue queue;

    rep(i, n) {
        string name;
        int time;
        cin >> name >> time;
        P p(name, time);
        queue.push(p);
    }

    int now = 0;
    while (!queue.isEmpty()) {
        P front = queue.pop();
        if (front.second <= q) {
            now += front.second;
            printf("%s %d\n", front.first.c_str(), now);
        } else {
            now += q;
            front.second -= q;
            queue.push(front);
        }
    }


}



Measured memory_bytes: 20688
package main

import ( 
		"fmt"
		"flag"
 )

func min(a, b int) int {
		if a < b {
				return a
		}
		return b
}

func main() {
		var N, A, B int
		fmt.Scan(&N, &A, &B)
		flag.Parse()
		fmt.Println(min(B, N*A))
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define printV(v) for(int i=0;i<v.size();i++){cout << v[i] << " ";} cout << endl
#define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
#define sortV(v) sort(v.begin(),v.end())
ll a,b,c,d,e,f,g,n,m,k,t,p;

ll mod = 1000000007;


struct LCA {
    vector<int> height, euler, first, segtree;
    vector<bool> visited;
    int n;
 
    LCA(vector<vector<int>> &adj, int root = 0) {
        n = adj.size();
        height.resize(n);
        first.resize(n);
        euler.reserve(n * 2);
        visited.assign(n, false);
        dfs(adj, root);
        int m = euler.size();
        segtree.resize(m * 4);
        build(1, 0, m - 1);
    }
 
    void dfs(vector<vector<int>> &adj, int node, int h = 0) {
        visited[node] = true;
        height[node] = h;
        first[node] = euler.size();
        euler.push_back(node);
        for (auto to : adj[node]) {
            if (!visited[to]) {
                dfs(adj, to, h + 1);
                euler.push_back(node);
            }
        }
    }
 
    void build(int node, int b, int e) {
        if (b == e) {
            segtree[node] = euler[b];
        } else {
            int mid = (b + e) / 2;
            build(node << 1, b, mid);
            build(node << 1 | 1, mid + 1, e);
            int l = segtree[node << 1], r = segtree[node << 1 | 1];
            segtree[node] = (height[l] < height[r]) ? l : r;
        }
    }
 
    int query(int node, int b, int e, int L, int R) {
        if (b > R || e < L)
            return -1;
        if (b >= L && e <= R)
            return segtree[node];
        int mid = (b + e) >> 1;
 
        int left = query(node << 1, b, mid, L, R);
        int right = query(node << 1 | 1, mid + 1, e, L, R);
        if (left == -1) return right;
        if (right == -1) return left;
        return height[left] < height[right] ? left : right;
    }
 
    int lca(int u, int v) {
        int left = first[u], right = first[v];
        if (left > right)
            swap(left, right);
        return query(1, 0, euler.size() - 1, left, right);
    }
};
 
 






void solve(){
   cin >> n >> a >> b;
   c = a + b;
   ll cnt = 0;
   cnt = (n / (a+b) * a);
   n = n % (a+b);
   if( n <= a){
       cnt += n;
   }else{
       cnt += a;
   }
   cout << cnt;
}

int main(){
    ios_base::sync_with_stdio(false);
  
    int cases = 1; 
    //cin >> cases;

    while(cases--){
        solve();
    }
    return 0;

}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 5005, mod = (int) (1 << 23) * 17 * 7 + 1;
long long dp[N], a[N];
int main() {
	int n, k, res = 0, cnt = 0;
	cin >> n >> k;
	dp[0] = 1;
	for (int j = 0; j < n; ++j) {
		cin >> a[j];
		if (a[j] < k) {
			for (int x = k; x >= a[j]; --x)
				dp[x] = (dp[x] + dp[x - a[j]]) % mod;
		}
	}
	for (int j = 0; j < n; ++j) {
		if (a[j] <= k) {
			for (int x = a[j]; x <= k; ++x)
				dp[x] = (dp[x] - dp[x - a[j]] + mod) % mod;
			int flag = 0;
			for (int x = 0; x < k; ++x)
				if (dp[x] >= 1 && x + a[j] >= k)
					flag = 1;
			res += flag ^ 1;
			for (int x = k; x >= a[j]; --x)
				dp[x] = (dp[x] + dp[x - a[j]]) % mod;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 384
while 1:

 n, x = map(int, input().split())

 if(n==0 and x==0):
     break
 else:
     count = 0
     for i in range(1,n+1):
        for j in range(i+1,n+1):
            for t in range(j+1,n+1):
                if(i+j+t == x):
                    count+=1

 print(count)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
map<ll, ll> prime_factorization(long long n) {
  // map<ll,ll> first=素因数 second=first素因数の数
  map<ll, ll> res;
  for (int i = 2; i <= n / i; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
int main() {
  ll N;
  cin >> N;
  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll num = 5;
  while (2 * num <= N) {
    ans += N / (num * 2);
    num *= 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int A,B,M;cin>>A>>B>>M;
  int ans=INF;
  vector<int> A_a(A),B_a(B);
  REP(i,0,A)cin>>A_a[i];
  REP(i,0,B)cin>>B_a[i];
  int x,y,c;
  REP(i,0,M){
    cin>>x>>y>>c;
    x--;y--;
    ans=min(ans,A_a[x]+B_a[y]-c);
  }
  sort(ALL(A_a));
  sort(ALL(B_a));
  ans=min(ans,A_a[0]+B_a[0]);
  print(ans);

}


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


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

    int n, k;
    cin >> n >> k;

    vector<int> v;

    for(int i = 0; i < n; i++) {
        int gh = 0;
        cin >> gh;
        v.push_back(gh);
    }
    sort(v.begin(), v.end(), greater<int>());
    long long int max = 0;
    for(int i = k; i < v.size(); i++)  {
        max += v[i];
    }
    cout << max << endl;

    return 0;
}




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

int main() {
    int n; cin >> n;
    vector<int> ans(n, 0);

    for (int x = 1; x * x <= n; ++x) {
        for (int y = 1; y * y <= n; ++y) {
            for (int z = 1; z * z <= n; ++z) {
                int f = x * x + y * y + z * z + x * y + y * z + z * x;
                if (f <= n) ++ans[f - 1];
            }
        }
    }

    for (auto &i : ans) cout << i << endl;
}



Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[109],pas;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(c=1; c<=a; c++) cin>>f[c];
	sort(f+1,f+a+1);
	for(c=1; c<=a; c++){
		if(b<f[c]){
			break;
		}else{
			pas++;
			b-=f[c];
		}
	}
	if(b>0&&c==a+1){
		pas--;
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,max=0;
  	cin>>n;
  	
  	for(int i=1;i<34;i++){
      for(int j=2;j<11;j++){
		if(pow(i,j)<=n && pow(i,j)>max){
			max=pow(i,j);
        }
      }
    }
	 	
    cout<<max<<endl;
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    b_s = LI()
    c_s = LI()
    ans = 0
    for i in range(n):
        ans += b_s[a_s[i] - 1]
        if i > 0 and a_s[i-1] + 1 == a_s[i]:
            ans += c_s[a_s[i-1] - 1]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#define NIL -2000000001
int main(){
  int i,n;
  int A[502];
  scanf("%d",&n);

  for(i=0;i<502;i++){
    A[i]=NIL;
  }
 for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1)printf("parent key = %d, ",A[i/2]);
    if(A[2*i]!=NIL){
      printf("left key = %d, ",A[2*i]);
      if(A[2*i+1]!=NIL)printf("right key = %d, ",A[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var list1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
        int q = int.Parse(Console.ReadLine());
        var list2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x));

        var intersectList = list1.Intersect(list2);
        Console.WriteLine(intersectList.Count());


    }
}


Measured memory_bytes: 18268
import java.util.*;
public class Main{
  	public static void main (String [] args){
     	Scanner sc = new Scanner (System.in);
      	int N = sc.nextInt();
      	int count = 0;
      	for (int i = 0; i <= N; i++){
          	if (i%2 != 0){
          		int factorCount = 0;
              	for (int j = 1; j <= i; j++){
                  	if (i%j==0) factorCount++;
                }
              	if (factorCount == 8) count++;
            }
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 35700
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n, m ;
    cin >> n >> m ;
    n %= m ;
    cout << min(n, m-n) << endl ;
}
 
int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9;
const double eps = 1e-6;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll mul(ll a,ll b){ll ans=0;a%=mod,b%=mod;while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }return ans;}
ll powmod(ll a,ll b){ ll ans = 1, pow = a; while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; } return ans;}
//(b/a)%p=b*a^(p-2)%p
//int pr(ll num){//判素
//     if(num == 1) return 0;
//     if(num ==2|| num==3 ) return 1 ;
//     if(num %6!= 1&&num %6!= 5) return 0 ;
//     int tmp =sqrt( num);
//     for(int i= 5;i <=tmp; i+=6 )
//          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
//     return 1 ;
//}
int Day(int y,int m, int d){if(m==1||m==2) { m+=12; y--; }int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;return w+1;}
//int pri[10000005];
//void getpri(){
//    memset(pri,true,sizeof(pri));
//    pri[0]=pri[1]=0;
//    for(int i=2;i<=10000000;i++){
//        if(pri[i]){
//            for(int j=2*i;j<=10000000;j+=i) pri[j]=0;
//        }
//    }
//}
//struct ac{
//    int x,y;
//    int fa;
//} pre[10000005];
//void init(){
//    for(int i=1; i<=10000005;++i) pre[i].fa=i;
//}
//int getf(int x){
//    if(pre[x].fa == x) return x;
//    else return pre[x].fa = getf(pre[x].fa);
//}
//void join(int x,int y){
//    int a = getf(x);
//    int b = getf(y);
//    if(a!=b) pre[b].fa=a;
//}
//大小写转换
//String s;
//Form(s.begin(),s.end(),s.begin(),::toupper);
//Form(s.begin(),s.end(),s.begin(),::tolower);
//(char)toupper('a')
//(char)tolower('B')
//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec
//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址
const int maxn=2e5+5;
vector<int> v[maxn];
ll go[maxn]={0};
ll dfs(int x){
    if(go[x]) return go[x];
    if(v[x].size()==0){
        go[x]=1;
        return 1;
    }
    ll maxx=0;
    for(auto i:v[x]){
        maxx=max(maxx,dfs(i));
    }
    go[x]=maxx+1;
    return go[x];
}
int main(){
    IO;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    ll ans=0;
    for(int i=1;i<=n;++i){
        ans=max(ans,dfs(i));
        //cout<<dfs(i)<<endl;
    }
    cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 14204
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int n;
  cin>>n;
  vector<int> x(n*3);
  for(auto &&i : x) cin>>i;
  sort(x.begin(),x.end(),greater<int>());
  int ans = 0;
  for(int i=0;i<n;++i) ans += x[i*2+1];
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 5612
#include "stdio.h"
#include <iostream>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

int q[55][2][3];

long long int xx[111];
long long int yy[111];
long long int zz[111];

int w[111][111][111];

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	
	priority_queue<int,vector<int>,greater<int> > x,y,z;
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d %d %d %d %d %d",&q[i][0][0],&q[i][0][1],&q[i][0][2],&q[i][1][0],&q[i][1][1],&q[i][1][2]);
		x.push(q[i][0][0]);
		x.push(q[i][1][0]);
		y.push(q[i][0][1]);
		y.push(q[i][1][1]);
		z.push(q[i][0][2]);
		z.push(q[i][1][2]);
	}
	
	int xw = 0;
	int yw = 0;
	int zw = 0;
	int mae;
	mae = -1;
	while(x.empty() == false)
	{
		if(mae != x.top())
		{
			xx[xw] = x.top();
			mae = x.top();
			xw++;
		}
		x.pop();
	}
	mae = -1;
	while(y.empty() == false)
	{
		if(mae != y.top())
		{
			yy[yw] = y.top();
			mae = y.top();
			yw++;
		}
		y.pop();
	}
	mae = -1;
	while(z.empty() == false)
	{
		if(mae != z.top())
		{
			zz[zw] = z.top();
			mae = z.top();
			zw++;
		}
		z.pop();
	}
	
	for(int i = 0; i < xw; i++)
	{
		for(int ii = 0; ii < yw; ii++)
		{
			for(int iii = 0; iii < zw; iii++)
			{
				w[i][ii][iii] = 0;
			}
		}
	}
	
	for(int j = 0; j < n; j++)
	{
		for(int i = 0; i < xw; i++)
		{
			for(int ii = 0; ii < yw; ii++)
			{
				for(int iii = 0; iii < zw; iii++)
				{
					if(q[j][0][0] <= xx[i] && xx[i] < q[j][1][0] && q[j][0][1] <= yy[ii] && yy[ii] < q[j][1][1] && q[j][0][2] <= zz[iii] && zz[iii] < q[j][1][2])
					{
						w[i][ii][iii]++;
					}
				}
			}
		}
	}
	
	long long int all = 0;
	for(int i = 0; i < xw; i++)
	{
		for(int ii = 0; ii < yw; ii++)
		{
			for(int iii = 0; iii < zw; iii++)
			{
				if(w[i][ii][iii] >= k)
				{
					all += (xx[i + 1] - xx[i]) * (yy[ii + 1] - yy[ii]) * (zz[iii + 1] - zz[iii]);
				}
			}
		}
	}
	
	printf("%lld\n",all);
	
	return 0;
}

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

#define REP(i, a, b) for (int i = a; i < b; ++i)
#define MOD 1000000007
#define nline cout << "\n";
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int lli;
typedef vector<int> vi;
typedef vector<lli> vlli;

typedef pair<int, int> pi;
typedef pair<lli, lli> plli;

typedef vector<pi> vpii;
typedef vector<plli> vplli;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;

    while (t--)
    {
        string s, t;
        cin >> s >> t;
        int count = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] != t[i])
                count++;
        }
        cout << count;
    }

    return 0;
}


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

//要再提出

int main() {
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i]=i+1;//先頭の数列は1からNを昇順に。

    map<vector<int>,int> mp;
    do{
        mp[a]=mp.size();
    } while(next_permutation(a.begin(),a.end()));

    int ans=abs(mp[p]-mp[q]);

    cout << ans << endl;
}

Measured memory_bytes: 5248
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 2010
#define MO 924844033
#define LL long long
int d[MAXN*2][MAXN][2],f[MAXN],n,k,tot,fac[MAXN],ans;
bool vis[MAXN][2],ed[MAXN*2];
int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=1LL*i*fac[i-1]%MO;
	for(int i=1;i<=n;i++)
		for(int j=0;j<2;j++)
			if(!vis[i][j])
			{
				int cnt=0;
				for(int x=i,y=j;x<=n;x+=k,y^=1)
					vis[x][y]=1,cnt++;
				tot+=cnt;
				ed[tot]=1;
			}
	ed[0]=1;
	d[0][0][0]=1;
	for(int i=0;i<n*2;i++)
		for(int j=0;j<=n;j++)
		{
			d[i+1][j][0]=(d[i][j][0]+d[i][j][1])%MO;
			if(!ed[i])
				d[i+1][j+1][1]=d[i][j][0];
		}
	for(int i=0;i<=n;i++)
		f[i]=1LL*(d[n*2][i][0]+d[n*2][i][1])%MO*fac[n-i]%MO;
	for(int i=0,j=1;i<=n;j=-j,i++)
		(ans+=f[i]*j)%=MO;
	printf("%d\n",(ans%MO+MO)%MO);
}

Measured memory_bytes: 62976