akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, b = 0;
    ll z = 0;
    string s;
    cin >> n >> s;
    for (int i = 1; i <= n; i++) b += (s[i - 1] == 'B');
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (s[i - 1] == 'R' && s[j - 1] == 'G') {
        z += b;
        int d = abs(i - j);
        if (min(i, j) - d > 0 && s[min(i, j) - d - 1] == 'B') z--;
        if (max(i, j) + d <= n && s[max(i, j) + d - 1] == 'B') z--;
        if (i % 2 == j % 2 && s[(i + j) / 2 - 1] == 'B') z--;
    }
    cout << z;
}


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

using namespace std;

typedef long long int llint;

llint N, R;

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

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + (100 * (10 - N)) << endl;
	}
}

Measured memory_bytes: 256
# ある 3 日間の天気予報が、長さ 3 の文字列 S として与えられます。
# S の i (1≤i≤3) 文字目が S のとき、i 日目の天気予報が晴れだったことを、
# C のときは曇りだったことを、R のときは雨だったことを意味します。
# また 3 日間の実際の天気が、長さ 3 の文字列 T として与えられます。
# T の i (1≤i≤3) 文字目が S のとき、i 日目の実際の天気が晴れだったことを、
# C のときは曇りだったことを、R のときは雨だったことを意味します。
# 3 日間で天気予報が的中した日が何日あるかを出力してください。

s = gets
t = gets

count = 0
3.times do |i|
  if s[i] == t[i]
    count += 1
  end
end

puts count

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int N,K;
ll h[112345];
ll dp[112345];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>N>>K;
  repeat(i,N){
    cin>>h[i];
  }
  fill(dp+1,dp+N,INF);
  repeat(i,N){
    repeat(j,K){
      dp[i+1+j] = min(dp[i+1+j],dp[i]+abs(h[i+1+j]-h[i]));
    }
  }
  //debugArray(dp,N);
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m = n % 10;
  if (m == 2 or m == 4 or m == 5 or m == 7 or m == 9) {
    puts("hon");
  } else if (m == 0 or m == 1 or m == 6 or m == 8) {
    puts("pon");
  } else if (m == 3) {
    puts("bon");
  }
  return 0;
}


Measured memory_bytes: 3632
a,b=map(int,input().split())

def xor(n):
  z=n%4
  if z==0:
      return n
  elif z==1:
      return 1
  elif z==2:
      return n+1
  else:
      return 0


xxx=xor(b)^xor(a-1)

print(xxx)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


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

    if(n % 1000 == 0) cout << 0 << endl;
    else{
        int a = 1000;
        while(1){
            if(n > a) a += 1000;
            else{
                cout << a - n << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 3616
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

bool edge();
bool round();
int idx;

string str;

bool check()
{
    idx = 0;
    bool res = true;

    while(res && idx < str.length()) {
        if (str[idx] == '(') {
            idx++;
            res = res && round();
        }
        else if (str[idx] == '['){
            idx++;
            res = res && edge();
        }
        else if (str[idx] == ']' || str[idx] == ')') {
            return false;
        }
        idx++;
    }

    return res;
}

bool round()
{
    bool res = true;
    while(res && idx < str.length()) {
        if (str[idx] == ')') {
            return true;
        }
        else if (str[idx] == ']') {
            return false;
        }
        else if (str[idx] == '(') {
            idx++;
            res = res && round();
        }
        else if (str[idx] == '['){
            idx++;
            res = res && edge();
        }
        idx++;
    }

    return idx >= str.length() ? false : res;
}

bool edge()
{
    bool res = true;
    while(res && idx < str.length()) {
        if (str[idx] == ']'){
            return true;
        }
        else if (str[idx] == ')') {
            return false;
        }
        else if (str[idx] == '(') {
            idx++;
            res = res && round();
        }
        else if (str[idx] == '['){
            idx++;
            res = res && edge();
        }
        idx++;
    }

    return idx >= str.length() ? false : res;
}

void solve()
{
    while(getline(cin, str), !(str[0] == '.' && str.length() == 1)) {
        cout << (check() ? "yes" : "no") << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main()
{
    int n , x = 0 , maxi = 0;
    cin >> n ;
    char str1[n] ;
    for (int i = 0 ; i < n ; i++){
        cin >> str1[i];
        if (str1[i] == 'I' )
            x++;
        else
            x--;

        if (maxi < x )
           maxi = x ;
    }

    cout << maxi ;
 return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	int N; cin >> N;
	lli K; cin >> K;
	vector<pair<int, int>> S(N);
	rep(i, 0, N)cin >> S[i].first >> S[i].second;
	sort(S.begin(), S.end());
	int j = 0;
	int ans;
	while (K > 0) {
		ans = S[j].first;
		K -= S[j].second;
		j++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include <algorithm>
#include <cmath>
#include <vector>  
#define ll long long

int states = 4096;
int N_MAX = 12;
  
using namespace std; 

int convert_to_state(int* bit_map) {
    int multi = 1;
    int sum = 0;
    for (int i = 0; i < N_MAX; i++) {
        sum += multi * bit_map[i];
        multi *= 2;
    }
    return sum;
}

void set_zero(int* bit_map) {
    for (int i = 0; i < N_MAX; i++) {
        bit_map[i] = 0;
    } 
}

void print_array(ll* A, int n) {
    for (int i = 0; i < n; i++) {
        cout << A[i] << ' ';
    }
    cout << endl;
}

void print_array(int* A, int n) {
    for (int i = 0; i < n; i++) {
        cout << A[i] << ' ';
    }
    cout << endl;
}

int main() {
    int bit_map[N_MAX];
    ll cost[states];
    ll tmp_cost[states];
    for (int i = 0; i < states; i++) {
        cost[i] = -1;
    }
    cost[0] = 0;

    for (int i = 0; i < N_MAX; i++) {
        bit_map[i] = 0;
    } 

    int N, M;
    cin >> N >> M;
    int states_arr[M], moneys[M];
    // cout << &states_arr[1] << endl;
    for (int i = 0; i < M; i++) {
        int a, b, idx;
        cin >> a >> b;
        set_zero(bit_map);
        for (int j = 0; j < b; j++) {
            cin >> idx;
            bit_map[idx-1] = 1;
        }
        states_arr[i] = convert_to_state(bit_map);
        // print_array(states_arr, M);
        moneys[i] = a;
        // print_array(states_arr, M);
    }

    // print_array(moneys, M);


    int merge_state;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < states; j++) {
            tmp_cost[j] = cost[j];
        }
        for (int j = 0; j < states; j++) {
            if (cost[j] == -1) continue;
            merge_state = states_arr[i] | j;
            if (tmp_cost[merge_state] == -1) {
                tmp_cost[merge_state] = cost[j] + moneys[i];
            }
            else {
                tmp_cost[merge_state] = tmp_cost[merge_state] > (cost[j] + moneys[i]) ? 
                     (cost[j] + moneys[i]) : tmp_cost[merge_state];
            }
        }
        for (int j = 0; j < states; j++) {
            cost[j] = tmp_cost[j];
        }
        // print_array(cost, 4);
    }

    int target = 1;
    for (int i = 0; i < N; i++) target *= 2;
    target--;

    // print_array(cost, 4);
    cout << cost[target] << endl;

}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  string s;
  cin >> s;
  int n = s.size();

  for(int i=0; i<n; ++i){
    if(s[i]=='?') s[i]='D';
  }

  cout << s;

  return 0;
}

Measured memory_bytes: 3756
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  int ans = n - k + 1;


  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scs(a) scanf("%s", a)
#define pri(x) printf("%d\n", x)
#define prie(x) printf("%d ", x)
#define pris() printf("\n")
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define power(a,x) __gnu_cxx::power(a, x)
#define eps 1e-5
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const ld pi = acos(-1);
const int MOD = 1e9 + 7;

int main()
{
    BUFF;
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    cout<<setprecision(15)<<fixed;
    for (int i = 0; i < n; i++) {
        vector<double> angulos;
        for (int j = 0; j < n; j++)
        if (i != j)
            angulos.push_back(atan2(y[i] - y[j], x[i] - x[j]));
        sort(angulos.begin(),angulos.end());
        double mx = 0.0;
        for (int j = 0; j < angulos.size()-1; j++)
            mx = max(mx, angulos[j+1] - angulos[j]);
        mx=max((ld)mx,angulos[0] + 2*pi - angulos[angulos.size()-1]);
        if(mx>pi)cout<<(mx-pi)/(2*pi)<<endl;
        else cout<<0.0<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0225
//ユニオンファインド木
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
//int n;//単語の数
 
 
int par[26];
int r[26];//rank
 
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        r[i] = 0;
        par[i] = i;
    }
}
 
int root(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = root(par[x]);
    }
}
 
bool same(int x, int y)
{
    return root(x) == root(y);
}
 
void unite(int x, int y)
{
    x = root(x);
    y = root(y);
    if (x == y)
    {
        return;
    }
    if (r[x] < r[y])
    {
        par[x] = y;
    }
    else if (r[x] > r[y])
    {
        par[y] = x;
    }
    else if (r[x] == r[y])
    {
        par[x] = y;
        r[y]++;
    }
}
 
 
 
int main()
{
    int n;
 
    while (cin >> n, n)
    {
        init(26);
        vector<string>word(n);
        for (auto& s : word)
        {
            cin >> s;
        }
 
        vector<int> in(26), out(26);
        for (auto& s : word)
        {
            const auto first = s[0] - 'a', last = s.back() - 'a';//最初と最後の文字を取り出す　-'a'はa-zを0-25に対応させている
            in[first]++;//入次数
            out[last]++;//出次数
            unite(first, last);//頂点(アルファべット)first,lastが同じ集合に属する
        }
        bool ok = true;
        int comp_num = 0;//集合の数
        for (int i = 0; i < 26; i++)
        {
            comp_num += (in[i] && root(i) == i);
            ok &= in[i] == out[i];
        }
        ok &= (comp_num == 1);
        if (ok)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "NG" << endl;
        }
    }
 
 
    return 0;
}


Measured memory_bytes: 3636
N = gets.to_i
abc = N.times.map {gets.split.map &:to_i}

dp = Array.new(N + 1) {Array.new(3) {0}}
N.times do |i|
  3.times do |j|
    3.times do |k|
      if j != k
        res = dp[i][j] + abc[i][k]
        dp[i + 1][k] = res if dp[i + 1][k] < res
      end
    end
  end
end

puts dp[N].max

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

long knapsackdp(int N,int W, int *w, long *v)
{
    if(N==1)
        return (w[0]<=W)?v[0]:0;
    long dp[N+1][W+1];
    for(int i=0;i<=N;i++)
    {
        for(int j=0;j<=W;j++)
        {
            if(i==0||j==0)
            {
                dp[i][j]=0;
                continue;
            }
            dp[i][j]=max(dp[i-1][j],((j-w[i-1]>=0)?(v[i-1]+dp[i-1][j-w[i-1]]):INT_MIN));
        }
    }
    return dp[N][W];
}

int main() 
{
    int N,W;
    cin>>N>>W;
    int w[N];
    long v[N];
    for(int i=0;i<N;i++)
        cin>>w[i]>>v[i];
    cout<<knapsackdp(N,W,w,v)<<endl;

}


Measured memory_bytes: 82360
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

map<string, int> blueCard;
map<string, int> redCard;

int main(int argc, char const *argv[])
{
  int N,M;
  string s;

  cin >> N;
  REP(N) {
    cin >> s;
    if(blueCard.count(s) == 0) blueCard[s] = 0;
    blueCard[s]++;
  }

  cin >> M;
  REP(M) {
    cin >> s;
    if(redCard.count(s) == 0) redCard[s] = 0;
    redCard[s]++;
  }

  int ans = 0;
  for(auto kv : blueCard) {
    ans = max(ans, kv.second - redCard[kv.first]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
var
	n,i:Longint;
	s,L,R,M,a,b:int64;
	h:array[1..100000]of int64;
begin
	read(n,a,b);
	for i:=1 to n do read(h[i]);
	R:=1000000000;
	while R-L>1 do begin
		M:=(L+R)div 2;
		s:=0;
		for i:=1 to n do begin
			if M*b<h[i]then s:=s+(h[i]-M*b+a-b-1)div(a-b);
		end;
		if s>M then L:=M else R:=M;
	end;
	writeln(R);
end.


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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, K;
    scan(A, B, K);
    long a, b;
    a = max(A - K, 0);
    K = max(K - A, 0);
    b = max(B - K, 0);
    writeln(a, " ", b);
}


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

int main(){
    int dp[110][10010] = {0};
    int v[110], w[110];
    int N, W;

    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> v[i] >> w[i];

    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7404
//************************
//*  Date: 2018.10.22    *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair<LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,m,li,ri,k;
LL pos[100010];
vector <pii> g[100010];

void dfs(LL pos1,LL coo)
{
	if(pos[pos1]!=1e18&&pos[pos1]!=coo)
	{
		puts("No");
		exit(0);
	}
	if(pos[pos1]!=1e18) return;
	pos[pos1]=coo;
	rep(i,g[pos1].size()) dfs(g[pos1][i].fi,coo+g[pos1][i].se);
}

int main()
{
	cin>>n>>m;
	rep(i,100005) pos[i]=1e18;
	rep(i,m)
	{
		scanf("%d%d%d",&li,&ri,&k);
		g[li].pb({ri,k});
		g[ri].pb({li,-k});
	}
	repn(i,n)
	{
		if(pos[i]==1e18) dfs(i,0);
	}
	puts("Yes");
	rt0;
}

Measured memory_bytes: 16512
#include <iostream>
using namespace std;
int s[210];
int v[110];
int main()
{
	long long n;
	cin >> n;
	n ++;
	int ans = 0;
	int k = -1;
	while(n)

	{
		v[++ k] = n % 2;
		n /= 2;
	}
	for(int i = 1;i <= k;i ++)
		s[2 * i] = 1;
	for(int i = 0,j = 2 * k + 1;i < k;i ++,j -= 2)
		if(v[i])
			s[j] = 1;
	for(int i = 1;i <= 2 * k + 1;i ++)
		if(s[i])
			ans ++;
	cout << ans * 2 << endl;
	for(int i = 2 * k + 1;i > 0;i -= 2)
		if(s[i])
			cout << i << ' ';
	for(int i = 1;i <= k;i ++)
		cout << 2 * i << ' ';
	for(int i = 1;i <= 2 * k + 1;i ++)
		if(s[i])
			cout << i << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <numeric>
#include <time.h>
#include <stack>
#include <bitset>

#define prev asasddlsa
#define rank aljds

#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i++)
 
using namespace std;
 
typedef long long ll;
typedef double dbl;
 
template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << " ";
    cout << endl;
}
 
template<class T>   
void print(const T* s, int n){
    for (int i = 0; i < n; i++)
        cout << s[i] << ' ';
    cout << endl;
}

template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

const int maxn = 2001;

vector<int> s[maxn];
bitset<maxn> ok[maxn];

int dist[maxn];

void bfs(int v, int n){
    fill(dist, dist + n, n);
    dist[v] = 0;
    vector<int> q{v};
    int cur = 0;
    while (cur < q.size()){
        v = q[cur++];
        for (int u : s[v]){
            if (dist[u] > dist[v] + 1){
                q.push_back(u);
                dist[u] = dist[v] + 1;
            }
        }
    }
}

int solve(){
    int n, k;
    cin >> n >> k;
    for (int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        s[a - 1].push_back(b - 1);
        s[b - 1].push_back(a - 1);
    }
    int res = -1;
    for (int i = 0; i < n; i++){
        bfs(i, n);
        for (int j = 0; j < n; j++){
            if (dist[j] <= k)
                ok[i].set(j);
        }
        // print(dist, n);
        for (int j = 0; j < i; j++){
            if (dist[j] == k && j < i)
                res = max(res, (int)(ok[i] & ok[j]).count());
        }
    }
    if (res == -1)
        res = n;
    cout << n - res << endl;
    return 0;
}

int main(){
    srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(10);
    cout << fixed; 
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 4276
#include <iostream>
using namespace std;
int main(){
    int a,b,c;

    cin >> a >> b >> c;

    if(a <= b && b <= c)cout << a << " " << b << " "<< c << endl;
    else if(b <= a && a <= c) cout << b<< " " << a<< " " << c << endl;
    else if(a <= c && c <= b) cout << a<< " " << c<< " " << b << endl;
    else if(b <= c && c <= a) cout << b<< " " << c<< " " << a << endl;
    else if(c <= b && b <= a) cout << c<< " " << b<< " " << a << endl;
    else if(c <= a && a <= b) cout << c<< " " << a << " " <<b << endl;

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi cnt(9, 0);
	int n;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		if (a >= 3200)a = 3200;
		cnt[a / 400]++;
	}
	int ans = 0;
	REP(i, 8) {
		if (cnt[i] > 0)ans++;
	}

	if(ans==0)cout <<1  << " " << ans + cnt[8] << endl;
	else cout << ans << " " << ans + cnt[8] << endl;
	return 0;
}


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

using namespace std;


int main(){
    int n;
    cin >> n;
    string a="";
    string b="";
    set<string> s;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a=="insert"){
            s.insert(b);
        }
        if(a=="find"){
            if( s.find( b ) == s.end() ){
                cout << "no" << endl;
            }else{
                cout << "yes" << endl;
            }        
        }
    }
    return 0;
}


Measured memory_bytes: 32552
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    ll res = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            res += i;
        }
    }
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



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

int main(){
  int a,b;
  cin >> a >>  b;
  int A = a;
  int B = b;
  string x = to_string(a);
  string y = to_string(b);
  string X = x;
  string Y = y;
   while(B > 1){
     x += X;
     B--;
   }
  while(A > 1){
    y += Y;
     A--;
   }
  vector<string> c(2);
  c[0] = x;
  c[1] = y;
  sort(c.begin(), c.end());
  cout << c[0] << endl;
}

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

const int INIT = -1;
vector<vector<int>> edge;
vector<int> dp;

int calc(int id)
{
    if (dp[id] != INIT)
        return dp[id];

    for (int i = 0; i < (int)edge[id].size(); i++) {
        dp[edge[id][i]] = calc(edge[id][i]);
    }

    int length = 0;
    for (int i = 0; i < (int)edge[id].size(); i++) {
        length = max(length, dp[edge[id][i]] + 1);
    }

    return length;
}

int main(void)
{
    int N, M;
    cin >> N >> M;

    edge = vector<vector<int>>(N, vector<int>());

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;

        x--;
        y--;

        edge[y].push_back(x);
    }

    dp = vector<int>(N, INIT);
    for (int i = 0; i < N; i++) {
        dp[i] = calc(i);
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;

    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string weather;
 cin >> weather;
  
  if(weather == "RRR"){
    cout << "3" << endl;}
  else if(weather == "SRR" || weather == "RRS"){
    cout << "2" << endl;}
  else if(weather == "RSR" || weather == "SSR" || weather == "SRS" || weather == "RSS"){
    cout << "1" << endl;}
  else{ cout << "0" << endl;}
  
}

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

int main(){
	int n, maxw;
	cin>>n>>maxw;
	int w[n+1], v[n+1];
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	long long int dp[n+1][maxw+1];
	for (int i=0;i<=maxw;i++){
		dp[0][i] = 0;
	}
	for(int i=0;i<=n;i++){
		dp[i][0] = 0;
	}	
	for (int i=1;i<=n;i++){
		for (int j=1;j<=maxw;j++){
			if (j >= w[i]){
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
			}
			else
				dp[i][j]= dp[i-1][j];
		}
	}
	// for (int i=0;i<=n;i++){
	// 	for (int j=0;j<=maxw;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cout<<dp[n][maxw];
}

Measured memory_bytes: 79104
awk 'function tobin(x, n) {
    s = ""
    for (i = 0; i < n; ++i) {
        s = (x % 2) s
        x = int(x / 2)
    }
    return s
}
NR == 1 {
    n = $1
    m = $2
}
NR > 1 && NR <= m + 1 {
    for (i=2; i<=$1 + 1; ++i) {
        sw[(NR-1) ";" $i] = 1
    }
}
NR > m + 1 {
    split($0, p)

    for (I=0; I < (2 ^ n); ++I) {
        ok = 1
        iset = tobin(I, n)
        # print "[" iset "]"
        for (j = 1; j <= m; ++j) {
            status = p[j]
            for (i=1; i <= n; ++i) {
                if (sw[j ";" i] && substr(iset, i, 1) == "1") {
                    status++
                }
            }
            if (status % 2 == 1) ok = 0
        }
        if (ok) ++ans;
    }

    print+ans
}'

Measured memory_bytes: 548
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



int main(){
    int a,b;
    
    cin >> a >> b;
    if (a>=b){
        rep(i,a){
            cout << b;
        }
    }
    else{
        rep(i,b) cout << a;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll h,w ; cin >> h >> w;
    if (h == 1 or w == 1) cout << 1 << endl;
    else {
        ll res = ceil((double)h*w/2);
        cout << res << endl;
    }
}


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

constexpr int kMaxN = 300 + 3;

int main() {
    int n;
    scanf("%d", &n);

    static int distance[kMaxN][kMaxN];

    for (int i = 0; i < n; i += 1) {
        for (int j = 0; j < n; j += 1) {
            scanf("%d", distance[i] + j);
        }
    }

    static bool necessary[kMaxN][kMaxN];
    memset(necessary, 1, sizeof(necessary));

    bool bad = false;
    for (int u = 0; u < n; u += 1) {
        for (int v = 0; v < u; v += 1) {
            int d = distance[u][v];
            for (int w = 0; w < n; w += 1) {
                if (w == u || w == v) {
                    continue;
                }
                int add = distance[u][w] + distance[w][v];
                if (d == add) {
                    necessary[u][v] = false;
                } else if (d > add) {
                    bad = true;
                }
            }
        }
    }

    if (bad) {
        std::cout << -1 << std::endl;
    } else {
        int64_t total = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < i; ++j) {
                if (not necessary[i][j]) {
                    continue;
                }
                total += distance[i][j];
            }
        }
        std::cout << total << std::endl;
    }
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

class UnionFind {
public:
    UnionFind(int n) : parent(n, -1), rank(n) {}

    int find(int x) {
        if (parent[x] < 0) {
            return x;
        } else {
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            parent[y] += parent[x];
            parent[x] = y;
        } else {
            parent[x] += parent[y];
            parent[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

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

    int size(int x) {
        return -parent[find(x)];
    }

private:
    vector<int> parent;
    vector<int> rank;
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (uf.find(i) == i) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	ll n, k;
	cin >> n >> k;
	ll a[n + 1];
	for (ll i = 1; i <= n; i++)
		cin >> a[i];
	ll vis[n + 1] = {0};
	vis[1] = 1;
	ll temp = 1;
	vector<ll>v;
	v.push_back(1);
	ll pos = 0;
	for (ll i = 1; i <= n; i++)
	{
		if (vis[a[temp]])
		{
			pos = a[temp];
			break;
		}
		else
		{
			vis[a[temp]] = 1;
			v.push_back(a[temp]);
			temp = a[temp];
		}
		//cout << temp << " ";
	}
	ll z;
	for (ll i = 0; i < v.size(); i++)
	{
		if (v[i] == pos)
		{
			z = i;
			break;
		}
	}
	vector<ll>v2;
	for (ll i = z; i < v.size(); i++)
		v2.push_back(v[i]);
	ll s = v2.size();
	// for (int i = 0; i < v2.size(); i++)
	// 	cout << v2[i] << " ";
	if (k < z)
		cout << v[k] << endl;
	else
	{
		k -= z;
		cout << v2[ k % s] << endl;
	}
}


Measured memory_bytes: 10828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int d,t,s;
	cin>>d>>t>>s;
	if(d <= s * t)
	cout<<"Yes\n";
	else cout<<"No\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(auto &e: a) cin >> e, e--;
    for(auto &e: b) cin >> e, e--;


    vector<ll> ac(n), bc(n);
    for(auto &e: a) ac[e]++;
    for(auto &e: b) bc[e]++;

    vector<ll> cc(n);
    vector<vector<ll>> res(n);

    priority_queue<tuple<ll,ll>> q, r;
    for(ll i=0; i<n; i++) {
        if(bc[i]) q.push({ac[i]+bc[i], i}); 
        if(ac[i]) r.push({ac[i]+bc[i], i}); 
    }

    while(!q.empty()) {
        ll i = get<1>(q.top()); q.pop();

        if(r.empty()) {
            cout << "No" << endl;
            return 0;
        }

        ll j = get<1>(r.top()); r.pop();
        if(i == j) {
            if(r.empty()) {
                cout << "No" << endl;
                return 0;
            }
            ll jj = get<1>(r.top()); r.pop();
            r.push({(bc[j]+ac[j]), j}); 
            j = jj;
        }

        res[j].push_back(i); bc[i]--, ac[j]--;

        if(bc[i]) q.push({(bc[i]+ac[i]), i}); 
        if(ac[j]) r.push({(bc[j]+ac[j]), j}); 
    }

    cout << "Yes" << endl;
    for(auto &v: res) for(auto &e: v) cout << e+1 << ' ';
    cout << endl;
}

Measured memory_bytes: 28268
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: usize, b: usize);
    let mut s = 0usize;
    for _ in 0..(n - 2) {
        parse!(it, x: usize);
        s ^= x;
    }
    let mut memo = HashMap::new();
    let ret = f(a, b, s, &mut memo)
        .map(|x| if x >= a { -1 } else { x as i64 })
        .unwrap_or(-1);
    println!("{}", ret);
}

// (a-d) ^ (b+d) == xを満たす最小のdを返す
fn f(
    a: usize,
    b: usize,
    x: usize,
    memo: &mut HashMap<(usize, usize, usize), Option<usize>>,
) -> Option<usize> {
    let key = (a, b, x);
    // メモ処理
    if let Some(&ret) = memo.get(&key) {
        return ret;
    }

    // 1桁目を見て、a^b == xとならないなら条件を満たすdは存在しない
    let ret = if (a ^ b ^ x) & 1 == 1 {
        None
    } else if x == 0 {
        // x==0なら、a ^ b == 0 <=> a == bとなる
        if a < b {
            None
        } else {
            Some((a - b) / 2)
        }
    } else if a == 0 {
        // a == 0なら, a^b == x <=> b==x
        if b != x {
            None
        } else {
            Some(0)
        }
    } else {
        // 適当に処理した後、2桁目よりを見ていく
        // 1桁目から何も移動しない場合
        let c = f(a >> 1, b >> 1, x >> 1, memo).map(|x| x * 2);
        // 1桁目から1だけ移動する場合
        let d = f((a - 1) >> 1, (b + 1) >> 1, x >> 1, memo).map(|x| x * 2 + 1);
        let ret = match (c, d) {
            (c, None) => c,
            (None, d) => d,
            (Some(c), Some(d)) => Some(min(c, d)),
        };
        ret
    };
    memo.insert(key, ret);
    ret
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int main() {
    string S;
    cin >> S;
    
    int p = 0, m = 0;
    for (int i=0; i<4; i++) {
        if (S[i] == '+') p++;
        else m++;
    }
    
    cout << p - m << endl;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<int> divisors;
	for(int i = 1; i <= sqrt(m) + 1; ++i){
		if(m % i == 0)divisors.push_back(i), divisors.push_back(m / i);
	}
	sort(begin(divisors), end(divisors));
	while(!divisors.empty()){
		int d = divisors.back(); divisors.pop_back();
		if(m / d >= n){
			cout << d << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll n;
  cin>>n;
  vector<int> ab(n+1);
  vin x(n+1);
  map<int,int> y;
  rep(i,0,n){
   // int ab;
    cin>>ab[i+1];
    //a[i+1]=make_pair(i+1,ab);//1 index
    x[i+1]=i+1+ab[i+1];
    y[i+1-ab[i+1]]++;
  }
  
  
  //////////
  ll ans=0;
  
  rep(i,1,n+1){
    if(y[x[i]]>0){
     y[x[i]-2*ab[i]]--;
      ans+=y[x[i]];
     // cout<<x[i]<<endl;
    }
   // cout<<x[i]<<endl;
  }
  
  
  
  
  
  
  
  
  
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 21852
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n,a[55],b[55],x=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}	
	sort(b+1,b+n+1);

	for(i=1;i<=n;i++){
		if(a[i]!=b[i])	x++;
	}
	if(x<=2)	cout<<"YES";
	else	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
    int h,a;

    scanf("%d%d", &h, &a);
    if (h%a == 0) {
        printf("%d\n", h/a);
    } else {
        printf("%d\n", h/a+1);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	long long n,a,b;
  	cin>>n>>a>>b;
  	if((b-a)&1)
    {
      long long a1=min(b-1,n-a);
      long long a2=a+(b-a-1)/2;
      a1=min(a1,a2);
      a2=n-b+1+(n-(a+n-b+1))/2;
      a1=min(a1,a2);
      cout<<a1;
    }
  	else
      cout<<(b-a)/2;
}

Measured memory_bytes: 256